aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/acpi-hotkey.txt2
-rw-r--r--Documentation/ibm-acpi.txt376
-rw-r--r--arch/i386/Kconfig1
-rw-r--r--arch/i386/defconfig4
-rw-r--r--arch/i386/kernel/Makefile2
-rw-r--r--arch/i386/kernel/acpi/Makefile2
-rw-r--r--arch/i386/kernel/acpi/boot.c557
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c40
-rw-r--r--arch/i386/kernel/acpi/sleep.c35
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c57
-rw-r--r--arch/i386/kernel/io_apic.c4
-rw-r--r--arch/i386/kernel/mpparse.c14
-rw-r--r--arch/i386/kernel/setup.c10
-rw-r--r--arch/i386/mach-es7000/es7000plat.c4
-rw-r--r--arch/i386/pci/Makefile2
-rw-r--r--arch/i386/pci/irq.c2
-rw-r--r--arch/ia64/Kconfig32
-rw-r--r--arch/ia64/configs/bigsur_defconfig6
-rw-r--r--arch/ia64/configs/sn2_defconfig7
-rw-r--r--arch/ia64/configs/tiger_defconfig7
-rw-r--r--arch/ia64/configs/zx1_defconfig7
-rw-r--r--arch/ia64/defconfig6
-rw-r--r--arch/ia64/kernel/acpi-ext.c37
-rw-r--r--arch/ia64/kernel/acpi.c328
-rw-r--r--arch/ia64/kernel/iosapic.c22
-rw-r--r--arch/ia64/kernel/setup.c4
-rw-r--r--arch/ia64/kernel/topology.c2
-rw-r--r--arch/ia64/sn/kernel/irq.c2
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_proc_fs.c2
-rw-r--r--arch/x86_64/Kconfig2
-rw-r--r--arch/x86_64/defconfig4
-rw-r--r--arch/x86_64/kernel/Makefile2
-rw-r--r--arch/x86_64/kernel/acpi/Makefile4
-rw-r--r--arch/x86_64/kernel/acpi/sleep.c17
-rw-r--r--arch/x86_64/kernel/genapic.c4
-rw-r--r--arch/x86_64/kernel/io_apic.c4
-rw-r--r--arch/x86_64/kernel/mpparse.c14
-rw-r--r--arch/x86_64/kernel/setup.c8
-rw-r--r--arch/x86_64/pci/Makefile2
-rw-r--r--arch/x86_64/pci/Makefile-BUS2
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/Kconfig83
-rw-r--r--drivers/acpi/Makefile14
-rw-r--r--drivers/acpi/ac.c138
-rw-r--r--drivers/acpi/acpi_memhotplug.c176
-rw-r--r--drivers/acpi/asus_acpi.c690
-rw-r--r--drivers/acpi/battery.c400
-rw-r--r--drivers/acpi/blacklist.c122
-rw-r--r--drivers/acpi/bus.c310
-rw-r--r--drivers/acpi/button.c274
-rw-r--r--drivers/acpi/container.c128
-rw-r--r--drivers/acpi/debug.c115
-rw-r--r--drivers/acpi/dispatcher/dsfield.c346
-rw-r--r--drivers/acpi/dispatcher/dsinit.c141
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c404
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c424
-rw-r--r--drivers/acpi/dispatcher/dsobject.c330
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c723
-rw-r--r--drivers/acpi/dispatcher/dsutils.c421
-rw-r--r--drivers/acpi/dispatcher/dswexec.c519
-rw-r--r--drivers/acpi/dispatcher/dswload.c522
-rw-r--r--drivers/acpi/dispatcher/dswscope.c139
-rw-r--r--drivers/acpi/dispatcher/dswstate.c668
-rw-r--r--drivers/acpi/ec.c1028
-rw-r--r--drivers/acpi/event.c76
-rw-r--r--drivers/acpi/events/evevent.c168
-rw-r--r--drivers/acpi/events/evgpe.c427
-rw-r--r--drivers/acpi/events/evgpeblk.c767
-rw-r--r--drivers/acpi/events/evmisc.c293
-rw-r--r--drivers/acpi/events/evregion.c582
-rw-r--r--drivers/acpi/events/evrgnini.c315
-rw-r--r--drivers/acpi/events/evsci.c77
-rw-r--r--drivers/acpi/events/evxface.c444
-rw-r--r--drivers/acpi/events/evxfevnt.c465
-rw-r--r--drivers/acpi/events/evxfregn.c114
-rw-r--r--drivers/acpi/executer/exconfig.c351
-rw-r--r--drivers/acpi/executer/exconvrt.c311
-rw-r--r--drivers/acpi/executer/excreate.c342
-rw-r--r--drivers/acpi/executer/exdump.c793
-rw-r--r--drivers/acpi/executer/exfield.c253
-rw-r--r--drivers/acpi/executer/exfldio.c644
-rw-r--r--drivers/acpi/executer/exmisc.c358
-rw-r--r--drivers/acpi/executer/exmutex.c160
-rw-r--r--drivers/acpi/executer/exnames.c236
-rw-r--r--drivers/acpi/executer/exoparg1.c574
-rw-r--r--drivers/acpi/executer/exoparg2.c317
-rw-r--r--drivers/acpi/executer/exoparg3.c167
-rw-r--r--drivers/acpi/executer/exoparg6.c127
-rw-r--r--drivers/acpi/executer/exprep.c381
-rw-r--r--drivers/acpi/executer/exregion.c280
-rw-r--r--drivers/acpi/executer/exresnte.c172
-rw-r--r--drivers/acpi/executer/exresolv.c284
-rw-r--r--drivers/acpi/executer/exresop.c398
-rw-r--r--drivers/acpi/executer/exstore.c417
-rw-r--r--drivers/acpi/executer/exstoren.c125
-rw-r--r--drivers/acpi/executer/exstorob.c86
-rw-r--r--drivers/acpi/executer/exsystem.c183
-rw-r--r--drivers/acpi/executer/exutils.c173
-rw-r--r--drivers/acpi/fan.c142
-rw-r--r--drivers/acpi/glue.c9
-rw-r--r--drivers/acpi/hardware/hwacpi.c116
-rw-r--r--drivers/acpi/hardware/hwgpe.c203
-rw-r--r--drivers/acpi/hardware/hwregs.c600
-rw-r--r--drivers/acpi/hardware/hwsleep.c415
-rw-r--r--drivers/acpi/hardware/hwtimer.c77
-rw-r--r--drivers/acpi/hotkey.c233
-rw-r--r--drivers/acpi/ibm_acpi.c1598
-rw-r--r--drivers/acpi/motherboard.c108
-rw-r--r--drivers/acpi/namespace/nsaccess.c355
-rw-r--r--drivers/acpi/namespace/nsalloc.c350
-rw-r--r--drivers/acpi/namespace/nsdump.c461
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c74
-rw-r--r--drivers/acpi/namespace/nseval.c274
-rw-r--r--drivers/acpi/namespace/nsinit.c257
-rw-r--r--drivers/acpi/namespace/nsload.c264
-rw-r--r--drivers/acpi/namespace/nsnames.c118
-rw-r--r--drivers/acpi/namespace/nsobject.c209
-rw-r--r--drivers/acpi/namespace/nsparse.c84
-rw-r--r--drivers/acpi/namespace/nssearch.c205
-rw-r--r--drivers/acpi/namespace/nsutils.c502
-rw-r--r--drivers/acpi/namespace/nswalk.c105
-rw-r--r--drivers/acpi/namespace/nsxfeval.c430
-rw-r--r--drivers/acpi/namespace/nsxfname.c173
-rw-r--r--drivers/acpi/namespace/nsxfobj.c91
-rw-r--r--drivers/acpi/numa.c125
-rw-r--r--drivers/acpi/osl.c695
-rw-r--r--drivers/acpi/parser/Makefile2
-rw-r--r--drivers/acpi/parser/psargs.c376
-rw-r--r--drivers/acpi/parser/psloop.c874
-rw-r--r--drivers/acpi/parser/psopcode.c739
-rw-r--r--drivers/acpi/parser/psparse.c1080
-rw-r--r--drivers/acpi/parser/psscope.c130
-rw-r--r--drivers/acpi/parser/pstree.c92
-rw-r--r--drivers/acpi/parser/psutils.c134
-rw-r--r--drivers/acpi/parser/pswalk.c26
-rw-r--r--drivers/acpi/parser/psxface.c251
-rw-r--r--drivers/acpi/pci_bind.c220
-rw-r--r--drivers/acpi/pci_irq.c275
-rw-r--r--drivers/acpi/pci_link.c482
-rw-r--r--drivers/acpi/pci_root.c130
-rw-r--r--drivers/acpi/power.c271
-rw-r--r--drivers/acpi/processor_core.c444
-rw-r--r--drivers/acpi/processor_idle.c315
-rw-r--r--drivers/acpi/processor_perflib.c297
-rw-r--r--drivers/acpi/processor_thermal.c153
-rw-r--r--drivers/acpi/processor_throttling.c133
-rw-r--r--drivers/acpi/resources/rsaddr.c873
-rw-r--r--drivers/acpi/resources/rscalc.c314
-rw-r--r--drivers/acpi/resources/rscreate.c297
-rw-r--r--drivers/acpi/resources/rsdump.c847
-rw-r--r--drivers/acpi/resources/rsio.c172
-rw-r--r--drivers/acpi/resources/rsirq.c251
-rw-r--r--drivers/acpi/resources/rslist.c279
-rw-r--r--drivers/acpi/resources/rsmemory.c218
-rw-r--r--drivers/acpi/resources/rsmisc.c230
-rw-r--r--drivers/acpi/resources/rsutils.c159
-rw-r--r--drivers/acpi/resources/rsxface.c182
-rw-r--r--drivers/acpi/scan.c437
-rw-r--r--drivers/acpi/sleep/poweroff.c2
-rw-r--r--drivers/acpi/sleep/proc.c269
-rw-r--r--drivers/acpi/sleep/wakeup.c115
-rw-r--r--drivers/acpi/system.c76
-rw-r--r--drivers/acpi/tables.c434
-rw-r--r--drivers/acpi/tables/tbconvrt.c408
-rw-r--r--drivers/acpi/tables/tbget.c275
-rw-r--r--drivers/acpi/tables/tbgetall.c189
-rw-r--r--drivers/acpi/tables/tbinstal.c264
-rw-r--r--drivers/acpi/tables/tbrsdt.c231
-rw-r--r--drivers/acpi/tables/tbutils.c178
-rw-r--r--drivers/acpi/tables/tbxface.c253
-rw-r--r--drivers/acpi/tables/tbxfroot.c513
-rw-r--r--drivers/acpi/thermal.c801
-rw-r--r--drivers/acpi/toshiba_acpi.c174
-rw-r--r--drivers/acpi/utilities/Makefile2
-rw-r--r--drivers/acpi/utilities/utalloc.c713
-rw-r--r--drivers/acpi/utilities/utcache.c305
-rw-r--r--drivers/acpi/utilities/utcopy.c592
-rw-r--r--drivers/acpi/utilities/utdebug.c400
-rw-r--r--drivers/acpi/utilities/utdelete.c431
-rw-r--r--drivers/acpi/utilities/uteval.c396
-rw-r--r--drivers/acpi/utilities/utglobal.c653
-rw-r--r--drivers/acpi/utilities/utinit.c135
-rw-r--r--drivers/acpi/utilities/utmath.c144
-rw-r--r--drivers/acpi/utilities/utmisc.c1175
-rw-r--r--drivers/acpi/utilities/utmutex.c354
-rw-r--r--drivers/acpi/utilities/utobject.c354
-rw-r--r--drivers/acpi/utilities/utstate.c333
-rw-r--r--drivers/acpi/utilities/utxface.c278
-rw-r--r--drivers/acpi/utils.c195
-rw-r--r--drivers/acpi/video.c1076
-rw-r--r--drivers/char/hpet.c8
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c9
-rw-r--r--drivers/char/tpm/Kconfig2
-rw-r--r--drivers/pci/hotplug/Kconfig4
-rw-r--r--drivers/pci/hotplug/Makefile4
-rw-r--r--drivers/pnp/Kconfig2
-rw-r--r--drivers/pnp/pnpacpi/Kconfig2
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c75
-rw-r--r--drivers/serial/8250_acpi.c20
-rw-r--r--drivers/serial/Kconfig2
-rw-r--r--include/acpi/acconfig.h29
-rw-r--r--include/acpi/acdebug.h259
-rw-r--r--include/acpi/acdisasm.h322
-rw-r--r--include/acpi/acdispat.h405
-rw-r--r--include/acpi/acevents.h241
-rw-r--r--include/acpi/acexcep.h34
-rw-r--r--include/acpi/acglobal.h271
-rw-r--r--include/acpi/achware.h107
-rw-r--r--include/acpi/acinterp.h626
-rw-r--r--include/acpi/aclocal.h722
-rw-r--r--include/acpi/acmacros.h145
-rw-r--r--include/acpi/acnames.h13
-rw-r--r--include/acpi/acnamesp.h357
-rw-r--r--include/acpi/acobject.h390
-rw-r--r--include/acpi/acopcode.h6
-rw-r--r--include/acpi/acoutput.h10
-rw-r--r--include/acpi/acparser.h255
-rw-r--r--include/acpi/acpi.h35
-rw-r--r--include/acpi/acpi_bus.h334
-rw-r--r--include/acpi/acpi_drivers.h40
-rw-r--r--include/acpi/acpiosxf.h264
-rw-r--r--include/acpi/acpixf.h408
-rw-r--r--include/acpi/acresrc.h309
-rw-r--r--include/acpi/acstruct.h221
-rw-r--r--include/acpi/actables.h121
-rw-r--r--include/acpi/actbl.h282
-rw-r--r--include/acpi/actbl1.h141
-rw-r--r--include/acpi/actbl2.h260
-rw-r--r--include/acpi/actbl71.h148
-rw-r--r--include/acpi/actypes.h807
-rw-r--r--include/acpi/acutils.h718
-rw-r--r--include/acpi/amlcode.h172
-rw-r--r--include/acpi/amlresrc.h380
-rw-r--r--include/acpi/container.h3
-rw-r--r--include/acpi/pdc_intel.h4
-rw-r--r--include/acpi/platform/acenv.h70
-rw-r--r--include/acpi/platform/acgcc.h10
-rw-r--r--include/acpi/platform/aclinux.h15
-rw-r--r--include/acpi/processor.h238
-rw-r--r--include/asm-i386/acpi.h20
-rw-r--r--include/asm-i386/fixmap.h2
-rw-r--r--include/asm-i386/io_apic.h4
-rw-r--r--include/asm-i386/mpspec.h4
-rw-r--r--include/asm-ia64/acpi-ext.h1
-rw-r--r--include/asm-x86_64/acpi.h27
-rw-r--r--include/asm-x86_64/io_apic.h2
-rw-r--r--include/asm-x86_64/mpspec.h2
-rw-r--r--include/linux/acpi.h45
-rw-r--r--kernel/power/Kconfig1
249 files changed, 28665 insertions, 32031 deletions
diff --git a/Documentation/acpi-hotkey.txt b/Documentation/acpi-hotkey.txt
index 0acdc80c30c2..744f1aec6553 100644
--- a/Documentation/acpi-hotkey.txt
+++ b/Documentation/acpi-hotkey.txt
@@ -35,4 +35,4 @@ created. Please use command "cat /proc/acpi/hotkey/polling_method"
35to retrieve it. 35to retrieve it.
36 36
37Note: Use cmdline "acpi_generic_hotkey" to over-ride 37Note: Use cmdline "acpi_generic_hotkey" to over-ride
38loading any platform specific drivers. 38platform-specific with generic driver.
diff --git a/Documentation/ibm-acpi.txt b/Documentation/ibm-acpi.txt
index c437b1aeff55..8b3fd82b2ce7 100644
--- a/Documentation/ibm-acpi.txt
+++ b/Documentation/ibm-acpi.txt
@@ -1,16 +1,16 @@
1 IBM ThinkPad ACPI Extras Driver 1 IBM ThinkPad ACPI Extras Driver
2 2
3 Version 0.8 3 Version 0.12
4 8 November 2004 4 17 August 2005
5 5
6 Borislav Deianov <borislav@users.sf.net> 6 Borislav Deianov <borislav@users.sf.net>
7 http://ibm-acpi.sf.net/ 7 http://ibm-acpi.sf.net/
8 8
9 9
10This is a Linux ACPI driver for the IBM ThinkPad laptops. It aims to 10This is a Linux ACPI driver for the IBM ThinkPad laptops. It supports
11support various features of these laptops which are accessible through 11various features of these laptops which are accessible through the
12the ACPI framework but not otherwise supported by the generic Linux 12ACPI framework but not otherwise supported by the generic Linux ACPI
13ACPI drivers. 13drivers.
14 14
15 15
16Status 16Status
@@ -25,9 +25,14 @@ detailed description):
25 - ThinkLight on and off 25 - ThinkLight on and off
26 - limited docking and undocking 26 - limited docking and undocking
27 - UltraBay eject 27 - UltraBay eject
28 - Experimental: CMOS control 28 - CMOS control
29 - Experimental: LED control 29 - LED control
30 - Experimental: ACPI sounds 30 - ACPI sounds
31 - temperature sensors
32 - Experimental: embedded controller register dump
33 - Experimental: LCD brightness control
34 - Experimental: volume control
35 - Experimental: fan speed, fan enable/disable
31 36
32A compatibility table by model and feature is maintained on the web 37A compatibility table by model and feature is maintained on the web
33site, http://ibm-acpi.sf.net/. I appreciate any success or failure 38site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -91,12 +96,12 @@ driver is still in the alpha stage, the exact proc file format and
91commands supported by the various features is guaranteed to change 96commands supported by the various features is guaranteed to change
92frequently. 97frequently.
93 98
94Driver Version -- /proc/acpi/ibm/driver 99Driver version -- /proc/acpi/ibm/driver
95-------------------------------------- 100---------------------------------------
96 101
97The driver name and version. No commands can be written to this file. 102The driver name and version. No commands can be written to this file.
98 103
99Hot Keys -- /proc/acpi/ibm/hotkey 104Hot keys -- /proc/acpi/ibm/hotkey
100--------------------------------- 105---------------------------------
101 106
102Without this driver, only the Fn-F4 key (sleep button) generates an 107Without this driver, only the Fn-F4 key (sleep button) generates an
@@ -188,7 +193,7 @@ and, on the X40, video corruption. By disabling automatic switching,
188the flickering or video corruption can be avoided. 193the flickering or video corruption can be avoided.
189 194
190The video_switch command cycles through the available video outputs 195The video_switch command cycles through the available video outputs
191(it sumulates the behavior of Fn-F7). 196(it simulates the behavior of Fn-F7).
192 197
193Video expansion can be toggled through this feature. This controls 198Video expansion can be toggled through this feature. This controls
194whether the display is expanded to fill the entire LCD screen when a 199whether the display is expanded to fill the entire LCD screen when a
@@ -201,6 +206,12 @@ Fn-F7 from working. This also disables the video output switching
201features of this driver, as it uses the same ACPI methods as 206features of this driver, as it uses the same ACPI methods as
202Fn-F7. Video switching on the console should still work. 207Fn-F7. Video switching on the console should still work.
203 208
209UPDATE: There's now a patch for the X.org Radeon driver which
210addresses this issue. Some people are reporting success with the patch
211while others are still having problems. For more information:
212
213https://bugs.freedesktop.org/show_bug.cgi?id=2000
214
204ThinkLight control -- /proc/acpi/ibm/light 215ThinkLight control -- /proc/acpi/ibm/light
205------------------------------------------ 216------------------------------------------
206 217
@@ -211,7 +222,7 @@ models which do not make the status available will show it as
211 echo on > /proc/acpi/ibm/light 222 echo on > /proc/acpi/ibm/light
212 echo off > /proc/acpi/ibm/light 223 echo off > /proc/acpi/ibm/light
213 224
214Docking / Undocking -- /proc/acpi/ibm/dock 225Docking / undocking -- /proc/acpi/ibm/dock
215------------------------------------------ 226------------------------------------------
216 227
217Docking and undocking (e.g. with the X4 UltraBase) requires some 228Docking and undocking (e.g. with the X4 UltraBase) requires some
@@ -228,11 +239,15 @@ NOTE: These events will only be generated if the laptop was docked
228when originally booted. This is due to the current lack of support for 239when originally booted. This is due to the current lack of support for
229hot plugging of devices in the Linux ACPI framework. If the laptop was 240hot plugging of devices in the Linux ACPI framework. If the laptop was
230booted while not in the dock, the following message is shown in the 241booted while not in the dock, the following message is shown in the
231logs: "ibm_acpi: dock device not present". No dock-related events are 242logs:
232generated but the dock and undock commands described below still 243
233work. They can be executed manually or triggered by Fn key 244 Mar 17 01:42:34 aero kernel: ibm_acpi: dock device not present
234combinations (see the example acpid configuration files included in 245
235the driver tarball package available on the web site). 246In this case, no dock-related events are generated but the dock and
247undock commands described below still work. They can be executed
248manually or triggered by Fn key combinations (see the example acpid
249configuration files included in the driver tarball package available
250on the web site).
236 251
237When the eject request button on the dock is pressed, the first event 252When the eject request button on the dock is pressed, the first event
238above is generated. The handler for this event should issue the 253above is generated. The handler for this event should issue the
@@ -267,7 +282,7 @@ the only docking stations currently supported are the X-series
267UltraBase docks and "dumb" port replicators like the Mini Dock (the 282UltraBase docks and "dumb" port replicators like the Mini Dock (the
268latter don't need any ACPI support, actually). 283latter don't need any ACPI support, actually).
269 284
270UltraBay Eject -- /proc/acpi/ibm/bay 285UltraBay eject -- /proc/acpi/ibm/bay
271------------------------------------ 286------------------------------------
272 287
273Inserting or ejecting an UltraBay device requires some actions to be 288Inserting or ejecting an UltraBay device requires some actions to be
@@ -284,8 +299,11 @@ when the laptop was originally booted (on the X series, the UltraBay
284is in the dock, so it may not be present if the laptop was undocked). 299is in the dock, so it may not be present if the laptop was undocked).
285This is due to the current lack of support for hot plugging of devices 300This is due to the current lack of support for hot plugging of devices
286in the Linux ACPI framework. If the laptop was booted without the 301in the Linux ACPI framework. If the laptop was booted without the
287UltraBay, the following message is shown in the logs: "ibm_acpi: bay 302UltraBay, the following message is shown in the logs:
288device not present". No bay-related events are generated but the eject 303
304 Mar 17 01:42:34 aero kernel: ibm_acpi: bay device not present
305
306In this case, no bay-related events are generated but the eject
289command described below still works. It can be executed manually or 307command described below still works. It can be executed manually or
290triggered by a hot key combination. 308triggered by a hot key combination.
291 309
@@ -306,22 +324,33 @@ necessary to enable the UltraBay device (e.g. call idectl).
306The contents of the /proc/acpi/ibm/bay file shows the current status 324The contents of the /proc/acpi/ibm/bay file shows the current status
307of the UltraBay, as provided by the ACPI framework. 325of the UltraBay, as provided by the ACPI framework.
308 326
309Experimental Features 327EXPERIMENTAL warm eject support on the 600e/x, A22p and A3x (To use
310--------------------- 328this feature, you need to supply the experimental=1 parameter when
329loading the module):
330
331These models do not have a button near the UltraBay device to request
332a hot eject but rather require the laptop to be put to sleep
333(suspend-to-ram) before the bay device is ejected or inserted).
334The sequence of steps to eject the device is as follows:
335
336 echo eject > /proc/acpi/ibm/bay
337 put the ThinkPad to sleep
338 remove the drive
339 resume from sleep
340 cat /proc/acpi/ibm/bay should show that the drive was removed
341
342On the A3x, both the UltraBay 2000 and UltraBay Plus devices are
343supported. Use "eject2" instead of "eject" for the second bay.
311 344
312The following features are marked experimental because using them 345Note: the UltraBay eject support on the 600e/x, A22p and A3x is
313involves guessing the correct values of some parameters. Guessing 346EXPERIMENTAL and may not work as expected. USE WITH CAUTION!
314incorrectly may have undesirable effects like crashing your
315ThinkPad. USE THESE WITH CAUTION! To activate them, you'll need to
316supply the experimental=1 parameter when loading the module.
317 347
318Experimental: CMOS control - /proc/acpi/ibm/cmos 348CMOS control -- /proc/acpi/ibm/cmos
319------------------------------------------------ 349-----------------------------------
320 350
321This feature is used internally by the ACPI firmware to control the 351This feature is used internally by the ACPI firmware to control the
322ThinkLight on most newer ThinkPad models. It appears that it can also 352ThinkLight on most newer ThinkPad models. It may also control LCD
323control LCD brightness, sounds volume and more, but only on some 353brightness, sounds volume and more, but only on some models.
324models.
325 354
326The commands are non-negative integer numbers: 355The commands are non-negative integer numbers:
327 356
@@ -330,10 +359,9 @@ The commands are non-negative integer numbers:
330 echo 2 >/proc/acpi/ibm/cmos 359 echo 2 >/proc/acpi/ibm/cmos
331 ... 360 ...
332 361
333The range of numbers which are used internally by various models is 0 362The range of valid numbers is 0 to 21, but not all have an effect and
334to 21, but it's possible that numbers outside this range have 363the behavior varies from model to model. Here is the behavior on the
335interesting behavior. Here is the behavior on the X40 (tpb is the 364X40 (tpb is the ThinkPad Buttons utility):
336ThinkPad Buttons utility):
337 365
338 0 - no effect but tpb reports "Volume down" 366 0 - no effect but tpb reports "Volume down"
339 1 - no effect but tpb reports "Volume up" 367 1 - no effect but tpb reports "Volume up"
@@ -346,26 +374,18 @@ ThinkPad Buttons utility):
346 13 - ThinkLight off 374 13 - ThinkLight off
347 14 - no effect but tpb reports ThinkLight status change 375 14 - no effect but tpb reports ThinkLight status change
348 376
349If you try this feature, please send me a report similar to the 377LED control -- /proc/acpi/ibm/led
350above. On models which allow control of LCD brightness or sound 378---------------------------------
351volume, I'd like to provide this functionality in an user-friendly
352way, but first I need a way to identify the models which this is
353possible.
354
355Experimental: LED control - /proc/acpi/ibm/LED
356----------------------------------------------
357 379
358Some of the LED indicators can be controlled through this feature. The 380Some of the LED indicators can be controlled through this feature. The
359available commands are: 381available commands are:
360 382
361 echo <led number> on >/proc/acpi/ibm/led 383 echo '<led number> on' >/proc/acpi/ibm/led
362 echo <led number> off >/proc/acpi/ibm/led 384 echo '<led number> off' >/proc/acpi/ibm/led
363 echo <led number> blink >/proc/acpi/ibm/led 385 echo '<led number> blink' >/proc/acpi/ibm/led
364 386
365The <led number> parameter is a non-negative integer. The range of LED 387The <led number> range is 0 to 7. The set of LEDs that can be
366numbers used internally by various models is 0 to 7 but it's possible 388controlled varies from model to model. Here is the mapping on the X40:
367that numbers outside this range are also valid. Here is the mapping on
368the X40:
369 389
370 0 - power 390 0 - power
371 1 - battery (orange) 391 1 - battery (orange)
@@ -376,49 +396,224 @@ the X40:
376 396
377All of the above can be turned on and off and can be made to blink. 397All of the above can be turned on and off and can be made to blink.
378 398
379If you try this feature, please send me a report similar to the 399ACPI sounds -- /proc/acpi/ibm/beep
380above. I'd like to provide this functionality in an user-friendly way, 400----------------------------------
381but first I need to identify the which numbers correspond to which
382LEDs on various models.
383
384Experimental: ACPI sounds - /proc/acpi/ibm/beep
385-----------------------------------------------
386 401
387The BEEP method is used internally by the ACPI firmware to provide 402The BEEP method is used internally by the ACPI firmware to provide
388audible alerts in various situtation. This feature allows the same 403audible alerts in various situations. This feature allows the same
389sounds to be triggered manually. 404sounds to be triggered manually.
390 405
391The commands are non-negative integer numbers: 406The commands are non-negative integer numbers:
392 407
393 echo 0 >/proc/acpi/ibm/beep 408 echo <number> >/proc/acpi/ibm/beep
394 echo 1 >/proc/acpi/ibm/beep
395 echo 2 >/proc/acpi/ibm/beep
396 ...
397 409
398The range of numbers which are used internally by various models is 0 410The valid <number> range is 0 to 17. Not all numbers trigger sounds
399to 17, but it's possible that numbers outside this range are also 411and the sounds vary from model to model. Here is the behavior on the
400valid. Here is the behavior on the X40: 412X40:
401 413
402 2 - two beeps, pause, third beep 414 0 - stop a sound in progress (but use 17 to stop 16)
415 2 - two beeps, pause, third beep ("low battery")
403 3 - single beep 416 3 - single beep
404 4 - "unable" 417 4 - high, followed by low-pitched beep ("unable")
405 5 - single beep 418 5 - single beep
406 6 - "AC/DC" 419 6 - very high, followed by high-pitched beep ("AC/DC")
407 7 - high-pitched beep 420 7 - high-pitched beep
408 9 - three short beeps 421 9 - three short beeps
409 10 - very long beep 422 10 - very long beep
410 12 - low-pitched beep 423 12 - low-pitched beep
424 15 - three high-pitched beeps repeating constantly, stop with 0
425 16 - one medium-pitched beep repeating constantly, stop with 17
426 17 - stop 16
427
428Temperature sensors -- /proc/acpi/ibm/thermal
429---------------------------------------------
430
431Most ThinkPads include six or more separate temperature sensors but
432only expose the CPU temperature through the standard ACPI methods.
433This feature shows readings from up to eight different sensors. Some
434readings may not be valid, e.g. may show large negative values. For
435example, on the X40, a typical output may be:
436
437temperatures: 42 42 45 41 36 -128 33 -128
438
439Thomas Gruber took his R51 apart and traced all six active sensors in
440his laptop (the location of sensors may vary on other models):
441
4421: CPU
4432: Mini PCI Module
4443: HDD
4454: GPU
4465: Battery
4476: N/A
4487: Battery
4498: N/A
450
451No commands can be written to this file.
452
453EXPERIMENTAL: Embedded controller reigster dump -- /proc/acpi/ibm/ecdump
454------------------------------------------------------------------------
455
456This feature is marked EXPERIMENTAL because the implementation
457directly accesses hardware registers and may not work as expected. USE
458WITH CAUTION! To use this feature, you need to supply the
459experimental=1 parameter when loading the module.
460
461This feature dumps the values of 256 embedded controller
462registers. Values which have changed since the last time the registers
463were dumped are marked with a star:
464
465[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump
466EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f
467EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00
468EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00
469EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80
470EC 0x30: 01 07 1a 00 30 04 00 00 *85 00 00 10 00 50 00 00
471EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00
472EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 *bc *02 *bc
473EC 0x60: *02 *bc *02 00 00 00 00 00 00 00 00 00 00 00 00 00
474EC 0x70: 00 00 00 00 00 12 30 40 *24 *26 *2c *27 *20 80 *1f 80
475EC 0x80: 00 00 00 06 *37 *0e 03 00 00 00 0e 07 00 00 00 00
476EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
477EC 0xa0: *ff 09 ff 09 ff ff *64 00 *00 *00 *a2 41 *ff *ff *e0 00
478EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
479EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
480EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
481EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03
482EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a
483
484This feature can be used to determine the register holding the fan
485speed on some models. To do that, do the following:
486
487 - make sure the battery is fully charged
488 - make sure the fan is running
489 - run 'cat /proc/acpi/ibm/ecdump' several times, once per second or so
490
491The first step makes sure various charging-related values don't
492vary. The second ensures that the fan-related values do vary, since
493the fan speed fluctuates a bit. The third will (hopefully) mark the
494fan register with a star:
495
496[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump
497EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f
498EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00
499EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00
500EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80
501EC 0x30: 01 07 1a 00 30 04 00 00 85 00 00 10 00 50 00 00
502EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00
503EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 bc 02 bc
504EC 0x60: 02 bc 02 00 00 00 00 00 00 00 00 00 00 00 00 00
505EC 0x70: 00 00 00 00 00 12 30 40 24 27 2c 27 21 80 1f 80
506EC 0x80: 00 00 00 06 *be 0d 03 00 00 00 0e 07 00 00 00 00
507EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
508EC 0xa0: ff 09 ff 09 ff ff 64 00 00 00 a2 41 ff ff e0 00
509EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
510EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
511EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
512EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03
513EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a
514
515Another set of values that varies often is the temperature
516readings. Since temperatures don't change vary fast, you can take
517several quick dumps to eliminate them.
518
519You can use a similar method to figure out the meaning of other
520embedded controller registers - e.g. make sure nothing else changes
521except the charging or discharging battery to determine which
522registers contain the current battery capacity, etc. If you experiment
523with this, do send me your results (including some complete dumps with
524a description of the conditions when they were taken.)
525
526EXPERIMENTAL: LCD brightness control -- /proc/acpi/ibm/brightness
527-----------------------------------------------------------------
528
529This feature is marked EXPERIMENTAL because the implementation
530directly accesses hardware registers and may not work as expected. USE
531WITH CAUTION! To use this feature, you need to supply the
532experimental=1 parameter when loading the module.
533
534This feature allows software control of the LCD brightness on ThinkPad
535models which don't have a hardware brightness slider. The available
536commands are:
537
538 echo up >/proc/acpi/ibm/brightness
539 echo down >/proc/acpi/ibm/brightness
540 echo 'level <level>' >/proc/acpi/ibm/brightness
541
542The <level> number range is 0 to 7, although not all of them may be
543distinct. The current brightness level is shown in the file.
544
545EXPERIMENTAL: Volume control -- /proc/acpi/ibm/volume
546-----------------------------------------------------
547
548This feature is marked EXPERIMENTAL because the implementation
549directly accesses hardware registers and may not work as expected. USE
550WITH CAUTION! To use this feature, you need to supply the
551experimental=1 parameter when loading the module.
552
553This feature allows volume control on ThinkPad models which don't have
554a hardware volume knob. The available commands are:
555
556 echo up >/proc/acpi/ibm/volume
557 echo down >/proc/acpi/ibm/volume
558 echo mute >/proc/acpi/ibm/volume
559 echo 'level <level>' >/proc/acpi/ibm/volume
560
561The <level> number range is 0 to 15 although not all of them may be
562distinct. The unmute the volume after the mute command, use either the
563up or down command (the level command will not unmute the volume).
564The current volume level and mute state is shown in the file.
565
566EXPERIMENTAL: fan speed, fan enable/disable -- /proc/acpi/ibm/fan
567-----------------------------------------------------------------
568
569This feature is marked EXPERIMENTAL because the implementation
570directly accesses hardware registers and may not work as expected. USE
571WITH CAUTION! To use this feature, you need to supply the
572experimental=1 parameter when loading the module.
573
574This feature attempts to show the current fan speed. The speed is read
575directly from the hardware registers of the embedded controller. This
576is known to work on later R, T and X series ThinkPads but may show a
577bogus value on other models.
578
579The fan may be enabled or disabled with the following commands:
580
581 echo enable >/proc/acpi/ibm/fan
582 echo disable >/proc/acpi/ibm/fan
583
584WARNING WARNING WARNING: do not leave the fan disabled unless you are
585monitoring the temperature sensor readings and you are ready to enable
586it if necessary to avoid overheating.
587
588The fan only runs if it's enabled *and* the various temperature
589sensors which control it read high enough. On the X40, this seems to
590depend on the CPU and HDD temperatures. Specifically, the fan is
591turned on when either the CPU temperature climbs to 56 degrees or the
592HDD temperature climbs to 46 degrees. The fan is turned off when the
593CPU temperature drops to 49 degrees and the HDD temperature drops to
59441 degrees. These thresholds cannot currently be controlled.
595
596On the X31 and X40 (and ONLY on those models), the fan speed can be
597controlled to a certain degree. Once the fan is running, it can be
598forced to run faster or slower with the following command:
599
600 echo 'speed <speed>' > /proc/acpi/ibm/thermal
601
602The sustainable range of fan speeds on the X40 appears to be from
603about 3700 to about 7350. Values outside this range either do not have
604any effect or the fan speed eventually settles somewhere in that
605range. The fan cannot be stopped or started with this command.
606
607On the 570, temperature readings are not available through this
608feature and the fan control works a little differently. The fan speed
609is reported in levels from 0 (off) to 7 (max) and can be controlled
610with the following command:
411 611
412(I've only been able to identify a couple of them). 612 echo 'level <level>' > /proc/acpi/ibm/thermal
413
414If you try this feature, please send me a report similar to the
415above. I'd like to provide this functionality in an user-friendly way,
416but first I need to identify the which numbers correspond to which
417sounds on various models.
418 613
419 614
420Multiple Command, Module Parameters 615Multiple Commands, Module Parameters
421----------------------------------- 616------------------------------------
422 617
423Multiple commands can be written to the proc files in one shot by 618Multiple commands can be written to the proc files in one shot by
424separating them with commas, for example: 619separating them with commas, for example:
@@ -451,24 +646,19 @@ scripts (included with ibm-acpi for completeness):
451 /usr/local/sbin/laptop_mode -- from the Linux kernel source 646 /usr/local/sbin/laptop_mode -- from the Linux kernel source
452 distribution, see Documentation/laptop-mode.txt 647 distribution, see Documentation/laptop-mode.txt
453 /sbin/service -- comes with Redhat/Fedora distributions 648 /sbin/service -- comes with Redhat/Fedora distributions
649 /usr/sbin/hibernate -- from the Software Suspend 2 distribution,
650 see http://softwaresuspend.berlios.de/
454 651
455Toan T Nguyen <ntt@control.uchicago.edu> has written a SuSE powersave 652Toan T Nguyen <ntt@physics.ucla.edu> notes that Suse uses the
456script for the X20, included in config/usr/sbin/ibm_hotkeys_X20 653powersave program to suspend ('powersave --suspend-to-ram') or
654hibernate ('powersave --suspend-to-disk'). This means that the
655hibernate script is not needed on that distribution.
457 656
458Henrik Brix Andersen <brix@gentoo.org> has written a Gentoo ACPI event 657Henrik Brix Andersen <brix@gentoo.org> has written a Gentoo ACPI event
459handler script for the X31. You can get the latest version from 658handler script for the X31. You can get the latest version from
460http://dev.gentoo.org/~brix/files/x31.sh 659http://dev.gentoo.org/~brix/files/x31.sh
461 660
462David Schweikert <dws@ee.eth.ch> has written an alternative blank.sh 661David Schweikert <dws@ee.eth.ch> has written an alternative blank.sh
463script which works on Debian systems, included in 662script which works on Debian systems. This scripts has now been
464configs/etc/acpi/actions/blank-debian.sh 663extended to also work on Fedora systems and included as the default
465 664blank.sh in the distribution.
466
467TODO
468----
469
470I'd like to implement the following features but haven't yet found the
471time and/or I don't yet know how to implement them:
472
473- UltraBay floppy drive support
474
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 619d843ba231..9ba334908742 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1203,7 +1203,6 @@ config PCI_DIRECT
1203config PCI_MMCONFIG 1203config PCI_MMCONFIG
1204 bool 1204 bool
1205 depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY) 1205 depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY)
1206 select ACPI_BOOT
1207 default y 1206 default y
1208 1207
1209source "drivers/pci/pcie/Kconfig" 1208source "drivers/pci/pcie/Kconfig"
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index ca07b95c06b8..6a431b926019 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -131,8 +131,6 @@ CONFIG_SOFTWARE_SUSPEND=y
131# ACPI (Advanced Configuration and Power Interface) Support 131# ACPI (Advanced Configuration and Power Interface) Support
132# 132#
133CONFIG_ACPI=y 133CONFIG_ACPI=y
134CONFIG_ACPI_BOOT=y
135CONFIG_ACPI_INTERPRETER=y
136CONFIG_ACPI_SLEEP=y 134CONFIG_ACPI_SLEEP=y
137CONFIG_ACPI_SLEEP_PROC_FS=y 135CONFIG_ACPI_SLEEP_PROC_FS=y
138CONFIG_ACPI_AC=y 136CONFIG_ACPI_AC=y
@@ -144,10 +142,8 @@ CONFIG_ACPI_THERMAL=y
144# CONFIG_ACPI_ASUS is not set 142# CONFIG_ACPI_ASUS is not set
145# CONFIG_ACPI_TOSHIBA is not set 143# CONFIG_ACPI_TOSHIBA is not set
146# CONFIG_ACPI_DEBUG is not set 144# CONFIG_ACPI_DEBUG is not set
147CONFIG_ACPI_BUS=y
148CONFIG_ACPI_EC=y 145CONFIG_ACPI_EC=y
149CONFIG_ACPI_POWER=y 146CONFIG_ACPI_POWER=y
150CONFIG_ACPI_PCI=y
151CONFIG_ACPI_SYSTEM=y 147CONFIG_ACPI_SYSTEM=y
152# CONFIG_X86_PM_TIMER is not set 148# CONFIG_X86_PM_TIMER is not set
153 149
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 4cc83b322b36..c52b4fad011b 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -11,7 +11,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
11 11
12obj-y += cpu/ 12obj-y += cpu/
13obj-y += timers/ 13obj-y += timers/
14obj-$(CONFIG_ACPI_BOOT) += acpi/ 14obj-$(CONFIG_ACPI) += acpi/
15obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o 15obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o
16obj-$(CONFIG_MCA) += mca.o 16obj-$(CONFIG_MCA) += mca.o
17obj-$(CONFIG_X86_MSR) += msr.o 17obj-$(CONFIG_X86_MSR) += msr.o
diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile
index 5e291a20c03d..267ca48e1b6c 100644
--- a/arch/i386/kernel/acpi/Makefile
+++ b/arch/i386/kernel/acpi/Makefile
@@ -1,4 +1,4 @@
1obj-$(CONFIG_ACPI_BOOT) := boot.o 1obj-y := boot.o
2obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o 2obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o 3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
4 4
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index b7808a89d945..0fb23c30eb98 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -40,19 +40,25 @@
40 40
41#ifdef CONFIG_X86_64 41#ifdef CONFIG_X86_64
42 42
43static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { } 43static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id)
44{
45}
44extern void __init clustered_apic_check(void); 46extern void __init clustered_apic_check(void);
45static inline int ioapic_setup_disabled(void) { return 0; } 47static inline int ioapic_setup_disabled(void)
48{
49 return 0;
50}
51
46#include <asm/proto.h> 52#include <asm/proto.h>
47 53
48#else /* X86 */ 54#else /* X86 */
49 55
50#ifdef CONFIG_X86_LOCAL_APIC 56#ifdef CONFIG_X86_LOCAL_APIC
51#include <mach_apic.h> 57#include <mach_apic.h>
52#include <mach_mpparse.h> 58#include <mach_mpparse.h>
53#endif /* CONFIG_X86_LOCAL_APIC */ 59#endif /* CONFIG_X86_LOCAL_APIC */
54 60
55#endif /* X86 */ 61#endif /* X86 */
56 62
57#define BAD_MADT_ENTRY(entry, end) ( \ 63#define BAD_MADT_ENTRY(entry, end) ( \
58 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ 64 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
@@ -60,13 +66,8 @@ static inline int ioapic_setup_disabled(void) { return 0; }
60 66
61#define PREFIX "ACPI: " 67#define PREFIX "ACPI: "
62 68
63#ifdef CONFIG_ACPI_PCI
64int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ 69int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
65int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ 70int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
66#else
67int acpi_noirq __initdata = 1;
68int acpi_pci_disabled __initdata = 1;
69#endif
70int acpi_ht __initdata = 1; /* enable HT */ 71int acpi_ht __initdata = 1; /* enable HT */
71 72
72int acpi_lapic; 73int acpi_lapic;
@@ -88,7 +89,7 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
88 89
89#define MAX_MADT_ENTRIES 256 90#define MAX_MADT_ENTRIES 256
90u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = 91u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
91 { [0 ... MAX_MADT_ENTRIES-1] = 0xff }; 92 {[0 ... MAX_MADT_ENTRIES - 1] = 0xff };
92EXPORT_SYMBOL(x86_acpiid_to_apicid); 93EXPORT_SYMBOL(x86_acpiid_to_apicid);
93 94
94/* -------------------------------------------------------------------------- 95/* --------------------------------------------------------------------------
@@ -99,7 +100,7 @@ EXPORT_SYMBOL(x86_acpiid_to_apicid);
99 * The default interrupt routing model is PIC (8259). This gets 100 * The default interrupt routing model is PIC (8259). This gets
100 * overriden if IOAPICs are enumerated (below). 101 * overriden if IOAPICs are enumerated (below).
101 */ 102 */
102enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; 103enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
103 104
104#ifdef CONFIG_X86_64 105#ifdef CONFIG_X86_64
105 106
@@ -107,7 +108,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
107char *__acpi_map_table(unsigned long phys_addr, unsigned long size) 108char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
108{ 109{
109 if (!phys_addr || !size) 110 if (!phys_addr || !size)
110 return NULL; 111 return NULL;
111 112
112 if (phys_addr < (end_pfn_map << PAGE_SHIFT)) 113 if (phys_addr < (end_pfn_map << PAGE_SHIFT))
113 return __va(phys_addr); 114 return __va(phys_addr);
@@ -134,8 +135,8 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
134 unsigned long base, offset, mapped_size; 135 unsigned long base, offset, mapped_size;
135 int idx; 136 int idx;
136 137
137 if (phys + size < 8*1024*1024) 138 if (phys + size < 8 * 1024 * 1024)
138 return __va(phys); 139 return __va(phys);
139 140
140 offset = phys & (PAGE_SIZE - 1); 141 offset = phys & (PAGE_SIZE - 1);
141 mapped_size = PAGE_SIZE - offset; 142 mapped_size = PAGE_SIZE - offset;
@@ -154,7 +155,7 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
154 mapped_size += PAGE_SIZE; 155 mapped_size += PAGE_SIZE;
155 } 156 }
156 157
157 return ((unsigned char *) base + offset); 158 return ((unsigned char *)base + offset);
158} 159}
159#endif 160#endif
160 161
@@ -172,7 +173,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
172 if (!phys_addr || !size) 173 if (!phys_addr || !size)
173 return -EINVAL; 174 return -EINVAL;
174 175
175 mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size); 176 mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
176 if (!mcfg) { 177 if (!mcfg) {
177 printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); 178 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
178 return -ENODEV; 179 return -ENODEV;
@@ -209,20 +210,17 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
209 210
210 return 0; 211 return 0;
211} 212}
212#endif /* CONFIG_PCI_MMCONFIG */ 213#endif /* CONFIG_PCI_MMCONFIG */
213 214
214#ifdef CONFIG_X86_LOCAL_APIC 215#ifdef CONFIG_X86_LOCAL_APIC
215static int __init 216static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
216acpi_parse_madt (
217 unsigned long phys_addr,
218 unsigned long size)
219{ 217{
220 struct acpi_table_madt *madt = NULL; 218 struct acpi_table_madt *madt = NULL;
221 219
222 if (!phys_addr || !size) 220 if (!phys_addr || !size)
223 return -EINVAL; 221 return -EINVAL;
224 222
225 madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size); 223 madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
226 if (!madt) { 224 if (!madt) {
227 printk(KERN_WARNING PREFIX "Unable to map MADT\n"); 225 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
228 return -ENODEV; 226 return -ENODEV;
@@ -232,22 +230,20 @@ acpi_parse_madt (
232 acpi_lapic_addr = (u64) madt->lapic_address; 230 acpi_lapic_addr = (u64) madt->lapic_address;
233 231
234 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", 232 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
235 madt->lapic_address); 233 madt->lapic_address);
236 } 234 }
237 235
238 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); 236 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
239 237
240 return 0; 238 return 0;
241} 239}
242 240
243
244static int __init 241static int __init
245acpi_parse_lapic ( 242acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
246 acpi_table_entry_header *header, const unsigned long end)
247{ 243{
248 struct acpi_table_lapic *processor = NULL; 244 struct acpi_table_lapic *processor = NULL;
249 245
250 processor = (struct acpi_table_lapic*) header; 246 processor = (struct acpi_table_lapic *)header;
251 247
252 if (BAD_MADT_ENTRY(processor, end)) 248 if (BAD_MADT_ENTRY(processor, end))
253 return -EINVAL; 249 return -EINVAL;
@@ -260,20 +256,19 @@ acpi_parse_lapic (
260 256
261 x86_acpiid_to_apicid[processor->acpi_id] = processor->id; 257 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
262 258
263 mp_register_lapic ( 259 mp_register_lapic(processor->id, /* APIC ID */
264 processor->id, /* APIC ID */ 260 processor->flags.enabled); /* Enabled? */
265 processor->flags.enabled); /* Enabled? */
266 261
267 return 0; 262 return 0;
268} 263}
269 264
270static int __init 265static int __init
271acpi_parse_lapic_addr_ovr ( 266acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
272 acpi_table_entry_header *header, const unsigned long end) 267 const unsigned long end)
273{ 268{
274 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL; 269 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
275 270
276 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header; 271 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
277 272
278 if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) 273 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
279 return -EINVAL; 274 return -EINVAL;
@@ -284,12 +279,11 @@ acpi_parse_lapic_addr_ovr (
284} 279}
285 280
286static int __init 281static int __init
287acpi_parse_lapic_nmi ( 282acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
288 acpi_table_entry_header *header, const unsigned long end)
289{ 283{
290 struct acpi_table_lapic_nmi *lapic_nmi = NULL; 284 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
291 285
292 lapic_nmi = (struct acpi_table_lapic_nmi*) header; 286 lapic_nmi = (struct acpi_table_lapic_nmi *)header;
293 287
294 if (BAD_MADT_ENTRY(lapic_nmi, end)) 288 if (BAD_MADT_ENTRY(lapic_nmi, end))
295 return -EINVAL; 289 return -EINVAL;
@@ -302,37 +296,32 @@ acpi_parse_lapic_nmi (
302 return 0; 296 return 0;
303} 297}
304 298
299#endif /*CONFIG_X86_LOCAL_APIC */
305 300
306#endif /*CONFIG_X86_LOCAL_APIC*/ 301#ifdef CONFIG_X86_IO_APIC
307
308#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
309 302
310static int __init 303static int __init
311acpi_parse_ioapic ( 304acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
312 acpi_table_entry_header *header, const unsigned long end)
313{ 305{
314 struct acpi_table_ioapic *ioapic = NULL; 306 struct acpi_table_ioapic *ioapic = NULL;
315 307
316 ioapic = (struct acpi_table_ioapic*) header; 308 ioapic = (struct acpi_table_ioapic *)header;
317 309
318 if (BAD_MADT_ENTRY(ioapic, end)) 310 if (BAD_MADT_ENTRY(ioapic, end))
319 return -EINVAL; 311 return -EINVAL;
320 312
321 acpi_table_print_madt_entry(header); 313 acpi_table_print_madt_entry(header);
322 314
323 mp_register_ioapic ( 315 mp_register_ioapic(ioapic->id,
324 ioapic->id, 316 ioapic->address, ioapic->global_irq_base);
325 ioapic->address, 317
326 ioapic->global_irq_base);
327
328 return 0; 318 return 0;
329} 319}
330 320
331/* 321/*
332 * Parse Interrupt Source Override for the ACPI SCI 322 * Parse Interrupt Source Override for the ACPI SCI
333 */ 323 */
334static void 324static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
335acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
336{ 325{
337 if (trigger == 0) /* compatible SCI trigger is level */ 326 if (trigger == 0) /* compatible SCI trigger is level */
338 trigger = 3; 327 trigger = 3;
@@ -348,7 +337,7 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
348 polarity = acpi_sci_flags.polarity; 337 polarity = acpi_sci_flags.polarity;
349 338
350 /* 339 /*
351 * mp_config_acpi_legacy_irqs() already setup IRQs < 16 340 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
352 * If GSI is < 16, this will update its flags, 341 * If GSI is < 16, this will update its flags,
353 * else it will create a new mp_irqs[] entry. 342 * else it will create a new mp_irqs[] entry.
354 */ 343 */
@@ -363,12 +352,12 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
363} 352}
364 353
365static int __init 354static int __init
366acpi_parse_int_src_ovr ( 355acpi_parse_int_src_ovr(acpi_table_entry_header * header,
367 acpi_table_entry_header *header, const unsigned long end) 356 const unsigned long end)
368{ 357{
369 struct acpi_table_int_src_ovr *intsrc = NULL; 358 struct acpi_table_int_src_ovr *intsrc = NULL;
370 359
371 intsrc = (struct acpi_table_int_src_ovr*) header; 360 intsrc = (struct acpi_table_int_src_ovr *)header;
372 361
373 if (BAD_MADT_ENTRY(intsrc, end)) 362 if (BAD_MADT_ENTRY(intsrc, end))
374 return -EINVAL; 363 return -EINVAL;
@@ -377,33 +366,30 @@ acpi_parse_int_src_ovr (
377 366
378 if (intsrc->bus_irq == acpi_fadt.sci_int) { 367 if (intsrc->bus_irq == acpi_fadt.sci_int) {
379 acpi_sci_ioapic_setup(intsrc->global_irq, 368 acpi_sci_ioapic_setup(intsrc->global_irq,
380 intsrc->flags.polarity, intsrc->flags.trigger); 369 intsrc->flags.polarity,
370 intsrc->flags.trigger);
381 return 0; 371 return 0;
382 } 372 }
383 373
384 if (acpi_skip_timer_override && 374 if (acpi_skip_timer_override &&
385 intsrc->bus_irq == 0 && intsrc->global_irq == 2) { 375 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
386 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); 376 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
387 return 0; 377 return 0;
388 } 378 }
389 379
390 mp_override_legacy_irq ( 380 mp_override_legacy_irq(intsrc->bus_irq,
391 intsrc->bus_irq, 381 intsrc->flags.polarity,
392 intsrc->flags.polarity, 382 intsrc->flags.trigger, intsrc->global_irq);
393 intsrc->flags.trigger,
394 intsrc->global_irq);
395 383
396 return 0; 384 return 0;
397} 385}
398 386
399
400static int __init 387static int __init
401acpi_parse_nmi_src ( 388acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
402 acpi_table_entry_header *header, const unsigned long end)
403{ 389{
404 struct acpi_table_nmi_src *nmi_src = NULL; 390 struct acpi_table_nmi_src *nmi_src = NULL;
405 391
406 nmi_src = (struct acpi_table_nmi_src*) header; 392 nmi_src = (struct acpi_table_nmi_src *)header;
407 393
408 if (BAD_MADT_ENTRY(nmi_src, end)) 394 if (BAD_MADT_ENTRY(nmi_src, end))
409 return -EINVAL; 395 return -EINVAL;
@@ -415,9 +401,7 @@ acpi_parse_nmi_src (
415 return 0; 401 return 0;
416} 402}
417 403
418#endif /* CONFIG_X86_IO_APIC */ 404#endif /* CONFIG_X86_IO_APIC */
419
420#ifdef CONFIG_ACPI_BUS
421 405
422/* 406/*
423 * acpi_pic_sci_set_trigger() 407 * acpi_pic_sci_set_trigger()
@@ -433,8 +417,7 @@ acpi_parse_nmi_src (
433 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0) 417 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
434 */ 418 */
435 419
436void __init 420void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
437acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
438{ 421{
439 unsigned int mask = 1 << irq; 422 unsigned int mask = 1 << irq;
440 unsigned int old, new; 423 unsigned int old, new;
@@ -454,10 +437,10 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
454 * routing tables.. 437 * routing tables..
455 */ 438 */
456 switch (trigger) { 439 switch (trigger) {
457 case 1: /* Edge - clear */ 440 case 1: /* Edge - clear */
458 new &= ~mask; 441 new &= ~mask;
459 break; 442 break;
460 case 3: /* Level - set */ 443 case 3: /* Level - set */
461 new |= mask; 444 new |= mask;
462 break; 445 break;
463 } 446 }
@@ -470,21 +453,22 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
470 outb(new >> 8, 0x4d1); 453 outb(new >> 8, 0x4d1);
471} 454}
472 455
473
474#endif /* CONFIG_ACPI_BUS */
475
476int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) 456int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
477{ 457{
478#ifdef CONFIG_X86_IO_APIC 458#ifdef CONFIG_X86_IO_APIC
479 if (use_pci_vector() && !platform_legacy_irq(gsi)) 459 if (use_pci_vector() && !platform_legacy_irq(gsi))
480 *irq = IO_APIC_VECTOR(gsi); 460 *irq = IO_APIC_VECTOR(gsi);
481 else 461 else
482#endif 462#endif
483 *irq = gsi; 463 *irq = gsi;
484 return 0; 464 return 0;
485} 465}
486 466
487unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) 467/*
468 * success: return IRQ number (>=0)
469 * failure: return < 0
470 */
471int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
488{ 472{
489 unsigned int irq; 473 unsigned int irq;
490 unsigned int plat_gsi = gsi; 474 unsigned int plat_gsi = gsi;
@@ -497,7 +481,7 @@ unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
497 extern void eisa_set_level_irq(unsigned int irq); 481 extern void eisa_set_level_irq(unsigned int irq);
498 482
499 if (edge_level == ACPI_LEVEL_SENSITIVE) 483 if (edge_level == ACPI_LEVEL_SENSITIVE)
500 eisa_set_level_irq(gsi); 484 eisa_set_level_irq(gsi);
501 } 485 }
502#endif 486#endif
503 487
@@ -509,60 +493,58 @@ unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
509 acpi_gsi_to_irq(plat_gsi, &irq); 493 acpi_gsi_to_irq(plat_gsi, &irq);
510 return irq; 494 return irq;
511} 495}
496
512EXPORT_SYMBOL(acpi_register_gsi); 497EXPORT_SYMBOL(acpi_register_gsi);
513 498
514/* 499/*
515 * ACPI based hotplug support for CPU 500 * ACPI based hotplug support for CPU
516 */ 501 */
517#ifdef CONFIG_ACPI_HOTPLUG_CPU 502#ifdef CONFIG_ACPI_HOTPLUG_CPU
518int 503int acpi_map_lsapic(acpi_handle handle, int *pcpu)
519acpi_map_lsapic(acpi_handle handle, int *pcpu)
520{ 504{
521 /* TBD */ 505 /* TBD */
522 return -EINVAL; 506 return -EINVAL;
523} 507}
524EXPORT_SYMBOL(acpi_map_lsapic);
525 508
509EXPORT_SYMBOL(acpi_map_lsapic);
526 510
527int 511int acpi_unmap_lsapic(int cpu)
528acpi_unmap_lsapic(int cpu)
529{ 512{
530 /* TBD */ 513 /* TBD */
531 return -EINVAL; 514 return -EINVAL;
532} 515}
516
533EXPORT_SYMBOL(acpi_unmap_lsapic); 517EXPORT_SYMBOL(acpi_unmap_lsapic);
534#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 518#endif /* CONFIG_ACPI_HOTPLUG_CPU */
535 519
536int 520int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
537acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
538{ 521{
539 /* TBD */ 522 /* TBD */
540 return -EINVAL; 523 return -EINVAL;
541} 524}
525
542EXPORT_SYMBOL(acpi_register_ioapic); 526EXPORT_SYMBOL(acpi_register_ioapic);
543 527
544int 528int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
545acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
546{ 529{
547 /* TBD */ 530 /* TBD */
548 return -EINVAL; 531 return -EINVAL;
549} 532}
533
550EXPORT_SYMBOL(acpi_unregister_ioapic); 534EXPORT_SYMBOL(acpi_unregister_ioapic);
551 535
552static unsigned long __init 536static unsigned long __init
553acpi_scan_rsdp ( 537acpi_scan_rsdp(unsigned long start, unsigned long length)
554 unsigned long start,
555 unsigned long length)
556{ 538{
557 unsigned long offset = 0; 539 unsigned long offset = 0;
558 unsigned long sig_len = sizeof("RSD PTR ") - 1; 540 unsigned long sig_len = sizeof("RSD PTR ") - 1;
559 541
560 /* 542 /*
561 * Scan all 16-byte boundaries of the physical memory region for the 543 * Scan all 16-byte boundaries of the physical memory region for the
562 * RSDP signature. 544 * RSDP signature.
563 */ 545 */
564 for (offset = 0; offset < length; offset += 16) { 546 for (offset = 0; offset < length; offset += 16) {
565 if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) 547 if (strncmp((char *)(start + offset), "RSD PTR ", sig_len))
566 continue; 548 continue;
567 return (start + offset); 549 return (start + offset);
568 } 550 }
@@ -575,20 +557,19 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
575 struct acpi_table_sbf *sb; 557 struct acpi_table_sbf *sb;
576 558
577 if (!phys_addr || !size) 559 if (!phys_addr || !size)
578 return -EINVAL; 560 return -EINVAL;
579 561
580 sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size); 562 sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
581 if (!sb) { 563 if (!sb) {
582 printk(KERN_WARNING PREFIX "Unable to map SBF\n"); 564 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
583 return -ENODEV; 565 return -ENODEV;
584 } 566 }
585 567
586 sbf_port = sb->sbf_cmos; /* Save CMOS port */ 568 sbf_port = sb->sbf_cmos; /* Save CMOS port */
587 569
588 return 0; 570 return 0;
589} 571}
590 572
591
592#ifdef CONFIG_HPET_TIMER 573#ifdef CONFIG_HPET_TIMER
593 574
594static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) 575static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
@@ -598,7 +579,7 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
598 if (!phys || !size) 579 if (!phys || !size)
599 return -EINVAL; 580 return -EINVAL;
600 581
601 hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size); 582 hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
602 if (!hpet_tbl) { 583 if (!hpet_tbl) {
603 printk(KERN_WARNING PREFIX "Unable to map HPET\n"); 584 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
604 return -ENODEV; 585 return -ENODEV;
@@ -609,22 +590,21 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
609 "memory.\n"); 590 "memory.\n");
610 return -1; 591 return -1;
611 } 592 }
612
613#ifdef CONFIG_X86_64 593#ifdef CONFIG_X86_64
614 vxtime.hpet_address = hpet_tbl->addr.addrl | 594 vxtime.hpet_address = hpet_tbl->addr.addrl |
615 ((long) hpet_tbl->addr.addrh << 32); 595 ((long)hpet_tbl->addr.addrh << 32);
616 596
617 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 597 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
618 hpet_tbl->id, vxtime.hpet_address); 598 hpet_tbl->id, vxtime.hpet_address);
619#else /* X86 */ 599#else /* X86 */
620 { 600 {
621 extern unsigned long hpet_address; 601 extern unsigned long hpet_address;
622 602
623 hpet_address = hpet_tbl->addr.addrl; 603 hpet_address = hpet_tbl->addr.addrl;
624 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 604 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
625 hpet_tbl->id, hpet_address); 605 hpet_tbl->id, hpet_address);
626 } 606 }
627#endif /* X86 */ 607#endif /* X86 */
628 608
629 return 0; 609 return 0;
630} 610}
@@ -640,28 +620,25 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
640{ 620{
641 struct fadt_descriptor_rev2 *fadt = NULL; 621 struct fadt_descriptor_rev2 *fadt = NULL;
642 622
643 fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); 623 fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
644 if(!fadt) { 624 if (!fadt) {
645 printk(KERN_WARNING PREFIX "Unable to map FADT\n"); 625 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
646 return 0; 626 return 0;
647 } 627 }
648
649#ifdef CONFIG_ACPI_INTERPRETER
650 /* initialize sci_int early for INT_SRC_OVR MADT parsing */ 628 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
651 acpi_fadt.sci_int = fadt->sci_int; 629 acpi_fadt.sci_int = fadt->sci_int;
652#endif
653 630
654#ifdef CONFIG_ACPI_BUS
655 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ 631 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
656 acpi_fadt.revision = fadt->revision; 632 acpi_fadt.revision = fadt->revision;
657 acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode; 633 acpi_fadt.force_apic_physical_destination_mode =
658#endif 634 fadt->force_apic_physical_destination_mode;
659 635
660#ifdef CONFIG_X86_PM_TIMER 636#ifdef CONFIG_X86_PM_TIMER
661 /* detect the location of the ACPI PM Timer */ 637 /* detect the location of the ACPI PM Timer */
662 if (fadt->revision >= FADT2_REVISION_ID) { 638 if (fadt->revision >= FADT2_REVISION_ID) {
663 /* FADT rev. 2 */ 639 /* FADT rev. 2 */
664 if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) 640 if (fadt->xpm_tmr_blk.address_space_id !=
641 ACPI_ADR_SPACE_SYSTEM_IO)
665 return 0; 642 return 0;
666 643
667 pmtmr_ioport = fadt->xpm_tmr_blk.address; 644 pmtmr_ioport = fadt->xpm_tmr_blk.address;
@@ -670,16 +647,15 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
670 pmtmr_ioport = fadt->V1_pm_tmr_blk; 647 pmtmr_ioport = fadt->V1_pm_tmr_blk;
671 } 648 }
672 if (pmtmr_ioport) 649 if (pmtmr_ioport)
673 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport); 650 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
651 pmtmr_ioport);
674#endif 652#endif
675 return 0; 653 return 0;
676} 654}
677 655
678 656unsigned long __init acpi_find_rsdp(void)
679unsigned long __init
680acpi_find_rsdp (void)
681{ 657{
682 unsigned long rsdp_phys = 0; 658 unsigned long rsdp_phys = 0;
683 659
684 if (efi_enabled) { 660 if (efi_enabled) {
685 if (efi.acpi20) 661 if (efi.acpi20)
@@ -691,9 +667,9 @@ acpi_find_rsdp (void)
691 * Scan memory looking for the RSDP signature. First search EBDA (low 667 * Scan memory looking for the RSDP signature. First search EBDA (low
692 * memory) paragraphs and then search upper memory (E0000-FFFFF). 668 * memory) paragraphs and then search upper memory (E0000-FFFFF).
693 */ 669 */
694 rsdp_phys = acpi_scan_rsdp (0, 0x400); 670 rsdp_phys = acpi_scan_rsdp(0, 0x400);
695 if (!rsdp_phys) 671 if (!rsdp_phys)
696 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000); 672 rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
697 673
698 return rsdp_phys; 674 return rsdp_phys;
699} 675}
@@ -703,8 +679,7 @@ acpi_find_rsdp (void)
703 * Parse LAPIC entries in MADT 679 * Parse LAPIC entries in MADT
704 * returns 0 on success, < 0 on error 680 * returns 0 on success, < 0 on error
705 */ 681 */
706static int __init 682static int __init acpi_parse_madt_lapic_entries(void)
707acpi_parse_madt_lapic_entries(void)
708{ 683{
709 int count; 684 int count;
710 685
@@ -713,28 +688,31 @@ acpi_parse_madt_lapic_entries(void)
713 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). 688 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
714 */ 689 */
715 690
716 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0); 691 count =
692 acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
693 acpi_parse_lapic_addr_ovr, 0);
717 if (count < 0) { 694 if (count < 0) {
718 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); 695 printk(KERN_ERR PREFIX
696 "Error parsing LAPIC address override entry\n");
719 return count; 697 return count;
720 } 698 }
721 699
722 mp_register_lapic_address(acpi_lapic_addr); 700 mp_register_lapic_address(acpi_lapic_addr);
723 701
724 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic, 702 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
725 MAX_APICS); 703 MAX_APICS);
726 if (!count) { 704 if (!count) {
727 printk(KERN_ERR PREFIX "No LAPIC entries present\n"); 705 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
728 /* TBD: Cleanup to allow fallback to MPS */ 706 /* TBD: Cleanup to allow fallback to MPS */
729 return -ENODEV; 707 return -ENODEV;
730 } 708 } else if (count < 0) {
731 else if (count < 0) {
732 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); 709 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
733 /* TBD: Cleanup to allow fallback to MPS */ 710 /* TBD: Cleanup to allow fallback to MPS */
734 return count; 711 return count;
735 } 712 }
736 713
737 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); 714 count =
715 acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
738 if (count < 0) { 716 if (count < 0) {
739 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 717 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
740 /* TBD: Cleanup to allow fallback to MPS */ 718 /* TBD: Cleanup to allow fallback to MPS */
@@ -742,15 +720,14 @@ acpi_parse_madt_lapic_entries(void)
742 } 720 }
743 return 0; 721 return 0;
744} 722}
745#endif /* CONFIG_X86_LOCAL_APIC */ 723#endif /* CONFIG_X86_LOCAL_APIC */
746 724
747#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) 725#ifdef CONFIG_X86_IO_APIC
748/* 726/*
749 * Parse IOAPIC related entries in MADT 727 * Parse IOAPIC related entries in MADT
750 * returns 0 on success, < 0 on error 728 * returns 0 on success, < 0 on error
751 */ 729 */
752static int __init 730static int __init acpi_parse_madt_ioapic_entries(void)
753acpi_parse_madt_ioapic_entries(void)
754{ 731{
755 int count; 732 int count;
756 733
@@ -762,30 +739,34 @@ acpi_parse_madt_ioapic_entries(void)
762 */ 739 */
763 if (acpi_disabled || acpi_noirq) { 740 if (acpi_disabled || acpi_noirq) {
764 return -ENODEV; 741 return -ENODEV;
765 } 742 }
766 743
767 /* 744 /*
768 * if "noapic" boot option, don't look for IO-APICs 745 * if "noapic" boot option, don't look for IO-APICs
769 */ 746 */
770 if (skip_ioapic_setup) { 747 if (skip_ioapic_setup) {
771 printk(KERN_INFO PREFIX "Skipping IOAPIC probe " 748 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
772 "due to 'noapic' option.\n"); 749 "due to 'noapic' option.\n");
773 return -ENODEV; 750 return -ENODEV;
774 } 751 }
775 752
776 count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS); 753 count =
754 acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
755 MAX_IO_APICS);
777 if (!count) { 756 if (!count) {
778 printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); 757 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
779 return -ENODEV; 758 return -ENODEV;
780 } 759 } else if (count < 0) {
781 else if (count < 0) {
782 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); 760 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
783 return count; 761 return count;
784 } 762 }
785 763
786 count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS); 764 count =
765 acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
766 NR_IRQ_VECTORS);
787 if (count < 0) { 767 if (count < 0) {
788 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); 768 printk(KERN_ERR PREFIX
769 "Error parsing interrupt source overrides entry\n");
789 /* TBD: Cleanup to allow fallback to MPS */ 770 /* TBD: Cleanup to allow fallback to MPS */
790 return count; 771 return count;
791 } 772 }
@@ -800,7 +781,9 @@ acpi_parse_madt_ioapic_entries(void)
800 /* Fill in identity legacy mapings where no override */ 781 /* Fill in identity legacy mapings where no override */
801 mp_config_acpi_legacy_irqs(); 782 mp_config_acpi_legacy_irqs();
802 783
803 count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS); 784 count =
785 acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
786 NR_IRQ_VECTORS);
804 if (count < 0) { 787 if (count < 0) {
805 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 788 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
806 /* TBD: Cleanup to allow fallback to MPS */ 789 /* TBD: Cleanup to allow fallback to MPS */
@@ -814,11 +797,9 @@ static inline int acpi_parse_madt_ioapic_entries(void)
814{ 797{
815 return -1; 798 return -1;
816} 799}
817#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ 800#endif /* !CONFIG_X86_IO_APIC */
818 801
819 802static void __init acpi_process_madt(void)
820static void __init
821acpi_process_madt(void)
822{ 803{
823#ifdef CONFIG_X86_LOCAL_APIC 804#ifdef CONFIG_X86_LOCAL_APIC
824 int count, error; 805 int count, error;
@@ -850,7 +831,8 @@ acpi_process_madt(void)
850 /* 831 /*
851 * Dell Precision Workstation 410, 610 come here. 832 * Dell Precision Workstation 410, 610 come here.
852 */ 833 */
853 printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n"); 834 printk(KERN_ERR PREFIX
835 "Invalid BIOS MADT, disabling ACPI\n");
854 disable_acpi(); 836 disable_acpi();
855 } 837 }
856 } 838 }
@@ -862,7 +844,6 @@ extern int acpi_force;
862 844
863#ifdef __i386__ 845#ifdef __i386__
864 846
865#ifdef CONFIG_ACPI_PCI
866static int __init disable_acpi_irq(struct dmi_system_id *d) 847static int __init disable_acpi_irq(struct dmi_system_id *d)
867{ 848{
868 if (!acpi_force) { 849 if (!acpi_force) {
@@ -882,12 +863,11 @@ static int __init disable_acpi_pci(struct dmi_system_id *d)
882 } 863 }
883 return 0; 864 return 0;
884} 865}
885#endif
886 866
887static int __init dmi_disable_acpi(struct dmi_system_id *d) 867static int __init dmi_disable_acpi(struct dmi_system_id *d)
888{ 868{
889 if (!acpi_force) { 869 if (!acpi_force) {
890 printk(KERN_NOTICE "%s detected: acpi off\n",d->ident); 870 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
891 disable_acpi(); 871 disable_acpi();
892 } else { 872 } else {
893 printk(KERN_NOTICE 873 printk(KERN_NOTICE
@@ -902,7 +882,8 @@ static int __init dmi_disable_acpi(struct dmi_system_id *d)
902static int __init force_acpi_ht(struct dmi_system_id *d) 882static int __init force_acpi_ht(struct dmi_system_id *d)
903{ 883{
904 if (!acpi_force) { 884 if (!acpi_force) {
905 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident); 885 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
886 d->ident);
906 disable_acpi(); 887 disable_acpi();
907 acpi_ht = 1; 888 acpi_ht = 1;
908 } else { 889 } else {
@@ -921,155 +902,155 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
921 * Boxes that need ACPI disabled 902 * Boxes that need ACPI disabled
922 */ 903 */
923 { 904 {
924 .callback = dmi_disable_acpi, 905 .callback = dmi_disable_acpi,
925 .ident = "IBM Thinkpad", 906 .ident = "IBM Thinkpad",
926 .matches = { 907 .matches = {
927 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 908 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
928 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), 909 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
929 }, 910 },
930 }, 911 },
931 912
932 /* 913 /*
933 * Boxes that need acpi=ht 914 * Boxes that need acpi=ht
934 */ 915 */
935 { 916 {
936 .callback = force_acpi_ht, 917 .callback = force_acpi_ht,
937 .ident = "FSC Primergy T850", 918 .ident = "FSC Primergy T850",
938 .matches = { 919 .matches = {
939 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 920 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
940 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), 921 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
941 }, 922 },
942 }, 923 },
943 { 924 {
944 .callback = force_acpi_ht, 925 .callback = force_acpi_ht,
945 .ident = "DELL GX240", 926 .ident = "DELL GX240",
946 .matches = { 927 .matches = {
947 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"), 928 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
948 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"), 929 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
949 }, 930 },
950 }, 931 },
951 { 932 {
952 .callback = force_acpi_ht, 933 .callback = force_acpi_ht,
953 .ident = "HP VISUALIZE NT Workstation", 934 .ident = "HP VISUALIZE NT Workstation",
954 .matches = { 935 .matches = {
955 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 936 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
956 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), 937 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
957 }, 938 },
958 }, 939 },
959 { 940 {
960 .callback = force_acpi_ht, 941 .callback = force_acpi_ht,
961 .ident = "Compaq Workstation W8000", 942 .ident = "Compaq Workstation W8000",
962 .matches = { 943 .matches = {
963 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), 944 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
964 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), 945 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
965 }, 946 },
966 }, 947 },
967 { 948 {
968 .callback = force_acpi_ht, 949 .callback = force_acpi_ht,
969 .ident = "ASUS P4B266", 950 .ident = "ASUS P4B266",
970 .matches = { 951 .matches = {
971 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 952 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
972 DMI_MATCH(DMI_BOARD_NAME, "P4B266"), 953 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
973 }, 954 },
974 }, 955 },
975 { 956 {
976 .callback = force_acpi_ht, 957 .callback = force_acpi_ht,
977 .ident = "ASUS P2B-DS", 958 .ident = "ASUS P2B-DS",
978 .matches = { 959 .matches = {
979 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 960 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
980 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"), 961 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
981 }, 962 },
982 }, 963 },
983 { 964 {
984 .callback = force_acpi_ht, 965 .callback = force_acpi_ht,
985 .ident = "ASUS CUR-DLS", 966 .ident = "ASUS CUR-DLS",
986 .matches = { 967 .matches = {
987 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 968 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
988 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), 969 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
989 }, 970 },
990 }, 971 },
991 { 972 {
992 .callback = force_acpi_ht, 973 .callback = force_acpi_ht,
993 .ident = "ABIT i440BX-W83977", 974 .ident = "ABIT i440BX-W83977",
994 .matches = { 975 .matches = {
995 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"), 976 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
996 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), 977 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
997 }, 978 },
998 }, 979 },
999 { 980 {
1000 .callback = force_acpi_ht, 981 .callback = force_acpi_ht,
1001 .ident = "IBM Bladecenter", 982 .ident = "IBM Bladecenter",
1002 .matches = { 983 .matches = {
1003 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 984 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1004 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), 985 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1005 }, 986 },
1006 }, 987 },
1007 { 988 {
1008 .callback = force_acpi_ht, 989 .callback = force_acpi_ht,
1009 .ident = "IBM eServer xSeries 360", 990 .ident = "IBM eServer xSeries 360",
1010 .matches = { 991 .matches = {
1011 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 992 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1012 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), 993 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1013 }, 994 },
1014 }, 995 },
1015 { 996 {
1016 .callback = force_acpi_ht, 997 .callback = force_acpi_ht,
1017 .ident = "IBM eserver xSeries 330", 998 .ident = "IBM eserver xSeries 330",
1018 .matches = { 999 .matches = {
1019 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1000 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1020 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), 1001 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1021 }, 1002 },
1022 }, 1003 },
1023 { 1004 {
1024 .callback = force_acpi_ht, 1005 .callback = force_acpi_ht,
1025 .ident = "IBM eserver xSeries 440", 1006 .ident = "IBM eserver xSeries 440",
1026 .matches = { 1007 .matches = {
1027 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1008 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1028 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), 1009 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1029 }, 1010 },
1030 }, 1011 },
1031 1012
1032#ifdef CONFIG_ACPI_PCI
1033 /* 1013 /*
1034 * Boxes that need ACPI PCI IRQ routing disabled 1014 * Boxes that need ACPI PCI IRQ routing disabled
1035 */ 1015 */
1036 { 1016 {
1037 .callback = disable_acpi_irq, 1017 .callback = disable_acpi_irq,
1038 .ident = "ASUS A7V", 1018 .ident = "ASUS A7V",
1039 .matches = { 1019 .matches = {
1040 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), 1020 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1041 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"), 1021 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1042 /* newer BIOS, Revision 1011, does work */ 1022 /* newer BIOS, Revision 1011, does work */
1043 DMI_MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"), 1023 DMI_MATCH(DMI_BIOS_VERSION,
1044 }, 1024 "ASUS A7V ACPI BIOS Revision 1007"),
1045 }, 1025 },
1026 },
1046 1027
1047 /* 1028 /*
1048 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled 1029 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1049 */ 1030 */
1050 { /* _BBN 0 bug */ 1031 { /* _BBN 0 bug */
1051 .callback = disable_acpi_pci, 1032 .callback = disable_acpi_pci,
1052 .ident = "ASUS PR-DLS", 1033 .ident = "ASUS PR-DLS",
1053 .matches = { 1034 .matches = {
1054 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 1035 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1055 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), 1036 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1056 DMI_MATCH(DMI_BIOS_VERSION, "ASUS PR-DLS ACPI BIOS Revision 1010"), 1037 DMI_MATCH(DMI_BIOS_VERSION,
1057 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") 1038 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1058 }, 1039 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1059 }, 1040 },
1041 },
1060 { 1042 {
1061 .callback = disable_acpi_pci, 1043 .callback = disable_acpi_pci,
1062 .ident = "Acer TravelMate 36x Laptop", 1044 .ident = "Acer TravelMate 36x Laptop",
1063 .matches = { 1045 .matches = {
1064 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 1046 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1065 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), 1047 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1066 }, 1048 },
1067 }, 1049 },
1068#endif 1050 {}
1069 { }
1070}; 1051};
1071 1052
1072#endif /* __i386__ */ 1053#endif /* __i386__ */
1073 1054
1074/* 1055/*
1075 * acpi_boot_table_init() and acpi_boot_init() 1056 * acpi_boot_table_init() and acpi_boot_init()
@@ -1094,8 +1075,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1094 * !0: failure 1075 * !0: failure
1095 */ 1076 */
1096 1077
1097int __init 1078int __init acpi_boot_table_init(void)
1098acpi_boot_table_init(void)
1099{ 1079{
1100 int error; 1080 int error;
1101 1081
@@ -1108,7 +1088,7 @@ acpi_boot_table_init(void)
1108 * One exception: acpi=ht continues far enough to enumerate LAPICs 1088 * One exception: acpi=ht continues far enough to enumerate LAPICs
1109 */ 1089 */
1110 if (acpi_disabled && !acpi_ht) 1090 if (acpi_disabled && !acpi_ht)
1111 return 1; 1091 return 1;
1112 1092
1113 /* 1093 /*
1114 * Initialize the ACPI boot-time table parser. 1094 * Initialize the ACPI boot-time table parser.
@@ -1118,7 +1098,6 @@ acpi_boot_table_init(void)
1118 disable_acpi(); 1098 disable_acpi();
1119 return error; 1099 return error;
1120 } 1100 }
1121
1122#ifdef __i386__ 1101#ifdef __i386__
1123 check_acpi_pci(); 1102 check_acpi_pci();
1124#endif 1103#endif
@@ -1142,7 +1121,6 @@ acpi_boot_table_init(void)
1142 return 0; 1121 return 0;
1143} 1122}
1144 1123
1145
1146int __init acpi_boot_init(void) 1124int __init acpi_boot_init(void)
1147{ 1125{
1148 /* 1126 /*
@@ -1150,7 +1128,7 @@ int __init acpi_boot_init(void)
1150 * One exception: acpi=ht continues far enough to enumerate LAPICs 1128 * One exception: acpi=ht continues far enough to enumerate LAPICs
1151 */ 1129 */
1152 if (acpi_disabled && !acpi_ht) 1130 if (acpi_disabled && !acpi_ht)
1153 return 1; 1131 return 1;
1154 1132
1155 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); 1133 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
1156 1134
@@ -1168,4 +1146,3 @@ int __init acpi_boot_init(void)
1168 1146
1169 return 0; 1147 return 0;
1170} 1148}
1171
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index 726a5ca4b165..f1b9d2a46dab 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -8,44 +8,44 @@
8#include <asm/pci-direct.h> 8#include <asm/pci-direct.h>
9#include <asm/acpi.h> 9#include <asm/acpi.h>
10 10
11static int __init check_bridge(int vendor, int device) 11static int __init check_bridge(int vendor, int device)
12{ 12{
13 /* According to Nvidia all timer overrides are bogus. Just ignore 13 /* According to Nvidia all timer overrides are bogus. Just ignore
14 them all. */ 14 them all. */
15 if (vendor == PCI_VENDOR_ID_NVIDIA) { 15 if (vendor == PCI_VENDOR_ID_NVIDIA) {
16 acpi_skip_timer_override = 1; 16 acpi_skip_timer_override = 1;
17 } 17 }
18 return 0; 18 return 0;
19} 19}
20 20
21void __init check_acpi_pci(void) 21void __init check_acpi_pci(void)
22{ 22{
23 int num,slot,func; 23 int num, slot, func;
24 24
25 /* Assume the machine supports type 1. If not it will 25 /* Assume the machine supports type 1. If not it will
26 always read ffffffff and should not have any side effect. */ 26 always read ffffffff and should not have any side effect. */
27 27
28 /* Poor man's PCI discovery */ 28 /* Poor man's PCI discovery */
29 for (num = 0; num < 32; num++) { 29 for (num = 0; num < 32; num++) {
30 for (slot = 0; slot < 32; slot++) { 30 for (slot = 0; slot < 32; slot++) {
31 for (func = 0; func < 8; func++) { 31 for (func = 0; func < 8; func++) {
32 u32 class; 32 u32 class;
33 u32 vendor; 33 u32 vendor;
34 class = read_pci_config(num,slot,func, 34 class = read_pci_config(num, slot, func,
35 PCI_CLASS_REVISION); 35 PCI_CLASS_REVISION);
36 if (class == 0xffffffff) 36 if (class == 0xffffffff)
37 break; 37 break;
38 38
39 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) 39 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
40 continue; 40 continue;
41 41
42 vendor = read_pci_config(num, slot, func, 42 vendor = read_pci_config(num, slot, func,
43 PCI_VENDOR_ID); 43 PCI_VENDOR_ID);
44 44
45 if (check_bridge(vendor&0xffff, vendor >> 16)) 45 if (check_bridge(vendor & 0xffff, vendor >> 16))
46 return; 46 return;
47 } 47 }
48 48
49 } 49 }
50 } 50 }
51} 51}
diff --git a/arch/i386/kernel/acpi/sleep.c b/arch/i386/kernel/acpi/sleep.c
index c1af93032ff3..1cb2b186a3af 100644
--- a/arch/i386/kernel/acpi/sleep.c
+++ b/arch/i386/kernel/acpi/sleep.c
@@ -20,12 +20,13 @@ extern void zap_low_mappings(void);
20 20
21extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long)); 21extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
22 22
23static void init_low_mapping(pgd_t *pgd, int pgd_limit) 23static void init_low_mapping(pgd_t * pgd, int pgd_limit)
24{ 24{
25 int pgd_ofs = 0; 25 int pgd_ofs = 0;
26 26
27 while ((pgd_ofs < pgd_limit) && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) { 27 while ((pgd_ofs < pgd_limit)
28 set_pgd(pgd, *(pgd+USER_PTRS_PER_PGD)); 28 && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) {
29 set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD));
29 pgd_ofs++, pgd++; 30 pgd_ofs++, pgd++;
30 } 31 }
31 flush_tlb_all(); 32 flush_tlb_all();
@@ -37,12 +38,13 @@ static void init_low_mapping(pgd_t *pgd, int pgd_limit)
37 * Create an identity mapped page table and copy the wakeup routine to 38 * Create an identity mapped page table and copy the wakeup routine to
38 * low memory. 39 * low memory.
39 */ 40 */
40int acpi_save_state_mem (void) 41int acpi_save_state_mem(void)
41{ 42{
42 if (!acpi_wakeup_address) 43 if (!acpi_wakeup_address)
43 return 1; 44 return 1;
44 init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD); 45 init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
45 memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); 46 memcpy((void *)acpi_wakeup_address, &wakeup_start,
47 &wakeup_end - &wakeup_start);
46 acpi_copy_wakeup_routine(acpi_wakeup_address); 48 acpi_copy_wakeup_routine(acpi_wakeup_address);
47 49
48 return 0; 50 return 0;
@@ -51,7 +53,7 @@ int acpi_save_state_mem (void)
51/* 53/*
52 * acpi_restore_state - undo effects of acpi_save_state_mem 54 * acpi_restore_state - undo effects of acpi_save_state_mem
53 */ 55 */
54void acpi_restore_state_mem (void) 56void acpi_restore_state_mem(void)
55{ 57{
56 zap_low_mappings(); 58 zap_low_mappings();
57} 59}
@@ -67,7 +69,8 @@ void acpi_restore_state_mem (void)
67void __init acpi_reserve_bootmem(void) 69void __init acpi_reserve_bootmem(void)
68{ 70{
69 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) { 71 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) {
70 printk(KERN_ERR "ACPI: Wakeup code way too big, S3 disabled.\n"); 72 printk(KERN_ERR
73 "ACPI: Wakeup code way too big, S3 disabled.\n");
71 return; 74 return;
72 } 75 }
73 76
@@ -90,10 +93,8 @@ static int __init acpi_sleep_setup(char *str)
90 return 1; 93 return 1;
91} 94}
92 95
93
94__setup("acpi_sleep=", acpi_sleep_setup); 96__setup("acpi_sleep=", acpi_sleep_setup);
95 97
96
97static __init int reset_videomode_after_s3(struct dmi_system_id *d) 98static __init int reset_videomode_after_s3(struct dmi_system_id *d)
98{ 99{
99 acpi_video_flags |= 2; 100 acpi_video_flags |= 2;
@@ -101,14 +102,14 @@ static __init int reset_videomode_after_s3(struct dmi_system_id *d)
101} 102}
102 103
103static __initdata struct dmi_system_id acpisleep_dmi_table[] = { 104static __initdata struct dmi_system_id acpisleep_dmi_table[] = {
104 { /* Reset video mode after returning from ACPI S3 sleep */ 105 { /* Reset video mode after returning from ACPI S3 sleep */
105 .callback = reset_videomode_after_s3, 106 .callback = reset_videomode_after_s3,
106 .ident = "Toshiba Satellite 4030cdt", 107 .ident = "Toshiba Satellite 4030cdt",
107 .matches = { 108 .matches = {
108 DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), 109 DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
109 }, 110 },
110 }, 111 },
111 { } 112 {}
112}; 113};
113 114
114static int __init acpisleep_dmi_init(void) 115static int __init acpisleep_dmi_init(void)
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 60a9e54dd20e..822c8ce9d1f1 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -31,6 +31,7 @@
31#include <linux/cpufreq.h> 31#include <linux/cpufreq.h>
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/compiler.h>
34#include <asm/io.h> 35#include <asm/io.h>
35#include <asm/delay.h> 36#include <asm/delay.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
@@ -57,6 +58,8 @@ static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS];
57 58
58static struct cpufreq_driver acpi_cpufreq_driver; 59static struct cpufreq_driver acpi_cpufreq_driver;
59 60
61static unsigned int acpi_pstate_strict;
62
60static int 63static int
61acpi_processor_write_port( 64acpi_processor_write_port(
62 u16 port, 65 u16 port,
@@ -163,34 +166,44 @@ acpi_processor_set_performance (
163 } 166 }
164 167
165 /* 168 /*
166 * Then we read the 'status_register' and compare the value with the 169 * Assume the write went through when acpi_pstate_strict is not used.
167 * target state's 'status' to make sure the transition was successful. 170 * As read status_register is an expensive operation and there
168 * Note that we'll poll for up to 1ms (100 cycles of 10us) before 171 * are no specific error cases where an IO port write will fail.
169 * giving up.
170 */ 172 */
171 173 if (acpi_pstate_strict) {
172 port = data->acpi_data.status_register.address; 174 /* Then we read the 'status_register' and compare the value
173 bit_width = data->acpi_data.status_register.bit_width; 175 * with the target state's 'status' to make sure the
174 176 * transition was successful.
175 dprintk("Looking for 0x%08x from port 0x%04x\n", 177 * Note that we'll poll for up to 1ms (100 cycles of 10us)
176 (u32) data->acpi_data.states[state].status, port); 178 * before giving up.
177 179 */
178 for (i=0; i<100; i++) { 180
179 ret = acpi_processor_read_port(port, bit_width, &value); 181 port = data->acpi_data.status_register.address;
180 if (ret) { 182 bit_width = data->acpi_data.status_register.bit_width;
181 dprintk("Invalid port width 0x%04x\n", bit_width); 183
182 retval = ret; 184 dprintk("Looking for 0x%08x from port 0x%04x\n",
183 goto migrate_end; 185 (u32) data->acpi_data.states[state].status, port);
186
187 for (i=0; i<100; i++) {
188 ret = acpi_processor_read_port(port, bit_width, &value);
189 if (ret) {
190 dprintk("Invalid port width 0x%04x\n", bit_width);
191 retval = ret;
192 goto migrate_end;
193 }
194 if (value == (u32) data->acpi_data.states[state].status)
195 break;
196 udelay(10);
184 } 197 }
185 if (value == (u32) data->acpi_data.states[state].status) 198 } else {
186 break; 199 i = 0;
187 udelay(10); 200 value = (u32) data->acpi_data.states[state].status;
188 } 201 }
189 202
190 /* notify cpufreq */ 203 /* notify cpufreq */
191 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); 204 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
192 205
193 if (value != (u32) data->acpi_data.states[state].status) { 206 if (unlikely(value != (u32) data->acpi_data.states[state].status)) {
194 unsigned int tmp = cpufreq_freqs.new; 207 unsigned int tmp = cpufreq_freqs.new;
195 cpufreq_freqs.new = cpufreq_freqs.old; 208 cpufreq_freqs.new = cpufreq_freqs.old;
196 cpufreq_freqs.old = tmp; 209 cpufreq_freqs.old = tmp;
@@ -537,6 +550,8 @@ acpi_cpufreq_exit (void)
537 return; 550 return;
538} 551}
539 552
553module_param(acpi_pstate_strict, uint, 0644);
554MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes.");
540 555
541late_initcall(acpi_cpufreq_init); 556late_initcall(acpi_cpufreq_init);
542module_exit(acpi_cpufreq_exit); 557module_exit(acpi_cpufreq_exit);
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 6578f40bd501..ebedd2e21670 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -2421,7 +2421,7 @@ device_initcall(ioapic_init_sysfs);
2421 ACPI-based IOAPIC Configuration 2421 ACPI-based IOAPIC Configuration
2422 -------------------------------------------------------------------------- */ 2422 -------------------------------------------------------------------------- */
2423 2423
2424#ifdef CONFIG_ACPI_BOOT 2424#ifdef CONFIG_ACPI
2425 2425
2426int __init io_apic_get_unique_id (int ioapic, int apic_id) 2426int __init io_apic_get_unique_id (int ioapic, int apic_id)
2427{ 2427{
@@ -2574,4 +2574,4 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2574 return 0; 2574 return 0;
2575} 2575}
2576 2576
2577#endif /*CONFIG_ACPI_BOOT*/ 2577#endif /* CONFIG_ACPI */
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index ce838abb27d8..97dbf289dbd5 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -653,8 +653,6 @@ void __init get_smp_config (void)
653 struct intel_mp_floating *mpf = mpf_found; 653 struct intel_mp_floating *mpf = mpf_found;
654 654
655 /* 655 /*
656 * ACPI may be used to obtain the entire SMP configuration or just to
657 * enumerate/configure processors (CONFIG_ACPI_BOOT). Note that
658 * ACPI supports both logical (e.g. Hyper-Threading) and physical 656 * ACPI supports both logical (e.g. Hyper-Threading) and physical
659 * processors, where MPS only supports physical. 657 * processors, where MPS only supports physical.
660 */ 658 */
@@ -810,7 +808,7 @@ void __init find_smp_config (void)
810 ACPI-based MP Configuration 808 ACPI-based MP Configuration
811 -------------------------------------------------------------------------- */ 809 -------------------------------------------------------------------------- */
812 810
813#ifdef CONFIG_ACPI_BOOT 811#ifdef CONFIG_ACPI
814 812
815void __init mp_register_lapic_address ( 813void __init mp_register_lapic_address (
816 u64 address) 814 u64 address)
@@ -856,7 +854,7 @@ void __init mp_register_lapic (
856 MP_processor_info(&processor); 854 MP_processor_info(&processor);
857} 855}
858 856
859#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT)) 857#ifdef CONFIG_X86_IO_APIC
860 858
861#define MP_ISA_BUS 0 859#define MP_ISA_BUS 0
862#define MP_MAX_IOAPIC_PIN 127 860#define MP_MAX_IOAPIC_PIN 127
@@ -1071,11 +1069,9 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1071 */ 1069 */
1072 static int gsi_to_irq[MAX_GSI_NUM]; 1070 static int gsi_to_irq[MAX_GSI_NUM];
1073 1071
1074#ifdef CONFIG_ACPI_BUS
1075 /* Don't set up the ACPI SCI because it's already set up */ 1072 /* Don't set up the ACPI SCI because it's already set up */
1076 if (acpi_fadt.sci_int == gsi) 1073 if (acpi_fadt.sci_int == gsi)
1077 return gsi; 1074 return gsi;
1078#endif
1079 1075
1080 ioapic = mp_find_ioapic(gsi); 1076 ioapic = mp_find_ioapic(gsi);
1081 if (ioapic < 0) { 1077 if (ioapic < 0) {
@@ -1118,13 +1114,11 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1118 if (gsi < MAX_GSI_NUM) { 1114 if (gsi < MAX_GSI_NUM) {
1119 if (gsi > 15) 1115 if (gsi > 15)
1120 gsi = pci_irq++; 1116 gsi = pci_irq++;
1121#ifdef CONFIG_ACPI_BUS
1122 /* 1117 /*
1123 * Don't assign IRQ used by ACPI SCI 1118 * Don't assign IRQ used by ACPI SCI
1124 */ 1119 */
1125 if (gsi == acpi_fadt.sci_int) 1120 if (gsi == acpi_fadt.sci_int)
1126 gsi = pci_irq++; 1121 gsi = pci_irq++;
1127#endif
1128 gsi_to_irq[irq] = gsi; 1122 gsi_to_irq[irq] = gsi;
1129 } else { 1123 } else {
1130 printk(KERN_ERR "GSI %u is too high\n", gsi); 1124 printk(KERN_ERR "GSI %u is too high\n", gsi);
@@ -1138,5 +1132,5 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1138 return gsi; 1132 return gsi;
1139} 1133}
1140 1134
1141#endif /*CONFIG_X86_IO_APIC && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)*/ 1135#endif /* CONFIG_X86_IO_APIC */
1142#endif /*CONFIG_ACPI_BOOT*/ 1136#endif /* CONFIG_ACPI */
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index af4de58cab54..d52eda399a7a 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -87,14 +87,14 @@ EXPORT_SYMBOL(boot_cpu_data);
87 87
88unsigned long mmu_cr4_features; 88unsigned long mmu_cr4_features;
89 89
90#ifdef CONFIG_ACPI_INTERPRETER 90#ifdef CONFIG_ACPI
91 int acpi_disabled = 0; 91 int acpi_disabled = 0;
92#else 92#else
93 int acpi_disabled = 1; 93 int acpi_disabled = 1;
94#endif 94#endif
95EXPORT_SYMBOL(acpi_disabled); 95EXPORT_SYMBOL(acpi_disabled);
96 96
97#ifdef CONFIG_ACPI_BOOT 97#ifdef CONFIG_ACPI
98int __initdata acpi_force = 0; 98int __initdata acpi_force = 0;
99extern acpi_interrupt_flags acpi_sci_flags; 99extern acpi_interrupt_flags acpi_sci_flags;
100#endif 100#endif
@@ -794,7 +794,7 @@ static void __init parse_cmdline_early (char ** cmdline_p)
794 } 794 }
795#endif 795#endif
796 796
797#ifdef CONFIG_ACPI_BOOT 797#ifdef CONFIG_ACPI
798 /* "acpi=off" disables both ACPI table parsing and interpreter */ 798 /* "acpi=off" disables both ACPI table parsing and interpreter */
799 else if (!memcmp(from, "acpi=off", 8)) { 799 else if (!memcmp(from, "acpi=off", 8)) {
800 disable_acpi(); 800 disable_acpi();
@@ -850,7 +850,7 @@ static void __init parse_cmdline_early (char ** cmdline_p)
850 else if (!memcmp(from, "noapic", 6)) 850 else if (!memcmp(from, "noapic", 6))
851 disable_ioapic_setup(); 851 disable_ioapic_setup();
852#endif /* CONFIG_X86_LOCAL_APIC */ 852#endif /* CONFIG_X86_LOCAL_APIC */
853#endif /* CONFIG_ACPI_BOOT */ 853#endif /* CONFIG_ACPI */
854 854
855#ifdef CONFIG_X86_LOCAL_APIC 855#ifdef CONFIG_X86_LOCAL_APIC
856 /* enable local APIC */ 856 /* enable local APIC */
@@ -1575,7 +1575,7 @@ void __init setup_arch(char **cmdline_p)
1575 if (efi_enabled) 1575 if (efi_enabled)
1576 efi_map_memmap(); 1576 efi_map_memmap();
1577 1577
1578#ifdef CONFIG_ACPI_BOOT 1578#ifdef CONFIG_ACPI
1579 /* 1579 /*
1580 * Parse the ACPI tables for possible boot-time SMP configuration. 1580 * Parse the ACPI tables for possible boot-time SMP configuration.
1581 */ 1581 */
diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
index d5936d500479..f549c0efdb9f 100644
--- a/arch/i386/mach-es7000/es7000plat.c
+++ b/arch/i386/mach-es7000/es7000plat.c
@@ -51,7 +51,7 @@ struct mip_reg *host_reg;
51int mip_port; 51int mip_port;
52unsigned long mip_addr, host_addr; 52unsigned long mip_addr, host_addr;
53 53
54#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT)) 54#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
55 55
56/* 56/*
57 * GSI override for ES7000 platforms. 57 * GSI override for ES7000 platforms.
@@ -73,7 +73,7 @@ es7000_rename_gsi(int ioapic, int gsi)
73 return gsi; 73 return gsi;
74} 74}
75 75
76#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT) 76#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
77 77
78/* 78/*
79 * Parse the OEM Table 79 * Parse the OEM Table
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
index 1bff03f36965..ead6122dd06d 100644
--- a/arch/i386/pci/Makefile
+++ b/arch/i386/pci/Makefile
@@ -5,7 +5,7 @@ obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
5obj-$(CONFIG_PCI_DIRECT) += direct.o 5obj-$(CONFIG_PCI_DIRECT) += direct.o
6 6
7pci-y := fixup.o 7pci-y := fixup.o
8pci-$(CONFIG_ACPI_PCI) += acpi.o 8pci-$(CONFIG_ACPI) += acpi.o
9pci-y += legacy.o irq.o 9pci-y += legacy.o irq.o
10 10
11pci-$(CONFIG_X86_VISWS) := visws.o fixup.o 11pci-$(CONFIG_X86_VISWS) := visws.o fixup.o
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index 86348b68fda1..326a2edc3834 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -1075,7 +1075,7 @@ static void pirq_penalize_isa_irq(int irq, int active)
1075 1075
1076void pcibios_penalize_isa_irq(int irq, int active) 1076void pcibios_penalize_isa_irq(int irq, int active)
1077{ 1077{
1078#ifdef CONFIG_ACPI_PCI 1078#ifdef CONFIG_ACPI
1079 if (!acpi_noirq) 1079 if (!acpi_noirq)
1080 acpi_penalize_isa_irq(irq, active); 1080 acpi_penalize_isa_irq(irq, active);
1081 else 1081 else
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 3deced637f07..e1c9ea03f31f 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -60,6 +60,7 @@ choice
60 60
61config IA64_GENERIC 61config IA64_GENERIC
62 bool "generic" 62 bool "generic"
63 select ACPI
63 select NUMA 64 select NUMA
64 select ACPI_NUMA 65 select ACPI_NUMA
65 select VIRTUAL_MEM_MAP 66 select VIRTUAL_MEM_MAP
@@ -340,6 +341,7 @@ config IA64_PALINFO
340 341
341config ACPI_DEALLOCATE_IRQ 342config ACPI_DEALLOCATE_IRQ
342 bool 343 bool
344 depends on ACPI
343 depends on IOSAPIC && EXPERIMENTAL 345 depends on IOSAPIC && EXPERIMENTAL
344 default y 346 default y
345 347
@@ -351,38 +353,10 @@ endmenu
351 353
352menu "Power management and ACPI" 354menu "Power management and ACPI"
353 355
354config PM 356source "kernel/power/Kconfig"
355 bool "Power Management support"
356 depends on !IA64_HP_SIM
357 default y
358 help
359 "Power Management" means that parts of your computer are shut
360 off or put into a power conserving "sleep" mode if they are not
361 being used. There are two competing standards for doing this: APM
362 and ACPI. If you want to use either one, say Y here and then also
363 to the requisite support below.
364
365 Power Management is most important for battery powered laptop
366 computers; if you have a laptop, check out the Linux Laptop home
367 page on the WWW at <http://www.linux-on-laptops.com/> and the
368 Battery Powered Linux mini-HOWTO, available from
369 <http://www.tldp.org/docs.html#howto>.
370
371 Note that, even if you say N here, Linux on the x86 architecture
372 will issue the hlt instruction if nothing is to be done, thereby
373 sending the processor to sleep and saving power.
374
375config ACPI
376 bool
377 depends on !IA64_HP_SIM
378 default y
379
380if !IA64_HP_SIM
381 357
382source "drivers/acpi/Kconfig" 358source "drivers/acpi/Kconfig"
383 359
384endif
385
386if PM 360if PM
387 361
388source "arch/ia64/kernel/cpufreq/Kconfig" 362source "arch/ia64/kernel/cpufreq/Kconfig"
diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig
index b95fcf86ea00..3b65cbb31b1d 100644
--- a/arch/ia64/configs/bigsur_defconfig
+++ b/arch/ia64/configs/bigsur_defconfig
@@ -107,18 +107,12 @@ CONFIG_ACPI=y
107# 107#
108# ACPI (Advanced Configuration and Power Interface) Support 108# ACPI (Advanced Configuration and Power Interface) Support
109# 109#
110CONFIG_ACPI_BOOT=y
111CONFIG_ACPI_INTERPRETER=y
112CONFIG_ACPI_BUTTON=m 110CONFIG_ACPI_BUTTON=m
113CONFIG_ACPI_VIDEO=m
114CONFIG_ACPI_FAN=m 111CONFIG_ACPI_FAN=m
115CONFIG_ACPI_PROCESSOR=m 112CONFIG_ACPI_PROCESSOR=m
116CONFIG_ACPI_THERMAL=m 113CONFIG_ACPI_THERMAL=m
117CONFIG_ACPI_BLACKLIST_YEAR=0
118# CONFIG_ACPI_DEBUG is not set 114# CONFIG_ACPI_DEBUG is not set
119CONFIG_ACPI_BUS=y
120CONFIG_ACPI_POWER=y 115CONFIG_ACPI_POWER=y
121CONFIG_ACPI_PCI=y
122CONFIG_ACPI_SYSTEM=y 116CONFIG_ACPI_SYSTEM=y
123 117
124# 118#
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index dccf35c60b94..1ca6e6e11b42 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -130,19 +130,12 @@ CONFIG_ACPI=y
130# 130#
131# ACPI (Advanced Configuration and Power Interface) Support 131# ACPI (Advanced Configuration and Power Interface) Support
132# 132#
133CONFIG_ACPI_BOOT=y
134CONFIG_ACPI_INTERPRETER=y
135# CONFIG_ACPI_BUTTON is not set 133# CONFIG_ACPI_BUTTON is not set
136CONFIG_ACPI_VIDEO=m
137CONFIG_ACPI_HOTKEY=m
138# CONFIG_ACPI_FAN is not set 134# CONFIG_ACPI_FAN is not set
139# CONFIG_ACPI_PROCESSOR is not set 135# CONFIG_ACPI_PROCESSOR is not set
140CONFIG_ACPI_NUMA=y 136CONFIG_ACPI_NUMA=y
141CONFIG_ACPI_BLACKLIST_YEAR=0
142# CONFIG_ACPI_DEBUG is not set 137# CONFIG_ACPI_DEBUG is not set
143CONFIG_ACPI_BUS=y
144CONFIG_ACPI_POWER=y 138CONFIG_ACPI_POWER=y
145CONFIG_ACPI_PCI=y
146CONFIG_ACPI_SYSTEM=y 139CONFIG_ACPI_SYSTEM=y
147# CONFIG_ACPI_CONTAINER is not set 140# CONFIG_ACPI_CONTAINER is not set
148 141
diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
index c853cfcd2d11..3ec94a12eac0 100644
--- a/arch/ia64/configs/tiger_defconfig
+++ b/arch/ia64/configs/tiger_defconfig
@@ -128,20 +128,13 @@ CONFIG_ACPI=y
128# 128#
129# ACPI (Advanced Configuration and Power Interface) Support 129# ACPI (Advanced Configuration and Power Interface) Support
130# 130#
131CONFIG_ACPI_BOOT=y
132CONFIG_ACPI_INTERPRETER=y
133CONFIG_ACPI_BUTTON=m 131CONFIG_ACPI_BUTTON=m
134# CONFIG_ACPI_VIDEO is not set
135# CONFIG_ACPI_HOTKEY is not set
136CONFIG_ACPI_FAN=m 132CONFIG_ACPI_FAN=m
137CONFIG_ACPI_PROCESSOR=m 133CONFIG_ACPI_PROCESSOR=m
138# CONFIG_ACPI_HOTPLUG_CPU is not set 134# CONFIG_ACPI_HOTPLUG_CPU is not set
139CONFIG_ACPI_THERMAL=m 135CONFIG_ACPI_THERMAL=m
140CONFIG_ACPI_BLACKLIST_YEAR=0
141# CONFIG_ACPI_DEBUG is not set 136# CONFIG_ACPI_DEBUG is not set
142CONFIG_ACPI_BUS=y
143CONFIG_ACPI_POWER=y 137CONFIG_ACPI_POWER=y
144CONFIG_ACPI_PCI=y
145CONFIG_ACPI_SYSTEM=y 138CONFIG_ACPI_SYSTEM=y
146# CONFIG_ACPI_CONTAINER is not set 139# CONFIG_ACPI_CONTAINER is not set
147 140
diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig
index 88e8867fa8e8..d4cf73d124bc 100644
--- a/arch/ia64/configs/zx1_defconfig
+++ b/arch/ia64/configs/zx1_defconfig
@@ -128,19 +128,12 @@ CONFIG_ACPI=y
128# 128#
129# ACPI (Advanced Configuration and Power Interface) Support 129# ACPI (Advanced Configuration and Power Interface) Support
130# 130#
131CONFIG_ACPI_BOOT=y
132CONFIG_ACPI_INTERPRETER=y
133CONFIG_ACPI_BUTTON=y 131CONFIG_ACPI_BUTTON=y
134CONFIG_ACPI_VIDEO=m
135CONFIG_ACPI_HOTKEY=m
136CONFIG_ACPI_FAN=y 132CONFIG_ACPI_FAN=y
137CONFIG_ACPI_PROCESSOR=y 133CONFIG_ACPI_PROCESSOR=y
138CONFIG_ACPI_THERMAL=y 134CONFIG_ACPI_THERMAL=y
139CONFIG_ACPI_BLACKLIST_YEAR=0
140# CONFIG_ACPI_DEBUG is not set 135# CONFIG_ACPI_DEBUG is not set
141CONFIG_ACPI_BUS=y
142CONFIG_ACPI_POWER=y 136CONFIG_ACPI_POWER=y
143CONFIG_ACPI_PCI=y
144CONFIG_ACPI_SYSTEM=y 137CONFIG_ACPI_SYSTEM=y
145# CONFIG_ACPI_CONTAINER is not set 138# CONFIG_ACPI_CONTAINER is not set
146 139
diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig
index 8444add76380..b6ec8d32c346 100644
--- a/arch/ia64/defconfig
+++ b/arch/ia64/defconfig
@@ -118,20 +118,14 @@ CONFIG_ACPI=y
118# 118#
119# ACPI (Advanced Configuration and Power Interface) Support 119# ACPI (Advanced Configuration and Power Interface) Support
120# 120#
121CONFIG_ACPI_BOOT=y
122CONFIG_ACPI_INTERPRETER=y
123CONFIG_ACPI_BUTTON=m 121CONFIG_ACPI_BUTTON=m
124CONFIG_ACPI_VIDEO=m
125CONFIG_ACPI_FAN=m 122CONFIG_ACPI_FAN=m
126CONFIG_ACPI_PROCESSOR=m 123CONFIG_ACPI_PROCESSOR=m
127CONFIG_ACPI_HOTPLUG_CPU=y 124CONFIG_ACPI_HOTPLUG_CPU=y
128CONFIG_ACPI_THERMAL=m 125CONFIG_ACPI_THERMAL=m
129CONFIG_ACPI_NUMA=y 126CONFIG_ACPI_NUMA=y
130CONFIG_ACPI_BLACKLIST_YEAR=0
131# CONFIG_ACPI_DEBUG is not set 127# CONFIG_ACPI_DEBUG is not set
132CONFIG_ACPI_BUS=y
133CONFIG_ACPI_POWER=y 128CONFIG_ACPI_POWER=y
134CONFIG_ACPI_PCI=y
135CONFIG_ACPI_SYSTEM=y 129CONFIG_ACPI_SYSTEM=y
136CONFIG_ACPI_CONTAINER=m 130CONFIG_ACPI_CONTAINER=m
137 131
diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c
index 2623df5e2633..13a5b3b49bf8 100644
--- a/arch/ia64/kernel/acpi-ext.c
+++ b/arch/ia64/kernel/acpi-ext.c
@@ -17,20 +17,20 @@
17#include <asm/acpi-ext.h> 17#include <asm/acpi-ext.h>
18 18
19struct acpi_vendor_descriptor { 19struct acpi_vendor_descriptor {
20 u8 guid_id; 20 u8 guid_id;
21 efi_guid_t guid; 21 efi_guid_t guid;
22}; 22};
23 23
24struct acpi_vendor_info { 24struct acpi_vendor_info {
25 struct acpi_vendor_descriptor *descriptor; 25 struct acpi_vendor_descriptor *descriptor;
26 u8 *data; 26 u8 *data;
27 u32 length; 27 u32 length;
28}; 28};
29 29
30acpi_status 30acpi_status
31acpi_vendor_resource_match(struct acpi_resource *resource, void *context) 31acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
32{ 32{
33 struct acpi_vendor_info *info = (struct acpi_vendor_info *) context; 33 struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
34 struct acpi_resource_vendor *vendor; 34 struct acpi_resource_vendor *vendor;
35 struct acpi_vendor_descriptor *descriptor; 35 struct acpi_vendor_descriptor *descriptor;
36 u32 length; 36 u32 length;
@@ -38,8 +38,8 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
38 if (resource->id != ACPI_RSTYPE_VENDOR) 38 if (resource->id != ACPI_RSTYPE_VENDOR)
39 return AE_OK; 39 return AE_OK;
40 40
41 vendor = (struct acpi_resource_vendor *) &resource->data; 41 vendor = (struct acpi_resource_vendor *)&resource->data;
42 descriptor = (struct acpi_vendor_descriptor *) vendor->reserved; 42 descriptor = (struct acpi_vendor_descriptor *)vendor->reserved;
43 if (vendor->length <= sizeof(*info->descriptor) || 43 if (vendor->length <= sizeof(*info->descriptor) ||
44 descriptor->guid_id != info->descriptor->guid_id || 44 descriptor->guid_id != info->descriptor->guid_id ||
45 efi_guidcmp(descriptor->guid, info->descriptor->guid)) 45 efi_guidcmp(descriptor->guid, info->descriptor->guid))
@@ -50,21 +50,24 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
50 if (!info->data) 50 if (!info->data)
51 return AE_NO_MEMORY; 51 return AE_NO_MEMORY;
52 52
53 memcpy(info->data, vendor->reserved + sizeof(struct acpi_vendor_descriptor), length); 53 memcpy(info->data,
54 vendor->reserved + sizeof(struct acpi_vendor_descriptor),
55 length);
54 info->length = length; 56 info->length = length;
55 return AE_CTRL_TERMINATE; 57 return AE_CTRL_TERMINATE;
56} 58}
57 59
58acpi_status 60acpi_status
59acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id, 61acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
60 u8 **data, u32 *length) 62 u8 ** data, u32 * length)
61{ 63{
62 struct acpi_vendor_info info; 64 struct acpi_vendor_info info;
63 65
64 info.descriptor = id; 66 info.descriptor = id;
65 info.data = NULL; 67 info.data = NULL;
66 68
67 acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match, &info); 69 acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match,
70 &info);
68 if (!info.data) 71 if (!info.data)
69 return AE_NOT_FOUND; 72 return AE_NOT_FOUND;
70 73
@@ -75,17 +78,19 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id,
75 78
76struct acpi_vendor_descriptor hp_ccsr_descriptor = { 79struct acpi_vendor_descriptor hp_ccsr_descriptor = {
77 .guid_id = 2, 80 .guid_id = 2,
78 .guid = EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad) 81 .guid =
82 EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01,
83 0x37, 0x0e, 0xad)
79}; 84};
80 85
81acpi_status 86acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
82hp_acpi_csr_space(acpi_handle obj, u64 *csr_base, u64 *csr_length)
83{ 87{
84 acpi_status status; 88 acpi_status status;
85 u8 *data; 89 u8 *data;
86 u32 length; 90 u32 length;
87 91
88 status = acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length); 92 status =
93 acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
89 94
90 if (ACPI_FAILURE(status) || length != 16) 95 if (ACPI_FAILURE(status) || length != 16)
91 return AE_NOT_FOUND; 96 return AE_NOT_FOUND;
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 9609f243e5d0..318787c84ac0 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -74,12 +74,11 @@ unsigned int acpi_cpei_override;
74unsigned int acpi_cpei_phys_cpuid; 74unsigned int acpi_cpei_phys_cpuid;
75 75
76#define MAX_SAPICS 256 76#define MAX_SAPICS 256
77u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = 77u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0 ... MAX_SAPICS - 1] = -1 };
78 { [0 ... MAX_SAPICS - 1] = -1 }; 78
79EXPORT_SYMBOL(ia64_acpiid_to_sapicid); 79EXPORT_SYMBOL(ia64_acpiid_to_sapicid);
80 80
81const char * 81const char *acpi_get_sysname(void)
82acpi_get_sysname (void)
83{ 82{
84#ifdef CONFIG_IA64_GENERIC 83#ifdef CONFIG_IA64_GENERIC
85 unsigned long rsdp_phys; 84 unsigned long rsdp_phys;
@@ -89,27 +88,29 @@ acpi_get_sysname (void)
89 88
90 rsdp_phys = acpi_find_rsdp(); 89 rsdp_phys = acpi_find_rsdp();
91 if (!rsdp_phys) { 90 if (!rsdp_phys) {
92 printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n"); 91 printk(KERN_ERR
92 "ACPI 2.0 RSDP not found, default to \"dig\"\n");
93 return "dig"; 93 return "dig";
94 } 94 }
95 95
96 rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys); 96 rsdp = (struct acpi20_table_rsdp *)__va(rsdp_phys);
97 if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) { 97 if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
98 printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); 98 printk(KERN_ERR
99 "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
99 return "dig"; 100 return "dig";
100 } 101 }
101 102
102 xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address); 103 xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_address);
103 hdr = &xsdt->header; 104 hdr = &xsdt->header;
104 if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) { 105 if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) {
105 printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); 106 printk(KERN_ERR
107 "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
106 return "dig"; 108 return "dig";
107 } 109 }
108 110
109 if (!strcmp(hdr->oem_id, "HP")) { 111 if (!strcmp(hdr->oem_id, "HP")) {
110 return "hpzx1"; 112 return "hpzx1";
111 } 113 } else if (!strcmp(hdr->oem_id, "SGI")) {
112 else if (!strcmp(hdr->oem_id, "SGI")) {
113 return "sn2"; 114 return "sn2";
114 } 115 }
115 116
@@ -131,7 +132,7 @@ acpi_get_sysname (void)
131#endif 132#endif
132} 133}
133 134
134#ifdef CONFIG_ACPI_BOOT 135#ifdef CONFIG_ACPI
135 136
136#define ACPI_MAX_PLATFORM_INTERRUPTS 256 137#define ACPI_MAX_PLATFORM_INTERRUPTS 256
137 138
@@ -146,8 +147,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
146 * Interrupt routing API for device drivers. Provides interrupt vector for 147 * Interrupt routing API for device drivers. Provides interrupt vector for
147 * a generic platform event. Currently only CPEI is implemented. 148 * a generic platform event. Currently only CPEI is implemented.
148 */ 149 */
149int 150int acpi_request_vector(u32 int_type)
150acpi_request_vector (u32 int_type)
151{ 151{
152 int vector = -1; 152 int vector = -1;
153 153
@@ -155,12 +155,12 @@ acpi_request_vector (u32 int_type)
155 /* corrected platform error interrupt */ 155 /* corrected platform error interrupt */
156 vector = platform_intr_list[int_type]; 156 vector = platform_intr_list[int_type];
157 } else 157 } else
158 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n"); 158 printk(KERN_ERR
159 "acpi_request_vector(): invalid interrupt type\n");
159 return vector; 160 return vector;
160} 161}
161 162
162char * 163char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
163__acpi_map_table (unsigned long phys_addr, unsigned long size)
164{ 164{
165 return __va(phys_addr); 165 return __va(phys_addr);
166} 166}
@@ -169,19 +169,18 @@ __acpi_map_table (unsigned long phys_addr, unsigned long size)
169 Boot-time Table Parsing 169 Boot-time Table Parsing
170 -------------------------------------------------------------------------- */ 170 -------------------------------------------------------------------------- */
171 171
172static int total_cpus __initdata; 172static int total_cpus __initdata;
173static int available_cpus __initdata; 173static int available_cpus __initdata;
174struct acpi_table_madt * acpi_madt __initdata; 174struct acpi_table_madt *acpi_madt __initdata;
175static u8 has_8259; 175static u8 has_8259;
176
177 176
178static int __init 177static int __init
179acpi_parse_lapic_addr_ovr ( 178acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
180 acpi_table_entry_header *header, const unsigned long end) 179 const unsigned long end)
181{ 180{
182 struct acpi_table_lapic_addr_ovr *lapic; 181 struct acpi_table_lapic_addr_ovr *lapic;
183 182
184 lapic = (struct acpi_table_lapic_addr_ovr *) header; 183 lapic = (struct acpi_table_lapic_addr_ovr *)header;
185 184
186 if (BAD_MADT_ENTRY(lapic, end)) 185 if (BAD_MADT_ENTRY(lapic, end))
187 return -EINVAL; 186 return -EINVAL;
@@ -193,22 +192,23 @@ acpi_parse_lapic_addr_ovr (
193 return 0; 192 return 0;
194} 193}
195 194
196
197static int __init 195static int __init
198acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end) 196acpi_parse_lsapic(acpi_table_entry_header * header, const unsigned long end)
199{ 197{
200 struct acpi_table_lsapic *lsapic; 198 struct acpi_table_lsapic *lsapic;
201 199
202 lsapic = (struct acpi_table_lsapic *) header; 200 lsapic = (struct acpi_table_lsapic *)header;
203 201
204 if (BAD_MADT_ENTRY(lsapic, end)) 202 if (BAD_MADT_ENTRY(lsapic, end))
205 return -EINVAL; 203 return -EINVAL;
206 204
207 if (lsapic->flags.enabled) { 205 if (lsapic->flags.enabled) {
208#ifdef CONFIG_SMP 206#ifdef CONFIG_SMP
209 smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid; 207 smp_boot_data.cpu_phys_id[available_cpus] =
208 (lsapic->id << 8) | lsapic->eid;
210#endif 209#endif
211 ia64_acpiid_to_sapicid[lsapic->acpi_id] = (lsapic->id << 8) | lsapic->eid; 210 ia64_acpiid_to_sapicid[lsapic->acpi_id] =
211 (lsapic->id << 8) | lsapic->eid;
212 ++available_cpus; 212 ++available_cpus;
213 } 213 }
214 214
@@ -216,13 +216,12 @@ acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end)
216 return 0; 216 return 0;
217} 217}
218 218
219
220static int __init 219static int __init
221acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end) 220acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
222{ 221{
223 struct acpi_table_lapic_nmi *lacpi_nmi; 222 struct acpi_table_lapic_nmi *lacpi_nmi;
224 223
225 lacpi_nmi = (struct acpi_table_lapic_nmi*) header; 224 lacpi_nmi = (struct acpi_table_lapic_nmi *)header;
226 225
227 if (BAD_MADT_ENTRY(lacpi_nmi, end)) 226 if (BAD_MADT_ENTRY(lacpi_nmi, end))
228 return -EINVAL; 227 return -EINVAL;
@@ -231,13 +230,12 @@ acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
231 return 0; 230 return 0;
232} 231}
233 232
234
235static int __init 233static int __init
236acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) 234acpi_parse_iosapic(acpi_table_entry_header * header, const unsigned long end)
237{ 235{
238 struct acpi_table_iosapic *iosapic; 236 struct acpi_table_iosapic *iosapic;
239 237
240 iosapic = (struct acpi_table_iosapic *) header; 238 iosapic = (struct acpi_table_iosapic *)header;
241 239
242 if (BAD_MADT_ENTRY(iosapic, end)) 240 if (BAD_MADT_ENTRY(iosapic, end))
243 return -EINVAL; 241 return -EINVAL;
@@ -245,15 +243,14 @@ acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
245 return iosapic_init(iosapic->address, iosapic->global_irq_base); 243 return iosapic_init(iosapic->address, iosapic->global_irq_base);
246} 244}
247 245
248
249static int __init 246static int __init
250acpi_parse_plat_int_src ( 247acpi_parse_plat_int_src(acpi_table_entry_header * header,
251 acpi_table_entry_header *header, const unsigned long end) 248 const unsigned long end)
252{ 249{
253 struct acpi_table_plat_int_src *plintsrc; 250 struct acpi_table_plat_int_src *plintsrc;
254 int vector; 251 int vector;
255 252
256 plintsrc = (struct acpi_table_plat_int_src *) header; 253 plintsrc = (struct acpi_table_plat_int_src *)header;
257 254
258 if (BAD_MADT_ENTRY(plintsrc, end)) 255 if (BAD_MADT_ENTRY(plintsrc, end))
259 return -EINVAL; 256 return -EINVAL;
@@ -267,8 +264,12 @@ acpi_parse_plat_int_src (
267 plintsrc->iosapic_vector, 264 plintsrc->iosapic_vector,
268 plintsrc->eid, 265 plintsrc->eid,
269 plintsrc->id, 266 plintsrc->id,
270 (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 267 (plintsrc->flags.polarity ==
271 (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 268 1) ? IOSAPIC_POL_HIGH :
269 IOSAPIC_POL_LOW,
270 (plintsrc->flags.trigger ==
271 1) ? IOSAPIC_EDGE :
272 IOSAPIC_LEVEL);
272 273
273 platform_intr_list[plintsrc->type] = vector; 274 platform_intr_list[plintsrc->type] = vector;
274 if (acpi_madt_rev > 1) { 275 if (acpi_madt_rev > 1) {
@@ -283,7 +284,6 @@ acpi_parse_plat_int_src (
283 return 0; 284 return 0;
284} 285}
285 286
286
287unsigned int can_cpei_retarget(void) 287unsigned int can_cpei_retarget(void)
288{ 288{
289 extern int cpe_vector; 289 extern int cpe_vector;
@@ -322,29 +322,30 @@ unsigned int get_cpei_target_cpu(void)
322} 322}
323 323
324static int __init 324static int __init
325acpi_parse_int_src_ovr ( 325acpi_parse_int_src_ovr(acpi_table_entry_header * header,
326 acpi_table_entry_header *header, const unsigned long end) 326 const unsigned long end)
327{ 327{
328 struct acpi_table_int_src_ovr *p; 328 struct acpi_table_int_src_ovr *p;
329 329
330 p = (struct acpi_table_int_src_ovr *) header; 330 p = (struct acpi_table_int_src_ovr *)header;
331 331
332 if (BAD_MADT_ENTRY(p, end)) 332 if (BAD_MADT_ENTRY(p, end))
333 return -EINVAL; 333 return -EINVAL;
334 334
335 iosapic_override_isa_irq(p->bus_irq, p->global_irq, 335 iosapic_override_isa_irq(p->bus_irq, p->global_irq,
336 (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 336 (p->flags.polarity ==
337 (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 337 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
338 (p->flags.trigger ==
339 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
338 return 0; 340 return 0;
339} 341}
340 342
341
342static int __init 343static int __init
343acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end) 344acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
344{ 345{
345 struct acpi_table_nmi_src *nmi_src; 346 struct acpi_table_nmi_src *nmi_src;
346 347
347 nmi_src = (struct acpi_table_nmi_src*) header; 348 nmi_src = (struct acpi_table_nmi_src *)header;
348 349
349 if (BAD_MADT_ENTRY(nmi_src, end)) 350 if (BAD_MADT_ENTRY(nmi_src, end))
350 return -EINVAL; 351 return -EINVAL;
@@ -353,11 +354,9 @@ acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
353 return 0; 354 return 0;
354} 355}
355 356
356static void __init 357static void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
357acpi_madt_oem_check (char *oem_id, char *oem_table_id)
358{ 358{
359 if (!strncmp(oem_id, "IBM", 3) && 359 if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))) {
360 (!strncmp(oem_table_id, "SERMOW", 6))) {
361 360
362 /* 361 /*
363 * Unfortunately ITC_DRIFT is not yet part of the 362 * Unfortunately ITC_DRIFT is not yet part of the
@@ -370,19 +369,18 @@ acpi_madt_oem_check (char *oem_id, char *oem_table_id)
370 } 369 }
371} 370}
372 371
373static int __init 372static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
374acpi_parse_madt (unsigned long phys_addr, unsigned long size)
375{ 373{
376 if (!phys_addr || !size) 374 if (!phys_addr || !size)
377 return -EINVAL; 375 return -EINVAL;
378 376
379 acpi_madt = (struct acpi_table_madt *) __va(phys_addr); 377 acpi_madt = (struct acpi_table_madt *)__va(phys_addr);
380 378
381 acpi_madt_rev = acpi_madt->header.revision; 379 acpi_madt_rev = acpi_madt->header.revision;
382 380
383 /* remember the value for reference after free_initmem() */ 381 /* remember the value for reference after free_initmem() */
384#ifdef CONFIG_ITANIUM 382#ifdef CONFIG_ITANIUM
385 has_8259 = 1; /* Firmware on old Itanium systems is broken */ 383 has_8259 = 1; /* Firmware on old Itanium systems is broken */
386#else 384#else
387 has_8259 = acpi_madt->flags.pcat_compat; 385 has_8259 = acpi_madt->flags.pcat_compat;
388#endif 386#endif
@@ -396,19 +394,18 @@ acpi_parse_madt (unsigned long phys_addr, unsigned long size)
396 printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr); 394 printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr);
397 395
398 acpi_madt_oem_check(acpi_madt->header.oem_id, 396 acpi_madt_oem_check(acpi_madt->header.oem_id,
399 acpi_madt->header.oem_table_id); 397 acpi_madt->header.oem_table_id);
400 398
401 return 0; 399 return 0;
402} 400}
403 401
404
405#ifdef CONFIG_ACPI_NUMA 402#ifdef CONFIG_ACPI_NUMA
406 403
407#undef SLIT_DEBUG 404#undef SLIT_DEBUG
408 405
409#define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32) 406#define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32)
410 407
411static int __initdata srat_num_cpus; /* number of cpus */ 408static int __initdata srat_num_cpus; /* number of cpus */
412static u32 __devinitdata pxm_flag[PXM_FLAG_LEN]; 409static u32 __devinitdata pxm_flag[PXM_FLAG_LEN];
413#define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag)) 410#define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag))
414#define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag)) 411#define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag))
@@ -421,15 +418,15 @@ static struct acpi_table_slit __initdata *slit_table;
421 * ACPI 2.0 SLIT (System Locality Information Table) 418 * ACPI 2.0 SLIT (System Locality Information Table)
422 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf 419 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
423 */ 420 */
424void __init 421void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
425acpi_numa_slit_init (struct acpi_table_slit *slit)
426{ 422{
427 u32 len; 423 u32 len;
428 424
429 len = sizeof(struct acpi_table_header) + 8 425 len = sizeof(struct acpi_table_header) + 8
430 + slit->localities * slit->localities; 426 + slit->localities * slit->localities;
431 if (slit->header.length != len) { 427 if (slit->header.length != len) {
432 printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", 428 printk(KERN_ERR
429 "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n",
433 len, slit->header.length); 430 len, slit->header.length);
434 memset(numa_slit, 10, sizeof(numa_slit)); 431 memset(numa_slit, 10, sizeof(numa_slit));
435 return; 432 return;
@@ -438,19 +435,20 @@ acpi_numa_slit_init (struct acpi_table_slit *slit)
438} 435}
439 436
440void __init 437void __init
441acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa) 438acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
442{ 439{
443 /* record this node in proximity bitmap */ 440 /* record this node in proximity bitmap */
444 pxm_bit_set(pa->proximity_domain); 441 pxm_bit_set(pa->proximity_domain);
445 442
446 node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid); 443 node_cpuid[srat_num_cpus].phys_id =
444 (pa->apic_id << 8) | (pa->lsapic_eid);
447 /* nid should be overridden as logical node id later */ 445 /* nid should be overridden as logical node id later */
448 node_cpuid[srat_num_cpus].nid = pa->proximity_domain; 446 node_cpuid[srat_num_cpus].nid = pa->proximity_domain;
449 srat_num_cpus++; 447 srat_num_cpus++;
450} 448}
451 449
452void __init 450void __init
453acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma) 451acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
454{ 452{
455 unsigned long paddr, size; 453 unsigned long paddr, size;
456 u8 pxm; 454 u8 pxm;
@@ -487,8 +485,7 @@ acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma)
487 num_node_memblks++; 485 num_node_memblks++;
488} 486}
489 487
490void __init 488void __init acpi_numa_arch_fixup(void)
491acpi_numa_arch_fixup (void)
492{ 489{
493 int i, j, node_from, node_to; 490 int i, j, node_from, node_to;
494 491
@@ -534,21 +531,24 @@ acpi_numa_arch_fixup (void)
534 for (i = 0; i < srat_num_cpus; i++) 531 for (i = 0; i < srat_num_cpus; i++)
535 node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid]; 532 node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid];
536 533
537 printk(KERN_INFO "Number of logical nodes in system = %d\n", num_online_nodes()); 534 printk(KERN_INFO "Number of logical nodes in system = %d\n",
538 printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks); 535 num_online_nodes());
536 printk(KERN_INFO "Number of memory chunks in system = %d\n",
537 num_node_memblks);
539 538
540 if (!slit_table) return; 539 if (!slit_table)
540 return;
541 memset(numa_slit, -1, sizeof(numa_slit)); 541 memset(numa_slit, -1, sizeof(numa_slit));
542 for (i=0; i<slit_table->localities; i++) { 542 for (i = 0; i < slit_table->localities; i++) {
543 if (!pxm_bit_test(i)) 543 if (!pxm_bit_test(i))
544 continue; 544 continue;
545 node_from = pxm_to_nid_map[i]; 545 node_from = pxm_to_nid_map[i];
546 for (j=0; j<slit_table->localities; j++) { 546 for (j = 0; j < slit_table->localities; j++) {
547 if (!pxm_bit_test(j)) 547 if (!pxm_bit_test(j))
548 continue; 548 continue;
549 node_to = pxm_to_nid_map[j]; 549 node_to = pxm_to_nid_map[j];
550 node_distance(node_from, node_to) = 550 node_distance(node_from, node_to) =
551 slit_table->entry[i*slit_table->localities + j]; 551 slit_table->entry[i * slit_table->localities + j];
552 } 552 }
553 } 553 }
554 554
@@ -556,36 +556,43 @@ acpi_numa_arch_fixup (void)
556 printk("ACPI 2.0 SLIT locality table:\n"); 556 printk("ACPI 2.0 SLIT locality table:\n");
557 for_each_online_node(i) { 557 for_each_online_node(i) {
558 for_each_online_node(j) 558 for_each_online_node(j)
559 printk("%03d ", node_distance(i,j)); 559 printk("%03d ", node_distance(i, j));
560 printk("\n"); 560 printk("\n");
561 } 561 }
562#endif 562#endif
563} 563}
564#endif /* CONFIG_ACPI_NUMA */ 564#endif /* CONFIG_ACPI_NUMA */
565 565
566unsigned int 566/*
567acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) 567 * success: return IRQ number (>=0)
568 * failure: return < 0
569 */
570int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
568{ 571{
569 if (has_8259 && gsi < 16) 572 if (has_8259 && gsi < 16)
570 return isa_irq_to_vector(gsi); 573 return isa_irq_to_vector(gsi);
571 574
572 return iosapic_register_intr(gsi, 575 return iosapic_register_intr(gsi,
573 (active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 576 (active_high_low ==
574 (edge_level == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 577 ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH :
578 IOSAPIC_POL_LOW,
579 (edge_level ==
580 ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE :
581 IOSAPIC_LEVEL);
575} 582}
583
576EXPORT_SYMBOL(acpi_register_gsi); 584EXPORT_SYMBOL(acpi_register_gsi);
577 585
578#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 586#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
579void 587void acpi_unregister_gsi(u32 gsi)
580acpi_unregister_gsi (u32 gsi)
581{ 588{
582 iosapic_unregister_intr(gsi); 589 iosapic_unregister_intr(gsi);
583} 590}
591
584EXPORT_SYMBOL(acpi_unregister_gsi); 592EXPORT_SYMBOL(acpi_unregister_gsi);
585#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ 593#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
586 594
587static int __init 595static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
588acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
589{ 596{
590 struct acpi_table_header *fadt_header; 597 struct acpi_table_header *fadt_header;
591 struct fadt_descriptor_rev2 *fadt; 598 struct fadt_descriptor_rev2 *fadt;
@@ -593,11 +600,11 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
593 if (!phys_addr || !size) 600 if (!phys_addr || !size)
594 return -EINVAL; 601 return -EINVAL;
595 602
596 fadt_header = (struct acpi_table_header *) __va(phys_addr); 603 fadt_header = (struct acpi_table_header *)__va(phys_addr);
597 if (fadt_header->revision != 3) 604 if (fadt_header->revision != 3)
598 return -ENODEV; /* Only deal with ACPI 2.0 FADT */ 605 return -ENODEV; /* Only deal with ACPI 2.0 FADT */
599 606
600 fadt = (struct fadt_descriptor_rev2 *) fadt_header; 607 fadt = (struct fadt_descriptor_rev2 *)fadt_header;
601 608
602 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER)) 609 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
603 acpi_kbd_controller_present = 0; 610 acpi_kbd_controller_present = 0;
@@ -609,22 +616,19 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
609 return 0; 616 return 0;
610} 617}
611 618
612 619unsigned long __init acpi_find_rsdp(void)
613unsigned long __init
614acpi_find_rsdp (void)
615{ 620{
616 unsigned long rsdp_phys = 0; 621 unsigned long rsdp_phys = 0;
617 622
618 if (efi.acpi20) 623 if (efi.acpi20)
619 rsdp_phys = __pa(efi.acpi20); 624 rsdp_phys = __pa(efi.acpi20);
620 else if (efi.acpi) 625 else if (efi.acpi)
621 printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n"); 626 printk(KERN_WARNING PREFIX
627 "v1.0/r0.71 tables no longer supported\n");
622 return rsdp_phys; 628 return rsdp_phys;
623} 629}
624 630
625 631int __init acpi_boot_init(void)
626int __init
627acpi_boot_init (void)
628{ 632{
629 633
630 /* 634 /*
@@ -642,31 +646,43 @@ acpi_boot_init (void)
642 646
643 /* Local APIC */ 647 /* Local APIC */
644 648
645 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) 649 if (acpi_table_parse_madt
646 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); 650 (ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0)
651 printk(KERN_ERR PREFIX
652 "Error parsing LAPIC address override entry\n");
647 653
648 if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1) 654 if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS)
649 printk(KERN_ERR PREFIX "Error parsing MADT - no LAPIC entries\n"); 655 < 1)
656 printk(KERN_ERR PREFIX
657 "Error parsing MADT - no LAPIC entries\n");
650 658
651 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0) 659 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0)
660 < 0)
652 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 661 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
653 662
654 /* I/O APIC */ 663 /* I/O APIC */
655 664
656 if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) 665 if (acpi_table_parse_madt
657 printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n"); 666 (ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1)
667 printk(KERN_ERR PREFIX
668 "Error parsing MADT - no IOSAPIC entries\n");
658 669
659 /* System-Level Interrupt Routing */ 670 /* System-Level Interrupt Routing */
660 671
661 if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0) 672 if (acpi_table_parse_madt
662 printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n"); 673 (ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src,
674 ACPI_MAX_PLATFORM_INTERRUPTS) < 0)
675 printk(KERN_ERR PREFIX
676 "Error parsing platform interrupt source entry\n");
663 677
664 if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) 678 if (acpi_table_parse_madt
665 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); 679 (ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0)
680 printk(KERN_ERR PREFIX
681 "Error parsing interrupt source overrides entry\n");
666 682
667 if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0) 683 if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0)
668 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 684 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
669 skip_madt: 685 skip_madt:
670 686
671 /* 687 /*
672 * FADT says whether a legacy keyboard controller is present. 688 * FADT says whether a legacy keyboard controller is present.
@@ -681,8 +697,9 @@ acpi_boot_init (void)
681 if (available_cpus == 0) { 697 if (available_cpus == 0) {
682 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); 698 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
683 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id()); 699 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
684 smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id(); 700 smp_boot_data.cpu_phys_id[available_cpus] =
685 available_cpus = 1; /* We've got at least one of these, no? */ 701 hard_smp_processor_id();
702 available_cpus = 1; /* We've got at least one of these, no? */
686 } 703 }
687 smp_boot_data.cpu_count = available_cpus; 704 smp_boot_data.cpu_count = available_cpus;
688 705
@@ -691,8 +708,10 @@ acpi_boot_init (void)
691 if (srat_num_cpus == 0) { 708 if (srat_num_cpus == 0) {
692 int cpu, i = 1; 709 int cpu, i = 1;
693 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) 710 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
694 if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id()) 711 if (smp_boot_data.cpu_phys_id[cpu] !=
695 node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu]; 712 hard_smp_processor_id())
713 node_cpuid[i++].phys_id =
714 smp_boot_data.cpu_phys_id[cpu];
696 } 715 }
697# endif 716# endif
698#endif 717#endif
@@ -700,12 +719,12 @@ acpi_boot_init (void)
700 build_cpu_to_node_map(); 719 build_cpu_to_node_map();
701#endif 720#endif
702 /* Make boot-up look pretty */ 721 /* Make boot-up look pretty */
703 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus); 722 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus,
723 total_cpus);
704 return 0; 724 return 0;
705} 725}
706 726
707int 727int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
708acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
709{ 728{
710 int vector; 729 int vector;
711 730
@@ -726,11 +745,10 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
726 */ 745 */
727#ifdef CONFIG_ACPI_HOTPLUG_CPU 746#ifdef CONFIG_ACPI_HOTPLUG_CPU
728static 747static
729int 748int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
730acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
731{ 749{
732#ifdef CONFIG_ACPI_NUMA 750#ifdef CONFIG_ACPI_NUMA
733 int pxm_id; 751 int pxm_id;
734 752
735 pxm_id = acpi_get_pxm(handle); 753 pxm_id = acpi_get_pxm(handle);
736 754
@@ -738,31 +756,28 @@ acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
738 * Assuming that the container driver would have set the proximity 756 * Assuming that the container driver would have set the proximity
739 * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag 757 * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag
740 */ 758 */
741 node_cpuid[cpu].nid = (pxm_id < 0) ? 0: 759 node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id];
742 pxm_to_nid_map[pxm_id];
743 760
744 node_cpuid[cpu].phys_id = physid; 761 node_cpuid[cpu].phys_id = physid;
745#endif 762#endif
746 return(0); 763 return (0);
747} 764}
748 765
749 766int acpi_map_lsapic(acpi_handle handle, int *pcpu)
750int
751acpi_map_lsapic(acpi_handle handle, int *pcpu)
752{ 767{
753 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 768 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
754 union acpi_object *obj; 769 union acpi_object *obj;
755 struct acpi_table_lsapic *lsapic; 770 struct acpi_table_lsapic *lsapic;
756 cpumask_t tmp_map; 771 cpumask_t tmp_map;
757 long physid; 772 long physid;
758 int cpu; 773 int cpu;
759 774
760 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 775 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
761 return -EINVAL; 776 return -EINVAL;
762 777
763 if (!buffer.length || !buffer.pointer) 778 if (!buffer.length || !buffer.pointer)
764 return -EINVAL; 779 return -EINVAL;
765 780
766 obj = buffer.pointer; 781 obj = buffer.pointer;
767 if (obj->type != ACPI_TYPE_BUFFER || 782 if (obj->type != ACPI_TYPE_BUFFER ||
768 obj->buffer.length < sizeof(*lsapic)) { 783 obj->buffer.length < sizeof(*lsapic)) {
@@ -778,7 +793,7 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
778 return -EINVAL; 793 return -EINVAL;
779 } 794 }
780 795
781 physid = ((lsapic->id <<8) | (lsapic->eid)); 796 physid = ((lsapic->id << 8) | (lsapic->eid));
782 797
783 acpi_os_free(buffer.pointer); 798 acpi_os_free(buffer.pointer);
784 buffer.length = ACPI_ALLOCATE_BUFFER; 799 buffer.length = ACPI_ALLOCATE_BUFFER;
@@ -786,50 +801,49 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
786 801
787 cpus_complement(tmp_map, cpu_present_map); 802 cpus_complement(tmp_map, cpu_present_map);
788 cpu = first_cpu(tmp_map); 803 cpu = first_cpu(tmp_map);
789 if(cpu >= NR_CPUS) 804 if (cpu >= NR_CPUS)
790 return -EINVAL; 805 return -EINVAL;
791 806
792 acpi_map_cpu2node(handle, cpu, physid); 807 acpi_map_cpu2node(handle, cpu, physid);
793 808
794 cpu_set(cpu, cpu_present_map); 809 cpu_set(cpu, cpu_present_map);
795 ia64_cpu_to_sapicid[cpu] = physid; 810 ia64_cpu_to_sapicid[cpu] = physid;
796 ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu]; 811 ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu];
797 812
798 *pcpu = cpu; 813 *pcpu = cpu;
799 return(0); 814 return (0);
800} 815}
801EXPORT_SYMBOL(acpi_map_lsapic);
802 816
817EXPORT_SYMBOL(acpi_map_lsapic);
803 818
804int 819int acpi_unmap_lsapic(int cpu)
805acpi_unmap_lsapic(int cpu)
806{ 820{
807 int i; 821 int i;
808 822
809 for (i=0; i<MAX_SAPICS; i++) { 823 for (i = 0; i < MAX_SAPICS; i++) {
810 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) { 824 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) {
811 ia64_acpiid_to_sapicid[i] = -1; 825 ia64_acpiid_to_sapicid[i] = -1;
812 break; 826 break;
813 } 827 }
814 } 828 }
815 ia64_cpu_to_sapicid[cpu] = -1; 829 ia64_cpu_to_sapicid[cpu] = -1;
816 cpu_clear(cpu,cpu_present_map); 830 cpu_clear(cpu, cpu_present_map);
817 831
818#ifdef CONFIG_ACPI_NUMA 832#ifdef CONFIG_ACPI_NUMA
819 /* NUMA specific cleanup's */ 833 /* NUMA specific cleanup's */
820#endif 834#endif
821 835
822 return(0); 836 return (0);
823} 837}
838
824EXPORT_SYMBOL(acpi_unmap_lsapic); 839EXPORT_SYMBOL(acpi_unmap_lsapic);
825#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 840#endif /* CONFIG_ACPI_HOTPLUG_CPU */
826
827 841
828#ifdef CONFIG_ACPI_NUMA 842#ifdef CONFIG_ACPI_NUMA
829acpi_status __devinit 843acpi_status __devinit
830acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) 844acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
831{ 845{
832 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 846 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
833 union acpi_object *obj; 847 union acpi_object *obj;
834 struct acpi_table_iosapic *iosapic; 848 struct acpi_table_iosapic *iosapic;
835 unsigned int gsi_base; 849 unsigned int gsi_base;
@@ -878,10 +892,9 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
878 map_iosapic_to_node(gsi_base, node); 892 map_iosapic_to_node(gsi_base, node);
879 return AE_OK; 893 return AE_OK;
880} 894}
881#endif /* CONFIG_NUMA */ 895#endif /* CONFIG_NUMA */
882 896
883int 897int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
884acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
885{ 898{
886 int err; 899 int err;
887 900
@@ -890,17 +903,18 @@ acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
890 903
891#if CONFIG_ACPI_NUMA 904#if CONFIG_ACPI_NUMA
892 acpi_map_iosapic(handle, 0, NULL, NULL); 905 acpi_map_iosapic(handle, 0, NULL, NULL);
893#endif /* CONFIG_ACPI_NUMA */ 906#endif /* CONFIG_ACPI_NUMA */
894 907
895 return 0; 908 return 0;
896} 909}
910
897EXPORT_SYMBOL(acpi_register_ioapic); 911EXPORT_SYMBOL(acpi_register_ioapic);
898 912
899int 913int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
900acpi_unregister_ioapic (acpi_handle handle, u32 gsi_base)
901{ 914{
902 return iosapic_remove(gsi_base); 915 return iosapic_remove(gsi_base);
903} 916}
917
904EXPORT_SYMBOL(acpi_unregister_ioapic); 918EXPORT_SYMBOL(acpi_unregister_ioapic);
905 919
906#endif /* CONFIG_ACPI_BOOT */ 920#endif /* CONFIG_ACPI */
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index 7936b62f7a2e..a13df592ebf7 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -561,7 +561,7 @@ static inline int vector_is_shared (int vector)
561 return (iosapic_intr_info[vector].count > 1); 561 return (iosapic_intr_info[vector].count > 1);
562} 562}
563 563
564static void 564static int
565register_intr (unsigned int gsi, int vector, unsigned char delivery, 565register_intr (unsigned int gsi, int vector, unsigned char delivery,
566 unsigned long polarity, unsigned long trigger) 566 unsigned long polarity, unsigned long trigger)
567{ 567{
@@ -576,7 +576,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
576 index = find_iosapic(gsi); 576 index = find_iosapic(gsi);
577 if (index < 0) { 577 if (index < 0) {
578 printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi); 578 printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi);
579 return; 579 return -ENODEV;
580 } 580 }
581 581
582 iosapic_address = iosapic_lists[index].addr; 582 iosapic_address = iosapic_lists[index].addr;
@@ -587,7 +587,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
587 rte = iosapic_alloc_rte(); 587 rte = iosapic_alloc_rte();
588 if (!rte) { 588 if (!rte) {
589 printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__); 589 printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__);
590 return; 590 return -ENOMEM;
591 } 591 }
592 592
593 rte_index = gsi - gsi_base; 593 rte_index = gsi - gsi_base;
@@ -603,7 +603,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
603 struct iosapic_intr_info *info = &iosapic_intr_info[vector]; 603 struct iosapic_intr_info *info = &iosapic_intr_info[vector];
604 if (info->trigger != trigger || info->polarity != polarity) { 604 if (info->trigger != trigger || info->polarity != polarity) {
605 printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__); 605 printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__);
606 return; 606 return -EINVAL;
607 } 607 }
608 } 608 }
609 609
@@ -623,6 +623,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
623 __FUNCTION__, vector, idesc->handler->typename, irq_type->typename); 623 __FUNCTION__, vector, idesc->handler->typename, irq_type->typename);
624 idesc->handler = irq_type; 624 idesc->handler = irq_type;
625 } 625 }
626 return 0;
626} 627}
627 628
628static unsigned int 629static unsigned int
@@ -710,7 +711,7 @@ int
710iosapic_register_intr (unsigned int gsi, 711iosapic_register_intr (unsigned int gsi,
711 unsigned long polarity, unsigned long trigger) 712 unsigned long polarity, unsigned long trigger)
712{ 713{
713 int vector, mask = 1; 714 int vector, mask = 1, err;
714 unsigned int dest; 715 unsigned int dest;
715 unsigned long flags; 716 unsigned long flags;
716 struct iosapic_rte_info *rte; 717 struct iosapic_rte_info *rte;
@@ -737,8 +738,8 @@ again:
737 vector = assign_irq_vector(AUTO_ASSIGN); 738 vector = assign_irq_vector(AUTO_ASSIGN);
738 if (vector < 0) { 739 if (vector < 0) {
739 vector = iosapic_find_sharable_vector(trigger, polarity); 740 vector = iosapic_find_sharable_vector(trigger, polarity);
740 if (vector < 0) 741 if (vector < 0)
741 panic("%s: out of interrupt vectors!\n", __FUNCTION__); 742 return -ENOSPC;
742 } 743 }
743 744
744 spin_lock_irqsave(&irq_descp(vector)->lock, flags); 745 spin_lock_irqsave(&irq_descp(vector)->lock, flags);
@@ -753,8 +754,13 @@ again:
753 } 754 }
754 755
755 dest = get_target_cpu(gsi, vector); 756 dest = get_target_cpu(gsi, vector);
756 register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, 757 err = register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
757 polarity, trigger); 758 polarity, trigger);
759 if (err < 0) {
760 spin_unlock(&iosapic_lock);
761 spin_unlock_irqrestore(&irq_descp(vector)->lock, flags);
762 return err;
763 }
758 764
759 /* 765 /*
760 * If the vector is shared and already unmasked for 766 * If the vector is shared and already unmasked for
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 84f89da7c640..1f5c26dbe705 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -384,7 +384,7 @@ setup_arch (char **cmdline_p)
384 if (early_console_setup(*cmdline_p) == 0) 384 if (early_console_setup(*cmdline_p) == 0)
385 mark_bsp_online(); 385 mark_bsp_online();
386 386
387#ifdef CONFIG_ACPI_BOOT 387#ifdef CONFIG_ACPI
388 /* Initialize the ACPI boot-time table parser */ 388 /* Initialize the ACPI boot-time table parser */
389 acpi_table_init(); 389 acpi_table_init();
390# ifdef CONFIG_ACPI_NUMA 390# ifdef CONFIG_ACPI_NUMA
@@ -420,7 +420,7 @@ setup_arch (char **cmdline_p)
420 420
421 cpu_init(); /* initialize the bootstrap CPU */ 421 cpu_init(); /* initialize the bootstrap CPU */
422 422
423#ifdef CONFIG_ACPI_BOOT 423#ifdef CONFIG_ACPI
424 acpi_boot_init(); 424 acpi_boot_init();
425#endif 425#endif
426 426
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 92ff46ad21e2..706b7734e191 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -36,7 +36,7 @@ int arch_register_cpu(int num)
36 parent = &sysfs_nodes[cpu_to_node(num)]; 36 parent = &sysfs_nodes[cpu_to_node(num)];
37#endif /* CONFIG_NUMA */ 37#endif /* CONFIG_NUMA */
38 38
39#ifdef CONFIG_ACPI_BOOT 39#ifdef CONFIG_ACPI
40 /* 40 /*
41 * If CPEI cannot be re-targetted, and this is 41 * If CPEI cannot be re-targetted, and this is
42 * CPEI target, then dont create the control file 42 * CPEI target, then dont create the control file
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index 9fc74631ba8a..01d18b7b5bb3 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -23,7 +23,7 @@ static void force_interrupt(int irq);
23static void register_intr_pda(struct sn_irq_info *sn_irq_info); 23static void register_intr_pda(struct sn_irq_info *sn_irq_info);
24static void unregister_intr_pda(struct sn_irq_info *sn_irq_info); 24static void unregister_intr_pda(struct sn_irq_info *sn_irq_info);
25 25
26extern int sn_force_interrupt_flag; 26int sn_force_interrupt_flag = 1;
27extern int sn_ioif_inited; 27extern int sn_ioif_inited;
28static struct list_head **sn_irq_lh; 28static struct list_head **sn_irq_lh;
29static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */ 29static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */
diff --git a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
index 51bf82720d99..a06719d752a0 100644
--- a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
+++ b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
@@ -52,7 +52,7 @@ static int licenseID_open(struct inode *inode, struct file *file)
52 * the bridge chip. The hardware will then send an interrupt message if the 52 * the bridge chip. The hardware will then send an interrupt message if the
53 * interrupt line is active. This mimics a level sensitive interrupt. 53 * interrupt line is active. This mimics a level sensitive interrupt.
54 */ 54 */
55int sn_force_interrupt_flag = 1; 55extern int sn_force_interrupt_flag;
56 56
57static int sn_force_interrupt_show(struct seq_file *s, void *p) 57static int sn_force_interrupt_show(struct seq_file *s, void *p)
58{ 58{
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 660a03a89e66..40242c61e90a 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -144,7 +144,6 @@ config X86_CPUID
144 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to 144 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
145 /dev/cpu/31/cpuid. 145 /dev/cpu/31/cpuid.
146 146
147# disable it for opteron optimized builds because it pulls in ACPI_BOOT
148config X86_HT 147config X86_HT
149 bool 148 bool
150 depends on SMP && !MK8 149 depends on SMP && !MK8
@@ -461,7 +460,6 @@ config PCI_DIRECT
461config PCI_MMCONFIG 460config PCI_MMCONFIG
462 bool "Support mmconfig PCI config space access" 461 bool "Support mmconfig PCI config space access"
463 depends on PCI && ACPI 462 depends on PCI && ACPI
464 select ACPI_BOOT
465 463
466config UNORDERED_IO 464config UNORDERED_IO
467 bool "Unordered IO mapping access" 465 bool "Unordered IO mapping access"
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index b97a61e1c71c..bf57e2362bf4 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -135,8 +135,6 @@ CONFIG_PM_STD_PARTITION=""
135# ACPI (Advanced Configuration and Power Interface) Support 135# ACPI (Advanced Configuration and Power Interface) Support
136# 136#
137CONFIG_ACPI=y 137CONFIG_ACPI=y
138CONFIG_ACPI_BOOT=y
139CONFIG_ACPI_INTERPRETER=y
140CONFIG_ACPI_AC=y 138CONFIG_ACPI_AC=y
141CONFIG_ACPI_BATTERY=y 139CONFIG_ACPI_BATTERY=y
142CONFIG_ACPI_BUTTON=y 140CONFIG_ACPI_BUTTON=y
@@ -151,10 +149,8 @@ CONFIG_ACPI_NUMA=y
151CONFIG_ACPI_TOSHIBA=y 149CONFIG_ACPI_TOSHIBA=y
152CONFIG_ACPI_BLACKLIST_YEAR=2001 150CONFIG_ACPI_BLACKLIST_YEAR=2001
153# CONFIG_ACPI_DEBUG is not set 151# CONFIG_ACPI_DEBUG is not set
154CONFIG_ACPI_BUS=y
155CONFIG_ACPI_EC=y 152CONFIG_ACPI_EC=y
156CONFIG_ACPI_POWER=y 153CONFIG_ACPI_POWER=y
157CONFIG_ACPI_PCI=y
158CONFIG_ACPI_SYSTEM=y 154CONFIG_ACPI_SYSTEM=y
159# CONFIG_ACPI_CONTAINER is not set 155# CONFIG_ACPI_CONTAINER is not set
160 156
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index 48f9e2c19cd6..0296ca6cbfa3 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -12,7 +12,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
12obj-$(CONFIG_X86_MCE) += mce.o 12obj-$(CONFIG_X86_MCE) += mce.o
13obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o 13obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o
14obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/ 14obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/
15obj-$(CONFIG_ACPI_BOOT) += acpi/ 15obj-$(CONFIG_ACPI) += acpi/
16obj-$(CONFIG_X86_MSR) += msr.o 16obj-$(CONFIG_X86_MSR) += msr.o
17obj-$(CONFIG_MICROCODE) += microcode.o 17obj-$(CONFIG_MICROCODE) += microcode.o
18obj-$(CONFIG_X86_CPUID) += cpuid.o 18obj-$(CONFIG_X86_CPUID) += cpuid.o
diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile
index d2c2ee5f9a88..7da9ace890bd 100644
--- a/arch/x86_64/kernel/acpi/Makefile
+++ b/arch/x86_64/kernel/acpi/Makefile
@@ -1,3 +1,3 @@
1obj-$(CONFIG_ACPI_BOOT) := boot.o 1obj-y := boot.o
2boot-$(CONFIG_ACPI_BOOT) := ../../../i386/kernel/acpi/boot.o 2boot-y := ../../../i386/kernel/acpi/boot.o
3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o 3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
diff --git a/arch/x86_64/kernel/acpi/sleep.c b/arch/x86_64/kernel/acpi/sleep.c
index 7a275de6df22..148f6f7ea315 100644
--- a/arch/x86_64/kernel/acpi/sleep.c
+++ b/arch/x86_64/kernel/acpi/sleep.c
@@ -47,7 +47,6 @@
47#include <asm/proto.h> 47#include <asm/proto.h>
48#include <asm/tlbflush.h> 48#include <asm/tlbflush.h>
49 49
50
51/* -------------------------------------------------------------------------- 50/* --------------------------------------------------------------------------
52 Low-Level Sleep Support 51 Low-Level Sleep Support
53 -------------------------------------------------------------------------- */ 52 -------------------------------------------------------------------------- */
@@ -77,11 +76,12 @@ static void init_low_mapping(void)
77 * Create an identity mapped page table and copy the wakeup routine to 76 * Create an identity mapped page table and copy the wakeup routine to
78 * low memory. 77 * low memory.
79 */ 78 */
80int acpi_save_state_mem (void) 79int acpi_save_state_mem(void)
81{ 80{
82 init_low_mapping(); 81 init_low_mapping();
83 82
84 memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); 83 memcpy((void *)acpi_wakeup_address, &wakeup_start,
84 &wakeup_end - &wakeup_start);
85 acpi_copy_wakeup_routine(acpi_wakeup_address); 85 acpi_copy_wakeup_routine(acpi_wakeup_address);
86 86
87 return 0; 87 return 0;
@@ -90,7 +90,7 @@ int acpi_save_state_mem (void)
90/* 90/*
91 * acpi_restore_state 91 * acpi_restore_state
92 */ 92 */
93void acpi_restore_state_mem (void) 93void acpi_restore_state_mem(void)
94{ 94{
95 set_pgd(pgd_offset(current->mm, 0UL), low_ptr); 95 set_pgd(pgd_offset(current->mm, 0UL), low_ptr);
96 flush_tlb_all(); 96 flush_tlb_all();
@@ -108,7 +108,8 @@ void __init acpi_reserve_bootmem(void)
108{ 108{
109 acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE); 109 acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
110 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) 110 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE)
111 printk(KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n"); 111 printk(KERN_CRIT
112 "ACPI: Wakeup code way too big, will crash on attempt to suspend\n");
112} 113}
113 114
114static int __init acpi_sleep_setup(char *str) 115static int __init acpi_sleep_setup(char *str)
@@ -127,6 +128,8 @@ static int __init acpi_sleep_setup(char *str)
127 128
128__setup("acpi_sleep=", acpi_sleep_setup); 129__setup("acpi_sleep=", acpi_sleep_setup);
129 130
130#endif /*CONFIG_ACPI_SLEEP*/ 131#endif /*CONFIG_ACPI_SLEEP */
131 132
132void acpi_pci_link_exit(void) {} 133void acpi_pci_link_exit(void)
134{
135}
diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c
index 30c843a5efdd..f031358906f5 100644
--- a/arch/x86_64/kernel/genapic.c
+++ b/arch/x86_64/kernel/genapic.c
@@ -20,7 +20,7 @@
20#include <asm/smp.h> 20#include <asm/smp.h>
21#include <asm/ipi.h> 21#include <asm/ipi.h>
22 22
23#if defined(CONFIG_ACPI_BUS) 23#if defined(CONFIG_ACPI)
24#include <acpi/acpi_bus.h> 24#include <acpi/acpi_bus.h>
25#endif 25#endif
26 26
@@ -47,7 +47,7 @@ void __init clustered_apic_check(void)
47 u8 cluster_cnt[NUM_APIC_CLUSTERS]; 47 u8 cluster_cnt[NUM_APIC_CLUSTERS];
48 int num_cpus = 0; 48 int num_cpus = 0;
49 49
50#if defined(CONFIG_ACPI_BUS) 50#if defined(CONFIG_ACPI)
51 /* 51 /*
52 * Some x86_64 machines use physical APIC mode regardless of how many 52 * Some x86_64 machines use physical APIC mode regardless of how many
53 * procs/clusters are present (x86_64 ES7000 is an example). 53 * procs/clusters are present (x86_64 ES7000 is an example).
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index d206d7e49cf5..1013a8fe44d7 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -1841,7 +1841,7 @@ device_initcall(ioapic_init_sysfs);
1841 ACPI-based IOAPIC Configuration 1841 ACPI-based IOAPIC Configuration
1842 -------------------------------------------------------------------------- */ 1842 -------------------------------------------------------------------------- */
1843 1843
1844#ifdef CONFIG_ACPI_BOOT 1844#ifdef CONFIG_ACPI
1845 1845
1846#define IO_APIC_MAX_ID 0xFE 1846#define IO_APIC_MAX_ID 0xFE
1847 1847
@@ -1923,7 +1923,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
1923 return 0; 1923 return 0;
1924} 1924}
1925 1925
1926#endif /*CONFIG_ACPI_BOOT*/ 1926#endif /* CONFIG_ACPI */
1927 1927
1928 1928
1929/* 1929/*
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 79c362d03e2e..8d8ed6ae1d0c 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -74,7 +74,7 @@ static unsigned int num_processors = 0;
74physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE; 74physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
75 75
76/* ACPI MADT entry parsing functions */ 76/* ACPI MADT entry parsing functions */
77#ifdef CONFIG_ACPI_BOOT 77#ifdef CONFIG_ACPI
78extern struct acpi_boot_flags acpi_boot; 78extern struct acpi_boot_flags acpi_boot;
79#ifdef CONFIG_X86_LOCAL_APIC 79#ifdef CONFIG_X86_LOCAL_APIC
80extern int acpi_parse_lapic (acpi_table_entry_header *header); 80extern int acpi_parse_lapic (acpi_table_entry_header *header);
@@ -84,7 +84,7 @@ extern int acpi_parse_lapic_nmi (acpi_table_entry_header *header);
84#ifdef CONFIG_X86_IO_APIC 84#ifdef CONFIG_X86_IO_APIC
85extern int acpi_parse_ioapic (acpi_table_entry_header *header); 85extern int acpi_parse_ioapic (acpi_table_entry_header *header);
86#endif /*CONFIG_X86_IO_APIC*/ 86#endif /*CONFIG_X86_IO_APIC*/
87#endif /*CONFIG_ACPI_BOOT*/ 87#endif /*CONFIG_ACPI*/
88 88
89u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; 89u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
90 90
@@ -519,8 +519,6 @@ void __init get_smp_config (void)
519 struct intel_mp_floating *mpf = mpf_found; 519 struct intel_mp_floating *mpf = mpf_found;
520 520
521 /* 521 /*
522 * ACPI may be used to obtain the entire SMP configuration or just to
523 * enumerate/configure processors (CONFIG_ACPI_BOOT). Note that
524 * ACPI supports both logical (e.g. Hyper-Threading) and physical 522 * ACPI supports both logical (e.g. Hyper-Threading) and physical
525 * processors, where MPS only supports physical. 523 * processors, where MPS only supports physical.
526 */ 524 */
@@ -673,7 +671,7 @@ void __init find_smp_config (void)
673 ACPI-based MP Configuration 671 ACPI-based MP Configuration
674 -------------------------------------------------------------------------- */ 672 -------------------------------------------------------------------------- */
675 673
676#ifdef CONFIG_ACPI_BOOT 674#ifdef CONFIG_ACPI
677 675
678void __init mp_register_lapic_address ( 676void __init mp_register_lapic_address (
679 u64 address) 677 u64 address)
@@ -929,11 +927,9 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
929 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) 927 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
930 return gsi; 928 return gsi;
931 929
932#ifdef CONFIG_ACPI_BUS
933 /* Don't set up the ACPI SCI because it's already set up */ 930 /* Don't set up the ACPI SCI because it's already set up */
934 if (acpi_fadt.sci_int == gsi) 931 if (acpi_fadt.sci_int == gsi)
935 return gsi; 932 return gsi;
936#endif
937 933
938 ioapic = mp_find_ioapic(gsi); 934 ioapic = mp_find_ioapic(gsi);
939 if (ioapic < 0) { 935 if (ioapic < 0) {
@@ -973,13 +969,11 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
973 if (gsi < MAX_GSI_NUM) { 969 if (gsi < MAX_GSI_NUM) {
974 if (gsi > 15) 970 if (gsi > 15)
975 gsi = pci_irq++; 971 gsi = pci_irq++;
976#ifdef CONFIG_ACPI_BUS
977 /* 972 /*
978 * Don't assign IRQ used by ACPI SCI 973 * Don't assign IRQ used by ACPI SCI
979 */ 974 */
980 if (gsi == acpi_fadt.sci_int) 975 if (gsi == acpi_fadt.sci_int)
981 gsi = pci_irq++; 976 gsi = pci_irq++;
982#endif
983 gsi_to_irq[irq] = gsi; 977 gsi_to_irq[irq] = gsi;
984 } else { 978 } else {
985 printk(KERN_ERR "GSI %u is too high\n", gsi); 979 printk(KERN_ERR "GSI %u is too high\n", gsi);
@@ -994,4 +988,4 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
994} 988}
995 989
996#endif /*CONFIG_X86_IO_APIC*/ 990#endif /*CONFIG_X86_IO_APIC*/
997#endif /*CONFIG_ACPI_BOOT*/ 991#endif /*CONFIG_ACPI*/
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 116a491e2961..cfcebc8ab7b4 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -71,7 +71,7 @@ unsigned long mmu_cr4_features;
71 71
72int acpi_disabled; 72int acpi_disabled;
73EXPORT_SYMBOL(acpi_disabled); 73EXPORT_SYMBOL(acpi_disabled);
74#ifdef CONFIG_ACPI_BOOT 74#ifdef CONFIG_ACPI
75extern int __initdata acpi_ht; 75extern int __initdata acpi_ht;
76extern acpi_interrupt_flags acpi_sci_flags; 76extern acpi_interrupt_flags acpi_sci_flags;
77int __initdata acpi_force = 0; 77int __initdata acpi_force = 0;
@@ -294,7 +294,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
294 maxcpus = simple_strtoul(from + 8, NULL, 0); 294 maxcpus = simple_strtoul(from + 8, NULL, 0);
295 } 295 }
296#endif 296#endif
297#ifdef CONFIG_ACPI_BOOT 297#ifdef CONFIG_ACPI
298 /* "acpi=off" disables both ACPI table parsing and interpreter init */ 298 /* "acpi=off" disables both ACPI table parsing and interpreter init */
299 if (!memcmp(from, "acpi=off", 8)) 299 if (!memcmp(from, "acpi=off", 8))
300 disable_acpi(); 300 disable_acpi();
@@ -566,7 +566,7 @@ void __init setup_arch(char **cmdline_p)
566 566
567 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT)); 567 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
568 568
569#ifdef CONFIG_ACPI_BOOT 569#ifdef CONFIG_ACPI
570 /* 570 /*
571 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT). 571 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
572 * Call this early for SRAT node setup. 572 * Call this early for SRAT node setup.
@@ -658,7 +658,7 @@ void __init setup_arch(char **cmdline_p)
658 658
659 check_ioapic(); 659 check_ioapic();
660 660
661#ifdef CONFIG_ACPI_BOOT 661#ifdef CONFIG_ACPI
662 /* 662 /*
663 * Read APIC and some other early information from ACPI tables. 663 * Read APIC and some other early information from ACPI tables.
664 */ 664 */
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile
index 37c92e841dec..bb34e5ef916c 100644
--- a/arch/x86_64/pci/Makefile
+++ b/arch/x86_64/pci/Makefile
@@ -8,7 +8,7 @@ CFLAGS += -Iarch/i386/pci
8obj-y := i386.o 8obj-y := i386.o
9obj-$(CONFIG_PCI_DIRECT)+= direct.o 9obj-$(CONFIG_PCI_DIRECT)+= direct.o
10obj-y += fixup.o 10obj-y += fixup.o
11obj-$(CONFIG_ACPI_PCI) += acpi.o 11obj-$(CONFIG_ACPI) += acpi.o
12obj-y += legacy.o irq.o common.o 12obj-y += legacy.o irq.o common.o
13# mmconfig has a 64bit special 13# mmconfig has a 64bit special
14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o 14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
diff --git a/arch/x86_64/pci/Makefile-BUS b/arch/x86_64/pci/Makefile-BUS
index 291985f0d2e4..4f0c05abd408 100644
--- a/arch/x86_64/pci/Makefile-BUS
+++ b/arch/x86_64/pci/Makefile-BUS
@@ -8,7 +8,7 @@ CFLAGS += -I arch/i386/pci
8obj-y := i386.o 8obj-y := i386.o
9obj-$(CONFIG_PCI_DIRECT)+= direct.o 9obj-$(CONFIG_PCI_DIRECT)+= direct.o
10obj-y += fixup.o 10obj-y += fixup.o
11obj-$(CONFIG_ACPI_PCI) += acpi.o 11obj-$(CONFIG_ACPI) += acpi.o
12obj-y += legacy.o irq.o common.o 12obj-y += legacy.o irq.o common.o
13# mmconfig has a 64bit special 13# mmconfig has a 64bit special
14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o 14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
diff --git a/drivers/Makefile b/drivers/Makefile
index 9663132ed825..86c8654a0ca9 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -8,7 +8,7 @@
8obj-$(CONFIG_PCI) += pci/ 8obj-$(CONFIG_PCI) += pci/
9obj-$(CONFIG_PARISC) += parisc/ 9obj-$(CONFIG_PARISC) += parisc/
10obj-y += video/ 10obj-y += video/
11obj-$(CONFIG_ACPI_BOOT) += acpi/ 11obj-$(CONFIG_ACPI) += acpi/
12# PnP must come after ACPI since it will eventually need to check if acpi 12# PnP must come after ACPI since it will eventually need to check if acpi
13# was used and do nothing if so 13# was used and do nothing if so
14obj-$(CONFIG_PNP) += pnp/ 14obj-$(CONFIG_PNP) += pnp/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index ba13896cae40..3998c9d35fe1 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -3,7 +3,6 @@
3# 3#
4 4
5menu "ACPI (Advanced Configuration and Power Interface) Support" 5menu "ACPI (Advanced Configuration and Power Interface) Support"
6 depends on PM
7 depends on !X86_VISWS 6 depends on !X86_VISWS
8 depends on !IA64_HP_SIM 7 depends on !IA64_HP_SIM
9 depends on IA64 || X86 8 depends on IA64 || X86
@@ -11,6 +10,8 @@ menu "ACPI (Advanced Configuration and Power Interface) Support"
11config ACPI 10config ACPI
12 bool "ACPI Support" 11 bool "ACPI Support"
13 depends on IA64 || X86 12 depends on IA64 || X86
13 select PM
14 select PCI
14 15
15 default y 16 default y
16 ---help--- 17 ---help---
@@ -43,20 +44,10 @@ config ACPI
43 44
44if ACPI 45if ACPI
45 46
46config ACPI_BOOT
47 bool
48 default y
49
50config ACPI_INTERPRETER
51 bool
52 default y
53
54if ACPI_INTERPRETER
55
56config ACPI_SLEEP 47config ACPI_SLEEP
57 bool "Sleep States (EXPERIMENTAL)" 48 bool "Sleep States"
58 depends on X86 && (!SMP || SUSPEND_SMP) 49 depends on X86 && (!SMP || SUSPEND_SMP)
59 depends on EXPERIMENTAL && PM 50 depends on PM
60 default y 51 default y
61 ---help--- 52 ---help---
62 This option adds support for ACPI suspend states. 53 This option adds support for ACPI suspend states.
@@ -90,16 +81,16 @@ config ACPI_SLEEP_PROC_SLEEP
90config ACPI_AC 81config ACPI_AC
91 tristate "AC Adapter" 82 tristate "AC Adapter"
92 depends on X86 83 depends on X86
93 default m 84 default y
94 help 85 help
95 This driver adds support for the AC Adapter object, which indicates 86 This driver adds support for the AC Adapter object, which indicates
96 whether a system is on AC, or not. Typically, only mobile systems 87 whether a system is on AC, or not. If you have a system that can
97 have this object, since desktops are always on AC. 88 switch between A/C and battery, say Y.
98 89
99config ACPI_BATTERY 90config ACPI_BATTERY
100 tristate "Battery" 91 tristate "Battery"
101 depends on X86 92 depends on X86
102 default m 93 default y
103 help 94 help
104 This driver adds support for battery information through 95 This driver adds support for battery information through
105 /proc/acpi/battery. If you have a mobile system with a battery, 96 /proc/acpi/battery. If you have a mobile system with a battery,
@@ -107,18 +98,17 @@ config ACPI_BATTERY
107 98
108config ACPI_BUTTON 99config ACPI_BUTTON
109 tristate "Button" 100 tristate "Button"
110 default m 101 default y
111 help 102 help
112 This driver registers for events based on buttons, such as the 103 This driver handles events on the power, sleep and lid buttons.
113 power, sleep, and lid switch. In the future, a daemon will read 104 A daemon reads /proc/acpi/event and perform user-defined actions
114 /proc/acpi/event and perform user-defined actions such as shutting 105 such as shutting down the system. This is necessary for
115 down the system. Until then, you can cat it, and see output when 106 software controlled poweroff.
116 a button is pressed.
117 107
118config ACPI_VIDEO 108config ACPI_VIDEO
119 tristate "Video" 109 tristate "Video"
120 depends on EXPERIMENTAL 110 depends on X86
121 default m 111 default y
122 help 112 help
123 This driver implement the ACPI Extensions For Display Adapters 113 This driver implement the ACPI Extensions For Display Adapters
124 for integrated graphics devices on motherboard, as specified in 114 for integrated graphics devices on motherboard, as specified in
@@ -129,10 +119,9 @@ config ACPI_VIDEO
129 for your integrated video device. 119 for your integrated video device.
130 120
131config ACPI_HOTKEY 121config ACPI_HOTKEY
132 tristate "Generic Hotkey" 122 tristate "Generic Hotkey (EXPERIMENTAL)"
133 depends on ACPI_INTERPRETER
134 depends on EXPERIMENTAL 123 depends on EXPERIMENTAL
135 depends on !IA64_SGI_SN 124 depends on X86
136 default n 125 default n
137 help 126 help
138 Experimental consolidated hotkey driver. 127 Experimental consolidated hotkey driver.
@@ -140,31 +129,30 @@ config ACPI_HOTKEY
140 129
141config ACPI_FAN 130config ACPI_FAN
142 tristate "Fan" 131 tristate "Fan"
143 default m 132 default y
144 help 133 help
145 This driver adds support for ACPI fan devices, allowing user-mode 134 This driver adds support for ACPI fan devices, allowing user-mode
146 applications to perform basic fan control (on, off, status). 135 applications to perform basic fan control (on, off, status).
147 136
148config ACPI_PROCESSOR 137config ACPI_PROCESSOR
149 tristate "Processor" 138 tristate "Processor"
150 default m 139 default y
151 help 140 help
152 This driver installs ACPI as the idle handler for Linux, and uses 141 This driver installs ACPI as the idle handler for Linux, and uses
153 ACPI C2 and C3 processor states to save power, on systems that 142 ACPI C2 and C3 processor states to save power, on systems that
154 support it. 143 support it. It is required by several flavors of cpufreq
144 Performance-state drivers.
155 145
156config ACPI_HOTPLUG_CPU 146config ACPI_HOTPLUG_CPU
157 bool "Processor Hotplug (EXPERIMENTAL)" 147 bool
158 depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL 148 depends on ACPI_PROCESSOR && HOTPLUG_CPU
159 select ACPI_CONTAINER 149 select ACPI_CONTAINER
160 default n 150 default y
161 ---help---
162 Select this option if your platform support physical CPU hotplug.
163 151
164config ACPI_THERMAL 152config ACPI_THERMAL
165 tristate "Thermal Zone" 153 tristate "Thermal Zone"
166 depends on ACPI_PROCESSOR 154 depends on ACPI_PROCESSOR
167 default m 155 default y
168 help 156 help
169 This driver adds support for ACPI thermal zones. Most mobile and 157 This driver adds support for ACPI thermal zones. Most mobile and
170 some desktop systems support ACPI thermal zones. It is HIGHLY 158 some desktop systems support ACPI thermal zones. It is HIGHLY
@@ -180,7 +168,7 @@ config ACPI_NUMA
180config ACPI_ASUS 168config ACPI_ASUS
181 tristate "ASUS/Medion Laptop Extras" 169 tristate "ASUS/Medion Laptop Extras"
182 depends on X86 170 depends on X86
183 default m 171 default y
184 ---help--- 172 ---help---
185 This driver provides support for extra features of ACPI-compatible 173 This driver provides support for extra features of ACPI-compatible
186 ASUS laptops. As some of Medion laptops are made by ASUS, it may also 174 ASUS laptops. As some of Medion laptops are made by ASUS, it may also
@@ -209,7 +197,7 @@ config ACPI_ASUS
209config ACPI_IBM 197config ACPI_IBM
210 tristate "IBM ThinkPad Laptop Extras" 198 tristate "IBM ThinkPad Laptop Extras"
211 depends on X86 199 depends on X86
212 default m 200 default y
213 ---help--- 201 ---help---
214 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds 202 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
215 support for Fn-Fx key combinations, Bluetooth control, video 203 support for Fn-Fx key combinations, Bluetooth control, video
@@ -222,7 +210,7 @@ config ACPI_IBM
222config ACPI_TOSHIBA 210config ACPI_TOSHIBA
223 tristate "Toshiba Laptop Extras" 211 tristate "Toshiba Laptop Extras"
224 depends on X86 212 depends on X86
225 default m 213 default y
226 ---help--- 214 ---help---
227 This driver adds support for access to certain system settings 215 This driver adds support for access to certain system settings
228 on "legacy free" Toshiba laptops. These laptops can be recognized by 216 on "legacy free" Toshiba laptops. These laptops can be recognized by
@@ -263,7 +251,7 @@ config ACPI_CUSTOM_DSDT_FILE
263 251
264config ACPI_BLACKLIST_YEAR 252config ACPI_BLACKLIST_YEAR
265 int "Disable ACPI for systems before Jan 1st this year" 253 int "Disable ACPI for systems before Jan 1st this year"
266 depends on ACPI_INTERPRETER 254 depends on X86
267 default 0 255 default 0
268 help 256 help
269 enter a 4-digit year, eg. 2001 to disable ACPI by default 257 enter a 4-digit year, eg. 2001 to disable ACPI by default
@@ -281,10 +269,6 @@ config ACPI_DEBUG
281 of verbosity. Saying Y enables these statements. This will increase 269 of verbosity. Saying Y enables these statements. This will increase
282 your kernel size by around 50K. 270 your kernel size by around 50K.
283 271
284config ACPI_BUS
285 bool
286 default y
287
288config ACPI_EC 272config ACPI_EC
289 bool 273 bool
290 depends on X86 274 depends on X86
@@ -298,10 +282,6 @@ config ACPI_POWER
298 bool 282 bool
299 default y 283 default y
300 284
301config ACPI_PCI
302 bool
303 default PCI
304
305config ACPI_SYSTEM 285config ACPI_SYSTEM
306 bool 286 bool
307 default y 287 default y
@@ -309,14 +289,11 @@ config ACPI_SYSTEM
309 This driver will enable your system to shut down using ACPI, and 289 This driver will enable your system to shut down using ACPI, and
310 dump your ACPI DSDT table using /proc/acpi/dsdt. 290 dump your ACPI DSDT table using /proc/acpi/dsdt.
311 291
312endif # ACPI_INTERPRETER
313
314config X86_PM_TIMER 292config X86_PM_TIMER
315 bool "Power Management Timer Support" 293 bool "Power Management Timer Support"
316 depends on X86 294 depends on X86
317 depends on ACPI_BOOT && EXPERIMENTAL
318 depends on !X86_64 295 depends on !X86_64
319 default n 296 default y
320 help 297 help
321 The Power Management Timer is available on all ACPI-capable, 298 The Power Management Timer is available on all ACPI-capable,
322 in most cases even if ACPI is unusable or blacklisted. 299 in most cases even if ACPI is unusable or blacklisted.
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index ad67e8f61e6c..a18243488c66 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -15,13 +15,13 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
15# 15#
16# ACPI Boot-Time Table Parsing 16# ACPI Boot-Time Table Parsing
17# 17#
18obj-$(CONFIG_ACPI_BOOT) += tables.o 18obj-y += tables.o
19obj-$(CONFIG_ACPI_INTERPRETER) += blacklist.o 19obj-y += blacklist.o
20 20
21# 21#
22# ACPI Core Subsystem (Interpreter) 22# ACPI Core Subsystem (Interpreter)
23# 23#
24obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \ 24obj-y += osl.o utils.o \
25 dispatcher/ events/ executer/ hardware/ \ 25 dispatcher/ events/ executer/ hardware/ \
26 namespace/ parser/ resources/ tables/ \ 26 namespace/ parser/ resources/ tables/ \
27 utilities/ 27 utilities/
@@ -35,8 +35,8 @@ ifdef CONFIG_CPU_FREQ
35processor-objs += processor_perflib.o 35processor-objs += processor_perflib.o
36endif 36endif
37 37
38obj-$(CONFIG_ACPI_BUS) += sleep/ 38obj-y += sleep/
39obj-$(CONFIG_ACPI_BUS) += bus.o glue.o 39obj-y += bus.o glue.o
40obj-$(CONFIG_ACPI_AC) += ac.o 40obj-$(CONFIG_ACPI_AC) += ac.o
41obj-$(CONFIG_ACPI_BATTERY) += battery.o 41obj-$(CONFIG_ACPI_BATTERY) += battery.o
42obj-$(CONFIG_ACPI_BUTTON) += button.o 42obj-$(CONFIG_ACPI_BUTTON) += button.o
@@ -44,7 +44,7 @@ obj-$(CONFIG_ACPI_EC) += ec.o
44obj-$(CONFIG_ACPI_FAN) += fan.o 44obj-$(CONFIG_ACPI_FAN) += fan.o
45obj-$(CONFIG_ACPI_VIDEO) += video.o 45obj-$(CONFIG_ACPI_VIDEO) += video.o
46obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o 46obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
47obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o 47obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
48obj-$(CONFIG_ACPI_POWER) += power.o 48obj-$(CONFIG_ACPI_POWER) += power.o
49obj-$(CONFIG_ACPI_PROCESSOR) += processor.o 49obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
50obj-$(CONFIG_ACPI_CONTAINER) += container.o 50obj-$(CONFIG_ACPI_CONTAINER) += container.o
@@ -55,5 +55,5 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o
55obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o 55obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
56obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o 56obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o
57obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o 57obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
58obj-$(CONFIG_ACPI_BUS) += scan.o motherboard.o 58obj-y += scan.o motherboard.o
59obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o 59obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 23ab761dd721..7839b831df94 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -32,7 +32,6 @@
32#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
34 34
35
36#define ACPI_AC_COMPONENT 0x00020000 35#define ACPI_AC_COMPONENT 0x00020000
37#define ACPI_AC_CLASS "ac_adapter" 36#define ACPI_AC_CLASS "ac_adapter"
38#define ACPI_AC_HID "ACPI0003" 37#define ACPI_AC_HID "ACPI0003"
@@ -45,47 +44,45 @@
45#define ACPI_AC_STATUS_UNKNOWN 0xFF 44#define ACPI_AC_STATUS_UNKNOWN 0xFF
46 45
47#define _COMPONENT ACPI_AC_COMPONENT 46#define _COMPONENT ACPI_AC_COMPONENT
48ACPI_MODULE_NAME ("acpi_ac") 47ACPI_MODULE_NAME("acpi_ac")
49 48
50MODULE_AUTHOR("Paul Diefenbaugh"); 49 MODULE_AUTHOR("Paul Diefenbaugh");
51MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); 50MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME);
52MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
53 52
54static int acpi_ac_add (struct acpi_device *device); 53static int acpi_ac_add(struct acpi_device *device);
55static int acpi_ac_remove (struct acpi_device *device, int type); 54static int acpi_ac_remove(struct acpi_device *device, int type);
56static int acpi_ac_open_fs(struct inode *inode, struct file *file); 55static int acpi_ac_open_fs(struct inode *inode, struct file *file);
57 56
58static struct acpi_driver acpi_ac_driver = { 57static struct acpi_driver acpi_ac_driver = {
59 .name = ACPI_AC_DRIVER_NAME, 58 .name = ACPI_AC_DRIVER_NAME,
60 .class = ACPI_AC_CLASS, 59 .class = ACPI_AC_CLASS,
61 .ids = ACPI_AC_HID, 60 .ids = ACPI_AC_HID,
62 .ops = { 61 .ops = {
63 .add = acpi_ac_add, 62 .add = acpi_ac_add,
64 .remove = acpi_ac_remove, 63 .remove = acpi_ac_remove,
65 }, 64 },
66}; 65};
67 66
68struct acpi_ac { 67struct acpi_ac {
69 acpi_handle handle; 68 acpi_handle handle;
70 unsigned long state; 69 unsigned long state;
71}; 70};
72 71
73static struct file_operations acpi_ac_fops = { 72static struct file_operations acpi_ac_fops = {
74 .open = acpi_ac_open_fs, 73 .open = acpi_ac_open_fs,
75 .read = seq_read, 74 .read = seq_read,
76 .llseek = seq_lseek, 75 .llseek = seq_lseek,
77 .release = single_release, 76 .release = single_release,
78}; 77};
79 78
80/* -------------------------------------------------------------------------- 79/* --------------------------------------------------------------------------
81 AC Adapter Management 80 AC Adapter Management
82 -------------------------------------------------------------------------- */ 81 -------------------------------------------------------------------------- */
83 82
84static int 83static int acpi_ac_get_state(struct acpi_ac *ac)
85acpi_ac_get_state (
86 struct acpi_ac *ac)
87{ 84{
88 acpi_status status = AE_OK; 85 acpi_status status = AE_OK;
89 86
90 ACPI_FUNCTION_TRACE("acpi_ac_get_state"); 87 ACPI_FUNCTION_TRACE("acpi_ac_get_state");
91 88
@@ -95,24 +92,23 @@ acpi_ac_get_state (
95 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); 92 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
96 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 94 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
98 "Error reading AC Adapter state\n")); 95 "Error reading AC Adapter state\n"));
99 ac->state = ACPI_AC_STATUS_UNKNOWN; 96 ac->state = ACPI_AC_STATUS_UNKNOWN;
100 return_VALUE(-ENODEV); 97 return_VALUE(-ENODEV);
101 } 98 }
102 99
103 return_VALUE(0); 100 return_VALUE(0);
104} 101}
105 102
106
107/* -------------------------------------------------------------------------- 103/* --------------------------------------------------------------------------
108 FS Interface (/proc) 104 FS Interface (/proc)
109 -------------------------------------------------------------------------- */ 105 -------------------------------------------------------------------------- */
110 106
111static struct proc_dir_entry *acpi_ac_dir; 107static struct proc_dir_entry *acpi_ac_dir;
112 108
113static int acpi_ac_seq_show(struct seq_file *seq, void *offset) 109static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
114{ 110{
115 struct acpi_ac *ac = (struct acpi_ac *) seq->private; 111 struct acpi_ac *ac = (struct acpi_ac *)seq->private;
116 112
117 ACPI_FUNCTION_TRACE("acpi_ac_seq_show"); 113 ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
118 114
@@ -139,23 +135,21 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
139 135
140 return_VALUE(0); 136 return_VALUE(0);
141} 137}
142 138
143static int acpi_ac_open_fs(struct inode *inode, struct file *file) 139static int acpi_ac_open_fs(struct inode *inode, struct file *file)
144{ 140{
145 return single_open(file, acpi_ac_seq_show, PDE(inode)->data); 141 return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
146} 142}
147 143
148static int 144static int acpi_ac_add_fs(struct acpi_device *device)
149acpi_ac_add_fs (
150 struct acpi_device *device)
151{ 145{
152 struct proc_dir_entry *entry = NULL; 146 struct proc_dir_entry *entry = NULL;
153 147
154 ACPI_FUNCTION_TRACE("acpi_ac_add_fs"); 148 ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
155 149
156 if (!acpi_device_dir(device)) { 150 if (!acpi_device_dir(device)) {
157 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 151 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
158 acpi_ac_dir); 152 acpi_ac_dir);
159 if (!acpi_device_dir(device)) 153 if (!acpi_device_dir(device))
160 return_VALUE(-ENODEV); 154 return_VALUE(-ENODEV);
161 acpi_device_dir(device)->owner = THIS_MODULE; 155 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -163,11 +157,11 @@ acpi_ac_add_fs (
163 157
164 /* 'state' [R] */ 158 /* 'state' [R] */
165 entry = create_proc_entry(ACPI_AC_FILE_STATE, 159 entry = create_proc_entry(ACPI_AC_FILE_STATE,
166 S_IRUGO, acpi_device_dir(device)); 160 S_IRUGO, acpi_device_dir(device));
167 if (!entry) 161 if (!entry)
168 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
169 "Unable to create '%s' fs entry\n", 163 "Unable to create '%s' fs entry\n",
170 ACPI_AC_FILE_STATE)); 164 ACPI_AC_FILE_STATE));
171 else { 165 else {
172 entry->proc_fops = &acpi_ac_fops; 166 entry->proc_fops = &acpi_ac_fops;
173 entry->data = acpi_driver_data(device); 167 entry->data = acpi_driver_data(device);
@@ -177,16 +171,12 @@ acpi_ac_add_fs (
177 return_VALUE(0); 171 return_VALUE(0);
178} 172}
179 173
180 174static int acpi_ac_remove_fs(struct acpi_device *device)
181static int
182acpi_ac_remove_fs (
183 struct acpi_device *device)
184{ 175{
185 ACPI_FUNCTION_TRACE("acpi_ac_remove_fs"); 176 ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
186 177
187 if (acpi_device_dir(device)) { 178 if (acpi_device_dir(device)) {
188 remove_proc_entry(ACPI_AC_FILE_STATE, 179 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
189 acpi_device_dir(device));
190 180
191 remove_proc_entry(acpi_device_bid(device), acpi_ac_dir); 181 remove_proc_entry(acpi_device_bid(device), acpi_ac_dir);
192 acpi_device_dir(device) = NULL; 182 acpi_device_dir(device) = NULL;
@@ -195,19 +185,14 @@ acpi_ac_remove_fs (
195 return_VALUE(0); 185 return_VALUE(0);
196} 186}
197 187
198
199/* -------------------------------------------------------------------------- 188/* --------------------------------------------------------------------------
200 Driver Model 189 Driver Model
201 -------------------------------------------------------------------------- */ 190 -------------------------------------------------------------------------- */
202 191
203static void 192static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
204acpi_ac_notify (
205 acpi_handle handle,
206 u32 event,
207 void *data)
208{ 193{
209 struct acpi_ac *ac = (struct acpi_ac *) data; 194 struct acpi_ac *ac = (struct acpi_ac *)data;
210 struct acpi_device *device = NULL; 195 struct acpi_device *device = NULL;
211 196
212 ACPI_FUNCTION_TRACE("acpi_ac_notify"); 197 ACPI_FUNCTION_TRACE("acpi_ac_notify");
213 198
@@ -224,21 +209,18 @@ acpi_ac_notify (
224 break; 209 break;
225 default: 210 default:
226 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 211 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
227 "Unsupported event [0x%x]\n", event)); 212 "Unsupported event [0x%x]\n", event));
228 break; 213 break;
229 } 214 }
230 215
231 return_VOID; 216 return_VOID;
232} 217}
233 218
234 219static int acpi_ac_add(struct acpi_device *device)
235static int
236acpi_ac_add (
237 struct acpi_device *device)
238{ 220{
239 int result = 0; 221 int result = 0;
240 acpi_status status = AE_OK; 222 acpi_status status = AE_OK;
241 struct acpi_ac *ac = NULL; 223 struct acpi_ac *ac = NULL;
242 224
243 ACPI_FUNCTION_TRACE("acpi_ac_add"); 225 ACPI_FUNCTION_TRACE("acpi_ac_add");
244 226
@@ -264,19 +246,20 @@ acpi_ac_add (
264 goto end; 246 goto end;
265 247
266 status = acpi_install_notify_handler(ac->handle, 248 status = acpi_install_notify_handler(ac->handle,
267 ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac); 249 ACPI_DEVICE_NOTIFY, acpi_ac_notify,
250 ac);
268 if (ACPI_FAILURE(status)) { 251 if (ACPI_FAILURE(status)) {
269 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 252 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
270 "Error installing notify handler\n")); 253 "Error installing notify handler\n"));
271 result = -ENODEV; 254 result = -ENODEV;
272 goto end; 255 goto end;
273 } 256 }
274 257
275 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 258 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
276 acpi_device_name(device), acpi_device_bid(device), 259 acpi_device_name(device), acpi_device_bid(device),
277 ac->state?"on-line":"off-line"); 260 ac->state ? "on-line" : "off-line");
278 261
279end: 262 end:
280 if (result) { 263 if (result) {
281 acpi_ac_remove_fs(device); 264 acpi_ac_remove_fs(device);
282 kfree(ac); 265 kfree(ac);
@@ -285,27 +268,23 @@ end:
285 return_VALUE(result); 268 return_VALUE(result);
286} 269}
287 270
288 271static int acpi_ac_remove(struct acpi_device *device, int type)
289static int
290acpi_ac_remove (
291 struct acpi_device *device,
292 int type)
293{ 272{
294 acpi_status status = AE_OK; 273 acpi_status status = AE_OK;
295 struct acpi_ac *ac = NULL; 274 struct acpi_ac *ac = NULL;
296 275
297 ACPI_FUNCTION_TRACE("acpi_ac_remove"); 276 ACPI_FUNCTION_TRACE("acpi_ac_remove");
298 277
299 if (!device || !acpi_driver_data(device)) 278 if (!device || !acpi_driver_data(device))
300 return_VALUE(-EINVAL); 279 return_VALUE(-EINVAL);
301 280
302 ac = (struct acpi_ac *) acpi_driver_data(device); 281 ac = (struct acpi_ac *)acpi_driver_data(device);
303 282
304 status = acpi_remove_notify_handler(ac->handle, 283 status = acpi_remove_notify_handler(ac->handle,
305 ACPI_DEVICE_NOTIFY, acpi_ac_notify); 284 ACPI_DEVICE_NOTIFY, acpi_ac_notify);
306 if (ACPI_FAILURE(status)) 285 if (ACPI_FAILURE(status))
307 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
308 "Error removing notify handler\n")); 287 "Error removing notify handler\n"));
309 288
310 acpi_ac_remove_fs(device); 289 acpi_ac_remove_fs(device);
311 290
@@ -314,11 +293,9 @@ acpi_ac_remove (
314 return_VALUE(0); 293 return_VALUE(0);
315} 294}
316 295
317 296static int __init acpi_ac_init(void)
318static int __init
319acpi_ac_init (void)
320{ 297{
321 int result = 0; 298 int result = 0;
322 299
323 ACPI_FUNCTION_TRACE("acpi_ac_init"); 300 ACPI_FUNCTION_TRACE("acpi_ac_init");
324 301
@@ -336,9 +313,7 @@ acpi_ac_init (void)
336 return_VALUE(0); 313 return_VALUE(0);
337} 314}
338 315
339 316static void __exit acpi_ac_exit(void)
340static void __exit
341acpi_ac_exit (void)
342{ 317{
343 ACPI_FUNCTION_TRACE("acpi_ac_exit"); 318 ACPI_FUNCTION_TRACE("acpi_ac_exit");
344 319
@@ -349,6 +324,5 @@ acpi_ac_exit (void)
349 return_VOID; 324 return_VOID;
350} 325}
351 326
352
353module_init(acpi_ac_init); 327module_init(acpi_ac_init);
354module_exit(acpi_ac_exit); 328module_exit(acpi_ac_exit);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 77285ffe41c5..01a1bd239263 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -32,7 +32,6 @@
32#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
33#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
34 34
35
36#define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL 35#define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL
37#define ACPI_MEMORY_DEVICE_CLASS "memory" 36#define ACPI_MEMORY_DEVICE_CLASS "memory"
38#define ACPI_MEMORY_DEVICE_HID "PNP0C80" 37#define ACPI_MEMORY_DEVICE_HID "PNP0C80"
@@ -41,8 +40,8 @@
41 40
42#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT 41#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT
43 42
44ACPI_MODULE_NAME ("acpi_memory") 43ACPI_MODULE_NAME("acpi_memory")
45MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>"); 44 MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
46MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME); 45MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME);
47MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
48 47
@@ -56,34 +55,33 @@ MODULE_LICENSE("GPL");
56#define MEMORY_POWER_ON_STATE 1 55#define MEMORY_POWER_ON_STATE 1
57#define MEMORY_POWER_OFF_STATE 2 56#define MEMORY_POWER_OFF_STATE 2
58 57
59static int acpi_memory_device_add (struct acpi_device *device); 58static int acpi_memory_device_add(struct acpi_device *device);
60static int acpi_memory_device_remove (struct acpi_device *device, int type); 59static int acpi_memory_device_remove(struct acpi_device *device, int type);
61 60
62static struct acpi_driver acpi_memory_device_driver = { 61static struct acpi_driver acpi_memory_device_driver = {
63 .name = ACPI_MEMORY_DEVICE_DRIVER_NAME, 62 .name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
64 .class = ACPI_MEMORY_DEVICE_CLASS, 63 .class = ACPI_MEMORY_DEVICE_CLASS,
65 .ids = ACPI_MEMORY_DEVICE_HID, 64 .ids = ACPI_MEMORY_DEVICE_HID,
66 .ops = { 65 .ops = {
67 .add = acpi_memory_device_add, 66 .add = acpi_memory_device_add,
68 .remove = acpi_memory_device_remove, 67 .remove = acpi_memory_device_remove,
69 }, 68 },
70}; 69};
71 70
72struct acpi_memory_device { 71struct acpi_memory_device {
73 acpi_handle handle; 72 acpi_handle handle;
74 unsigned int state; /* State of the memory device */ 73 unsigned int state; /* State of the memory device */
75 unsigned short cache_attribute; /* memory cache attribute */ 74 unsigned short cache_attribute; /* memory cache attribute */
76 unsigned short read_write_attribute;/* memory read/write attribute */ 75 unsigned short read_write_attribute; /* memory read/write attribute */
77 u64 start_addr; /* Memory Range start physical addr */ 76 u64 start_addr; /* Memory Range start physical addr */
78 u64 end_addr; /* Memory Range end physical addr */ 77 u64 end_addr; /* Memory Range end physical addr */
79}; 78};
80 79
81
82static int 80static int
83acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) 81acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
84{ 82{
85 acpi_status status; 83 acpi_status status;
86 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
87 struct acpi_resource *resource = NULL; 85 struct acpi_resource *resource = NULL;
88 struct acpi_resource_address64 address64; 86 struct acpi_resource_address64 address64;
89 87
@@ -94,15 +92,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
94 if (ACPI_FAILURE(status)) 92 if (ACPI_FAILURE(status))
95 return_VALUE(-EINVAL); 93 return_VALUE(-EINVAL);
96 94
97 resource = (struct acpi_resource *) buffer.pointer; 95 resource = (struct acpi_resource *)buffer.pointer;
98 status = acpi_resource_to_address64(resource, &address64); 96 status = acpi_resource_to_address64(resource, &address64);
99 if (ACPI_SUCCESS(status)) { 97 if (ACPI_SUCCESS(status)) {
100 if (address64.resource_type == ACPI_MEMORY_RANGE) { 98 if (address64.resource_type == ACPI_MEMORY_RANGE) {
101 /* Populate the structure */ 99 /* Populate the structure */
102 mem_device->cache_attribute = 100 mem_device->cache_attribute =
103 address64.attribute.memory.cache_attribute; 101 address64.attribute.memory.cache_attribute;
104 mem_device->read_write_attribute = 102 mem_device->read_write_attribute =
105 address64.attribute.memory.read_write_attribute; 103 address64.attribute.memory.read_write_attribute;
106 mem_device->start_addr = address64.min_address_range; 104 mem_device->start_addr = address64.min_address_range;
107 mem_device->end_addr = address64.max_address_range; 105 mem_device->end_addr = address64.max_address_range;
108 } 106 }
@@ -114,7 +112,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
114 112
115static int 113static int
116acpi_memory_get_device(acpi_handle handle, 114acpi_memory_get_device(acpi_handle handle,
117 struct acpi_memory_device **mem_device) 115 struct acpi_memory_device **mem_device)
118{ 116{
119 acpi_status status; 117 acpi_status status;
120 acpi_handle phandle; 118 acpi_handle phandle;
@@ -128,8 +126,7 @@ acpi_memory_get_device(acpi_handle handle,
128 126
129 status = acpi_get_parent(handle, &phandle); 127 status = acpi_get_parent(handle, &phandle);
130 if (ACPI_FAILURE(status)) { 128 if (ACPI_FAILURE(status)) {
131 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 129 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n"));
132 "Error in acpi_get_parent\n"));
133 return_VALUE(-EINVAL); 130 return_VALUE(-EINVAL);
134 } 131 }
135 132
@@ -137,7 +134,7 @@ acpi_memory_get_device(acpi_handle handle,
137 status = acpi_bus_get_device(phandle, &pdevice); 134 status = acpi_bus_get_device(phandle, &pdevice);
138 if (ACPI_FAILURE(status)) { 135 if (ACPI_FAILURE(status)) {
139 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 136 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
140 "Error in acpi_bus_get_device\n")); 137 "Error in acpi_bus_get_device\n"));
141 return_VALUE(-EINVAL); 138 return_VALUE(-EINVAL);
142 } 139 }
143 140
@@ -147,23 +144,21 @@ acpi_memory_get_device(acpi_handle handle,
147 */ 144 */
148 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 145 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
149 if (ACPI_FAILURE(status)) { 146 if (ACPI_FAILURE(status)) {
150 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n"));
151 "Error in acpi_bus_add\n"));
152 return_VALUE(-EINVAL); 148 return_VALUE(-EINVAL);
153 } 149 }
154 150
155end: 151 end:
156 *mem_device = acpi_driver_data(device); 152 *mem_device = acpi_driver_data(device);
157 if (!(*mem_device)) { 153 if (!(*mem_device)) {
158 printk(KERN_ERR "\n driver data not found" ); 154 printk(KERN_ERR "\n driver data not found");
159 return_VALUE(-ENODEV); 155 return_VALUE(-ENODEV);
160 } 156 }
161 157
162 return_VALUE(0); 158 return_VALUE(0);
163} 159}
164 160
165static int 161static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
166acpi_memory_check_device(struct acpi_memory_device *mem_device)
167{ 162{
168 unsigned long current_status; 163 unsigned long current_status;
169 164
@@ -171,22 +166,21 @@ acpi_memory_check_device(struct acpi_memory_device *mem_device)
171 166
172 /* Get device present/absent information from the _STA */ 167 /* Get device present/absent information from the _STA */
173 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", 168 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
174 NULL, &current_status))) 169 NULL, &current_status)))
175 return_VALUE(-ENODEV); 170 return_VALUE(-ENODEV);
176 /* 171 /*
177 * Check for device status. Device should be 172 * Check for device status. Device should be
178 * present/enabled/functioning. 173 * present/enabled/functioning.
179 */ 174 */
180 if (!((current_status & ACPI_MEMORY_STA_PRESENT) 175 if (!((current_status & ACPI_MEMORY_STA_PRESENT)
181 && (current_status & ACPI_MEMORY_STA_ENABLED) 176 && (current_status & ACPI_MEMORY_STA_ENABLED)
182 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) 177 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
183 return_VALUE(-ENODEV); 178 return_VALUE(-ENODEV);
184 179
185 return_VALUE(0); 180 return_VALUE(0);
186} 181}
187 182
188static int 183static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
189acpi_memory_enable_device(struct acpi_memory_device *mem_device)
190{ 184{
191 int result; 185 int result;
192 186
@@ -196,7 +190,7 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
196 result = acpi_memory_get_device_resources(mem_device); 190 result = acpi_memory_get_device_resources(mem_device);
197 if (result) { 191 if (result) {
198 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 192 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
199 "\nget_device_resources failed\n")); 193 "\nget_device_resources failed\n"));
200 mem_device->state = MEMORY_INVALID_STATE; 194 mem_device->state = MEMORY_INVALID_STATE;
201 return result; 195 return result;
202 } 196 }
@@ -206,11 +200,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
206 * Note: Assume that this function returns zero on success 200 * Note: Assume that this function returns zero on success
207 */ 201 */
208 result = add_memory(mem_device->start_addr, 202 result = add_memory(mem_device->start_addr,
209 (mem_device->end_addr - mem_device->start_addr) + 1, 203 (mem_device->end_addr - mem_device->start_addr) + 1,
210 mem_device->read_write_attribute); 204 mem_device->read_write_attribute);
211 if (result) { 205 if (result) {
212 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 206 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n"));
213 "\nadd_memory failed\n"));
214 mem_device->state = MEMORY_INVALID_STATE; 207 mem_device->state = MEMORY_INVALID_STATE;
215 return result; 208 return result;
216 } 209 }
@@ -218,11 +211,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
218 return result; 211 return result;
219} 212}
220 213
221static int 214static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
222acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
223{ 215{
224 acpi_status status; 216 acpi_status status;
225 struct acpi_object_list arg_list; 217 struct acpi_object_list arg_list;
226 union acpi_object arg; 218 union acpi_object arg;
227 unsigned long current_status; 219 unsigned long current_status;
228 220
@@ -234,16 +226,16 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
234 arg.type = ACPI_TYPE_INTEGER; 226 arg.type = ACPI_TYPE_INTEGER;
235 arg.integer.value = 1; 227 arg.integer.value = 1;
236 status = acpi_evaluate_object(mem_device->handle, 228 status = acpi_evaluate_object(mem_device->handle,
237 "_EJ0", &arg_list, NULL); 229 "_EJ0", &arg_list, NULL);
238 /* Return on _EJ0 failure */ 230 /* Return on _EJ0 failure */
239 if (ACPI_FAILURE(status)) { 231 if (ACPI_FAILURE(status)) {
240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"_EJ0 failed.\n")); 232 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n"));
241 return_VALUE(-ENODEV); 233 return_VALUE(-ENODEV);
242 } 234 }
243 235
244 /* Evalute _STA to check if the device is disabled */ 236 /* Evalute _STA to check if the device is disabled */
245 status = acpi_evaluate_integer(mem_device->handle, "_STA", 237 status = acpi_evaluate_integer(mem_device->handle, "_STA",
246 NULL, &current_status); 238 NULL, &current_status);
247 if (ACPI_FAILURE(status)) 239 if (ACPI_FAILURE(status))
248 return_VALUE(-ENODEV); 240 return_VALUE(-ENODEV);
249 241
@@ -254,8 +246,7 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
254 return_VALUE(0); 246 return_VALUE(0);
255} 247}
256 248
257static int 249static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
258acpi_memory_disable_device(struct acpi_memory_device *mem_device)
259{ 250{
260 int result; 251 int result;
261 u64 start = mem_device->start_addr; 252 u64 start = mem_device->start_addr;
@@ -278,7 +269,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device)
278 result = acpi_memory_powerdown_device(mem_device); 269 result = acpi_memory_powerdown_device(mem_device);
279 if (result) { 270 if (result) {
280 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 271 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
281 "Device Power Down failed.\n")); 272 "Device Power Down failed.\n"));
282 /* Set the status of the device to invalid */ 273 /* Set the status of the device to invalid */
283 mem_device->state = MEMORY_INVALID_STATE; 274 mem_device->state = MEMORY_INVALID_STATE;
284 return result; 275 return result;
@@ -288,8 +279,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device)
288 return result; 279 return result;
289} 280}
290 281
291static void 282static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
292acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
293{ 283{
294 struct acpi_memory_device *mem_device; 284 struct acpi_memory_device *mem_device;
295 struct acpi_device *device; 285 struct acpi_device *device;
@@ -299,37 +289,37 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
299 switch (event) { 289 switch (event) {
300 case ACPI_NOTIFY_BUS_CHECK: 290 case ACPI_NOTIFY_BUS_CHECK:
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 291 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
302 "\nReceived BUS CHECK notification for device\n")); 292 "\nReceived BUS CHECK notification for device\n"));
303 /* Fall Through */ 293 /* Fall Through */
304 case ACPI_NOTIFY_DEVICE_CHECK: 294 case ACPI_NOTIFY_DEVICE_CHECK:
305 if (event == ACPI_NOTIFY_DEVICE_CHECK) 295 if (event == ACPI_NOTIFY_DEVICE_CHECK)
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 296 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
307 "\nReceived DEVICE CHECK notification for device\n")); 297 "\nReceived DEVICE CHECK notification for device\n"));
308 if (acpi_memory_get_device(handle, &mem_device)) { 298 if (acpi_memory_get_device(handle, &mem_device)) {
309 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 299 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
310 "Error in finding driver data\n")); 300 "Error in finding driver data\n"));
311 return_VOID; 301 return_VOID;
312 } 302 }
313 303
314 if (!acpi_memory_check_device(mem_device)) { 304 if (!acpi_memory_check_device(mem_device)) {
315 if (acpi_memory_enable_device(mem_device)) 305 if (acpi_memory_enable_device(mem_device))
316 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
317 "Error in acpi_memory_enable_device\n")); 307 "Error in acpi_memory_enable_device\n"));
318 } 308 }
319 break; 309 break;
320 case ACPI_NOTIFY_EJECT_REQUEST: 310 case ACPI_NOTIFY_EJECT_REQUEST:
321 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 311 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
322 "\nReceived EJECT REQUEST notification for device\n")); 312 "\nReceived EJECT REQUEST notification for device\n"));
323 313
324 if (acpi_bus_get_device(handle, &device)) { 314 if (acpi_bus_get_device(handle, &device)) {
325 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 315 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
326 "Device doesn't exist\n")); 316 "Device doesn't exist\n"));
327 break; 317 break;
328 } 318 }
329 mem_device = acpi_driver_data(device); 319 mem_device = acpi_driver_data(device);
330 if (!mem_device) { 320 if (!mem_device) {
331 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
332 "Driver Data is NULL\n")); 322 "Driver Data is NULL\n"));
333 break; 323 break;
334 } 324 }
335 325
@@ -337,26 +327,25 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
337 * Currently disabling memory device from kernel mode 327 * Currently disabling memory device from kernel mode
338 * TBD: Can also be disabled from user mode scripts 328 * TBD: Can also be disabled from user mode scripts
339 * TBD: Can also be disabled by Callback registration 329 * TBD: Can also be disabled by Callback registration
340 * with generic sysfs driver 330 * with generic sysfs driver
341 */ 331 */
342 if (acpi_memory_disable_device(mem_device)) 332 if (acpi_memory_disable_device(mem_device))
343 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 333 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
344 "Error in acpi_memory_disable_device\n")); 334 "Error in acpi_memory_disable_device\n"));
345 /* 335 /*
346 * TBD: Invoke acpi_bus_remove to cleanup data structures 336 * TBD: Invoke acpi_bus_remove to cleanup data structures
347 */ 337 */
348 break; 338 break;
349 default: 339 default:
350 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 340 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
351 "Unsupported event [0x%x]\n", event)); 341 "Unsupported event [0x%x]\n", event));
352 break; 342 break;
353 } 343 }
354 344
355 return_VOID; 345 return_VOID;
356} 346}
357 347
358static int 348static int acpi_memory_device_add(struct acpi_device *device)
359acpi_memory_device_add(struct acpi_device *device)
360{ 349{
361 int result; 350 int result;
362 struct acpi_memory_device *mem_device = NULL; 351 struct acpi_memory_device *mem_device = NULL;
@@ -391,8 +380,7 @@ acpi_memory_device_add(struct acpi_device *device)
391 return_VALUE(result); 380 return_VALUE(result);
392} 381}
393 382
394static int 383static int acpi_memory_device_remove(struct acpi_device *device, int type)
395acpi_memory_device_remove (struct acpi_device *device, int type)
396{ 384{
397 struct acpi_memory_device *mem_device = NULL; 385 struct acpi_memory_device *mem_device = NULL;
398 386
@@ -401,7 +389,7 @@ acpi_memory_device_remove (struct acpi_device *device, int type)
401 if (!device || !acpi_driver_data(device)) 389 if (!device || !acpi_driver_data(device))
402 return_VALUE(-EINVAL); 390 return_VALUE(-EINVAL);
403 391
404 mem_device = (struct acpi_memory_device *) acpi_driver_data(device); 392 mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
405 kfree(mem_device); 393 kfree(mem_device);
406 394
407 return_VALUE(0); 395 return_VALUE(0);
@@ -410,12 +398,11 @@ acpi_memory_device_remove (struct acpi_device *device, int type)
410/* 398/*
411 * Helper function to check for memory device 399 * Helper function to check for memory device
412 */ 400 */
413static acpi_status 401static acpi_status is_memory_device(acpi_handle handle)
414is_memory_device(acpi_handle handle)
415{ 402{
416 char *hardware_id; 403 char *hardware_id;
417 acpi_status status; 404 acpi_status status;
418 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 405 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
419 struct acpi_device_info *info; 406 struct acpi_device_info *info;
420 407
421 ACPI_FUNCTION_TRACE("is_memory_device"); 408 ACPI_FUNCTION_TRACE("is_memory_device");
@@ -432,7 +419,7 @@ is_memory_device(acpi_handle handle)
432 419
433 hardware_id = info->hardware_id.value; 420 hardware_id = info->hardware_id.value;
434 if ((hardware_id == NULL) || 421 if ((hardware_id == NULL) ||
435 (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) 422 (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID)))
436 status = AE_ERROR; 423 status = AE_ERROR;
437 424
438 acpi_os_free(buffer.pointer); 425 acpi_os_free(buffer.pointer);
@@ -440,8 +427,8 @@ is_memory_device(acpi_handle handle)
440} 427}
441 428
442static acpi_status 429static acpi_status
443acpi_memory_register_notify_handler (acpi_handle handle, 430acpi_memory_register_notify_handler(acpi_handle handle,
444 u32 level, void *ctxt, void **retv) 431 u32 level, void *ctxt, void **retv)
445{ 432{
446 acpi_status status; 433 acpi_status status;
447 434
@@ -452,10 +439,10 @@ acpi_memory_register_notify_handler (acpi_handle handle,
452 return_ACPI_STATUS(AE_OK); /* continue */ 439 return_ACPI_STATUS(AE_OK); /* continue */
453 440
454 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 441 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
455 acpi_memory_device_notify, NULL); 442 acpi_memory_device_notify, NULL);
456 if (ACPI_FAILURE(status)) { 443 if (ACPI_FAILURE(status)) {
457 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 444 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
458 "Error installing notify handler\n")); 445 "Error installing notify handler\n"));
459 return_ACPI_STATUS(AE_OK); /* continue */ 446 return_ACPI_STATUS(AE_OK); /* continue */
460 } 447 }
461 448
@@ -463,8 +450,8 @@ acpi_memory_register_notify_handler (acpi_handle handle,
463} 450}
464 451
465static acpi_status 452static acpi_status
466acpi_memory_deregister_notify_handler (acpi_handle handle, 453acpi_memory_deregister_notify_handler(acpi_handle handle,
467 u32 level, void *ctxt, void **retv) 454 u32 level, void *ctxt, void **retv)
468{ 455{
469 acpi_status status; 456 acpi_status status;
470 457
@@ -475,18 +462,18 @@ acpi_memory_deregister_notify_handler (acpi_handle handle,
475 return_ACPI_STATUS(AE_OK); /* continue */ 462 return_ACPI_STATUS(AE_OK); /* continue */
476 463
477 status = acpi_remove_notify_handler(handle, 464 status = acpi_remove_notify_handler(handle,
478 ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify); 465 ACPI_SYSTEM_NOTIFY,
466 acpi_memory_device_notify);
479 if (ACPI_FAILURE(status)) { 467 if (ACPI_FAILURE(status)) {
480 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 468 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
481 "Error removing notify handler\n")); 469 "Error removing notify handler\n"));
482 return_ACPI_STATUS(AE_OK); /* continue */ 470 return_ACPI_STATUS(AE_OK); /* continue */
483 } 471 }
484 472
485 return_ACPI_STATUS(status); 473 return_ACPI_STATUS(status);
486} 474}
487 475
488static int __init 476static int __init acpi_memory_device_init(void)
489acpi_memory_device_init (void)
490{ 477{
491 int result; 478 int result;
492 acpi_status status; 479 acpi_status status;
@@ -499,21 +486,20 @@ acpi_memory_device_init (void)
499 return_VALUE(-ENODEV); 486 return_VALUE(-ENODEV);
500 487
501 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 488 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
502 ACPI_UINT32_MAX, 489 ACPI_UINT32_MAX,
503 acpi_memory_register_notify_handler, 490 acpi_memory_register_notify_handler,
504 NULL, NULL); 491 NULL, NULL);
505 492
506 if (ACPI_FAILURE (status)) { 493 if (ACPI_FAILURE(status)) {
507 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n")); 494 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
508 acpi_bus_unregister_driver(&acpi_memory_device_driver); 495 acpi_bus_unregister_driver(&acpi_memory_device_driver);
509 return_VALUE(-ENODEV); 496 return_VALUE(-ENODEV);
510 } 497 }
511 498
512 return_VALUE(0); 499 return_VALUE(0);
513} 500}
514 501
515static void __exit 502static void __exit acpi_memory_device_exit(void)
516acpi_memory_device_exit (void)
517{ 503{
518 acpi_status status; 504 acpi_status status;
519 505
@@ -524,12 +510,12 @@ acpi_memory_device_exit (void)
524 * handles. 510 * handles.
525 */ 511 */
526 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 512 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
527 ACPI_UINT32_MAX, 513 ACPI_UINT32_MAX,
528 acpi_memory_deregister_notify_handler, 514 acpi_memory_deregister_notify_handler,
529 NULL, NULL); 515 NULL, NULL);
530 516
531 if (ACPI_FAILURE (status)) 517 if (ACPI_FAILURE(status))
532 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n")); 518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
533 519
534 acpi_bus_unregister_driver(&acpi_memory_device_driver); 520 acpi_bus_unregister_driver(&acpi_memory_device_driver);
535 521
@@ -538,5 +524,3 @@ acpi_memory_device_exit (void)
538 524
539module_init(acpi_memory_device_init); 525module_init(acpi_memory_device_init);
540module_exit(acpi_memory_device_exit); 526module_exit(acpi_memory_device_exit);
541
542
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index a560b1e2da77..fec895af6ae6 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -61,7 +61,7 @@
61/* 61/*
62 * Some events we use, same for all Asus 62 * Some events we use, same for all Asus
63 */ 63 */
64#define BR_UP 0x10 64#define BR_UP 0x10
65#define BR_DOWN 0x20 65#define BR_DOWN 0x20
66 66
67/* 67/*
@@ -75,7 +75,6 @@ MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
75MODULE_DESCRIPTION(ACPI_HOTK_NAME); 75MODULE_DESCRIPTION(ACPI_HOTK_NAME);
76MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77 77
78
79static uid_t asus_uid; 78static uid_t asus_uid;
80static gid_t asus_gid; 79static gid_t asus_gid;
81module_param(asus_uid, uint, 0); 80module_param(asus_uid, uint, 0);
@@ -83,26 +82,25 @@ MODULE_PARM_DESC(uid, "UID for entries in /proc/acpi/asus.\n");
83module_param(asus_gid, uint, 0); 82module_param(asus_gid, uint, 0);
84MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n"); 83MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n");
85 84
86
87/* For each model, all features implemented, 85/* For each model, all features implemented,
88 * those marked with R are relative to HOTK, A for absolute */ 86 * those marked with R are relative to HOTK, A for absolute */
89struct model_data { 87struct model_data {
90 char *name; //name of the laptop________________A 88 char *name; //name of the laptop________________A
91 char *mt_mled; //method to handle mled_____________R 89 char *mt_mled; //method to handle mled_____________R
92 char *mled_status; //node to handle mled reading_______A 90 char *mled_status; //node to handle mled reading_______A
93 char *mt_wled; //method to handle wled_____________R 91 char *mt_wled; //method to handle wled_____________R
94 char *wled_status; //node to handle wled reading_______A 92 char *wled_status; //node to handle wled reading_______A
95 char *mt_tled; //method to handle tled_____________R 93 char *mt_tled; //method to handle tled_____________R
96 char *tled_status; //node to handle tled reading_______A 94 char *tled_status; //node to handle tled reading_______A
97 char *mt_lcd_switch; //method to turn LCD ON/OFF_________A 95 char *mt_lcd_switch; //method to turn LCD ON/OFF_________A
98 char *lcd_status; //node to read LCD panel state______A 96 char *lcd_status; //node to read LCD panel state______A
99 char *brightness_up; //method to set brightness up_______A 97 char *brightness_up; //method to set brightness up_______A
100 char *brightness_down; //guess what ?______________________A 98 char *brightness_down; //guess what ?______________________A
101 char *brightness_set; //method to set absolute brightness_R 99 char *brightness_set; //method to set absolute brightness_R
102 char *brightness_get; //method to get absolute brightness_R 100 char *brightness_get; //method to get absolute brightness_R
103 char *brightness_status; //node to get brightness____________A 101 char *brightness_status; //node to get brightness____________A
104 char *display_set; //method to set video output________R 102 char *display_set; //method to set video output________R
105 char *display_get; //method to get video output________R 103 char *display_get; //method to get video output________R
106}; 104};
107 105
108/* 106/*
@@ -110,34 +108,34 @@ struct model_data {
110 * about the hotk device 108 * about the hotk device
111 */ 109 */
112struct asus_hotk { 110struct asus_hotk {
113 struct acpi_device *device; //the device we are in 111 struct acpi_device *device; //the device we are in
114 acpi_handle handle; //the handle of the hotk device 112 acpi_handle handle; //the handle of the hotk device
115 char status; //status of the hotk, for LEDs, ... 113 char status; //status of the hotk, for LEDs, ...
116 struct model_data *methods; //methods available on the laptop 114 struct model_data *methods; //methods available on the laptop
117 u8 brightness; //brightness level 115 u8 brightness; //brightness level
118 enum { 116 enum {
119 A1x = 0, //A1340D, A1300F 117 A1x = 0, //A1340D, A1300F
120 A2x, //A2500H 118 A2x, //A2500H
121 D1x, //D1 119 D1x, //D1
122 L2D, //L2000D 120 L2D, //L2000D
123 L3C, //L3800C 121 L3C, //L3800C
124 L3D, //L3400D 122 L3D, //L3400D
125 L3H, //L3H, but also L2000E 123 L3H, //L3H, but also L2000E
126 L4R, //L4500R 124 L4R, //L4500R
127 L5x, //L5800C 125 L5x, //L5800C
128 L8L, //L8400L 126 L8L, //L8400L
129 M1A, //M1300A 127 M1A, //M1300A
130 M2E, //M2400E, L4400L 128 M2E, //M2400E, L4400L
131 M6N, //M6800N 129 M6N, //M6800N
132 M6R, //M6700R 130 M6R, //M6700R
133 P30, //Samsung P30 131 P30, //Samsung P30
134 S1x, //S1300A, but also L1400B and M2400A (L84F) 132 S1x, //S1300A, but also L1400B and M2400A (L84F)
135 S2x, //S200 (J1 reported), Victor MP-XP7210 133 S2x, //S200 (J1 reported), Victor MP-XP7210
136 xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON 134 xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON
137 //(Centrino) 135 //(Centrino)
138 END_MODEL 136 END_MODEL
139 } model; //Models currently supported 137 } model; //Models currently supported
140 u16 event_count[128]; //count for each event TODO make this better 138 u16 event_count[128]; //count for each event TODO make this better
141}; 139};
142 140
143/* Here we go */ 141/* Here we go */
@@ -150,7 +148,7 @@ struct asus_hotk {
150#define xxN_PREFIX "\\_SB.PCI0.SBRG.EC0." 148#define xxN_PREFIX "\\_SB.PCI0.SBRG.EC0."
151 149
152static struct model_data model_conf[END_MODEL] = { 150static struct model_data model_conf[END_MODEL] = {
153 /* 151 /*
154 * Those pathnames are relative to the HOTK / ATKD device : 152 * Those pathnames are relative to the HOTK / ATKD device :
155 * - mt_mled 153 * - mt_mled
156 * - mt_wled 154 * - mt_wled
@@ -165,215 +163,197 @@ static struct model_data model_conf[END_MODEL] = {
165 */ 163 */
166 164
167 { 165 {
168 .name = "A1x", 166 .name = "A1x",
169 .mt_mled = "MLED", 167 .mt_mled = "MLED",
170 .mled_status = "\\MAIL", 168 .mled_status = "\\MAIL",
171 .mt_lcd_switch = A1x_PREFIX "_Q10", 169 .mt_lcd_switch = A1x_PREFIX "_Q10",
172 .lcd_status = "\\BKLI", 170 .lcd_status = "\\BKLI",
173 .brightness_up = A1x_PREFIX "_Q0E", 171 .brightness_up = A1x_PREFIX "_Q0E",
174 .brightness_down = A1x_PREFIX "_Q0F" 172 .brightness_down = A1x_PREFIX "_Q0F"},
175 },
176 173
177 { 174 {
178 .name = "A2x", 175 .name = "A2x",
179 .mt_mled = "MLED", 176 .mt_mled = "MLED",
180 .mt_wled = "WLED", 177 .mt_wled = "WLED",
181 .wled_status = "\\SG66", 178 .wled_status = "\\SG66",
182 .mt_lcd_switch = "\\Q10", 179 .mt_lcd_switch = "\\Q10",
183 .lcd_status = "\\BAOF", 180 .lcd_status = "\\BAOF",
184 .brightness_set = "SPLV", 181 .brightness_set = "SPLV",
185 .brightness_get = "GPLV", 182 .brightness_get = "GPLV",
186 .display_set = "SDSP", 183 .display_set = "SDSP",
187 .display_get = "\\INFB" 184 .display_get = "\\INFB"},
188 },
189 185
190 { 186 {
191 .name = "D1x", 187 .name = "D1x",
192 .mt_mled = "MLED", 188 .mt_mled = "MLED",
193 .mt_lcd_switch = "\\Q0D", 189 .mt_lcd_switch = "\\Q0D",
194 .lcd_status = "\\GP11", 190 .lcd_status = "\\GP11",
195 .brightness_up = "\\Q0C", 191 .brightness_up = "\\Q0C",
196 .brightness_down = "\\Q0B", 192 .brightness_down = "\\Q0B",
197 .brightness_status = "\\BLVL", 193 .brightness_status = "\\BLVL",
198 .display_set = "SDSP", 194 .display_set = "SDSP",
199 .display_get = "\\INFB" 195 .display_get = "\\INFB"},
200 },
201 196
202 { 197 {
203 .name = "L2D", 198 .name = "L2D",
204 .mt_mled = "MLED", 199 .mt_mled = "MLED",
205 .mled_status = "\\SGP6", 200 .mled_status = "\\SGP6",
206 .mt_wled = "WLED", 201 .mt_wled = "WLED",
207 .wled_status = "\\RCP3", 202 .wled_status = "\\RCP3",
208 .mt_lcd_switch = "\\Q10", 203 .mt_lcd_switch = "\\Q10",
209 .lcd_status = "\\SGP0", 204 .lcd_status = "\\SGP0",
210 .brightness_up = "\\Q0E", 205 .brightness_up = "\\Q0E",
211 .brightness_down = "\\Q0F", 206 .brightness_down = "\\Q0F",
212 .display_set = "SDSP", 207 .display_set = "SDSP",
213 .display_get = "\\INFB" 208 .display_get = "\\INFB"},
214 },
215 209
216 { 210 {
217 .name = "L3C", 211 .name = "L3C",
218 .mt_mled = "MLED", 212 .mt_mled = "MLED",
219 .mt_wled = "WLED", 213 .mt_wled = "WLED",
220 .mt_lcd_switch = L3C_PREFIX "_Q10", 214 .mt_lcd_switch = L3C_PREFIX "_Q10",
221 .lcd_status = "\\GL32", 215 .lcd_status = "\\GL32",
222 .brightness_set = "SPLV", 216 .brightness_set = "SPLV",
223 .brightness_get = "GPLV", 217 .brightness_get = "GPLV",
224 .display_set = "SDSP", 218 .display_set = "SDSP",
225 .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP" 219 .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP"},
226 },
227 220
228 { 221 {
229 .name = "L3D", 222 .name = "L3D",
230 .mt_mled = "MLED", 223 .mt_mled = "MLED",
231 .mled_status = "\\MALD", 224 .mled_status = "\\MALD",
232 .mt_wled = "WLED", 225 .mt_wled = "WLED",
233 .mt_lcd_switch = "\\Q10", 226 .mt_lcd_switch = "\\Q10",
234 .lcd_status = "\\BKLG", 227 .lcd_status = "\\BKLG",
235 .brightness_set = "SPLV", 228 .brightness_set = "SPLV",
236 .brightness_get = "GPLV", 229 .brightness_get = "GPLV",
237 .display_set = "SDSP", 230 .display_set = "SDSP",
238 .display_get = "\\INFB" 231 .display_get = "\\INFB"},
239 },
240 232
241 { 233 {
242 .name = "L3H", 234 .name = "L3H",
243 .mt_mled = "MLED", 235 .mt_mled = "MLED",
244 .mt_wled = "WLED", 236 .mt_wled = "WLED",
245 .mt_lcd_switch = "EHK", 237 .mt_lcd_switch = "EHK",
246 .lcd_status = "\\_SB.PCI0.PM.PBC", 238 .lcd_status = "\\_SB.PCI0.PM.PBC",
247 .brightness_set = "SPLV", 239 .brightness_set = "SPLV",
248 .brightness_get = "GPLV", 240 .brightness_get = "GPLV",
249 .display_set = "SDSP", 241 .display_set = "SDSP",
250 .display_get = "\\INFB" 242 .display_get = "\\INFB"},
251 },
252 243
253 { 244 {
254 .name = "L4R", 245 .name = "L4R",
255 .mt_mled = "MLED", 246 .mt_mled = "MLED",
256 .mt_wled = "WLED", 247 .mt_wled = "WLED",
257 .wled_status = "\\_SB.PCI0.SBRG.SG13", 248 .wled_status = "\\_SB.PCI0.SBRG.SG13",
258 .mt_lcd_switch = xxN_PREFIX "_Q10", 249 .mt_lcd_switch = xxN_PREFIX "_Q10",
259 .lcd_status = "\\_SB.PCI0.SBSM.SEO4", 250 .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
260 .brightness_set = "SPLV", 251 .brightness_set = "SPLV",
261 .brightness_get = "GPLV", 252 .brightness_get = "GPLV",
262 .display_set = "SDSP", 253 .display_set = "SDSP",
263 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD" 254 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
264 },
265 255
266 { 256 {
267 .name = "L5x", 257 .name = "L5x",
268 .mt_mled = "MLED", 258 .mt_mled = "MLED",
269/* WLED present, but not controlled by ACPI */ 259/* WLED present, but not controlled by ACPI */
270 .mt_tled = "TLED", 260 .mt_tled = "TLED",
271 .mt_lcd_switch = "\\Q0D", 261 .mt_lcd_switch = "\\Q0D",
272 .lcd_status = "\\BAOF", 262 .lcd_status = "\\BAOF",
273 .brightness_set = "SPLV", 263 .brightness_set = "SPLV",
274 .brightness_get = "GPLV", 264 .brightness_get = "GPLV",
275 .display_set = "SDSP", 265 .display_set = "SDSP",
276 .display_get = "\\INFB" 266 .display_get = "\\INFB"},
277 },
278 267
279 { 268 {
280 .name = "L8L" 269 .name = "L8L"
281/* No features, but at least support the hotkeys */ 270/* No features, but at least support the hotkeys */
282 }, 271 },
283 272
284 { 273 {
285 .name = "M1A", 274 .name = "M1A",
286 .mt_mled = "MLED", 275 .mt_mled = "MLED",
287 .mt_lcd_switch = M1A_PREFIX "Q10", 276 .mt_lcd_switch = M1A_PREFIX "Q10",
288 .lcd_status = "\\PNOF", 277 .lcd_status = "\\PNOF",
289 .brightness_up = M1A_PREFIX "Q0E", 278 .brightness_up = M1A_PREFIX "Q0E",
290 .brightness_down = M1A_PREFIX "Q0F", 279 .brightness_down = M1A_PREFIX "Q0F",
291 .brightness_status = "\\BRIT", 280 .brightness_status = "\\BRIT",
292 .display_set = "SDSP", 281 .display_set = "SDSP",
293 .display_get = "\\INFB" 282 .display_get = "\\INFB"},
294 },
295 283
296 { 284 {
297 .name = "M2E", 285 .name = "M2E",
298 .mt_mled = "MLED", 286 .mt_mled = "MLED",
299 .mt_wled = "WLED", 287 .mt_wled = "WLED",
300 .mt_lcd_switch = "\\Q10", 288 .mt_lcd_switch = "\\Q10",
301 .lcd_status = "\\GP06", 289 .lcd_status = "\\GP06",
302 .brightness_set = "SPLV", 290 .brightness_set = "SPLV",
303 .brightness_get = "GPLV", 291 .brightness_get = "GPLV",
304 .display_set = "SDSP", 292 .display_set = "SDSP",
305 .display_get = "\\INFB" 293 .display_get = "\\INFB"},
306 },
307 294
308 { 295 {
309 .name = "M6N", 296 .name = "M6N",
310 .mt_mled = "MLED", 297 .mt_mled = "MLED",
311 .mt_wled = "WLED", 298 .mt_wled = "WLED",
312 .wled_status = "\\_SB.PCI0.SBRG.SG13", 299 .wled_status = "\\_SB.PCI0.SBRG.SG13",
313 .mt_lcd_switch = xxN_PREFIX "_Q10", 300 .mt_lcd_switch = xxN_PREFIX "_Q10",
314 .lcd_status = "\\_SB.BKLT", 301 .lcd_status = "\\_SB.BKLT",
315 .brightness_set = "SPLV", 302 .brightness_set = "SPLV",
316 .brightness_get = "GPLV", 303 .brightness_get = "GPLV",
317 .display_set = "SDSP", 304 .display_set = "SDSP",
318 .display_get = "\\SSTE" 305 .display_get = "\\SSTE"},
319 },
320 { 306 {
321 .name = "M6R", 307 .name = "M6R",
322 .mt_mled = "MLED", 308 .mt_mled = "MLED",
323 .mt_wled = "WLED", 309 .mt_wled = "WLED",
324 .mt_lcd_switch = xxN_PREFIX "_Q10", 310 .mt_lcd_switch = xxN_PREFIX "_Q10",
325 .lcd_status = "\\_SB.PCI0.SBSM.SEO4", 311 .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
326 .brightness_set = "SPLV", 312 .brightness_set = "SPLV",
327 .brightness_get = "GPLV", 313 .brightness_get = "GPLV",
328 .display_set = "SDSP", 314 .display_set = "SDSP",
329 .display_get = "\\SSTE" 315 .display_get = "\\SSTE"},
330 },
331
332 316
333 { 317 {
334 .name = "P30", 318 .name = "P30",
335 .mt_wled = "WLED", 319 .mt_wled = "WLED",
336 .mt_lcd_switch = P30_PREFIX "_Q0E", 320 .mt_lcd_switch = P30_PREFIX "_Q0E",
337 .lcd_status = "\\BKLT", 321 .lcd_status = "\\BKLT",
338 .brightness_up = P30_PREFIX "_Q68", 322 .brightness_up = P30_PREFIX "_Q68",
339 .brightness_down = P30_PREFIX "_Q69", 323 .brightness_down = P30_PREFIX "_Q69",
340 .brightness_get = "GPLV", 324 .brightness_get = "GPLV",
341 .display_set = "SDSP", 325 .display_set = "SDSP",
342 .display_get = "\\DNXT" 326 .display_get = "\\DNXT"},
343 },
344 327
345 { 328 {
346 .name = "S1x", 329 .name = "S1x",
347 .mt_mled = "MLED", 330 .mt_mled = "MLED",
348 .mled_status = "\\EMLE", 331 .mled_status = "\\EMLE",
349 .mt_wled = "WLED", 332 .mt_wled = "WLED",
350 .mt_lcd_switch = S1x_PREFIX "Q10" , 333 .mt_lcd_switch = S1x_PREFIX "Q10",
351 .lcd_status = "\\PNOF", 334 .lcd_status = "\\PNOF",
352 .brightness_set = "SPLV", 335 .brightness_set = "SPLV",
353 .brightness_get = "GPLV" 336 .brightness_get = "GPLV"},
354 },
355 337
356 { 338 {
357 .name = "S2x", 339 .name = "S2x",
358 .mt_mled = "MLED", 340 .mt_mled = "MLED",
359 .mled_status = "\\MAIL", 341 .mled_status = "\\MAIL",
360 .mt_lcd_switch = S2x_PREFIX "_Q10", 342 .mt_lcd_switch = S2x_PREFIX "_Q10",
361 .lcd_status = "\\BKLI", 343 .lcd_status = "\\BKLI",
362 .brightness_up = S2x_PREFIX "_Q0B", 344 .brightness_up = S2x_PREFIX "_Q0B",
363 .brightness_down = S2x_PREFIX "_Q0A" 345 .brightness_down = S2x_PREFIX "_Q0A"},
364 },
365 346
366 { 347 {
367 .name = "xxN", 348 .name = "xxN",
368 .mt_mled = "MLED", 349 .mt_mled = "MLED",
369/* WLED present, but not controlled by ACPI */ 350/* WLED present, but not controlled by ACPI */
370 .mt_lcd_switch = xxN_PREFIX "_Q10", 351 .mt_lcd_switch = xxN_PREFIX "_Q10",
371 .lcd_status = "\\BKLT", 352 .lcd_status = "\\BKLT",
372 .brightness_set = "SPLV", 353 .brightness_set = "SPLV",
373 .brightness_get = "GPLV", 354 .brightness_get = "GPLV",
374 .display_set = "SDSP", 355 .display_set = "SDSP",
375 .display_get = "\\ADVG" 356 .display_get = "\\ADVG"}
376 }
377}; 357};
378 358
379/* procdir we use */ 359/* procdir we use */
@@ -395,13 +375,13 @@ static struct asus_hotk *hotk;
395static int asus_hotk_add(struct acpi_device *device); 375static int asus_hotk_add(struct acpi_device *device);
396static int asus_hotk_remove(struct acpi_device *device, int type); 376static int asus_hotk_remove(struct acpi_device *device, int type);
397static struct acpi_driver asus_hotk_driver = { 377static struct acpi_driver asus_hotk_driver = {
398 .name = ACPI_HOTK_NAME, 378 .name = ACPI_HOTK_NAME,
399 .class = ACPI_HOTK_CLASS, 379 .class = ACPI_HOTK_CLASS,
400 .ids = ACPI_HOTK_HID, 380 .ids = ACPI_HOTK_HID,
401 .ops = { 381 .ops = {
402 .add = asus_hotk_add, 382 .add = asus_hotk_add,
403 .remove = asus_hotk_remove, 383 .remove = asus_hotk_remove,
404 }, 384 },
405}; 385};
406 386
407/* 387/*
@@ -423,11 +403,10 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
423 in_obj.type = ACPI_TYPE_INTEGER; 403 in_obj.type = ACPI_TYPE_INTEGER;
424 in_obj.integer.value = val; 404 in_obj.integer.value = val;
425 405
426 status = acpi_evaluate_object(handle, (char *) method, &params, output); 406 status = acpi_evaluate_object(handle, (char *)method, &params, output);
427 return (status == AE_OK); 407 return (status == AE_OK);
428} 408}
429 409
430
431static int read_acpi_int(acpi_handle handle, const char *method, int *val) 410static int read_acpi_int(acpi_handle handle, const char *method, int *val)
432{ 411{
433 struct acpi_buffer output; 412 struct acpi_buffer output;
@@ -437,7 +416,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
437 output.length = sizeof(out_obj); 416 output.length = sizeof(out_obj);
438 output.pointer = &out_obj; 417 output.pointer = &out_obj;
439 418
440 status = acpi_evaluate_object(handle, (char *) method, NULL, &output); 419 status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
441 *val = out_obj.integer.value; 420 *val = out_obj.integer.value;
442 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER); 421 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
443} 422}
@@ -449,7 +428,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
449 */ 428 */
450static int 429static int
451proc_read_info(char *page, char **start, off_t off, int count, int *eof, 430proc_read_info(char *page, char **start, off_t off, int count, int *eof,
452 void *data) 431 void *data)
453{ 432{
454 int len = 0; 433 int len = 0;
455 int temp; 434 int temp;
@@ -460,7 +439,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
460 */ 439 */
461 440
462 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); 441 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
463 len += sprintf(page + len, "Model reference : %s\n", 442 len += sprintf(page + len, "Model reference : %s\n",
464 hotk->methods->name); 443 hotk->methods->name);
465 /* 444 /*
466 * The SFUN method probably allows the original driver to get the list 445 * The SFUN method probably allows the original driver to get the list
@@ -469,7 +448,8 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
469 * The significance of others is yet to be found. 448 * The significance of others is yet to be found.
470 */ 449 */
471 if (read_acpi_int(hotk->handle, "SFUN", &temp)) 450 if (read_acpi_int(hotk->handle, "SFUN", &temp))
472 len += sprintf(page + len, "SFUN value : 0x%04x\n", temp); 451 len +=
452 sprintf(page + len, "SFUN value : 0x%04x\n", temp);
473 /* 453 /*
474 * Another value for userspace: the ASYM method returns 0x02 for 454 * Another value for userspace: the ASYM method returns 0x02 for
475 * battery low and 0x04 for battery critical, its readings tend to be 455 * battery low and 0x04 for battery critical, its readings tend to be
@@ -478,7 +458,8 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
478 * silently ignored. 458 * silently ignored.
479 */ 459 */
480 if (read_acpi_int(hotk->handle, "ASYM", &temp)) 460 if (read_acpi_int(hotk->handle, "ASYM", &temp))
481 len += sprintf(page + len, "ASYM value : 0x%04x\n", temp); 461 len +=
462 sprintf(page + len, "ASYM value : 0x%04x\n", temp);
482 if (asus_info) { 463 if (asus_info) {
483 snprintf(buf, 16, "%d", asus_info->length); 464 snprintf(buf, 16, "%d", asus_info->length);
484 len += sprintf(page + len, "DSDT length : %s\n", buf); 465 len += sprintf(page + len, "DSDT length : %s\n", buf);
@@ -501,7 +482,6 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
501 return len; 482 return len;
502} 483}
503 484
504
505/* 485/*
506 * /proc handlers 486 * /proc handlers
507 * We write our info in page, we begin at offset off and cannot write more 487 * We write our info in page, we begin at offset off and cannot write more
@@ -510,8 +490,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
510 */ 490 */
511 491
512/* Generic LED functions */ 492/* Generic LED functions */
513static int 493static int read_led(const char *ledname, int ledmask)
514read_led(const char *ledname, int ledmask)
515{ 494{
516 if (ledname) { 495 if (ledname) {
517 int led_status; 496 int led_status;
@@ -525,7 +504,7 @@ read_led(const char *ledname, int ledmask)
525 return (hotk->status & ledmask) ? 1 : 0; 504 return (hotk->status & ledmask) ? 1 : 0;
526} 505}
527 506
528static int parse_arg(const char __user *buf, unsigned long count, int *val) 507static int parse_arg(const char __user * buf, unsigned long count, int *val)
529{ 508{
530 char s[32]; 509 char s[32];
531 if (!count) 510 if (!count)
@@ -542,8 +521,8 @@ static int parse_arg(const char __user *buf, unsigned long count, int *val)
542 521
543/* FIXME: kill extraneous args so it can be called independently */ 522/* FIXME: kill extraneous args so it can be called independently */
544static int 523static int
545write_led(const char __user *buffer, unsigned long count, 524write_led(const char __user * buffer, unsigned long count,
546 char *ledname, int ledmask, int invert) 525 char *ledname, int ledmask, int invert)
547{ 526{
548 int value; 527 int value;
549 int led_out = 0; 528 int led_out = 0;
@@ -555,16 +534,16 @@ write_led(const char __user *buffer, unsigned long count,
555 hotk->status = 534 hotk->status =
556 (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); 535 (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
557 536
558 if (invert) /* invert target value */ 537 if (invert) /* invert target value */
559 led_out = !led_out & 0x1; 538 led_out = !led_out & 0x1;
560 539
561 if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) 540 if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
562 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", ledname); 541 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
542 ledname);
563 543
564 return count; 544 return count;
565} 545}
566 546
567
568/* 547/*
569 * Proc handlers for MLED 548 * Proc handlers for MLED
570 */ 549 */
@@ -572,12 +551,12 @@ static int
572proc_read_mled(char *page, char **start, off_t off, int count, int *eof, 551proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
573 void *data) 552 void *data)
574{ 553{
575 return sprintf(page, "%d\n", read_led(hotk->methods->mled_status, MLED_ON)); 554 return sprintf(page, "%d\n",
555 read_led(hotk->methods->mled_status, MLED_ON));
576} 556}
577 557
578
579static int 558static int
580proc_write_mled(struct file *file, const char __user *buffer, 559proc_write_mled(struct file *file, const char __user * buffer,
581 unsigned long count, void *data) 560 unsigned long count, void *data)
582{ 561{
583 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); 562 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
@@ -590,11 +569,12 @@ static int
590proc_read_wled(char *page, char **start, off_t off, int count, int *eof, 569proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
591 void *data) 570 void *data)
592{ 571{
593 return sprintf(page, "%d\n", read_led(hotk->methods->wled_status, WLED_ON)); 572 return sprintf(page, "%d\n",
573 read_led(hotk->methods->wled_status, WLED_ON));
594} 574}
595 575
596static int 576static int
597proc_write_wled(struct file *file, const char __user *buffer, 577proc_write_wled(struct file *file, const char __user * buffer,
598 unsigned long count, void *data) 578 unsigned long count, void *data)
599{ 579{
600 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); 580 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
@@ -607,35 +587,36 @@ static int
607proc_read_tled(char *page, char **start, off_t off, int count, int *eof, 587proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
608 void *data) 588 void *data)
609{ 589{
610 return sprintf(page, "%d\n", read_led(hotk->methods->tled_status, TLED_ON)); 590 return sprintf(page, "%d\n",
591 read_led(hotk->methods->tled_status, TLED_ON));
611} 592}
612 593
613static int 594static int
614proc_write_tled(struct file *file, const char __user *buffer, 595proc_write_tled(struct file *file, const char __user * buffer,
615 unsigned long count, void *data) 596 unsigned long count, void *data)
616{ 597{
617 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); 598 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
618} 599}
619 600
620
621static int get_lcd_state(void) 601static int get_lcd_state(void)
622{ 602{
623 int lcd = 0; 603 int lcd = 0;
624 604
625 if (hotk->model != L3H) { 605 if (hotk->model != L3H) {
626 /* We don't have to check anything if we are here */ 606 /* We don't have to check anything if we are here */
627 if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd)) 607 if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
628 printk(KERN_WARNING "Asus ACPI: Error reading LCD status\n"); 608 printk(KERN_WARNING
629 609 "Asus ACPI: Error reading LCD status\n");
610
630 if (hotk->model == L2D) 611 if (hotk->model == L2D)
631 lcd = ~lcd; 612 lcd = ~lcd;
632 } else { /* L3H and the like have to be handled differently */ 613 } else { /* L3H and the like have to be handled differently */
633 acpi_status status = 0; 614 acpi_status status = 0;
634 struct acpi_object_list input; 615 struct acpi_object_list input;
635 union acpi_object mt_params[2]; 616 union acpi_object mt_params[2];
636 struct acpi_buffer output; 617 struct acpi_buffer output;
637 union acpi_object out_obj; 618 union acpi_object out_obj;
638 619
639 input.count = 2; 620 input.count = 2;
640 input.pointer = mt_params; 621 input.pointer = mt_params;
641 /* Note: the following values are partly guessed up, but 622 /* Note: the following values are partly guessed up, but
@@ -647,15 +628,17 @@ static int get_lcd_state(void)
647 628
648 output.length = sizeof(out_obj); 629 output.length = sizeof(out_obj);
649 output.pointer = &out_obj; 630 output.pointer = &out_obj;
650 631
651 status = acpi_evaluate_object(NULL, hotk->methods->lcd_status, &input, &output); 632 status =
633 acpi_evaluate_object(NULL, hotk->methods->lcd_status,
634 &input, &output);
652 if (status != AE_OK) 635 if (status != AE_OK)
653 return -1; 636 return -1;
654 if (out_obj.type == ACPI_TYPE_INTEGER) 637 if (out_obj.type == ACPI_TYPE_INTEGER)
655 /* That's what the AML code does */ 638 /* That's what the AML code does */
656 lcd = out_obj.integer.value >> 8; 639 lcd = out_obj.integer.value >> 8;
657 } 640 }
658 641
659 return (lcd & 1); 642 return (lcd & 1);
660} 643}
661 644
@@ -669,10 +652,13 @@ static int set_lcd_state(int value)
669 /* switch */ 652 /* switch */
670 if (hotk->model != L3H) { 653 if (hotk->model != L3H) {
671 status = 654 status =
672 acpi_evaluate_object(NULL, hotk->methods->mt_lcd_switch, 655 acpi_evaluate_object(NULL,
656 hotk->methods->mt_lcd_switch,
673 NULL, NULL); 657 NULL, NULL);
674 } else { /* L3H and the like have to be handled differently */ 658 } else { /* L3H and the like have to be handled differently */
675 if (!write_acpi_int(hotk->handle, hotk->methods->mt_lcd_switch, 0x07, NULL)) 659 if (!write_acpi_int
660 (hotk->handle, hotk->methods->mt_lcd_switch, 0x07,
661 NULL))
676 status = AE_ERROR; 662 status = AE_ERROR;
677 /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress, 663 /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress,
678 the exact behaviour is simulated here */ 664 the exact behaviour is simulated here */
@@ -691,33 +677,33 @@ proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
691 return sprintf(page, "%d\n", get_lcd_state()); 677 return sprintf(page, "%d\n", get_lcd_state());
692} 678}
693 679
694
695static int 680static int
696proc_write_lcd(struct file *file, const char __user *buffer, 681proc_write_lcd(struct file *file, const char __user * buffer,
697 unsigned long count, void *data) 682 unsigned long count, void *data)
698{ 683{
699 int value; 684 int value;
700 685
701 count = parse_arg(buffer, count, &value); 686 count = parse_arg(buffer, count, &value);
702 if (count > 0) 687 if (count > 0)
703 set_lcd_state(value); 688 set_lcd_state(value);
704 return count; 689 return count;
705} 690}
706 691
707
708static int read_brightness(void) 692static int read_brightness(void)
709{ 693{
710 int value; 694 int value;
711 695
712 if(hotk->methods->brightness_get) { /* SPLV/GPLV laptop */ 696 if (hotk->methods->brightness_get) { /* SPLV/GPLV laptop */
713 if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get, 697 if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get,
714 &value)) 698 &value))
715 printk(KERN_WARNING "Asus ACPI: Error reading brightness\n"); 699 printk(KERN_WARNING
716 } else if (hotk->methods->brightness_status) { /* For D1 for example */ 700 "Asus ACPI: Error reading brightness\n");
717 if (!read_acpi_int(NULL, hotk->methods->brightness_status, 701 } else if (hotk->methods->brightness_status) { /* For D1 for example */
702 if (!read_acpi_int(NULL, hotk->methods->brightness_status,
718 &value)) 703 &value))
719 printk(KERN_WARNING "Asus ACPI: Error reading brightness\n"); 704 printk(KERN_WARNING
720 } else /* No GPLV method */ 705 "Asus ACPI: Error reading brightness\n");
706 } else /* No GPLV method */
721 value = hotk->brightness; 707 value = hotk->brightness;
722 return value; 708 return value;
723} 709}
@@ -730,23 +716,25 @@ static void set_brightness(int value)
730 acpi_status status = 0; 716 acpi_status status = 0;
731 717
732 /* SPLV laptop */ 718 /* SPLV laptop */
733 if(hotk->methods->brightness_set) { 719 if (hotk->methods->brightness_set) {
734 if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set, 720 if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set,
735 value, NULL)) 721 value, NULL))
736 printk(KERN_WARNING "Asus ACPI: Error changing brightness\n"); 722 printk(KERN_WARNING
723 "Asus ACPI: Error changing brightness\n");
737 return; 724 return;
738 } 725 }
739 726
740 /* No SPLV method if we are here, act as appropriate */ 727 /* No SPLV method if we are here, act as appropriate */
741 value -= read_brightness(); 728 value -= read_brightness();
742 while (value != 0) { 729 while (value != 0) {
743 status = acpi_evaluate_object(NULL, (value > 0) ? 730 status = acpi_evaluate_object(NULL, (value > 0) ?
744 hotk->methods->brightness_up : 731 hotk->methods->brightness_up :
745 hotk->methods->brightness_down, 732 hotk->methods->brightness_down,
746 NULL, NULL); 733 NULL, NULL);
747 (value > 0) ? value-- : value++; 734 (value > 0) ? value-- : value++;
748 if (ACPI_FAILURE(status)) 735 if (ACPI_FAILURE(status))
749 printk(KERN_WARNING "Asus ACPI: Error changing brightness\n"); 736 printk(KERN_WARNING
737 "Asus ACPI: Error changing brightness\n");
750 } 738 }
751 return; 739 return;
752} 740}
@@ -759,7 +747,7 @@ proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
759} 747}
760 748
761static int 749static int
762proc_write_brn(struct file *file, const char __user *buffer, 750proc_write_brn(struct file *file, const char __user * buffer,
763 unsigned long count, void *data) 751 unsigned long count, void *data)
764{ 752{
765 int value; 753 int value;
@@ -767,7 +755,7 @@ proc_write_brn(struct file *file, const char __user *buffer,
767 count = parse_arg(buffer, count, &value); 755 count = parse_arg(buffer, count, &value);
768 if (count > 0) { 756 if (count > 0) {
769 value = (0 < value) ? ((15 < value) ? 15 : value) : 0; 757 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
770 /* 0 <= value <= 15 */ 758 /* 0 <= value <= 15 */
771 set_brightness(value); 759 set_brightness(value);
772 } else if (count < 0) { 760 } else if (count < 0) {
773 printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); 761 printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
@@ -779,7 +767,7 @@ proc_write_brn(struct file *file, const char __user *buffer,
779static void set_display(int value) 767static void set_display(int value)
780{ 768{
781 /* no sanity check needed for now */ 769 /* no sanity check needed for now */
782 if (!write_acpi_int(hotk->handle, hotk->methods->display_set, 770 if (!write_acpi_int(hotk->handle, hotk->methods->display_set,
783 value, NULL)) 771 value, NULL))
784 printk(KERN_WARNING "Asus ACPI: Error setting display\n"); 772 printk(KERN_WARNING "Asus ACPI: Error setting display\n");
785 return; 773 return;
@@ -791,13 +779,14 @@ static void set_display(int value)
791 */ 779 */
792static int 780static int
793proc_read_disp(char *page, char **start, off_t off, int count, int *eof, 781proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
794 void *data) 782 void *data)
795{ 783{
796 int value = 0; 784 int value = 0;
797 785
798 if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value)) 786 if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
799 printk(KERN_WARNING "Asus ACPI: Error reading display status\n"); 787 printk(KERN_WARNING
800 value &= 0x07; /* needed for some models, shouldn't hurt others */ 788 "Asus ACPI: Error reading display status\n");
789 value &= 0x07; /* needed for some models, shouldn't hurt others */
801 return sprintf(page, "%d\n", value); 790 return sprintf(page, "%d\n", value);
802} 791}
803 792
@@ -808,8 +797,8 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
808 * simultaneously, so be warned. See the acpi4asus README for more info. 797 * simultaneously, so be warned. See the acpi4asus README for more info.
809 */ 798 */
810static int 799static int
811proc_write_disp(struct file *file, const char __user *buffer, 800proc_write_disp(struct file *file, const char __user * buffer,
812 unsigned long count, void *data) 801 unsigned long count, void *data)
813{ 802{
814 int value; 803 int value;
815 804
@@ -822,19 +811,19 @@ proc_write_disp(struct file *file, const char __user *buffer,
822 return count; 811 return count;
823} 812}
824 813
825 814typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
826typedef int (proc_readfunc)(char *page, char **start, off_t off, int count, 815 int *eof, void *data);
827 int *eof, void *data); 816typedef int (proc_writefunc) (struct file * file, const char __user * buffer,
828typedef int (proc_writefunc)(struct file *file, const char __user *buffer, 817 unsigned long count, void *data);
829 unsigned long count, void *data);
830 818
831static int 819static int
832__init asus_proc_add(char *name, proc_writefunc *writefunc, 820__init asus_proc_add(char *name, proc_writefunc * writefunc,
833 proc_readfunc *readfunc, mode_t mode, 821 proc_readfunc * readfunc, mode_t mode,
834 struct acpi_device *device) 822 struct acpi_device *device)
835{ 823{
836 struct proc_dir_entry *proc = create_proc_entry(name, mode, acpi_device_dir(device)); 824 struct proc_dir_entry *proc =
837 if(!proc) { 825 create_proc_entry(name, mode, acpi_device_dir(device));
826 if (!proc) {
838 printk(KERN_WARNING " Unable to create %s fs entry\n", name); 827 printk(KERN_WARNING " Unable to create %s fs entry\n", name);
839 return -1; 828 return -1;
840 } 829 }
@@ -851,14 +840,14 @@ static int __init asus_hotk_add_fs(struct acpi_device *device)
851{ 840{
852 struct proc_dir_entry *proc; 841 struct proc_dir_entry *proc;
853 mode_t mode; 842 mode_t mode;
854 843
855 /* 844 /*
856 * If parameter uid or gid is not changed, keep the default setting for 845 * If parameter uid or gid is not changed, keep the default setting for
857 * our proc entries (-rw-rw-rw-) else, it means we care about security, 846 * our proc entries (-rw-rw-rw-) else, it means we care about security,
858 * and then set to -rw-rw---- 847 * and then set to -rw-rw----
859 */ 848 */
860 849
861 if ((asus_uid == 0) && (asus_gid == 0)){ 850 if ((asus_uid == 0) && (asus_gid == 0)) {
862 mode = S_IFREG | S_IRUGO | S_IWUGO; 851 mode = S_IFREG | S_IRUGO | S_IWUGO;
863 } else { 852 } else {
864 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP; 853 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
@@ -881,15 +870,18 @@ static int __init asus_hotk_add_fs(struct acpi_device *device)
881 } 870 }
882 871
883 if (hotk->methods->mt_wled) { 872 if (hotk->methods->mt_wled) {
884 asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled, mode, device); 873 asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled,
874 mode, device);
885 } 875 }
886 876
887 if (hotk->methods->mt_mled) { 877 if (hotk->methods->mt_mled) {
888 asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, mode, device); 878 asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled,
879 mode, device);
889 } 880 }
890 881
891 if (hotk->methods->mt_tled) { 882 if (hotk->methods->mt_tled) {
892 asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled, mode, device); 883 asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled,
884 mode, device);
893 } 885 }
894 886
895 /* 887 /*
@@ -897,35 +889,40 @@ static int __init asus_hotk_add_fs(struct acpi_device *device)
897 * from keyboard 889 * from keyboard
898 */ 890 */
899 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { 891 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
900 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, device); 892 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode,
893 device);
901 } 894 }
902 895
903 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || 896 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
904 (hotk->methods->brightness_get && hotk->methods->brightness_set)) { 897 (hotk->methods->brightness_get && hotk->methods->brightness_set)) {
905 asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode, device); 898 asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode,
899 device);
906 } 900 }
907 901
908 if (hotk->methods->display_set) { 902 if (hotk->methods->display_set) {
909 asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp, mode, device); 903 asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp,
904 mode, device);
910 } 905 }
911 906
912 return 0; 907 return 0;
913} 908}
914 909
915static int asus_hotk_remove_fs(struct acpi_device* device) 910static int asus_hotk_remove_fs(struct acpi_device *device)
916{ 911{
917 if(acpi_device_dir(device)) { 912 if (acpi_device_dir(device)) {
918 remove_proc_entry(PROC_INFO,acpi_device_dir(device)); 913 remove_proc_entry(PROC_INFO, acpi_device_dir(device));
919 if (hotk->methods->mt_wled) 914 if (hotk->methods->mt_wled)
920 remove_proc_entry(PROC_WLED,acpi_device_dir(device)); 915 remove_proc_entry(PROC_WLED, acpi_device_dir(device));
921 if (hotk->methods->mt_mled) 916 if (hotk->methods->mt_mled)
922 remove_proc_entry(PROC_MLED,acpi_device_dir(device)); 917 remove_proc_entry(PROC_MLED, acpi_device_dir(device));
923 if (hotk->methods->mt_tled) 918 if (hotk->methods->mt_tled)
924 remove_proc_entry(PROC_TLED,acpi_device_dir(device)); 919 remove_proc_entry(PROC_TLED, acpi_device_dir(device));
925 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) 920 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status)
926 remove_proc_entry(PROC_LCD, acpi_device_dir(device)); 921 remove_proc_entry(PROC_LCD, acpi_device_dir(device));
927 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || 922 if ((hotk->methods->brightness_up
928 (hotk->methods->brightness_get && hotk->methods->brightness_set)) 923 && hotk->methods->brightness_down)
924 || (hotk->methods->brightness_get
925 && hotk->methods->brightness_set))
929 remove_proc_entry(PROC_BRN, acpi_device_dir(device)); 926 remove_proc_entry(PROC_BRN, acpi_device_dir(device));
930 if (hotk->methods->display_set) 927 if (hotk->methods->display_set)
931 remove_proc_entry(PROC_DISP, acpi_device_dir(device)); 928 remove_proc_entry(PROC_DISP, acpi_device_dir(device));
@@ -933,16 +930,15 @@ static int asus_hotk_remove_fs(struct acpi_device* device)
933 return 0; 930 return 0;
934} 931}
935 932
936
937static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) 933static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
938{ 934{
939 /* TODO Find a better way to handle events count.*/ 935 /* TODO Find a better way to handle events count. */
940 if (!hotk) 936 if (!hotk)
941 return; 937 return;
942 938
943 if ((event & ~((u32) BR_UP)) < 16) { 939 if ((event & ~((u32) BR_UP)) < 16) {
944 hotk->brightness = (event & ~((u32) BR_UP)); 940 hotk->brightness = (event & ~((u32) BR_UP));
945 } else if ((event & ~((u32) BR_DOWN)) < 16 ) { 941 } else if ((event & ~((u32) BR_DOWN)) < 16) {
946 hotk->brightness = (event & ~((u32) BR_DOWN)); 942 hotk->brightness = (event & ~((u32) BR_DOWN));
947 } 943 }
948 944
@@ -976,7 +972,7 @@ static int __init asus_hotk_get_info(void)
976 if (ACPI_FAILURE(status)) 972 if (ACPI_FAILURE(status))
977 printk(KERN_WARNING " Couldn't get the DSDT table header\n"); 973 printk(KERN_WARNING " Couldn't get the DSDT table header\n");
978 else 974 else
979 asus_info = (struct acpi_table_header *) dsdt.pointer; 975 asus_info = (struct acpi_table_header *)dsdt.pointer;
980 976
981 /* We have to write 0 on init this far for all ASUS models */ 977 /* We have to write 0 on init this far for all ASUS models */
982 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { 978 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
@@ -988,15 +984,17 @@ static int __init asus_hotk_get_info(void)
988 if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result)) 984 if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result))
989 printk(KERN_WARNING " Error calling BSTS\n"); 985 printk(KERN_WARNING " Error calling BSTS\n");
990 else if (bsts_result) 986 else if (bsts_result)
991 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n", bsts_result); 987 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n",
988 bsts_result);
992 989
993 /* Samsung P30 has a device with a valid _HID whose INIT does not 990 /* Samsung P30 has a device with a valid _HID whose INIT does not
994 * return anything. Catch this one and any similar here */ 991 * return anything. Catch this one and any similar here */
995 if (buffer.pointer == NULL) { 992 if (buffer.pointer == NULL) {
996 if (asus_info && /* Samsung P30 */ 993 if (asus_info && /* Samsung P30 */
997 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) { 994 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
998 hotk->model = P30; 995 hotk->model = P30;
999 printk(KERN_NOTICE " Samsung P30 detected, supported\n"); 996 printk(KERN_NOTICE
997 " Samsung P30 detected, supported\n");
1000 } else { 998 } else {
1001 hotk->model = M2E; 999 hotk->model = M2E;
1002 printk(KERN_WARNING " no string returned by INIT\n"); 1000 printk(KERN_WARNING " no string returned by INIT\n");
@@ -1006,10 +1004,11 @@ static int __init asus_hotk_get_info(void)
1006 hotk->methods = &model_conf[hotk->model]; 1004 hotk->methods = &model_conf[hotk->model];
1007 return AE_OK; 1005 return AE_OK;
1008 } 1006 }
1009 1007
1010 model = (union acpi_object *) buffer.pointer; 1008 model = (union acpi_object *)buffer.pointer;
1011 if (model->type == ACPI_TYPE_STRING) { 1009 if (model->type == ACPI_TYPE_STRING) {
1012 printk(KERN_NOTICE " %s model detected, ", model->string.pointer); 1010 printk(KERN_NOTICE " %s model detected, ",
1011 model->string.pointer);
1013 } 1012 }
1014 1013
1015 hotk->model = END_MODEL; 1014 hotk->model = END_MODEL;
@@ -1035,7 +1034,7 @@ static int __init asus_hotk_get_info(void)
1035 strncmp(model->string.pointer, "M6N", 3) == 0 || 1034 strncmp(model->string.pointer, "M6N", 3) == 0 ||
1036 strncmp(model->string.pointer, "S1N", 3) == 0 || 1035 strncmp(model->string.pointer, "S1N", 3) == 0 ||
1037 strncmp(model->string.pointer, "S5N", 3) == 0 || 1036 strncmp(model->string.pointer, "S5N", 3) == 0 ||
1038 strncmp(model->string.pointer, "W1N", 3) == 0) 1037 strncmp(model->string.pointer, "W1N", 3) == 0)
1039 hotk->model = xxN; 1038 hotk->model = xxN;
1040 else if (strncmp(model->string.pointer, "M1", 2) == 0) 1039 else if (strncmp(model->string.pointer, "M1", 2) == 0)
1041 hotk->model = M1A; 1040 hotk->model = M1A;
@@ -1069,21 +1068,21 @@ static int __init asus_hotk_get_info(void)
1069 1068
1070 /* Sort of per-model blacklist */ 1069 /* Sort of per-model blacklist */
1071 if (strncmp(model->string.pointer, "L2B", 3) == 0) 1070 if (strncmp(model->string.pointer, "L2B", 3) == 0)
1072 hotk->methods->lcd_status = NULL; 1071 hotk->methods->lcd_status = NULL;
1073 /* L2B is similar enough to L3C to use its settings, with this only 1072 /* L2B is similar enough to L3C to use its settings, with this only
1074 exception */ 1073 exception */
1075 else if (strncmp(model->string.pointer, "S5N", 3) == 0 || 1074 else if (strncmp(model->string.pointer, "S5N", 3) == 0 ||
1076 strncmp(model->string.pointer, "M5N", 3) == 0) 1075 strncmp(model->string.pointer, "M5N", 3) == 0)
1077 hotk->methods->mt_mled = NULL; 1076 hotk->methods->mt_mled = NULL;
1078 /* S5N and M5N have no MLED */ 1077 /* S5N and M5N have no MLED */
1079 else if (strncmp(model->string.pointer, "M2N", 3) == 0 || 1078 else if (strncmp(model->string.pointer, "M2N", 3) == 0 ||
1080 strncmp(model->string.pointer, "W1N", 3) == 0) 1079 strncmp(model->string.pointer, "W1N", 3) == 0)
1081 hotk->methods->mt_wled = "WLED"; 1080 hotk->methods->mt_wled = "WLED";
1082 /* M2N and W1N have a usable WLED */ 1081 /* M2N and W1N have a usable WLED */
1083 else if (asus_info) { 1082 else if (asus_info) {
1084 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0) 1083 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
1085 hotk->methods->mled_status = NULL; 1084 hotk->methods->mled_status = NULL;
1086 /* S1300A reports L84F, but L1400B too, account for that */ 1085 /* S1300A reports L84F, but L1400B too, account for that */
1087 } 1086 }
1088 1087
1089 acpi_os_free(model); 1088 acpi_os_free(model);
@@ -1091,7 +1090,6 @@ static int __init asus_hotk_get_info(void)
1091 return AE_OK; 1090 return AE_OK;
1092} 1091}
1093 1092
1094
1095static int __init asus_hotk_check(void) 1093static int __init asus_hotk_check(void)
1096{ 1094{
1097 int result = 0; 1095 int result = 0;
@@ -1110,7 +1108,6 @@ static int __init asus_hotk_check(void)
1110 return result; 1108 return result;
1111} 1109}
1112 1110
1113
1114static int __init asus_hotk_add(struct acpi_device *device) 1111static int __init asus_hotk_add(struct acpi_device *device)
1115{ 1112{
1116 acpi_status status = AE_OK; 1113 acpi_status status = AE_OK;
@@ -1123,7 +1120,7 @@ static int __init asus_hotk_add(struct acpi_device *device)
1123 ASUS_ACPI_VERSION); 1120 ASUS_ACPI_VERSION);
1124 1121
1125 hotk = 1122 hotk =
1126 (struct asus_hotk *) kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); 1123 (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
1127 if (!hotk) 1124 if (!hotk)
1128 return -ENOMEM; 1125 return -ENOMEM;
1129 memset(hotk, 0, sizeof(struct asus_hotk)); 1126 memset(hotk, 0, sizeof(struct asus_hotk));
@@ -1134,7 +1131,6 @@ static int __init asus_hotk_add(struct acpi_device *device)
1134 acpi_driver_data(device) = hotk; 1131 acpi_driver_data(device) = hotk;
1135 hotk->device = device; 1132 hotk->device = device;
1136 1133
1137
1138 result = asus_hotk_check(); 1134 result = asus_hotk_check();
1139 if (result) 1135 if (result)
1140 goto end; 1136 goto end;
@@ -1153,17 +1149,22 @@ static int __init asus_hotk_add(struct acpi_device *device)
1153 printk(KERN_ERR " Error installing notify handler\n"); 1149 printk(KERN_ERR " Error installing notify handler\n");
1154 1150
1155 /* For laptops without GPLV: init the hotk->brightness value */ 1151 /* For laptops without GPLV: init the hotk->brightness value */
1156 if ((!hotk->methods->brightness_get) && (!hotk->methods->brightness_status) && 1152 if ((!hotk->methods->brightness_get)
1157 (hotk->methods->brightness_up && hotk->methods->brightness_down)) { 1153 && (!hotk->methods->brightness_status)
1158 status = acpi_evaluate_object(NULL, hotk->methods->brightness_down, 1154 && (hotk->methods->brightness_up
1159 NULL, NULL); 1155 && hotk->methods->brightness_down)) {
1156 status =
1157 acpi_evaluate_object(NULL, hotk->methods->brightness_down,
1158 NULL, NULL);
1160 if (ACPI_FAILURE(status)) 1159 if (ACPI_FAILURE(status))
1161 printk(KERN_WARNING " Error changing brightness\n"); 1160 printk(KERN_WARNING " Error changing brightness\n");
1162 else { 1161 else {
1163 status = acpi_evaluate_object(NULL, hotk->methods->brightness_up, 1162 status =
1164 NULL, NULL); 1163 acpi_evaluate_object(NULL,
1164 hotk->methods->brightness_up,
1165 NULL, NULL);
1165 if (ACPI_FAILURE(status)) 1166 if (ACPI_FAILURE(status))
1166 printk(KERN_WARNING " Strange, error changing" 1167 printk(KERN_WARNING " Strange, error changing"
1167 " brightness\n"); 1168 " brightness\n");
1168 } 1169 }
1169 } 1170 }
@@ -1176,7 +1177,6 @@ static int __init asus_hotk_add(struct acpi_device *device)
1176 return result; 1177 return result;
1177} 1178}
1178 1179
1179
1180static int asus_hotk_remove(struct acpi_device *device, int type) 1180static int asus_hotk_remove(struct acpi_device *device, int type)
1181{ 1181{
1182 acpi_status status = 0; 1182 acpi_status status = 0;
@@ -1196,7 +1196,6 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
1196 return 0; 1196 return 0;
1197} 1197}
1198 1198
1199
1200static int __init asus_acpi_init(void) 1199static int __init asus_acpi_init(void)
1201{ 1200{
1202 int result; 1201 int result;
@@ -1204,9 +1203,9 @@ static int __init asus_acpi_init(void)
1204 if (acpi_disabled) 1203 if (acpi_disabled)
1205 return -ENODEV; 1204 return -ENODEV;
1206 1205
1207 if (!acpi_specific_hotkey_enabled){ 1206 if (!acpi_specific_hotkey_enabled) {
1208 printk(KERN_ERR "Using generic hotkey driver\n"); 1207 printk(KERN_ERR "Using generic hotkey driver\n");
1209 return -ENODEV; 1208 return -ENODEV;
1210 } 1209 }
1211 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); 1210 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
1212 if (!asus_proc_dir) { 1211 if (!asus_proc_dir) {
@@ -1225,7 +1224,6 @@ static int __init asus_acpi_init(void)
1225 return 0; 1224 return 0;
1226} 1225}
1227 1226
1228
1229static void __exit asus_acpi_exit(void) 1227static void __exit asus_acpi_exit(void)
1230{ 1228{
1231 acpi_bus_unregister_driver(&asus_hotk_driver); 1229 acpi_bus_unregister_driver(&asus_hotk_driver);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c55feca9b7d5..702e857e98c5 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -34,7 +34,6 @@
34#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
36 36
37
38#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF 37#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
39 38
40#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS" 39#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS"
@@ -53,87 +52,85 @@
53#define ACPI_BATTERY_UNITS_WATTS "mW" 52#define ACPI_BATTERY_UNITS_WATTS "mW"
54#define ACPI_BATTERY_UNITS_AMPS "mA" 53#define ACPI_BATTERY_UNITS_AMPS "mA"
55 54
56
57#define _COMPONENT ACPI_BATTERY_COMPONENT 55#define _COMPONENT ACPI_BATTERY_COMPONENT
58ACPI_MODULE_NAME ("acpi_battery") 56ACPI_MODULE_NAME("acpi_battery")
59 57
60MODULE_AUTHOR("Paul Diefenbaugh"); 58 MODULE_AUTHOR("Paul Diefenbaugh");
61MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME); 59MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
62MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
63 61
64static int acpi_battery_add (struct acpi_device *device); 62static int acpi_battery_add(struct acpi_device *device);
65static int acpi_battery_remove (struct acpi_device *device, int type); 63static int acpi_battery_remove(struct acpi_device *device, int type);
66 64
67static struct acpi_driver acpi_battery_driver = { 65static struct acpi_driver acpi_battery_driver = {
68 .name = ACPI_BATTERY_DRIVER_NAME, 66 .name = ACPI_BATTERY_DRIVER_NAME,
69 .class = ACPI_BATTERY_CLASS, 67 .class = ACPI_BATTERY_CLASS,
70 .ids = ACPI_BATTERY_HID, 68 .ids = ACPI_BATTERY_HID,
71 .ops = { 69 .ops = {
72 .add = acpi_battery_add, 70 .add = acpi_battery_add,
73 .remove = acpi_battery_remove, 71 .remove = acpi_battery_remove,
74 }, 72 },
75}; 73};
76 74
77struct acpi_battery_status { 75struct acpi_battery_status {
78 acpi_integer state; 76 acpi_integer state;
79 acpi_integer present_rate; 77 acpi_integer present_rate;
80 acpi_integer remaining_capacity; 78 acpi_integer remaining_capacity;
81 acpi_integer present_voltage; 79 acpi_integer present_voltage;
82}; 80};
83 81
84struct acpi_battery_info { 82struct acpi_battery_info {
85 acpi_integer power_unit; 83 acpi_integer power_unit;
86 acpi_integer design_capacity; 84 acpi_integer design_capacity;
87 acpi_integer last_full_capacity; 85 acpi_integer last_full_capacity;
88 acpi_integer battery_technology; 86 acpi_integer battery_technology;
89 acpi_integer design_voltage; 87 acpi_integer design_voltage;
90 acpi_integer design_capacity_warning; 88 acpi_integer design_capacity_warning;
91 acpi_integer design_capacity_low; 89 acpi_integer design_capacity_low;
92 acpi_integer battery_capacity_granularity_1; 90 acpi_integer battery_capacity_granularity_1;
93 acpi_integer battery_capacity_granularity_2; 91 acpi_integer battery_capacity_granularity_2;
94 acpi_string model_number; 92 acpi_string model_number;
95 acpi_string serial_number; 93 acpi_string serial_number;
96 acpi_string battery_type; 94 acpi_string battery_type;
97 acpi_string oem_info; 95 acpi_string oem_info;
98}; 96};
99 97
100struct acpi_battery_flags { 98struct acpi_battery_flags {
101 u8 present:1; /* Bay occupied? */ 99 u8 present:1; /* Bay occupied? */
102 u8 power_unit:1; /* 0=watts, 1=apms */ 100 u8 power_unit:1; /* 0=watts, 1=apms */
103 u8 alarm:1; /* _BTP present? */ 101 u8 alarm:1; /* _BTP present? */
104 u8 reserved:5; 102 u8 reserved:5;
105}; 103};
106 104
107struct acpi_battery_trips { 105struct acpi_battery_trips {
108 unsigned long warning; 106 unsigned long warning;
109 unsigned long low; 107 unsigned long low;
110}; 108};
111 109
112struct acpi_battery { 110struct acpi_battery {
113 acpi_handle handle; 111 acpi_handle handle;
114 struct acpi_battery_flags flags; 112 struct acpi_battery_flags flags;
115 struct acpi_battery_trips trips; 113 struct acpi_battery_trips trips;
116 unsigned long alarm; 114 unsigned long alarm;
117 struct acpi_battery_info *info; 115 struct acpi_battery_info *info;
118}; 116};
119 117
120
121/* -------------------------------------------------------------------------- 118/* --------------------------------------------------------------------------
122 Battery Management 119 Battery Management
123 -------------------------------------------------------------------------- */ 120 -------------------------------------------------------------------------- */
124 121
125static int 122static int
126acpi_battery_get_info ( 123acpi_battery_get_info(struct acpi_battery *battery,
127 struct acpi_battery *battery, 124 struct acpi_battery_info **bif)
128 struct acpi_battery_info **bif)
129{ 125{
130 int result = 0; 126 int result = 0;
131 acpi_status status = 0; 127 acpi_status status = 0;
132 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 128 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
133 struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BIF), 129 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
134 ACPI_BATTERY_FORMAT_BIF}; 130 ACPI_BATTERY_FORMAT_BIF
135 struct acpi_buffer data = {0, NULL}; 131 };
136 union acpi_object *package = NULL; 132 struct acpi_buffer data = { 0, NULL };
133 union acpi_object *package = NULL;
137 134
138 ACPI_FUNCTION_TRACE("acpi_battery_get_info"); 135 ACPI_FUNCTION_TRACE("acpi_battery_get_info");
139 136
@@ -148,7 +145,7 @@ acpi_battery_get_info (
148 return_VALUE(-ENODEV); 145 return_VALUE(-ENODEV);
149 } 146 }
150 147
151 package = (union acpi_object *) buffer.pointer; 148 package = (union acpi_object *)buffer.pointer;
152 149
153 /* Extract Package Data */ 150 /* Extract Package Data */
154 151
@@ -174,27 +171,27 @@ acpi_battery_get_info (
174 goto end; 171 goto end;
175 } 172 }
176 173
177end: 174 end:
178 acpi_os_free(buffer.pointer); 175 acpi_os_free(buffer.pointer);
179 176
180 if (!result) 177 if (!result)
181 (*bif) = (struct acpi_battery_info *) data.pointer; 178 (*bif) = (struct acpi_battery_info *)data.pointer;
182 179
183 return_VALUE(result); 180 return_VALUE(result);
184} 181}
185 182
186static int 183static int
187acpi_battery_get_status ( 184acpi_battery_get_status(struct acpi_battery *battery,
188 struct acpi_battery *battery, 185 struct acpi_battery_status **bst)
189 struct acpi_battery_status **bst)
190{ 186{
191 int result = 0; 187 int result = 0;
192 acpi_status status = 0; 188 acpi_status status = 0;
193 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 189 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
194 struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BST), 190 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
195 ACPI_BATTERY_FORMAT_BST}; 191 ACPI_BATTERY_FORMAT_BST
196 struct acpi_buffer data = {0, NULL}; 192 };
197 union acpi_object *package = NULL; 193 struct acpi_buffer data = { 0, NULL };
194 union acpi_object *package = NULL;
198 195
199 ACPI_FUNCTION_TRACE("acpi_battery_get_status"); 196 ACPI_FUNCTION_TRACE("acpi_battery_get_status");
200 197
@@ -209,7 +206,7 @@ acpi_battery_get_status (
209 return_VALUE(-ENODEV); 206 return_VALUE(-ENODEV);
210 } 207 }
211 208
212 package = (union acpi_object *) buffer.pointer; 209 package = (union acpi_object *)buffer.pointer;
213 210
214 /* Extract Package Data */ 211 /* Extract Package Data */
215 212
@@ -235,24 +232,21 @@ acpi_battery_get_status (
235 goto end; 232 goto end;
236 } 233 }
237 234
238end: 235 end:
239 acpi_os_free(buffer.pointer); 236 acpi_os_free(buffer.pointer);
240 237
241 if (!result) 238 if (!result)
242 (*bst) = (struct acpi_battery_status *) data.pointer; 239 (*bst) = (struct acpi_battery_status *)data.pointer;
243 240
244 return_VALUE(result); 241 return_VALUE(result);
245} 242}
246 243
247
248static int 244static int
249acpi_battery_set_alarm ( 245acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
250 struct acpi_battery *battery,
251 unsigned long alarm)
252{ 246{
253 acpi_status status = 0; 247 acpi_status status = 0;
254 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 248 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
255 struct acpi_object_list arg_list = {1, &arg0}; 249 struct acpi_object_list arg_list = { 1, &arg0 };
256 250
257 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); 251 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
258 252
@@ -275,19 +269,16 @@ acpi_battery_set_alarm (
275 return_VALUE(0); 269 return_VALUE(0);
276} 270}
277 271
278 272static int acpi_battery_check(struct acpi_battery *battery)
279static int
280acpi_battery_check (
281 struct acpi_battery *battery)
282{ 273{
283 int result = 0; 274 int result = 0;
284 acpi_status status = AE_OK; 275 acpi_status status = AE_OK;
285 acpi_handle handle = NULL; 276 acpi_handle handle = NULL;
286 struct acpi_device *device = NULL; 277 struct acpi_device *device = NULL;
287 struct acpi_battery_info *bif = NULL; 278 struct acpi_battery_info *bif = NULL;
288 279
289 ACPI_FUNCTION_TRACE("acpi_battery_check"); 280 ACPI_FUNCTION_TRACE("acpi_battery_check");
290 281
291 if (!battery) 282 if (!battery)
292 return_VALUE(-EINVAL); 283 return_VALUE(-EINVAL);
293 284
@@ -336,18 +327,17 @@ acpi_battery_check (
336 return_VALUE(result); 327 return_VALUE(result);
337} 328}
338 329
339
340/* -------------------------------------------------------------------------- 330/* --------------------------------------------------------------------------
341 FS Interface (/proc) 331 FS Interface (/proc)
342 -------------------------------------------------------------------------- */ 332 -------------------------------------------------------------------------- */
343 333
344static struct proc_dir_entry *acpi_battery_dir; 334static struct proc_dir_entry *acpi_battery_dir;
345static int acpi_battery_read_info(struct seq_file *seq, void *offset) 335static int acpi_battery_read_info(struct seq_file *seq, void *offset)
346{ 336{
347 int result = 0; 337 int result = 0;
348 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 338 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
349 struct acpi_battery_info *bif = NULL; 339 struct acpi_battery_info *bif = NULL;
350 char *units = "?"; 340 char *units = "?";
351 341
352 ACPI_FUNCTION_TRACE("acpi_battery_read_info"); 342 ACPI_FUNCTION_TRACE("acpi_battery_read_info");
353 343
@@ -369,19 +359,21 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
369 goto end; 359 goto end;
370 } 360 }
371 361
372 units = bif->power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 362 units =
373 363 bif->
364 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
365
374 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 366 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
375 seq_printf(seq, "design capacity: unknown\n"); 367 seq_printf(seq, "design capacity: unknown\n");
376 else 368 else
377 seq_printf(seq, "design capacity: %d %sh\n", 369 seq_printf(seq, "design capacity: %d %sh\n",
378 (u32) bif->design_capacity, units); 370 (u32) bif->design_capacity, units);
379 371
380 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 372 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
381 seq_printf(seq, "last full capacity: unknown\n"); 373 seq_printf(seq, "last full capacity: unknown\n");
382 else 374 else
383 seq_printf(seq, "last full capacity: %d %sh\n", 375 seq_printf(seq, "last full capacity: %d %sh\n",
384 (u32) bif->last_full_capacity, units); 376 (u32) bif->last_full_capacity, units);
385 377
386 switch ((u32) bif->battery_technology) { 378 switch ((u32) bif->battery_technology) {
387 case 0: 379 case 0:
@@ -399,26 +391,22 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
399 seq_printf(seq, "design voltage: unknown\n"); 391 seq_printf(seq, "design voltage: unknown\n");
400 else 392 else
401 seq_printf(seq, "design voltage: %d mV\n", 393 seq_printf(seq, "design voltage: %d mV\n",
402 (u32) bif->design_voltage); 394 (u32) bif->design_voltage);
403 395
404 seq_printf(seq, "design capacity warning: %d %sh\n", 396 seq_printf(seq, "design capacity warning: %d %sh\n",
405 (u32) bif->design_capacity_warning, units); 397 (u32) bif->design_capacity_warning, units);
406 seq_printf(seq, "design capacity low: %d %sh\n", 398 seq_printf(seq, "design capacity low: %d %sh\n",
407 (u32) bif->design_capacity_low, units); 399 (u32) bif->design_capacity_low, units);
408 seq_printf(seq, "capacity granularity 1: %d %sh\n", 400 seq_printf(seq, "capacity granularity 1: %d %sh\n",
409 (u32) bif->battery_capacity_granularity_1, units); 401 (u32) bif->battery_capacity_granularity_1, units);
410 seq_printf(seq, "capacity granularity 2: %d %sh\n", 402 seq_printf(seq, "capacity granularity 2: %d %sh\n",
411 (u32) bif->battery_capacity_granularity_2, units); 403 (u32) bif->battery_capacity_granularity_2, units);
412 seq_printf(seq, "model number: %s\n", 404 seq_printf(seq, "model number: %s\n", bif->model_number);
413 bif->model_number); 405 seq_printf(seq, "serial number: %s\n", bif->serial_number);
414 seq_printf(seq, "serial number: %s\n", 406 seq_printf(seq, "battery type: %s\n", bif->battery_type);
415 bif->serial_number); 407 seq_printf(seq, "OEM info: %s\n", bif->oem_info);
416 seq_printf(seq, "battery type: %s\n", 408
417 bif->battery_type); 409 end:
418 seq_printf(seq, "OEM info: %s\n",
419 bif->oem_info);
420
421end:
422 kfree(bif); 410 kfree(bif);
423 411
424 return_VALUE(0); 412 return_VALUE(0);
@@ -429,14 +417,12 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
429 return single_open(file, acpi_battery_read_info, PDE(inode)->data); 417 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
430} 418}
431 419
432 420static int acpi_battery_read_state(struct seq_file *seq, void *offset)
433static int
434acpi_battery_read_state (struct seq_file *seq, void *offset)
435{ 421{
436 int result = 0; 422 int result = 0;
437 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 423 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
438 struct acpi_battery_status *bst = NULL; 424 struct acpi_battery_status *bst = NULL;
439 char *units = "?"; 425 char *units = "?";
440 426
441 ACPI_FUNCTION_TRACE("acpi_battery_read_state"); 427 ACPI_FUNCTION_TRACE("acpi_battery_read_state");
442 428
@@ -452,7 +438,9 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
452 438
453 /* Battery Units */ 439 /* Battery Units */
454 440
455 units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 441 units =
442 battery->flags.
443 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
456 444
457 /* Battery Status (_BST) */ 445 /* Battery Status (_BST) */
458 446
@@ -467,12 +455,12 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
467 else 455 else
468 seq_printf(seq, "capacity state: critical\n"); 456 seq_printf(seq, "capacity state: critical\n");
469 457
470 if ((bst->state & 0x01) && (bst->state & 0x02)){ 458 if ((bst->state & 0x01) && (bst->state & 0x02)) {
471 seq_printf(seq, "charging state: charging/discharging\n"); 459 seq_printf(seq,
472 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 460 "charging state: charging/discharging\n");
473 "Battery Charging and Discharging?\n")); 461 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
474 } 462 "Battery Charging and Discharging?\n"));
475 else if (bst->state & 0x01) 463 } else if (bst->state & 0x01)
476 seq_printf(seq, "charging state: discharging\n"); 464 seq_printf(seq, "charging state: discharging\n");
477 else if (bst->state & 0x02) 465 else if (bst->state & 0x02)
478 seq_printf(seq, "charging state: charging\n"); 466 seq_printf(seq, "charging state: charging\n");
@@ -484,21 +472,21 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
484 seq_printf(seq, "present rate: unknown\n"); 472 seq_printf(seq, "present rate: unknown\n");
485 else 473 else
486 seq_printf(seq, "present rate: %d %s\n", 474 seq_printf(seq, "present rate: %d %s\n",
487 (u32) bst->present_rate, units); 475 (u32) bst->present_rate, units);
488 476
489 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 477 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
490 seq_printf(seq, "remaining capacity: unknown\n"); 478 seq_printf(seq, "remaining capacity: unknown\n");
491 else 479 else
492 seq_printf(seq, "remaining capacity: %d %sh\n", 480 seq_printf(seq, "remaining capacity: %d %sh\n",
493 (u32) bst->remaining_capacity, units); 481 (u32) bst->remaining_capacity, units);
494 482
495 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN) 483 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
496 seq_printf(seq, "present voltage: unknown\n"); 484 seq_printf(seq, "present voltage: unknown\n");
497 else 485 else
498 seq_printf(seq, "present voltage: %d mV\n", 486 seq_printf(seq, "present voltage: %d mV\n",
499 (u32) bst->present_voltage); 487 (u32) bst->present_voltage);
500 488
501end: 489 end:
502 kfree(bst); 490 kfree(bst);
503 491
504 return_VALUE(0); 492 return_VALUE(0);
@@ -509,12 +497,10 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
509 return single_open(file, acpi_battery_read_state, PDE(inode)->data); 497 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
510} 498}
511 499
512 500static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
513static int
514acpi_battery_read_alarm (struct seq_file *seq, void *offset)
515{ 501{
516 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 502 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
517 char *units = "?"; 503 char *units = "?";
518 504
519 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); 505 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
520 506
@@ -527,8 +513,10 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
527 } 513 }
528 514
529 /* Battery Units */ 515 /* Battery Units */
530 516
531 units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 517 units =
518 battery->flags.
519 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
532 520
533 /* Battery Alarm */ 521 /* Battery Alarm */
534 522
@@ -538,22 +526,19 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
538 else 526 else
539 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); 527 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
540 528
541end: 529 end:
542 return_VALUE(0); 530 return_VALUE(0);
543} 531}
544 532
545
546static ssize_t 533static ssize_t
547acpi_battery_write_alarm ( 534acpi_battery_write_alarm(struct file *file,
548 struct file *file, 535 const char __user * buffer,
549 const char __user *buffer, 536 size_t count, loff_t * ppos)
550 size_t count,
551 loff_t *ppos)
552{ 537{
553 int result = 0; 538 int result = 0;
554 char alarm_string[12] = {'\0'}; 539 char alarm_string[12] = { '\0' };
555 struct seq_file *m = (struct seq_file *)file->private_data; 540 struct seq_file *m = (struct seq_file *)file->private_data;
556 struct acpi_battery *battery = (struct acpi_battery *)m->private; 541 struct acpi_battery *battery = (struct acpi_battery *)m->private;
557 542
558 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); 543 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
559 544
@@ -565,11 +550,11 @@ acpi_battery_write_alarm (
565 550
566 if (copy_from_user(alarm_string, buffer, count)) 551 if (copy_from_user(alarm_string, buffer, count))
567 return_VALUE(-EFAULT); 552 return_VALUE(-EFAULT);
568 553
569 alarm_string[count] = '\0'; 554 alarm_string[count] = '\0';
570 555
571 result = acpi_battery_set_alarm(battery, 556 result = acpi_battery_set_alarm(battery,
572 simple_strtoul(alarm_string, NULL, 0)); 557 simple_strtoul(alarm_string, NULL, 0));
573 if (result) 558 if (result)
574 return_VALUE(result); 559 return_VALUE(result);
575 560
@@ -582,41 +567,39 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
582} 567}
583 568
584static struct file_operations acpi_battery_info_ops = { 569static struct file_operations acpi_battery_info_ops = {
585 .open = acpi_battery_info_open_fs, 570 .open = acpi_battery_info_open_fs,
586 .read = seq_read, 571 .read = seq_read,
587 .llseek = seq_lseek, 572 .llseek = seq_lseek,
588 .release = single_release, 573 .release = single_release,
589 .owner = THIS_MODULE, 574 .owner = THIS_MODULE,
590}; 575};
591 576
592static struct file_operations acpi_battery_state_ops = { 577static struct file_operations acpi_battery_state_ops = {
593 .open = acpi_battery_state_open_fs, 578 .open = acpi_battery_state_open_fs,
594 .read = seq_read, 579 .read = seq_read,
595 .llseek = seq_lseek, 580 .llseek = seq_lseek,
596 .release = single_release, 581 .release = single_release,
597 .owner = THIS_MODULE, 582 .owner = THIS_MODULE,
598}; 583};
599 584
600static struct file_operations acpi_battery_alarm_ops = { 585static struct file_operations acpi_battery_alarm_ops = {
601 .open = acpi_battery_alarm_open_fs, 586 .open = acpi_battery_alarm_open_fs,
602 .read = seq_read, 587 .read = seq_read,
603 .write = acpi_battery_write_alarm, 588 .write = acpi_battery_write_alarm,
604 .llseek = seq_lseek, 589 .llseek = seq_lseek,
605 .release = single_release, 590 .release = single_release,
606 .owner = THIS_MODULE, 591 .owner = THIS_MODULE,
607}; 592};
608 593
609static int 594static int acpi_battery_add_fs(struct acpi_device *device)
610acpi_battery_add_fs (
611 struct acpi_device *device)
612{ 595{
613 struct proc_dir_entry *entry = NULL; 596 struct proc_dir_entry *entry = NULL;
614 597
615 ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); 598 ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
616 599
617 if (!acpi_device_dir(device)) { 600 if (!acpi_device_dir(device)) {
618 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 601 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
619 acpi_battery_dir); 602 acpi_battery_dir);
620 if (!acpi_device_dir(device)) 603 if (!acpi_device_dir(device))
621 return_VALUE(-ENODEV); 604 return_VALUE(-ENODEV);
622 acpi_device_dir(device)->owner = THIS_MODULE; 605 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -624,24 +607,24 @@ acpi_battery_add_fs (
624 607
625 /* 'info' [R] */ 608 /* 'info' [R] */
626 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, 609 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
627 S_IRUGO, acpi_device_dir(device)); 610 S_IRUGO, acpi_device_dir(device));
628 if (!entry) 611 if (!entry)
629 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 612 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
630 "Unable to create '%s' fs entry\n", 613 "Unable to create '%s' fs entry\n",
631 ACPI_BATTERY_FILE_INFO)); 614 ACPI_BATTERY_FILE_INFO));
632 else { 615 else {
633 entry->proc_fops = &acpi_battery_info_ops; 616 entry->proc_fops = &acpi_battery_info_ops;
634 entry->data = acpi_driver_data(device); 617 entry->data = acpi_driver_data(device);
635 entry->owner = THIS_MODULE; 618 entry->owner = THIS_MODULE;
636 } 619 }
637 620
638 /* 'status' [R] */ 621 /* 'status' [R] */
639 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, 622 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
640 S_IRUGO, acpi_device_dir(device)); 623 S_IRUGO, acpi_device_dir(device));
641 if (!entry) 624 if (!entry)
642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "Unable to create '%s' fs entry\n", 626 "Unable to create '%s' fs entry\n",
644 ACPI_BATTERY_FILE_STATUS)); 627 ACPI_BATTERY_FILE_STATUS));
645 else { 628 else {
646 entry->proc_fops = &acpi_battery_state_ops; 629 entry->proc_fops = &acpi_battery_state_ops;
647 entry->data = acpi_driver_data(device); 630 entry->data = acpi_driver_data(device);
@@ -650,11 +633,12 @@ acpi_battery_add_fs (
650 633
651 /* 'alarm' [R/W] */ 634 /* 'alarm' [R/W] */
652 entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM, 635 entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
653 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 636 S_IFREG | S_IRUGO | S_IWUSR,
637 acpi_device_dir(device));
654 if (!entry) 638 if (!entry)
655 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
656 "Unable to create '%s' fs entry\n", 640 "Unable to create '%s' fs entry\n",
657 ACPI_BATTERY_FILE_ALARM)); 641 ACPI_BATTERY_FILE_ALARM));
658 else { 642 else {
659 entry->proc_fops = &acpi_battery_alarm_ops; 643 entry->proc_fops = &acpi_battery_alarm_ops;
660 entry->data = acpi_driver_data(device); 644 entry->data = acpi_driver_data(device);
@@ -664,10 +648,7 @@ acpi_battery_add_fs (
664 return_VALUE(0); 648 return_VALUE(0);
665} 649}
666 650
667 651static int acpi_battery_remove_fs(struct acpi_device *device)
668static int
669acpi_battery_remove_fs (
670 struct acpi_device *device)
671{ 652{
672 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); 653 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
673 654
@@ -686,19 +667,14 @@ acpi_battery_remove_fs (
686 return_VALUE(0); 667 return_VALUE(0);
687} 668}
688 669
689
690/* -------------------------------------------------------------------------- 670/* --------------------------------------------------------------------------
691 Driver Interface 671 Driver Interface
692 -------------------------------------------------------------------------- */ 672 -------------------------------------------------------------------------- */
693 673
694static void 674static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
695acpi_battery_notify (
696 acpi_handle handle,
697 u32 event,
698 void *data)
699{ 675{
700 struct acpi_battery *battery = (struct acpi_battery *) data; 676 struct acpi_battery *battery = (struct acpi_battery *)data;
701 struct acpi_device *device = NULL; 677 struct acpi_device *device = NULL;
702 678
703 ACPI_FUNCTION_TRACE("acpi_battery_notify"); 679 ACPI_FUNCTION_TRACE("acpi_battery_notify");
704 680
@@ -716,24 +692,21 @@ acpi_battery_notify (
716 break; 692 break;
717 default: 693 default:
718 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 694 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
719 "Unsupported event [0x%x]\n", event)); 695 "Unsupported event [0x%x]\n", event));
720 break; 696 break;
721 } 697 }
722 698
723 return_VOID; 699 return_VOID;
724} 700}
725 701
726 702static int acpi_battery_add(struct acpi_device *device)
727static int
728acpi_battery_add (
729 struct acpi_device *device)
730{ 703{
731 int result = 0; 704 int result = 0;
732 acpi_status status = 0; 705 acpi_status status = 0;
733 struct acpi_battery *battery = NULL; 706 struct acpi_battery *battery = NULL;
734 707
735 ACPI_FUNCTION_TRACE("acpi_battery_add"); 708 ACPI_FUNCTION_TRACE("acpi_battery_add");
736 709
737 if (!device) 710 if (!device)
738 return_VALUE(-EINVAL); 711 return_VALUE(-EINVAL);
739 712
@@ -756,19 +729,20 @@ acpi_battery_add (
756 goto end; 729 goto end;
757 730
758 status = acpi_install_notify_handler(battery->handle, 731 status = acpi_install_notify_handler(battery->handle,
759 ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); 732 ACPI_DEVICE_NOTIFY,
733 acpi_battery_notify, battery);
760 if (ACPI_FAILURE(status)) { 734 if (ACPI_FAILURE(status)) {
761 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
762 "Error installing notify handler\n")); 736 "Error installing notify handler\n"));
763 result = -ENODEV; 737 result = -ENODEV;
764 goto end; 738 goto end;
765 } 739 }
766 740
767 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", 741 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
768 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), 742 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
769 device->status.battery_present?"present":"absent"); 743 device->status.battery_present ? "present" : "absent");
770 744
771end: 745 end:
772 if (result) { 746 if (result) {
773 acpi_battery_remove_fs(device); 747 acpi_battery_remove_fs(device);
774 kfree(battery); 748 kfree(battery);
@@ -777,27 +751,24 @@ end:
777 return_VALUE(result); 751 return_VALUE(result);
778} 752}
779 753
780 754static int acpi_battery_remove(struct acpi_device *device, int type)
781static int
782acpi_battery_remove (
783 struct acpi_device *device,
784 int type)
785{ 755{
786 acpi_status status = 0; 756 acpi_status status = 0;
787 struct acpi_battery *battery = NULL; 757 struct acpi_battery *battery = NULL;
788 758
789 ACPI_FUNCTION_TRACE("acpi_battery_remove"); 759 ACPI_FUNCTION_TRACE("acpi_battery_remove");
790 760
791 if (!device || !acpi_driver_data(device)) 761 if (!device || !acpi_driver_data(device))
792 return_VALUE(-EINVAL); 762 return_VALUE(-EINVAL);
793 763
794 battery = (struct acpi_battery *) acpi_driver_data(device); 764 battery = (struct acpi_battery *)acpi_driver_data(device);
795 765
796 status = acpi_remove_notify_handler(battery->handle, 766 status = acpi_remove_notify_handler(battery->handle,
797 ACPI_DEVICE_NOTIFY, acpi_battery_notify); 767 ACPI_DEVICE_NOTIFY,
768 acpi_battery_notify);
798 if (ACPI_FAILURE(status)) 769 if (ACPI_FAILURE(status))
799 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
800 "Error removing notify handler\n")); 771 "Error removing notify handler\n"));
801 772
802 acpi_battery_remove_fs(device); 773 acpi_battery_remove_fs(device);
803 774
@@ -806,11 +777,9 @@ acpi_battery_remove (
806 return_VALUE(0); 777 return_VALUE(0);
807} 778}
808 779
809 780static int __init acpi_battery_init(void)
810static int __init
811acpi_battery_init (void)
812{ 781{
813 int result = 0; 782 int result = 0;
814 783
815 ACPI_FUNCTION_TRACE("acpi_battery_init"); 784 ACPI_FUNCTION_TRACE("acpi_battery_init");
816 785
@@ -828,9 +797,7 @@ acpi_battery_init (void)
828 return_VALUE(0); 797 return_VALUE(0);
829} 798}
830 799
831 800static void __exit acpi_battery_exit(void)
832static void __exit
833acpi_battery_exit (void)
834{ 801{
835 ACPI_FUNCTION_TRACE("acpi_battery_exit"); 802 ACPI_FUNCTION_TRACE("acpi_battery_exit");
836 803
@@ -841,6 +808,5 @@ acpi_battery_exit (void)
841 return_VOID; 808 return_VOID;
842} 809}
843 810
844
845module_init(acpi_battery_init); 811module_init(acpi_battery_init);
846module_exit(acpi_battery_exit); 812module_exit(acpi_battery_exit);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 4c010e7f11b8..9824f679a910 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -26,7 +26,6 @@
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 */ 27 */
28 28
29
30#include <linux/kernel.h> 29#include <linux/kernel.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/init.h> 31#include <linux/init.h>
@@ -34,49 +33,49 @@
34#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
35#include <linux/dmi.h> 34#include <linux/dmi.h>
36 35
37enum acpi_blacklist_predicates 36enum acpi_blacklist_predicates {
38{ 37 all_versions,
39 all_versions, 38 less_than_or_equal,
40 less_than_or_equal, 39 equal,
41 equal, 40 greater_than_or_equal,
42 greater_than_or_equal,
43}; 41};
44 42
45struct acpi_blacklist_item 43struct acpi_blacklist_item {
46{ 44 char oem_id[7];
47 char oem_id[7]; 45 char oem_table_id[9];
48 char oem_table_id[9]; 46 u32 oem_revision;
49 u32 oem_revision; 47 acpi_table_type table;
50 acpi_table_type table; 48 enum acpi_blacklist_predicates oem_revision_predicate;
51 enum acpi_blacklist_predicates oem_revision_predicate; 49 char *reason;
52 char *reason; 50 u32 is_critical_error;
53 u32 is_critical_error;
54}; 51};
55 52
56/* 53/*
57 * POLICY: If *anything* doesn't work, put it on the blacklist. 54 * POLICY: If *anything* doesn't work, put it on the blacklist.
58 * If they are critical errors, mark it critical, and abort driver load. 55 * If they are critical errors, mark it critical, and abort driver load.
59 */ 56 */
60static struct acpi_blacklist_item acpi_blacklist[] __initdata = 57static struct acpi_blacklist_item acpi_blacklist[] __initdata = {
61{
62 /* Compaq Presario 1700 */ 58 /* Compaq Presario 1700 */
63 {"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal, "Multiple problems", 1}, 59 {"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal,
60 "Multiple problems", 1},
64 /* Sony FX120, FX140, FX150? */ 61 /* Sony FX120, FX140, FX150? */
65 {"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal, "ACPI driver problem", 1}, 62 {"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal,
63 "ACPI driver problem", 1},
66 /* Compaq Presario 800, Insyde BIOS */ 64 /* Compaq Presario 800, Insyde BIOS */
67 {"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal, "Does not use _REG to protect EC OpRegions", 1}, 65 {"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal,
66 "Does not use _REG to protect EC OpRegions", 1},
68 /* IBM 600E - _ADR should return 7, but it returns 1 */ 67 /* IBM 600E - _ADR should return 7, but it returns 1 */
69 {"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal, "Incorrect _ADR", 1}, 68 {"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal,
70 {"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions, "Bogus PCI routing", 1}, 69 "Incorrect _ADR", 1},
70 {"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions,
71 "Bogus PCI routing", 1},
71 72
72 {""} 73 {""}
73}; 74};
74 75
75
76#if CONFIG_ACPI_BLACKLIST_YEAR 76#if CONFIG_ACPI_BLACKLIST_YEAR
77 77
78static int __init 78static int __init blacklist_by_year(void)
79blacklist_by_year(void)
80{ 79{
81 int year; 80 int year;
82 char *s = dmi_get_system_info(DMI_BIOS_DATE); 81 char *s = dmi_get_system_info(DMI_BIOS_DATE);
@@ -92,36 +91,38 @@ blacklist_by_year(void)
92 91
93 s += 1; 92 s += 1;
94 93
95 year = simple_strtoul(s,NULL,0); 94 year = simple_strtoul(s, NULL, 0);
96 95
97 if (year < 100) { /* 2-digit year */ 96 if (year < 100) { /* 2-digit year */
98 year += 1900; 97 year += 1900;
99 if (year < 1996) /* no dates < spec 1.0 */ 98 if (year < 1996) /* no dates < spec 1.0 */
100 year += 100; 99 year += 100;
101 } 100 }
102 101
103 if (year < CONFIG_ACPI_BLACKLIST_YEAR) { 102 if (year < CONFIG_ACPI_BLACKLIST_YEAR) {
104 printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), " 103 printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), "
105 "acpi=force is required to enable ACPI\n", 104 "acpi=force is required to enable ACPI\n",
106 year, CONFIG_ACPI_BLACKLIST_YEAR); 105 year, CONFIG_ACPI_BLACKLIST_YEAR);
107 return 1; 106 return 1;
108 } 107 }
109 return 0; 108 return 0;
110} 109}
111#else 110#else
112static inline int blacklist_by_year(void) { return 0; } 111static inline int blacklist_by_year(void)
112{
113 return 0;
114}
113#endif 115#endif
114 116
115int __init 117int __init acpi_blacklisted(void)
116acpi_blacklisted(void)
117{ 118{
118 int i = 0; 119 int i = 0;
119 int blacklisted = 0; 120 int blacklisted = 0;
120 struct acpi_table_header *table_header; 121 struct acpi_table_header *table_header;
121 122
122 while (acpi_blacklist[i].oem_id[0] != '\0') 123 while (acpi_blacklist[i].oem_id[0] != '\0') {
123 { 124 if (acpi_get_table_header_early
124 if (acpi_get_table_header_early(acpi_blacklist[i].table, &table_header)) { 125 (acpi_blacklist[i].table, &table_header)) {
125 i++; 126 i++;
126 continue; 127 continue;
127 } 128 }
@@ -131,33 +132,43 @@ acpi_blacklisted(void)
131 continue; 132 continue;
132 } 133 }
133 134
134 if (strncmp(acpi_blacklist[i].oem_table_id, table_header->oem_table_id, 8)) { 135 if (strncmp
136 (acpi_blacklist[i].oem_table_id, table_header->oem_table_id,
137 8)) {
135 i++; 138 i++;
136 continue; 139 continue;
137 } 140 }
138 141
139 if ((acpi_blacklist[i].oem_revision_predicate == all_versions) 142 if ((acpi_blacklist[i].oem_revision_predicate == all_versions)
140 || (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal 143 || (acpi_blacklist[i].oem_revision_predicate ==
141 && table_header->oem_revision <= acpi_blacklist[i].oem_revision) 144 less_than_or_equal
142 || (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal 145 && table_header->oem_revision <=
143 && table_header->oem_revision >= acpi_blacklist[i].oem_revision) 146 acpi_blacklist[i].oem_revision)
147 || (acpi_blacklist[i].oem_revision_predicate ==
148 greater_than_or_equal
149 && table_header->oem_revision >=
150 acpi_blacklist[i].oem_revision)
144 || (acpi_blacklist[i].oem_revision_predicate == equal 151 || (acpi_blacklist[i].oem_revision_predicate == equal
145 && table_header->oem_revision == acpi_blacklist[i].oem_revision)) { 152 && table_header->oem_revision ==
146 153 acpi_blacklist[i].oem_revision)) {
147 printk(KERN_ERR PREFIX "Vendor \"%6.6s\" System \"%8.8s\" " 154
148 "Revision 0x%x has a known ACPI BIOS problem.\n", 155 printk(KERN_ERR PREFIX
149 acpi_blacklist[i].oem_id, 156 "Vendor \"%6.6s\" System \"%8.8s\" "
150 acpi_blacklist[i].oem_table_id, 157 "Revision 0x%x has a known ACPI BIOS problem.\n",
151 acpi_blacklist[i].oem_revision); 158 acpi_blacklist[i].oem_id,
152 159 acpi_blacklist[i].oem_table_id,
153 printk(KERN_ERR PREFIX "Reason: %s. This is a %s error\n", 160 acpi_blacklist[i].oem_revision);
154 acpi_blacklist[i].reason, 161
155 (acpi_blacklist[i].is_critical_error ? "non-recoverable" : "recoverable")); 162 printk(KERN_ERR PREFIX
163 "Reason: %s. This is a %s error\n",
164 acpi_blacklist[i].reason,
165 (acpi_blacklist[i].
166 is_critical_error ? "non-recoverable" :
167 "recoverable"));
156 168
157 blacklisted = acpi_blacklist[i].is_critical_error; 169 blacklisted = acpi_blacklist[i].is_critical_error;
158 break; 170 break;
159 } 171 } else {
160 else {
161 i++; 172 i++;
162 } 173 }
163 } 174 }
@@ -166,4 +177,3 @@ acpi_blacklisted(void)
166 177
167 return blacklisted; 178 return blacklisted;
168} 179}
169
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index d77c2307883c..6a4da417c16b 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -36,19 +36,17 @@
36#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
37#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
38 38
39
40#define _COMPONENT ACPI_BUS_COMPONENT 39#define _COMPONENT ACPI_BUS_COMPONENT
41ACPI_MODULE_NAME ("acpi_bus") 40ACPI_MODULE_NAME("acpi_bus")
42
43#ifdef CONFIG_X86 41#ifdef CONFIG_X86
44extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger); 42extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger);
45#endif 43#endif
46 44
47FADT_DESCRIPTOR acpi_fadt; 45FADT_DESCRIPTOR acpi_fadt;
48EXPORT_SYMBOL(acpi_fadt); 46EXPORT_SYMBOL(acpi_fadt);
49 47
50struct acpi_device *acpi_root; 48struct acpi_device *acpi_root;
51struct proc_dir_entry *acpi_root_dir; 49struct proc_dir_entry *acpi_root_dir;
52EXPORT_SYMBOL(acpi_root_dir); 50EXPORT_SYMBOL(acpi_root_dir);
53 51
54#define STRUCT_TO_INT(s) (*((int*)&s)) 52#define STRUCT_TO_INT(s) (*((int*)&s))
@@ -57,12 +55,9 @@ EXPORT_SYMBOL(acpi_root_dir);
57 Device Management 55 Device Management
58 -------------------------------------------------------------------------- */ 56 -------------------------------------------------------------------------- */
59 57
60int 58int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
61acpi_bus_get_device (
62 acpi_handle handle,
63 struct acpi_device **device)
64{ 59{
65 acpi_status status = AE_OK; 60 acpi_status status = AE_OK;
66 61
67 ACPI_FUNCTION_TRACE("acpi_bus_get_device"); 62 ACPI_FUNCTION_TRACE("acpi_bus_get_device");
68 63
@@ -71,24 +66,23 @@ acpi_bus_get_device (
71 66
72 /* TBD: Support fixed-feature devices */ 67 /* TBD: Support fixed-feature devices */
73 68
74 status = acpi_get_data(handle, acpi_bus_data_handler, (void**) device); 69 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
75 if (ACPI_FAILURE(status) || !*device) { 70 if (ACPI_FAILURE(status) || !*device) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", 71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n",
77 handle)); 72 handle));
78 return_VALUE(-ENODEV); 73 return_VALUE(-ENODEV);
79 } 74 }
80 75
81 return_VALUE(0); 76 return_VALUE(0);
82} 77}
78
83EXPORT_SYMBOL(acpi_bus_get_device); 79EXPORT_SYMBOL(acpi_bus_get_device);
84 80
85int 81int acpi_bus_get_status(struct acpi_device *device)
86acpi_bus_get_status (
87 struct acpi_device *device)
88{ 82{
89 acpi_status status = AE_OK; 83 acpi_status status = AE_OK;
90 unsigned long sta = 0; 84 unsigned long sta = 0;
91 85
92 ACPI_FUNCTION_TRACE("acpi_bus_get_status"); 86 ACPI_FUNCTION_TRACE("acpi_bus_get_status");
93 87
94 if (!device) 88 if (!device)
@@ -98,10 +92,11 @@ acpi_bus_get_status (
98 * Evaluate _STA if present. 92 * Evaluate _STA if present.
99 */ 93 */
100 if (device->flags.dynamic_status) { 94 if (device->flags.dynamic_status) {
101 status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); 95 status =
96 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
102 if (ACPI_FAILURE(status)) 97 if (ACPI_FAILURE(status))
103 return_VALUE(-ENODEV); 98 return_VALUE(-ENODEV);
104 STRUCT_TO_INT(device->status) = (int) sta; 99 STRUCT_TO_INT(device->status) = (int)sta;
105 } 100 }
106 101
107 /* 102 /*
@@ -115,33 +110,30 @@ acpi_bus_get_status (
115 110
116 if (device->status.functional && !device->status.present) { 111 if (device->status.functional && !device->status.present) {
117 printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: " 112 printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: "
118 "functional but not present; setting present\n", 113 "functional but not present; setting present\n",
119 device->pnp.bus_id, 114 device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status));
120 (u32) STRUCT_TO_INT(device->status));
121 device->status.present = 1; 115 device->status.present = 1;
122 } 116 }
123 117
124 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 118 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
125 device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status))); 119 device->pnp.bus_id,
120 (u32) STRUCT_TO_INT(device->status)));
126 121
127 return_VALUE(0); 122 return_VALUE(0);
128} 123}
129EXPORT_SYMBOL(acpi_bus_get_status);
130 124
125EXPORT_SYMBOL(acpi_bus_get_status);
131 126
132/* -------------------------------------------------------------------------- 127/* --------------------------------------------------------------------------
133 Power Management 128 Power Management
134 -------------------------------------------------------------------------- */ 129 -------------------------------------------------------------------------- */
135 130
136int 131int acpi_bus_get_power(acpi_handle handle, int *state)
137acpi_bus_get_power (
138 acpi_handle handle,
139 int *state)
140{ 132{
141 int result = 0; 133 int result = 0;
142 acpi_status status = 0; 134 acpi_status status = 0;
143 struct acpi_device *device = NULL; 135 struct acpi_device *device = NULL;
144 unsigned long psc = 0; 136 unsigned long psc = 0;
145 137
146 ACPI_FUNCTION_TRACE("acpi_bus_get_power"); 138 ACPI_FUNCTION_TRACE("acpi_bus_get_power");
147 139
@@ -157,20 +149,18 @@ acpi_bus_get_power (
157 *state = device->parent->power.state; 149 *state = device->parent->power.state;
158 else 150 else
159 *state = ACPI_STATE_D0; 151 *state = ACPI_STATE_D0;
160 } 152 } else {
161 else {
162 /* 153 /*
163 * Get the device's power state either directly (via _PSC) or 154 * Get the device's power state either directly (via _PSC) or
164 * indirectly (via power resources). 155 * indirectly (via power resources).
165 */ 156 */
166 if (device->power.flags.explicit_get) { 157 if (device->power.flags.explicit_get) {
167 status = acpi_evaluate_integer(device->handle, "_PSC", 158 status = acpi_evaluate_integer(device->handle, "_PSC",
168 NULL, &psc); 159 NULL, &psc);
169 if (ACPI_FAILURE(status)) 160 if (ACPI_FAILURE(status))
170 return_VALUE(-ENODEV); 161 return_VALUE(-ENODEV);
171 device->power.state = (int) psc; 162 device->power.state = (int)psc;
172 } 163 } else if (device->power.flags.power_resources) {
173 else if (device->power.flags.power_resources) {
174 result = acpi_power_get_inferred_state(device); 164 result = acpi_power_get_inferred_state(device);
175 if (result) 165 if (result)
176 return_VALUE(result); 166 return_VALUE(result);
@@ -180,22 +170,19 @@ acpi_bus_get_power (
180 } 170 }
181 171
182 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", 172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
183 device->pnp.bus_id, device->power.state)); 173 device->pnp.bus_id, device->power.state));
184 174
185 return_VALUE(0); 175 return_VALUE(0);
186} 176}
187EXPORT_SYMBOL(acpi_bus_get_power);
188 177
178EXPORT_SYMBOL(acpi_bus_get_power);
189 179
190int 180int acpi_bus_set_power(acpi_handle handle, int state)
191acpi_bus_set_power (
192 acpi_handle handle,
193 int state)
194{ 181{
195 int result = 0; 182 int result = 0;
196 acpi_status status = AE_OK; 183 acpi_status status = AE_OK;
197 struct acpi_device *device = NULL; 184 struct acpi_device *device = NULL;
198 char object_name[5] = {'_','P','S','0'+state,'\0'}; 185 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
199 186
200 ACPI_FUNCTION_TRACE("acpi_bus_set_power"); 187 ACPI_FUNCTION_TRACE("acpi_bus_set_power");
201 188
@@ -209,7 +196,8 @@ acpi_bus_set_power (
209 /* Make sure this is a valid target state */ 196 /* Make sure this is a valid target state */
210 197
211 if (!device->flags.power_manageable) { 198 if (!device->flags.power_manageable) {
212 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n")); 199 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
200 "Device is not power manageable\n"));
213 return_VALUE(-ENODEV); 201 return_VALUE(-ENODEV);
214 } 202 }
215 /* 203 /*
@@ -219,15 +207,18 @@ acpi_bus_set_power (
219 if (device->power.state == ACPI_STATE_UNKNOWN) 207 if (device->power.state == ACPI_STATE_UNKNOWN)
220 acpi_bus_get_power(device->handle, &device->power.state); 208 acpi_bus_get_power(device->handle, &device->power.state);
221 if (state == device->power.state) { 209 if (state == device->power.state) {
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
211 state));
223 return_VALUE(0); 212 return_VALUE(0);
224 } 213 }
225 if (!device->power.states[state].flags.valid) { 214 if (!device->power.states[state].flags.valid) {
226 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", state)); 215 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n",
216 state));
227 return_VALUE(-ENODEV); 217 return_VALUE(-ENODEV);
228 } 218 }
229 if (device->parent && (state < device->parent->power.state)) { 219 if (device->parent && (state < device->parent->power.state)) {
230 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Cannot set device to a higher-powered state than parent\n")); 220 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
221 "Cannot set device to a higher-powered state than parent\n"));
231 return_VALUE(-ENODEV); 222 return_VALUE(-ENODEV);
232 } 223 }
233 224
@@ -245,18 +236,17 @@ acpi_bus_set_power (
245 goto end; 236 goto end;
246 } 237 }
247 if (device->power.states[state].flags.explicit_set) { 238 if (device->power.states[state].flags.explicit_set) {
248 status = acpi_evaluate_object(device->handle, 239 status = acpi_evaluate_object(device->handle,
249 object_name, NULL, NULL); 240 object_name, NULL, NULL);
250 if (ACPI_FAILURE(status)) { 241 if (ACPI_FAILURE(status)) {
251 result = -ENODEV; 242 result = -ENODEV;
252 goto end; 243 goto end;
253 } 244 }
254 } 245 }
255 } 246 } else {
256 else {
257 if (device->power.states[state].flags.explicit_set) { 247 if (device->power.states[state].flags.explicit_set) {
258 status = acpi_evaluate_object(device->handle, 248 status = acpi_evaluate_object(device->handle,
259 object_name, NULL, NULL); 249 object_name, NULL, NULL);
260 if (ACPI_FAILURE(status)) { 250 if (ACPI_FAILURE(status)) {
261 result = -ENODEV; 251 result = -ENODEV;
262 goto end; 252 goto end;
@@ -269,19 +259,20 @@ acpi_bus_set_power (
269 } 259 }
270 } 260 }
271 261
272end: 262 end:
273 if (result) 263 if (result)
274 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n", 264 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
275 device->pnp.bus_id, state)); 265 "Error transitioning device [%s] to D%d\n",
266 device->pnp.bus_id, state));
276 else 267 else
277 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n", 268 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
278 device->pnp.bus_id, state)); 269 "Device [%s] transitioned to D%d\n",
270 device->pnp.bus_id, state));
279 271
280 return_VALUE(result); 272 return_VALUE(result);
281} 273}
282EXPORT_SYMBOL(acpi_bus_set_power);
283
284 274
275EXPORT_SYMBOL(acpi_bus_set_power);
285 276
286/* -------------------------------------------------------------------------- 277/* --------------------------------------------------------------------------
287 Event Management 278 Event Management
@@ -292,16 +283,12 @@ static DEFINE_SPINLOCK(acpi_bus_event_lock);
292LIST_HEAD(acpi_bus_event_list); 283LIST_HEAD(acpi_bus_event_list);
293DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); 284DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
294 285
295extern int event_is_open; 286extern int event_is_open;
296 287
297int 288int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
298acpi_bus_generate_event (
299 struct acpi_device *device,
300 u8 type,
301 int data)
302{ 289{
303 struct acpi_bus_event *event = NULL; 290 struct acpi_bus_event *event = NULL;
304 unsigned long flags = 0; 291 unsigned long flags = 0;
305 292
306 ACPI_FUNCTION_TRACE("acpi_bus_generate_event"); 293 ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
307 294
@@ -329,14 +316,13 @@ acpi_bus_generate_event (
329 316
330 return_VALUE(0); 317 return_VALUE(0);
331} 318}
319
332EXPORT_SYMBOL(acpi_bus_generate_event); 320EXPORT_SYMBOL(acpi_bus_generate_event);
333 321
334int 322int acpi_bus_receive_event(struct acpi_bus_event *event)
335acpi_bus_receive_event (
336 struct acpi_bus_event *event)
337{ 323{
338 unsigned long flags = 0; 324 unsigned long flags = 0;
339 struct acpi_bus_event *entry = NULL; 325 struct acpi_bus_event *entry = NULL;
340 326
341 DECLARE_WAITQUEUE(wait, current); 327 DECLARE_WAITQUEUE(wait, current);
342 328
@@ -361,7 +347,8 @@ acpi_bus_receive_event (
361 } 347 }
362 348
363 spin_lock_irqsave(&acpi_bus_event_lock, flags); 349 spin_lock_irqsave(&acpi_bus_event_lock, flags);
364 entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); 350 entry =
351 list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
365 if (entry) 352 if (entry)
366 list_del(&entry->node); 353 list_del(&entry->node);
367 spin_unlock_irqrestore(&acpi_bus_event_lock, flags); 354 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
@@ -375,19 +362,17 @@ acpi_bus_receive_event (
375 362
376 return_VALUE(0); 363 return_VALUE(0);
377} 364}
378EXPORT_SYMBOL(acpi_bus_receive_event);
379 365
366EXPORT_SYMBOL(acpi_bus_receive_event);
380 367
381/* -------------------------------------------------------------------------- 368/* --------------------------------------------------------------------------
382 Notification Handling 369 Notification Handling
383 -------------------------------------------------------------------------- */ 370 -------------------------------------------------------------------------- */
384 371
385static int 372static int
386acpi_bus_check_device ( 373acpi_bus_check_device(struct acpi_device *device, int *status_changed)
387 struct acpi_device *device,
388 int *status_changed)
389{ 374{
390 acpi_status status = 0; 375 acpi_status status = 0;
391 struct acpi_device_status old_status; 376 struct acpi_device_status old_status;
392 377
393 ACPI_FUNCTION_TRACE("acpi_bus_check_device"); 378 ACPI_FUNCTION_TRACE("acpi_bus_check_device");
@@ -422,15 +407,14 @@ acpi_bus_check_device (
422 407
423 if (status_changed) 408 if (status_changed)
424 *status_changed = 1; 409 *status_changed = 1;
425 410
426 /* 411 /*
427 * Device Insertion/Removal 412 * Device Insertion/Removal
428 */ 413 */
429 if ((device->status.present) && !(old_status.present)) { 414 if ((device->status.present) && !(old_status.present)) {
430 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n")); 415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
431 /* TBD: Handle device insertion */ 416 /* TBD: Handle device insertion */
432 } 417 } else if (!(device->status.present) && (old_status.present)) {
433 else if (!(device->status.present) && (old_status.present)) {
434 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n")); 418 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
435 /* TBD: Handle device removal */ 419 /* TBD: Handle device removal */
436 } 420 }
@@ -438,13 +422,10 @@ acpi_bus_check_device (
438 return_VALUE(0); 422 return_VALUE(0);
439} 423}
440 424
441 425static int acpi_bus_check_scope(struct acpi_device *device)
442static int
443acpi_bus_check_scope (
444 struct acpi_device *device)
445{ 426{
446 int result = 0; 427 int result = 0;
447 int status_changed = 0; 428 int status_changed = 0;
448 429
449 ACPI_FUNCTION_TRACE("acpi_bus_check_scope"); 430 ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
450 431
@@ -467,20 +448,15 @@ acpi_bus_check_scope (
467 return_VALUE(0); 448 return_VALUE(0);
468} 449}
469 450
470
471/** 451/**
472 * acpi_bus_notify 452 * acpi_bus_notify
473 * --------------- 453 * ---------------
474 * Callback for all 'system-level' device notifications (values 0x00-0x7F). 454 * Callback for all 'system-level' device notifications (values 0x00-0x7F).
475 */ 455 */
476static void 456static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
477acpi_bus_notify (
478 acpi_handle handle,
479 u32 type,
480 void *data)
481{ 457{
482 int result = 0; 458 int result = 0;
483 struct acpi_device *device = NULL; 459 struct acpi_device *device = NULL;
484 460
485 ACPI_FUNCTION_TRACE("acpi_bus_notify"); 461 ACPI_FUNCTION_TRACE("acpi_bus_notify");
486 462
@@ -490,64 +466,73 @@ acpi_bus_notify (
490 switch (type) { 466 switch (type) {
491 467
492 case ACPI_NOTIFY_BUS_CHECK: 468 case ACPI_NOTIFY_BUS_CHECK:
493 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n", 469 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
494 device->pnp.bus_id)); 470 "Received BUS CHECK notification for device [%s]\n",
471 device->pnp.bus_id));
495 result = acpi_bus_check_scope(device); 472 result = acpi_bus_check_scope(device);
496 /* 473 /*
497 * TBD: We'll need to outsource certain events to non-ACPI 474 * TBD: We'll need to outsource certain events to non-ACPI
498 * drivers via the device manager (device.c). 475 * drivers via the device manager (device.c).
499 */ 476 */
500 break; 477 break;
501 478
502 case ACPI_NOTIFY_DEVICE_CHECK: 479 case ACPI_NOTIFY_DEVICE_CHECK:
503 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n", 480 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
504 device->pnp.bus_id)); 481 "Received DEVICE CHECK notification for device [%s]\n",
482 device->pnp.bus_id));
505 result = acpi_bus_check_device(device, NULL); 483 result = acpi_bus_check_device(device, NULL);
506 /* 484 /*
507 * TBD: We'll need to outsource certain events to non-ACPI 485 * TBD: We'll need to outsource certain events to non-ACPI
508 * drivers via the device manager (device.c). 486 * drivers via the device manager (device.c).
509 */ 487 */
510 break; 488 break;
511 489
512 case ACPI_NOTIFY_DEVICE_WAKE: 490 case ACPI_NOTIFY_DEVICE_WAKE:
513 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n", 491 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
514 device->pnp.bus_id)); 492 "Received DEVICE WAKE notification for device [%s]\n",
493 device->pnp.bus_id));
515 /* TBD */ 494 /* TBD */
516 break; 495 break;
517 496
518 case ACPI_NOTIFY_EJECT_REQUEST: 497 case ACPI_NOTIFY_EJECT_REQUEST:
519 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n", 498 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
520 device->pnp.bus_id)); 499 "Received EJECT REQUEST notification for device [%s]\n",
500 device->pnp.bus_id));
521 /* TBD */ 501 /* TBD */
522 break; 502 break;
523 503
524 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: 504 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
525 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n", 505 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
526 device->pnp.bus_id)); 506 "Received DEVICE CHECK LIGHT notification for device [%s]\n",
507 device->pnp.bus_id));
527 /* TBD: Exactly what does 'light' mean? */ 508 /* TBD: Exactly what does 'light' mean? */
528 break; 509 break;
529 510
530 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 511 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
531 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n", 512 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
532 device->pnp.bus_id)); 513 "Received FREQUENCY MISMATCH notification for device [%s]\n",
514 device->pnp.bus_id));
533 /* TBD */ 515 /* TBD */
534 break; 516 break;
535 517
536 case ACPI_NOTIFY_BUS_MODE_MISMATCH: 518 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
537 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n", 519 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
538 device->pnp.bus_id)); 520 "Received BUS MODE MISMATCH notification for device [%s]\n",
521 device->pnp.bus_id));
539 /* TBD */ 522 /* TBD */
540 break; 523 break;
541 524
542 case ACPI_NOTIFY_POWER_FAULT: 525 case ACPI_NOTIFY_POWER_FAULT:
543 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n", 526 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
544 device->pnp.bus_id)); 527 "Received POWER FAULT notification for device [%s]\n",
528 device->pnp.bus_id));
545 /* TBD */ 529 /* TBD */
546 break; 530 break;
547 531
548 default: 532 default:
549 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n", 533 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
550 type)); 534 "Received unknown/unsupported notification [%08x]\n",
535 type));
551 break; 536 break;
552 } 537 }
553 538
@@ -558,13 +543,12 @@ acpi_bus_notify (
558 Initialization/Cleanup 543 Initialization/Cleanup
559 -------------------------------------------------------------------------- */ 544 -------------------------------------------------------------------------- */
560 545
561static int __init 546static int __init acpi_bus_init_irq(void)
562acpi_bus_init_irq (void)
563{ 547{
564 acpi_status status = AE_OK; 548 acpi_status status = AE_OK;
565 union acpi_object arg = {ACPI_TYPE_INTEGER}; 549 union acpi_object arg = { ACPI_TYPE_INTEGER };
566 struct acpi_object_list arg_list = {1, &arg}; 550 struct acpi_object_list arg_list = { 1, &arg };
567 char *message = NULL; 551 char *message = NULL;
568 552
569 ACPI_FUNCTION_TRACE("acpi_bus_init_irq"); 553 ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
570 554
@@ -601,12 +585,10 @@ acpi_bus_init_irq (void)
601 return_VALUE(0); 585 return_VALUE(0);
602} 586}
603 587
604 588void __init acpi_early_init(void)
605void __init
606acpi_early_init (void)
607{ 589{
608 acpi_status status = AE_OK; 590 acpi_status status = AE_OK;
609 struct acpi_buffer buffer = {sizeof(acpi_fadt), &acpi_fadt}; 591 struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
610 592
611 ACPI_FUNCTION_TRACE("acpi_early_init"); 593 ACPI_FUNCTION_TRACE("acpi_early_init");
612 594
@@ -619,13 +601,15 @@ acpi_early_init (void)
619 601
620 status = acpi_initialize_subsystem(); 602 status = acpi_initialize_subsystem();
621 if (ACPI_FAILURE(status)) { 603 if (ACPI_FAILURE(status)) {
622 printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n"); 604 printk(KERN_ERR PREFIX
605 "Unable to initialize the ACPI Interpreter\n");
623 goto error0; 606 goto error0;
624 } 607 }
625 608
626 status = acpi_load_tables(); 609 status = acpi_load_tables();
627 if (ACPI_FAILURE(status)) { 610 if (ACPI_FAILURE(status)) {
628 printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n"); 611 printk(KERN_ERR PREFIX
612 "Unable to load the System Description Tables\n");
629 goto error0; 613 goto error0;
630 } 614 }
631 615
@@ -637,7 +621,6 @@ acpi_early_init (void)
637 printk(KERN_ERR PREFIX "Unable to get the FADT\n"); 621 printk(KERN_ERR PREFIX "Unable to get the FADT\n");
638 goto error0; 622 goto error0;
639 } 623 }
640
641#ifdef CONFIG_X86 624#ifdef CONFIG_X86
642 if (!acpi_ioapic) { 625 if (!acpi_ioapic) {
643 extern acpi_interrupt_flags acpi_sci_flags; 626 extern acpi_interrupt_flags acpi_sci_flags;
@@ -647,7 +630,8 @@ acpi_early_init (void)
647 acpi_sci_flags.trigger = 3; 630 acpi_sci_flags.trigger = 3;
648 631
649 /* Set PIC-mode SCI trigger type */ 632 /* Set PIC-mode SCI trigger type */
650 acpi_pic_sci_set_trigger(acpi_fadt.sci_int, acpi_sci_flags.trigger); 633 acpi_pic_sci_set_trigger(acpi_fadt.sci_int,
634 acpi_sci_flags.trigger);
651 } else { 635 } else {
652 extern int acpi_sci_override_gsi; 636 extern int acpi_sci_override_gsi;
653 /* 637 /*
@@ -658,7 +642,10 @@ acpi_early_init (void)
658 } 642 }
659#endif 643#endif
660 644
661 status = acpi_enable_subsystem(~(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE)); 645 status =
646 acpi_enable_subsystem(~
647 (ACPI_NO_HARDWARE_INIT |
648 ACPI_NO_ACPI_ENABLE));
662 if (ACPI_FAILURE(status)) { 649 if (ACPI_FAILURE(status)) {
663 printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); 650 printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
664 goto error0; 651 goto error0;
@@ -666,30 +653,32 @@ acpi_early_init (void)
666 653
667 return_VOID; 654 return_VOID;
668 655
669error0: 656 error0:
670 disable_acpi(); 657 disable_acpi();
671 return_VOID; 658 return_VOID;
672} 659}
673 660
674static int __init 661static int __init acpi_bus_init(void)
675acpi_bus_init (void)
676{ 662{
677 int result = 0; 663 int result = 0;
678 acpi_status status = AE_OK; 664 acpi_status status = AE_OK;
679 extern acpi_status acpi_os_initialize1(void); 665 extern acpi_status acpi_os_initialize1(void);
680 666
681 ACPI_FUNCTION_TRACE("acpi_bus_init"); 667 ACPI_FUNCTION_TRACE("acpi_bus_init");
682 668
683 status = acpi_os_initialize1(); 669 status = acpi_os_initialize1();
684 670
685 status = acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); 671 status =
672 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
686 if (ACPI_FAILURE(status)) { 673 if (ACPI_FAILURE(status)) {
687 printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n"); 674 printk(KERN_ERR PREFIX
675 "Unable to start the ACPI Interpreter\n");
688 goto error1; 676 goto error1;
689 } 677 }
690 678
691 if (ACPI_FAILURE(status)) { 679 if (ACPI_FAILURE(status)) {
692 printk(KERN_ERR PREFIX "Unable to initialize ACPI OS objects\n"); 680 printk(KERN_ERR PREFIX
681 "Unable to initialize ACPI OS objects\n");
693 goto error1; 682 goto error1;
694 } 683 }
695#ifdef CONFIG_ACPI_EC 684#ifdef CONFIG_ACPI_EC
@@ -723,9 +712,12 @@ acpi_bus_init (void)
723 /* 712 /*
724 * Register the for all standard device notifications. 713 * Register the for all standard device notifications.
725 */ 714 */
726 status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL); 715 status =
716 acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
717 &acpi_bus_notify, NULL);
727 if (ACPI_FAILURE(status)) { 718 if (ACPI_FAILURE(status)) {
728 printk(KERN_ERR PREFIX "Unable to register for device notifications\n"); 719 printk(KERN_ERR PREFIX
720 "Unable to register for device notifications\n");
729 goto error1; 721 goto error1;
730 } 722 }
731 723
@@ -737,21 +729,20 @@ acpi_bus_init (void)
737 return_VALUE(0); 729 return_VALUE(0);
738 730
739 /* Mimic structured exception handling */ 731 /* Mimic structured exception handling */
740error1: 732 error1:
741 acpi_terminate(); 733 acpi_terminate();
742 return_VALUE(-ENODEV); 734 return_VALUE(-ENODEV);
743} 735}
744 736
745decl_subsys(acpi,NULL,NULL); 737decl_subsys(acpi, NULL, NULL);
746 738
747static int __init acpi_init (void) 739static int __init acpi_init(void)
748{ 740{
749 int result = 0; 741 int result = 0;
750 742
751 ACPI_FUNCTION_TRACE("acpi_init"); 743 ACPI_FUNCTION_TRACE("acpi_init");
752 744
753 printk(KERN_INFO PREFIX "Subsystem revision %08x\n", 745 printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION);
754 ACPI_CA_VERSION);
755 746
756 if (acpi_disabled) { 747 if (acpi_disabled) {
757 printk(KERN_INFO PREFIX "Interpreter disabled.\n"); 748 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -767,7 +758,8 @@ static int __init acpi_init (void)
767 if (!PM_IS_ACTIVE()) 758 if (!PM_IS_ACTIVE())
768 pm_active = 1; 759 pm_active = 1;
769 else { 760 else {
770 printk(KERN_INFO PREFIX "APM is already active, exiting\n"); 761 printk(KERN_INFO PREFIX
762 "APM is already active, exiting\n");
771 disable_acpi(); 763 disable_acpi();
772 result = -ENODEV; 764 result = -ENODEV;
773 } 765 }
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 8162fd0c21a7..4b6d9f0096a1 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -32,7 +32,6 @@
32#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
34 34
35
36#define ACPI_BUTTON_COMPONENT 0x00080000 35#define ACPI_BUTTON_COMPONENT 0x00080000
37#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" 36#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
38#define ACPI_BUTTON_CLASS "button" 37#define ACPI_BUTTON_CLASS "button"
@@ -42,7 +41,7 @@
42#define ACPI_BUTTON_NOTIFY_STATUS 0x80 41#define ACPI_BUTTON_NOTIFY_STATUS 0x80
43 42
44#define ACPI_BUTTON_SUBCLASS_POWER "power" 43#define ACPI_BUTTON_SUBCLASS_POWER "power"
45#define ACPI_BUTTON_HID_POWER "PNP0C0C" 44#define ACPI_BUTTON_HID_POWER "PNP0C0C"
46#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" 45#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)"
47#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" 46#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)"
48#define ACPI_BUTTON_TYPE_POWER 0x01 47#define ACPI_BUTTON_TYPE_POWER 0x01
@@ -61,65 +60,65 @@
61#define ACPI_BUTTON_TYPE_LID 0x05 60#define ACPI_BUTTON_TYPE_LID 0x05
62 61
63#define _COMPONENT ACPI_BUTTON_COMPONENT 62#define _COMPONENT ACPI_BUTTON_COMPONENT
64ACPI_MODULE_NAME ("acpi_button") 63ACPI_MODULE_NAME("acpi_button")
65 64
66MODULE_AUTHOR("Paul Diefenbaugh"); 65 MODULE_AUTHOR("Paul Diefenbaugh");
67MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); 66MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
68MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
69 68
70 69static int acpi_button_add(struct acpi_device *device);
71static int acpi_button_add (struct acpi_device *device); 70static int acpi_button_remove(struct acpi_device *device, int type);
72static int acpi_button_remove (struct acpi_device *device, int type);
73static int acpi_button_info_open_fs(struct inode *inode, struct file *file); 71static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
74static int acpi_button_state_open_fs(struct inode *inode, struct file *file); 72static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
75 73
76static struct acpi_driver acpi_button_driver = { 74static struct acpi_driver acpi_button_driver = {
77 .name = ACPI_BUTTON_DRIVER_NAME, 75 .name = ACPI_BUTTON_DRIVER_NAME,
78 .class = ACPI_BUTTON_CLASS, 76 .class = ACPI_BUTTON_CLASS,
79 .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", 77 .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
80 .ops = { 78 .ops = {
81 .add = acpi_button_add, 79 .add = acpi_button_add,
82 .remove = acpi_button_remove, 80 .remove = acpi_button_remove,
83 }, 81 },
84}; 82};
85 83
86struct acpi_button { 84struct acpi_button {
87 acpi_handle handle; 85 acpi_handle handle;
88 struct acpi_device *device; /* Fixed button kludge */ 86 struct acpi_device *device; /* Fixed button kludge */
89 u8 type; 87 u8 type;
90 unsigned long pushed; 88 unsigned long pushed;
91}; 89};
92 90
93static struct file_operations acpi_button_info_fops = { 91static struct file_operations acpi_button_info_fops = {
94 .open = acpi_button_info_open_fs, 92 .open = acpi_button_info_open_fs,
95 .read = seq_read, 93 .read = seq_read,
96 .llseek = seq_lseek, 94 .llseek = seq_lseek,
97 .release = single_release, 95 .release = single_release,
98}; 96};
99 97
100static struct file_operations acpi_button_state_fops = { 98static struct file_operations acpi_button_state_fops = {
101 .open = acpi_button_state_open_fs, 99 .open = acpi_button_state_open_fs,
102 .read = seq_read, 100 .read = seq_read,
103 .llseek = seq_lseek, 101 .llseek = seq_lseek,
104 .release = single_release, 102 .release = single_release,
105}; 103};
104
106/* -------------------------------------------------------------------------- 105/* --------------------------------------------------------------------------
107 FS Interface (/proc) 106 FS Interface (/proc)
108 -------------------------------------------------------------------------- */ 107 -------------------------------------------------------------------------- */
109 108
110static struct proc_dir_entry *acpi_button_dir; 109static struct proc_dir_entry *acpi_button_dir;
111 110
112static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) 111static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
113{ 112{
114 struct acpi_button *button = (struct acpi_button *) seq->private; 113 struct acpi_button *button = (struct acpi_button *)seq->private;
115 114
116 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); 115 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
117 116
118 if (!button || !button->device) 117 if (!button || !button->device)
119 return_VALUE(0); 118 return_VALUE(0);
120 119
121 seq_printf(seq, "type: %s\n", 120 seq_printf(seq, "type: %s\n",
122 acpi_device_name(button->device)); 121 acpi_device_name(button->device));
123 122
124 return_VALUE(0); 123 return_VALUE(0);
125} 124}
@@ -128,24 +127,24 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
128{ 127{
129 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); 128 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
130} 129}
131 130
132static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 131static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
133{ 132{
134 struct acpi_button *button = (struct acpi_button *) seq->private; 133 struct acpi_button *button = (struct acpi_button *)seq->private;
135 acpi_status status; 134 acpi_status status;
136 unsigned long state; 135 unsigned long state;
137 136
138 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); 137 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
139 138
140 if (!button || !button->device) 139 if (!button || !button->device)
141 return_VALUE(0); 140 return_VALUE(0);
142 141
143 status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state); 142 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
144 if (ACPI_FAILURE(status)) { 143 if (ACPI_FAILURE(status)) {
145 seq_printf(seq, "state: unsupported\n"); 144 seq_printf(seq, "state: unsupported\n");
146 } 145 } else {
147 else{ 146 seq_printf(seq, "state: %s\n",
148 seq_printf(seq, "state: %s\n", (state ? "open" : "closed")); 147 (state ? "open" : "closed"));
149 } 148 }
150 149
151 return_VALUE(0); 150 return_VALUE(0);
@@ -160,12 +159,10 @@ static struct proc_dir_entry *acpi_power_dir;
160static struct proc_dir_entry *acpi_sleep_dir; 159static struct proc_dir_entry *acpi_sleep_dir;
161static struct proc_dir_entry *acpi_lid_dir; 160static struct proc_dir_entry *acpi_lid_dir;
162 161
163static int 162static int acpi_button_add_fs(struct acpi_device *device)
164acpi_button_add_fs (
165 struct acpi_device *device)
166{ 163{
167 struct proc_dir_entry *entry = NULL; 164 struct proc_dir_entry *entry = NULL;
168 struct acpi_button *button = NULL; 165 struct acpi_button *button = NULL;
169 166
170 ACPI_FUNCTION_TRACE("acpi_button_add_fs"); 167 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
171 168
@@ -178,21 +175,21 @@ acpi_button_add_fs (
178 case ACPI_BUTTON_TYPE_POWER: 175 case ACPI_BUTTON_TYPE_POWER:
179 case ACPI_BUTTON_TYPE_POWERF: 176 case ACPI_BUTTON_TYPE_POWERF:
180 if (!acpi_power_dir) 177 if (!acpi_power_dir)
181 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 178 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
182 acpi_button_dir); 179 acpi_button_dir);
183 entry = acpi_power_dir; 180 entry = acpi_power_dir;
184 break; 181 break;
185 case ACPI_BUTTON_TYPE_SLEEP: 182 case ACPI_BUTTON_TYPE_SLEEP:
186 case ACPI_BUTTON_TYPE_SLEEPF: 183 case ACPI_BUTTON_TYPE_SLEEPF:
187 if (!acpi_sleep_dir) 184 if (!acpi_sleep_dir)
188 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, 185 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
189 acpi_button_dir); 186 acpi_button_dir);
190 entry = acpi_sleep_dir; 187 entry = acpi_sleep_dir;
191 break; 188 break;
192 case ACPI_BUTTON_TYPE_LID: 189 case ACPI_BUTTON_TYPE_LID:
193 if (!acpi_lid_dir) 190 if (!acpi_lid_dir)
194 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, 191 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
195 acpi_button_dir); 192 acpi_button_dir);
196 entry = acpi_lid_dir; 193 entry = acpi_lid_dir;
197 break; 194 break;
198 } 195 }
@@ -208,11 +205,11 @@ acpi_button_add_fs (
208 205
209 /* 'info' [R] */ 206 /* 'info' [R] */
210 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 207 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
211 S_IRUGO, acpi_device_dir(device)); 208 S_IRUGO, acpi_device_dir(device));
212 if (!entry) 209 if (!entry)
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
214 "Unable to create '%s' fs entry\n", 211 "Unable to create '%s' fs entry\n",
215 ACPI_BUTTON_FILE_INFO)); 212 ACPI_BUTTON_FILE_INFO));
216 else { 213 else {
217 entry->proc_fops = &acpi_button_info_fops; 214 entry->proc_fops = &acpi_button_info_fops;
218 entry->data = acpi_driver_data(device); 215 entry->data = acpi_driver_data(device);
@@ -222,11 +219,11 @@ acpi_button_add_fs (
222 /* show lid state [R] */ 219 /* show lid state [R] */
223 if (button->type == ACPI_BUTTON_TYPE_LID) { 220 if (button->type == ACPI_BUTTON_TYPE_LID) {
224 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, 221 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
225 S_IRUGO, acpi_device_dir(device)); 222 S_IRUGO, acpi_device_dir(device));
226 if (!entry) 223 if (!entry)
227 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
228 "Unable to create '%s' fs entry\n", 225 "Unable to create '%s' fs entry\n",
229 ACPI_BUTTON_FILE_INFO)); 226 ACPI_BUTTON_FILE_INFO));
230 else { 227 else {
231 entry->proc_fops = &acpi_button_state_fops; 228 entry->proc_fops = &acpi_button_state_fops;
232 entry->data = acpi_driver_data(device); 229 entry->data = acpi_driver_data(device);
@@ -237,12 +234,9 @@ acpi_button_add_fs (
237 return_VALUE(0); 234 return_VALUE(0);
238} 235}
239 236
240 237static int acpi_button_remove_fs(struct acpi_device *device)
241static int
242acpi_button_remove_fs (
243 struct acpi_device *device)
244{ 238{
245 struct acpi_button *button = NULL; 239 struct acpi_button *button = NULL;
246 240
247 ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); 241 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
248 242
@@ -250,30 +244,25 @@ acpi_button_remove_fs (
250 if (acpi_device_dir(device)) { 244 if (acpi_device_dir(device)) {
251 if (button->type == ACPI_BUTTON_TYPE_LID) 245 if (button->type == ACPI_BUTTON_TYPE_LID)
252 remove_proc_entry(ACPI_BUTTON_FILE_STATE, 246 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
253 acpi_device_dir(device)); 247 acpi_device_dir(device));
254 remove_proc_entry(ACPI_BUTTON_FILE_INFO, 248 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
255 acpi_device_dir(device)); 249 acpi_device_dir(device));
256 250
257 remove_proc_entry(acpi_device_bid(device), 251 remove_proc_entry(acpi_device_bid(device),
258 acpi_device_dir(device)->parent); 252 acpi_device_dir(device)->parent);
259 acpi_device_dir(device) = NULL; 253 acpi_device_dir(device) = NULL;
260 } 254 }
261 255
262 return_VALUE(0); 256 return_VALUE(0);
263} 257}
264 258
265
266/* -------------------------------------------------------------------------- 259/* --------------------------------------------------------------------------
267 Driver Interface 260 Driver Interface
268 -------------------------------------------------------------------------- */ 261 -------------------------------------------------------------------------- */
269 262
270static void 263static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
271acpi_button_notify (
272 acpi_handle handle,
273 u32 event,
274 void *data)
275{ 264{
276 struct acpi_button *button = (struct acpi_button *) data; 265 struct acpi_button *button = (struct acpi_button *)data;
277 266
278 ACPI_FUNCTION_TRACE("acpi_button_notify"); 267 ACPI_FUNCTION_TRACE("acpi_button_notify");
279 268
@@ -282,24 +271,22 @@ acpi_button_notify (
282 271
283 switch (event) { 272 switch (event) {
284 case ACPI_BUTTON_NOTIFY_STATUS: 273 case ACPI_BUTTON_NOTIFY_STATUS:
285 acpi_bus_generate_event(button->device, event, ++button->pushed); 274 acpi_bus_generate_event(button->device, event,
275 ++button->pushed);
286 break; 276 break;
287 default: 277 default:
288 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 278 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
289 "Unsupported event [0x%x]\n", event)); 279 "Unsupported event [0x%x]\n", event));
290 break; 280 break;
291 } 281 }
292 282
293 return_VOID; 283 return_VOID;
294} 284}
295 285
296 286static acpi_status acpi_button_notify_fixed(void *data)
297static acpi_status
298acpi_button_notify_fixed (
299 void *data)
300{ 287{
301 struct acpi_button *button = (struct acpi_button *) data; 288 struct acpi_button *button = (struct acpi_button *)data;
302 289
303 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); 290 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
304 291
305 if (!button) 292 if (!button)
@@ -310,14 +297,11 @@ acpi_button_notify_fixed (
310 return_ACPI_STATUS(AE_OK); 297 return_ACPI_STATUS(AE_OK);
311} 298}
312 299
313 300static int acpi_button_add(struct acpi_device *device)
314static int
315acpi_button_add (
316 struct acpi_device *device)
317{ 301{
318 int result = 0; 302 int result = 0;
319 acpi_status status = AE_OK; 303 acpi_status status = AE_OK;
320 struct acpi_button *button = NULL; 304 struct acpi_button *button = NULL;
321 305
322 ACPI_FUNCTION_TRACE("acpi_button_add"); 306 ACPI_FUNCTION_TRACE("acpi_button_add");
323 307
@@ -339,42 +323,34 @@ acpi_button_add (
339 */ 323 */
340 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { 324 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
341 button->type = ACPI_BUTTON_TYPE_POWER; 325 button->type = ACPI_BUTTON_TYPE_POWER;
342 strcpy(acpi_device_name(device), 326 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
343 ACPI_BUTTON_DEVICE_NAME_POWER); 327 sprintf(acpi_device_class(device), "%s/%s",
344 sprintf(acpi_device_class(device), "%s/%s",
345 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); 328 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
346 } 329 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
347 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
348 button->type = ACPI_BUTTON_TYPE_POWERF; 330 button->type = ACPI_BUTTON_TYPE_POWERF;
349 strcpy(acpi_device_name(device), 331 strcpy(acpi_device_name(device),
350 ACPI_BUTTON_DEVICE_NAME_POWERF); 332 ACPI_BUTTON_DEVICE_NAME_POWERF);
351 sprintf(acpi_device_class(device), "%s/%s", 333 sprintf(acpi_device_class(device), "%s/%s",
352 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); 334 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
353 } 335 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
354 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
355 button->type = ACPI_BUTTON_TYPE_SLEEP; 336 button->type = ACPI_BUTTON_TYPE_SLEEP;
356 strcpy(acpi_device_name(device), 337 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
357 ACPI_BUTTON_DEVICE_NAME_SLEEP); 338 sprintf(acpi_device_class(device), "%s/%s",
358 sprintf(acpi_device_class(device), "%s/%s",
359 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); 339 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
360 } 340 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
361 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
362 button->type = ACPI_BUTTON_TYPE_SLEEPF; 341 button->type = ACPI_BUTTON_TYPE_SLEEPF;
363 strcpy(acpi_device_name(device), 342 strcpy(acpi_device_name(device),
364 ACPI_BUTTON_DEVICE_NAME_SLEEPF); 343 ACPI_BUTTON_DEVICE_NAME_SLEEPF);
365 sprintf(acpi_device_class(device), "%s/%s", 344 sprintf(acpi_device_class(device), "%s/%s",
366 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); 345 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
367 } 346 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
368 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
369 button->type = ACPI_BUTTON_TYPE_LID; 347 button->type = ACPI_BUTTON_TYPE_LID;
370 strcpy(acpi_device_name(device), 348 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
371 ACPI_BUTTON_DEVICE_NAME_LID); 349 sprintf(acpi_device_class(device), "%s/%s",
372 sprintf(acpi_device_class(device), "%s/%s",
373 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); 350 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
374 } 351 } else {
375 else {
376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", 352 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
377 acpi_device_hid(device))); 353 acpi_device_hid(device)));
378 result = -ENODEV; 354 result = -ENODEV;
379 goto end; 355 goto end;
380 } 356 }
@@ -385,46 +361,46 @@ acpi_button_add (
385 361
386 switch (button->type) { 362 switch (button->type) {
387 case ACPI_BUTTON_TYPE_POWERF: 363 case ACPI_BUTTON_TYPE_POWERF:
388 status = acpi_install_fixed_event_handler ( 364 status =
389 ACPI_EVENT_POWER_BUTTON, 365 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
390 acpi_button_notify_fixed, 366 acpi_button_notify_fixed,
391 button); 367 button);
392 break; 368 break;
393 case ACPI_BUTTON_TYPE_SLEEPF: 369 case ACPI_BUTTON_TYPE_SLEEPF:
394 status = acpi_install_fixed_event_handler ( 370 status =
395 ACPI_EVENT_SLEEP_BUTTON, 371 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
396 acpi_button_notify_fixed, 372 acpi_button_notify_fixed,
397 button); 373 button);
398 break; 374 break;
399 default: 375 default:
400 status = acpi_install_notify_handler ( 376 status = acpi_install_notify_handler(button->handle,
401 button->handle, 377 ACPI_DEVICE_NOTIFY,
402 ACPI_DEVICE_NOTIFY, 378 acpi_button_notify,
403 acpi_button_notify, 379 button);
404 button);
405 break; 380 break;
406 } 381 }
407 382
408 if (ACPI_FAILURE(status)) { 383 if (ACPI_FAILURE(status)) {
409 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
410 "Error installing notify handler\n")); 385 "Error installing notify handler\n"));
411 result = -ENODEV; 386 result = -ENODEV;
412 goto end; 387 goto end;
413 } 388 }
414 389
415 if (device->wakeup.flags.valid) { 390 if (device->wakeup.flags.valid) {
416 /* Button's GPE is run-wake GPE */ 391 /* Button's GPE is run-wake GPE */
417 acpi_set_gpe_type(device->wakeup.gpe_device, 392 acpi_set_gpe_type(device->wakeup.gpe_device,
418 device->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 393 device->wakeup.gpe_number,
419 acpi_enable_gpe(device->wakeup.gpe_device, 394 ACPI_GPE_TYPE_WAKE_RUN);
420 device->wakeup.gpe_number, ACPI_NOT_ISR); 395 acpi_enable_gpe(device->wakeup.gpe_device,
396 device->wakeup.gpe_number, ACPI_NOT_ISR);
421 device->wakeup.state.enabled = 1; 397 device->wakeup.state.enabled = 1;
422 } 398 }
423 399
424 printk(KERN_INFO PREFIX "%s [%s]\n", 400 printk(KERN_INFO PREFIX "%s [%s]\n",
425 acpi_device_name(device), acpi_device_bid(device)); 401 acpi_device_name(device), acpi_device_bid(device));
426 402
427end: 403 end:
428 if (result) { 404 if (result) {
429 acpi_button_remove_fs(device); 405 acpi_button_remove_fs(device);
430 kfree(button); 406 kfree(button);
@@ -433,12 +409,10 @@ end:
433 return_VALUE(result); 409 return_VALUE(result);
434} 410}
435 411
436 412static int acpi_button_remove(struct acpi_device *device, int type)
437static int
438acpi_button_remove (struct acpi_device *device, int type)
439{ 413{
440 acpi_status status = 0; 414 acpi_status status = 0;
441 struct acpi_button *button = NULL; 415 struct acpi_button *button = NULL;
442 416
443 ACPI_FUNCTION_TRACE("acpi_button_remove"); 417 ACPI_FUNCTION_TRACE("acpi_button_remove");
444 418
@@ -450,35 +424,36 @@ acpi_button_remove (struct acpi_device *device, int type)
450 /* Unregister for device notifications. */ 424 /* Unregister for device notifications. */
451 switch (button->type) { 425 switch (button->type) {
452 case ACPI_BUTTON_TYPE_POWERF: 426 case ACPI_BUTTON_TYPE_POWERF:
453 status = acpi_remove_fixed_event_handler( 427 status =
454 ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); 428 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
429 acpi_button_notify_fixed);
455 break; 430 break;
456 case ACPI_BUTTON_TYPE_SLEEPF: 431 case ACPI_BUTTON_TYPE_SLEEPF:
457 status = acpi_remove_fixed_event_handler( 432 status =
458 ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); 433 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
434 acpi_button_notify_fixed);
459 break; 435 break;
460 default: 436 default:
461 status = acpi_remove_notify_handler(button->handle, 437 status = acpi_remove_notify_handler(button->handle,
462 ACPI_DEVICE_NOTIFY, acpi_button_notify); 438 ACPI_DEVICE_NOTIFY,
439 acpi_button_notify);
463 break; 440 break;
464 } 441 }
465 442
466 if (ACPI_FAILURE(status)) 443 if (ACPI_FAILURE(status))
467 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 444 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
468 "Error removing notify handler\n")); 445 "Error removing notify handler\n"));
469 446
470 acpi_button_remove_fs(device); 447 acpi_button_remove_fs(device);
471 448
472 kfree(button); 449 kfree(button);
473 450
474 return_VALUE(0); 451 return_VALUE(0);
475} 452}
476 453
477 454static int __init acpi_button_init(void)
478static int __init
479acpi_button_init (void)
480{ 455{
481 int result = 0; 456 int result = 0;
482 457
483 ACPI_FUNCTION_TRACE("acpi_button_init"); 458 ACPI_FUNCTION_TRACE("acpi_button_init");
484 459
@@ -495,15 +470,13 @@ acpi_button_init (void)
495 return_VALUE(0); 470 return_VALUE(0);
496} 471}
497 472
498 473static void __exit acpi_button_exit(void)
499static void __exit
500acpi_button_exit (void)
501{ 474{
502 ACPI_FUNCTION_TRACE("acpi_button_exit"); 475 ACPI_FUNCTION_TRACE("acpi_button_exit");
503 476
504 acpi_bus_unregister_driver(&acpi_button_driver); 477 acpi_bus_unregister_driver(&acpi_button_driver);
505 478
506 if (acpi_power_dir) 479 if (acpi_power_dir)
507 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); 480 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
508 if (acpi_sleep_dir) 481 if (acpi_sleep_dir)
509 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); 482 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
@@ -514,6 +487,5 @@ acpi_button_exit (void)
514 return_VOID; 487 return_VOID;
515} 488}
516 489
517
518module_init(acpi_button_init); 490module_init(acpi_button_init);
519module_exit(acpi_button_exit); 491module_exit(acpi_button_exit);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 97013ddfa202..10dd695a1dd9 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -44,9 +44,9 @@
44 44
45#define ACPI_CONTAINER_COMPONENT 0x01000000 45#define ACPI_CONTAINER_COMPONENT 0x01000000
46#define _COMPONENT ACPI_CONTAINER_COMPONENT 46#define _COMPONENT ACPI_CONTAINER_COMPONENT
47ACPI_MODULE_NAME ("acpi_container") 47ACPI_MODULE_NAME("acpi_container")
48 48
49MODULE_AUTHOR("Anil S Keshavamurthy"); 49 MODULE_AUTHOR("Anil S Keshavamurthy");
50MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME); 50MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
@@ -56,41 +56,38 @@ static int acpi_container_add(struct acpi_device *device);
56static int acpi_container_remove(struct acpi_device *device, int type); 56static int acpi_container_remove(struct acpi_device *device, int type);
57 57
58static struct acpi_driver acpi_container_driver = { 58static struct acpi_driver acpi_container_driver = {
59 .name = ACPI_CONTAINER_DRIVER_NAME, 59 .name = ACPI_CONTAINER_DRIVER_NAME,
60 .class = ACPI_CONTAINER_CLASS, 60 .class = ACPI_CONTAINER_CLASS,
61 .ids = "ACPI0004,PNP0A05,PNP0A06", 61 .ids = "ACPI0004,PNP0A05,PNP0A06",
62 .ops = { 62 .ops = {
63 .add = acpi_container_add, 63 .add = acpi_container_add,
64 .remove = acpi_container_remove, 64 .remove = acpi_container_remove,
65 }, 65 },
66}; 66};
67 67
68
69/*******************************************************************/ 68/*******************************************************************/
70 69
71static int 70static int is_device_present(acpi_handle handle)
72is_device_present(acpi_handle handle)
73{ 71{
74 acpi_handle temp; 72 acpi_handle temp;
75 acpi_status status; 73 acpi_status status;
76 unsigned long sta; 74 unsigned long sta;
77 75
78 ACPI_FUNCTION_TRACE("is_device_present"); 76 ACPI_FUNCTION_TRACE("is_device_present");
79 77
80 status = acpi_get_handle(handle, "_STA", &temp); 78 status = acpi_get_handle(handle, "_STA", &temp);
81 if (ACPI_FAILURE(status)) 79 if (ACPI_FAILURE(status))
82 return_VALUE(1); /* _STA not found, assmue device present */ 80 return_VALUE(1); /* _STA not found, assmue device present */
83 81
84 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 82 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
85 if (ACPI_FAILURE(status)) 83 if (ACPI_FAILURE(status))
86 return_VALUE(0); /* Firmware error */ 84 return_VALUE(0); /* Firmware error */
87 85
88 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); 86 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
89} 87}
90 88
91/*******************************************************************/ 89/*******************************************************************/
92static int 90static int acpi_container_add(struct acpi_device *device)
93acpi_container_add(struct acpi_device *device)
94{ 91{
95 struct acpi_container *container; 92 struct acpi_container *container;
96 93
@@ -102,28 +99,26 @@ acpi_container_add(struct acpi_device *device)
102 } 99 }
103 100
104 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); 101 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
105 if(!container) 102 if (!container)
106 return_VALUE(-ENOMEM); 103 return_VALUE(-ENOMEM);
107 104
108 memset(container, 0, sizeof(struct acpi_container)); 105 memset(container, 0, sizeof(struct acpi_container));
109 container->handle = device->handle; 106 container->handle = device->handle;
110 strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); 107 strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
111 strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); 108 strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
112 acpi_driver_data(device) = container; 109 acpi_driver_data(device) = container;
113 110
114 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", \ 111 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
115 acpi_device_name(device), acpi_device_bid(device))); 112 acpi_device_name(device), acpi_device_bid(device)));
116
117 113
118 return_VALUE(0); 114 return_VALUE(0);
119} 115}
120 116
121static int 117static int acpi_container_remove(struct acpi_device *device, int type)
122acpi_container_remove(struct acpi_device *device, int type)
123{ 118{
124 acpi_status status = AE_OK; 119 acpi_status status = AE_OK;
125 struct acpi_container *pc = NULL; 120 struct acpi_container *pc = NULL;
126 pc = (struct acpi_container*) acpi_driver_data(device); 121 pc = (struct acpi_container *)acpi_driver_data(device);
127 122
128 if (pc) 123 if (pc)
129 kfree(pc); 124 kfree(pc);
@@ -131,9 +126,7 @@ acpi_container_remove(struct acpi_device *device, int type)
131 return status; 126 return status;
132} 127}
133 128
134 129static int container_device_add(struct acpi_device **device, acpi_handle handle)
135static int
136container_device_add(struct acpi_device **device, acpi_handle handle)
137{ 130{
138 acpi_handle phandle; 131 acpi_handle phandle;
139 struct acpi_device *pdev; 132 struct acpi_device *pdev;
@@ -158,10 +151,9 @@ container_device_add(struct acpi_device **device, acpi_handle handle)
158 return_VALUE(result); 151 return_VALUE(result);
159} 152}
160 153
161static void 154static void container_notify_cb(acpi_handle handle, u32 type, void *context)
162container_notify_cb(acpi_handle handle, u32 type, void *context)
163{ 155{
164 struct acpi_device *device = NULL; 156 struct acpi_device *device = NULL;
165 int result; 157 int result;
166 int present; 158 int present;
167 acpi_status status; 159 acpi_status status;
@@ -169,14 +161,14 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
169 ACPI_FUNCTION_TRACE("container_notify_cb"); 161 ACPI_FUNCTION_TRACE("container_notify_cb");
170 162
171 present = is_device_present(handle); 163 present = is_device_present(handle);
172 164
173 switch (type) { 165 switch (type) {
174 case ACPI_NOTIFY_BUS_CHECK: 166 case ACPI_NOTIFY_BUS_CHECK:
175 /* Fall through */ 167 /* Fall through */
176 case ACPI_NOTIFY_DEVICE_CHECK: 168 case ACPI_NOTIFY_DEVICE_CHECK:
177 printk("Container driver received %s event\n", 169 printk("Container driver received %s event\n",
178 (type == ACPI_NOTIFY_BUS_CHECK)? 170 (type == ACPI_NOTIFY_BUS_CHECK) ?
179 "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); 171 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
180 status = acpi_bus_get_device(handle, &device); 172 status = acpi_bus_get_device(handle, &device);
181 if (present) { 173 if (present) {
182 if (ACPI_FAILURE(status) || !device) { 174 if (ACPI_FAILURE(status) || !device) {
@@ -207,15 +199,13 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
207 199
208static acpi_status 200static acpi_status
209container_walk_namespace_cb(acpi_handle handle, 201container_walk_namespace_cb(acpi_handle handle,
210 u32 lvl, 202 u32 lvl, void *context, void **rv)
211 void *context,
212 void **rv)
213{ 203{
214 char *hid = NULL; 204 char *hid = NULL;
215 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 205 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
216 struct acpi_device_info *info; 206 struct acpi_device_info *info;
217 acpi_status status; 207 acpi_status status;
218 int *action = context; 208 int *action = context;
219 209
220 ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); 210 ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
221 211
@@ -233,66 +223,60 @@ container_walk_namespace_cb(acpi_handle handle,
233 } 223 }
234 224
235 if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") && 225 if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") &&
236 strcmp(hid, "PNP0A06")) { 226 strcmp(hid, "PNP0A06")) {
237 goto end; 227 goto end;
238 } 228 }
239 229
240 switch(*action) { 230 switch (*action) {
241 case INSTALL_NOTIFY_HANDLER: 231 case INSTALL_NOTIFY_HANDLER:
242 acpi_install_notify_handler(handle, 232 acpi_install_notify_handler(handle,
243 ACPI_SYSTEM_NOTIFY, 233 ACPI_SYSTEM_NOTIFY,
244 container_notify_cb, 234 container_notify_cb, NULL);
245 NULL);
246 break; 235 break;
247 case UNINSTALL_NOTIFY_HANDLER: 236 case UNINSTALL_NOTIFY_HANDLER:
248 acpi_remove_notify_handler(handle, 237 acpi_remove_notify_handler(handle,
249 ACPI_SYSTEM_NOTIFY, 238 ACPI_SYSTEM_NOTIFY,
250 container_notify_cb); 239 container_notify_cb);
251 break; 240 break;
252 default: 241 default:
253 break; 242 break;
254 } 243 }
255 244
256end: 245 end:
257 acpi_os_free(buffer.pointer); 246 acpi_os_free(buffer.pointer);
258 247
259 return_ACPI_STATUS(AE_OK); 248 return_ACPI_STATUS(AE_OK);
260} 249}
261 250
262 251static int __init acpi_container_init(void)
263static int __init
264acpi_container_init(void)
265{ 252{
266 int result = 0; 253 int result = 0;
267 int action = INSTALL_NOTIFY_HANDLER; 254 int action = INSTALL_NOTIFY_HANDLER;
268 255
269 result = acpi_bus_register_driver(&acpi_container_driver); 256 result = acpi_bus_register_driver(&acpi_container_driver);
270 if (result < 0) { 257 if (result < 0) {
271 return(result); 258 return (result);
272 } 259 }
273 260
274 /* register notify handler to every container device */ 261 /* register notify handler to every container device */
275 acpi_walk_namespace(ACPI_TYPE_DEVICE, 262 acpi_walk_namespace(ACPI_TYPE_DEVICE,
276 ACPI_ROOT_OBJECT, 263 ACPI_ROOT_OBJECT,
277 ACPI_UINT32_MAX, 264 ACPI_UINT32_MAX,
278 container_walk_namespace_cb, 265 container_walk_namespace_cb, &action, NULL);
279 &action, NULL);
280 266
281 return(0); 267 return (0);
282} 268}
283 269
284static void __exit 270static void __exit acpi_container_exit(void)
285acpi_container_exit(void)
286{ 271{
287 int action = UNINSTALL_NOTIFY_HANDLER; 272 int action = UNINSTALL_NOTIFY_HANDLER;
288 273
289 ACPI_FUNCTION_TRACE("acpi_container_exit"); 274 ACPI_FUNCTION_TRACE("acpi_container_exit");
290 275
291 acpi_walk_namespace(ACPI_TYPE_DEVICE, 276 acpi_walk_namespace(ACPI_TYPE_DEVICE,
292 ACPI_ROOT_OBJECT, 277 ACPI_ROOT_OBJECT,
293 ACPI_UINT32_MAX, 278 ACPI_UINT32_MAX,
294 container_walk_namespace_cb, 279 container_walk_namespace_cb, &action, NULL);
295 &action, NULL);
296 280
297 acpi_bus_unregister_driver(&acpi_container_driver); 281 acpi_bus_unregister_driver(&acpi_container_driver);
298 282
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 2c0dac559f16..263322b7d113 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -12,17 +12,14 @@
12#include <acpi/acglobal.h> 12#include <acpi/acglobal.h>
13 13
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 14#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME ("debug") 15ACPI_MODULE_NAME("debug")
16
17#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" 16#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
18#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" 17#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
19
20#ifdef MODULE_PARAM_PREFIX 18#ifdef MODULE_PARAM_PREFIX
21#undef MODULE_PARAM_PREFIX 19#undef MODULE_PARAM_PREFIX
22#endif 20#endif
23
24#define MODULE_PARAM_PREFIX 21#define MODULE_PARAM_PREFIX
25module_param(acpi_dbg_layer, uint, 0400); 22 module_param(acpi_dbg_layer, uint, 0400);
26module_param(acpi_dbg_level, uint, 0400); 23module_param(acpi_dbg_level, uint, 0400);
27 24
28struct acpi_dlayer { 25struct acpi_dlayer {
@@ -35,8 +32,7 @@ struct acpi_dlevel {
35}; 32};
36#define ACPI_DEBUG_INIT(v) { .name = #v, .value = v } 33#define ACPI_DEBUG_INIT(v) { .name = #v, .value = v }
37 34
38static const struct acpi_dlayer acpi_debug_layers[] = 35static const struct acpi_dlayer acpi_debug_layers[] = {
39{
40 ACPI_DEBUG_INIT(ACPI_UTILITIES), 36 ACPI_DEBUG_INIT(ACPI_UTILITIES),
41 ACPI_DEBUG_INIT(ACPI_HARDWARE), 37 ACPI_DEBUG_INIT(ACPI_HARDWARE),
42 ACPI_DEBUG_INIT(ACPI_EVENTS), 38 ACPI_DEBUG_INIT(ACPI_EVENTS),
@@ -53,8 +49,7 @@ static const struct acpi_dlayer acpi_debug_layers[] =
53 ACPI_DEBUG_INIT(ACPI_TOOLS), 49 ACPI_DEBUG_INIT(ACPI_TOOLS),
54}; 50};
55 51
56static const struct acpi_dlevel acpi_debug_levels[] = 52static const struct acpi_dlevel acpi_debug_levels[] = {
57{
58 ACPI_DEBUG_INIT(ACPI_LV_ERROR), 53 ACPI_DEBUG_INIT(ACPI_LV_ERROR),
59 ACPI_DEBUG_INIT(ACPI_LV_WARN), 54 ACPI_DEBUG_INIT(ACPI_LV_WARN),
60 ACPI_DEBUG_INIT(ACPI_LV_INIT), 55 ACPI_DEBUG_INIT(ACPI_LV_INIT),
@@ -88,81 +83,77 @@ static const struct acpi_dlevel acpi_debug_levels[] =
88 ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE), 83 ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE),
89 ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO), 84 ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO),
90 ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES), 85 ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
91 ACPI_DEBUG_INIT(ACPI_LV_EVENTS), 86 ACPI_DEBUG_INIT(ACPI_LV_EVENTS),
92}; 87};
93 88
94static int 89static int
95acpi_system_read_debug ( 90acpi_system_read_debug(char *page,
96 char *page, 91 char **start, off_t off, int count, int *eof, void *data)
97 char **start,
98 off_t off,
99 int count,
100 int *eof,
101 void *data)
102{ 92{
103 char *p = page; 93 char *p = page;
104 int size = 0; 94 int size = 0;
105 unsigned int i; 95 unsigned int i;
106 96
107 if (off != 0) 97 if (off != 0)
108 goto end; 98 goto end;
109 99
110 p += sprintf(p, "%-25s\tHex SET\n", "Description"); 100 p += sprintf(p, "%-25s\tHex SET\n", "Description");
111 101
112 switch ((unsigned long) data) { 102 switch ((unsigned long)data) {
113 case 0: 103 case 0:
114 for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { 104 for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
115 p += sprintf(p, "%-25s\t0x%08lX [%c]\n", 105 p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
116 acpi_debug_layers[i].name, 106 acpi_debug_layers[i].name,
117 acpi_debug_layers[i].value, 107 acpi_debug_layers[i].value,
118 (acpi_dbg_layer & acpi_debug_layers[i].value) ? 108 (acpi_dbg_layer & acpi_debug_layers[i].
119 '*' : ' '); 109 value) ? '*' : ' ');
120 } 110 }
121 p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", 111 p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
122 ACPI_ALL_DRIVERS, 112 ACPI_ALL_DRIVERS,
123 (acpi_dbg_layer & ACPI_ALL_DRIVERS) == ACPI_ALL_DRIVERS? 113 (acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
124 '*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 0 ? 114 ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer &
125 ' ' : '-'); 115 ACPI_ALL_DRIVERS) ==
116 0 ? ' ' : '-');
126 p += sprintf(p, 117 p += sprintf(p,
127 "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", 118 "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
128 acpi_dbg_layer); 119 acpi_dbg_layer);
129 break; 120 break;
130 case 1: 121 case 1:
131 for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { 122 for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
132 p += sprintf(p, "%-25s\t0x%08lX [%c]\n", 123 p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
133 acpi_debug_levels[i].name, 124 acpi_debug_levels[i].name,
134 acpi_debug_levels[i].value, 125 acpi_debug_levels[i].value,
135 (acpi_dbg_level & acpi_debug_levels[i].value) ? 126 (acpi_dbg_level & acpi_debug_levels[i].
136 '*' : ' '); 127 value) ? '*' : ' ');
137 } 128 }
138 p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n", 129 p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n",
139 acpi_dbg_level); 130 acpi_dbg_level);
140 break; 131 break;
141 default: 132 default:
142 p += sprintf(p, "Invalid debug option\n"); 133 p += sprintf(p, "Invalid debug option\n");
143 break; 134 break;
144 } 135 }
145 136
146end: 137 end:
147 size = (p - page); 138 size = (p - page);
148 if (size <= off+count) *eof = 1; 139 if (size <= off + count)
140 *eof = 1;
149 *start = page + off; 141 *start = page + off;
150 size -= off; 142 size -= off;
151 if (size>count) size = count; 143 if (size > count)
152 if (size<0) size = 0; 144 size = count;
145 if (size < 0)
146 size = 0;
153 147
154 return size; 148 return size;
155} 149}
156 150
157
158static int 151static int
159acpi_system_write_debug ( 152acpi_system_write_debug(struct file *file,
160 struct file *file, 153 const char __user * buffer,
161 const char __user *buffer, 154 unsigned long count, void *data)
162 unsigned long count,
163 void *data)
164{ 155{
165 char debug_string[12] = {'\0'}; 156 char debug_string[12] = { '\0' };
166 157
167 ACPI_FUNCTION_TRACE("acpi_system_write_debug"); 158 ACPI_FUNCTION_TRACE("acpi_system_write_debug");
168 159
@@ -174,7 +165,7 @@ acpi_system_write_debug (
174 165
175 debug_string[count] = '\0'; 166 debug_string[count] = '\0';
176 167
177 switch ((unsigned long) data) { 168 switch ((unsigned long)data) {
178 case 0: 169 case 0:
179 acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); 170 acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
180 break; 171 break;
@@ -190,9 +181,9 @@ acpi_system_write_debug (
190 181
191static int __init acpi_debug_init(void) 182static int __init acpi_debug_init(void)
192{ 183{
193 struct proc_dir_entry *entry; 184 struct proc_dir_entry *entry;
194 int error = 0; 185 int error = 0;
195 char * name; 186 char *name;
196 187
197 ACPI_FUNCTION_TRACE("acpi_debug_init"); 188 ACPI_FUNCTION_TRACE("acpi_debug_init");
198 189
@@ -201,8 +192,10 @@ static int __init acpi_debug_init(void)
201 192
202 /* 'debug_layer' [R/W] */ 193 /* 'debug_layer' [R/W] */
203 name = ACPI_SYSTEM_FILE_DEBUG_LAYER; 194 name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
204 entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir, 195 entry =
205 acpi_system_read_debug,(void *)0); 196 create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
197 acpi_root_dir, acpi_system_read_debug,
198 (void *)0);
206 if (entry) 199 if (entry)
207 entry->write_proc = acpi_system_write_debug; 200 entry->write_proc = acpi_system_write_debug;
208 else 201 else
@@ -210,19 +203,21 @@ static int __init acpi_debug_init(void)
210 203
211 /* 'debug_level' [R/W] */ 204 /* 'debug_level' [R/W] */
212 name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; 205 name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
213 entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir, 206 entry =
214 acpi_system_read_debug, (void *)1); 207 create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
215 if (entry) 208 acpi_root_dir, acpi_system_read_debug,
209 (void *)1);
210 if (entry)
216 entry->write_proc = acpi_system_write_debug; 211 entry->write_proc = acpi_system_write_debug;
217 else 212 else
218 goto Error; 213 goto Error;
219 214
220 Done: 215 Done:
221 return_VALUE(error); 216 return_VALUE(error);
222 217
223 Error: 218 Error:
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
225 "Unable to create '%s' proc fs entry\n", name)); 220 "Unable to create '%s' proc fs entry\n", name));
226 221
227 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); 222 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
228 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); 223 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
index 84193983d6ba..2022aeaecfbb 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/dispatcher/dsfield.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
@@ -49,18 +48,14 @@
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50#include <acpi/acparser.h> 49#include <acpi/acparser.h>
51 50
52
53#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
54 ACPI_MODULE_NAME ("dsfield") 52ACPI_MODULE_NAME("dsfield")
55 53
56/* Local prototypes */ 54/* Local prototypes */
57
58static acpi_status 55static acpi_status
59acpi_ds_get_field_names ( 56acpi_ds_get_field_names(struct acpi_create_field_info *info,
60 struct acpi_create_field_info *info, 57 struct acpi_walk_state *walk_state,
61 struct acpi_walk_state *walk_state, 58 union acpi_parse_object *arg);
62 union acpi_parse_object *arg);
63
64 59
65/******************************************************************************* 60/*******************************************************************************
66 * 61 *
@@ -82,41 +77,36 @@ acpi_ds_get_field_names (
82 ******************************************************************************/ 77 ******************************************************************************/
83 78
84acpi_status 79acpi_status
85acpi_ds_create_buffer_field ( 80acpi_ds_create_buffer_field(union acpi_parse_object *op,
86 union acpi_parse_object *op, 81 struct acpi_walk_state *walk_state)
87 struct acpi_walk_state *walk_state)
88{ 82{
89 union acpi_parse_object *arg; 83 union acpi_parse_object *arg;
90 struct acpi_namespace_node *node; 84 struct acpi_namespace_node *node;
91 acpi_status status; 85 acpi_status status;
92 union acpi_operand_object *obj_desc; 86 union acpi_operand_object *obj_desc;
93 union acpi_operand_object *second_desc = NULL; 87 union acpi_operand_object *second_desc = NULL;
94 u32 flags; 88 u32 flags;
95
96
97 ACPI_FUNCTION_TRACE ("ds_create_buffer_field");
98 89
90 ACPI_FUNCTION_TRACE("ds_create_buffer_field");
99 91
100 /* Get the name_string argument */ 92 /* Get the name_string argument */
101 93
102 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { 94 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
103 arg = acpi_ps_get_arg (op, 3); 95 arg = acpi_ps_get_arg(op, 3);
104 } 96 } else {
105 else {
106 /* Create Bit/Byte/Word/Dword field */ 97 /* Create Bit/Byte/Word/Dword field */
107 98
108 arg = acpi_ps_get_arg (op, 2); 99 arg = acpi_ps_get_arg(op, 2);
109 } 100 }
110 101
111 if (!arg) { 102 if (!arg) {
112 return_ACPI_STATUS (AE_AML_NO_OPERAND); 103 return_ACPI_STATUS(AE_AML_NO_OPERAND);
113 } 104 }
114 105
115 if (walk_state->deferred_node) { 106 if (walk_state->deferred_node) {
116 node = walk_state->deferred_node; 107 node = walk_state->deferred_node;
117 status = AE_OK; 108 status = AE_OK;
118 } 109 } else {
119 else {
120 /* 110 /*
121 * During the load phase, we want to enter the name of the field into 111 * During the load phase, we want to enter the name of the field into
122 * the namespace. During the execute phase (when we evaluate the size 112 * the namespace. During the execute phase (when we evaluate the size
@@ -124,21 +114,22 @@ acpi_ds_create_buffer_field (
124 */ 114 */
125 if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) { 115 if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
126 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; 116 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
127 } 117 } else {
128 else {
129 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 118 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
130 ACPI_NS_ERROR_IF_FOUND; 119 ACPI_NS_ERROR_IF_FOUND;
131 } 120 }
132 121
133 /* 122 /*
134 * Enter the name_string into the namespace 123 * Enter the name_string into the namespace
135 */ 124 */
136 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 125 status =
137 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, 126 acpi_ns_lookup(walk_state->scope_info,
138 flags, walk_state, &(node)); 127 arg->common.value.string, ACPI_TYPE_ANY,
139 if (ACPI_FAILURE (status)) { 128 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
140 ACPI_REPORT_NSERROR (arg->common.value.string, status); 129 &(node));
141 return_ACPI_STATUS (status); 130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_NSERROR(arg->common.value.string, status);
132 return_ACPI_STATUS(status);
142 } 133 }
143 } 134 }
144 135
@@ -153,9 +144,9 @@ acpi_ds_create_buffer_field (
153 * and we need to create the field object. Otherwise, this was a lookup 144 * and we need to create the field object. Otherwise, this was a lookup
154 * of an existing node and we don't want to create the field object again. 145 * of an existing node and we don't want to create the field object again.
155 */ 146 */
156 obj_desc = acpi_ns_get_attached_object (node); 147 obj_desc = acpi_ns_get_attached_object(node);
157 if (obj_desc) { 148 if (obj_desc) {
158 return_ACPI_STATUS (AE_OK); 149 return_ACPI_STATUS(AE_OK);
159 } 150 }
160 151
161 /* 152 /*
@@ -165,7 +156,7 @@ acpi_ds_create_buffer_field (
165 156
166 /* Create the buffer field object */ 157 /* Create the buffer field object */
167 158
168 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD); 159 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD);
169 if (!obj_desc) { 160 if (!obj_desc) {
170 status = AE_NO_MEMORY; 161 status = AE_NO_MEMORY;
171 goto cleanup; 162 goto cleanup;
@@ -176,28 +167,26 @@ acpi_ds_create_buffer_field (
176 * opcode and operands -- since the buffer and index 167 * opcode and operands -- since the buffer and index
177 * operands must be evaluated. 168 * operands must be evaluated.
178 */ 169 */
179 second_desc = obj_desc->common.next_object; 170 second_desc = obj_desc->common.next_object;
180 second_desc->extra.aml_start = op->named.data; 171 second_desc->extra.aml_start = op->named.data;
181 second_desc->extra.aml_length = op->named.length; 172 second_desc->extra.aml_length = op->named.length;
182 obj_desc->buffer_field.node = node; 173 obj_desc->buffer_field.node = node;
183 174
184 /* Attach constructed field descriptors to parent node */ 175 /* Attach constructed field descriptors to parent node */
185 176
186 status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD); 177 status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
187 if (ACPI_FAILURE (status)) { 178 if (ACPI_FAILURE(status)) {
188 goto cleanup; 179 goto cleanup;
189 } 180 }
190 181
191 182 cleanup:
192cleanup:
193 183
194 /* Remove local reference to the object */ 184 /* Remove local reference to the object */
195 185
196 acpi_ut_remove_reference (obj_desc); 186 acpi_ut_remove_reference(obj_desc);
197 return_ACPI_STATUS (status); 187 return_ACPI_STATUS(status);
198} 188}
199 189
200
201/******************************************************************************* 190/*******************************************************************************
202 * 191 *
203 * FUNCTION: acpi_ds_get_field_names 192 * FUNCTION: acpi_ds_get_field_names
@@ -214,17 +203,14 @@ cleanup:
214 ******************************************************************************/ 203 ******************************************************************************/
215 204
216static acpi_status 205static acpi_status
217acpi_ds_get_field_names ( 206acpi_ds_get_field_names(struct acpi_create_field_info *info,
218 struct acpi_create_field_info *info, 207 struct acpi_walk_state *walk_state,
219 struct acpi_walk_state *walk_state, 208 union acpi_parse_object *arg)
220 union acpi_parse_object *arg)
221{ 209{
222 acpi_status status; 210 acpi_status status;
223 acpi_integer position; 211 acpi_integer position;
224
225
226 ACPI_FUNCTION_TRACE_PTR ("ds_get_field_names", info);
227 212
213 ACPI_FUNCTION_TRACE_PTR("ds_get_field_names", info);
228 214
229 /* First field starts at bit zero */ 215 /* First field starts at bit zero */
230 216
@@ -243,18 +229,16 @@ acpi_ds_get_field_names (
243 case AML_INT_RESERVEDFIELD_OP: 229 case AML_INT_RESERVEDFIELD_OP:
244 230
245 position = (acpi_integer) info->field_bit_position 231 position = (acpi_integer) info->field_bit_position
246 + (acpi_integer) arg->common.value.size; 232 + (acpi_integer) arg->common.value.size;
247 233
248 if (position > ACPI_UINT32_MAX) { 234 if (position > ACPI_UINT32_MAX) {
249 ACPI_REPORT_ERROR (( 235 ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n"));
250 "Bit offset within field too large (> 0xFFFFFFFF)\n")); 236 return_ACPI_STATUS(AE_SUPPORT);
251 return_ACPI_STATUS (AE_SUPPORT);
252 } 237 }
253 238
254 info->field_bit_position = (u32) position; 239 info->field_bit_position = (u32) position;
255 break; 240 break;
256 241
257
258 case AML_INT_ACCESSFIELD_OP: 242 case AML_INT_ACCESSFIELD_OP:
259 243
260 /* 244 /*
@@ -266,73 +250,70 @@ acpi_ds_get_field_names (
266 * ACCESS_TYPE bits 250 * ACCESS_TYPE bits
267 */ 251 */
268 info->field_flags = (u8) 252 info->field_flags = (u8)
269 ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | 253 ((info->
270 ((u8) ((u32) arg->common.value.integer >> 8))); 254 field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
255 ((u8) ((u32) arg->common.value.integer >> 8)));
271 256
272 info->attribute = (u8) (arg->common.value.integer); 257 info->attribute = (u8) (arg->common.value.integer);
273 break; 258 break;
274 259
275
276 case AML_INT_NAMEDFIELD_OP: 260 case AML_INT_NAMEDFIELD_OP:
277 261
278 /* Lookup the name */ 262 /* Lookup the name */
279 263
280 status = acpi_ns_lookup (walk_state->scope_info, 264 status = acpi_ns_lookup(walk_state->scope_info,
281 (char *) &arg->named.name, 265 (char *)&arg->named.name,
282 info->field_type, ACPI_IMODE_EXECUTE, 266 info->field_type,
283 ACPI_NS_DONT_OPEN_SCOPE, 267 ACPI_IMODE_EXECUTE,
284 walk_state, &info->field_node); 268 ACPI_NS_DONT_OPEN_SCOPE,
285 if (ACPI_FAILURE (status)) { 269 walk_state, &info->field_node);
286 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); 270 if (ACPI_FAILURE(status)) {
271 ACPI_REPORT_NSERROR((char *)&arg->named.name,
272 status);
287 if (status != AE_ALREADY_EXISTS) { 273 if (status != AE_ALREADY_EXISTS) {
288 return_ACPI_STATUS (status); 274 return_ACPI_STATUS(status);
289 } 275 }
290 276
291 /* Already exists, ignore error */ 277 /* Already exists, ignore error */
292 } 278 } else {
293 else {
294 arg->common.node = info->field_node; 279 arg->common.node = info->field_node;
295 info->field_bit_length = arg->common.value.size; 280 info->field_bit_length = arg->common.value.size;
296 281
297 /* Create and initialize an object for the new Field Node */ 282 /* Create and initialize an object for the new Field Node */
298 283
299 status = acpi_ex_prep_field_value (info); 284 status = acpi_ex_prep_field_value(info);
300 if (ACPI_FAILURE (status)) { 285 if (ACPI_FAILURE(status)) {
301 return_ACPI_STATUS (status); 286 return_ACPI_STATUS(status);
302 } 287 }
303 } 288 }
304 289
305 /* Keep track of bit position for the next field */ 290 /* Keep track of bit position for the next field */
306 291
307 position = (acpi_integer) info->field_bit_position 292 position = (acpi_integer) info->field_bit_position
308 + (acpi_integer) arg->common.value.size; 293 + (acpi_integer) arg->common.value.size;
309 294
310 if (position > ACPI_UINT32_MAX) { 295 if (position > ACPI_UINT32_MAX) {
311 ACPI_REPORT_ERROR (( 296 ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name));
312 "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", 297 return_ACPI_STATUS(AE_SUPPORT);
313 (char *) &info->field_node->name));
314 return_ACPI_STATUS (AE_SUPPORT);
315 } 298 }
316 299
317 info->field_bit_position += info->field_bit_length; 300 info->field_bit_position += info->field_bit_length;
318 break; 301 break;
319 302
320
321 default: 303 default:
322 304
323 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Invalid opcode in field list: %X\n", 306 "Invalid opcode in field list: %X\n",
325 arg->common.aml_opcode)); 307 arg->common.aml_opcode));
326 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 308 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
327 } 309 }
328 310
329 arg = arg->common.next; 311 arg = arg->common.next;
330 } 312 }
331 313
332 return_ACPI_STATUS (AE_OK); 314 return_ACPI_STATUS(AE_OK);
333} 315}
334 316
335
336/******************************************************************************* 317/*******************************************************************************
337 * 318 *
338 * FUNCTION: acpi_ds_create_field 319 * FUNCTION: acpi_ds_create_field
@@ -348,29 +329,28 @@ acpi_ds_get_field_names (
348 ******************************************************************************/ 329 ******************************************************************************/
349 330
350acpi_status 331acpi_status
351acpi_ds_create_field ( 332acpi_ds_create_field(union acpi_parse_object *op,
352 union acpi_parse_object *op, 333 struct acpi_namespace_node *region_node,
353 struct acpi_namespace_node *region_node, 334 struct acpi_walk_state *walk_state)
354 struct acpi_walk_state *walk_state)
355{ 335{
356 acpi_status status; 336 acpi_status status;
357 union acpi_parse_object *arg; 337 union acpi_parse_object *arg;
358 struct acpi_create_field_info info; 338 struct acpi_create_field_info info;
359
360
361 ACPI_FUNCTION_TRACE_PTR ("ds_create_field", op);
362 339
340 ACPI_FUNCTION_TRACE_PTR("ds_create_field", op);
363 341
364 /* First arg is the name of the parent op_region (must already exist) */ 342 /* First arg is the name of the parent op_region (must already exist) */
365 343
366 arg = op->common.value.arg; 344 arg = op->common.value.arg;
367 if (!region_node) { 345 if (!region_node) {
368 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name, 346 status =
369 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 347 acpi_ns_lookup(walk_state->scope_info,
370 ACPI_NS_SEARCH_PARENT, walk_state, &region_node); 348 arg->common.value.name, ACPI_TYPE_REGION,
371 if (ACPI_FAILURE (status)) { 349 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
372 ACPI_REPORT_NSERROR (arg->common.value.name, status); 350 walk_state, &region_node);
373 return_ACPI_STATUS (status); 351 if (ACPI_FAILURE(status)) {
352 ACPI_REPORT_NSERROR(arg->common.value.name, status);
353 return_ACPI_STATUS(status);
374 } 354 }
375 } 355 }
376 356
@@ -385,12 +365,11 @@ acpi_ds_create_field (
385 info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD; 365 info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
386 info.region_node = region_node; 366 info.region_node = region_node;
387 367
388 status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); 368 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
389 369
390 return_ACPI_STATUS (status); 370 return_ACPI_STATUS(status);
391} 371}
392 372
393
394/******************************************************************************* 373/*******************************************************************************
395 * 374 *
396 * FUNCTION: acpi_ds_init_field_objects 375 * FUNCTION: acpi_ds_init_field_objects
@@ -407,37 +386,34 @@ acpi_ds_create_field (
407 ******************************************************************************/ 386 ******************************************************************************/
408 387
409acpi_status 388acpi_status
410acpi_ds_init_field_objects ( 389acpi_ds_init_field_objects(union acpi_parse_object *op,
411 union acpi_parse_object *op, 390 struct acpi_walk_state *walk_state)
412 struct acpi_walk_state *walk_state)
413{ 391{
414 acpi_status status; 392 acpi_status status;
415 union acpi_parse_object *arg = NULL; 393 union acpi_parse_object *arg = NULL;
416 struct acpi_namespace_node *node; 394 struct acpi_namespace_node *node;
417 u8 type = 0; 395 u8 type = 0;
418
419
420 ACPI_FUNCTION_TRACE_PTR ("ds_init_field_objects", op);
421 396
397 ACPI_FUNCTION_TRACE_PTR("ds_init_field_objects", op);
422 398
423 switch (walk_state->opcode) { 399 switch (walk_state->opcode) {
424 case AML_FIELD_OP: 400 case AML_FIELD_OP:
425 arg = acpi_ps_get_arg (op, 2); 401 arg = acpi_ps_get_arg(op, 2);
426 type = ACPI_TYPE_LOCAL_REGION_FIELD; 402 type = ACPI_TYPE_LOCAL_REGION_FIELD;
427 break; 403 break;
428 404
429 case AML_BANK_FIELD_OP: 405 case AML_BANK_FIELD_OP:
430 arg = acpi_ps_get_arg (op, 4); 406 arg = acpi_ps_get_arg(op, 4);
431 type = ACPI_TYPE_LOCAL_BANK_FIELD; 407 type = ACPI_TYPE_LOCAL_BANK_FIELD;
432 break; 408 break;
433 409
434 case AML_INDEX_FIELD_OP: 410 case AML_INDEX_FIELD_OP:
435 arg = acpi_ps_get_arg (op, 3); 411 arg = acpi_ps_get_arg(op, 3);
436 type = ACPI_TYPE_LOCAL_INDEX_FIELD; 412 type = ACPI_TYPE_LOCAL_INDEX_FIELD;
437 break; 413 break;
438 414
439 default: 415 default:
440 return_ACPI_STATUS (AE_BAD_PARAMETER); 416 return_ACPI_STATUS(AE_BAD_PARAMETER);
441 } 417 }
442 418
443 /* 419 /*
@@ -447,16 +423,18 @@ acpi_ds_init_field_objects (
447 /* Ignore OFFSET and ACCESSAS terms here */ 423 /* Ignore OFFSET and ACCESSAS terms here */
448 424
449 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { 425 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
450 status = acpi_ns_lookup (walk_state->scope_info, 426 status = acpi_ns_lookup(walk_state->scope_info,
451 (char *) &arg->named.name, 427 (char *)&arg->named.name,
452 type, ACPI_IMODE_LOAD_PASS1, 428 type, ACPI_IMODE_LOAD_PASS1,
453 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 429 ACPI_NS_NO_UPSEARCH |
454 ACPI_NS_ERROR_IF_FOUND, 430 ACPI_NS_DONT_OPEN_SCOPE |
455 walk_state, &node); 431 ACPI_NS_ERROR_IF_FOUND,
456 if (ACPI_FAILURE (status)) { 432 walk_state, &node);
457 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); 433 if (ACPI_FAILURE(status)) {
434 ACPI_REPORT_NSERROR((char *)&arg->named.name,
435 status);
458 if (status != AE_ALREADY_EXISTS) { 436 if (status != AE_ALREADY_EXISTS) {
459 return_ACPI_STATUS (status); 437 return_ACPI_STATUS(status);
460 } 438 }
461 439
462 /* Name already exists, just ignore this error */ 440 /* Name already exists, just ignore this error */
@@ -472,10 +450,9 @@ acpi_ds_init_field_objects (
472 arg = arg->common.next; 450 arg = arg->common.next;
473 } 451 }
474 452
475 return_ACPI_STATUS (AE_OK); 453 return_ACPI_STATUS(AE_OK);
476} 454}
477 455
478
479/******************************************************************************* 456/*******************************************************************************
480 * 457 *
481 * FUNCTION: acpi_ds_create_bank_field 458 * FUNCTION: acpi_ds_create_bank_field
@@ -491,41 +468,42 @@ acpi_ds_init_field_objects (
491 ******************************************************************************/ 468 ******************************************************************************/
492 469
493acpi_status 470acpi_status
494acpi_ds_create_bank_field ( 471acpi_ds_create_bank_field(union acpi_parse_object *op,
495 union acpi_parse_object *op, 472 struct acpi_namespace_node *region_node,
496 struct acpi_namespace_node *region_node, 473 struct acpi_walk_state *walk_state)
497 struct acpi_walk_state *walk_state)
498{ 474{
499 acpi_status status; 475 acpi_status status;
500 union acpi_parse_object *arg; 476 union acpi_parse_object *arg;
501 struct acpi_create_field_info info; 477 struct acpi_create_field_info info;
502
503
504 ACPI_FUNCTION_TRACE_PTR ("ds_create_bank_field", op);
505 478
479 ACPI_FUNCTION_TRACE_PTR("ds_create_bank_field", op);
506 480
507 /* First arg is the name of the parent op_region (must already exist) */ 481 /* First arg is the name of the parent op_region (must already exist) */
508 482
509 arg = op->common.value.arg; 483 arg = op->common.value.arg;
510 if (!region_node) { 484 if (!region_node) {
511 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name, 485 status =
512 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 486 acpi_ns_lookup(walk_state->scope_info,
513 ACPI_NS_SEARCH_PARENT, walk_state, &region_node); 487 arg->common.value.name, ACPI_TYPE_REGION,
514 if (ACPI_FAILURE (status)) { 488 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
515 ACPI_REPORT_NSERROR (arg->common.value.name, status); 489 walk_state, &region_node);
516 return_ACPI_STATUS (status); 490 if (ACPI_FAILURE(status)) {
491 ACPI_REPORT_NSERROR(arg->common.value.name, status);
492 return_ACPI_STATUS(status);
517 } 493 }
518 } 494 }
519 495
520 /* Second arg is the Bank Register (Field) (must already exist) */ 496 /* Second arg is the Bank Register (Field) (must already exist) */
521 497
522 arg = arg->common.next; 498 arg = arg->common.next;
523 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 499 status =
524 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 500 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
525 ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); 501 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
526 if (ACPI_FAILURE (status)) { 502 ACPI_NS_SEARCH_PARENT, walk_state,
527 ACPI_REPORT_NSERROR (arg->common.value.string, status); 503 &info.register_node);
528 return_ACPI_STATUS (status); 504 if (ACPI_FAILURE(status)) {
505 ACPI_REPORT_NSERROR(arg->common.value.string, status);
506 return_ACPI_STATUS(status);
529 } 507 }
530 508
531 /* Third arg is the bank_value */ 509 /* Third arg is the bank_value */
@@ -543,12 +521,11 @@ acpi_ds_create_bank_field (
543 info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD; 521 info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
544 info.region_node = region_node; 522 info.region_node = region_node;
545 523
546 status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); 524 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
547 525
548 return_ACPI_STATUS (status); 526 return_ACPI_STATUS(status);
549} 527}
550 528
551
552/******************************************************************************* 529/*******************************************************************************
553 * 530 *
554 * FUNCTION: acpi_ds_create_index_field 531 * FUNCTION: acpi_ds_create_index_field
@@ -564,39 +541,40 @@ acpi_ds_create_bank_field (
564 ******************************************************************************/ 541 ******************************************************************************/
565 542
566acpi_status 543acpi_status
567acpi_ds_create_index_field ( 544acpi_ds_create_index_field(union acpi_parse_object *op,
568 union acpi_parse_object *op, 545 struct acpi_namespace_node *region_node,
569 struct acpi_namespace_node *region_node, 546 struct acpi_walk_state *walk_state)
570 struct acpi_walk_state *walk_state)
571{ 547{
572 acpi_status status; 548 acpi_status status;
573 union acpi_parse_object *arg; 549 union acpi_parse_object *arg;
574 struct acpi_create_field_info info; 550 struct acpi_create_field_info info;
575
576
577 ACPI_FUNCTION_TRACE_PTR ("ds_create_index_field", op);
578 551
552 ACPI_FUNCTION_TRACE_PTR("ds_create_index_field", op);
579 553
580 /* First arg is the name of the Index register (must already exist) */ 554 /* First arg is the name of the Index register (must already exist) */
581 555
582 arg = op->common.value.arg; 556 arg = op->common.value.arg;
583 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 557 status =
584 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 558 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
585 ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); 559 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
586 if (ACPI_FAILURE (status)) { 560 ACPI_NS_SEARCH_PARENT, walk_state,
587 ACPI_REPORT_NSERROR (arg->common.value.string, status); 561 &info.register_node);
588 return_ACPI_STATUS (status); 562 if (ACPI_FAILURE(status)) {
563 ACPI_REPORT_NSERROR(arg->common.value.string, status);
564 return_ACPI_STATUS(status);
589 } 565 }
590 566
591 /* Second arg is the data register (must already exist) */ 567 /* Second arg is the data register (must already exist) */
592 568
593 arg = arg->common.next; 569 arg = arg->common.next;
594 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 570 status =
595 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 571 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
596 ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node); 572 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
597 if (ACPI_FAILURE (status)) { 573 ACPI_NS_SEARCH_PARENT, walk_state,
598 ACPI_REPORT_NSERROR (arg->common.value.string, status); 574 &info.data_register_node);
599 return_ACPI_STATUS (status); 575 if (ACPI_FAILURE(status)) {
576 ACPI_REPORT_NSERROR(arg->common.value.string, status);
577 return_ACPI_STATUS(status);
600 } 578 }
601 579
602 /* Next arg is the field flags */ 580 /* Next arg is the field flags */
@@ -609,9 +587,7 @@ acpi_ds_create_index_field (
609 info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD; 587 info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
610 info.region_node = region_node; 588 info.region_node = region_node;
611 589
612 status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); 590 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
613 591
614 return_ACPI_STATUS (status); 592 return_ACPI_STATUS(status);
615} 593}
616
617
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index d7790db50178..8693c704aea6 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -41,23 +41,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 45#include <acpi/acdispat.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49#define _COMPONENT ACPI_DISPATCHER 48#define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME ("dsinit") 49ACPI_MODULE_NAME("dsinit")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54static acpi_status 52static acpi_status
55acpi_ds_init_one_object ( 53acpi_ds_init_one_object(acpi_handle obj_handle,
56 acpi_handle obj_handle, 54 u32 level, void *context, void **return_value);
57 u32 level,
58 void *context,
59 void **return_value);
60
61 55
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
@@ -80,26 +74,23 @@ acpi_ds_init_one_object (
80 ******************************************************************************/ 74 ******************************************************************************/
81 75
82static acpi_status 76static acpi_status
83acpi_ds_init_one_object ( 77acpi_ds_init_one_object(acpi_handle obj_handle,
84 acpi_handle obj_handle, 78 u32 level, void *context, void **return_value)
85 u32 level,
86 void *context,
87 void **return_value)
88{ 79{
89 acpi_object_type type; 80 struct acpi_init_walk_info *info =
90 acpi_status status; 81 (struct acpi_init_walk_info *)context;
91 struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; 82 struct acpi_namespace_node *node =
92 83 (struct acpi_namespace_node *)obj_handle;
93 84 acpi_object_type type;
94 ACPI_FUNCTION_NAME ("ds_init_one_object"); 85 acpi_status status;
95 86
87 ACPI_FUNCTION_NAME("ds_init_one_object");
96 88
97 /* 89 /*
98 * We are only interested in objects owned by the table that 90 * We are only interested in NS nodes owned by the table that
99 * was just loaded 91 * was just loaded
100 */ 92 */
101 if (((struct acpi_namespace_node *) obj_handle)->owner_id != 93 if (node->owner_id != info->table_desc->owner_id) {
102 info->table_desc->table_id) {
103 return (AE_OK); 94 return (AE_OK);
104 } 95 }
105 96
@@ -107,33 +98,31 @@ acpi_ds_init_one_object (
107 98
108 /* And even then, we are only interested in a few object types */ 99 /* And even then, we are only interested in a few object types */
109 100
110 type = acpi_ns_get_type (obj_handle); 101 type = acpi_ns_get_type(obj_handle);
111 102
112 switch (type) { 103 switch (type) {
113 case ACPI_TYPE_REGION: 104 case ACPI_TYPE_REGION:
114 105
115 status = acpi_ds_initialize_region (obj_handle); 106 status = acpi_ds_initialize_region(obj_handle);
116 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
117 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 108 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
118 "Region %p [%4.4s] - Init failure, %s\n", 109 "Region %p [%4.4s] - Init failure, %s\n",
119 obj_handle, acpi_ut_get_node_name (obj_handle), 110 obj_handle,
120 acpi_format_exception (status))); 111 acpi_ut_get_node_name(obj_handle),
112 acpi_format_exception(status)));
121 } 113 }
122 114
123 info->op_region_count++; 115 info->op_region_count++;
124 break; 116 break;
125 117
126
127 case ACPI_TYPE_METHOD: 118 case ACPI_TYPE_METHOD:
128 119
129 info->method_count++;
130
131 /* 120 /*
132 * Print a dot for each method unless we are going to print 121 * Print a dot for each method unless we are going to print
133 * the entire pathname 122 * the entire pathname
134 */ 123 */
135 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 124 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
136 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 125 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
137 } 126 }
138 127
139 /* 128 /*
@@ -143,41 +132,32 @@ acpi_ds_init_one_object (
143 * on a per-table basis. Currently, we just use a global for the width. 132 * on a per-table basis. Currently, we just use a global for the width.
144 */ 133 */
145 if (info->table_desc->pointer->revision == 1) { 134 if (info->table_desc->pointer->revision == 1) {
146 ((struct acpi_namespace_node *) obj_handle)->flags |= ANOBJ_DATA_WIDTH_32; 135 node->flags |= ANOBJ_DATA_WIDTH_32;
147 } 136 }
148 137
149 /* 138 /*
150 * Always parse methods to detect errors, we will delete 139 * Always parse methods to detect errors, we will delete
151 * the parse tree below 140 * the parse tree below
152 */ 141 */
153 status = acpi_ds_parse_method (obj_handle); 142 status = acpi_ds_parse_method(obj_handle);
154 if (ACPI_FAILURE (status)) { 143 if (ACPI_FAILURE(status)) {
155 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
156 "Method %p [%4.4s] - parse failure, %s\n", 145 "\n+Method %p [%4.4s] - parse failure, %s\n",
157 obj_handle, acpi_ut_get_node_name (obj_handle), 146 obj_handle,
158 acpi_format_exception (status))); 147 acpi_ut_get_node_name(obj_handle),
148 acpi_format_exception(status)));
159 149
160 /* This parse failed, but we will continue parsing more methods */ 150 /* This parse failed, but we will continue parsing more methods */
161
162 break;
163 } 151 }
164 152
165 /* 153 info->method_count++;
166 * Delete the parse tree. We simply re-parse the method
167 * for every execution since there isn't much overhead
168 */
169 acpi_ns_delete_namespace_subtree (obj_handle);
170 acpi_ns_delete_namespace_by_owner (
171 ((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
172 break; 154 break;
173 155
174
175 case ACPI_TYPE_DEVICE: 156 case ACPI_TYPE_DEVICE:
176 157
177 info->device_count++; 158 info->device_count++;
178 break; 159 break;
179 160
180
181 default: 161 default:
182 break; 162 break;
183 } 163 }
@@ -189,7 +169,6 @@ acpi_ds_init_one_object (
189 return (AE_OK); 169 return (AE_OK);
190} 170}
191 171
192
193/******************************************************************************* 172/*******************************************************************************
194 * 173 *
195 * FUNCTION: acpi_ds_initialize_objects 174 * FUNCTION: acpi_ds_initialize_objects
@@ -205,45 +184,43 @@ acpi_ds_init_one_object (
205 ******************************************************************************/ 184 ******************************************************************************/
206 185
207acpi_status 186acpi_status
208acpi_ds_initialize_objects ( 187acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
209 struct acpi_table_desc *table_desc, 188 struct acpi_namespace_node * start_node)
210 struct acpi_namespace_node *start_node)
211{ 189{
212 acpi_status status; 190 acpi_status status;
213 struct acpi_init_walk_info info; 191 struct acpi_init_walk_info info;
214 192
193 ACPI_FUNCTION_TRACE("ds_initialize_objects");
215 194
216 ACPI_FUNCTION_TRACE ("ds_initialize_objects"); 195 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
196 "**** Starting initialization of namespace objects ****\n"));
197 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
217 198
218 199 info.method_count = 0;
219 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
220 "**** Starting initialization of namespace objects ****\n"));
221 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
222
223 info.method_count = 0;
224 info.op_region_count = 0; 200 info.op_region_count = 0;
225 info.object_count = 0; 201 info.object_count = 0;
226 info.device_count = 0; 202 info.device_count = 0;
227 info.table_desc = table_desc; 203 info.table_desc = table_desc;
228 204
229 /* Walk entire namespace from the supplied root */ 205 /* Walk entire namespace from the supplied root */
230 206
231 status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 207 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
232 acpi_ds_init_one_object, &info, NULL); 208 acpi_ds_init_one_object, &info, NULL);
233 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
234 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n", 210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
235 acpi_format_exception (status))); 211 acpi_format_exception(status)));
236 } 212 }
237 213
238 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 214 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
239 "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", 215 "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
240 table_desc->pointer->signature, table_desc->table_id, info.object_count, 216 table_desc->pointer->signature,
241 info.device_count, info.method_count, info.op_region_count)); 217 table_desc->owner_id, info.object_count,
218 info.device_count, info.method_count,
219 info.op_region_count));
242 220
243 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 221 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
244 "%hd Methods, %hd Regions\n", info.method_count, info.op_region_count)); 222 "%hd Methods, %hd Regions\n", info.method_count,
223 info.op_region_count));
245 224
246 return_ACPI_STATUS (AE_OK); 225 return_ACPI_STATUS(AE_OK);
247} 226}
248
249
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 9fc3f4c033eb..36c1ca0b9adb 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -49,67 +48,57 @@
49#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
50#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
51 50
52
53#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
54 ACPI_MODULE_NAME ("dsmethod") 52ACPI_MODULE_NAME("dsmethod")
55
56 53
57/******************************************************************************* 54/*******************************************************************************
58 * 55 *
59 * FUNCTION: acpi_ds_parse_method 56 * FUNCTION: acpi_ds_parse_method
60 * 57 *
61 * PARAMETERS: obj_handle - Method node 58 * PARAMETERS: Node - Method node
62 * 59 *
63 * RETURN: Status 60 * RETURN: Status
64 * 61 *
65 * DESCRIPTION: Call the parser and parse the AML that is associated with the 62 * DESCRIPTION: Parse the AML that is associated with the method.
66 * method.
67 * 63 *
68 * MUTEX: Assumes parser is locked 64 * MUTEX: Assumes parser is locked
69 * 65 *
70 ******************************************************************************/ 66 ******************************************************************************/
71 67acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
72acpi_status
73acpi_ds_parse_method (
74 acpi_handle obj_handle)
75{ 68{
76 acpi_status status; 69 acpi_status status;
77 union acpi_operand_object *obj_desc; 70 union acpi_operand_object *obj_desc;
78 union acpi_parse_object *op; 71 union acpi_parse_object *op;
79 struct acpi_namespace_node *node; 72 struct acpi_walk_state *walk_state;
80 acpi_owner_id owner_id;
81 struct acpi_walk_state *walk_state;
82
83
84 ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", obj_handle);
85 73
74 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
86 75
87 /* Parameter Validation */ 76 /* Parameter Validation */
88 77
89 if (!obj_handle) { 78 if (!node) {
90 return_ACPI_STATUS (AE_NULL_ENTRY); 79 return_ACPI_STATUS(AE_NULL_ENTRY);
91 } 80 }
92 81
93 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n", 82 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
94 acpi_ut_get_node_name (obj_handle), obj_handle)); 83 "**** Parsing [%4.4s] **** named_obj=%p\n",
84 acpi_ut_get_node_name(node), node));
95 85
96 /* Extract the method object from the method Node */ 86 /* Extract the method object from the method Node */
97 87
98 node = (struct acpi_namespace_node *) obj_handle; 88 obj_desc = acpi_ns_get_attached_object(node);
99 obj_desc = acpi_ns_get_attached_object (node);
100 if (!obj_desc) { 89 if (!obj_desc) {
101 return_ACPI_STATUS (AE_NULL_OBJECT); 90 return_ACPI_STATUS(AE_NULL_OBJECT);
102 } 91 }
103 92
104 /* Create a mutex for the method if there is a concurrency limit */ 93 /* Create a mutex for the method if there is a concurrency limit */
105 94
106 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && 95 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
107 (!obj_desc->method.semaphore)) { 96 (!obj_desc->method.semaphore)) {
108 status = acpi_os_create_semaphore (obj_desc->method.concurrency, 97 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
109 obj_desc->method.concurrency, 98 obj_desc->method.concurrency,
110 &obj_desc->method.semaphore); 99 &obj_desc->method.semaphore);
111 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
113 } 102 }
114 } 103 }
115 104
@@ -117,14 +106,14 @@ acpi_ds_parse_method (
117 * Allocate a new parser op to be the root of the parsed 106 * Allocate a new parser op to be the root of the parsed
118 * method tree 107 * method tree
119 */ 108 */
120 op = acpi_ps_alloc_op (AML_METHOD_OP); 109 op = acpi_ps_alloc_op(AML_METHOD_OP);
121 if (!op) { 110 if (!op) {
122 return_ACPI_STATUS (AE_NO_MEMORY); 111 return_ACPI_STATUS(AE_NO_MEMORY);
123 } 112 }
124 113
125 /* Init new op with the method name and pointer back to the Node */ 114 /* Init new op with the method name and pointer back to the Node */
126 115
127 acpi_ps_set_name (op, node->name.integer); 116 acpi_ps_set_name(op, node->name.integer);
128 op->common.node = node; 117 op->common.node = node;
129 118
130 /* 119 /*
@@ -132,22 +121,27 @@ acpi_ds_parse_method (
132 * objects (such as Operation Regions) can be created during the 121 * objects (such as Operation Regions) can be created during the
133 * first pass parse. 122 * first pass parse.
134 */ 123 */
135 owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); 124 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
136 obj_desc->method.owning_id = owner_id; 125 if (ACPI_FAILURE(status)) {
126 goto cleanup;
127 }
137 128
138 /* Create and initialize a new walk state */ 129 /* Create and initialize a new walk state */
139 130
140 walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL); 131 walk_state =
132 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
133 NULL);
141 if (!walk_state) { 134 if (!walk_state) {
142 return_ACPI_STATUS (AE_NO_MEMORY); 135 status = AE_NO_MEMORY;
136 goto cleanup2;
143 } 137 }
144 138
145 status = acpi_ds_init_aml_walk (walk_state, op, node, 139 status = acpi_ds_init_aml_walk(walk_state, op, node,
146 obj_desc->method.aml_start, 140 obj_desc->method.aml_start,
147 obj_desc->method.aml_length, NULL, 1); 141 obj_desc->method.aml_length, NULL, 1);
148 if (ACPI_FAILURE (status)) { 142 if (ACPI_FAILURE(status)) {
149 acpi_ds_delete_walk_state (walk_state); 143 acpi_ds_delete_walk_state(walk_state);
150 return_ACPI_STATUS (status); 144 goto cleanup2;
151 } 145 }
152 146
153 /* 147 /*
@@ -159,19 +153,30 @@ acpi_ds_parse_method (
159 * method so that operands to the named objects can take on dynamic 153 * method so that operands to the named objects can take on dynamic
160 * run-time values. 154 * run-time values.
161 */ 155 */
162 status = acpi_ps_parse_aml (walk_state); 156 status = acpi_ps_parse_aml(walk_state);
163 if (ACPI_FAILURE (status)) { 157 if (ACPI_FAILURE(status)) {
164 return_ACPI_STATUS (status); 158 goto cleanup2;
165 } 159 }
166 160
167 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 161 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
168 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", 162 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
169 acpi_ut_get_node_name (obj_handle), obj_handle, op)); 163 acpi_ut_get_node_name(node), node, op));
170 164
171 acpi_ps_delete_parse_tree (op); 165 /*
172 return_ACPI_STATUS (status); 166 * Delete the parse tree. We simply re-parse the method for every
173} 167 * execution since there isn't much overhead (compared to keeping lots
168 * of parse trees around)
169 */
170 acpi_ns_delete_namespace_subtree(node);
171 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
172
173 cleanup2:
174 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
174 175
176 cleanup:
177 acpi_ps_delete_parse_tree(op);
178 return_ACPI_STATUS(status);
179}
175 180
176/******************************************************************************* 181/*******************************************************************************
177 * 182 *
@@ -190,19 +195,23 @@ acpi_ds_parse_method (
190 ******************************************************************************/ 195 ******************************************************************************/
191 196
192acpi_status 197acpi_status
193acpi_ds_begin_method_execution ( 198acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
194 struct acpi_namespace_node *method_node, 199 union acpi_operand_object *obj_desc,
195 union acpi_operand_object *obj_desc, 200 struct acpi_namespace_node *calling_method_node)
196 struct acpi_namespace_node *calling_method_node)
197{ 201{
198 acpi_status status = AE_OK; 202 acpi_status status = AE_OK;
199 203
204 ACPI_FUNCTION_TRACE_PTR("ds_begin_method_execution", method_node);
200 205
201 ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node); 206 if (!method_node) {
207 return_ACPI_STATUS(AE_NULL_ENTRY);
208 }
202 209
210 /* Prevent wraparound of thread count */
203 211
204 if (!method_node) { 212 if (obj_desc->method.thread_count == ACPI_UINT8_MAX) {
205 return_ACPI_STATUS (AE_NULL_ENTRY); 213 ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n"));
214 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
206 } 215 }
207 216
208 /* 217 /*
@@ -219,8 +228,9 @@ acpi_ds_begin_method_execution (
219 * thread that is making recursive method calls. 228 * thread that is making recursive method calls.
220 */ 229 */
221 if (method_node == calling_method_node) { 230 if (method_node == calling_method_node) {
222 if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { 231 if (obj_desc->method.thread_count >=
223 return_ACPI_STATUS (AE_AML_METHOD_LIMIT); 232 obj_desc->method.concurrency) {
233 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
224 } 234 }
225 } 235 }
226 236
@@ -228,8 +238,21 @@ acpi_ds_begin_method_execution (
228 * Get a unit from the method semaphore. This releases the 238 * Get a unit from the method semaphore. This releases the
229 * interpreter if we block 239 * interpreter if we block
230 */ 240 */
231 status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore, 241 status =
232 ACPI_WAIT_FOREVER); 242 acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,
243 ACPI_WAIT_FOREVER);
244 }
245
246 /*
247 * Allocate an Owner ID for this method, only if this is the first thread
248 * to begin concurrent execution. We only need one owner_id, even if the
249 * method is invoked recursively.
250 */
251 if (!obj_desc->method.owner_id) {
252 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
253 if (ACPI_FAILURE(status)) {
254 return_ACPI_STATUS(status);
255 }
233 } 256 }
234 257
235 /* 258 /*
@@ -237,10 +260,9 @@ acpi_ds_begin_method_execution (
237 * reentered one more time (even if it is the same thread) 260 * reentered one more time (even if it is the same thread)
238 */ 261 */
239 obj_desc->method.thread_count++; 262 obj_desc->method.thread_count++;
240 return_ACPI_STATUS (status); 263 return_ACPI_STATUS(status);
241} 264}
242 265
243
244/******************************************************************************* 266/*******************************************************************************
245 * 267 *
246 * FUNCTION: acpi_ds_call_control_method 268 * FUNCTION: acpi_ds_call_control_method
@@ -256,101 +278,99 @@ acpi_ds_begin_method_execution (
256 ******************************************************************************/ 278 ******************************************************************************/
257 279
258acpi_status 280acpi_status
259acpi_ds_call_control_method ( 281acpi_ds_call_control_method(struct acpi_thread_state *thread,
260 struct acpi_thread_state *thread, 282 struct acpi_walk_state *this_walk_state,
261 struct acpi_walk_state *this_walk_state, 283 union acpi_parse_object *op)
262 union acpi_parse_object *op)
263{ 284{
264 acpi_status status; 285 acpi_status status;
265 struct acpi_namespace_node *method_node; 286 struct acpi_namespace_node *method_node;
266 struct acpi_walk_state *next_walk_state; 287 struct acpi_walk_state *next_walk_state = NULL;
267 union acpi_operand_object *obj_desc; 288 union acpi_operand_object *obj_desc;
268 struct acpi_parameter_info info; 289 struct acpi_parameter_info info;
269 u32 i; 290 u32 i;
270
271 291
272 ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state); 292 ACPI_FUNCTION_TRACE_PTR("ds_call_control_method", this_walk_state);
273 293
274 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", 294 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
275 this_walk_state->prev_op, this_walk_state)); 295 "Execute method %p, currentstate=%p\n",
296 this_walk_state->prev_op, this_walk_state));
276 297
277 /* 298 /*
278 * Get the namespace entry for the control method we are about to call 299 * Get the namespace entry for the control method we are about to call
279 */ 300 */
280 method_node = this_walk_state->method_call_node; 301 method_node = this_walk_state->method_call_node;
281 if (!method_node) { 302 if (!method_node) {
282 return_ACPI_STATUS (AE_NULL_ENTRY); 303 return_ACPI_STATUS(AE_NULL_ENTRY);
283 } 304 }
284 305
285 obj_desc = acpi_ns_get_attached_object (method_node); 306 obj_desc = acpi_ns_get_attached_object(method_node);
286 if (!obj_desc) { 307 if (!obj_desc) {
287 return_ACPI_STATUS (AE_NULL_OBJECT); 308 return_ACPI_STATUS(AE_NULL_OBJECT);
288 } 309 }
289 310
290 obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
291
292 /* Init for new method, wait on concurrency semaphore */ 311 /* Init for new method, wait on concurrency semaphore */
293 312
294 status = acpi_ds_begin_method_execution (method_node, obj_desc, 313 status = acpi_ds_begin_method_execution(method_node, obj_desc,
295 this_walk_state->method_node); 314 this_walk_state->method_node);
296 if (ACPI_FAILURE (status)) { 315 if (ACPI_FAILURE(status)) {
297 return_ACPI_STATUS (status); 316 goto cleanup;
298 } 317 }
299 318
300 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { 319 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
301 /* 1) Parse: Create a new walk state for the preempting walk */ 320 /* 1) Parse: Create a new walk state for the preempting walk */
302 321
303 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, 322 next_walk_state =
304 op, obj_desc, NULL); 323 acpi_ds_create_walk_state(obj_desc->method.owner_id, op,
324 obj_desc, NULL);
305 if (!next_walk_state) { 325 if (!next_walk_state) {
306 return_ACPI_STATUS (AE_NO_MEMORY); 326 return_ACPI_STATUS(AE_NO_MEMORY);
307 } 327 }
308 328
309 /* Create and init a Root Node */ 329 /* Create and init a Root Node */
310 330
311 op = acpi_ps_create_scope_op (); 331 op = acpi_ps_create_scope_op();
312 if (!op) { 332 if (!op) {
313 status = AE_NO_MEMORY; 333 status = AE_NO_MEMORY;
314 goto cleanup; 334 goto cleanup;
315 } 335 }
316 336
317 status = acpi_ds_init_aml_walk (next_walk_state, op, method_node, 337 status = acpi_ds_init_aml_walk(next_walk_state, op, method_node,
318 obj_desc->method.aml_start, obj_desc->method.aml_length, 338 obj_desc->method.aml_start,
319 NULL, 1); 339 obj_desc->method.aml_length,
320 if (ACPI_FAILURE (status)) { 340 NULL, 1);
321 acpi_ds_delete_walk_state (next_walk_state); 341 if (ACPI_FAILURE(status)) {
342 acpi_ds_delete_walk_state(next_walk_state);
322 goto cleanup; 343 goto cleanup;
323 } 344 }
324 345
325 /* Begin AML parse */ 346 /* Begin AML parse */
326 347
327 status = acpi_ps_parse_aml (next_walk_state); 348 status = acpi_ps_parse_aml(next_walk_state);
328 acpi_ps_delete_parse_tree (op); 349 acpi_ps_delete_parse_tree(op);
329 } 350 }
330 351
331 /* 2) Execute: Create a new state for the preempting walk */ 352 /* 2) Execute: Create a new state for the preempting walk */
332 353
333 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, 354 next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
334 NULL, obj_desc, thread); 355 NULL, obj_desc, thread);
335 if (!next_walk_state) { 356 if (!next_walk_state) {
336 status = AE_NO_MEMORY; 357 status = AE_NO_MEMORY;
337 goto cleanup; 358 goto cleanup;
338 } 359 }
339 /* 360 /*
340 * The resolved arguments were put on the previous walk state's operand 361 * The resolved arguments were put on the previous walk state's operand
341 * stack. Operands on the previous walk state stack always 362 * stack. Operands on the previous walk state stack always
342 * start at index 0. 363 * start at index 0. Also, null terminate the list of arguments
343 * Null terminate the list of arguments
344 */ 364 */
345 this_walk_state->operands [this_walk_state->num_operands] = NULL; 365 this_walk_state->operands[this_walk_state->num_operands] = NULL;
346 366
347 info.parameters = &this_walk_state->operands[0]; 367 info.parameters = &this_walk_state->operands[0];
348 info.parameter_type = ACPI_PARAM_ARGS; 368 info.parameter_type = ACPI_PARAM_ARGS;
349 369
350 status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node, 370 status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node,
351 obj_desc->method.aml_start, obj_desc->method.aml_length, 371 obj_desc->method.aml_start,
352 &info, 3); 372 obj_desc->method.aml_length, &info, 3);
353 if (ACPI_FAILURE (status)) { 373 if (ACPI_FAILURE(status)) {
354 goto cleanup; 374 goto cleanup;
355 } 375 }
356 376
@@ -359,38 +379,37 @@ acpi_ds_call_control_method (
359 * (they were copied to new objects) 379 * (they were copied to new objects)
360 */ 380 */
361 for (i = 0; i < obj_desc->method.param_count; i++) { 381 for (i = 0; i < obj_desc->method.param_count; i++) {
362 acpi_ut_remove_reference (this_walk_state->operands [i]); 382 acpi_ut_remove_reference(this_walk_state->operands[i]);
363 this_walk_state->operands [i] = NULL; 383 this_walk_state->operands[i] = NULL;
364 } 384 }
365 385
366 /* Clear the operand stack */ 386 /* Clear the operand stack */
367 387
368 this_walk_state->num_operands = 0; 388 this_walk_state->num_operands = 0;
369 389
370 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 390 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
371 "Starting nested execution, newstate=%p\n", next_walk_state)); 391 "Starting nested execution, newstate=%p\n",
392 next_walk_state));
372 393
373 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 394 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
374 status = obj_desc->method.implementation (next_walk_state); 395 status = obj_desc->method.implementation(next_walk_state);
375 return_ACPI_STATUS (status);
376 } 396 }
377 397
378 return_ACPI_STATUS (AE_OK); 398 return_ACPI_STATUS(status);
379
380 399
381 /* On error, we must delete the new walk state */ 400 cleanup:
401 /* Decrement the thread count on the method parse tree */
382 402
383cleanup:
384 if (next_walk_state && (next_walk_state->method_desc)) { 403 if (next_walk_state && (next_walk_state->method_desc)) {
385 /* Decrement the thread count on the method parse tree */ 404 next_walk_state->method_desc->method.thread_count--;
386
387 next_walk_state->method_desc->method.thread_count--;
388 } 405 }
389 (void) acpi_ds_terminate_control_method (next_walk_state);
390 acpi_ds_delete_walk_state (next_walk_state);
391 return_ACPI_STATUS (status);
392}
393 406
407 /* On error, we must delete the new walk state */
408
409 acpi_ds_terminate_control_method(next_walk_state);
410 acpi_ds_delete_walk_state(next_walk_state);
411 return_ACPI_STATUS(status);
412}
394 413
395/******************************************************************************* 414/*******************************************************************************
396 * 415 *
@@ -407,25 +426,22 @@ cleanup:
407 ******************************************************************************/ 426 ******************************************************************************/
408 427
409acpi_status 428acpi_status
410acpi_ds_restart_control_method ( 429acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
411 struct acpi_walk_state *walk_state, 430 union acpi_operand_object *return_desc)
412 union acpi_operand_object *return_desc)
413{ 431{
414 acpi_status status; 432 acpi_status status;
415 433
434 ACPI_FUNCTION_TRACE_PTR("ds_restart_control_method", walk_state);
416 435
417 ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state); 436 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
437 "****Restart [%4.4s] Op %p return_value_from_callee %p\n",
438 (char *)&walk_state->method_node->name,
439 walk_state->method_call_op, return_desc));
418 440
419 441 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
420 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 442 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
421 "****Restart [%4.4s] Op %p return_value_from_callee %p\n", 443 walk_state->return_used,
422 (char *) &walk_state->method_node->name, walk_state->method_call_op, 444 walk_state->results, walk_state));
423 return_desc));
424
425 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
426 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
427 walk_state->return_used,
428 walk_state->results, walk_state));
429 445
430 /* Did the called method return a value? */ 446 /* Did the called method return a value? */
431 447
@@ -435,10 +451,10 @@ acpi_ds_restart_control_method (
435 if (walk_state->return_used) { 451 if (walk_state->return_used) {
436 /* Save the return value from the previous method */ 452 /* Save the return value from the previous method */
437 453
438 status = acpi_ds_result_push (return_desc, walk_state); 454 status = acpi_ds_result_push(return_desc, walk_state);
439 if (ACPI_FAILURE (status)) { 455 if (ACPI_FAILURE(status)) {
440 acpi_ut_remove_reference (return_desc); 456 acpi_ut_remove_reference(return_desc);
441 return_ACPI_STATUS (status); 457 return_ACPI_STATUS(status);
442 } 458 }
443 459
444 /* 460 /*
@@ -456,26 +472,26 @@ acpi_ds_restart_control_method (
456 * NOTE: this is optional because the ASL language does not actually 472 * NOTE: this is optional because the ASL language does not actually
457 * support this behavior. 473 * support this behavior.
458 */ 474 */
459 else if (!acpi_ds_do_implicit_return (return_desc, walk_state, FALSE)) { 475 else if (!acpi_ds_do_implicit_return
476 (return_desc, walk_state, FALSE)) {
460 /* 477 /*
461 * Delete the return value if it will not be used by the 478 * Delete the return value if it will not be used by the
462 * calling method 479 * calling method
463 */ 480 */
464 acpi_ut_remove_reference (return_desc); 481 acpi_ut_remove_reference(return_desc);
465 } 482 }
466 } 483 }
467 484
468 return_ACPI_STATUS (AE_OK); 485 return_ACPI_STATUS(AE_OK);
469} 486}
470 487
471
472/******************************************************************************* 488/*******************************************************************************
473 * 489 *
474 * FUNCTION: acpi_ds_terminate_control_method 490 * FUNCTION: acpi_ds_terminate_control_method
475 * 491 *
476 * PARAMETERS: walk_state - State of the method 492 * PARAMETERS: walk_state - State of the method
477 * 493 *
478 * RETURN: Status 494 * RETURN: None
479 * 495 *
480 * DESCRIPTION: Terminate a control method. Delete everything that the method 496 * DESCRIPTION: Terminate a control method. Delete everything that the method
481 * created, delete all locals and arguments, and delete the parse 497 * created, delete all locals and arguments, and delete the parse
@@ -483,63 +499,59 @@ acpi_ds_restart_control_method (
483 * 499 *
484 ******************************************************************************/ 500 ******************************************************************************/
485 501
486acpi_status 502void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
487acpi_ds_terminate_control_method (
488 struct acpi_walk_state *walk_state)
489{ 503{
490 union acpi_operand_object *obj_desc; 504 union acpi_operand_object *obj_desc;
491 struct acpi_namespace_node *method_node; 505 struct acpi_namespace_node *method_node;
492 acpi_status status; 506 acpi_status status;
493
494
495 ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state);
496 507
508 ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state);
497 509
498 if (!walk_state) { 510 if (!walk_state) {
499 return (AE_BAD_PARAMETER); 511 return_VOID;
500 } 512 }
501 513
502 /* The current method object was saved in the walk state */ 514 /* The current method object was saved in the walk state */
503 515
504 obj_desc = walk_state->method_desc; 516 obj_desc = walk_state->method_desc;
505 if (!obj_desc) { 517 if (!obj_desc) {
506 return_ACPI_STATUS (AE_OK); 518 return_VOID;
507 } 519 }
508 520
509 /* Delete all arguments and locals */ 521 /* Delete all arguments and locals */
510 522
511 acpi_ds_method_data_delete_all (walk_state); 523 acpi_ds_method_data_delete_all(walk_state);
512 524
513 /* 525 /*
514 * Lock the parser while we terminate this method. 526 * Lock the parser while we terminate this method.
515 * If this is the last thread executing the method, 527 * If this is the last thread executing the method,
516 * we have additional cleanup to perform 528 * we have additional cleanup to perform
517 */ 529 */
518 status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER); 530 status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER);
519 if (ACPI_FAILURE (status)) { 531 if (ACPI_FAILURE(status)) {
520 return_ACPI_STATUS (status); 532 return_VOID;
521 } 533 }
522 534
523 /* Signal completion of the execution of this method if necessary */ 535 /* Signal completion of the execution of this method if necessary */
524 536
525 if (walk_state->method_desc->method.semaphore) { 537 if (walk_state->method_desc->method.semaphore) {
526 status = acpi_os_signal_semaphore ( 538 status =
527 walk_state->method_desc->method.semaphore, 1); 539 acpi_os_signal_semaphore(walk_state->method_desc->method.
528 if (ACPI_FAILURE (status)) { 540 semaphore, 1);
529 ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); 541 if (ACPI_FAILURE(status)) {
530 status = AE_OK; 542 ACPI_REPORT_ERROR(("Could not signal method semaphore\n"));
531 543
532 /* Ignore error and continue cleanup */ 544 /* Ignore error and continue cleanup */
533 } 545 }
534 } 546 }
535 547
536 if (walk_state->method_desc->method.thread_count) { 548 if (walk_state->method_desc->method.thread_count) {
537 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 549 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
538 "*** Not deleting method namespace, there are still %d threads\n", 550 "*** Not deleting method namespace, there are still %d threads\n",
539 walk_state->method_desc->method.thread_count)); 551 walk_state->method_desc->method.
540 } 552 thread_count));
553 } else { /* This is the last executing thread */
541 554
542 if (!walk_state->method_desc->method.thread_count) {
543 /* 555 /*
544 * Support to dynamically change a method from not_serialized to 556 * Support to dynamically change a method from not_serialized to
545 * Serialized if it appears that the method is written foolishly and 557 * Serialized if it appears that the method is written foolishly and
@@ -551,10 +563,11 @@ acpi_ds_terminate_control_method (
551 * before creating the synchronization semaphore. 563 * before creating the synchronization semaphore.
552 */ 564 */
553 if ((walk_state->method_desc->method.concurrency == 1) && 565 if ((walk_state->method_desc->method.concurrency == 1) &&
554 (!walk_state->method_desc->method.semaphore)) { 566 (!walk_state->method_desc->method.semaphore)) {
555 status = acpi_os_create_semaphore (1, 567 status = acpi_os_create_semaphore(1, 1,
556 1, 568 &walk_state->
557 &walk_state->method_desc->method.semaphore); 569 method_desc->method.
570 semaphore);
558 } 571 }
559 572
560 /* 573 /*
@@ -569,28 +582,27 @@ acpi_ds_terminate_control_method (
569 * Delete any namespace entries created immediately underneath 582 * Delete any namespace entries created immediately underneath
570 * the method 583 * the method
571 */ 584 */
572 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 585 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
573 if (ACPI_FAILURE (status)) { 586 if (ACPI_FAILURE(status)) {
574 return_ACPI_STATUS (status); 587 goto exit;
575 } 588 }
576 589
577 if (method_node->child) { 590 if (method_node->child) {
578 acpi_ns_delete_namespace_subtree (method_node); 591 acpi_ns_delete_namespace_subtree(method_node);
579 } 592 }
580 593
581 /* 594 /*
582 * Delete any namespace entries created anywhere else within 595 * Delete any namespace entries created anywhere else within
583 * the namespace 596 * the namespace
584 */ 597 */
585 acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); 598 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
586 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 599 method.owner_id);
587 if (ACPI_FAILURE (status)) { 600 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
588 return_ACPI_STATUS (status); 601 acpi_ut_release_owner_id(&walk_state->method_desc->method.
589 } 602 owner_id);
590 } 603 }
591 604
592 status = acpi_ut_release_mutex (ACPI_MTX_PARSER); 605 exit:
593 return_ACPI_STATUS (status); 606 (void)acpi_ut_release_mutex(ACPI_MTX_PARSER);
607 return_VOID;
594} 608}
595
596
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index f7998306f756..4095ce70982b 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -41,41 +41,32 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 45#include <acpi/acdispat.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
50 49
51
52#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsmthdat") 51ACPI_MODULE_NAME("dsmthdat")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static void 54static void
58acpi_ds_method_data_delete_value ( 55acpi_ds_method_data_delete_value(u16 opcode,
59 u16 opcode, 56 u32 index, struct acpi_walk_state *walk_state);
60 u32 index,
61 struct acpi_walk_state *walk_state);
62 57
63static acpi_status 58static acpi_status
64acpi_ds_method_data_set_value ( 59acpi_ds_method_data_set_value(u16 opcode,
65 u16 opcode, 60 u32 index,
66 u32 index, 61 union acpi_operand_object *object,
67 union acpi_operand_object *object, 62 struct acpi_walk_state *walk_state);
68 struct acpi_walk_state *walk_state);
69 63
70#ifdef ACPI_OBSOLETE_FUNCTIONS 64#ifdef ACPI_OBSOLETE_FUNCTIONS
71acpi_object_type 65acpi_object_type
72acpi_ds_method_data_get_type ( 66acpi_ds_method_data_get_type(u16 opcode,
73 u16 opcode, 67 u32 index, struct acpi_walk_state *walk_state);
74 u32 index,
75 struct acpi_walk_state *walk_state);
76#endif 68#endif
77 69
78
79/******************************************************************************* 70/*******************************************************************************
80 * 71 *
81 * FUNCTION: acpi_ds_method_data_init 72 * FUNCTION: acpi_ds_method_data_init
@@ -97,45 +88,41 @@ acpi_ds_method_data_get_type (
97 * 88 *
98 ******************************************************************************/ 89 ******************************************************************************/
99 90
100void 91void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
101acpi_ds_method_data_init (
102 struct acpi_walk_state *walk_state)
103{ 92{
104 u32 i; 93 u32 i;
105
106
107 ACPI_FUNCTION_TRACE ("ds_method_data_init");
108 94
95 ACPI_FUNCTION_TRACE("ds_method_data_init");
109 96
110 /* Init the method arguments */ 97 /* Init the method arguments */
111 98
112 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { 99 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
113 ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name, 100 ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
114 NAMEOF_ARG_NTE); 101 NAMEOF_ARG_NTE);
115 walk_state->arguments[i].name.integer |= (i << 24); 102 walk_state->arguments[i].name.integer |= (i << 24);
116 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; 103 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
117 walk_state->arguments[i].type = ACPI_TYPE_ANY; 104 walk_state->arguments[i].type = ACPI_TYPE_ANY;
118 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | 105 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
119 ANOBJ_METHOD_ARG; 106 ANOBJ_METHOD_ARG;
120 } 107 }
121 108
122 /* Init the method locals */ 109 /* Init the method locals */
123 110
124 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { 111 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
125 ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name, 112 ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
126 NAMEOF_LOCAL_NTE); 113 NAMEOF_LOCAL_NTE);
127 114
128 walk_state->local_variables[i].name.integer |= (i << 24); 115 walk_state->local_variables[i].name.integer |= (i << 24);
129 walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; 116 walk_state->local_variables[i].descriptor =
130 walk_state->local_variables[i].type = ACPI_TYPE_ANY; 117 ACPI_DESC_TYPE_NAMED;
131 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | 118 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
132 ANOBJ_METHOD_LOCAL; 119 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
120 ANOBJ_METHOD_LOCAL;
133 } 121 }
134 122
135 return_VOID; 123 return_VOID;
136} 124}
137 125
138
139/******************************************************************************* 126/*******************************************************************************
140 * 127 *
141 * FUNCTION: acpi_ds_method_data_delete_all 128 * FUNCTION: acpi_ds_method_data_delete_all
@@ -149,26 +136,25 @@ acpi_ds_method_data_init (
149 * 136 *
150 ******************************************************************************/ 137 ******************************************************************************/
151 138
152void 139void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
153acpi_ds_method_data_delete_all (
154 struct acpi_walk_state *walk_state)
155{ 140{
156 u32 index; 141 u32 index;
157
158
159 ACPI_FUNCTION_TRACE ("ds_method_data_delete_all");
160 142
143 ACPI_FUNCTION_TRACE("ds_method_data_delete_all");
161 144
162 /* Detach the locals */ 145 /* Detach the locals */
163 146
164 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) { 147 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
165 if (walk_state->local_variables[index].object) { 148 if (walk_state->local_variables[index].object) {
166 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", 149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
167 index, walk_state->local_variables[index].object)); 150 index,
151 walk_state->local_variables[index].
152 object));
168 153
169 /* Detach object (if present) and remove a reference */ 154 /* Detach object (if present) and remove a reference */
170 155
171 acpi_ns_detach_object (&walk_state->local_variables[index]); 156 acpi_ns_detach_object(&walk_state->
157 local_variables[index]);
172 } 158 }
173 } 159 }
174 160
@@ -176,19 +162,19 @@ acpi_ds_method_data_delete_all (
176 162
177 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) { 163 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
178 if (walk_state->arguments[index].object) { 164 if (walk_state->arguments[index].object) {
179 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", 165 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
180 index, walk_state->arguments[index].object)); 166 index,
167 walk_state->arguments[index].object));
181 168
182 /* Detach object (if present) and remove a reference */ 169 /* Detach object (if present) and remove a reference */
183 170
184 acpi_ns_detach_object (&walk_state->arguments[index]); 171 acpi_ns_detach_object(&walk_state->arguments[index]);
185 } 172 }
186 } 173 }
187 174
188 return_VOID; 175 return_VOID;
189} 176}
190 177
191
192/******************************************************************************* 178/*******************************************************************************
193 * 179 *
194 * FUNCTION: acpi_ds_method_data_init_args 180 * FUNCTION: acpi_ds_method_data_init_args
@@ -206,47 +192,44 @@ acpi_ds_method_data_delete_all (
206 ******************************************************************************/ 192 ******************************************************************************/
207 193
208acpi_status 194acpi_status
209acpi_ds_method_data_init_args ( 195acpi_ds_method_data_init_args(union acpi_operand_object **params,
210 union acpi_operand_object **params, 196 u32 max_param_count,
211 u32 max_param_count, 197 struct acpi_walk_state *walk_state)
212 struct acpi_walk_state *walk_state)
213{ 198{
214 acpi_status status; 199 acpi_status status;
215 u32 index = 0; 200 u32 index = 0;
216
217
218 ACPI_FUNCTION_TRACE_PTR ("ds_method_data_init_args", params);
219 201
202 ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params);
220 203
221 if (!params) { 204 if (!params) {
222 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); 205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
223 return_ACPI_STATUS (AE_OK); 206 "No param list passed to method\n"));
207 return_ACPI_STATUS(AE_OK);
224 } 208 }
225 209
226 /* Copy passed parameters into the new method stack frame */ 210 /* Copy passed parameters into the new method stack frame */
227 211
228 while ((index < ACPI_METHOD_NUM_ARGS) && 212 while ((index < ACPI_METHOD_NUM_ARGS) &&
229 (index < max_param_count) && 213 (index < max_param_count) && params[index]) {
230 params[index]) {
231 /* 214 /*
232 * A valid parameter. 215 * A valid parameter.
233 * Store the argument in the method/walk descriptor. 216 * Store the argument in the method/walk descriptor.
234 * Do not copy the arg in order to implement call by reference 217 * Do not copy the arg in order to implement call by reference
235 */ 218 */
236 status = acpi_ds_method_data_set_value (AML_ARG_OP, index, 219 status = acpi_ds_method_data_set_value(AML_ARG_OP, index,
237 params[index], walk_state); 220 params[index],
238 if (ACPI_FAILURE (status)) { 221 walk_state);
239 return_ACPI_STATUS (status); 222 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS(status);
240 } 224 }
241 225
242 index++; 226 index++;
243 } 227 }
244 228
245 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index)); 229 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index));
246 return_ACPI_STATUS (AE_OK); 230 return_ACPI_STATUS(AE_OK);
247} 231}
248 232
249
250/******************************************************************************* 233/*******************************************************************************
251 * 234 *
252 * FUNCTION: acpi_ds_method_data_get_node 235 * FUNCTION: acpi_ds_method_data_get_node
@@ -263,14 +246,12 @@ acpi_ds_method_data_init_args (
263 ******************************************************************************/ 246 ******************************************************************************/
264 247
265acpi_status 248acpi_status
266acpi_ds_method_data_get_node ( 249acpi_ds_method_data_get_node(u16 opcode,
267 u16 opcode, 250 u32 index,
268 u32 index, 251 struct acpi_walk_state *walk_state,
269 struct acpi_walk_state *walk_state, 252 struct acpi_namespace_node **node)
270 struct acpi_namespace_node **node)
271{ 253{
272 ACPI_FUNCTION_TRACE ("ds_method_data_get_node"); 254 ACPI_FUNCTION_TRACE("ds_method_data_get_node");
273
274 255
275 /* 256 /*
276 * Method Locals and Arguments are supported 257 * Method Locals and Arguments are supported
@@ -279,10 +260,10 @@ acpi_ds_method_data_get_node (
279 case AML_LOCAL_OP: 260 case AML_LOCAL_OP:
280 261
281 if (index > ACPI_METHOD_MAX_LOCAL) { 262 if (index > ACPI_METHOD_MAX_LOCAL) {
282 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 263 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
283 "Local index %d is invalid (max %d)\n", 264 "Local index %d is invalid (max %d)\n",
284 index, ACPI_METHOD_MAX_LOCAL)); 265 index, ACPI_METHOD_MAX_LOCAL));
285 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 266 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
286 } 267 }
287 268
288 /* Return a pointer to the pseudo-node */ 269 /* Return a pointer to the pseudo-node */
@@ -293,10 +274,10 @@ acpi_ds_method_data_get_node (
293 case AML_ARG_OP: 274 case AML_ARG_OP:
294 275
295 if (index > ACPI_METHOD_MAX_ARG) { 276 if (index > ACPI_METHOD_MAX_ARG) {
296 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
297 "Arg index %d is invalid (max %d)\n", 278 "Arg index %d is invalid (max %d)\n",
298 index, ACPI_METHOD_MAX_ARG)); 279 index, ACPI_METHOD_MAX_ARG));
299 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 280 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
300 } 281 }
301 282
302 /* Return a pointer to the pseudo-node */ 283 /* Return a pointer to the pseudo-node */
@@ -305,14 +286,14 @@ acpi_ds_method_data_get_node (
305 break; 286 break;
306 287
307 default: 288 default:
308 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); 289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n",
309 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 290 opcode));
291 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
310 } 292 }
311 293
312 return_ACPI_STATUS (AE_OK); 294 return_ACPI_STATUS(AE_OK);
313} 295}
314 296
315
316/******************************************************************************* 297/*******************************************************************************
317 * 298 *
318 * FUNCTION: acpi_ds_method_data_set_value 299 * FUNCTION: acpi_ds_method_data_set_value
@@ -330,29 +311,26 @@ acpi_ds_method_data_get_node (
330 ******************************************************************************/ 311 ******************************************************************************/
331 312
332static acpi_status 313static acpi_status
333acpi_ds_method_data_set_value ( 314acpi_ds_method_data_set_value(u16 opcode,
334 u16 opcode, 315 u32 index,
335 u32 index, 316 union acpi_operand_object *object,
336 union acpi_operand_object *object, 317 struct acpi_walk_state *walk_state)
337 struct acpi_walk_state *walk_state)
338{ 318{
339 acpi_status status; 319 acpi_status status;
340 struct acpi_namespace_node *node; 320 struct acpi_namespace_node *node;
341
342 321
343 ACPI_FUNCTION_TRACE ("ds_method_data_set_value"); 322 ACPI_FUNCTION_TRACE("ds_method_data_set_value");
344 323
345 324 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
346 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 325 "new_obj %p Opcode %X, Refs=%d [%s]\n", object,
347 "new_obj %p Opcode %X, Refs=%d [%s]\n", object, 326 opcode, object->common.reference_count,
348 opcode, object->common.reference_count, 327 acpi_ut_get_type_name(object->common.type)));
349 acpi_ut_get_type_name (object->common.type)));
350 328
351 /* Get the namespace node for the arg/local */ 329 /* Get the namespace node for the arg/local */
352 330
353 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); 331 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
354 if (ACPI_FAILURE (status)) { 332 if (ACPI_FAILURE(status)) {
355 return_ACPI_STATUS (status); 333 return_ACPI_STATUS(status);
356 } 334 }
357 335
358 /* 336 /*
@@ -361,15 +339,14 @@ acpi_ds_method_data_set_value (
361 * reference semantics of ACPI Control Method invocation. 339 * reference semantics of ACPI Control Method invocation.
362 * (See ACPI specification 2.0_c) 340 * (See ACPI specification 2.0_c)
363 */ 341 */
364 acpi_ut_add_reference (object); 342 acpi_ut_add_reference(object);
365 343
366 /* Install the object */ 344 /* Install the object */
367 345
368 node->object = object; 346 node->object = object;
369 return_ACPI_STATUS (status); 347 return_ACPI_STATUS(status);
370} 348}
371 349
372
373/******************************************************************************* 350/*******************************************************************************
374 * 351 *
375 * FUNCTION: acpi_ds_method_data_get_value 352 * FUNCTION: acpi_ds_method_data_get_value
@@ -387,32 +364,30 @@ acpi_ds_method_data_set_value (
387 ******************************************************************************/ 364 ******************************************************************************/
388 365
389acpi_status 366acpi_status
390acpi_ds_method_data_get_value ( 367acpi_ds_method_data_get_value(u16 opcode,
391 u16 opcode, 368 u32 index,
392 u32 index, 369 struct acpi_walk_state *walk_state,
393 struct acpi_walk_state *walk_state, 370 union acpi_operand_object **dest_desc)
394 union acpi_operand_object **dest_desc)
395{ 371{
396 acpi_status status; 372 acpi_status status;
397 struct acpi_namespace_node *node; 373 struct acpi_namespace_node *node;
398 union acpi_operand_object *object; 374 union acpi_operand_object *object;
399
400
401 ACPI_FUNCTION_TRACE ("ds_method_data_get_value");
402 375
376 ACPI_FUNCTION_TRACE("ds_method_data_get_value");
403 377
404 /* Validate the object descriptor */ 378 /* Validate the object descriptor */
405 379
406 if (!dest_desc) { 380 if (!dest_desc) {
407 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); 381 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
408 return_ACPI_STATUS (AE_BAD_PARAMETER); 382 "Null object descriptor pointer\n"));
383 return_ACPI_STATUS(AE_BAD_PARAMETER);
409 } 384 }
410 385
411 /* Get the namespace node for the arg/local */ 386 /* Get the namespace node for the arg/local */
412 387
413 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); 388 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
414 if (ACPI_FAILURE (status)) { 389 if (ACPI_FAILURE(status)) {
415 return_ACPI_STATUS (status); 390 return_ACPI_STATUS(status);
416 } 391 }
417 392
418 /* Get the object from the node */ 393 /* Get the object from the node */
@@ -433,9 +408,10 @@ acpi_ds_method_data_get_value (
433 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ 408 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
434 409
435 if (acpi_gbl_enable_interpreter_slack) { 410 if (acpi_gbl_enable_interpreter_slack) {
436 object = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 411 object =
412 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
437 if (!object) { 413 if (!object) {
438 return_ACPI_STATUS (AE_NO_MEMORY); 414 return_ACPI_STATUS(AE_NO_MEMORY);
439 } 415 }
440 416
441 object->integer.value = 0; 417 object->integer.value = 0;
@@ -444,27 +420,29 @@ acpi_ds_method_data_get_value (
444 420
445 /* Otherwise, return the error */ 421 /* Otherwise, return the error */
446 422
447 else switch (opcode) { 423 else
448 case AML_ARG_OP: 424 switch (opcode) {
425 case AML_ARG_OP:
449 426
450 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 427 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
451 "Uninitialized Arg[%d] at node %p\n", 428 "Uninitialized Arg[%d] at node %p\n",
452 index, node)); 429 index, node));
453 430
454 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 431 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
455 432
456 case AML_LOCAL_OP: 433 case AML_LOCAL_OP:
457 434
458 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 435 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
459 "Uninitialized Local[%d] at node %p\n", 436 "Uninitialized Local[%d] at node %p\n",
460 index, node)); 437 index, node));
461 438
462 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 439 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
463 440
464 default: 441 default:
465 ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode)); 442 ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n",
466 return_ACPI_STATUS (AE_AML_INTERNAL); 443 opcode));
467 } 444 return_ACPI_STATUS(AE_AML_INTERNAL);
445 }
468 } 446 }
469 447
470 /* 448 /*
@@ -472,12 +450,11 @@ acpi_ds_method_data_get_value (
472 * Return an additional reference to the object 450 * Return an additional reference to the object
473 */ 451 */
474 *dest_desc = object; 452 *dest_desc = object;
475 acpi_ut_add_reference (object); 453 acpi_ut_add_reference(object);
476 454
477 return_ACPI_STATUS (AE_OK); 455 return_ACPI_STATUS(AE_OK);
478} 456}
479 457
480
481/******************************************************************************* 458/*******************************************************************************
482 * 459 *
483 * FUNCTION: acpi_ds_method_data_delete_value 460 * FUNCTION: acpi_ds_method_data_delete_value
@@ -494,29 +471,25 @@ acpi_ds_method_data_get_value (
494 ******************************************************************************/ 471 ******************************************************************************/
495 472
496static void 473static void
497acpi_ds_method_data_delete_value ( 474acpi_ds_method_data_delete_value(u16 opcode,
498 u16 opcode, 475 u32 index, struct acpi_walk_state *walk_state)
499 u32 index,
500 struct acpi_walk_state *walk_state)
501{ 476{
502 acpi_status status; 477 acpi_status status;
503 struct acpi_namespace_node *node; 478 struct acpi_namespace_node *node;
504 union acpi_operand_object *object; 479 union acpi_operand_object *object;
505
506
507 ACPI_FUNCTION_TRACE ("ds_method_data_delete_value");
508 480
481 ACPI_FUNCTION_TRACE("ds_method_data_delete_value");
509 482
510 /* Get the namespace node for the arg/local */ 483 /* Get the namespace node for the arg/local */
511 484
512 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); 485 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
513 if (ACPI_FAILURE (status)) { 486 if (ACPI_FAILURE(status)) {
514 return_VOID; 487 return_VOID;
515 } 488 }
516 489
517 /* Get the associated object */ 490 /* Get the associated object */
518 491
519 object = acpi_ns_get_attached_object (node); 492 object = acpi_ns_get_attached_object(node);
520 493
521 /* 494 /*
522 * Undefine the Arg or Local by setting its descriptor 495 * Undefine the Arg or Local by setting its descriptor
@@ -526,19 +499,18 @@ acpi_ds_method_data_delete_value (
526 node->object = NULL; 499 node->object = NULL;
527 500
528 if ((object) && 501 if ((object) &&
529 (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) { 502 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
530 /* 503 /*
531 * There is a valid object. 504 * There is a valid object.
532 * Decrement the reference count by one to balance the 505 * Decrement the reference count by one to balance the
533 * increment when the object was stored. 506 * increment when the object was stored.
534 */ 507 */
535 acpi_ut_remove_reference (object); 508 acpi_ut_remove_reference(object);
536 } 509 }
537 510
538 return_VOID; 511 return_VOID;
539} 512}
540 513
541
542/******************************************************************************* 514/*******************************************************************************
543 * 515 *
544 * FUNCTION: acpi_ds_store_object_to_local 516 * FUNCTION: acpi_ds_store_object_to_local
@@ -557,40 +529,38 @@ acpi_ds_method_data_delete_value (
557 ******************************************************************************/ 529 ******************************************************************************/
558 530
559acpi_status 531acpi_status
560acpi_ds_store_object_to_local ( 532acpi_ds_store_object_to_local(u16 opcode,
561 u16 opcode, 533 u32 index,
562 u32 index, 534 union acpi_operand_object *obj_desc,
563 union acpi_operand_object *obj_desc, 535 struct acpi_walk_state *walk_state)
564 struct acpi_walk_state *walk_state)
565{ 536{
566 acpi_status status; 537 acpi_status status;
567 struct acpi_namespace_node *node; 538 struct acpi_namespace_node *node;
568 union acpi_operand_object *current_obj_desc; 539 union acpi_operand_object *current_obj_desc;
569 union acpi_operand_object *new_obj_desc; 540 union acpi_operand_object *new_obj_desc;
570
571 541
572 ACPI_FUNCTION_TRACE ("ds_store_object_to_local"); 542 ACPI_FUNCTION_TRACE("ds_store_object_to_local");
573 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", 543 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
574 opcode, index, obj_desc)); 544 opcode, index, obj_desc));
575 545
576 /* Parameter validation */ 546 /* Parameter validation */
577 547
578 if (!obj_desc) { 548 if (!obj_desc) {
579 return_ACPI_STATUS (AE_BAD_PARAMETER); 549 return_ACPI_STATUS(AE_BAD_PARAMETER);
580 } 550 }
581 551
582 /* Get the namespace node for the arg/local */ 552 /* Get the namespace node for the arg/local */
583 553
584 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); 554 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
585 if (ACPI_FAILURE (status)) { 555 if (ACPI_FAILURE(status)) {
586 return_ACPI_STATUS (status); 556 return_ACPI_STATUS(status);
587 } 557 }
588 558
589 current_obj_desc = acpi_ns_get_attached_object (node); 559 current_obj_desc = acpi_ns_get_attached_object(node);
590 if (current_obj_desc == obj_desc) { 560 if (current_obj_desc == obj_desc) {
591 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", 561 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
592 obj_desc)); 562 obj_desc));
593 return_ACPI_STATUS (status); 563 return_ACPI_STATUS(status);
594 } 564 }
595 565
596 /* 566 /*
@@ -602,9 +572,11 @@ acpi_ds_store_object_to_local (
602 */ 572 */
603 new_obj_desc = obj_desc; 573 new_obj_desc = obj_desc;
604 if (obj_desc->common.reference_count > 1) { 574 if (obj_desc->common.reference_count > 1) {
605 status = acpi_ut_copy_iobject_to_iobject (obj_desc, &new_obj_desc, walk_state); 575 status =
606 if (ACPI_FAILURE (status)) { 576 acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
607 return_ACPI_STATUS (status); 577 walk_state);
578 if (ACPI_FAILURE(status)) {
579 return_ACPI_STATUS(status);
608 } 580 }
609 } 581 }
610 582
@@ -633,42 +605,39 @@ acpi_ds_store_object_to_local (
633 */ 605 */
634 if (opcode == AML_ARG_OP) { 606 if (opcode == AML_ARG_OP) {
635 /* 607 /*
636 * Make sure that the object is the correct type. This may be
637 * overkill, butit is here because references were NS nodes in
638 * the past. Now they are operand objects of type Reference.
639 */
640 if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
641 ACPI_REPORT_ERROR ((
642 "Invalid descriptor type while storing to method arg: [%s]\n",
643 acpi_ut_get_descriptor_name (current_obj_desc)));
644 return_ACPI_STATUS (AE_AML_INTERNAL);
645 }
646
647 /*
648 * If we have a valid reference object that came from ref_of(), 608 * If we have a valid reference object that came from ref_of(),
649 * do the indirect store 609 * do the indirect store
650 */ 610 */
651 if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 611 if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
652 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { 612 ACPI_DESC_TYPE_OPERAND)
653 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 613 && (current_obj_desc->common.type ==
654 "Arg (%p) is an obj_ref(Node), storing in node %p\n", 614 ACPI_TYPE_LOCAL_REFERENCE)
655 new_obj_desc, current_obj_desc)); 615 && (current_obj_desc->reference.opcode ==
616 AML_REF_OF_OP)) {
617 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
618 "Arg (%p) is an obj_ref(Node), storing in node %p\n",
619 new_obj_desc,
620 current_obj_desc));
656 621
657 /* 622 /*
658 * Store this object to the Node (perform the indirect store) 623 * Store this object to the Node (perform the indirect store)
659 * NOTE: No implicit conversion is performed, as per the ACPI 624 * NOTE: No implicit conversion is performed, as per the ACPI
660 * specification rules on storing to Locals/Args. 625 * specification rules on storing to Locals/Args.
661 */ 626 */
662 status = acpi_ex_store_object_to_node (new_obj_desc, 627 status =
663 current_obj_desc->reference.object, walk_state, 628 acpi_ex_store_object_to_node(new_obj_desc,
664 ACPI_NO_IMPLICIT_CONVERSION); 629 current_obj_desc->
630 reference.
631 object,
632 walk_state,
633 ACPI_NO_IMPLICIT_CONVERSION);
665 634
666 /* Remove local reference if we copied the object above */ 635 /* Remove local reference if we copied the object above */
667 636
668 if (new_obj_desc != obj_desc) { 637 if (new_obj_desc != obj_desc) {
669 acpi_ut_remove_reference (new_obj_desc); 638 acpi_ut_remove_reference(new_obj_desc);
670 } 639 }
671 return_ACPI_STATUS (status); 640 return_ACPI_STATUS(status);
672 } 641 }
673 } 642 }
674 643
@@ -676,7 +645,7 @@ acpi_ds_store_object_to_local (
676 * Delete the existing object 645 * Delete the existing object
677 * before storing the new one 646 * before storing the new one
678 */ 647 */
679 acpi_ds_method_data_delete_value (opcode, index, walk_state); 648 acpi_ds_method_data_delete_value(opcode, index, walk_state);
680 } 649 }
681 650
682 /* 651 /*
@@ -684,18 +653,19 @@ acpi_ds_store_object_to_local (
684 * the descriptor for the Arg or Local. 653 * the descriptor for the Arg or Local.
685 * (increments the object reference count by one) 654 * (increments the object reference count by one)
686 */ 655 */
687 status = acpi_ds_method_data_set_value (opcode, index, new_obj_desc, walk_state); 656 status =
657 acpi_ds_method_data_set_value(opcode, index, new_obj_desc,
658 walk_state);
688 659
689 /* Remove local reference if we copied the object above */ 660 /* Remove local reference if we copied the object above */
690 661
691 if (new_obj_desc != obj_desc) { 662 if (new_obj_desc != obj_desc) {
692 acpi_ut_remove_reference (new_obj_desc); 663 acpi_ut_remove_reference(new_obj_desc);
693 } 664 }
694 665
695 return_ACPI_STATUS (status); 666 return_ACPI_STATUS(status);
696} 667}
697 668
698
699#ifdef ACPI_OBSOLETE_FUNCTIONS 669#ifdef ACPI_OBSOLETE_FUNCTIONS
700/******************************************************************************* 670/*******************************************************************************
701 * 671 *
@@ -712,39 +682,33 @@ acpi_ds_store_object_to_local (
712 ******************************************************************************/ 682 ******************************************************************************/
713 683
714acpi_object_type 684acpi_object_type
715acpi_ds_method_data_get_type ( 685acpi_ds_method_data_get_type(u16 opcode,
716 u16 opcode, 686 u32 index, struct acpi_walk_state *walk_state)
717 u32 index,
718 struct acpi_walk_state *walk_state)
719{ 687{
720 acpi_status status; 688 acpi_status status;
721 struct acpi_namespace_node *node; 689 struct acpi_namespace_node *node;
722 union acpi_operand_object *object; 690 union acpi_operand_object *object;
723
724
725 ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
726 691
692 ACPI_FUNCTION_TRACE("ds_method_data_get_type");
727 693
728 /* Get the namespace node for the arg/local */ 694 /* Get the namespace node for the arg/local */
729 695
730 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); 696 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
731 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
732 return_VALUE ((ACPI_TYPE_NOT_FOUND)); 698 return_VALUE((ACPI_TYPE_NOT_FOUND));
733 } 699 }
734 700
735 /* Get the object */ 701 /* Get the object */
736 702
737 object = acpi_ns_get_attached_object (node); 703 object = acpi_ns_get_attached_object(node);
738 if (!object) { 704 if (!object) {
739 /* Uninitialized local/arg, return TYPE_ANY */ 705 /* Uninitialized local/arg, return TYPE_ANY */
740 706
741 return_VALUE (ACPI_TYPE_ANY); 707 return_VALUE(ACPI_TYPE_ANY);
742 } 708 }
743 709
744 /* Get the object type */ 710 /* Get the object type */
745 711
746 return_VALUE (ACPI_GET_OBJECT_TYPE (object)); 712 return_VALUE(ACPI_GET_OBJECT_TYPE(object));
747} 713}
748#endif 714#endif
749
750
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index bfbae4e4c667..8ac0cd93adb5 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -50,14 +49,12 @@
50#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
51 50
52#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsobject") 52ACPI_MODULE_NAME("dsobject")
54 53
55static acpi_status 54static acpi_status
56acpi_ds_build_internal_object ( 55acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
57 struct acpi_walk_state *walk_state, 56 union acpi_parse_object *op,
58 union acpi_parse_object *op, 57 union acpi_operand_object **obj_desc_ptr);
59 union acpi_operand_object **obj_desc_ptr);
60
61 58
62#ifndef ACPI_NO_METHOD_EXECUTION 59#ifndef ACPI_NO_METHOD_EXECUTION
63/******************************************************************************* 60/*******************************************************************************
@@ -76,17 +73,14 @@ acpi_ds_build_internal_object (
76 ******************************************************************************/ 73 ******************************************************************************/
77 74
78static acpi_status 75static acpi_status
79acpi_ds_build_internal_object ( 76acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
80 struct acpi_walk_state *walk_state, 77 union acpi_parse_object *op,
81 union acpi_parse_object *op, 78 union acpi_operand_object **obj_desc_ptr)
82 union acpi_operand_object **obj_desc_ptr)
83{ 79{
84 union acpi_operand_object *obj_desc; 80 union acpi_operand_object *obj_desc;
85 acpi_status status; 81 acpi_status status;
86
87
88 ACPI_FUNCTION_TRACE ("ds_build_internal_object");
89 82
83 ACPI_FUNCTION_TRACE("ds_build_internal_object");
90 84
91 *obj_desc_ptr = NULL; 85 *obj_desc_ptr = NULL;
92 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 86 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
@@ -96,40 +90,44 @@ acpi_ds_build_internal_object (
96 * Otherwise, go ahead and look it up now 90 * Otherwise, go ahead and look it up now
97 */ 91 */
98 if (!op->common.node) { 92 if (!op->common.node) {
99 status = acpi_ns_lookup (walk_state->scope_info, 93 status = acpi_ns_lookup(walk_state->scope_info,
100 op->common.value.string, 94 op->common.value.string,
101 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 95 ACPI_TYPE_ANY,
102 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 96 ACPI_IMODE_EXECUTE,
103 NULL, 97 ACPI_NS_SEARCH_PARENT |
104 (struct acpi_namespace_node **) &(op->common.node)); 98 ACPI_NS_DONT_OPEN_SCOPE, NULL,
105 99 (struct acpi_namespace_node **)
106 if (ACPI_FAILURE (status)) { 100 &(op->common.node));
107 ACPI_REPORT_NSERROR (op->common.value.string, status); 101
108 return_ACPI_STATUS (status); 102 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_NSERROR(op->common.value.string,
104 status);
105 return_ACPI_STATUS(status);
109 } 106 }
110 } 107 }
111 } 108 }
112 109
113 /* Create and init the internal ACPI object */ 110 /* Create and init the internal ACPI object */
114 111
115 obj_desc = acpi_ut_create_internal_object ( 112 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
116 (acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type); 113 (op->common.aml_opcode))->
114 object_type);
117 if (!obj_desc) { 115 if (!obj_desc) {
118 return_ACPI_STATUS (AE_NO_MEMORY); 116 return_ACPI_STATUS(AE_NO_MEMORY);
119 } 117 }
120 118
121 status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode, 119 status =
122 &obj_desc); 120 acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
123 if (ACPI_FAILURE (status)) { 121 &obj_desc);
124 acpi_ut_remove_reference (obj_desc); 122 if (ACPI_FAILURE(status)) {
125 return_ACPI_STATUS (status); 123 acpi_ut_remove_reference(obj_desc);
124 return_ACPI_STATUS(status);
126 } 125 }
127 126
128 *obj_desc_ptr = obj_desc; 127 *obj_desc_ptr = obj_desc;
129 return_ACPI_STATUS (AE_OK); 128 return_ACPI_STATUS(AE_OK);
130} 129}
131 130
132
133/******************************************************************************* 131/*******************************************************************************
134 * 132 *
135 * FUNCTION: acpi_ds_build_internal_buffer_obj 133 * FUNCTION: acpi_ds_build_internal_buffer_obj
@@ -147,20 +145,17 @@ acpi_ds_build_internal_object (
147 ******************************************************************************/ 145 ******************************************************************************/
148 146
149acpi_status 147acpi_status
150acpi_ds_build_internal_buffer_obj ( 148acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
151 struct acpi_walk_state *walk_state, 149 union acpi_parse_object *op,
152 union acpi_parse_object *op, 150 u32 buffer_length,
153 u32 buffer_length, 151 union acpi_operand_object **obj_desc_ptr)
154 union acpi_operand_object **obj_desc_ptr)
155{ 152{
156 union acpi_parse_object *arg; 153 union acpi_parse_object *arg;
157 union acpi_operand_object *obj_desc; 154 union acpi_operand_object *obj_desc;
158 union acpi_parse_object *byte_list; 155 union acpi_parse_object *byte_list;
159 u32 byte_list_length = 0; 156 u32 byte_list_length = 0;
160
161
162 ACPI_FUNCTION_TRACE ("ds_build_internal_buffer_obj");
163 157
158 ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj");
164 159
165 obj_desc = *obj_desc_ptr; 160 obj_desc = *obj_desc_ptr;
166 if (obj_desc) { 161 if (obj_desc) {
@@ -168,14 +163,13 @@ acpi_ds_build_internal_buffer_obj (
168 * We are evaluating a Named buffer object "Name (xxxx, Buffer)". 163 * We are evaluating a Named buffer object "Name (xxxx, Buffer)".
169 * The buffer object already exists (from the NS node) 164 * The buffer object already exists (from the NS node)
170 */ 165 */
171 } 166 } else {
172 else {
173 /* Create a new buffer object */ 167 /* Create a new buffer object */
174 168
175 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); 169 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
176 *obj_desc_ptr = obj_desc; 170 *obj_desc_ptr = obj_desc;
177 if (!obj_desc) { 171 if (!obj_desc) {
178 return_ACPI_STATUS (AE_NO_MEMORY); 172 return_ACPI_STATUS(AE_NO_MEMORY);
179 } 173 }
180 } 174 }
181 175
@@ -184,16 +178,17 @@ acpi_ds_build_internal_buffer_obj (
184 * individual bytes or a string initializer. In either case, a 178 * individual bytes or a string initializer. In either case, a
185 * byte_list appears in the AML. 179 * byte_list appears in the AML.
186 */ 180 */
187 arg = op->common.value.arg; /* skip first arg */ 181 arg = op->common.value.arg; /* skip first arg */
188 182
189 byte_list = arg->named.next; 183 byte_list = arg->named.next;
190 if (byte_list) { 184 if (byte_list) {
191 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { 185 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
192 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
193 "Expecting bytelist, got AML opcode %X in op %p\n", 187 "Expecting bytelist, got AML opcode %X in op %p\n",
194 byte_list->common.aml_opcode, byte_list)); 188 byte_list->common.aml_opcode,
189 byte_list));
195 190
196 acpi_ut_remove_reference (obj_desc); 191 acpi_ut_remove_reference(obj_desc);
197 return (AE_TYPE); 192 return (AE_TYPE);
198 } 193 }
199 194
@@ -214,31 +209,29 @@ acpi_ds_build_internal_buffer_obj (
214 209
215 if (obj_desc->buffer.length == 0) { 210 if (obj_desc->buffer.length == 0) {
216 obj_desc->buffer.pointer = NULL; 211 obj_desc->buffer.pointer = NULL;
217 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 212 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
218 "Buffer defined with zero length in AML, creating\n")); 213 "Buffer defined with zero length in AML, creating\n"));
219 } 214 } else {
220 else { 215 obj_desc->buffer.pointer =
221 obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE ( 216 ACPI_MEM_CALLOCATE(obj_desc->buffer.length);
222 obj_desc->buffer.length);
223 if (!obj_desc->buffer.pointer) { 217 if (!obj_desc->buffer.pointer) {
224 acpi_ut_delete_object_desc (obj_desc); 218 acpi_ut_delete_object_desc(obj_desc);
225 return_ACPI_STATUS (AE_NO_MEMORY); 219 return_ACPI_STATUS(AE_NO_MEMORY);
226 } 220 }
227 221
228 /* Initialize buffer from the byte_list (if present) */ 222 /* Initialize buffer from the byte_list (if present) */
229 223
230 if (byte_list) { 224 if (byte_list) {
231 ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->named.data, 225 ACPI_MEMCPY(obj_desc->buffer.pointer,
232 byte_list_length); 226 byte_list->named.data, byte_list_length);
233 } 227 }
234 } 228 }
235 229
236 obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; 230 obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
237 op->common.node = (struct acpi_namespace_node *) obj_desc; 231 op->common.node = (struct acpi_namespace_node *)obj_desc;
238 return_ACPI_STATUS (AE_OK); 232 return_ACPI_STATUS(AE_OK);
239} 233}
240 234
241
242/******************************************************************************* 235/*******************************************************************************
243 * 236 *
244 * FUNCTION: acpi_ds_build_internal_package_obj 237 * FUNCTION: acpi_ds_build_internal_package_obj
@@ -256,28 +249,25 @@ acpi_ds_build_internal_buffer_obj (
256 ******************************************************************************/ 249 ******************************************************************************/
257 250
258acpi_status 251acpi_status
259acpi_ds_build_internal_package_obj ( 252acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
260 struct acpi_walk_state *walk_state, 253 union acpi_parse_object *op,
261 union acpi_parse_object *op, 254 u32 package_length,
262 u32 package_length, 255 union acpi_operand_object **obj_desc_ptr)
263 union acpi_operand_object **obj_desc_ptr)
264{ 256{
265 union acpi_parse_object *arg; 257 union acpi_parse_object *arg;
266 union acpi_parse_object *parent; 258 union acpi_parse_object *parent;
267 union acpi_operand_object *obj_desc = NULL; 259 union acpi_operand_object *obj_desc = NULL;
268 u32 package_list_length; 260 u32 package_list_length;
269 acpi_status status = AE_OK; 261 acpi_status status = AE_OK;
270 u32 i; 262 u32 i;
271
272
273 ACPI_FUNCTION_TRACE ("ds_build_internal_package_obj");
274 263
264 ACPI_FUNCTION_TRACE("ds_build_internal_package_obj");
275 265
276 /* Find the parent of a possibly nested package */ 266 /* Find the parent of a possibly nested package */
277 267
278 parent = op->common.parent; 268 parent = op->common.parent;
279 while ((parent->common.aml_opcode == AML_PACKAGE_OP) || 269 while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
280 (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { 270 (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
281 parent = parent->common.parent; 271 parent = parent->common.parent;
282 } 272 }
283 273
@@ -287,12 +277,11 @@ acpi_ds_build_internal_package_obj (
287 * We are evaluating a Named package object "Name (xxxx, Package)". 277 * We are evaluating a Named package object "Name (xxxx, Package)".
288 * Get the existing package object from the NS node 278 * Get the existing package object from the NS node
289 */ 279 */
290 } 280 } else {
291 else { 281 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
292 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
293 *obj_desc_ptr = obj_desc; 282 *obj_desc_ptr = obj_desc;
294 if (!obj_desc) { 283 if (!obj_desc) {
295 return_ACPI_STATUS (AE_NO_MEMORY); 284 return_ACPI_STATUS(AE_NO_MEMORY);
296 } 285 }
297 286
298 obj_desc->package.node = parent->common.node; 287 obj_desc->package.node = parent->common.node;
@@ -323,12 +312,13 @@ acpi_ds_build_internal_package_obj (
323 * individual objects). Add an extra pointer slot so 312 * individual objects). Add an extra pointer slot so
324 * that the list is always null terminated. 313 * that the list is always null terminated.
325 */ 314 */
326 obj_desc->package.elements = ACPI_MEM_CALLOCATE ( 315 obj_desc->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) obj_desc->
327 ((acpi_size) obj_desc->package.count + 1) * sizeof (void *)); 316 package.count +
317 1) * sizeof(void *));
328 318
329 if (!obj_desc->package.elements) { 319 if (!obj_desc->package.elements) {
330 acpi_ut_delete_object_desc (obj_desc); 320 acpi_ut_delete_object_desc(obj_desc);
331 return_ACPI_STATUS (AE_NO_MEMORY); 321 return_ACPI_STATUS(AE_NO_MEMORY);
332 } 322 }
333 323
334 /* 324 /*
@@ -342,11 +332,13 @@ acpi_ds_build_internal_package_obj (
342 /* Object (package or buffer) is already built */ 332 /* Object (package or buffer) is already built */
343 333
344 obj_desc->package.elements[i] = 334 obj_desc->package.elements[i] =
345 ACPI_CAST_PTR (union acpi_operand_object, arg->common.node); 335 ACPI_CAST_PTR(union acpi_operand_object,
346 } 336 arg->common.node);
347 else { 337 } else {
348 status = acpi_ds_build_internal_object (walk_state, arg, 338 status = acpi_ds_build_internal_object(walk_state, arg,
349 &obj_desc->package.elements[i]); 339 &obj_desc->
340 package.
341 elements[i]);
350 } 342 }
351 343
352 i++; 344 i++;
@@ -354,11 +346,10 @@ acpi_ds_build_internal_package_obj (
354 } 346 }
355 347
356 obj_desc->package.flags |= AOPOBJ_DATA_VALID; 348 obj_desc->package.flags |= AOPOBJ_DATA_VALID;
357 op->common.node = (struct acpi_namespace_node *) obj_desc; 349 op->common.node = (struct acpi_namespace_node *)obj_desc;
358 return_ACPI_STATUS (status); 350 return_ACPI_STATUS(status);
359} 351}
360 352
361
362/******************************************************************************* 353/*******************************************************************************
363 * 354 *
364 * FUNCTION: acpi_ds_create_node 355 * FUNCTION: acpi_ds_create_node
@@ -374,57 +365,53 @@ acpi_ds_build_internal_package_obj (
374 ******************************************************************************/ 365 ******************************************************************************/
375 366
376acpi_status 367acpi_status
377acpi_ds_create_node ( 368acpi_ds_create_node(struct acpi_walk_state *walk_state,
378 struct acpi_walk_state *walk_state, 369 struct acpi_namespace_node *node,
379 struct acpi_namespace_node *node, 370 union acpi_parse_object *op)
380 union acpi_parse_object *op)
381{ 371{
382 acpi_status status; 372 acpi_status status;
383 union acpi_operand_object *obj_desc; 373 union acpi_operand_object *obj_desc;
384
385
386 ACPI_FUNCTION_TRACE_PTR ("ds_create_node", op);
387 374
375 ACPI_FUNCTION_TRACE_PTR("ds_create_node", op);
388 376
389 /* 377 /*
390 * Because of the execution pass through the non-control-method 378 * Because of the execution pass through the non-control-method
391 * parts of the table, we can arrive here twice. Only init 379 * parts of the table, we can arrive here twice. Only init
392 * the named object node the first time through 380 * the named object node the first time through
393 */ 381 */
394 if (acpi_ns_get_attached_object (node)) { 382 if (acpi_ns_get_attached_object(node)) {
395 return_ACPI_STATUS (AE_OK); 383 return_ACPI_STATUS(AE_OK);
396 } 384 }
397 385
398 if (!op->common.value.arg) { 386 if (!op->common.value.arg) {
399 /* No arguments, there is nothing to do */ 387 /* No arguments, there is nothing to do */
400 388
401 return_ACPI_STATUS (AE_OK); 389 return_ACPI_STATUS(AE_OK);
402 } 390 }
403 391
404 /* Build an internal object for the argument(s) */ 392 /* Build an internal object for the argument(s) */
405 393
406 status = acpi_ds_build_internal_object (walk_state, op->common.value.arg, 394 status = acpi_ds_build_internal_object(walk_state, op->common.value.arg,
407 &obj_desc); 395 &obj_desc);
408 if (ACPI_FAILURE (status)) { 396 if (ACPI_FAILURE(status)) {
409 return_ACPI_STATUS (status); 397 return_ACPI_STATUS(status);
410 } 398 }
411 399
412 /* Re-type the object according to its argument */ 400 /* Re-type the object according to its argument */
413 401
414 node->type = ACPI_GET_OBJECT_TYPE (obj_desc); 402 node->type = ACPI_GET_OBJECT_TYPE(obj_desc);
415 403
416 /* Attach obj to node */ 404 /* Attach obj to node */
417 405
418 status = acpi_ns_attach_object (node, obj_desc, node->type); 406 status = acpi_ns_attach_object(node, obj_desc, node->type);
419 407
420 /* Remove local reference to the object */ 408 /* Remove local reference to the object */
421 409
422 acpi_ut_remove_reference (obj_desc); 410 acpi_ut_remove_reference(obj_desc);
423 return_ACPI_STATUS (status); 411 return_ACPI_STATUS(status);
424} 412}
425 413
426#endif /* ACPI_NO_METHOD_EXECUTION */ 414#endif /* ACPI_NO_METHOD_EXECUTION */
427
428 415
429/******************************************************************************* 416/*******************************************************************************
430 * 417 *
@@ -444,55 +431,50 @@ acpi_ds_create_node (
444 ******************************************************************************/ 431 ******************************************************************************/
445 432
446acpi_status 433acpi_status
447acpi_ds_init_object_from_op ( 434acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
448 struct acpi_walk_state *walk_state, 435 union acpi_parse_object *op,
449 union acpi_parse_object *op, 436 u16 opcode,
450 u16 opcode, 437 union acpi_operand_object **ret_obj_desc)
451 union acpi_operand_object **ret_obj_desc)
452{ 438{
453 const struct acpi_opcode_info *op_info; 439 const struct acpi_opcode_info *op_info;
454 union acpi_operand_object *obj_desc; 440 union acpi_operand_object *obj_desc;
455 acpi_status status = AE_OK; 441 acpi_status status = AE_OK;
456
457
458 ACPI_FUNCTION_TRACE ("ds_init_object_from_op");
459 442
443 ACPI_FUNCTION_TRACE("ds_init_object_from_op");
460 444
461 obj_desc = *ret_obj_desc; 445 obj_desc = *ret_obj_desc;
462 op_info = acpi_ps_get_opcode_info (opcode); 446 op_info = acpi_ps_get_opcode_info(opcode);
463 if (op_info->class == AML_CLASS_UNKNOWN) { 447 if (op_info->class == AML_CLASS_UNKNOWN) {
464 /* Unknown opcode */ 448 /* Unknown opcode */
465 449
466 return_ACPI_STATUS (AE_TYPE); 450 return_ACPI_STATUS(AE_TYPE);
467 } 451 }
468 452
469 /* Perform per-object initialization */ 453 /* Perform per-object initialization */
470 454
471 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 455 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
472 case ACPI_TYPE_BUFFER: 456 case ACPI_TYPE_BUFFER:
473 457
474 /* 458 /*
475 * Defer evaluation of Buffer term_arg operand 459 * Defer evaluation of Buffer term_arg operand
476 */ 460 */
477 obj_desc->buffer.node = (struct acpi_namespace_node *) 461 obj_desc->buffer.node = (struct acpi_namespace_node *)
478 walk_state->operands[0]; 462 walk_state->operands[0];
479 obj_desc->buffer.aml_start = op->named.data; 463 obj_desc->buffer.aml_start = op->named.data;
480 obj_desc->buffer.aml_length = op->named.length; 464 obj_desc->buffer.aml_length = op->named.length;
481 break; 465 break;
482 466
483
484 case ACPI_TYPE_PACKAGE: 467 case ACPI_TYPE_PACKAGE:
485 468
486 /* 469 /*
487 * Defer evaluation of Package term_arg operand 470 * Defer evaluation of Package term_arg operand
488 */ 471 */
489 obj_desc->package.node = (struct acpi_namespace_node *) 472 obj_desc->package.node = (struct acpi_namespace_node *)
490 walk_state->operands[0]; 473 walk_state->operands[0];
491 obj_desc->package.aml_start = op->named.data; 474 obj_desc->package.aml_start = op->named.data;
492 obj_desc->package.aml_length = op->named.length; 475 obj_desc->package.aml_length = op->named.length;
493 break; 476 break;
494 477
495
496 case ACPI_TYPE_INTEGER: 478 case ACPI_TYPE_INTEGER:
497 479
498 switch (op_info->type) { 480 switch (op_info->type) {
@@ -525,7 +507,7 @@ acpi_ds_init_object_from_op (
525 /* Truncate value if we are executing from a 32-bit ACPI table */ 507 /* Truncate value if we are executing from a 32-bit ACPI table */
526 508
527#ifndef ACPI_NO_METHOD_EXECUTION 509#ifndef ACPI_NO_METHOD_EXECUTION
528 acpi_ex_truncate_for32bit_table (obj_desc); 510 acpi_ex_truncate_for32bit_table(obj_desc);
529#endif 511#endif
530 break; 512 break;
531 513
@@ -536,33 +518,36 @@ acpi_ds_init_object_from_op (
536 518
537 default: 519 default:
538 520
539 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 521 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
540 "Unknown constant opcode %X\n", opcode)); 522 "Unknown constant opcode %X\n",
523 opcode));
541 status = AE_AML_OPERAND_TYPE; 524 status = AE_AML_OPERAND_TYPE;
542 break; 525 break;
543 } 526 }
544 break; 527 break;
545 528
546
547 case AML_TYPE_LITERAL: 529 case AML_TYPE_LITERAL:
548 530
549 obj_desc->integer.value = op->common.value.integer; 531 obj_desc->integer.value = op->common.value.integer;
532#ifndef ACPI_NO_METHOD_EXECUTION
533 acpi_ex_truncate_for32bit_table(obj_desc);
534#endif
550 break; 535 break;
551 536
552
553 default: 537 default:
554 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", 538 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
555 op_info->type)); 539 "Unknown Integer type %X\n",
540 op_info->type));
556 status = AE_AML_OPERAND_TYPE; 541 status = AE_AML_OPERAND_TYPE;
557 break; 542 break;
558 } 543 }
559 break; 544 break;
560 545
561
562 case ACPI_TYPE_STRING: 546 case ACPI_TYPE_STRING:
563 547
564 obj_desc->string.pointer = op->common.value.string; 548 obj_desc->string.pointer = op->common.value.string;
565 obj_desc->string.length = (u32) ACPI_STRLEN (op->common.value.string); 549 obj_desc->string.length =
550 (u32) ACPI_STRLEN(op->common.value.string);
566 551
567 /* 552 /*
568 * The string is contained in the ACPI table, don't ever try 553 * The string is contained in the ACPI table, don't ever try
@@ -571,11 +556,9 @@ acpi_ds_init_object_from_op (
571 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 556 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
572 break; 557 break;
573 558
574
575 case ACPI_TYPE_METHOD: 559 case ACPI_TYPE_METHOD:
576 break; 560 break;
577 561
578
579 case ACPI_TYPE_LOCAL_REFERENCE: 562 case ACPI_TYPE_LOCAL_REFERENCE:
580 563
581 switch (op_info->type) { 564 switch (op_info->type) {
@@ -587,14 +570,17 @@ acpi_ds_init_object_from_op (
587 obj_desc->reference.offset = opcode - AML_LOCAL_OP; 570 obj_desc->reference.offset = opcode - AML_LOCAL_OP;
588 571
589#ifndef ACPI_NO_METHOD_EXECUTION 572#ifndef ACPI_NO_METHOD_EXECUTION
590 status = acpi_ds_method_data_get_node (AML_LOCAL_OP, 573 status = acpi_ds_method_data_get_node(AML_LOCAL_OP,
591 obj_desc->reference.offset, 574 obj_desc->
592 walk_state, 575 reference.offset,
593 (struct acpi_namespace_node **) &obj_desc->reference.object); 576 walk_state,
577 (struct
578 acpi_namespace_node
579 **)&obj_desc->
580 reference.object);
594#endif 581#endif
595 break; 582 break;
596 583
597
598 case AML_TYPE_METHOD_ARGUMENT: 584 case AML_TYPE_METHOD_ARGUMENT:
599 585
600 /* Split the opcode into a base opcode + offset */ 586 /* Split the opcode into a base opcode + offset */
@@ -603,14 +589,18 @@ acpi_ds_init_object_from_op (
603 obj_desc->reference.offset = opcode - AML_ARG_OP; 589 obj_desc->reference.offset = opcode - AML_ARG_OP;
604 590
605#ifndef ACPI_NO_METHOD_EXECUTION 591#ifndef ACPI_NO_METHOD_EXECUTION
606 status = acpi_ds_method_data_get_node (AML_ARG_OP, 592 status = acpi_ds_method_data_get_node(AML_ARG_OP,
607 obj_desc->reference.offset, 593 obj_desc->
608 walk_state, 594 reference.offset,
609 (struct acpi_namespace_node **) &obj_desc->reference.object); 595 walk_state,
596 (struct
597 acpi_namespace_node
598 **)&obj_desc->
599 reference.object);
610#endif 600#endif
611 break; 601 break;
612 602
613 default: /* Other literals, etc.. */ 603 default: /* Other literals, etc.. */
614 604
615 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 605 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
616 /* Node was saved in Op */ 606 /* Node was saved in Op */
@@ -623,17 +613,15 @@ acpi_ds_init_object_from_op (
623 } 613 }
624 break; 614 break;
625 615
626
627 default: 616 default:
628 617
629 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", 618 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
630 ACPI_GET_OBJECT_TYPE (obj_desc))); 619 "Unimplemented data type: %X\n",
620 ACPI_GET_OBJECT_TYPE(obj_desc)));
631 621
632 status = AE_AML_OPERAND_TYPE; 622 status = AE_AML_OPERAND_TYPE;
633 break; 623 break;
634 } 624 }
635 625
636 return_ACPI_STATUS (status); 626 return_ACPI_STATUS(status);
637} 627}
638
639
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index ba13bca28bee..939d167bf87b 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
@@ -52,26 +51,21 @@
52#include <acpi/acevents.h> 51#include <acpi/acevents.h>
53 52
54#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
55 ACPI_MODULE_NAME ("dsopcode") 54ACPI_MODULE_NAME("dsopcode")
56 55
57/* Local prototypes */ 56/* Local prototypes */
58
59static acpi_status 57static acpi_status
60acpi_ds_execute_arguments ( 58acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *node, 59 struct acpi_namespace_node *scope_node,
62 struct acpi_namespace_node *scope_node, 60 u32 aml_length, u8 * aml_start);
63 u32 aml_length,
64 u8 *aml_start);
65 61
66static acpi_status 62static acpi_status
67acpi_ds_init_buffer_field ( 63acpi_ds_init_buffer_field(u16 aml_opcode,
68 u16 aml_opcode, 64 union acpi_operand_object *obj_desc,
69 union acpi_operand_object *obj_desc, 65 union acpi_operand_object *buffer_desc,
70 union acpi_operand_object *buffer_desc, 66 union acpi_operand_object *offset_desc,
71 union acpi_operand_object *offset_desc, 67 union acpi_operand_object *length_desc,
72 union acpi_operand_object *length_desc, 68 union acpi_operand_object *result_desc);
73 union acpi_operand_object *result_desc);
74
75 69
76/******************************************************************************* 70/*******************************************************************************
77 * 71 *
@@ -89,26 +83,22 @@ acpi_ds_init_buffer_field (
89 ******************************************************************************/ 83 ******************************************************************************/
90 84
91static acpi_status 85static acpi_status
92acpi_ds_execute_arguments ( 86acpi_ds_execute_arguments(struct acpi_namespace_node *node,
93 struct acpi_namespace_node *node, 87 struct acpi_namespace_node *scope_node,
94 struct acpi_namespace_node *scope_node, 88 u32 aml_length, u8 * aml_start)
95 u32 aml_length,
96 u8 *aml_start)
97{ 89{
98 acpi_status status; 90 acpi_status status;
99 union acpi_parse_object *op; 91 union acpi_parse_object *op;
100 struct acpi_walk_state *walk_state; 92 struct acpi_walk_state *walk_state;
101
102
103 ACPI_FUNCTION_TRACE ("ds_execute_arguments");
104 93
94 ACPI_FUNCTION_TRACE("ds_execute_arguments");
105 95
106 /* 96 /*
107 * Allocate a new parser op to be the root of the parsed tree 97 * Allocate a new parser op to be the root of the parsed tree
108 */ 98 */
109 op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); 99 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
110 if (!op) { 100 if (!op) {
111 return_ACPI_STATUS (AE_NO_MEMORY); 101 return_ACPI_STATUS(AE_NO_MEMORY);
112 } 102 }
113 103
114 /* Save the Node for use in acpi_ps_parse_aml */ 104 /* Save the Node for use in acpi_ps_parse_aml */
@@ -117,16 +107,17 @@ acpi_ds_execute_arguments (
117 107
118 /* Create and initialize a new parser state */ 108 /* Create and initialize a new parser state */
119 109
120 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 110 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
121 if (!walk_state) { 111 if (!walk_state) {
122 return_ACPI_STATUS (AE_NO_MEMORY); 112 status = AE_NO_MEMORY;
113 goto cleanup;
123 } 114 }
124 115
125 status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, 116 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
126 aml_length, NULL, 1); 117 aml_length, NULL, 1);
127 if (ACPI_FAILURE (status)) { 118 if (ACPI_FAILURE(status)) {
128 acpi_ds_delete_walk_state (walk_state); 119 acpi_ds_delete_walk_state(walk_state);
129 return_ACPI_STATUS (status); 120 goto cleanup;
130 } 121 }
131 122
132 /* Mark this parse as a deferred opcode */ 123 /* Mark this parse as a deferred opcode */
@@ -136,50 +127,51 @@ acpi_ds_execute_arguments (
136 127
137 /* Pass1: Parse the entire declaration */ 128 /* Pass1: Parse the entire declaration */
138 129
139 status = acpi_ps_parse_aml (walk_state); 130 status = acpi_ps_parse_aml(walk_state);
140 if (ACPI_FAILURE (status)) { 131 if (ACPI_FAILURE(status)) {
141 acpi_ps_delete_parse_tree (op); 132 goto cleanup;
142 return_ACPI_STATUS (status);
143 } 133 }
144 134
145 /* Get and init the Op created above */ 135 /* Get and init the Op created above */
146 136
147 op->common.node = node; 137 op->common.node = node;
148 acpi_ps_delete_parse_tree (op); 138 acpi_ps_delete_parse_tree(op);
149 139
150 /* Evaluate the deferred arguments */ 140 /* Evaluate the deferred arguments */
151 141
152 op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); 142 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
153 if (!op) { 143 if (!op) {
154 return_ACPI_STATUS (AE_NO_MEMORY); 144 return_ACPI_STATUS(AE_NO_MEMORY);
155 } 145 }
156 146
157 op->common.node = scope_node; 147 op->common.node = scope_node;
158 148
159 /* Create and initialize a new parser state */ 149 /* Create and initialize a new parser state */
160 150
161 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 151 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
162 if (!walk_state) { 152 if (!walk_state) {
163 return_ACPI_STATUS (AE_NO_MEMORY); 153 status = AE_NO_MEMORY;
154 goto cleanup;
164 } 155 }
165 156
166 /* Execute the opcode and arguments */ 157 /* Execute the opcode and arguments */
167 158
168 status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, 159 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
169 aml_length, NULL, 3); 160 aml_length, NULL, 3);
170 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
171 acpi_ds_delete_walk_state (walk_state); 162 acpi_ds_delete_walk_state(walk_state);
172 return_ACPI_STATUS (status); 163 goto cleanup;
173 } 164 }
174 165
175 /* Mark this execution as a deferred opcode */ 166 /* Mark this execution as a deferred opcode */
176 167
177 walk_state->deferred_node = node; 168 walk_state->deferred_node = node;
178 status = acpi_ps_parse_aml (walk_state); 169 status = acpi_ps_parse_aml(walk_state);
179 acpi_ps_delete_parse_tree (op);
180 return_ACPI_STATUS (status);
181}
182 170
171 cleanup:
172 acpi_ps_delete_parse_tree(op);
173 return_ACPI_STATUS(status);
174}
183 175
184/******************************************************************************* 176/*******************************************************************************
185 * 177 *
@@ -195,38 +187,36 @@ acpi_ds_execute_arguments (
195 ******************************************************************************/ 187 ******************************************************************************/
196 188
197acpi_status 189acpi_status
198acpi_ds_get_buffer_field_arguments ( 190acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
199 union acpi_operand_object *obj_desc)
200{ 191{
201 union acpi_operand_object *extra_desc; 192 union acpi_operand_object *extra_desc;
202 struct acpi_namespace_node *node; 193 struct acpi_namespace_node *node;
203 acpi_status status; 194 acpi_status status;
204
205
206 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc);
207 195
196 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc);
208 197
209 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 198 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
210 return_ACPI_STATUS (AE_OK); 199 return_ACPI_STATUS(AE_OK);
211 } 200 }
212 201
213 /* Get the AML pointer (method object) and buffer_field node */ 202 /* Get the AML pointer (method object) and buffer_field node */
214 203
215 extra_desc = acpi_ns_get_secondary_object (obj_desc); 204 extra_desc = acpi_ns_get_secondary_object(obj_desc);
216 node = obj_desc->buffer_field.node; 205 node = obj_desc->buffer_field.node;
217 206
218 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL)); 207 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
219 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", 208 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
220 acpi_ut_get_node_name (node))); 209 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n",
210 acpi_ut_get_node_name(node)));
221 211
222 /* Execute the AML code for the term_arg arguments */ 212 /* Execute the AML code for the term_arg arguments */
223 213
224 status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), 214 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
225 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 215 extra_desc->extra.aml_length,
226 return_ACPI_STATUS (status); 216 extra_desc->extra.aml_start);
217 return_ACPI_STATUS(status);
227} 218}
228 219
229
230/******************************************************************************* 220/*******************************************************************************
231 * 221 *
232 * FUNCTION: acpi_ds_get_buffer_arguments 222 * FUNCTION: acpi_ds_get_buffer_arguments
@@ -240,40 +230,35 @@ acpi_ds_get_buffer_field_arguments (
240 * 230 *
241 ******************************************************************************/ 231 ******************************************************************************/
242 232
243acpi_status 233acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
244acpi_ds_get_buffer_arguments (
245 union acpi_operand_object *obj_desc)
246{ 234{
247 struct acpi_namespace_node *node; 235 struct acpi_namespace_node *node;
248 acpi_status status; 236 acpi_status status;
249
250
251 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc);
252 237
238 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc);
253 239
254 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 240 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
255 return_ACPI_STATUS (AE_OK); 241 return_ACPI_STATUS(AE_OK);
256 } 242 }
257 243
258 /* Get the Buffer node */ 244 /* Get the Buffer node */
259 245
260 node = obj_desc->buffer.node; 246 node = obj_desc->buffer.node;
261 if (!node) { 247 if (!node) {
262 ACPI_REPORT_ERROR (( 248 ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc));
263 "No pointer back to NS node in buffer obj %p\n", obj_desc)); 249 return_ACPI_STATUS(AE_AML_INTERNAL);
264 return_ACPI_STATUS (AE_AML_INTERNAL);
265 } 250 }
266 251
267 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 252 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
268 253
269 /* Execute the AML code for the term_arg arguments */ 254 /* Execute the AML code for the term_arg arguments */
270 255
271 status = acpi_ds_execute_arguments (node, node, 256 status = acpi_ds_execute_arguments(node, node,
272 obj_desc->buffer.aml_length, obj_desc->buffer.aml_start); 257 obj_desc->buffer.aml_length,
273 return_ACPI_STATUS (status); 258 obj_desc->buffer.aml_start);
259 return_ACPI_STATUS(status);
274} 260}
275 261
276
277/******************************************************************************* 262/*******************************************************************************
278 * 263 *
279 * FUNCTION: acpi_ds_get_package_arguments 264 * FUNCTION: acpi_ds_get_package_arguments
@@ -287,40 +272,36 @@ acpi_ds_get_buffer_arguments (
287 * 272 *
288 ******************************************************************************/ 273 ******************************************************************************/
289 274
290acpi_status 275acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
291acpi_ds_get_package_arguments (
292 union acpi_operand_object *obj_desc)
293{ 276{
294 struct acpi_namespace_node *node; 277 struct acpi_namespace_node *node;
295 acpi_status status; 278 acpi_status status;
296
297
298 ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc);
299 279
280 ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc);
300 281
301 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 282 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
302 return_ACPI_STATUS (AE_OK); 283 return_ACPI_STATUS(AE_OK);
303 } 284 }
304 285
305 /* Get the Package node */ 286 /* Get the Package node */
306 287
307 node = obj_desc->package.node; 288 node = obj_desc->package.node;
308 if (!node) { 289 if (!node) {
309 ACPI_REPORT_ERROR (( 290 ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n",
310 "No pointer back to NS node in package %p\n", obj_desc)); 291 obj_desc));
311 return_ACPI_STATUS (AE_AML_INTERNAL); 292 return_ACPI_STATUS(AE_AML_INTERNAL);
312 } 293 }
313 294
314 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 295 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
315 296
316 /* Execute the AML code for the term_arg arguments */ 297 /* Execute the AML code for the term_arg arguments */
317 298
318 status = acpi_ds_execute_arguments (node, node, 299 status = acpi_ds_execute_arguments(node, node,
319 obj_desc->package.aml_length, obj_desc->package.aml_start); 300 obj_desc->package.aml_length,
320 return_ACPI_STATUS (status); 301 obj_desc->package.aml_start);
302 return_ACPI_STATUS(status);
321} 303}
322 304
323
324/***************************************************************************** 305/*****************************************************************************
325 * 306 *
326 * FUNCTION: acpi_ds_get_region_arguments 307 * FUNCTION: acpi_ds_get_region_arguments
@@ -334,44 +315,43 @@ acpi_ds_get_package_arguments (
334 * 315 *
335 ****************************************************************************/ 316 ****************************************************************************/
336 317
337acpi_status 318acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
338acpi_ds_get_region_arguments (
339 union acpi_operand_object *obj_desc)
340{ 319{
341 struct acpi_namespace_node *node; 320 struct acpi_namespace_node *node;
342 acpi_status status; 321 acpi_status status;
343 union acpi_operand_object *extra_desc; 322 union acpi_operand_object *extra_desc;
344
345
346 ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc);
347 323
324 ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc);
348 325
349 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 326 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
350 return_ACPI_STATUS (AE_OK); 327 return_ACPI_STATUS(AE_OK);
351 } 328 }
352 329
353 extra_desc = acpi_ns_get_secondary_object (obj_desc); 330 extra_desc = acpi_ns_get_secondary_object(obj_desc);
354 if (!extra_desc) { 331 if (!extra_desc) {
355 return_ACPI_STATUS (AE_NOT_EXIST); 332 return_ACPI_STATUS(AE_NOT_EXIST);
356 } 333 }
357 334
358 /* Get the Region node */ 335 /* Get the Region node */
359 336
360 node = obj_desc->region.node; 337 node = obj_desc->region.node;
361 338
362 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL)); 339 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
340 (ACPI_TYPE_REGION, node, NULL));
363 341
364 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n", 342 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
365 acpi_ut_get_node_name (node), extra_desc->extra.aml_start)); 343 "[%4.4s] op_region Arg Init at AML %p\n",
344 acpi_ut_get_node_name(node),
345 extra_desc->extra.aml_start));
366 346
367 /* Execute the argument AML */ 347 /* Execute the argument AML */
368 348
369 status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), 349 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
370 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 350 extra_desc->extra.aml_length,
371 return_ACPI_STATUS (status); 351 extra_desc->extra.aml_start);
352 return_ACPI_STATUS(status);
372} 353}
373 354
374
375/******************************************************************************* 355/*******************************************************************************
376 * 356 *
377 * FUNCTION: acpi_ds_initialize_region 357 * FUNCTION: acpi_ds_initialize_region
@@ -384,23 +364,19 @@ acpi_ds_get_region_arguments (
384 * 364 *
385 ******************************************************************************/ 365 ******************************************************************************/
386 366
387acpi_status 367acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
388acpi_ds_initialize_region (
389 acpi_handle obj_handle)
390{ 368{
391 union acpi_operand_object *obj_desc; 369 union acpi_operand_object *obj_desc;
392 acpi_status status; 370 acpi_status status;
393 371
394 372 obj_desc = acpi_ns_get_attached_object(obj_handle);
395 obj_desc = acpi_ns_get_attached_object (obj_handle);
396 373
397 /* Namespace is NOT locked */ 374 /* Namespace is NOT locked */
398 375
399 status = acpi_ev_initialize_region (obj_desc, FALSE); 376 status = acpi_ev_initialize_region(obj_desc, FALSE);
400 return (status); 377 return (status);
401} 378}
402 379
403
404/******************************************************************************* 380/*******************************************************************************
405 * 381 *
406 * FUNCTION: acpi_ds_init_buffer_field 382 * FUNCTION: acpi_ds_init_buffer_field
@@ -419,30 +395,27 @@ acpi_ds_initialize_region (
419 ******************************************************************************/ 395 ******************************************************************************/
420 396
421static acpi_status 397static acpi_status
422acpi_ds_init_buffer_field ( 398acpi_ds_init_buffer_field(u16 aml_opcode,
423 u16 aml_opcode, 399 union acpi_operand_object *obj_desc,
424 union acpi_operand_object *obj_desc, 400 union acpi_operand_object *buffer_desc,
425 union acpi_operand_object *buffer_desc, 401 union acpi_operand_object *offset_desc,
426 union acpi_operand_object *offset_desc, 402 union acpi_operand_object *length_desc,
427 union acpi_operand_object *length_desc, 403 union acpi_operand_object *result_desc)
428 union acpi_operand_object *result_desc)
429{ 404{
430 u32 offset; 405 u32 offset;
431 u32 bit_offset; 406 u32 bit_offset;
432 u32 bit_count; 407 u32 bit_count;
433 u8 field_flags; 408 u8 field_flags;
434 acpi_status status; 409 acpi_status status;
435
436
437 ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc);
438 410
411 ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc);
439 412
440 /* Host object must be a Buffer */ 413 /* Host object must be a Buffer */
441 414
442 if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) { 415 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
443 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
444 "Target of Create Field is not a Buffer object - %s\n", 417 "Target of Create Field is not a Buffer object - %s\n",
445 acpi_ut_get_object_type_name (buffer_desc))); 418 acpi_ut_get_object_type_name(buffer_desc)));
446 419
447 status = AE_AML_OPERAND_TYPE; 420 status = AE_AML_OPERAND_TYPE;
448 goto cleanup; 421 goto cleanup;
@@ -453,11 +426,11 @@ acpi_ds_init_buffer_field (
453 * out as a name_string, and should therefore now be a NS node 426 * out as a name_string, and should therefore now be a NS node
454 * after resolution in acpi_ex_resolve_operands(). 427 * after resolution in acpi_ex_resolve_operands().
455 */ 428 */
456 if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { 429 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
457 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 430 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
458 "(%s) destination not a NS Node [%s]\n", 431 "(%s) destination not a NS Node [%s]\n",
459 acpi_ps_get_opcode_name (aml_opcode), 432 acpi_ps_get_opcode_name(aml_opcode),
460 acpi_ut_get_descriptor_name (result_desc))); 433 acpi_ut_get_descriptor_name(result_desc)));
461 434
462 status = AE_AML_OPERAND_TYPE; 435 status = AE_AML_OPERAND_TYPE;
463 goto cleanup; 436 goto cleanup;
@@ -475,13 +448,13 @@ acpi_ds_init_buffer_field (
475 448
476 field_flags = AML_FIELD_ACCESS_BYTE; 449 field_flags = AML_FIELD_ACCESS_BYTE;
477 bit_offset = offset; 450 bit_offset = offset;
478 bit_count = (u32) length_desc->integer.value; 451 bit_count = (u32) length_desc->integer.value;
479 452
480 /* Must have a valid (>0) bit count */ 453 /* Must have a valid (>0) bit count */
481 454
482 if (bit_count == 0) { 455 if (bit_count == 0) {
483 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 456 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
484 "Attempt to create_field of length 0\n")); 457 "Attempt to create_field of length 0\n"));
485 status = AE_AML_OPERAND_VALUE; 458 status = AE_AML_OPERAND_VALUE;
486 goto cleanup; 459 goto cleanup;
487 } 460 }
@@ -492,7 +465,7 @@ acpi_ds_init_buffer_field (
492 /* Offset is in bits, Field is one bit */ 465 /* Offset is in bits, Field is one bit */
493 466
494 bit_offset = offset; 467 bit_offset = offset;
495 bit_count = 1; 468 bit_count = 1;
496 field_flags = AML_FIELD_ACCESS_BYTE; 469 field_flags = AML_FIELD_ACCESS_BYTE;
497 break; 470 break;
498 471
@@ -501,7 +474,7 @@ acpi_ds_init_buffer_field (
501 /* Offset is in bytes, field is one byte */ 474 /* Offset is in bytes, field is one byte */
502 475
503 bit_offset = 8 * offset; 476 bit_offset = 8 * offset;
504 bit_count = 8; 477 bit_count = 8;
505 field_flags = AML_FIELD_ACCESS_BYTE; 478 field_flags = AML_FIELD_ACCESS_BYTE;
506 break; 479 break;
507 480
@@ -510,7 +483,7 @@ acpi_ds_init_buffer_field (
510 /* Offset is in bytes, field is one word */ 483 /* Offset is in bytes, field is one word */
511 484
512 bit_offset = 8 * offset; 485 bit_offset = 8 * offset;
513 bit_count = 16; 486 bit_count = 16;
514 field_flags = AML_FIELD_ACCESS_WORD; 487 field_flags = AML_FIELD_ACCESS_WORD;
515 break; 488 break;
516 489
@@ -519,7 +492,7 @@ acpi_ds_init_buffer_field (
519 /* Offset is in bytes, field is one dword */ 492 /* Offset is in bytes, field is one dword */
520 493
521 bit_offset = 8 * offset; 494 bit_offset = 8 * offset;
522 bit_count = 32; 495 bit_count = 32;
523 field_flags = AML_FIELD_ACCESS_DWORD; 496 field_flags = AML_FIELD_ACCESS_DWORD;
524 break; 497 break;
525 498
@@ -528,29 +501,29 @@ acpi_ds_init_buffer_field (
528 /* Offset is in bytes, field is one qword */ 501 /* Offset is in bytes, field is one qword */
529 502
530 bit_offset = 8 * offset; 503 bit_offset = 8 * offset;
531 bit_count = 64; 504 bit_count = 64;
532 field_flags = AML_FIELD_ACCESS_QWORD; 505 field_flags = AML_FIELD_ACCESS_QWORD;
533 break; 506 break;
534 507
535 default: 508 default:
536 509
537 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 510 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
538 "Unknown field creation opcode %02x\n", 511 "Unknown field creation opcode %02x\n",
539 aml_opcode)); 512 aml_opcode));
540 status = AE_AML_BAD_OPCODE; 513 status = AE_AML_BAD_OPCODE;
541 goto cleanup; 514 goto cleanup;
542 } 515 }
543 516
544 /* Entire field must fit within the current length of the buffer */ 517 /* Entire field must fit within the current length of the buffer */
545 518
546 if ((bit_offset + bit_count) > 519 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
547 (8 * (u32) buffer_desc->buffer.length)) { 520 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
548 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 521 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n",
549 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 522 acpi_ut_get_node_name(result_desc),
550 acpi_ut_get_node_name (result_desc), 523 bit_offset + bit_count,
551 bit_offset + bit_count, 524 acpi_ut_get_node_name(buffer_desc->buffer.
552 acpi_ut_get_node_name (buffer_desc->buffer.node), 525 node),
553 8 * (u32) buffer_desc->buffer.length)); 526 8 * (u32) buffer_desc->buffer.length));
554 status = AE_AML_BUFFER_LIMIT; 527 status = AE_AML_BUFFER_LIMIT;
555 goto cleanup; 528 goto cleanup;
556 } 529 }
@@ -560,9 +533,9 @@ acpi_ds_init_buffer_field (
560 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), 533 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
561 * UPDATE_RULE = 0 (UPDATE_PRESERVE) 534 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
562 */ 535 */
563 status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0, 536 status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
564 bit_offset, bit_count); 537 bit_offset, bit_count);
565 if (ACPI_FAILURE (status)) { 538 if (ACPI_FAILURE(status)) {
566 goto cleanup; 539 goto cleanup;
567 } 540 }
568 541
@@ -571,35 +544,33 @@ acpi_ds_init_buffer_field (
571 /* Reference count for buffer_desc inherits obj_desc count */ 544 /* Reference count for buffer_desc inherits obj_desc count */
572 545
573 buffer_desc->common.reference_count = (u16) 546 buffer_desc->common.reference_count = (u16)
574 (buffer_desc->common.reference_count + obj_desc->common.reference_count); 547 (buffer_desc->common.reference_count +
548 obj_desc->common.reference_count);
575 549
576 550 cleanup:
577cleanup:
578 551
579 /* Always delete the operands */ 552 /* Always delete the operands */
580 553
581 acpi_ut_remove_reference (offset_desc); 554 acpi_ut_remove_reference(offset_desc);
582 acpi_ut_remove_reference (buffer_desc); 555 acpi_ut_remove_reference(buffer_desc);
583 556
584 if (aml_opcode == AML_CREATE_FIELD_OP) { 557 if (aml_opcode == AML_CREATE_FIELD_OP) {
585 acpi_ut_remove_reference (length_desc); 558 acpi_ut_remove_reference(length_desc);
586 } 559 }
587 560
588 /* On failure, delete the result descriptor */ 561 /* On failure, delete the result descriptor */
589 562
590 if (ACPI_FAILURE (status)) { 563 if (ACPI_FAILURE(status)) {
591 acpi_ut_remove_reference (result_desc); /* Result descriptor */ 564 acpi_ut_remove_reference(result_desc); /* Result descriptor */
592 } 565 } else {
593 else {
594 /* Now the address and length are valid for this buffer_field */ 566 /* Now the address and length are valid for this buffer_field */
595 567
596 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; 568 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
597 } 569 }
598 570
599 return_ACPI_STATUS (status); 571 return_ACPI_STATUS(status);
600} 572}
601 573
602
603/******************************************************************************* 574/*******************************************************************************
604 * 575 *
605 * FUNCTION: acpi_ds_eval_buffer_field_operands 576 * FUNCTION: acpi_ds_eval_buffer_field_operands
@@ -615,24 +586,21 @@ cleanup:
615 ******************************************************************************/ 586 ******************************************************************************/
616 587
617acpi_status 588acpi_status
618acpi_ds_eval_buffer_field_operands ( 589acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
619 struct acpi_walk_state *walk_state, 590 union acpi_parse_object *op)
620 union acpi_parse_object *op)
621{ 591{
622 acpi_status status; 592 acpi_status status;
623 union acpi_operand_object *obj_desc; 593 union acpi_operand_object *obj_desc;
624 struct acpi_namespace_node *node; 594 struct acpi_namespace_node *node;
625 union acpi_parse_object *next_op; 595 union acpi_parse_object *next_op;
626
627
628 ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op);
629 596
597 ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op);
630 598
631 /* 599 /*
632 * This is where we evaluate the address and length fields of the 600 * This is where we evaluate the address and length fields of the
633 * create_xxx_field declaration 601 * create_xxx_field declaration
634 */ 602 */
635 node = op->common.node; 603 node = op->common.node;
636 604
637 /* next_op points to the op that holds the Buffer */ 605 /* next_op points to the op that holds the Buffer */
638 606
@@ -640,30 +608,32 @@ acpi_ds_eval_buffer_field_operands (
640 608
641 /* Evaluate/create the address and length operands */ 609 /* Evaluate/create the address and length operands */
642 610
643 status = acpi_ds_create_operands (walk_state, next_op); 611 status = acpi_ds_create_operands(walk_state, next_op);
644 if (ACPI_FAILURE (status)) { 612 if (ACPI_FAILURE(status)) {
645 return_ACPI_STATUS (status); 613 return_ACPI_STATUS(status);
646 } 614 }
647 615
648 obj_desc = acpi_ns_get_attached_object (node); 616 obj_desc = acpi_ns_get_attached_object(node);
649 if (!obj_desc) { 617 if (!obj_desc) {
650 return_ACPI_STATUS (AE_NOT_EXIST); 618 return_ACPI_STATUS(AE_NOT_EXIST);
651 } 619 }
652 620
653 /* Resolve the operands */ 621 /* Resolve the operands */
654 622
655 status = acpi_ex_resolve_operands (op->common.aml_opcode, 623 status = acpi_ex_resolve_operands(op->common.aml_opcode,
656 ACPI_WALK_OPERANDS, walk_state); 624 ACPI_WALK_OPERANDS, walk_state);
657 625
658 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 626 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
659 acpi_ps_get_opcode_name (op->common.aml_opcode), 627 acpi_ps_get_opcode_name(op->common.aml_opcode),
660 walk_state->num_operands, "after acpi_ex_resolve_operands"); 628 walk_state->num_operands,
629 "after acpi_ex_resolve_operands");
661 630
662 if (ACPI_FAILURE (status)) { 631 if (ACPI_FAILURE(status)) {
663 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
664 acpi_ps_get_opcode_name (op->common.aml_opcode), status)); 633 acpi_ps_get_opcode_name(op->common.
634 aml_opcode), status));
665 635
666 return_ACPI_STATUS (status); 636 return_ACPI_STATUS(status);
667 } 637 }
668 638
669 /* Initialize the Buffer Field */ 639 /* Initialize the Buffer Field */
@@ -671,22 +641,25 @@ acpi_ds_eval_buffer_field_operands (
671 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { 641 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
672 /* NOTE: Slightly different operands for this opcode */ 642 /* NOTE: Slightly different operands for this opcode */
673 643
674 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 644 status =
675 walk_state->operands[0], walk_state->operands[1], 645 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
676 walk_state->operands[2], walk_state->operands[3]); 646 walk_state->operands[0],
677 } 647 walk_state->operands[1],
678 else { 648 walk_state->operands[2],
649 walk_state->operands[3]);
650 } else {
679 /* All other, create_xxx_field opcodes */ 651 /* All other, create_xxx_field opcodes */
680 652
681 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 653 status =
682 walk_state->operands[0], walk_state->operands[1], 654 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
683 NULL, walk_state->operands[2]); 655 walk_state->operands[0],
656 walk_state->operands[1], NULL,
657 walk_state->operands[2]);
684 } 658 }
685 659
686 return_ACPI_STATUS (status); 660 return_ACPI_STATUS(status);
687} 661}
688 662
689
690/******************************************************************************* 663/*******************************************************************************
691 * 664 *
692 * FUNCTION: acpi_ds_eval_region_operands 665 * FUNCTION: acpi_ds_eval_region_operands
@@ -702,25 +675,22 @@ acpi_ds_eval_buffer_field_operands (
702 ******************************************************************************/ 675 ******************************************************************************/
703 676
704acpi_status 677acpi_status
705acpi_ds_eval_region_operands ( 678acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
706 struct acpi_walk_state *walk_state, 679 union acpi_parse_object *op)
707 union acpi_parse_object *op)
708{ 680{
709 acpi_status status; 681 acpi_status status;
710 union acpi_operand_object *obj_desc; 682 union acpi_operand_object *obj_desc;
711 union acpi_operand_object *operand_desc; 683 union acpi_operand_object *operand_desc;
712 struct acpi_namespace_node *node; 684 struct acpi_namespace_node *node;
713 union acpi_parse_object *next_op; 685 union acpi_parse_object *next_op;
714
715
716 ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op);
717 686
687 ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op);
718 688
719 /* 689 /*
720 * This is where we evaluate the address and length fields of the 690 * This is where we evaluate the address and length fields of the
721 * op_region declaration 691 * op_region declaration
722 */ 692 */
723 node = op->common.node; 693 node = op->common.node;
724 694
725 /* next_op points to the op that holds the space_iD */ 695 /* next_op points to the op that holds the space_iD */
726 696
@@ -732,26 +702,26 @@ acpi_ds_eval_region_operands (
732 702
733 /* Evaluate/create the address and length operands */ 703 /* Evaluate/create the address and length operands */
734 704
735 status = acpi_ds_create_operands (walk_state, next_op); 705 status = acpi_ds_create_operands(walk_state, next_op);
736 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
737 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
738 } 708 }
739 709
740 /* Resolve the length and address operands to numbers */ 710 /* Resolve the length and address operands to numbers */
741 711
742 status = acpi_ex_resolve_operands (op->common.aml_opcode, 712 status = acpi_ex_resolve_operands(op->common.aml_opcode,
743 ACPI_WALK_OPERANDS, walk_state); 713 ACPI_WALK_OPERANDS, walk_state);
744 if (ACPI_FAILURE (status)) { 714 if (ACPI_FAILURE(status)) {
745 return_ACPI_STATUS (status); 715 return_ACPI_STATUS(status);
746 } 716 }
747 717
748 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 718 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
749 acpi_ps_get_opcode_name (op->common.aml_opcode), 719 acpi_ps_get_opcode_name(op->common.aml_opcode),
750 1, "after acpi_ex_resolve_operands"); 720 1, "after acpi_ex_resolve_operands");
751 721
752 obj_desc = acpi_ns_get_attached_object (node); 722 obj_desc = acpi_ns_get_attached_object(node);
753 if (!obj_desc) { 723 if (!obj_desc) {
754 return_ACPI_STATUS (AE_NOT_EXIST); 724 return_ACPI_STATUS(AE_NOT_EXIST);
755 } 725 }
756 726
757 /* 727 /*
@@ -761,7 +731,7 @@ acpi_ds_eval_region_operands (
761 operand_desc = walk_state->operands[walk_state->num_operands - 1]; 731 operand_desc = walk_state->operands[walk_state->num_operands - 1];
762 732
763 obj_desc->region.length = (u32) operand_desc->integer.value; 733 obj_desc->region.length = (u32) operand_desc->integer.value;
764 acpi_ut_remove_reference (operand_desc); 734 acpi_ut_remove_reference(operand_desc);
765 735
766 /* 736 /*
767 * Get the address and save it 737 * Get the address and save it
@@ -770,22 +740,21 @@ acpi_ds_eval_region_operands (
770 operand_desc = walk_state->operands[walk_state->num_operands - 2]; 740 operand_desc = walk_state->operands[walk_state->num_operands - 2];
771 741
772 obj_desc->region.address = (acpi_physical_address) 742 obj_desc->region.address = (acpi_physical_address)
773 operand_desc->integer.value; 743 operand_desc->integer.value;
774 acpi_ut_remove_reference (operand_desc); 744 acpi_ut_remove_reference(operand_desc);
775 745
776 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", 746 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
777 obj_desc, 747 obj_desc,
778 ACPI_FORMAT_UINT64 (obj_desc->region.address), 748 ACPI_FORMAT_UINT64(obj_desc->region.address),
779 obj_desc->region.length)); 749 obj_desc->region.length));
780 750
781 /* Now the address and length are valid for this opregion */ 751 /* Now the address and length are valid for this opregion */
782 752
783 obj_desc->region.flags |= AOPOBJ_DATA_VALID; 753 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
784 754
785 return_ACPI_STATUS (status); 755 return_ACPI_STATUS(status);
786} 756}
787 757
788
789/******************************************************************************* 758/*******************************************************************************
790 * 759 *
791 * FUNCTION: acpi_ds_eval_data_object_operands 760 * FUNCTION: acpi_ds_eval_data_object_operands
@@ -802,46 +771,44 @@ acpi_ds_eval_region_operands (
802 ******************************************************************************/ 771 ******************************************************************************/
803 772
804acpi_status 773acpi_status
805acpi_ds_eval_data_object_operands ( 774acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
806 struct acpi_walk_state *walk_state, 775 union acpi_parse_object *op,
807 union acpi_parse_object *op, 776 union acpi_operand_object *obj_desc)
808 union acpi_operand_object *obj_desc)
809{ 777{
810 acpi_status status; 778 acpi_status status;
811 union acpi_operand_object *arg_desc; 779 union acpi_operand_object *arg_desc;
812 u32 length; 780 u32 length;
813
814
815 ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands");
816 781
782 ACPI_FUNCTION_TRACE("ds_eval_data_object_operands");
817 783
818 /* The first operand (for all of these data objects) is the length */ 784 /* The first operand (for all of these data objects) is the length */
819 785
820 status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1); 786 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
821 if (ACPI_FAILURE (status)) { 787 if (ACPI_FAILURE(status)) {
822 return_ACPI_STATUS (status); 788 return_ACPI_STATUS(status);
823 } 789 }
824 790
825 status = acpi_ex_resolve_operands (walk_state->opcode, 791 status = acpi_ex_resolve_operands(walk_state->opcode,
826 &(walk_state->operands [walk_state->num_operands -1]), 792 &(walk_state->
827 walk_state); 793 operands[walk_state->num_operands -
828 if (ACPI_FAILURE (status)) { 794 1]), walk_state);
829 return_ACPI_STATUS (status); 795 if (ACPI_FAILURE(status)) {
796 return_ACPI_STATUS(status);
830 } 797 }
831 798
832 /* Extract length operand */ 799 /* Extract length operand */
833 800
834 arg_desc = walk_state->operands [walk_state->num_operands - 1]; 801 arg_desc = walk_state->operands[walk_state->num_operands - 1];
835 length = (u32) arg_desc->integer.value; 802 length = (u32) arg_desc->integer.value;
836 803
837 /* Cleanup for length operand */ 804 /* Cleanup for length operand */
838 805
839 status = acpi_ds_obj_stack_pop (1, walk_state); 806 status = acpi_ds_obj_stack_pop(1, walk_state);
840 if (ACPI_FAILURE (status)) { 807 if (ACPI_FAILURE(status)) {
841 return_ACPI_STATUS (status); 808 return_ACPI_STATUS(status);
842 } 809 }
843 810
844 acpi_ut_remove_reference (arg_desc); 811 acpi_ut_remove_reference(arg_desc);
845 812
846 /* 813 /*
847 * Create the actual data object 814 * Create the actual data object
@@ -849,37 +816,42 @@ acpi_ds_eval_data_object_operands (
849 switch (op->common.aml_opcode) { 816 switch (op->common.aml_opcode) {
850 case AML_BUFFER_OP: 817 case AML_BUFFER_OP:
851 818
852 status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc); 819 status =
820 acpi_ds_build_internal_buffer_obj(walk_state, op, length,
821 &obj_desc);
853 break; 822 break;
854 823
855 case AML_PACKAGE_OP: 824 case AML_PACKAGE_OP:
856 case AML_VAR_PACKAGE_OP: 825 case AML_VAR_PACKAGE_OP:
857 826
858 status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc); 827 status =
828 acpi_ds_build_internal_package_obj(walk_state, op, length,
829 &obj_desc);
859 break; 830 break;
860 831
861 default: 832 default:
862 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 833 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
863 } 834 }
864 835
865 if (ACPI_SUCCESS (status)) { 836 if (ACPI_SUCCESS(status)) {
866 /* 837 /*
867 * Return the object in the walk_state, unless the parent is a package - 838 * Return the object in the walk_state, unless the parent is a package -
868 * in this case, the return object will be stored in the parse tree 839 * in this case, the return object will be stored in the parse tree
869 * for the package. 840 * for the package.
870 */ 841 */
871 if ((!op->common.parent) || 842 if ((!op->common.parent) ||
872 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && 843 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
873 (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) && 844 (op->common.parent->common.aml_opcode !=
874 (op->common.parent->common.aml_opcode != AML_NAME_OP))) { 845 AML_VAR_PACKAGE_OP)
846 && (op->common.parent->common.aml_opcode !=
847 AML_NAME_OP))) {
875 walk_state->result_obj = obj_desc; 848 walk_state->result_obj = obj_desc;
876 } 849 }
877 } 850 }
878 851
879 return_ACPI_STATUS (status); 852 return_ACPI_STATUS(status);
880} 853}
881 854
882
883/******************************************************************************* 855/*******************************************************************************
884 * 856 *
885 * FUNCTION: acpi_ds_exec_begin_control_op 857 * FUNCTION: acpi_ds_exec_begin_control_op
@@ -895,19 +867,16 @@ acpi_ds_eval_data_object_operands (
895 ******************************************************************************/ 867 ******************************************************************************/
896 868
897acpi_status 869acpi_status
898acpi_ds_exec_begin_control_op ( 870acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
899 struct acpi_walk_state *walk_state, 871 union acpi_parse_object *op)
900 union acpi_parse_object *op)
901{ 872{
902 acpi_status status = AE_OK; 873 acpi_status status = AE_OK;
903 union acpi_generic_state *control_state; 874 union acpi_generic_state *control_state;
904
905 875
906 ACPI_FUNCTION_NAME ("ds_exec_begin_control_op"); 876 ACPI_FUNCTION_NAME("ds_exec_begin_control_op");
907 877
908 878 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
909 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, 879 op->common.aml_opcode, walk_state));
910 op->common.aml_opcode, walk_state));
911 880
912 switch (op->common.aml_opcode) { 881 switch (op->common.aml_opcode) {
913 case AML_IF_OP: 882 case AML_IF_OP:
@@ -918,7 +887,7 @@ acpi_ds_exec_begin_control_op (
918 * constructs. We need to manage these as a stack, in order 887 * constructs. We need to manage these as a stack, in order
919 * to handle nesting. 888 * to handle nesting.
920 */ 889 */
921 control_state = acpi_ut_create_control_state (); 890 control_state = acpi_ut_create_control_state();
922 if (!control_state) { 891 if (!control_state) {
923 status = AE_NO_MEMORY; 892 status = AE_NO_MEMORY;
924 break; 893 break;
@@ -927,14 +896,16 @@ acpi_ds_exec_begin_control_op (
927 * Save a pointer to the predicate for multiple executions 896 * Save a pointer to the predicate for multiple executions
928 * of a loop 897 * of a loop
929 */ 898 */
930 control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; 899 control_state->control.aml_predicate_start =
931 control_state->control.package_end = walk_state->parser_state.pkg_end; 900 walk_state->parser_state.aml - 1;
901 control_state->control.package_end =
902 walk_state->parser_state.pkg_end;
932 control_state->control.opcode = op->common.aml_opcode; 903 control_state->control.opcode = op->common.aml_opcode;
933 904
934
935 /* Push the control state on this walk's control stack */ 905 /* Push the control state on this walk's control stack */
936 906
937 acpi_ut_push_generic_state (&walk_state->control_state, control_state); 907 acpi_ut_push_generic_state(&walk_state->control_state,
908 control_state);
938 break; 909 break;
939 910
940 case AML_ELSE_OP: 911 case AML_ELSE_OP:
@@ -959,7 +930,6 @@ acpi_ds_exec_begin_control_op (
959 return (status); 930 return (status);
960} 931}
961 932
962
963/******************************************************************************* 933/*******************************************************************************
964 * 934 *
965 * FUNCTION: acpi_ds_exec_end_control_op 935 * FUNCTION: acpi_ds_exec_end_control_op
@@ -975,46 +945,42 @@ acpi_ds_exec_begin_control_op (
975 ******************************************************************************/ 945 ******************************************************************************/
976 946
977acpi_status 947acpi_status
978acpi_ds_exec_end_control_op ( 948acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
979 struct acpi_walk_state *walk_state, 949 union acpi_parse_object * op)
980 union acpi_parse_object *op)
981{ 950{
982 acpi_status status = AE_OK; 951 acpi_status status = AE_OK;
983 union acpi_generic_state *control_state; 952 union acpi_generic_state *control_state;
984
985
986 ACPI_FUNCTION_NAME ("ds_exec_end_control_op");
987 953
954 ACPI_FUNCTION_NAME("ds_exec_end_control_op");
988 955
989 switch (op->common.aml_opcode) { 956 switch (op->common.aml_opcode) {
990 case AML_IF_OP: 957 case AML_IF_OP:
991 958
992 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); 959 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
993 960
994 /* 961 /*
995 * Save the result of the predicate in case there is an 962 * Save the result of the predicate in case there is an
996 * ELSE to come 963 * ELSE to come
997 */ 964 */
998 walk_state->last_predicate = 965 walk_state->last_predicate =
999 (u8) walk_state->control_state->common.value; 966 (u8) walk_state->control_state->common.value;
1000 967
1001 /* 968 /*
1002 * Pop the control state that was created at the start 969 * Pop the control state that was created at the start
1003 * of the IF and free it 970 * of the IF and free it
1004 */ 971 */
1005 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 972 control_state =
1006 acpi_ut_delete_generic_state (control_state); 973 acpi_ut_pop_generic_state(&walk_state->control_state);
974 acpi_ut_delete_generic_state(control_state);
1007 break; 975 break;
1008 976
1009
1010 case AML_ELSE_OP: 977 case AML_ELSE_OP:
1011 978
1012 break; 979 break;
1013 980
1014
1015 case AML_WHILE_OP: 981 case AML_WHILE_OP:
1016 982
1017 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 983 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1018 984
1019 if (walk_state->control_state->common.value) { 985 if (walk_state->control_state->common.value) {
1020 /* Predicate was true, go back and evaluate it again! */ 986 /* Predicate was true, go back and evaluate it again! */
@@ -1022,22 +988,24 @@ acpi_ds_exec_end_control_op (
1022 status = AE_CTRL_PENDING; 988 status = AE_CTRL_PENDING;
1023 } 989 }
1024 990
1025 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 991 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1026 "[WHILE_OP] termination! Op=%p\n",op)); 992 "[WHILE_OP] termination! Op=%p\n", op));
1027 993
1028 /* Pop this control state and free it */ 994 /* Pop this control state and free it */
1029 995
1030 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 996 control_state =
997 acpi_ut_pop_generic_state(&walk_state->control_state);
1031 998
1032 walk_state->aml_last_while = control_state->control.aml_predicate_start; 999 walk_state->aml_last_while =
1033 acpi_ut_delete_generic_state (control_state); 1000 control_state->control.aml_predicate_start;
1001 acpi_ut_delete_generic_state(control_state);
1034 break; 1002 break;
1035 1003
1036
1037 case AML_RETURN_OP: 1004 case AML_RETURN_OP:
1038 1005
1039 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1006 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1040 "[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg)); 1007 "[RETURN_OP] Op=%p Arg=%p\n", op,
1008 op->common.value.arg));
1041 1009
1042 /* 1010 /*
1043 * One optional operand -- the return value 1011 * One optional operand -- the return value
@@ -1047,12 +1015,14 @@ acpi_ds_exec_end_control_op (
1047 if (op->common.value.arg) { 1015 if (op->common.value.arg) {
1048 /* Since we have a real Return(), delete any implicit return */ 1016 /* Since we have a real Return(), delete any implicit return */
1049 1017
1050 acpi_ds_clear_implicit_return (walk_state); 1018 acpi_ds_clear_implicit_return(walk_state);
1051 1019
1052 /* Return statement has an immediate operand */ 1020 /* Return statement has an immediate operand */
1053 1021
1054 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 1022 status =
1055 if (ACPI_FAILURE (status)) { 1023 acpi_ds_create_operands(walk_state,
1024 op->common.value.arg);
1025 if (ACPI_FAILURE(status)) {
1056 return (status); 1026 return (status);
1057 } 1027 }
1058 1028
@@ -1061,8 +1031,10 @@ acpi_ds_exec_end_control_op (
1061 * an arg or local), resolve it now because it may 1031 * an arg or local), resolve it now because it may
1062 * cease to exist at the end of the method. 1032 * cease to exist at the end of the method.
1063 */ 1033 */
1064 status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); 1034 status =
1065 if (ACPI_FAILURE (status)) { 1035 acpi_ex_resolve_to_value(&walk_state->operands[0],
1036 walk_state);
1037 if (ACPI_FAILURE(status)) {
1066 return (status); 1038 return (status);
1067 } 1039 }
1068 1040
@@ -1072,12 +1044,11 @@ acpi_ds_exec_end_control_op (
1072 * is set to anything other than zero! 1044 * is set to anything other than zero!
1073 */ 1045 */
1074 walk_state->return_desc = walk_state->operands[0]; 1046 walk_state->return_desc = walk_state->operands[0];
1075 } 1047 } else if ((walk_state->results) &&
1076 else if ((walk_state->results) && 1048 (walk_state->results->results.num_results > 0)) {
1077 (walk_state->results->results.num_results > 0)) {
1078 /* Since we have a real Return(), delete any implicit return */ 1049 /* Since we have a real Return(), delete any implicit return */
1079 1050
1080 acpi_ds_clear_implicit_return (walk_state); 1051 acpi_ds_clear_implicit_return(walk_state);
1081 1052
1082 /* 1053 /*
1083 * The return value has come from a previous calculation. 1054 * The return value has come from a previous calculation.
@@ -1088,67 +1059,78 @@ acpi_ds_exec_end_control_op (
1088 * 1059 *
1089 * Allow references created by the Index operator to return unchanged. 1060 * Allow references created by the Index operator to return unchanged.
1090 */ 1061 */
1091 if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) && 1062 if ((ACPI_GET_DESCRIPTOR_TYPE
1092 (ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1063 (walk_state->results->results.obj_desc[0]) ==
1093 ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { 1064 ACPI_DESC_TYPE_OPERAND)
1094 status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); 1065 &&
1095 if (ACPI_FAILURE (status)) { 1066 (ACPI_GET_OBJECT_TYPE
1067 (walk_state->results->results.obj_desc[0]) ==
1068 ACPI_TYPE_LOCAL_REFERENCE)
1069 && ((walk_state->results->results.obj_desc[0])->
1070 reference.opcode != AML_INDEX_OP)) {
1071 status =
1072 acpi_ex_resolve_to_value(&walk_state->
1073 results->results.
1074 obj_desc[0],
1075 walk_state);
1076 if (ACPI_FAILURE(status)) {
1096 return (status); 1077 return (status);
1097 } 1078 }
1098 } 1079 }
1099 1080
1100 walk_state->return_desc = walk_state->results->results.obj_desc [0]; 1081 walk_state->return_desc =
1101 } 1082 walk_state->results->results.obj_desc[0];
1102 else { 1083 } else {
1103 /* No return operand */ 1084 /* No return operand */
1104 1085
1105 if (walk_state->num_operands) { 1086 if (walk_state->num_operands) {
1106 acpi_ut_remove_reference (walk_state->operands [0]); 1087 acpi_ut_remove_reference(walk_state->
1088 operands[0]);
1107 } 1089 }
1108 1090
1109 walk_state->operands [0] = NULL; 1091 walk_state->operands[0] = NULL;
1110 walk_state->num_operands = 0; 1092 walk_state->num_operands = 0;
1111 walk_state->return_desc = NULL; 1093 walk_state->return_desc = NULL;
1112 } 1094 }
1113 1095
1114 1096 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1115 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1097 "Completed RETURN_OP State=%p, ret_val=%p\n",
1116 "Completed RETURN_OP State=%p, ret_val=%p\n", 1098 walk_state, walk_state->return_desc));
1117 walk_state, walk_state->return_desc));
1118 1099
1119 /* End the control method execution right now */ 1100 /* End the control method execution right now */
1120 1101
1121 status = AE_CTRL_TERMINATE; 1102 status = AE_CTRL_TERMINATE;
1122 break; 1103 break;
1123 1104
1124
1125 case AML_NOOP_OP: 1105 case AML_NOOP_OP:
1126 1106
1127 /* Just do nothing! */ 1107 /* Just do nothing! */
1128 break; 1108 break;
1129 1109
1130
1131 case AML_BREAK_POINT_OP: 1110 case AML_BREAK_POINT_OP:
1132 1111
1133 /* Call up to the OS service layer to handle this */ 1112 /* Call up to the OS service layer to handle this */
1134 1113
1135 status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); 1114 status =
1115 acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1116 "Executed AML Breakpoint opcode");
1136 1117
1137 /* If and when it returns, all done. */ 1118 /* If and when it returns, all done. */
1138 1119
1139 break; 1120 break;
1140 1121
1141
1142 case AML_BREAK_OP: 1122 case AML_BREAK_OP:
1143 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1123 case AML_CONTINUE_OP: /* ACPI 2.0 */
1144
1145 1124
1146 /* Pop and delete control states until we find a while */ 1125 /* Pop and delete control states until we find a while */
1147 1126
1148 while (walk_state->control_state && 1127 while (walk_state->control_state &&
1149 (walk_state->control_state->control.opcode != AML_WHILE_OP)) { 1128 (walk_state->control_state->control.opcode !=
1150 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 1129 AML_WHILE_OP)) {
1151 acpi_ut_delete_generic_state (control_state); 1130 control_state =
1131 acpi_ut_pop_generic_state(&walk_state->
1132 control_state);
1133 acpi_ut_delete_generic_state(control_state);
1152 } 1134 }
1153 1135
1154 /* No while found? */ 1136 /* No while found? */
@@ -1159,23 +1141,23 @@ acpi_ds_exec_end_control_op (
1159 1141
1160 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ 1142 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1161 1143
1162 walk_state->aml_last_while = walk_state->control_state->control.package_end; 1144 walk_state->aml_last_while =
1145 walk_state->control_state->control.package_end;
1163 1146
1164 /* Return status depending on opcode */ 1147 /* Return status depending on opcode */
1165 1148
1166 if (op->common.aml_opcode == AML_BREAK_OP) { 1149 if (op->common.aml_opcode == AML_BREAK_OP) {
1167 status = AE_CTRL_BREAK; 1150 status = AE_CTRL_BREAK;
1168 } 1151 } else {
1169 else {
1170 status = AE_CTRL_CONTINUE; 1152 status = AE_CTRL_CONTINUE;
1171 } 1153 }
1172 break; 1154 break;
1173 1155
1174
1175 default: 1156 default:
1176 1157
1177 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1178 op->common.aml_opcode, op)); 1159 "Unknown control opcode=%X Op=%p\n",
1160 op->common.aml_opcode, op));
1179 1161
1180 status = AE_AML_BAD_OPCODE; 1162 status = AE_AML_BAD_OPCODE;
1181 break; 1163 break;
@@ -1183,4 +1165,3 @@ acpi_ds_exec_end_control_op (
1183 1165
1184 return (status); 1166 return (status);
1185} 1167}
1186
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 9613349ac31d..83ae1c1aa286 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -51,8 +50,7 @@
51#include <acpi/acdebug.h> 50#include <acpi/acdebug.h>
52 51
53#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
54 ACPI_MODULE_NAME ("dsutils") 53ACPI_MODULE_NAME("dsutils")
55
56 54
57/******************************************************************************* 55/*******************************************************************************
58 * 56 *
@@ -68,13 +66,9 @@
68 * parent method exits.) 66 * parent method exits.)
69 * 67 *
70 ******************************************************************************/ 68 ******************************************************************************/
71 69void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state)
72void
73acpi_ds_clear_implicit_return (
74 struct acpi_walk_state *walk_state)
75{ 70{
76 ACPI_FUNCTION_NAME ("ds_clear_implicit_return"); 71 ACPI_FUNCTION_NAME("ds_clear_implicit_return");
77
78 72
79 /* 73 /*
80 * Slack must be enabled for this feature 74 * Slack must be enabled for this feature
@@ -89,16 +83,15 @@ acpi_ds_clear_implicit_return (
89 * complex statements, the implicit return value can be 83 * complex statements, the implicit return value can be
90 * bubbled up several levels. 84 * bubbled up several levels.
91 */ 85 */
92 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 86 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
93 "Removing reference on stale implicit return obj %p\n", 87 "Removing reference on stale implicit return obj %p\n",
94 walk_state->implicit_return_obj)); 88 walk_state->implicit_return_obj));
95 89
96 acpi_ut_remove_reference (walk_state->implicit_return_obj); 90 acpi_ut_remove_reference(walk_state->implicit_return_obj);
97 walk_state->implicit_return_obj = NULL; 91 walk_state->implicit_return_obj = NULL;
98 } 92 }
99} 93}
100 94
101
102#ifndef ACPI_NO_METHOD_EXECUTION 95#ifndef ACPI_NO_METHOD_EXECUTION
103/******************************************************************************* 96/*******************************************************************************
104 * 97 *
@@ -119,27 +112,22 @@ acpi_ds_clear_implicit_return (
119 ******************************************************************************/ 112 ******************************************************************************/
120 113
121u8 114u8
122acpi_ds_do_implicit_return ( 115acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
123 union acpi_operand_object *return_desc, 116 struct acpi_walk_state *walk_state, u8 add_reference)
124 struct acpi_walk_state *walk_state,
125 u8 add_reference)
126{ 117{
127 ACPI_FUNCTION_NAME ("ds_do_implicit_return"); 118 ACPI_FUNCTION_NAME("ds_do_implicit_return");
128
129 119
130 /* 120 /*
131 * Slack must be enabled for this feature, and we must 121 * Slack must be enabled for this feature, and we must
132 * have a valid return object 122 * have a valid return object
133 */ 123 */
134 if ((!acpi_gbl_enable_interpreter_slack) || 124 if ((!acpi_gbl_enable_interpreter_slack) || (!return_desc)) {
135 (!return_desc)) {
136 return (FALSE); 125 return (FALSE);
137 } 126 }
138 127
139 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 128 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
140 "Result %p will be implicitly returned; Prev=%p\n", 129 "Result %p will be implicitly returned; Prev=%p\n",
141 return_desc, 130 return_desc, walk_state->implicit_return_obj));
142 walk_state->implicit_return_obj));
143 131
144 /* 132 /*
145 * Delete any "stale" implicit return value first. However, in 133 * Delete any "stale" implicit return value first. However, in
@@ -151,20 +139,19 @@ acpi_ds_do_implicit_return (
151 if (walk_state->implicit_return_obj == return_desc) { 139 if (walk_state->implicit_return_obj == return_desc) {
152 return (TRUE); 140 return (TRUE);
153 } 141 }
154 acpi_ds_clear_implicit_return (walk_state); 142 acpi_ds_clear_implicit_return(walk_state);
155 } 143 }
156 144
157 /* Save the implicit return value, add a reference if requested */ 145 /* Save the implicit return value, add a reference if requested */
158 146
159 walk_state->implicit_return_obj = return_desc; 147 walk_state->implicit_return_obj = return_desc;
160 if (add_reference) { 148 if (add_reference) {
161 acpi_ut_add_reference (return_desc); 149 acpi_ut_add_reference(return_desc);
162 } 150 }
163 151
164 return (TRUE); 152 return (TRUE);
165} 153}
166 154
167
168/******************************************************************************* 155/*******************************************************************************
169 * 156 *
170 * FUNCTION: acpi_ds_is_result_used 157 * FUNCTION: acpi_ds_is_result_used
@@ -179,20 +166,18 @@ acpi_ds_do_implicit_return (
179 ******************************************************************************/ 166 ******************************************************************************/
180 167
181u8 168u8
182acpi_ds_is_result_used ( 169acpi_ds_is_result_used(union acpi_parse_object * op,
183 union acpi_parse_object *op, 170 struct acpi_walk_state * walk_state)
184 struct acpi_walk_state *walk_state)
185{ 171{
186 const struct acpi_opcode_info *parent_info; 172 const struct acpi_opcode_info *parent_info;
187
188 ACPI_FUNCTION_TRACE_PTR ("ds_is_result_used", op);
189 173
174 ACPI_FUNCTION_TRACE_PTR("ds_is_result_used", op);
190 175
191 /* Must have both an Op and a Result Object */ 176 /* Must have both an Op and a Result Object */
192 177
193 if (!op) { 178 if (!op) {
194 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
195 return_VALUE (TRUE); 180 return_VALUE(TRUE);
196 } 181 }
197 182
198 /* 183 /*
@@ -204,7 +189,8 @@ acpi_ds_is_result_used (
204 * NOTE: this is optional because the ASL language does not actually 189 * NOTE: this is optional because the ASL language does not actually
205 * support this behavior. 190 * support this behavior.
206 */ 191 */
207 (void) acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE); 192 (void)acpi_ds_do_implicit_return(walk_state->result_obj, walk_state,
193 TRUE);
208 194
209 /* 195 /*
210 * Now determine if the parent will use the result 196 * Now determine if the parent will use the result
@@ -215,22 +201,24 @@ acpi_ds_is_result_used (
215 * via execute_control_method has a scope_op as the parent. 201 * via execute_control_method has a scope_op as the parent.
216 */ 202 */
217 if ((!op->common.parent) || 203 if ((!op->common.parent) ||
218 (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) { 204 (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
219 /* No parent, the return value cannot possibly be used */ 205 /* No parent, the return value cannot possibly be used */
220 206
221 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 207 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
222 "At Method level, result of [%s] not used\n", 208 "At Method level, result of [%s] not used\n",
223 acpi_ps_get_opcode_name (op->common.aml_opcode))); 209 acpi_ps_get_opcode_name(op->common.
224 return_VALUE (FALSE); 210 aml_opcode)));
211 return_VALUE(FALSE);
225 } 212 }
226 213
227 /* Get info on the parent. The root_op is AML_SCOPE */ 214 /* Get info on the parent. The root_op is AML_SCOPE */
228 215
229 parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode); 216 parent_info =
217 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
230 if (parent_info->class == AML_CLASS_UNKNOWN) { 218 if (parent_info->class == AML_CLASS_UNKNOWN) {
231 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
232 "Unknown parent opcode. Op=%p\n", op)); 220 "Unknown parent opcode. Op=%p\n", op));
233 return_VALUE (FALSE); 221 return_VALUE(FALSE);
234 } 222 }
235 223
236 /* 224 /*
@@ -256,8 +244,10 @@ acpi_ds_is_result_used (
256 * If we are executing the predicate AND this is the predicate op, 244 * If we are executing the predicate AND this is the predicate op,
257 * we will use the return value 245 * we will use the return value
258 */ 246 */
259 if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) && 247 if ((walk_state->control_state->common.state ==
260 (walk_state->control_state->control.predicate_op == op)) { 248 ACPI_CONTROL_PREDICATE_EXECUTING)
249 && (walk_state->control_state->control.
250 predicate_op == op)) {
261 goto result_used; 251 goto result_used;
262 } 252 }
263 break; 253 break;
@@ -271,7 +261,6 @@ acpi_ds_is_result_used (
271 261
272 goto result_not_used; 262 goto result_not_used;
273 263
274
275 case AML_CLASS_CREATE: 264 case AML_CLASS_CREATE:
276 265
277 /* 266 /*
@@ -280,15 +269,16 @@ acpi_ds_is_result_used (
280 */ 269 */
281 goto result_used; 270 goto result_used;
282 271
283
284 case AML_CLASS_NAMED_OBJECT: 272 case AML_CLASS_NAMED_OBJECT:
285 273
286 if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || 274 if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
287 (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) || 275 (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP)
288 (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || 276 || (op->common.parent->common.aml_opcode == AML_PACKAGE_OP)
289 (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) || 277 || (op->common.parent->common.aml_opcode ==
290 (op->common.parent->common.aml_opcode == AML_BUFFER_OP) || 278 AML_VAR_PACKAGE_OP)
291 (op->common.parent->common.aml_opcode == AML_INT_EVAL_SUBTREE_OP)) { 279 || (op->common.parent->common.aml_opcode == AML_BUFFER_OP)
280 || (op->common.parent->common.aml_opcode ==
281 AML_INT_EVAL_SUBTREE_OP)) {
292 /* 282 /*
293 * These opcodes allow term_arg(s) as operands and therefore 283 * These opcodes allow term_arg(s) as operands and therefore
294 * the operands can be method calls. The result is used. 284 * the operands can be method calls. The result is used.
@@ -298,7 +288,6 @@ acpi_ds_is_result_used (
298 288
299 goto result_not_used; 289 goto result_not_used;
300 290
301
302 default: 291 default:
303 292
304 /* 293 /*
@@ -308,26 +297,25 @@ acpi_ds_is_result_used (
308 goto result_used; 297 goto result_used;
309 } 298 }
310 299
300 result_used:
301 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
302 "Result of [%s] used by Parent [%s] Op=%p\n",
303 acpi_ps_get_opcode_name(op->common.aml_opcode),
304 acpi_ps_get_opcode_name(op->common.parent->common.
305 aml_opcode), op));
311 306
312result_used: 307 return_VALUE(TRUE);
313 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
314 "Result of [%s] used by Parent [%s] Op=%p\n",
315 acpi_ps_get_opcode_name (op->common.aml_opcode),
316 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
317
318 return_VALUE (TRUE);
319
320 308
321result_not_used: 309 result_not_used:
322 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
323 "Result of [%s] not used by Parent [%s] Op=%p\n", 311 "Result of [%s] not used by Parent [%s] Op=%p\n",
324 acpi_ps_get_opcode_name (op->common.aml_opcode), 312 acpi_ps_get_opcode_name(op->common.aml_opcode),
325 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op)); 313 acpi_ps_get_opcode_name(op->common.parent->common.
314 aml_opcode), op));
326 315
327 return_VALUE (FALSE); 316 return_VALUE(FALSE);
328} 317}
329 318
330
331/******************************************************************************* 319/*******************************************************************************
332 * 320 *
333 * FUNCTION: acpi_ds_delete_result_if_not_used 321 * FUNCTION: acpi_ds_delete_result_if_not_used
@@ -346,20 +334,17 @@ result_not_used:
346 ******************************************************************************/ 334 ******************************************************************************/
347 335
348void 336void
349acpi_ds_delete_result_if_not_used ( 337acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
350 union acpi_parse_object *op, 338 union acpi_operand_object *result_obj,
351 union acpi_operand_object *result_obj, 339 struct acpi_walk_state *walk_state)
352 struct acpi_walk_state *walk_state)
353{ 340{
354 union acpi_operand_object *obj_desc; 341 union acpi_operand_object *obj_desc;
355 acpi_status status; 342 acpi_status status;
356
357
358 ACPI_FUNCTION_TRACE_PTR ("ds_delete_result_if_not_used", result_obj);
359 343
344 ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj);
360 345
361 if (!op) { 346 if (!op) {
362 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); 347 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
363 return_VOID; 348 return_VOID;
364 } 349 }
365 350
@@ -367,19 +352,18 @@ acpi_ds_delete_result_if_not_used (
367 return_VOID; 352 return_VOID;
368 } 353 }
369 354
370 if (!acpi_ds_is_result_used (op, walk_state)) { 355 if (!acpi_ds_is_result_used(op, walk_state)) {
371 /* Must pop the result stack (obj_desc should be equal to result_obj) */ 356 /* Must pop the result stack (obj_desc should be equal to result_obj) */
372 357
373 status = acpi_ds_result_pop (&obj_desc, walk_state); 358 status = acpi_ds_result_pop(&obj_desc, walk_state);
374 if (ACPI_SUCCESS (status)) { 359 if (ACPI_SUCCESS(status)) {
375 acpi_ut_remove_reference (result_obj); 360 acpi_ut_remove_reference(result_obj);
376 } 361 }
377 } 362 }
378 363
379 return_VOID; 364 return_VOID;
380} 365}
381 366
382
383/******************************************************************************* 367/*******************************************************************************
384 * 368 *
385 * FUNCTION: acpi_ds_resolve_operands 369 * FUNCTION: acpi_ds_resolve_operands
@@ -394,16 +378,12 @@ acpi_ds_delete_result_if_not_used (
394 * 378 *
395 ******************************************************************************/ 379 ******************************************************************************/
396 380
397acpi_status 381acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state)
398acpi_ds_resolve_operands (
399 struct acpi_walk_state *walk_state)
400{ 382{
401 u32 i; 383 u32 i;
402 acpi_status status = AE_OK; 384 acpi_status status = AE_OK;
403
404
405 ACPI_FUNCTION_TRACE_PTR ("ds_resolve_operands", walk_state);
406 385
386 ACPI_FUNCTION_TRACE_PTR("ds_resolve_operands", walk_state);
407 387
408 /* 388 /*
409 * Attempt to resolve each of the valid operands 389 * Attempt to resolve each of the valid operands
@@ -411,16 +391,17 @@ acpi_ds_resolve_operands (
411 * that the actual objects are passed, not copies of the objects. 391 * that the actual objects are passed, not copies of the objects.
412 */ 392 */
413 for (i = 0; i < walk_state->num_operands; i++) { 393 for (i = 0; i < walk_state->num_operands; i++) {
414 status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state); 394 status =
415 if (ACPI_FAILURE (status)) { 395 acpi_ex_resolve_to_value(&walk_state->operands[i],
396 walk_state);
397 if (ACPI_FAILURE(status)) {
416 break; 398 break;
417 } 399 }
418 } 400 }
419 401
420 return_ACPI_STATUS (status); 402 return_ACPI_STATUS(status);
421} 403}
422 404
423
424/******************************************************************************* 405/*******************************************************************************
425 * 406 *
426 * FUNCTION: acpi_ds_clear_operands 407 * FUNCTION: acpi_ds_clear_operands
@@ -433,15 +414,11 @@ acpi_ds_resolve_operands (
433 * 414 *
434 ******************************************************************************/ 415 ******************************************************************************/
435 416
436void 417void acpi_ds_clear_operands(struct acpi_walk_state *walk_state)
437acpi_ds_clear_operands (
438 struct acpi_walk_state *walk_state)
439{ 418{
440 u32 i; 419 u32 i;
441
442
443 ACPI_FUNCTION_TRACE_PTR ("ds_clear_operands", walk_state);
444 420
421 ACPI_FUNCTION_TRACE_PTR("ds_clear_operands", walk_state);
445 422
446 /* Remove a reference on each operand on the stack */ 423 /* Remove a reference on each operand on the stack */
447 424
@@ -450,7 +427,7 @@ acpi_ds_clear_operands (
450 * Remove a reference to all operands, including both 427 * Remove a reference to all operands, including both
451 * "Arguments" and "Targets". 428 * "Arguments" and "Targets".
452 */ 429 */
453 acpi_ut_remove_reference (walk_state->operands[i]); 430 acpi_ut_remove_reference(walk_state->operands[i]);
454 walk_state->operands[i] = NULL; 431 walk_state->operands[i] = NULL;
455 } 432 }
456 433
@@ -459,7 +436,6 @@ acpi_ds_clear_operands (
459} 436}
460#endif 437#endif
461 438
462
463/******************************************************************************* 439/*******************************************************************************
464 * 440 *
465 * FUNCTION: acpi_ds_create_operand 441 * FUNCTION: acpi_ds_create_operand
@@ -478,37 +454,36 @@ acpi_ds_clear_operands (
478 ******************************************************************************/ 454 ******************************************************************************/
479 455
480acpi_status 456acpi_status
481acpi_ds_create_operand ( 457acpi_ds_create_operand(struct acpi_walk_state *walk_state,
482 struct acpi_walk_state *walk_state, 458 union acpi_parse_object *arg, u32 arg_index)
483 union acpi_parse_object *arg,
484 u32 arg_index)
485{ 459{
486 acpi_status status = AE_OK; 460 acpi_status status = AE_OK;
487 char *name_string; 461 char *name_string;
488 u32 name_length; 462 u32 name_length;
489 union acpi_operand_object *obj_desc; 463 union acpi_operand_object *obj_desc;
490 union acpi_parse_object *parent_op; 464 union acpi_parse_object *parent_op;
491 u16 opcode; 465 u16 opcode;
492 acpi_interpreter_mode interpreter_mode; 466 acpi_interpreter_mode interpreter_mode;
493 const struct acpi_opcode_info *op_info; 467 const struct acpi_opcode_info *op_info;
494
495
496 ACPI_FUNCTION_TRACE_PTR ("ds_create_operand", arg);
497 468
469 ACPI_FUNCTION_TRACE_PTR("ds_create_operand", arg);
498 470
499 /* A valid name must be looked up in the namespace */ 471 /* A valid name must be looked up in the namespace */
500 472
501 if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) && 473 if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
502 (arg->common.value.string)) { 474 (arg->common.value.string)) {
503 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", arg)); 475 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n",
476 arg));
504 477
505 /* Get the entire name string from the AML stream */ 478 /* Get the entire name string from the AML stream */
506 479
507 status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->common.value.buffer, 480 status =
508 &name_string, &name_length); 481 acpi_ex_get_name_string(ACPI_TYPE_ANY,
482 arg->common.value.buffer,
483 &name_string, &name_length);
509 484
510 if (ACPI_FAILURE (status)) { 485 if (ACPI_FAILURE(status)) {
511 return_ACPI_STATUS (status); 486 return_ACPI_STATUS(status);
512 } 487 }
513 488
514 /* All prefixes have been handled, and the name is in name_string */ 489 /* All prefixes have been handled, and the name is in name_string */
@@ -523,13 +498,14 @@ acpi_ds_create_operand (
523 * actual opcode exists. 498 * actual opcode exists.
524 */ 499 */
525 if ((walk_state->deferred_node) && 500 if ((walk_state->deferred_node) &&
526 (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) && 501 (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD)
527 (arg_index != 0)) { 502 && (arg_index != 0)) {
528 obj_desc = ACPI_CAST_PTR ( 503 obj_desc =
529 union acpi_operand_object, walk_state->deferred_node); 504 ACPI_CAST_PTR(union acpi_operand_object,
505 walk_state->deferred_node);
530 status = AE_OK; 506 status = AE_OK;
531 } 507 } else { /* All other opcodes */
532 else /* All other opcodes */ { 508
533 /* 509 /*
534 * Differentiate between a namespace "create" operation 510 * Differentiate between a namespace "create" operation
535 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. 511 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
@@ -537,43 +513,51 @@ acpi_ds_create_operand (
537 * namespace objects during the execution of control methods. 513 * namespace objects during the execution of control methods.
538 */ 514 */
539 parent_op = arg->common.parent; 515 parent_op = arg->common.parent;
540 op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode); 516 op_info =
541 if ((op_info->flags & AML_NSNODE) && 517 acpi_ps_get_opcode_info(parent_op->common.
542 (parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) && 518 aml_opcode);
543 (parent_op->common.aml_opcode != AML_REGION_OP) && 519 if ((op_info->flags & AML_NSNODE)
544 (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) { 520 && (parent_op->common.aml_opcode !=
521 AML_INT_METHODCALL_OP)
522 && (parent_op->common.aml_opcode != AML_REGION_OP)
523 && (parent_op->common.aml_opcode !=
524 AML_INT_NAMEPATH_OP)) {
545 /* Enter name into namespace if not found */ 525 /* Enter name into namespace if not found */
546 526
547 interpreter_mode = ACPI_IMODE_LOAD_PASS2; 527 interpreter_mode = ACPI_IMODE_LOAD_PASS2;
548 } 528 } else {
549 else {
550 /* Return a failure if name not found */ 529 /* Return a failure if name not found */
551 530
552 interpreter_mode = ACPI_IMODE_EXECUTE; 531 interpreter_mode = ACPI_IMODE_EXECUTE;
553 } 532 }
554 533
555 status = acpi_ns_lookup (walk_state->scope_info, name_string, 534 status =
556 ACPI_TYPE_ANY, interpreter_mode, 535 acpi_ns_lookup(walk_state->scope_info, name_string,
557 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 536 ACPI_TYPE_ANY, interpreter_mode,
558 walk_state, 537 ACPI_NS_SEARCH_PARENT |
559 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc)); 538 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
539 ACPI_CAST_INDIRECT_PTR(struct
540 acpi_namespace_node,
541 &obj_desc));
560 /* 542 /*
561 * The only case where we pass through (ignore) a NOT_FOUND 543 * The only case where we pass through (ignore) a NOT_FOUND
562 * error is for the cond_ref_of opcode. 544 * error is for the cond_ref_of opcode.
563 */ 545 */
564 if (status == AE_NOT_FOUND) { 546 if (status == AE_NOT_FOUND) {
565 if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) { 547 if (parent_op->common.aml_opcode ==
548 AML_COND_REF_OF_OP) {
566 /* 549 /*
567 * For the Conditional Reference op, it's OK if 550 * For the Conditional Reference op, it's OK if
568 * the name is not found; We just need a way to 551 * the name is not found; We just need a way to
569 * indicate this to the interpreter, set the 552 * indicate this to the interpreter, set the
570 * object to the root 553 * object to the root
571 */ 554 */
572 obj_desc = ACPI_CAST_PTR ( 555 obj_desc =
573 union acpi_operand_object, acpi_gbl_root_node); 556 ACPI_CAST_PTR(union
557 acpi_operand_object,
558 acpi_gbl_root_node);
574 status = AE_OK; 559 status = AE_OK;
575 } 560 } else {
576 else {
577 /* 561 /*
578 * We just plain didn't find it -- which is a 562 * We just plain didn't find it -- which is a
579 * very serious error at this point 563 * very serious error at this point
@@ -582,30 +566,30 @@ acpi_ds_create_operand (
582 } 566 }
583 } 567 }
584 568
585 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
586 ACPI_REPORT_NSERROR (name_string, status); 570 ACPI_REPORT_NSERROR(name_string, status);
587 } 571 }
588 } 572 }
589 573
590 /* Free the namestring created above */ 574 /* Free the namestring created above */
591 575
592 ACPI_MEM_FREE (name_string); 576 ACPI_MEM_FREE(name_string);
593 577
594 /* Check status from the lookup */ 578 /* Check status from the lookup */
595 579
596 if (ACPI_FAILURE (status)) { 580 if (ACPI_FAILURE(status)) {
597 return_ACPI_STATUS (status); 581 return_ACPI_STATUS(status);
598 } 582 }
599 583
600 /* Put the resulting object onto the current object stack */ 584 /* Put the resulting object onto the current object stack */
601 585
602 status = acpi_ds_obj_stack_push (obj_desc, walk_state); 586 status = acpi_ds_obj_stack_push(obj_desc, walk_state);
603 if (ACPI_FAILURE (status)) { 587 if (ACPI_FAILURE(status)) {
604 return_ACPI_STATUS (status); 588 return_ACPI_STATUS(status);
605 } 589 }
606 ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); 590 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
607 } 591 (obj_desc, walk_state));
608 else { 592 } else {
609 /* Check for null name case */ 593 /* Check for null name case */
610 594
611 if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) { 595 if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) {
@@ -615,77 +599,83 @@ acpi_ds_create_operand (
615 * in the original ASL. Create a Zero Constant for a 599 * in the original ASL. Create a Zero Constant for a
616 * placeholder. (Store to a constant is a Noop.) 600 * placeholder. (Store to a constant is a Noop.)
617 */ 601 */
618 opcode = AML_ZERO_OP; /* Has no arguments! */ 602 opcode = AML_ZERO_OP; /* Has no arguments! */
619 603
620 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 604 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
621 "Null namepath: Arg=%p\n", arg)); 605 "Null namepath: Arg=%p\n", arg));
622 } 606 } else {
623 else {
624 opcode = arg->common.aml_opcode; 607 opcode = arg->common.aml_opcode;
625 } 608 }
626 609
627 /* Get the object type of the argument */ 610 /* Get the object type of the argument */
628 611
629 op_info = acpi_ps_get_opcode_info (opcode); 612 op_info = acpi_ps_get_opcode_info(opcode);
630 if (op_info->object_type == ACPI_TYPE_INVALID) { 613 if (op_info->object_type == ACPI_TYPE_INVALID) {
631 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 614 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
632 } 615 }
633 616
634 if (op_info->flags & AML_HAS_RETVAL) { 617 if (op_info->flags & AML_HAS_RETVAL) {
635 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
636 "Argument previously created, already stacked \n")); 619 "Argument previously created, already stacked \n"));
637 620
638 ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object ( 621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
639 walk_state->operands [walk_state->num_operands - 1], walk_state)); 622 (walk_state->
623 operands[walk_state->num_operands -
624 1], walk_state));
640 625
641 /* 626 /*
642 * Use value that was already previously returned 627 * Use value that was already previously returned
643 * by the evaluation of this argument 628 * by the evaluation of this argument
644 */ 629 */
645 status = acpi_ds_result_pop_from_bottom (&obj_desc, walk_state); 630 status =
646 if (ACPI_FAILURE (status)) { 631 acpi_ds_result_pop_from_bottom(&obj_desc,
632 walk_state);
633 if (ACPI_FAILURE(status)) {
647 /* 634 /*
648 * Only error is underflow, and this indicates 635 * Only error is underflow, and this indicates
649 * a missing or null operand! 636 * a missing or null operand!
650 */ 637 */
651 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
652 "Missing or null operand, %s\n", 639 "Missing or null operand, %s\n",
653 acpi_format_exception (status))); 640 acpi_format_exception
654 return_ACPI_STATUS (status); 641 (status)));
642 return_ACPI_STATUS(status);
655 } 643 }
656 } 644 } else {
657 else {
658 /* Create an ACPI_INTERNAL_OBJECT for the argument */ 645 /* Create an ACPI_INTERNAL_OBJECT for the argument */
659 646
660 obj_desc = acpi_ut_create_internal_object (op_info->object_type); 647 obj_desc =
648 acpi_ut_create_internal_object(op_info->
649 object_type);
661 if (!obj_desc) { 650 if (!obj_desc) {
662 return_ACPI_STATUS (AE_NO_MEMORY); 651 return_ACPI_STATUS(AE_NO_MEMORY);
663 } 652 }
664 653
665 /* Initialize the new object */ 654 /* Initialize the new object */
666 655
667 status = acpi_ds_init_object_from_op ( 656 status =
668 walk_state, arg, opcode, &obj_desc); 657 acpi_ds_init_object_from_op(walk_state, arg, opcode,
669 if (ACPI_FAILURE (status)) { 658 &obj_desc);
670 acpi_ut_delete_object_desc (obj_desc); 659 if (ACPI_FAILURE(status)) {
671 return_ACPI_STATUS (status); 660 acpi_ut_delete_object_desc(obj_desc);
661 return_ACPI_STATUS(status);
672 } 662 }
673 } 663 }
674 664
675 /* Put the operand object on the object stack */ 665 /* Put the operand object on the object stack */
676 666
677 status = acpi_ds_obj_stack_push (obj_desc, walk_state); 667 status = acpi_ds_obj_stack_push(obj_desc, walk_state);
678 if (ACPI_FAILURE (status)) { 668 if (ACPI_FAILURE(status)) {
679 return_ACPI_STATUS (status); 669 return_ACPI_STATUS(status);
680 } 670 }
681 671
682 ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); 672 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
673 (obj_desc, walk_state));
683 } 674 }
684 675
685 return_ACPI_STATUS (AE_OK); 676 return_ACPI_STATUS(AE_OK);
686} 677}
687 678
688
689/******************************************************************************* 679/*******************************************************************************
690 * 680 *
691 * FUNCTION: acpi_ds_create_operands 681 * FUNCTION: acpi_ds_create_operands
@@ -702,29 +692,27 @@ acpi_ds_create_operand (
702 ******************************************************************************/ 692 ******************************************************************************/
703 693
704acpi_status 694acpi_status
705acpi_ds_create_operands ( 695acpi_ds_create_operands(struct acpi_walk_state *walk_state,
706 struct acpi_walk_state *walk_state, 696 union acpi_parse_object *first_arg)
707 union acpi_parse_object *first_arg)
708{ 697{
709 acpi_status status = AE_OK; 698 acpi_status status = AE_OK;
710 union acpi_parse_object *arg; 699 union acpi_parse_object *arg;
711 u32 arg_count = 0; 700 u32 arg_count = 0;
712
713
714 ACPI_FUNCTION_TRACE_PTR ("ds_create_operands", first_arg);
715 701
702 ACPI_FUNCTION_TRACE_PTR("ds_create_operands", first_arg);
716 703
717 /* For all arguments in the list... */ 704 /* For all arguments in the list... */
718 705
719 arg = first_arg; 706 arg = first_arg;
720 while (arg) { 707 while (arg) {
721 status = acpi_ds_create_operand (walk_state, arg, arg_count); 708 status = acpi_ds_create_operand(walk_state, arg, arg_count);
722 if (ACPI_FAILURE (status)) { 709 if (ACPI_FAILURE(status)) {
723 goto cleanup; 710 goto cleanup;
724 } 711 }
725 712
726 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", 713 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
727 arg_count, arg, first_arg)); 714 "Arg #%d (%p) done, Arg1=%p\n", arg_count,
715 arg, first_arg));
728 716
729 /* Move on to next argument, if any */ 717 /* Move on to next argument, if any */
730 718
@@ -732,20 +720,17 @@ acpi_ds_create_operands (
732 arg_count++; 720 arg_count++;
733 } 721 }
734 722
735 return_ACPI_STATUS (status); 723 return_ACPI_STATUS(status);
736
737 724
738cleanup: 725 cleanup:
739 /* 726 /*
740 * We must undo everything done above; meaning that we must 727 * We must undo everything done above; meaning that we must
741 * pop everything off of the operand stack and delete those 728 * pop everything off of the operand stack and delete those
742 * objects 729 * objects
743 */ 730 */
744 (void) acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state); 731 (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
745 732
746 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n", 733 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
747 (arg_count + 1), acpi_format_exception (status))); 734 (arg_count + 1), acpi_format_exception(status)));
748 return_ACPI_STATUS (status); 735 return_ACPI_STATUS(status);
749} 736}
750
751
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index 10f71318e23b..e522763bb692 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
@@ -52,27 +51,26 @@
52#include <acpi/acdebug.h> 51#include <acpi/acdebug.h>
53#include <acpi/acdisasm.h> 52#include <acpi/acdisasm.h>
54 53
55
56#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
57 ACPI_MODULE_NAME ("dswexec") 55ACPI_MODULE_NAME("dswexec")
58 56
59/* 57/*
60 * Dispatch table for opcode classes 58 * Dispatch table for opcode classes
61 */ 59 */
62static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = { 60static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = {
63 acpi_ex_opcode_0A_0T_1R, 61 acpi_ex_opcode_0A_0T_1R,
64 acpi_ex_opcode_1A_0T_0R, 62 acpi_ex_opcode_1A_0T_0R,
65 acpi_ex_opcode_1A_0T_1R, 63 acpi_ex_opcode_1A_0T_1R,
66 acpi_ex_opcode_1A_1T_0R, 64 acpi_ex_opcode_1A_1T_0R,
67 acpi_ex_opcode_1A_1T_1R, 65 acpi_ex_opcode_1A_1T_1R,
68 acpi_ex_opcode_2A_0T_0R, 66 acpi_ex_opcode_2A_0T_0R,
69 acpi_ex_opcode_2A_0T_1R, 67 acpi_ex_opcode_2A_0T_1R,
70 acpi_ex_opcode_2A_1T_1R, 68 acpi_ex_opcode_2A_1T_1R,
71 acpi_ex_opcode_2A_2T_1R, 69 acpi_ex_opcode_2A_2T_1R,
72 acpi_ex_opcode_3A_0T_0R, 70 acpi_ex_opcode_3A_0T_0R,
73 acpi_ex_opcode_3A_1T_1R, 71 acpi_ex_opcode_3A_1T_1R,
74 acpi_ex_opcode_6A_0T_1R}; 72 acpi_ex_opcode_6A_0T_1R
75 73};
76 74
77/***************************************************************************** 75/*****************************************************************************
78 * 76 *
@@ -88,64 +86,64 @@ static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = {
88 ****************************************************************************/ 86 ****************************************************************************/
89 87
90acpi_status 88acpi_status
91acpi_ds_get_predicate_value ( 89acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
92 struct acpi_walk_state *walk_state, 90 union acpi_operand_object *result_obj)
93 union acpi_operand_object *result_obj) { 91{
94 acpi_status status = AE_OK; 92 acpi_status status = AE_OK;
95 union acpi_operand_object *obj_desc; 93 union acpi_operand_object *obj_desc;
96 union acpi_operand_object *local_obj_desc = NULL; 94 union acpi_operand_object *local_obj_desc = NULL;
97
98
99 ACPI_FUNCTION_TRACE_PTR ("ds_get_predicate_value", walk_state);
100 95
96 ACPI_FUNCTION_TRACE_PTR("ds_get_predicate_value", walk_state);
101 97
102 walk_state->control_state->common.state = 0; 98 walk_state->control_state->common.state = 0;
103 99
104 if (result_obj) { 100 if (result_obj) {
105 status = acpi_ds_result_pop (&obj_desc, walk_state); 101 status = acpi_ds_result_pop(&obj_desc, walk_state);
106 if (ACPI_FAILURE (status)) { 102 if (ACPI_FAILURE(status)) {
107 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 103 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
108 "Could not get result from predicate evaluation, %s\n", 104 "Could not get result from predicate evaluation, %s\n",
109 acpi_format_exception (status))); 105 acpi_format_exception(status)));
110 106
111 return_ACPI_STATUS (status); 107 return_ACPI_STATUS(status);
112 } 108 }
113 } 109 } else {
114 else { 110 status = acpi_ds_create_operand(walk_state, walk_state->op, 0);
115 status = acpi_ds_create_operand (walk_state, walk_state->op, 0); 111 if (ACPI_FAILURE(status)) {
116 if (ACPI_FAILURE (status)) { 112 return_ACPI_STATUS(status);
117 return_ACPI_STATUS (status);
118 } 113 }
119 114
120 status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); 115 status =
121 if (ACPI_FAILURE (status)) { 116 acpi_ex_resolve_to_value(&walk_state->operands[0],
122 return_ACPI_STATUS (status); 117 walk_state);
118 if (ACPI_FAILURE(status)) {
119 return_ACPI_STATUS(status);
123 } 120 }
124 121
125 obj_desc = walk_state->operands [0]; 122 obj_desc = walk_state->operands[0];
126 } 123 }
127 124
128 if (!obj_desc) { 125 if (!obj_desc) {
129 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
130 "No predicate obj_desc=%p State=%p\n", 127 "No predicate obj_desc=%p State=%p\n",
131 obj_desc, walk_state)); 128 obj_desc, walk_state));
132 129
133 return_ACPI_STATUS (AE_AML_NO_OPERAND); 130 return_ACPI_STATUS(AE_AML_NO_OPERAND);
134 } 131 }
135 132
136 /* 133 /*
137 * Result of predicate evaluation must be an Integer 134 * Result of predicate evaluation must be an Integer
138 * object. Implicitly convert the argument if necessary. 135 * object. Implicitly convert the argument if necessary.
139 */ 136 */
140 status = acpi_ex_convert_to_integer (obj_desc, &local_obj_desc, 16); 137 status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 16);
141 if (ACPI_FAILURE (status)) { 138 if (ACPI_FAILURE(status)) {
142 goto cleanup; 139 goto cleanup;
143 } 140 }
144 141
145 if (ACPI_GET_OBJECT_TYPE (local_obj_desc) != ACPI_TYPE_INTEGER) { 142 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
146 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 143 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
147 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", 144 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n",
148 obj_desc, walk_state, ACPI_GET_OBJECT_TYPE (obj_desc))); 145 obj_desc, walk_state,
146 ACPI_GET_OBJECT_TYPE(obj_desc)));
149 147
150 status = AE_AML_OPERAND_TYPE; 148 status = AE_AML_OPERAND_TYPE;
151 goto cleanup; 149 goto cleanup;
@@ -153,7 +151,7 @@ acpi_ds_get_predicate_value (
153 151
154 /* Truncate the predicate to 32-bits if necessary */ 152 /* Truncate the predicate to 32-bits if necessary */
155 153
156 acpi_ex_truncate_for32bit_table (local_obj_desc); 154 acpi_ex_truncate_for32bit_table(local_obj_desc);
157 155
158 /* 156 /*
159 * Save the result of the predicate evaluation on 157 * Save the result of the predicate evaluation on
@@ -161,8 +159,7 @@ acpi_ds_get_predicate_value (
161 */ 159 */
162 if (local_obj_desc->integer.value) { 160 if (local_obj_desc->integer.value) {
163 walk_state->control_state->common.value = TRUE; 161 walk_state->control_state->common.value = TRUE;
164 } 162 } else {
165 else {
166 /* 163 /*
167 * Predicate is FALSE, we will just toss the 164 * Predicate is FALSE, we will just toss the
168 * rest of the package 165 * rest of the package
@@ -171,30 +168,30 @@ acpi_ds_get_predicate_value (
171 status = AE_CTRL_FALSE; 168 status = AE_CTRL_FALSE;
172 } 169 }
173 170
171 cleanup:
174 172
175cleanup: 173 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
174 walk_state->control_state->common.value,
175 walk_state->op));
176 176
177 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", 177 /* Break to debugger to display result */
178 walk_state->control_state->common.value, walk_state->op));
179 178
180 /* Break to debugger to display result */ 179 ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
181 180 (local_obj_desc, walk_state));
182 ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (local_obj_desc, walk_state));
183 181
184 /* 182 /*
185 * Delete the predicate result object (we know that 183 * Delete the predicate result object (we know that
186 * we don't need it anymore) 184 * we don't need it anymore)
187 */ 185 */
188 if (local_obj_desc != obj_desc) { 186 if (local_obj_desc != obj_desc) {
189 acpi_ut_remove_reference (local_obj_desc); 187 acpi_ut_remove_reference(local_obj_desc);
190 } 188 }
191 acpi_ut_remove_reference (obj_desc); 189 acpi_ut_remove_reference(obj_desc);
192 190
193 walk_state->control_state->common.state = ACPI_CONTROL_NORMAL; 191 walk_state->control_state->common.state = ACPI_CONTROL_NORMAL;
194 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
195} 193}
196 194
197
198/***************************************************************************** 195/*****************************************************************************
199 * 196 *
200 * FUNCTION: acpi_ds_exec_begin_op 197 * FUNCTION: acpi_ds_exec_begin_op
@@ -211,38 +208,39 @@ cleanup:
211 ****************************************************************************/ 208 ****************************************************************************/
212 209
213acpi_status 210acpi_status
214acpi_ds_exec_begin_op ( 211acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
215 struct acpi_walk_state *walk_state, 212 union acpi_parse_object **out_op)
216 union acpi_parse_object **out_op)
217{ 213{
218 union acpi_parse_object *op; 214 union acpi_parse_object *op;
219 acpi_status status = AE_OK; 215 acpi_status status = AE_OK;
220 u32 opcode_class; 216 u32 opcode_class;
221
222
223 ACPI_FUNCTION_TRACE_PTR ("ds_exec_begin_op", walk_state);
224 217
218 ACPI_FUNCTION_TRACE_PTR("ds_exec_begin_op", walk_state);
225 219
226 op = walk_state->op; 220 op = walk_state->op;
227 if (!op) { 221 if (!op) {
228 status = acpi_ds_load2_begin_op (walk_state, out_op); 222 status = acpi_ds_load2_begin_op(walk_state, out_op);
229 if (ACPI_FAILURE (status)) { 223 if (ACPI_FAILURE(status)) {
230 return_ACPI_STATUS (status); 224 return_ACPI_STATUS(status);
231 } 225 }
232 226
233 op = *out_op; 227 op = *out_op;
234 walk_state->op = op; 228 walk_state->op = op;
235 walk_state->opcode = op->common.aml_opcode; 229 walk_state->opcode = op->common.aml_opcode;
236 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 230 walk_state->op_info =
237 231 acpi_ps_get_opcode_info(op->common.aml_opcode);
238 if (acpi_ns_opens_scope (walk_state->op_info->object_type)) { 232
239 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 233 if (acpi_ns_opens_scope(walk_state->op_info->object_type)) {
240 "(%s) Popping scope for Op %p\n", 234 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
241 acpi_ut_get_type_name (walk_state->op_info->object_type), op)); 235 "(%s) Popping scope for Op %p\n",
242 236 acpi_ut_get_type_name(walk_state->
243 status = acpi_ds_scope_stack_pop (walk_state); 237 op_info->
244 if (ACPI_FAILURE (status)) { 238 object_type),
245 return_ACPI_STATUS (status); 239 op));
240
241 status = acpi_ds_scope_stack_pop(walk_state);
242 if (ACPI_FAILURE(status)) {
243 return_ACPI_STATUS(status);
246 } 244 }
247 } 245 }
248 } 246 }
@@ -252,7 +250,7 @@ acpi_ds_exec_begin_op (
252 *out_op = op; 250 *out_op = op;
253 } 251 }
254 252
255 return_ACPI_STATUS (AE_OK); 253 return_ACPI_STATUS(AE_OK);
256 } 254 }
257 255
258 /* 256 /*
@@ -261,19 +259,20 @@ acpi_ds_exec_begin_op (
261 * Save this knowledge in the current scope descriptor 259 * Save this knowledge in the current scope descriptor
262 */ 260 */
263 if ((walk_state->control_state) && 261 if ((walk_state->control_state) &&
264 (walk_state->control_state->common.state == 262 (walk_state->control_state->common.state ==
265 ACPI_CONTROL_CONDITIONAL_EXECUTING)) { 263 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
266 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", 264 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
267 op, walk_state)); 265 "Exec predicate Op=%p State=%p\n", op,
266 walk_state));
268 267
269 walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING; 268 walk_state->control_state->common.state =
269 ACPI_CONTROL_PREDICATE_EXECUTING;
270 270
271 /* Save start of predicate */ 271 /* Save start of predicate */
272 272
273 walk_state->control_state->control.predicate_op = op; 273 walk_state->control_state->control.predicate_op = op;
274 } 274 }
275 275
276
277 opcode_class = walk_state->op_info->class; 276 opcode_class = walk_state->op_info->class;
278 277
279 /* We want to send namepaths to the load code */ 278 /* We want to send namepaths to the load code */
@@ -288,15 +287,14 @@ acpi_ds_exec_begin_op (
288 switch (opcode_class) { 287 switch (opcode_class) {
289 case AML_CLASS_CONTROL: 288 case AML_CLASS_CONTROL:
290 289
291 status = acpi_ds_result_stack_push (walk_state); 290 status = acpi_ds_result_stack_push(walk_state);
292 if (ACPI_FAILURE (status)) { 291 if (ACPI_FAILURE(status)) {
293 return_ACPI_STATUS (status); 292 return_ACPI_STATUS(status);
294 } 293 }
295 294
296 status = acpi_ds_exec_begin_control_op (walk_state, op); 295 status = acpi_ds_exec_begin_control_op(walk_state, op);
297 break; 296 break;
298 297
299
300 case AML_CLASS_NAMED_OBJECT: 298 case AML_CLASS_NAMED_OBJECT:
301 299
302 if (walk_state->walk_type == ACPI_WALK_METHOD) { 300 if (walk_state->walk_type == ACPI_WALK_METHOD) {
@@ -306,15 +304,14 @@ acpi_ds_exec_begin_op (
306 * object is temporary and will be deleted upon completion of 304 * object is temporary and will be deleted upon completion of
307 * the execution of this method. 305 * the execution of this method.
308 */ 306 */
309 status = acpi_ds_load2_begin_op (walk_state, NULL); 307 status = acpi_ds_load2_begin_op(walk_state, NULL);
310 } 308 }
311 309
312 if (op->common.aml_opcode == AML_REGION_OP) { 310 if (op->common.aml_opcode == AML_REGION_OP) {
313 status = acpi_ds_result_stack_push (walk_state); 311 status = acpi_ds_result_stack_push(walk_state);
314 } 312 }
315 break; 313 break;
316 314
317
318 case AML_CLASS_EXECUTE: 315 case AML_CLASS_EXECUTE:
319 case AML_CLASS_CREATE: 316 case AML_CLASS_CREATE:
320 317
@@ -322,20 +319,18 @@ acpi_ds_exec_begin_op (
322 * Most operators with arguments. 319 * Most operators with arguments.
323 * Start a new result/operand state 320 * Start a new result/operand state
324 */ 321 */
325 status = acpi_ds_result_stack_push (walk_state); 322 status = acpi_ds_result_stack_push(walk_state);
326 break; 323 break;
327 324
328
329 default: 325 default:
330 break; 326 break;
331 } 327 }
332 328
333 /* Nothing to do here during method execution */ 329 /* Nothing to do here during method execution */
334 330
335 return_ACPI_STATUS (status); 331 return_ACPI_STATUS(status);
336} 332}
337 333
338
339/***************************************************************************** 334/*****************************************************************************
340 * 335 *
341 * FUNCTION: acpi_ds_exec_end_op 336 * FUNCTION: acpi_ds_exec_end_op
@@ -350,28 +345,25 @@ acpi_ds_exec_begin_op (
350 * 345 *
351 ****************************************************************************/ 346 ****************************************************************************/
352 347
353acpi_status 348acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
354acpi_ds_exec_end_op (
355 struct acpi_walk_state *walk_state)
356{ 349{
357 union acpi_parse_object *op; 350 union acpi_parse_object *op;
358 acpi_status status = AE_OK; 351 acpi_status status = AE_OK;
359 u32 op_type; 352 u32 op_type;
360 u32 op_class; 353 u32 op_class;
361 union acpi_parse_object *next_op; 354 union acpi_parse_object *next_op;
362 union acpi_parse_object *first_arg; 355 union acpi_parse_object *first_arg;
363 356
357 ACPI_FUNCTION_TRACE_PTR("ds_exec_end_op", walk_state);
364 358
365 ACPI_FUNCTION_TRACE_PTR ("ds_exec_end_op", walk_state); 359 op = walk_state->op;
366
367
368 op = walk_state->op;
369 op_type = walk_state->op_info->type; 360 op_type = walk_state->op_info->type;
370 op_class = walk_state->op_info->class; 361 op_class = walk_state->op_info->class;
371 362
372 if (op_class == AML_CLASS_UNKNOWN) { 363 if (op_class == AML_CLASS_UNKNOWN) {
373 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->common.aml_opcode)); 364 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n",
374 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 365 op->common.aml_opcode));
366 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
375 } 367 }
376 368
377 first_arg = op->common.value.arg; 369 first_arg = op->common.value.arg;
@@ -384,29 +376,31 @@ acpi_ds_exec_end_op (
384 376
385 /* Call debugger for single step support (DEBUG build only) */ 377 /* Call debugger for single step support (DEBUG build only) */
386 378
387 ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class)); 379 ACPI_DEBUGGER_EXEC(status =
388 ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);}); 380 acpi_db_single_step(walk_state, op, op_class));
381 ACPI_DEBUGGER_EXEC(if (ACPI_FAILURE(status)) {
382 return_ACPI_STATUS(status);}
383 ) ;
389 384
390 /* Decode the Opcode Class */ 385 /* Decode the Opcode Class */
391 386
392 switch (op_class) { 387 switch (op_class) {
393 case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ 388 case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
394 break; 389 break;
395 390
396 391 case AML_CLASS_EXECUTE: /* most operators with arguments */
397 case AML_CLASS_EXECUTE: /* most operators with arguments */
398 392
399 /* Build resolved operand stack */ 393 /* Build resolved operand stack */
400 394
401 status = acpi_ds_create_operands (walk_state, first_arg); 395 status = acpi_ds_create_operands(walk_state, first_arg);
402 if (ACPI_FAILURE (status)) { 396 if (ACPI_FAILURE(status)) {
403 goto cleanup; 397 goto cleanup;
404 } 398 }
405 399
406 /* Done with this result state (Now that operand stack is built) */ 400 /* Done with this result state (Now that operand stack is built) */
407 401
408 status = acpi_ds_result_stack_pop (walk_state); 402 status = acpi_ds_result_stack_pop(walk_state);
409 if (ACPI_FAILURE (status)) { 403 if (ACPI_FAILURE(status)) {
410 goto cleanup; 404 goto cleanup;
411 } 405 }
412 406
@@ -417,86 +411,93 @@ acpi_ds_exec_end_op (
417 if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) { 411 if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) {
418 /* Resolve all operands */ 412 /* Resolve all operands */
419 413
420 status = acpi_ex_resolve_operands (walk_state->opcode, 414 status = acpi_ex_resolve_operands(walk_state->opcode,
421 &(walk_state->operands [walk_state->num_operands -1]), 415 &(walk_state->
422 walk_state); 416 operands
423 if (ACPI_SUCCESS (status)) { 417 [walk_state->
424 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 418 num_operands - 1]),
425 acpi_ps_get_opcode_name (walk_state->opcode), 419 walk_state);
426 walk_state->num_operands, "after ex_resolve_operands"); 420 if (ACPI_SUCCESS(status)) {
421 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
422 ACPI_IMODE_EXECUTE,
423 acpi_ps_get_opcode_name
424 (walk_state->opcode),
425 walk_state->num_operands,
426 "after ex_resolve_operands");
427 } 427 }
428 } 428 }
429 429
430 if (ACPI_SUCCESS (status)) { 430 if (ACPI_SUCCESS(status)) {
431 /* 431 /*
432 * Dispatch the request to the appropriate interpreter handler 432 * Dispatch the request to the appropriate interpreter handler
433 * routine. There is one routine per opcode "type" based upon the 433 * routine. There is one routine per opcode "type" based upon the
434 * number of opcode arguments and return type. 434 * number of opcode arguments and return type.
435 */ 435 */
436 status = acpi_gbl_op_type_dispatch[op_type] (walk_state); 436 status =
437 } 437 acpi_gbl_op_type_dispatch[op_type] (walk_state);
438 else { 438 } else {
439 /* 439 /*
440 * Treat constructs of the form "Store(local_x,local_x)" as noops when the 440 * Treat constructs of the form "Store(local_x,local_x)" as noops when the
441 * Local is uninitialized. 441 * Local is uninitialized.
442 */ 442 */
443 if ((status == AE_AML_UNINITIALIZED_LOCAL) && 443 if ((status == AE_AML_UNINITIALIZED_LOCAL) &&
444 (walk_state->opcode == AML_STORE_OP) && 444 (walk_state->opcode == AML_STORE_OP) &&
445 (walk_state->operands[0]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 445 (walk_state->operands[0]->common.type ==
446 (walk_state->operands[1]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 446 ACPI_TYPE_LOCAL_REFERENCE)
447 (walk_state->operands[0]->reference.opcode == 447 && (walk_state->operands[1]->common.type ==
448 walk_state->operands[1]->reference.opcode) && 448 ACPI_TYPE_LOCAL_REFERENCE)
449 (walk_state->operands[0]->reference.offset == 449 && (walk_state->operands[0]->reference.opcode ==
450 walk_state->operands[1]->reference.offset)) { 450 walk_state->operands[1]->reference.opcode)
451 && (walk_state->operands[0]->reference.offset ==
452 walk_state->operands[1]->reference.offset)) {
451 status = AE_OK; 453 status = AE_OK;
452 } 454 } else {
453 else { 455 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
454 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 456 "[%s]: Could not resolve operands, %s\n",
455 "[%s]: Could not resolve operands, %s\n", 457 acpi_ps_get_opcode_name
456 acpi_ps_get_opcode_name (walk_state->opcode), 458 (walk_state->opcode),
457 acpi_format_exception (status))); 459 acpi_format_exception
460 (status)));
458 } 461 }
459 } 462 }
460 463
461 /* Always delete the argument objects and clear the operand stack */ 464 /* Always delete the argument objects and clear the operand stack */
462 465
463 acpi_ds_clear_operands (walk_state); 466 acpi_ds_clear_operands(walk_state);
464 467
465 /* 468 /*
466 * If a result object was returned from above, push it on the 469 * If a result object was returned from above, push it on the
467 * current result stack 470 * current result stack
468 */ 471 */
469 if (ACPI_SUCCESS (status) && 472 if (ACPI_SUCCESS(status) && walk_state->result_obj) {
470 walk_state->result_obj) { 473 status =
471 status = acpi_ds_result_push (walk_state->result_obj, walk_state); 474 acpi_ds_result_push(walk_state->result_obj,
475 walk_state);
472 } 476 }
473 477
474 break; 478 break;
475 479
476
477 default: 480 default:
478 481
479 switch (op_type) { 482 switch (op_type) {
480 case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ 483 case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
481 484
482 /* 1 Operand, 0 external_result, 0 internal_result */ 485 /* 1 Operand, 0 external_result, 0 internal_result */
483 486
484 status = acpi_ds_exec_end_control_op (walk_state, op); 487 status = acpi_ds_exec_end_control_op(walk_state, op);
485 488
486 /* Make sure to properly pop the result stack */ 489 /* Make sure to properly pop the result stack */
487 490
488 if (ACPI_SUCCESS (status)) { 491 if (ACPI_SUCCESS(status)) {
489 status = acpi_ds_result_stack_pop (walk_state); 492 status = acpi_ds_result_stack_pop(walk_state);
490 } 493 } else if (status == AE_CTRL_PENDING) {
491 else if (status == AE_CTRL_PENDING) { 494 status = acpi_ds_result_stack_pop(walk_state);
492 status = acpi_ds_result_stack_pop (walk_state); 495 if (ACPI_SUCCESS(status)) {
493 if (ACPI_SUCCESS (status)) {
494 status = AE_CTRL_PENDING; 496 status = AE_CTRL_PENDING;
495 } 497 }
496 } 498 }
497 break; 499 break;
498 500
499
500 case AML_TYPE_METHOD_CALL: 501 case AML_TYPE_METHOD_CALL:
501 502
502 /* 503 /*
@@ -505,16 +506,22 @@ acpi_ds_exec_end_op (
505 * a reference to it. 506 * a reference to it.
506 */ 507 */
507 if ((op->asl.parent) && 508 if ((op->asl.parent) &&
508 ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) || 509 ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP)
509 (op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) { 510 || (op->asl.parent->asl.aml_opcode ==
510 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 511 AML_VAR_PACKAGE_OP))) {
511 "Method Reference in a Package, Op=%p\n", op)); 512 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
512 op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object; 513 "Method Reference in a Package, Op=%p\n",
513 acpi_ut_add_reference (op->asl.value.arg->asl.node->object); 514 op));
514 return_ACPI_STATUS (AE_OK); 515 op->common.node =
516 (struct acpi_namespace_node *)op->asl.value.
517 arg->asl.node->object;
518 acpi_ut_add_reference(op->asl.value.arg->asl.
519 node->object);
520 return_ACPI_STATUS(AE_OK);
515 } 521 }
516 522
517 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", op)); 523 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
524 "Method invocation, Op=%p\n", op));
518 525
519 /* 526 /*
520 * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains 527 * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
@@ -531,8 +538,8 @@ acpi_ds_exec_end_op (
531 /* 538 /*
532 * Get the method's arguments and put them on the operand stack 539 * Get the method's arguments and put them on the operand stack
533 */ 540 */
534 status = acpi_ds_create_operands (walk_state, next_op); 541 status = acpi_ds_create_operands(walk_state, next_op);
535 if (ACPI_FAILURE (status)) { 542 if (ACPI_FAILURE(status)) {
536 break; 543 break;
537 } 544 }
538 545
@@ -541,11 +548,11 @@ acpi_ds_exec_end_op (
541 * we must resolve all local references here (Local variables, 548 * we must resolve all local references here (Local variables,
542 * arguments to *this* method, etc.) 549 * arguments to *this* method, etc.)
543 */ 550 */
544 status = acpi_ds_resolve_operands (walk_state); 551 status = acpi_ds_resolve_operands(walk_state);
545 if (ACPI_FAILURE (status)) { 552 if (ACPI_FAILURE(status)) {
546 /* On error, clear all resolved operands */ 553 /* On error, clear all resolved operands */
547 554
548 acpi_ds_clear_operands (walk_state); 555 acpi_ds_clear_operands(walk_state);
549 break; 556 break;
550 } 557 }
551 558
@@ -559,27 +566,28 @@ acpi_ds_exec_end_op (
559 * Return now; we don't want to disturb anything, 566 * Return now; we don't want to disturb anything,
560 * especially the operand count! 567 * especially the operand count!
561 */ 568 */
562 return_ACPI_STATUS (status); 569 return_ACPI_STATUS(status);
563
564 570
565 case AML_TYPE_CREATE_FIELD: 571 case AML_TYPE_CREATE_FIELD:
566 572
567 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 573 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
568 "Executing create_field Buffer/Index Op=%p\n", op)); 574 "Executing create_field Buffer/Index Op=%p\n",
575 op));
569 576
570 status = acpi_ds_load2_end_op (walk_state); 577 status = acpi_ds_load2_end_op(walk_state);
571 if (ACPI_FAILURE (status)) { 578 if (ACPI_FAILURE(status)) {
572 break; 579 break;
573 } 580 }
574 581
575 status = acpi_ds_eval_buffer_field_operands (walk_state, op); 582 status =
583 acpi_ds_eval_buffer_field_operands(walk_state, op);
576 break; 584 break;
577 585
578
579 case AML_TYPE_CREATE_OBJECT: 586 case AML_TYPE_CREATE_OBJECT:
580 587
581 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 588 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
582 "Executing create_object (Buffer/Package) Op=%p\n", op)); 589 "Executing create_object (Buffer/Package) Op=%p\n",
590 op));
583 591
584 switch (op->common.parent->common.aml_opcode) { 592 switch (op->common.parent->common.aml_opcode) {
585 case AML_NAME_OP: 593 case AML_NAME_OP:
@@ -588,13 +596,15 @@ acpi_ds_exec_end_op (
588 * Put the Node on the object stack (Contains the ACPI Name 596 * Put the Node on the object stack (Contains the ACPI Name
589 * of this object) 597 * of this object)
590 */ 598 */
591 walk_state->operands[0] = (void *) op->common.parent->common.node; 599 walk_state->operands[0] =
600 (void *)op->common.parent->common.node;
592 walk_state->num_operands = 1; 601 walk_state->num_operands = 1;
593 602
594 status = acpi_ds_create_node (walk_state, 603 status = acpi_ds_create_node(walk_state,
595 op->common.parent->common.node, 604 op->common.parent->
596 op->common.parent); 605 common.node,
597 if (ACPI_FAILURE (status)) { 606 op->common.parent);
607 if (ACPI_FAILURE(status)) {
598 break; 608 break;
599 } 609 }
600 610
@@ -603,20 +613,26 @@ acpi_ds_exec_end_op (
603 613
604 case AML_INT_EVAL_SUBTREE_OP: 614 case AML_INT_EVAL_SUBTREE_OP:
605 615
606 status = acpi_ds_eval_data_object_operands (walk_state, op, 616 status =
607 acpi_ns_get_attached_object (op->common.parent->common.node)); 617 acpi_ds_eval_data_object_operands
618 (walk_state, op,
619 acpi_ns_get_attached_object(op->common.
620 parent->common.
621 node));
608 break; 622 break;
609 623
610 default: 624 default:
611 625
612 status = acpi_ds_eval_data_object_operands (walk_state, op, NULL); 626 status =
627 acpi_ds_eval_data_object_operands
628 (walk_state, op, NULL);
613 break; 629 break;
614 } 630 }
615 631
616 /* Done with result state (Now that operand stack is built) */ 632 /* Done with result state (Now that operand stack is built) */
617 633
618 status = acpi_ds_result_stack_pop (walk_state); 634 status = acpi_ds_result_stack_pop(walk_state);
619 if (ACPI_FAILURE (status)) { 635 if (ACPI_FAILURE(status)) {
620 goto cleanup; 636 goto cleanup;
621 } 637 }
622 638
@@ -625,56 +641,58 @@ acpi_ds_exec_end_op (
625 * current result stack 641 * current result stack
626 */ 642 */
627 if (walk_state->result_obj) { 643 if (walk_state->result_obj) {
628 status = acpi_ds_result_push (walk_state->result_obj, walk_state); 644 status =
645 acpi_ds_result_push(walk_state->result_obj,
646 walk_state);
629 } 647 }
630 break; 648 break;
631 649
632
633 case AML_TYPE_NAMED_FIELD: 650 case AML_TYPE_NAMED_FIELD:
634 case AML_TYPE_NAMED_COMPLEX: 651 case AML_TYPE_NAMED_COMPLEX:
635 case AML_TYPE_NAMED_SIMPLE: 652 case AML_TYPE_NAMED_SIMPLE:
636 case AML_TYPE_NAMED_NO_OBJ: 653 case AML_TYPE_NAMED_NO_OBJ:
637 654
638 status = acpi_ds_load2_end_op (walk_state); 655 status = acpi_ds_load2_end_op(walk_state);
639 if (ACPI_FAILURE (status)) { 656 if (ACPI_FAILURE(status)) {
640 break; 657 break;
641 } 658 }
642 659
643 if (op->common.aml_opcode == AML_REGION_OP) { 660 if (op->common.aml_opcode == AML_REGION_OP) {
644 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 661 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
645 "Executing op_region Address/Length Op=%p\n", op)); 662 "Executing op_region Address/Length Op=%p\n",
646 663 op));
647 status = acpi_ds_eval_region_operands (walk_state, op); 664
648 if (ACPI_FAILURE (status)) { 665 status =
666 acpi_ds_eval_region_operands(walk_state,
667 op);
668 if (ACPI_FAILURE(status)) {
649 break; 669 break;
650 } 670 }
651 671
652 status = acpi_ds_result_stack_pop (walk_state); 672 status = acpi_ds_result_stack_pop(walk_state);
653 } 673 }
654 674
655 break; 675 break;
656 676
657
658 case AML_TYPE_UNDEFINED: 677 case AML_TYPE_UNDEFINED:
659 678
660 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
661 "Undefined opcode type Op=%p\n", op)); 680 "Undefined opcode type Op=%p\n", op));
662 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 681 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
663
664 682
665 case AML_TYPE_BOGUS: 683 case AML_TYPE_BOGUS:
666 684
667 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 685 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
668 "Internal opcode=%X type Op=%p\n", 686 "Internal opcode=%X type Op=%p\n",
669 walk_state->opcode, op)); 687 walk_state->opcode, op));
670 break; 688 break;
671 689
672
673 default: 690 default:
674 691
675 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 692 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
676 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", 693 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
677 op_class, op_type, op->common.aml_opcode, op)); 694 op_class, op_type,
695 op->common.aml_opcode, op));
678 696
679 status = AE_NOT_IMPLEMENTED; 697 status = AE_NOT_IMPLEMENTED;
680 break; 698 break;
@@ -685,55 +703,58 @@ acpi_ds_exec_end_op (
685 * ACPI 2.0 support for 64-bit integers: Truncate numeric 703 * ACPI 2.0 support for 64-bit integers: Truncate numeric
686 * result value if we are executing from a 32-bit ACPI table 704 * result value if we are executing from a 32-bit ACPI table
687 */ 705 */
688 acpi_ex_truncate_for32bit_table (walk_state->result_obj); 706 acpi_ex_truncate_for32bit_table(walk_state->result_obj);
689 707
690 /* 708 /*
691 * Check if we just completed the evaluation of a 709 * Check if we just completed the evaluation of a
692 * conditional predicate 710 * conditional predicate
693 */ 711 */
694 712
695 if ((ACPI_SUCCESS (status)) && 713 if ((ACPI_SUCCESS(status)) &&
696 (walk_state->control_state) && 714 (walk_state->control_state) &&
697 (walk_state->control_state->common.state == 715 (walk_state->control_state->common.state ==
698 ACPI_CONTROL_PREDICATE_EXECUTING) && 716 ACPI_CONTROL_PREDICATE_EXECUTING) &&
699 (walk_state->control_state->control.predicate_op == op)) { 717 (walk_state->control_state->control.predicate_op == op)) {
700 status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj); 718 status =
719 acpi_ds_get_predicate_value(walk_state,
720 walk_state->result_obj);
701 walk_state->result_obj = NULL; 721 walk_state->result_obj = NULL;
702 } 722 }
703 723
704 724 cleanup:
705cleanup:
706 725
707 /* Invoke exception handler on error */ 726 /* Invoke exception handler on error */
708 727
709 if (ACPI_FAILURE (status) && 728 if (ACPI_FAILURE(status) &&
710 acpi_gbl_exception_handler && 729 acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) {
711 !(status & AE_CODE_CONTROL)) { 730 acpi_ex_exit_interpreter();
712 acpi_ex_exit_interpreter (); 731 status = acpi_gbl_exception_handler(status,
713 status = acpi_gbl_exception_handler (status, 732 walk_state->method_node->
714 walk_state->method_node->name.integer, walk_state->opcode, 733 name.integer,
715 walk_state->aml_offset, NULL); 734 walk_state->opcode,
716 (void) acpi_ex_enter_interpreter (); 735 walk_state->aml_offset,
736 NULL);
737 (void)acpi_ex_enter_interpreter();
717 } 738 }
718 739
719 if (walk_state->result_obj) { 740 if (walk_state->result_obj) {
720 /* Break to debugger to display result */ 741 /* Break to debugger to display result */
721 742
722 ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, 743 ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
723 walk_state)); 744 (walk_state->result_obj, walk_state));
724 745
725 /* 746 /*
726 * Delete the result op if and only if: 747 * Delete the result op if and only if:
727 * Parent will not use the result -- such as any 748 * Parent will not use the result -- such as any
728 * non-nested type2 op in a method (parent will be method) 749 * non-nested type2 op in a method (parent will be method)
729 */ 750 */
730 acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state); 751 acpi_ds_delete_result_if_not_used(op, walk_state->result_obj,
752 walk_state);
731 } 753 }
732
733#ifdef _UNDER_DEVELOPMENT 754#ifdef _UNDER_DEVELOPMENT
734 755
735 if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) { 756 if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) {
736 acpi_db_method_end (walk_state); 757 acpi_db_method_end(walk_state);
737 } 758 }
738#endif 759#endif
739 760
@@ -745,12 +766,10 @@ cleanup:
745 766
746 /* On error, display method locals/args */ 767 /* On error, display method locals/args */
747 768
748 if (ACPI_FAILURE (status)) { 769 if (ACPI_FAILURE(status)) {
749 acpi_dm_dump_method_info (status, walk_state, op); 770 acpi_dm_dump_method_info(status, walk_state, op);
750 } 771 }
751#endif 772#endif
752 773
753 return_ACPI_STATUS (status); 774 return_ACPI_STATUS(status);
754} 775}
755
756
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index d11620018421..411731261c29 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -50,13 +49,12 @@
50#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
51#include <acpi/acevents.h> 50#include <acpi/acevents.h>
52 51
53#ifdef _ACPI_ASL_COMPILER 52#ifdef ACPI_ASL_COMPILER
54#include <acpi/acdisasm.h> 53#include <acpi/acdisasm.h>
55#endif 54#endif
56 55
57#define _COMPONENT ACPI_DISPATCHER 56#define _COMPONENT ACPI_DISPATCHER
58 ACPI_MODULE_NAME ("dswload") 57ACPI_MODULE_NAME("dswload")
59
60 58
61/******************************************************************************* 59/*******************************************************************************
62 * 60 *
@@ -70,32 +68,29 @@
70 * DESCRIPTION: Init walk state callbacks 68 * DESCRIPTION: Init walk state callbacks
71 * 69 *
72 ******************************************************************************/ 70 ******************************************************************************/
73
74acpi_status 71acpi_status
75acpi_ds_init_callbacks ( 72acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
76 struct acpi_walk_state *walk_state,
77 u32 pass_number)
78{ 73{
79 74
80 switch (pass_number) { 75 switch (pass_number) {
81 case 1: 76 case 1:
82 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 77 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
83 ACPI_PARSE_DELETE_TREE; 78 ACPI_PARSE_DELETE_TREE;
84 walk_state->descending_callback = acpi_ds_load1_begin_op; 79 walk_state->descending_callback = acpi_ds_load1_begin_op;
85 walk_state->ascending_callback = acpi_ds_load1_end_op; 80 walk_state->ascending_callback = acpi_ds_load1_end_op;
86 break; 81 break;
87 82
88 case 2: 83 case 2:
89 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 84 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
90 ACPI_PARSE_DELETE_TREE; 85 ACPI_PARSE_DELETE_TREE;
91 walk_state->descending_callback = acpi_ds_load2_begin_op; 86 walk_state->descending_callback = acpi_ds_load2_begin_op;
92 walk_state->ascending_callback = acpi_ds_load2_end_op; 87 walk_state->ascending_callback = acpi_ds_load2_end_op;
93 break; 88 break;
94 89
95 case 3: 90 case 3:
96#ifndef ACPI_NO_METHOD_EXECUTION 91#ifndef ACPI_NO_METHOD_EXECUTION
97 walk_state->parse_flags |= ACPI_PARSE_EXECUTE | 92 walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
98 ACPI_PARSE_DELETE_TREE; 93 ACPI_PARSE_DELETE_TREE;
99 walk_state->descending_callback = acpi_ds_exec_begin_op; 94 walk_state->descending_callback = acpi_ds_exec_begin_op;
100 walk_state->ascending_callback = acpi_ds_exec_end_op; 95 walk_state->ascending_callback = acpi_ds_exec_end_op;
101#endif 96#endif
@@ -108,7 +103,6 @@ acpi_ds_init_callbacks (
108 return (AE_OK); 103 return (AE_OK);
109} 104}
110 105
111
112/******************************************************************************* 106/*******************************************************************************
113 * 107 *
114 * FUNCTION: acpi_ds_load1_begin_op 108 * FUNCTION: acpi_ds_load1_begin_op
@@ -123,37 +117,26 @@ acpi_ds_init_callbacks (
123 ******************************************************************************/ 117 ******************************************************************************/
124 118
125acpi_status 119acpi_status
126acpi_ds_load1_begin_op ( 120acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
127 struct acpi_walk_state *walk_state, 121 union acpi_parse_object ** out_op)
128 union acpi_parse_object **out_op)
129{ 122{
130 union acpi_parse_object *op; 123 union acpi_parse_object *op;
131 struct acpi_namespace_node *node; 124 struct acpi_namespace_node *node;
132 acpi_status status; 125 acpi_status status;
133 acpi_object_type object_type; 126 acpi_object_type object_type;
134 char *path; 127 char *path;
135 u32 flags; 128 u32 flags;
136
137
138 ACPI_FUNCTION_NAME ("ds_load1_begin_op");
139 129
130 ACPI_FUNCTION_NAME("ds_load1_begin_op");
140 131
141 op = walk_state->op; 132 op = walk_state->op;
142 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
134 walk_state));
143 135
144 /* We are only interested in opcodes that have an associated name */ 136 /* We are only interested in opcodes that have an associated name */
145 137
146 if (op) { 138 if (op) {
147 if (!(walk_state->op_info->flags & AML_NAMED)) { 139 if (!(walk_state->op_info->flags & AML_NAMED)) {
148#if 0
149 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
150 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
151 acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n",
152 walk_state->op_info->name);
153 *out_op = op;
154 return (AE_CTRL_SKIP);
155 }
156#endif
157 *out_op = op; 140 *out_op = op;
158 return (AE_OK); 141 return (AE_OK);
159 } 142 }
@@ -166,14 +149,15 @@ acpi_ds_load1_begin_op (
166 } 149 }
167 } 150 }
168 151
169 path = acpi_ps_get_next_namestring (&walk_state->parser_state); 152 path = acpi_ps_get_next_namestring(&walk_state->parser_state);
170 153
171 /* Map the raw opcode into an internal object type */ 154 /* Map the raw opcode into an internal object type */
172 155
173 object_type = walk_state->op_info->object_type; 156 object_type = walk_state->op_info->object_type;
174 157
175 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 158 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
176 "State=%p Op=%p [%s]\n", walk_state, op, acpi_ut_get_type_name (object_type))); 159 "State=%p Op=%p [%s]\n", walk_state, op,
160 acpi_ut_get_type_name(object_type)));
177 161
178 switch (walk_state->opcode) { 162 switch (walk_state->opcode) {
179 case AML_SCOPE_OP: 163 case AML_SCOPE_OP:
@@ -183,23 +167,27 @@ acpi_ds_load1_begin_op (
183 * that we can actually open the scope to enter new names underneath it. 167 * that we can actually open the scope to enter new names underneath it.
184 * Allow search-to-root for single namesegs. 168 * Allow search-to-root for single namesegs.
185 */ 169 */
186 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 170 status =
187 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 171 acpi_ns_lookup(walk_state->scope_info, path, object_type,
188#ifdef _ACPI_ASL_COMPILER 172 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
173 walk_state, &(node));
174#ifdef ACPI_ASL_COMPILER
189 if (status == AE_NOT_FOUND) { 175 if (status == AE_NOT_FOUND) {
190 /* 176 /*
191 * Table disassembly: 177 * Table disassembly:
192 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
193 * insert the name into the namespace. 179 * insert the name into the namespace.
194 */ 180 */
195 acpi_dm_add_to_external_list (path); 181 acpi_dm_add_to_external_list(path);
196 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 182 status =
197 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 183 acpi_ns_lookup(walk_state->scope_info, path,
198 walk_state, &(node)); 184 object_type, ACPI_IMODE_LOAD_PASS1,
185 ACPI_NS_SEARCH_PARENT, walk_state,
186 &(node));
199 } 187 }
200#endif 188#endif
201 if (ACPI_FAILURE (status)) { 189 if (ACPI_FAILURE(status)) {
202 ACPI_REPORT_NSERROR (path, status); 190 ACPI_REPORT_NSERROR(path, status);
203 return (status); 191 return (status);
204 } 192 }
205 193
@@ -208,7 +196,7 @@ acpi_ds_load1_begin_op (
208 * one of the opcodes that actually opens a scope 196 * one of the opcodes that actually opens a scope
209 */ 197 */
210 switch (node->type) { 198 switch (node->type) {
211 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 199 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
212 case ACPI_TYPE_DEVICE: 200 case ACPI_TYPE_DEVICE:
213 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
214 case ACPI_TYPE_PROCESSOR: 202 case ACPI_TYPE_PROCESSOR:
@@ -232,9 +220,10 @@ acpi_ds_load1_begin_op (
232 * a warning 220 * a warning
233 */ 221 */
234 222
235 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 223 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
236 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 224 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
237 path, acpi_ut_get_type_name (node->type))); 225 path,
226 acpi_ut_get_type_name(node->type)));
238 227
239 node->type = ACPI_TYPE_ANY; 228 node->type = ACPI_TYPE_ANY;
240 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 229 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -244,15 +233,12 @@ acpi_ds_load1_begin_op (
244 233
245 /* All other types are an error */ 234 /* All other types are an error */
246 235
247 ACPI_REPORT_ERROR (( 236 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path));
248 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
249 acpi_ut_get_type_name (node->type), path));
250 237
251 return (AE_AML_OPERAND_TYPE); 238 return (AE_AML_OPERAND_TYPE);
252 } 239 }
253 break; 240 break;
254 241
255
256 default: 242 default:
257 243
258 /* 244 /*
@@ -281,15 +267,15 @@ acpi_ds_load1_begin_op (
281 267
282 flags = ACPI_NS_NO_UPSEARCH; 268 flags = ACPI_NS_NO_UPSEARCH;
283 if ((walk_state->opcode != AML_SCOPE_OP) && 269 if ((walk_state->opcode != AML_SCOPE_OP) &&
284 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
285 flags |= ACPI_NS_ERROR_IF_FOUND; 271 flags |= ACPI_NS_ERROR_IF_FOUND;
286 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 272 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
287 acpi_ut_get_type_name (object_type))); 273 "[%s] Cannot already exist\n",
288 } 274 acpi_ut_get_type_name(object_type)));
289 else { 275 } else {
290 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 276 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
291 "[%s] Both Find or Create allowed\n", 277 "[%s] Both Find or Create allowed\n",
292 acpi_ut_get_type_name (object_type))); 278 acpi_ut_get_type_name(object_type)));
293 } 279 }
294 280
295 /* 281 /*
@@ -298,22 +284,23 @@ acpi_ds_load1_begin_op (
298 * involve arguments to the opcode must be created as we go back up the 284 * involve arguments to the opcode must be created as we go back up the
299 * parse tree later. 285 * parse tree later.
300 */ 286 */
301 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 287 status =
302 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); 288 acpi_ns_lookup(walk_state->scope_info, path, object_type,
303 if (ACPI_FAILURE (status)) { 289 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
304 ACPI_REPORT_NSERROR (path, status); 290 &(node));
291 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status);
305 return (status); 293 return (status);
306 } 294 }
307 break; 295 break;
308 } 296 }
309 297
310
311 /* Common exit */ 298 /* Common exit */
312 299
313 if (!op) { 300 if (!op) {
314 /* Create a new op */ 301 /* Create a new op */
315 302
316 op = acpi_ps_alloc_op (walk_state->opcode); 303 op = acpi_ps_alloc_op(walk_state->opcode);
317 if (!op) { 304 if (!op) {
318 return (AE_NO_MEMORY); 305 return (AE_NO_MEMORY);
319 } 306 }
@@ -327,19 +314,18 @@ acpi_ds_load1_begin_op (
327 op->named.path = (u8 *) path; 314 op->named.path = (u8 *) path;
328#endif 315#endif
329 316
330
331 /* 317 /*
332 * Put the Node in the "op" object that the parser uses, so we 318 * Put the Node in the "op" object that the parser uses, so we
333 * can get it again quickly when this scope is closed 319 * can get it again quickly when this scope is closed
334 */ 320 */
335 op->common.node = node; 321 op->common.node = node;
336 acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op); 322 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
323 op);
337 324
338 *out_op = op; 325 *out_op = op;
339 return (status); 326 return (status);
340} 327}
341 328
342
343/******************************************************************************* 329/*******************************************************************************
344 * 330 *
345 * FUNCTION: acpi_ds_load1_end_op 331 * FUNCTION: acpi_ds_load1_end_op
@@ -353,20 +339,17 @@ acpi_ds_load1_begin_op (
353 * 339 *
354 ******************************************************************************/ 340 ******************************************************************************/
355 341
356acpi_status 342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
357acpi_ds_load1_end_op (
358 struct acpi_walk_state *walk_state)
359{ 343{
360 union acpi_parse_object *op; 344 union acpi_parse_object *op;
361 acpi_object_type object_type; 345 acpi_object_type object_type;
362 acpi_status status = AE_OK; 346 acpi_status status = AE_OK;
363
364
365 ACPI_FUNCTION_NAME ("ds_load1_end_op");
366 347
348 ACPI_FUNCTION_NAME("ds_load1_end_op");
367 349
368 op = walk_state->op; 350 op = walk_state->op;
369 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 351 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
352 walk_state));
370 353
371 /* We are only interested in opcodes that have an associated name */ 354 /* We are only interested in opcodes that have an associated name */
372 355
@@ -380,21 +363,20 @@ acpi_ds_load1_end_op (
380 363
381#ifndef ACPI_NO_METHOD_EXECUTION 364#ifndef ACPI_NO_METHOD_EXECUTION
382 if (walk_state->op_info->flags & AML_FIELD) { 365 if (walk_state->op_info->flags & AML_FIELD) {
383 if (walk_state->opcode == AML_FIELD_OP || 366 if (walk_state->opcode == AML_FIELD_OP ||
384 walk_state->opcode == AML_BANK_FIELD_OP || 367 walk_state->opcode == AML_BANK_FIELD_OP ||
385 walk_state->opcode == AML_INDEX_FIELD_OP) { 368 walk_state->opcode == AML_INDEX_FIELD_OP) {
386 status = acpi_ds_init_field_objects (op, walk_state); 369 status = acpi_ds_init_field_objects(op, walk_state);
387 } 370 }
388 return (status); 371 return (status);
389 } 372 }
390 373
391
392 if (op->common.aml_opcode == AML_REGION_OP) { 374 if (op->common.aml_opcode == AML_REGION_OP) {
393 status = acpi_ex_create_region (op->named.data, op->named.length, 375 status = acpi_ex_create_region(op->named.data, op->named.length,
394 (acpi_adr_space_type) 376 (acpi_adr_space_type)
395 ((op->common.value.arg)->common.value.integer), 377 ((op->common.value.arg)->common.
396 walk_state); 378 value.integer), walk_state);
397 if (ACPI_FAILURE (status)) { 379 if (ACPI_FAILURE(status)) {
398 return (status); 380 return (status);
399 } 381 }
400 } 382 }
@@ -404,8 +386,11 @@ acpi_ds_load1_end_op (
404 /* For Name opcode, get the object type from the argument */ 386 /* For Name opcode, get the object type from the argument */
405 387
406 if (op->common.value.arg) { 388 if (op->common.value.arg) {
407 object_type = (acpi_ps_get_opcode_info ( 389 object_type = (acpi_ps_get_opcode_info((op->common.
408 (op->common.value.arg)->common.aml_opcode))->object_type; 390 value.arg)->
391 common.
392 aml_opcode))->
393 object_type;
409 op->common.node->type = (u8) object_type; 394 op->common.node->type = (u8) object_type;
410 } 395 }
411 } 396 }
@@ -419,23 +404,26 @@ acpi_ds_load1_end_op (
419 * of invocations of the method (need to know the number of 404 * of invocations of the method (need to know the number of
420 * arguments.) 405 * arguments.)
421 */ 406 */
422 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
423 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 408 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
424 walk_state, op, op->named.node)); 409 walk_state, op, op->named.node));
425 410
426 if (!acpi_ns_get_attached_object (op->named.node)) { 411 if (!acpi_ns_get_attached_object(op->named.node)) {
427 walk_state->operands[0] = (void *) op->named.node; 412 walk_state->operands[0] = (void *)op->named.node;
428 walk_state->num_operands = 1; 413 walk_state->num_operands = 1;
429 414
430 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 415 status =
431 if (ACPI_SUCCESS (status)) { 416 acpi_ds_create_operands(walk_state,
432 status = acpi_ex_create_method (op->named.data, 417 op->common.value.arg);
433 op->named.length, walk_state); 418 if (ACPI_SUCCESS(status)) {
419 status = acpi_ex_create_method(op->named.data,
420 op->named.length,
421 walk_state);
434 } 422 }
435 walk_state->operands[0] = NULL; 423 walk_state->operands[0] = NULL;
436 walk_state->num_operands = 0; 424 walk_state->num_operands = 0;
437 425
438 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
439 return (status); 427 return (status);
440 } 428 }
441 } 429 }
@@ -443,17 +431,17 @@ acpi_ds_load1_end_op (
443 431
444 /* Pop the scope stack */ 432 /* Pop the scope stack */
445 433
446 if (acpi_ns_opens_scope (object_type)) { 434 if (acpi_ns_opens_scope(object_type)) {
447 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
448 acpi_ut_get_type_name (object_type), op)); 436 "(%s): Popping scope for Op %p\n",
437 acpi_ut_get_type_name(object_type), op));
449 438
450 status = acpi_ds_scope_stack_pop (walk_state); 439 status = acpi_ds_scope_stack_pop(walk_state);
451 } 440 }
452 441
453 return (status); 442 return (status);
454} 443}
455 444
456
457/******************************************************************************* 445/*******************************************************************************
458 * 446 *
459 * FUNCTION: acpi_ds_load2_begin_op 447 * FUNCTION: acpi_ds_load2_begin_op
@@ -468,30 +456,53 @@ acpi_ds_load1_end_op (
468 ******************************************************************************/ 456 ******************************************************************************/
469 457
470acpi_status 458acpi_status
471acpi_ds_load2_begin_op ( 459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
472 struct acpi_walk_state *walk_state, 460 union acpi_parse_object ** out_op)
473 union acpi_parse_object **out_op)
474{ 461{
475 union acpi_parse_object *op; 462 union acpi_parse_object *op;
476 struct acpi_namespace_node *node; 463 struct acpi_namespace_node *node;
477 acpi_status status; 464 acpi_status status;
478 acpi_object_type object_type; 465 acpi_object_type object_type;
479 char *buffer_ptr; 466 char *buffer_ptr;
480
481
482 ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
483 467
468 ACPI_FUNCTION_TRACE("ds_load2_begin_op");
484 469
485 op = walk_state->op; 470 op = walk_state->op;
486 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 471 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
472 walk_state));
487 473
488 if (op) { 474 if (op) {
475 if ((walk_state->control_state) &&
476 (walk_state->control_state->common.state ==
477 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
478 /* We are executing a while loop outside of a method */
479
480 status = acpi_ds_exec_begin_op(walk_state, out_op);
481 return_ACPI_STATUS(status);
482 }
483
489 /* We only care about Namespace opcodes here */ 484 /* We only care about Namespace opcodes here */
490 485
491 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 486 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
492 (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 487 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
493 (!(walk_state->op_info->flags & AML_NAMED))) { 488 (!(walk_state->op_info->flags & AML_NAMED))) {
494 return_ACPI_STATUS (AE_OK); 489#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
490 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
491 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
492
493 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
494 "Begin/EXEC: %s (fl %8.8X)\n",
495 walk_state->op_info->name,
496 walk_state->op_info->flags));
497
498 /* Executing a type1 or type2 opcode outside of a method */
499
500 status =
501 acpi_ds_exec_begin_op(walk_state, out_op);
502 return_ACPI_STATUS(status);
503 }
504#endif
505 return_ACPI_STATUS(AE_OK);
495 } 506 }
496 507
497 /* Get the name we are going to enter or lookup in the namespace */ 508 /* Get the name we are going to enter or lookup in the namespace */
@@ -503,28 +514,27 @@ acpi_ds_load2_begin_op (
503 if (!buffer_ptr) { 514 if (!buffer_ptr) {
504 /* No name, just exit */ 515 /* No name, just exit */
505 516
506 return_ACPI_STATUS (AE_OK); 517 return_ACPI_STATUS(AE_OK);
507 } 518 }
508 } 519 } else {
509 else {
510 /* Get name from the op */ 520 /* Get name from the op */
511 521
512 buffer_ptr = (char *) &op->named.name; 522 buffer_ptr = (char *)&op->named.name;
513 } 523 }
514 } 524 } else {
515 else {
516 /* Get the namestring from the raw AML */ 525 /* Get the namestring from the raw AML */
517 526
518 buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state); 527 buffer_ptr =
528 acpi_ps_get_next_namestring(&walk_state->parser_state);
519 } 529 }
520 530
521 /* Map the opcode into an internal object type */ 531 /* Map the opcode into an internal object type */
522 532
523 object_type = walk_state->op_info->object_type; 533 object_type = walk_state->op_info->object_type;
524 534
525 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 535 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
526 "State=%p Op=%p Type=%X\n", walk_state, op, object_type)); 536 "State=%p Op=%p Type=%X\n", walk_state, op,
527 537 object_type));
528 538
529 switch (walk_state->opcode) { 539 switch (walk_state->opcode) {
530 case AML_FIELD_OP: 540 case AML_FIELD_OP:
@@ -542,9 +552,10 @@ acpi_ds_load2_begin_op (
542 * Don't enter the name into the namespace, but look it up 552 * Don't enter the name into the namespace, but look it up
543 * for use later. 553 * for use later.
544 */ 554 */
545 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 555 status =
546 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 556 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
547 walk_state, &(node)); 557 object_type, ACPI_IMODE_EXECUTE,
558 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
548 break; 559 break;
549 560
550 case AML_SCOPE_OP: 561 case AML_SCOPE_OP:
@@ -554,28 +565,28 @@ acpi_ds_load2_begin_op (
554 * Don't enter the name into the namespace, but look it up 565 * Don't enter the name into the namespace, but look it up
555 * for use later. 566 * for use later.
556 */ 567 */
557 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 568 status =
558 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 569 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
559 walk_state, &(node)); 570 object_type, ACPI_IMODE_EXECUTE,
560 if (ACPI_FAILURE (status)) { 571 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
561#ifdef _ACPI_ASL_COMPILER 572 if (ACPI_FAILURE(status)) {
573#ifdef ACPI_ASL_COMPILER
562 if (status == AE_NOT_FOUND) { 574 if (status == AE_NOT_FOUND) {
563 status = AE_OK; 575 status = AE_OK;
564 } 576 } else {
565 else { 577 ACPI_REPORT_NSERROR(buffer_ptr, status);
566 ACPI_REPORT_NSERROR (buffer_ptr, status);
567 } 578 }
568#else 579#else
569 ACPI_REPORT_NSERROR (buffer_ptr, status); 580 ACPI_REPORT_NSERROR(buffer_ptr, status);
570#endif 581#endif
571 return_ACPI_STATUS (status); 582 return_ACPI_STATUS(status);
572 } 583 }
573 /* 584 /*
574 * We must check to make sure that the target is 585 * We must check to make sure that the target is
575 * one of the opcodes that actually opens a scope 586 * one of the opcodes that actually opens a scope
576 */ 587 */
577 switch (node->type) { 588 switch (node->type) {
578 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 589 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
579 case ACPI_TYPE_DEVICE: 590 case ACPI_TYPE_DEVICE:
580 case ACPI_TYPE_POWER: 591 case ACPI_TYPE_POWER:
581 case ACPI_TYPE_PROCESSOR: 592 case ACPI_TYPE_PROCESSOR:
@@ -596,9 +607,7 @@ acpi_ds_load2_begin_op (
596 * Scope (DEB) { ... } 607 * Scope (DEB) { ... }
597 */ 608 */
598 609
599 ACPI_REPORT_WARNING (( 610 ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type)));
600 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
601 buffer_ptr, acpi_ut_get_type_name (node->type)));
602 611
603 node->type = ACPI_TYPE_ANY; 612 node->type = ACPI_TYPE_ANY;
604 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 613 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -608,9 +617,7 @@ acpi_ds_load2_begin_op (
608 617
609 /* All other types are an error */ 618 /* All other types are an error */
610 619
611 ACPI_REPORT_ERROR (( 620 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr));
612 "Invalid type (%s) for target of Scope operator [%4.4s]\n",
613 acpi_ut_get_type_name (node->type), buffer_ptr));
614 621
615 return (AE_AML_OPERAND_TYPE); 622 return (AE_AML_OPERAND_TYPE);
616 } 623 }
@@ -625,14 +632,16 @@ acpi_ds_load2_begin_op (
625 632
626 node = op->common.node; 633 node = op->common.node;
627 634
628 if (acpi_ns_opens_scope (object_type)) { 635 if (acpi_ns_opens_scope(object_type)) {
629 status = acpi_ds_scope_stack_push (node, object_type, walk_state); 636 status =
630 if (ACPI_FAILURE (status)) { 637 acpi_ds_scope_stack_push(node, object_type,
631 return_ACPI_STATUS (status); 638 walk_state);
639 if (ACPI_FAILURE(status)) {
640 return_ACPI_STATUS(status);
632 } 641 }
633 642
634 } 643 }
635 return_ACPI_STATUS (AE_OK); 644 return_ACPI_STATUS(AE_OK);
636 } 645 }
637 646
638 /* 647 /*
@@ -651,24 +660,26 @@ acpi_ds_load2_begin_op (
651 break; 660 break;
652 } 661 }
653 662
654 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 663 /* Add new entry into namespace */
655 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, 664
656 walk_state, &(node)); 665 status =
666 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
667 object_type, ACPI_IMODE_LOAD_PASS2,
668 ACPI_NS_NO_UPSEARCH, walk_state, &(node));
657 break; 669 break;
658 } 670 }
659 671
660 if (ACPI_FAILURE (status)) { 672 if (ACPI_FAILURE(status)) {
661 ACPI_REPORT_NSERROR (buffer_ptr, status); 673 ACPI_REPORT_NSERROR(buffer_ptr, status);
662 return_ACPI_STATUS (status); 674 return_ACPI_STATUS(status);
663 } 675 }
664 676
665
666 if (!op) { 677 if (!op) {
667 /* Create a new op */ 678 /* Create a new op */
668 679
669 op = acpi_ps_alloc_op (walk_state->opcode); 680 op = acpi_ps_alloc_op(walk_state->opcode);
670 if (!op) { 681 if (!op) {
671 return_ACPI_STATUS (AE_NO_MEMORY); 682 return_ACPI_STATUS(AE_NO_MEMORY);
672 } 683 }
673 684
674 /* Initialize the new op */ 685 /* Initialize the new op */
@@ -676,9 +687,7 @@ acpi_ds_load2_begin_op (
676 if (node) { 687 if (node) {
677 op->named.name = node->name.integer; 688 op->named.name = node->name.integer;
678 } 689 }
679 if (out_op) { 690 *out_op = op;
680 *out_op = op;
681 }
682 } 691 }
683 692
684 /* 693 /*
@@ -687,10 +696,9 @@ acpi_ds_load2_begin_op (
687 */ 696 */
688 op->common.node = node; 697 op->common.node = node;
689 698
690 return_ACPI_STATUS (status); 699 return_ACPI_STATUS(status);
691} 700}
692 701
693
694/******************************************************************************* 702/*******************************************************************************
695 * 703 *
696 * FUNCTION: acpi_ds_load2_end_op 704 * FUNCTION: acpi_ds_load2_end_op
@@ -704,39 +712,54 @@ acpi_ds_load2_begin_op (
704 * 712 *
705 ******************************************************************************/ 713 ******************************************************************************/
706 714
707acpi_status 715acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
708acpi_ds_load2_end_op (
709 struct acpi_walk_state *walk_state)
710{ 716{
711 union acpi_parse_object *op; 717 union acpi_parse_object *op;
712 acpi_status status = AE_OK; 718 acpi_status status = AE_OK;
713 acpi_object_type object_type; 719 acpi_object_type object_type;
714 struct acpi_namespace_node *node; 720 struct acpi_namespace_node *node;
715 union acpi_parse_object *arg; 721 union acpi_parse_object *arg;
716 struct acpi_namespace_node *new_node; 722 struct acpi_namespace_node *new_node;
717#ifndef ACPI_NO_METHOD_EXECUTION 723#ifndef ACPI_NO_METHOD_EXECUTION
718 u32 i; 724 u32 i;
719#endif 725#endif
720 726
721 727 ACPI_FUNCTION_TRACE("ds_load2_end_op");
722 ACPI_FUNCTION_TRACE ("ds_load2_end_op");
723 728
724 op = walk_state->op; 729 op = walk_state->op;
725 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 730 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
726 walk_state->op_info->name, op, walk_state)); 731 walk_state->op_info->name, op, walk_state));
727 732
728 /* Only interested in opcodes that have namespace objects */ 733 /* Check if opcode had an associated namespace object */
729 734
730 if (!(walk_state->op_info->flags & AML_NSOBJECT)) { 735 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
731 return_ACPI_STATUS (AE_OK); 736#ifndef ACPI_NO_METHOD_EXECUTION
737#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
738 /* No namespace object. Executable opcode? */
739
740 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
741 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
742 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
743 "End/EXEC: %s (fl %8.8X)\n",
744 walk_state->op_info->name,
745 walk_state->op_info->flags));
746
747 /* Executing a type1 or type2 opcode outside of a method */
748
749 status = acpi_ds_exec_end_op(walk_state);
750 return_ACPI_STATUS(status);
751 }
752#endif
753#endif
754 return_ACPI_STATUS(AE_OK);
732 } 755 }
733 756
734 if (op->common.aml_opcode == AML_SCOPE_OP) { 757 if (op->common.aml_opcode == AML_SCOPE_OP) {
735 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 758 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
736 "Ending scope Op=%p State=%p\n", op, walk_state)); 759 "Ending scope Op=%p State=%p\n", op,
760 walk_state));
737 } 761 }
738 762
739
740 object_type = walk_state->op_info->object_type; 763 object_type = walk_state->op_info->object_type;
741 764
742 /* 765 /*
@@ -749,18 +772,19 @@ acpi_ds_load2_end_op (
749 * Put the Node on the object stack (Contains the ACPI Name of 772 * Put the Node on the object stack (Contains the ACPI Name of
750 * this object) 773 * this object)
751 */ 774 */
752 walk_state->operands[0] = (void *) node; 775 walk_state->operands[0] = (void *)node;
753 walk_state->num_operands = 1; 776 walk_state->num_operands = 1;
754 777
755 /* Pop the scope stack */ 778 /* Pop the scope stack */
756 779
757 if (acpi_ns_opens_scope (object_type) && 780 if (acpi_ns_opens_scope(object_type) &&
758 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 781 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
759 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 782 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
760 acpi_ut_get_type_name (object_type), op)); 783 "(%s) Popping scope for Op %p\n",
784 acpi_ut_get_type_name(object_type), op));
761 785
762 status = acpi_ds_scope_stack_pop (walk_state); 786 status = acpi_ds_scope_stack_pop(walk_state);
763 if (ACPI_FAILURE (status)) { 787 if (ACPI_FAILURE(status)) {
764 goto cleanup; 788 goto cleanup;
765 } 789 }
766 } 790 }
@@ -793,9 +817,10 @@ acpi_ds_load2_end_op (
793 * AML_THERMALZONE 817 * AML_THERMALZONE
794 */ 818 */
795 819
796 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 820 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
797 "Create-Load [%s] State=%p Op=%p named_obj=%p\n", 821 "Create-Load [%s] State=%p Op=%p named_obj=%p\n",
798 acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node)); 822 acpi_ps_get_opcode_name(op->common.aml_opcode),
823 walk_state, op, node));
799 824
800 /* Decode the opcode */ 825 /* Decode the opcode */
801 826
@@ -810,27 +835,32 @@ acpi_ds_load2_end_op (
810 * Create the field object, but the field buffer and index must 835 * Create the field object, but the field buffer and index must
811 * be evaluated later during the execution phase 836 * be evaluated later during the execution phase
812 */ 837 */
813 status = acpi_ds_create_buffer_field (op, walk_state); 838 status = acpi_ds_create_buffer_field(op, walk_state);
814 break; 839 break;
815 840
816 841 case AML_TYPE_NAMED_FIELD:
817 case AML_TYPE_NAMED_FIELD:
818 842
819 switch (op->common.aml_opcode) { 843 switch (op->common.aml_opcode) {
820 case AML_INDEX_FIELD_OP: 844 case AML_INDEX_FIELD_OP:
821 845
822 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node, 846 status =
823 walk_state); 847 acpi_ds_create_index_field(op,
848 (acpi_handle) arg->
849 common.node, walk_state);
824 break; 850 break;
825 851
826 case AML_BANK_FIELD_OP: 852 case AML_BANK_FIELD_OP:
827 853
828 status = acpi_ds_create_bank_field (op, arg->common.node, walk_state); 854 status =
855 acpi_ds_create_bank_field(op, arg->common.node,
856 walk_state);
829 break; 857 break;
830 858
831 case AML_FIELD_OP: 859 case AML_FIELD_OP:
832 860
833 status = acpi_ds_create_field (op, arg->common.node, walk_state); 861 status =
862 acpi_ds_create_field(op, arg->common.node,
863 walk_state);
834 break; 864 break;
835 865
836 default: 866 default:
@@ -839,43 +869,42 @@ acpi_ds_load2_end_op (
839 } 869 }
840 break; 870 break;
841 871
872 case AML_TYPE_NAMED_SIMPLE:
842 873
843 case AML_TYPE_NAMED_SIMPLE: 874 status = acpi_ds_create_operands(walk_state, arg);
844 875 if (ACPI_FAILURE(status)) {
845 status = acpi_ds_create_operands (walk_state, arg);
846 if (ACPI_FAILURE (status)) {
847 goto cleanup; 876 goto cleanup;
848 } 877 }
849 878
850 switch (op->common.aml_opcode) { 879 switch (op->common.aml_opcode) {
851 case AML_PROCESSOR_OP: 880 case AML_PROCESSOR_OP:
852 881
853 status = acpi_ex_create_processor (walk_state); 882 status = acpi_ex_create_processor(walk_state);
854 break; 883 break;
855 884
856 case AML_POWER_RES_OP: 885 case AML_POWER_RES_OP:
857 886
858 status = acpi_ex_create_power_resource (walk_state); 887 status = acpi_ex_create_power_resource(walk_state);
859 break; 888 break;
860 889
861 case AML_MUTEX_OP: 890 case AML_MUTEX_OP:
862 891
863 status = acpi_ex_create_mutex (walk_state); 892 status = acpi_ex_create_mutex(walk_state);
864 break; 893 break;
865 894
866 case AML_EVENT_OP: 895 case AML_EVENT_OP:
867 896
868 status = acpi_ex_create_event (walk_state); 897 status = acpi_ex_create_event(walk_state);
869 break; 898 break;
870 899
871 case AML_DATA_REGION_OP: 900 case AML_DATA_REGION_OP:
872 901
873 status = acpi_ex_create_table_region (walk_state); 902 status = acpi_ex_create_table_region(walk_state);
874 break; 903 break;
875 904
876 case AML_ALIAS_OP: 905 case AML_ALIAS_OP:
877 906
878 status = acpi_ex_create_alias (walk_state); 907 status = acpi_ex_create_alias(walk_state);
879 break; 908 break;
880 909
881 default: 910 default:
@@ -888,12 +917,12 @@ acpi_ds_load2_end_op (
888 /* Delete operands */ 917 /* Delete operands */
889 918
890 for (i = 1; i < walk_state->num_operands; i++) { 919 for (i = 1; i < walk_state->num_operands; i++) {
891 acpi_ut_remove_reference (walk_state->operands[i]); 920 acpi_ut_remove_reference(walk_state->operands[i]);
892 walk_state->operands[i] = NULL; 921 walk_state->operands[i] = NULL;
893 } 922 }
894 923
895 break; 924 break;
896#endif /* ACPI_NO_METHOD_EXECUTION */ 925#endif /* ACPI_NO_METHOD_EXECUTION */
897 926
898 case AML_TYPE_NAMED_COMPLEX: 927 case AML_TYPE_NAMED_COMPLEX:
899 928
@@ -909,9 +938,10 @@ acpi_ds_load2_end_op (
909 * If we have a valid region, initialize it 938 * If we have a valid region, initialize it
910 * Namespace is NOT locked at this point. 939 * Namespace is NOT locked at this point.
911 */ 940 */
912 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), 941 status =
913 FALSE); 942 acpi_ev_initialize_region
914 if (ACPI_FAILURE (status)) { 943 (acpi_ns_get_attached_object(node), FALSE);
944 if (ACPI_FAILURE(status)) {
915 /* 945 /*
916 * If AE_NOT_EXIST is returned, it is not fatal 946 * If AE_NOT_EXIST is returned, it is not fatal
917 * because many regions get created before a handler 947 * because many regions get created before a handler
@@ -923,13 +953,11 @@ acpi_ds_load2_end_op (
923 } 953 }
924 break; 954 break;
925 955
926
927 case AML_NAME_OP: 956 case AML_NAME_OP:
928 957
929 status = acpi_ds_create_node (walk_state, node, op); 958 status = acpi_ds_create_node(walk_state, node, op);
930 break; 959 break;
931#endif /* ACPI_NO_METHOD_EXECUTION */ 960#endif /* ACPI_NO_METHOD_EXECUTION */
932
933 961
934 default: 962 default:
935 /* All NAMED_COMPLEX opcodes must be handled above */ 963 /* All NAMED_COMPLEX opcodes must be handled above */
@@ -938,27 +966,29 @@ acpi_ds_load2_end_op (
938 } 966 }
939 break; 967 break;
940 968
941
942 case AML_CLASS_INTERNAL: 969 case AML_CLASS_INTERNAL:
943 970
944 /* case AML_INT_NAMEPATH_OP: */ 971 /* case AML_INT_NAMEPATH_OP: */
945 break; 972 break;
946 973
947
948 case AML_CLASS_METHOD_CALL: 974 case AML_CLASS_METHOD_CALL:
949 975
950 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 976 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
951 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n", 977 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
952 walk_state, op, node)); 978 walk_state, op, node));
953 979
954 /* 980 /*
955 * Lookup the method name and save the Node 981 * Lookup the method name and save the Node
956 */ 982 */
957 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 983 status =
958 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, 984 acpi_ns_lookup(walk_state->scope_info,
959 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 985 arg->common.value.string, ACPI_TYPE_ANY,
960 walk_state, &(new_node)); 986 ACPI_IMODE_LOAD_PASS2,
961 if (ACPI_SUCCESS (status)) { 987 ACPI_NS_SEARCH_PARENT |
988 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
989 &(new_node));
990 if (ACPI_SUCCESS(status)) {
991
962 /* 992 /*
963 * Make sure that what we found is indeed a method 993 * Make sure that what we found is indeed a method
964 * We didn't search for a method on purpose, to see if the name 994 * We didn't search for a method on purpose, to see if the name
@@ -973,24 +1003,20 @@ acpi_ds_load2_end_op (
973 * parser uses, so we can get it again at the end of this scope 1003 * parser uses, so we can get it again at the end of this scope
974 */ 1004 */
975 op->common.node = new_node; 1005 op->common.node = new_node;
976 } 1006 } else {
977 else { 1007 ACPI_REPORT_NSERROR(arg->common.value.string, status);
978 ACPI_REPORT_NSERROR (arg->common.value.string, status);
979 } 1008 }
980 break; 1009 break;
981 1010
982
983 default: 1011 default:
984 break; 1012 break;
985 } 1013 }
986 1014
987cleanup: 1015 cleanup:
988 1016
989 /* Remove the Node pushed at the very beginning */ 1017 /* Remove the Node pushed at the very beginning */
990 1018
991 walk_state->operands[0] = NULL; 1019 walk_state->operands[0] = NULL;
992 walk_state->num_operands = 0; 1020 walk_state->num_operands = 0;
993 return_ACPI_STATUS (status); 1021 return_ACPI_STATUS(status);
994} 1022}
995
996
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index 21f4548ff323..defe956ef751 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 45#include <acpi/acdispat.h>
47 46
48
49#define _COMPONENT ACPI_DISPATCHER 47#define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME ("dswscope") 48ACPI_MODULE_NAME("dswscope")
51
52 49
53/**************************************************************************** 50/****************************************************************************
54 * 51 *
@@ -62,15 +59,11 @@
62 * root scope object (which remains at the stack top.) 59 * root scope object (which remains at the stack top.)
63 * 60 *
64 ***************************************************************************/ 61 ***************************************************************************/
65 62void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state)
66void
67acpi_ds_scope_stack_clear (
68 struct acpi_walk_state *walk_state)
69{ 63{
70 union acpi_generic_state *scope_info; 64 union acpi_generic_state *scope_info;
71
72 ACPI_FUNCTION_NAME ("ds_scope_stack_clear");
73 65
66 ACPI_FUNCTION_NAME("ds_scope_stack_clear");
74 67
75 while (walk_state->scope_info) { 68 while (walk_state->scope_info) {
76 /* Pop a scope off the stack */ 69 /* Pop a scope off the stack */
@@ -78,14 +71,14 @@ acpi_ds_scope_stack_clear (
78 scope_info = walk_state->scope_info; 71 scope_info = walk_state->scope_info;
79 walk_state->scope_info = scope_info->scope.next; 72 walk_state->scope_info = scope_info->scope.next;
80 73
81 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 74 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
82 "Popped object type (%s)\n", 75 "Popped object type (%s)\n",
83 acpi_ut_get_type_name (scope_info->common.value))); 76 acpi_ut_get_type_name(scope_info->common.
84 acpi_ut_delete_generic_state (scope_info); 77 value)));
78 acpi_ut_delete_generic_state(scope_info);
85 } 79 }
86} 80}
87 81
88
89/**************************************************************************** 82/****************************************************************************
90 * 83 *
91 * FUNCTION: acpi_ds_scope_stack_push 84 * FUNCTION: acpi_ds_scope_stack_push
@@ -102,74 +95,70 @@ acpi_ds_scope_stack_clear (
102 ***************************************************************************/ 95 ***************************************************************************/
103 96
104acpi_status 97acpi_status
105acpi_ds_scope_stack_push ( 98acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
106 struct acpi_namespace_node *node, 99 acpi_object_type type,
107 acpi_object_type type, 100 struct acpi_walk_state *walk_state)
108 struct acpi_walk_state *walk_state)
109{ 101{
110 union acpi_generic_state *scope_info; 102 union acpi_generic_state *scope_info;
111 union acpi_generic_state *old_scope_info; 103 union acpi_generic_state *old_scope_info;
112
113
114 ACPI_FUNCTION_TRACE ("ds_scope_stack_push");
115 104
105 ACPI_FUNCTION_TRACE("ds_scope_stack_push");
116 106
117 if (!node) { 107 if (!node) {
118 /* Invalid scope */ 108 /* Invalid scope */
119 109
120 ACPI_REPORT_ERROR (("ds_scope_stack_push: null scope passed\n")); 110 ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n"));
121 return_ACPI_STATUS (AE_BAD_PARAMETER); 111 return_ACPI_STATUS(AE_BAD_PARAMETER);
122 } 112 }
123 113
124 /* Make sure object type is valid */ 114 /* Make sure object type is valid */
125 115
126 if (!acpi_ut_valid_object_type (type)) { 116 if (!acpi_ut_valid_object_type(type)) {
127 ACPI_REPORT_WARNING (( 117 ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type));
128 "ds_scope_stack_push: Invalid object type: 0x%X\n", type));
129 } 118 }
130 119
131 /* Allocate a new scope object */ 120 /* Allocate a new scope object */
132 121
133 scope_info = acpi_ut_create_generic_state (); 122 scope_info = acpi_ut_create_generic_state();
134 if (!scope_info) { 123 if (!scope_info) {
135 return_ACPI_STATUS (AE_NO_MEMORY); 124 return_ACPI_STATUS(AE_NO_MEMORY);
136 } 125 }
137 126
138 /* Init new scope object */ 127 /* Init new scope object */
139 128
140 scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE; 129 scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE;
141 scope_info->scope.node = node; 130 scope_info->scope.node = node;
142 scope_info->common.value = (u16) type; 131 scope_info->common.value = (u16) type;
143 132
144 walk_state->scope_depth++; 133 walk_state->scope_depth++;
145 134
146 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 135 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
147 "[%.2d] Pushed scope ", (u32) walk_state->scope_depth)); 136 "[%.2d] Pushed scope ",
137 (u32) walk_state->scope_depth));
148 138
149 old_scope_info = walk_state->scope_info; 139 old_scope_info = walk_state->scope_info;
150 if (old_scope_info) { 140 if (old_scope_info) {
151 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, 141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
152 "[%4.4s] (%s)", 142 "[%4.4s] (%s)",
153 acpi_ut_get_node_name (old_scope_info->scope.node), 143 acpi_ut_get_node_name(old_scope_info->
154 acpi_ut_get_type_name (old_scope_info->common.value))); 144 scope.node),
155 } 145 acpi_ut_get_type_name(old_scope_info->
156 else { 146 common.value)));
157 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, 147 } else {
158 "[\\___] (%s)", "ROOT")); 148 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT"));
159 } 149 }
160 150
161 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, 151 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
162 ", New scope -> [%4.4s] (%s)\n", 152 ", New scope -> [%4.4s] (%s)\n",
163 acpi_ut_get_node_name (scope_info->scope.node), 153 acpi_ut_get_node_name(scope_info->scope.node),
164 acpi_ut_get_type_name (scope_info->common.value))); 154 acpi_ut_get_type_name(scope_info->common.value)));
165 155
166 /* Push new scope object onto stack */ 156 /* Push new scope object onto stack */
167 157
168 acpi_ut_push_generic_state (&walk_state->scope_info, scope_info); 158 acpi_ut_push_generic_state(&walk_state->scope_info, scope_info);
169 return_ACPI_STATUS (AE_OK); 159 return_ACPI_STATUS(AE_OK);
170} 160}
171 161
172
173/**************************************************************************** 162/****************************************************************************
174 * 163 *
175 * FUNCTION: acpi_ds_scope_stack_pop 164 * FUNCTION: acpi_ds_scope_stack_pop
@@ -182,47 +171,41 @@ acpi_ds_scope_stack_push (
182 * 171 *
183 ***************************************************************************/ 172 ***************************************************************************/
184 173
185acpi_status 174acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state)
186acpi_ds_scope_stack_pop (
187 struct acpi_walk_state *walk_state)
188{ 175{
189 union acpi_generic_state *scope_info; 176 union acpi_generic_state *scope_info;
190 union acpi_generic_state *new_scope_info; 177 union acpi_generic_state *new_scope_info;
191
192
193 ACPI_FUNCTION_TRACE ("ds_scope_stack_pop");
194 178
179 ACPI_FUNCTION_TRACE("ds_scope_stack_pop");
195 180
196 /* 181 /*
197 * Pop scope info object off the stack. 182 * Pop scope info object off the stack.
198 */ 183 */
199 scope_info = acpi_ut_pop_generic_state (&walk_state->scope_info); 184 scope_info = acpi_ut_pop_generic_state(&walk_state->scope_info);
200 if (!scope_info) { 185 if (!scope_info) {
201 return_ACPI_STATUS (AE_STACK_UNDERFLOW); 186 return_ACPI_STATUS(AE_STACK_UNDERFLOW);
202 } 187 }
203 188
204 walk_state->scope_depth--; 189 walk_state->scope_depth--;
205 190
206 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 191 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
207 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", 192 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
208 (u32) walk_state->scope_depth, 193 (u32) walk_state->scope_depth,
209 acpi_ut_get_node_name (scope_info->scope.node), 194 acpi_ut_get_node_name(scope_info->scope.node),
210 acpi_ut_get_type_name (scope_info->common.value))); 195 acpi_ut_get_type_name(scope_info->common.value)));
211 196
212 new_scope_info = walk_state->scope_info; 197 new_scope_info = walk_state->scope_info;
213 if (new_scope_info) { 198 if (new_scope_info) {
214 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, 199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
215 "[%4.4s] (%s)\n", 200 "[%4.4s] (%s)\n",
216 acpi_ut_get_node_name (new_scope_info->scope.node), 201 acpi_ut_get_node_name(new_scope_info->
217 acpi_ut_get_type_name (new_scope_info->common.value))); 202 scope.node),
218 } 203 acpi_ut_get_type_name(new_scope_info->
219 else { 204 common.value)));
220 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, 205 } else {
221 "[\\___] (ROOT)\n")); 206 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (ROOT)\n"));
222 } 207 }
223 208
224 acpi_ut_delete_generic_state (scope_info); 209 acpi_ut_delete_generic_state(scope_info);
225 return_ACPI_STATUS (AE_OK); 210 return_ACPI_STATUS(AE_OK);
226} 211}
227
228
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index 9cd3db652b31..7d68a5aaf3c4 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -41,37 +41,28 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_DISPATCHER 49#define _COMPONENT ACPI_DISPATCHER
51 ACPI_MODULE_NAME ("dswstate") 50ACPI_MODULE_NAME("dswstate")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55#ifdef ACPI_OBSOLETE_FUNCTIONS 53#ifdef ACPI_OBSOLETE_FUNCTIONS
56acpi_status 54acpi_status
57acpi_ds_result_insert ( 55acpi_ds_result_insert(void *object,
58 void *object, 56 u32 index, struct acpi_walk_state *walk_state);
59 u32 index,
60 struct acpi_walk_state *walk_state);
61 57
62acpi_status 58acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state *walk_state);
63acpi_ds_obj_stack_delete_all (
64 struct acpi_walk_state *walk_state);
65 59
66acpi_status 60acpi_status
67acpi_ds_obj_stack_pop_object ( 61acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
68 union acpi_operand_object **object, 62 struct acpi_walk_state *walk_state);
69 struct acpi_walk_state *walk_state); 63
70 64void *acpi_ds_obj_stack_get_value(u32 index,
71void * 65 struct acpi_walk_state *walk_state);
72acpi_ds_obj_stack_get_value (
73 u32 index,
74 struct acpi_walk_state *walk_state);
75#endif 66#endif
76 67
77#ifdef ACPI_FUTURE_USAGE 68#ifdef ACPI_FUTURE_USAGE
@@ -92,36 +83,35 @@ acpi_ds_obj_stack_get_value (
92 ******************************************************************************/ 83 ******************************************************************************/
93 84
94acpi_status 85acpi_status
95acpi_ds_result_remove ( 86acpi_ds_result_remove(union acpi_operand_object **object,
96 union acpi_operand_object **object, 87 u32 index, struct acpi_walk_state *walk_state)
97 u32 index,
98 struct acpi_walk_state *walk_state)
99{ 88{
100 union acpi_generic_state *state; 89 union acpi_generic_state *state;
101
102
103 ACPI_FUNCTION_NAME ("ds_result_remove");
104 90
91 ACPI_FUNCTION_NAME("ds_result_remove");
105 92
106 state = walk_state->results; 93 state = walk_state->results;
107 if (!state) { 94 if (!state) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", 95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
109 walk_state)); 96 "No result object pushed! State=%p\n",
97 walk_state));
110 return (AE_NOT_EXIST); 98 return (AE_NOT_EXIST);
111 } 99 }
112 100
113 if (index >= ACPI_OBJ_MAX_OPERAND) { 101 if (index >= ACPI_OBJ_MAX_OPERAND) {
114 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 102 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
115 "Index out of range: %X State=%p Num=%X\n", 103 "Index out of range: %X State=%p Num=%X\n",
116 index, walk_state, state->results.num_results)); 104 index, walk_state,
105 state->results.num_results));
117 } 106 }
118 107
119 /* Check for a valid result object */ 108 /* Check for a valid result object */
120 109
121 if (!state->results.obj_desc [index]) { 110 if (!state->results.obj_desc[index]) {
122 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 111 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
123 "Null operand! State=%p #Ops=%X, Index=%X\n", 112 "Null operand! State=%p #Ops=%X, Index=%X\n",
124 walk_state, state->results.num_results, index)); 113 walk_state, state->results.num_results,
114 index));
125 return (AE_AML_NO_RETURN_VALUE); 115 return (AE_AML_NO_RETURN_VALUE);
126 } 116 }
127 117
@@ -129,18 +119,20 @@ acpi_ds_result_remove (
129 119
130 state->results.num_results--; 120 state->results.num_results--;
131 121
132 *object = state->results.obj_desc [index]; 122 *object = state->results.obj_desc[index];
133 state->results.obj_desc [index] = NULL; 123 state->results.obj_desc[index] = NULL;
134 124
135 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 125 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
136 "Obj=%p [%s] Index=%X State=%p Num=%X\n", 126 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
137 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", 127 *object,
138 index, walk_state, state->results.num_results)); 128 (*object) ? acpi_ut_get_object_type_name(*object) :
129 "NULL", index, walk_state,
130 state->results.num_results));
139 131
140 return (AE_OK); 132 return (AE_OK);
141} 133}
142 134
143#endif /* ACPI_FUTURE_USAGE */ 135#endif /* ACPI_FUTURE_USAGE */
144 136
145/******************************************************************************* 137/*******************************************************************************
146 * 138 *
@@ -157,16 +149,13 @@ acpi_ds_result_remove (
157 ******************************************************************************/ 149 ******************************************************************************/
158 150
159acpi_status 151acpi_status
160acpi_ds_result_pop ( 152acpi_ds_result_pop(union acpi_operand_object ** object,
161 union acpi_operand_object **object, 153 struct acpi_walk_state * walk_state)
162 struct acpi_walk_state *walk_state)
163{ 154{
164 acpi_native_uint index; 155 acpi_native_uint index;
165 union acpi_generic_state *state; 156 union acpi_generic_state *state;
166
167
168 ACPI_FUNCTION_NAME ("ds_result_pop");
169 157
158 ACPI_FUNCTION_NAME("ds_result_pop");
170 159
171 state = walk_state->results; 160 state = walk_state->results;
172 if (!state) { 161 if (!state) {
@@ -174,8 +163,9 @@ acpi_ds_result_pop (
174 } 163 }
175 164
176 if (!state->results.num_results) { 165 if (!state->results.num_results) {
177 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", 166 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
178 walk_state)); 167 "Result stack is empty! State=%p\n",
168 walk_state));
179 return (AE_AML_NO_RETURN_VALUE); 169 return (AE_AML_NO_RETURN_VALUE);
180 } 170 }
181 171
@@ -186,26 +176,27 @@ acpi_ds_result_pop (
186 for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) { 176 for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) {
187 /* Check for a valid result object */ 177 /* Check for a valid result object */
188 178
189 if (state->results.obj_desc [index -1]) { 179 if (state->results.obj_desc[index - 1]) {
190 *object = state->results.obj_desc [index -1]; 180 *object = state->results.obj_desc[index - 1];
191 state->results.obj_desc [index -1] = NULL; 181 state->results.obj_desc[index - 1] = NULL;
192 182
193 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 183 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
194 "Obj=%p [%s] Index=%X State=%p Num=%X\n", 184 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
195 *object, 185 *object,
196 (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", 186 (*object) ?
197 (u32) index -1, walk_state, state->results.num_results)); 187 acpi_ut_get_object_type_name(*object)
188 : "NULL", (u32) index - 1, walk_state,
189 state->results.num_results));
198 190
199 return (AE_OK); 191 return (AE_OK);
200 } 192 }
201 } 193 }
202 194
203 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 195 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
204 "No result objects! State=%p\n", walk_state)); 196 "No result objects! State=%p\n", walk_state));
205 return (AE_AML_NO_RETURN_VALUE); 197 return (AE_AML_NO_RETURN_VALUE);
206} 198}
207 199
208
209/******************************************************************************* 200/*******************************************************************************
210 * 201 *
211 * FUNCTION: acpi_ds_result_pop_from_bottom 202 * FUNCTION: acpi_ds_result_pop_from_bottom
@@ -221,38 +212,37 @@ acpi_ds_result_pop (
221 ******************************************************************************/ 212 ******************************************************************************/
222 213
223acpi_status 214acpi_status
224acpi_ds_result_pop_from_bottom ( 215acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
225 union acpi_operand_object **object, 216 struct acpi_walk_state * walk_state)
226 struct acpi_walk_state *walk_state)
227{ 217{
228 acpi_native_uint index; 218 acpi_native_uint index;
229 union acpi_generic_state *state; 219 union acpi_generic_state *state;
230
231
232 ACPI_FUNCTION_NAME ("ds_result_pop_from_bottom");
233 220
221 ACPI_FUNCTION_NAME("ds_result_pop_from_bottom");
234 222
235 state = walk_state->results; 223 state = walk_state->results;
236 if (!state) { 224 if (!state) {
237 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 225 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
238 "Warning: No result object pushed! State=%p\n", walk_state)); 226 "Warning: No result object pushed! State=%p\n",
227 walk_state));
239 return (AE_NOT_EXIST); 228 return (AE_NOT_EXIST);
240 } 229 }
241 230
242 if (!state->results.num_results) { 231 if (!state->results.num_results) {
243 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", 232 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
244 walk_state)); 233 "No result objects! State=%p\n", walk_state));
245 return (AE_AML_NO_RETURN_VALUE); 234 return (AE_AML_NO_RETURN_VALUE);
246 } 235 }
247 236
248 /* Remove Bottom element */ 237 /* Remove Bottom element */
249 238
250 *object = state->results.obj_desc [0]; 239 *object = state->results.obj_desc[0];
251 240
252 /* Push entire stack down one element */ 241 /* Push entire stack down one element */
253 242
254 for (index = 0; index < state->results.num_results; index++) { 243 for (index = 0; index < state->results.num_results; index++) {
255 state->results.obj_desc [index] = state->results.obj_desc [index + 1]; 244 state->results.obj_desc[index] =
245 state->results.obj_desc[index + 1];
256 } 246 }
257 247
258 state->results.num_results--; 248 state->results.num_results--;
@@ -260,20 +250,21 @@ acpi_ds_result_pop_from_bottom (
260 /* Check for a valid result object */ 250 /* Check for a valid result object */
261 251
262 if (!*object) { 252 if (!*object) {
263 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
264 "Null operand! State=%p #Ops=%X, Index=%X\n", 254 "Null operand! State=%p #Ops=%X Index=%X\n",
265 walk_state, state->results.num_results, (u32) index)); 255 walk_state, state->results.num_results,
256 (u32) index));
266 return (AE_AML_NO_RETURN_VALUE); 257 return (AE_AML_NO_RETURN_VALUE);
267 } 258 }
268 259
269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", 260 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n",
270 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", 261 *object,
271 state, walk_state)); 262 (*object) ? acpi_ut_get_object_type_name(*object) :
263 "NULL", state, walk_state));
272 264
273 return (AE_OK); 265 return (AE_OK);
274} 266}
275 267
276
277/******************************************************************************* 268/*******************************************************************************
278 * 269 *
279 * FUNCTION: acpi_ds_result_push 270 * FUNCTION: acpi_ds_result_push
@@ -288,47 +279,50 @@ acpi_ds_result_pop_from_bottom (
288 ******************************************************************************/ 279 ******************************************************************************/
289 280
290acpi_status 281acpi_status
291acpi_ds_result_push ( 282acpi_ds_result_push(union acpi_operand_object * object,
292 union acpi_operand_object *object, 283 struct acpi_walk_state * walk_state)
293 struct acpi_walk_state *walk_state)
294{ 284{
295 union acpi_generic_state *state; 285 union acpi_generic_state *state;
296
297
298 ACPI_FUNCTION_NAME ("ds_result_push");
299 286
287 ACPI_FUNCTION_NAME("ds_result_push");
300 288
301 state = walk_state->results; 289 state = walk_state->results;
302 if (!state) { 290 if (!state) {
303 ACPI_REPORT_ERROR (("No result stack frame during push\n")); 291 ACPI_REPORT_ERROR(("No result stack frame during push\n"));
304 return (AE_AML_INTERNAL); 292 return (AE_AML_INTERNAL);
305 } 293 }
306 294
307 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { 295 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
308 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
309 "Result stack overflow: Obj=%p State=%p Num=%X\n", 297 "Result stack overflow: Obj=%p State=%p Num=%X\n",
310 object, walk_state, state->results.num_results)); 298 object, walk_state,
299 state->results.num_results));
311 return (AE_STACK_OVERFLOW); 300 return (AE_STACK_OVERFLOW);
312 } 301 }
313 302
314 if (!object) { 303 if (!object) {
315 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
316 "Null Object! Obj=%p State=%p Num=%X\n", 305 "Null Object! Obj=%p State=%p Num=%X\n",
317 object, walk_state, state->results.num_results)); 306 object, walk_state,
307 state->results.num_results));
318 return (AE_BAD_PARAMETER); 308 return (AE_BAD_PARAMETER);
319 } 309 }
320 310
321 state->results.obj_desc [state->results.num_results] = object; 311 state->results.obj_desc[state->results.num_results] = object;
322 state->results.num_results++; 312 state->results.num_results++;
323 313
324 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 314 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
325 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", 315 object,
326 walk_state, state->results.num_results, walk_state->current_result)); 316 object ?
317 acpi_ut_get_object_type_name((union
318 acpi_operand_object *)
319 object) : "NULL",
320 walk_state, state->results.num_results,
321 walk_state->current_result));
327 322
328 return (AE_OK); 323 return (AE_OK);
329} 324}
330 325
331
332/******************************************************************************* 326/*******************************************************************************
333 * 327 *
334 * FUNCTION: acpi_ds_result_stack_push 328 * FUNCTION: acpi_ds_result_stack_push
@@ -341,30 +335,26 @@ acpi_ds_result_push (
341 * 335 *
342 ******************************************************************************/ 336 ******************************************************************************/
343 337
344acpi_status 338acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
345acpi_ds_result_stack_push (
346 struct acpi_walk_state *walk_state)
347{ 339{
348 union acpi_generic_state *state; 340 union acpi_generic_state *state;
349
350 ACPI_FUNCTION_NAME ("ds_result_stack_push");
351 341
342 ACPI_FUNCTION_NAME("ds_result_stack_push");
352 343
353 state = acpi_ut_create_generic_state (); 344 state = acpi_ut_create_generic_state();
354 if (!state) { 345 if (!state) {
355 return (AE_NO_MEMORY); 346 return (AE_NO_MEMORY);
356 } 347 }
357 348
358 state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; 349 state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT;
359 acpi_ut_push_generic_state (&walk_state->results, state); 350 acpi_ut_push_generic_state(&walk_state->results, state);
360 351
361 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", 352 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
362 state, walk_state)); 353 state, walk_state));
363 354
364 return (AE_OK); 355 return (AE_OK);
365} 356}
366 357
367
368/******************************************************************************* 358/*******************************************************************************
369 * 359 *
370 * FUNCTION: acpi_ds_result_stack_pop 360 * FUNCTION: acpi_ds_result_stack_pop
@@ -377,35 +367,31 @@ acpi_ds_result_stack_push (
377 * 367 *
378 ******************************************************************************/ 368 ******************************************************************************/
379 369
380acpi_status 370acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
381acpi_ds_result_stack_pop (
382 struct acpi_walk_state *walk_state)
383{ 371{
384 union acpi_generic_state *state; 372 union acpi_generic_state *state;
385
386 ACPI_FUNCTION_NAME ("ds_result_stack_pop");
387 373
374 ACPI_FUNCTION_NAME("ds_result_stack_pop");
388 375
389 /* Check for stack underflow */ 376 /* Check for stack underflow */
390 377
391 if (walk_state->results == NULL) { 378 if (walk_state->results == NULL) {
392 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", 379 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Underflow - State=%p\n",
393 walk_state)); 380 walk_state));
394 return (AE_AML_NO_OPERAND); 381 return (AE_AML_NO_OPERAND);
395 } 382 }
396 383
397 state = acpi_ut_pop_generic_state (&walk_state->results); 384 state = acpi_ut_pop_generic_state(&walk_state->results);
398 385
399 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 386 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
400 "Result=%p remaining_results=%X State=%p\n", 387 "Result=%p remaining_results=%X State=%p\n",
401 state, state->results.num_results, walk_state)); 388 state, state->results.num_results, walk_state));
402 389
403 acpi_ut_delete_generic_state (state); 390 acpi_ut_delete_generic_state(state);
404 391
405 return (AE_OK); 392 return (AE_OK);
406} 393}
407 394
408
409/******************************************************************************* 395/*******************************************************************************
410 * 396 *
411 * FUNCTION: acpi_ds_obj_stack_push 397 * FUNCTION: acpi_ds_obj_stack_push
@@ -420,35 +406,35 @@ acpi_ds_result_stack_pop (
420 ******************************************************************************/ 406 ******************************************************************************/
421 407
422acpi_status 408acpi_status
423acpi_ds_obj_stack_push ( 409acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
424 void *object,
425 struct acpi_walk_state *walk_state)
426{ 410{
427 ACPI_FUNCTION_NAME ("ds_obj_stack_push"); 411 ACPI_FUNCTION_NAME("ds_obj_stack_push");
428
429 412
430 /* Check for stack overflow */ 413 /* Check for stack overflow */
431 414
432 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { 415 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
433 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
434 "overflow! Obj=%p State=%p #Ops=%X\n", 417 "overflow! Obj=%p State=%p #Ops=%X\n",
435 object, walk_state, walk_state->num_operands)); 418 object, walk_state,
419 walk_state->num_operands));
436 return (AE_STACK_OVERFLOW); 420 return (AE_STACK_OVERFLOW);
437 } 421 }
438 422
439 /* Put the object onto the stack */ 423 /* Put the object onto the stack */
440 424
441 walk_state->operands [walk_state->num_operands] = object; 425 walk_state->operands[walk_state->num_operands] = object;
442 walk_state->num_operands++; 426 walk_state->num_operands++;
443 427
444 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", 428 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
445 object, acpi_ut_get_object_type_name ((union acpi_operand_object *) object), 429 object,
446 walk_state, walk_state->num_operands)); 430 acpi_ut_get_object_type_name((union
431 acpi_operand_object *)
432 object), walk_state,
433 walk_state->num_operands));
447 434
448 return (AE_OK); 435 return (AE_OK);
449} 436}
450 437
451
452/******************************************************************************* 438/*******************************************************************************
453 * 439 *
454 * FUNCTION: acpi_ds_obj_stack_pop 440 * FUNCTION: acpi_ds_obj_stack_pop
@@ -464,38 +450,35 @@ acpi_ds_obj_stack_push (
464 ******************************************************************************/ 450 ******************************************************************************/
465 451
466acpi_status 452acpi_status
467acpi_ds_obj_stack_pop ( 453acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
468 u32 pop_count,
469 struct acpi_walk_state *walk_state)
470{ 454{
471 u32 i; 455 u32 i;
472
473 ACPI_FUNCTION_NAME ("ds_obj_stack_pop");
474 456
457 ACPI_FUNCTION_NAME("ds_obj_stack_pop");
475 458
476 for (i = 0; i < pop_count; i++) { 459 for (i = 0; i < pop_count; i++) {
477 /* Check for stack underflow */ 460 /* Check for stack underflow */
478 461
479 if (walk_state->num_operands == 0) { 462 if (walk_state->num_operands == 0) {
480 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
481 "Underflow! Count=%X State=%p #Ops=%X\n", 464 "Underflow! Count=%X State=%p #Ops=%X\n",
482 pop_count, walk_state, walk_state->num_operands)); 465 pop_count, walk_state,
466 walk_state->num_operands));
483 return (AE_STACK_UNDERFLOW); 467 return (AE_STACK_UNDERFLOW);
484 } 468 }
485 469
486 /* Just set the stack entry to null */ 470 /* Just set the stack entry to null */
487 471
488 walk_state->num_operands--; 472 walk_state->num_operands--;
489 walk_state->operands [walk_state->num_operands] = NULL; 473 walk_state->operands[walk_state->num_operands] = NULL;
490 } 474 }
491 475
492 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", 476 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
493 pop_count, walk_state, walk_state->num_operands)); 477 pop_count, walk_state, walk_state->num_operands));
494 478
495 return (AE_OK); 479 return (AE_OK);
496} 480}
497 481
498
499/******************************************************************************* 482/*******************************************************************************
500 * 483 *
501 * FUNCTION: acpi_ds_obj_stack_pop_and_delete 484 * FUNCTION: acpi_ds_obj_stack_pop_and_delete
@@ -511,44 +494,43 @@ acpi_ds_obj_stack_pop (
511 ******************************************************************************/ 494 ******************************************************************************/
512 495
513acpi_status 496acpi_status
514acpi_ds_obj_stack_pop_and_delete ( 497acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
515 u32 pop_count, 498 struct acpi_walk_state * walk_state)
516 struct acpi_walk_state *walk_state)
517{ 499{
518 u32 i; 500 u32 i;
519 union acpi_operand_object *obj_desc; 501 union acpi_operand_object *obj_desc;
520
521
522 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete");
523 502
503 ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete");
524 504
525 for (i = 0; i < pop_count; i++) { 505 for (i = 0; i < pop_count; i++) {
526 /* Check for stack underflow */ 506 /* Check for stack underflow */
527 507
528 if (walk_state->num_operands == 0) { 508 if (walk_state->num_operands == 0) {
529 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 509 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
530 "Underflow! Count=%X State=%p #Ops=%X\n", 510 "Underflow! Count=%X State=%p #Ops=%X\n",
531 pop_count, walk_state, walk_state->num_operands)); 511 pop_count, walk_state,
512 walk_state->num_operands));
532 return (AE_STACK_UNDERFLOW); 513 return (AE_STACK_UNDERFLOW);
533 } 514 }
534 515
535 /* Pop the stack and delete an object if present in this stack entry */ 516 /* Pop the stack and delete an object if present in this stack entry */
536 517
537 walk_state->num_operands--; 518 walk_state->num_operands--;
538 obj_desc = walk_state->operands [walk_state->num_operands]; 519 obj_desc = walk_state->operands[walk_state->num_operands];
539 if (obj_desc) { 520 if (obj_desc) {
540 acpi_ut_remove_reference (walk_state->operands [walk_state->num_operands]); 521 acpi_ut_remove_reference(walk_state->
541 walk_state->operands [walk_state->num_operands] = NULL; 522 operands[walk_state->
523 num_operands]);
524 walk_state->operands[walk_state->num_operands] = NULL;
542 } 525 }
543 } 526 }
544 527
545 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", 528 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
546 pop_count, walk_state, walk_state->num_operands)); 529 pop_count, walk_state, walk_state->num_operands));
547 530
548 return (AE_OK); 531 return (AE_OK);
549} 532}
550 533
551
552/******************************************************************************* 534/*******************************************************************************
553 * 535 *
554 * FUNCTION: acpi_ds_get_current_walk_state 536 * FUNCTION: acpi_ds_get_current_walk_state
@@ -562,25 +544,21 @@ acpi_ds_obj_stack_pop_and_delete (
562 * 544 *
563 ******************************************************************************/ 545 ******************************************************************************/
564 546
565struct acpi_walk_state * 547struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
566acpi_ds_get_current_walk_state ( 548 *thread)
567 struct acpi_thread_state *thread)
568
569{ 549{
570 ACPI_FUNCTION_NAME ("ds_get_current_walk_state"); 550 ACPI_FUNCTION_NAME("ds_get_current_walk_state");
571
572 551
573 if (!thread) { 552 if (!thread) {
574 return (NULL); 553 return (NULL);
575 } 554 }
576 555
577 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current walk_state %p\n", 556 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n",
578 thread->walk_state_list)); 557 thread->walk_state_list));
579 558
580 return (thread->walk_state_list); 559 return (thread->walk_state_list);
581} 560}
582 561
583
584/******************************************************************************* 562/*******************************************************************************
585 * 563 *
586 * FUNCTION: acpi_ds_push_walk_state 564 * FUNCTION: acpi_ds_push_walk_state
@@ -595,20 +573,17 @@ acpi_ds_get_current_walk_state (
595 ******************************************************************************/ 573 ******************************************************************************/
596 574
597void 575void
598acpi_ds_push_walk_state ( 576acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
599 struct acpi_walk_state *walk_state, 577 struct acpi_thread_state *thread)
600 struct acpi_thread_state *thread)
601{ 578{
602 ACPI_FUNCTION_TRACE ("ds_push_walk_state"); 579 ACPI_FUNCTION_TRACE("ds_push_walk_state");
603
604 580
605 walk_state->next = thread->walk_state_list; 581 walk_state->next = thread->walk_state_list;
606 thread->walk_state_list = walk_state; 582 thread->walk_state_list = walk_state;
607 583
608 return_VOID; 584 return_VOID;
609} 585}
610 586
611
612/******************************************************************************* 587/*******************************************************************************
613 * 588 *
614 * FUNCTION: acpi_ds_pop_walk_state 589 * FUNCTION: acpi_ds_pop_walk_state
@@ -623,15 +598,11 @@ acpi_ds_push_walk_state (
623 * 598 *
624 ******************************************************************************/ 599 ******************************************************************************/
625 600
626struct acpi_walk_state * 601struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
627acpi_ds_pop_walk_state (
628 struct acpi_thread_state *thread)
629{ 602{
630 struct acpi_walk_state *walk_state; 603 struct acpi_walk_state *walk_state;
631
632
633 ACPI_FUNCTION_TRACE ("ds_pop_walk_state");
634 604
605 ACPI_FUNCTION_TRACE("ds_pop_walk_state");
635 606
636 walk_state = thread->walk_state_list; 607 walk_state = thread->walk_state_list;
637 608
@@ -647,10 +618,9 @@ acpi_ds_pop_walk_state (
647 */ 618 */
648 } 619 }
649 620
650 return_PTR (walk_state); 621 return_PTR(walk_state);
651} 622}
652 623
653
654/******************************************************************************* 624/*******************************************************************************
655 * 625 *
656 * FUNCTION: acpi_ds_create_walk_state 626 * FUNCTION: acpi_ds_create_walk_state
@@ -667,57 +637,55 @@ acpi_ds_pop_walk_state (
667 * 637 *
668 ******************************************************************************/ 638 ******************************************************************************/
669 639
670struct acpi_walk_state * 640struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
671acpi_ds_create_walk_state ( 641 union acpi_parse_object
672 acpi_owner_id owner_id, 642 *origin,
673 union acpi_parse_object *origin, 643 union acpi_operand_object
674 union acpi_operand_object *mth_desc, 644 *mth_desc,
675 struct acpi_thread_state *thread) 645 struct acpi_thread_state
646 *thread)
676{ 647{
677 struct acpi_walk_state *walk_state; 648 struct acpi_walk_state *walk_state;
678 acpi_status status; 649 acpi_status status;
679
680 650
681 ACPI_FUNCTION_TRACE ("ds_create_walk_state"); 651 ACPI_FUNCTION_TRACE("ds_create_walk_state");
682 652
683 653 walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state));
684 walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK);
685 if (!walk_state) { 654 if (!walk_state) {
686 return_PTR (NULL); 655 return_PTR(NULL);
687 } 656 }
688 657
689 walk_state->data_type = ACPI_DESC_TYPE_WALK; 658 walk_state->data_type = ACPI_DESC_TYPE_WALK;
690 walk_state->owner_id = owner_id; 659 walk_state->owner_id = owner_id;
691 walk_state->origin = origin; 660 walk_state->origin = origin;
692 walk_state->method_desc = mth_desc; 661 walk_state->method_desc = mth_desc;
693 walk_state->thread = thread; 662 walk_state->thread = thread;
694 663
695 walk_state->parser_state.start_op = origin; 664 walk_state->parser_state.start_op = origin;
696 665
697 /* Init the method args/local */ 666 /* Init the method args/local */
698 667
699#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 668#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
700 acpi_ds_method_data_init (walk_state); 669 acpi_ds_method_data_init(walk_state);
701#endif 670#endif
702 671
703 /* Create an initial result stack entry */ 672 /* Create an initial result stack entry */
704 673
705 status = acpi_ds_result_stack_push (walk_state); 674 status = acpi_ds_result_stack_push(walk_state);
706 if (ACPI_FAILURE (status)) { 675 if (ACPI_FAILURE(status)) {
707 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); 676 ACPI_MEM_FREE(walk_state);
708 return_PTR (NULL); 677 return_PTR(NULL);
709 } 678 }
710 679
711 /* Put the new state at the head of the walk list */ 680 /* Put the new state at the head of the walk list */
712 681
713 if (thread) { 682 if (thread) {
714 acpi_ds_push_walk_state (walk_state, thread); 683 acpi_ds_push_walk_state(walk_state, thread);
715 } 684 }
716 685
717 return_PTR (walk_state); 686 return_PTR(walk_state);
718} 687}
719 688
720
721/******************************************************************************* 689/*******************************************************************************
722 * 690 *
723 * FUNCTION: acpi_ds_init_aml_walk 691 * FUNCTION: acpi_ds_init_aml_walk
@@ -737,70 +705,70 @@ acpi_ds_create_walk_state (
737 ******************************************************************************/ 705 ******************************************************************************/
738 706
739acpi_status 707acpi_status
740acpi_ds_init_aml_walk ( 708acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
741 struct acpi_walk_state *walk_state, 709 union acpi_parse_object *op,
742 union acpi_parse_object *op, 710 struct acpi_namespace_node *method_node,
743 struct acpi_namespace_node *method_node, 711 u8 * aml_start,
744 u8 *aml_start, 712 u32 aml_length,
745 u32 aml_length, 713 struct acpi_parameter_info *info, u8 pass_number)
746 struct acpi_parameter_info *info,
747 u32 pass_number)
748{ 714{
749 acpi_status status; 715 acpi_status status;
750 struct acpi_parse_state *parser_state = &walk_state->parser_state; 716 struct acpi_parse_state *parser_state = &walk_state->parser_state;
751 union acpi_parse_object *extra_op; 717 union acpi_parse_object *extra_op;
752 718
719 ACPI_FUNCTION_TRACE("ds_init_aml_walk");
753 720
754 ACPI_FUNCTION_TRACE ("ds_init_aml_walk"); 721 walk_state->parser_state.aml =
755 722 walk_state->parser_state.aml_start = aml_start;
756
757 walk_state->parser_state.aml =
758 walk_state->parser_state.aml_start = aml_start;
759 walk_state->parser_state.aml_end = 723 walk_state->parser_state.aml_end =
760 walk_state->parser_state.pkg_end = aml_start + aml_length; 724 walk_state->parser_state.pkg_end = aml_start + aml_length;
761 725
762 /* The next_op of the next_walk will be the beginning of the method */ 726 /* The next_op of the next_walk will be the beginning of the method */
763 727
764 walk_state->next_op = NULL; 728 walk_state->next_op = NULL;
729 walk_state->pass_number = pass_number;
765 730
766 if (info) { 731 if (info) {
767 if (info->parameter_type == ACPI_PARAM_GPE) { 732 if (info->parameter_type == ACPI_PARAM_GPE) {
768 walk_state->gpe_event_info = ACPI_CAST_PTR (struct acpi_gpe_event_info, 733 walk_state->gpe_event_info =
769 info->parameters); 734 ACPI_CAST_PTR(struct acpi_gpe_event_info,
770 } 735 info->parameters);
771 else { 736 } else {
772 walk_state->params = info->parameters; 737 walk_state->params = info->parameters;
773 walk_state->caller_return_desc = &info->return_object; 738 walk_state->caller_return_desc = &info->return_object;
774 } 739 }
775 } 740 }
776 741
777 status = acpi_ps_init_scope (&walk_state->parser_state, op); 742 status = acpi_ps_init_scope(&walk_state->parser_state, op);
778 if (ACPI_FAILURE (status)) { 743 if (ACPI_FAILURE(status)) {
779 return_ACPI_STATUS (status); 744 return_ACPI_STATUS(status);
780 } 745 }
781 746
782 if (method_node) { 747 if (method_node) {
783 walk_state->parser_state.start_node = method_node; 748 walk_state->parser_state.start_node = method_node;
784 walk_state->walk_type = ACPI_WALK_METHOD; 749 walk_state->walk_type = ACPI_WALK_METHOD;
785 walk_state->method_node = method_node; 750 walk_state->method_node = method_node;
786 walk_state->method_desc = acpi_ns_get_attached_object (method_node); 751 walk_state->method_desc =
752 acpi_ns_get_attached_object(method_node);
787 753
788 /* Push start scope on scope stack and make it current */ 754 /* Push start scope on scope stack and make it current */
789 755
790 status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state); 756 status =
791 if (ACPI_FAILURE (status)) { 757 acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD,
792 return_ACPI_STATUS (status); 758 walk_state);
759 if (ACPI_FAILURE(status)) {
760 return_ACPI_STATUS(status);
793 } 761 }
794 762
795 /* Init the method arguments */ 763 /* Init the method arguments */
796 764
797 status = acpi_ds_method_data_init_args (walk_state->params, 765 status = acpi_ds_method_data_init_args(walk_state->params,
798 ACPI_METHOD_NUM_ARGS, walk_state); 766 ACPI_METHOD_NUM_ARGS,
799 if (ACPI_FAILURE (status)) { 767 walk_state);
800 return_ACPI_STATUS (status); 768 if (ACPI_FAILURE(status)) {
769 return_ACPI_STATUS(status);
801 } 770 }
802 } 771 } else {
803 else {
804 /* 772 /*
805 * Setup the current scope. 773 * Setup the current scope.
806 * Find a Named Op that has a namespace node associated with it. 774 * Find a Named Op that has a namespace node associated with it.
@@ -814,27 +782,27 @@ acpi_ds_init_aml_walk (
814 782
815 if (!extra_op) { 783 if (!extra_op) {
816 parser_state->start_node = NULL; 784 parser_state->start_node = NULL;
817 } 785 } else {
818 else {
819 parser_state->start_node = extra_op->common.node; 786 parser_state->start_node = extra_op->common.node;
820 } 787 }
821 788
822 if (parser_state->start_node) { 789 if (parser_state->start_node) {
823 /* Push start scope on scope stack and make it current */ 790 /* Push start scope on scope stack and make it current */
824 791
825 status = acpi_ds_scope_stack_push (parser_state->start_node, 792 status =
826 parser_state->start_node->type, walk_state); 793 acpi_ds_scope_stack_push(parser_state->start_node,
827 if (ACPI_FAILURE (status)) { 794 parser_state->start_node->
828 return_ACPI_STATUS (status); 795 type, walk_state);
796 if (ACPI_FAILURE(status)) {
797 return_ACPI_STATUS(status);
829 } 798 }
830 } 799 }
831 } 800 }
832 801
833 status = acpi_ds_init_callbacks (walk_state, pass_number); 802 status = acpi_ds_init_callbacks(walk_state, pass_number);
834 return_ACPI_STATUS (status); 803 return_ACPI_STATUS(status);
835} 804}
836 805
837
838/******************************************************************************* 806/*******************************************************************************
839 * 807 *
840 * FUNCTION: acpi_ds_delete_walk_state 808 * FUNCTION: acpi_ds_delete_walk_state
@@ -847,29 +815,27 @@ acpi_ds_init_aml_walk (
847 * 815 *
848 ******************************************************************************/ 816 ******************************************************************************/
849 817
850void 818void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
851acpi_ds_delete_walk_state (
852 struct acpi_walk_state *walk_state)
853{ 819{
854 union acpi_generic_state *state; 820 union acpi_generic_state *state;
855
856
857 ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state);
858 821
822 ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state);
859 823
860 if (!walk_state) { 824 if (!walk_state) {
861 return; 825 return;
862 } 826 }
863 827
864 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 828 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
865 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", 829 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
866 walk_state)); 830 "%p is not a valid walk state\n",
831 walk_state));
867 return; 832 return;
868 } 833 }
869 834
870 if (walk_state->parser_state.scope) { 835 if (walk_state->parser_state.scope) {
871 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", 836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
872 walk_state)); 837 "%p walk still has a scope list\n",
838 walk_state));
873 } 839 }
874 840
875 /* Always must free any linked control states */ 841 /* Always must free any linked control states */
@@ -878,7 +844,7 @@ acpi_ds_delete_walk_state (
878 state = walk_state->control_state; 844 state = walk_state->control_state;
879 walk_state->control_state = state->common.next; 845 walk_state->control_state = state->common.next;
880 846
881 acpi_ut_delete_generic_state (state); 847 acpi_ut_delete_generic_state(state);
882 } 848 }
883 849
884 /* Always must free any linked parse states */ 850 /* Always must free any linked parse states */
@@ -887,7 +853,7 @@ acpi_ds_delete_walk_state (
887 state = walk_state->scope_info; 853 state = walk_state->scope_info;
888 walk_state->scope_info = state->common.next; 854 walk_state->scope_info = state->common.next;
889 855
890 acpi_ut_delete_generic_state (state); 856 acpi_ut_delete_generic_state(state);
891 } 857 }
892 858
893 /* Always must free any stacked result states */ 859 /* Always must free any stacked result states */
@@ -896,40 +862,12 @@ acpi_ds_delete_walk_state (
896 state = walk_state->results; 862 state = walk_state->results;
897 walk_state->results = state->common.next; 863 walk_state->results = state->common.next;
898 864
899 acpi_ut_delete_generic_state (state); 865 acpi_ut_delete_generic_state(state);
900 } 866 }
901 867
902 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); 868 ACPI_MEM_FREE(walk_state);
903 return_VOID;
904}
905
906
907#ifdef ACPI_ENABLE_OBJECT_CACHE
908/******************************************************************************
909 *
910 * FUNCTION: acpi_ds_delete_walk_state_cache
911 *
912 * PARAMETERS: None
913 *
914 * RETURN: None
915 *
916 * DESCRIPTION: Purge the global state object cache. Used during subsystem
917 * termination.
918 *
919 ******************************************************************************/
920
921void
922acpi_ds_delete_walk_state_cache (
923 void)
924{
925 ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
926
927
928 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
929 return_VOID; 869 return_VOID;
930} 870}
931#endif
932
933 871
934#ifdef ACPI_OBSOLETE_FUNCTIONS 872#ifdef ACPI_OBSOLETE_FUNCTIONS
935/******************************************************************************* 873/*******************************************************************************
@@ -947,50 +885,53 @@ acpi_ds_delete_walk_state_cache (
947 ******************************************************************************/ 885 ******************************************************************************/
948 886
949acpi_status 887acpi_status
950acpi_ds_result_insert ( 888acpi_ds_result_insert(void *object,
951 void *object, 889 u32 index, struct acpi_walk_state *walk_state)
952 u32 index,
953 struct acpi_walk_state *walk_state)
954{ 890{
955 union acpi_generic_state *state; 891 union acpi_generic_state *state;
956
957
958 ACPI_FUNCTION_NAME ("ds_result_insert");
959 892
893 ACPI_FUNCTION_NAME("ds_result_insert");
960 894
961 state = walk_state->results; 895 state = walk_state->results;
962 if (!state) { 896 if (!state) {
963 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", 897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
964 walk_state)); 898 "No result object pushed! State=%p\n",
899 walk_state));
965 return (AE_NOT_EXIST); 900 return (AE_NOT_EXIST);
966 } 901 }
967 902
968 if (index >= ACPI_OBJ_NUM_OPERANDS) { 903 if (index >= ACPI_OBJ_NUM_OPERANDS) {
969 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 904 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
970 "Index out of range: %X Obj=%p State=%p Num=%X\n", 905 "Index out of range: %X Obj=%p State=%p Num=%X\n",
971 index, object, walk_state, state->results.num_results)); 906 index, object, walk_state,
907 state->results.num_results));
972 return (AE_BAD_PARAMETER); 908 return (AE_BAD_PARAMETER);
973 } 909 }
974 910
975 if (!object) { 911 if (!object) {
976 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 912 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
977 "Null Object! Index=%X Obj=%p State=%p Num=%X\n", 913 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
978 index, object, walk_state, state->results.num_results)); 914 index, object, walk_state,
915 state->results.num_results));
979 return (AE_BAD_PARAMETER); 916 return (AE_BAD_PARAMETER);
980 } 917 }
981 918
982 state->results.obj_desc [index] = object; 919 state->results.obj_desc[index] = object;
983 state->results.num_results++; 920 state->results.num_results++;
984 921
985 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 922 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
986 "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 923 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
987 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", 924 object,
988 walk_state, state->results.num_results, walk_state->current_result)); 925 object ?
926 acpi_ut_get_object_type_name((union
927 acpi_operand_object *)
928 object) : "NULL",
929 walk_state, state->results.num_results,
930 walk_state->current_result));
989 931
990 return (AE_OK); 932 return (AE_OK);
991} 933}
992 934
993
994/******************************************************************************* 935/*******************************************************************************
995 * 936 *
996 * FUNCTION: acpi_ds_obj_stack_delete_all 937 * FUNCTION: acpi_ds_obj_stack_delete_all
@@ -1004,29 +945,24 @@ acpi_ds_result_insert (
1004 * 945 *
1005 ******************************************************************************/ 946 ******************************************************************************/
1006 947
1007acpi_status 948acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state)
1008acpi_ds_obj_stack_delete_all (
1009 struct acpi_walk_state *walk_state)
1010{ 949{
1011 u32 i; 950 u32 i;
1012
1013
1014 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
1015 951
952 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state);
1016 953
1017 /* The stack size is configurable, but fixed */ 954 /* The stack size is configurable, but fixed */
1018 955
1019 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) { 956 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
1020 if (walk_state->operands[i]) { 957 if (walk_state->operands[i]) {
1021 acpi_ut_remove_reference (walk_state->operands[i]); 958 acpi_ut_remove_reference(walk_state->operands[i]);
1022 walk_state->operands[i] = NULL; 959 walk_state->operands[i] = NULL;
1023 } 960 }
1024 } 961 }
1025 962
1026 return_ACPI_STATUS (AE_OK); 963 return_ACPI_STATUS(AE_OK);
1027} 964}
1028 965
1029
1030/******************************************************************************* 966/*******************************************************************************
1031 * 967 *
1032 * FUNCTION: acpi_ds_obj_stack_pop_object 968 * FUNCTION: acpi_ds_obj_stack_pop_object
@@ -1042,19 +978,17 @@ acpi_ds_obj_stack_delete_all (
1042 ******************************************************************************/ 978 ******************************************************************************/
1043 979
1044acpi_status 980acpi_status
1045acpi_ds_obj_stack_pop_object ( 981acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
1046 union acpi_operand_object **object, 982 struct acpi_walk_state *walk_state)
1047 struct acpi_walk_state *walk_state)
1048{ 983{
1049 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object"); 984 ACPI_FUNCTION_NAME("ds_obj_stack_pop_object");
1050
1051 985
1052 /* Check for stack underflow */ 986 /* Check for stack underflow */
1053 987
1054 if (walk_state->num_operands == 0) { 988 if (walk_state->num_operands == 0) {
1055 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 989 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1056 "Missing operand/stack empty! State=%p #Ops=%X\n", 990 "Missing operand/stack empty! State=%p #Ops=%X\n",
1057 walk_state, walk_state->num_operands)); 991 walk_state, walk_state->num_operands));
1058 *object = NULL; 992 *object = NULL;
1059 return (AE_AML_NO_OPERAND); 993 return (AE_AML_NO_OPERAND);
1060 } 994 }
@@ -1065,27 +999,26 @@ acpi_ds_obj_stack_pop_object (
1065 999
1066 /* Check for a valid operand */ 1000 /* Check for a valid operand */
1067 1001
1068 if (!walk_state->operands [walk_state->num_operands]) { 1002 if (!walk_state->operands[walk_state->num_operands]) {
1069 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1003 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1070 "Null operand! State=%p #Ops=%X\n", 1004 "Null operand! State=%p #Ops=%X\n",
1071 walk_state, walk_state->num_operands)); 1005 walk_state, walk_state->num_operands));
1072 *object = NULL; 1006 *object = NULL;
1073 return (AE_AML_NO_OPERAND); 1007 return (AE_AML_NO_OPERAND);
1074 } 1008 }
1075 1009
1076 /* Get operand and set stack entry to null */ 1010 /* Get operand and set stack entry to null */
1077 1011
1078 *object = walk_state->operands [walk_state->num_operands]; 1012 *object = walk_state->operands[walk_state->num_operands];
1079 walk_state->operands [walk_state->num_operands] = NULL; 1013 walk_state->operands[walk_state->num_operands] = NULL;
1080 1014
1081 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", 1015 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
1082 *object, acpi_ut_get_object_type_name (*object), 1016 *object, acpi_ut_get_object_type_name(*object),
1083 walk_state, walk_state->num_operands)); 1017 walk_state, walk_state->num_operands));
1084 1018
1085 return (AE_OK); 1019 return (AE_OK);
1086} 1020}
1087 1021
1088
1089/******************************************************************************* 1022/*******************************************************************************
1090 * 1023 *
1091 * FUNCTION: acpi_ds_obj_stack_get_value 1024 * FUNCTION: acpi_ds_obj_stack_get_value
@@ -1101,30 +1034,25 @@ acpi_ds_obj_stack_pop_object (
1101 * 1034 *
1102 ******************************************************************************/ 1035 ******************************************************************************/
1103 1036
1104void * 1037void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state)
1105acpi_ds_obj_stack_get_value (
1106 u32 index,
1107 struct acpi_walk_state *walk_state)
1108{ 1038{
1109 1039
1110 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state); 1040 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state);
1111
1112 1041
1113 /* Can't do it if the stack is empty */ 1042 /* Can't do it if the stack is empty */
1114 1043
1115 if (walk_state->num_operands == 0) { 1044 if (walk_state->num_operands == 0) {
1116 return_PTR (NULL); 1045 return_PTR(NULL);
1117 } 1046 }
1118 1047
1119 /* or if the index is past the top of the stack */ 1048 /* or if the index is past the top of the stack */
1120 1049
1121 if (index > (walk_state->num_operands - (u32) 1)) { 1050 if (index > (walk_state->num_operands - (u32) 1)) {
1122 return_PTR (NULL); 1051 return_PTR(NULL);
1123 } 1052 }
1124 1053
1125 return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) - 1054 return_PTR(walk_state->
1126 index]); 1055 operands[(acpi_native_uint) (walk_state->num_operands - 1) -
1056 index]);
1127} 1057}
1128#endif 1058#endif
1129
1130
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 1ac5731d45e5..7e1a445955bc 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -38,130 +38,112 @@
38#include <acpi/actypes.h> 38#include <acpi/actypes.h>
39 39
40#define _COMPONENT ACPI_EC_COMPONENT 40#define _COMPONENT ACPI_EC_COMPONENT
41ACPI_MODULE_NAME ("acpi_ec") 41ACPI_MODULE_NAME("acpi_ec")
42
43#define ACPI_EC_COMPONENT 0x00100000 42#define ACPI_EC_COMPONENT 0x00100000
44#define ACPI_EC_CLASS "embedded_controller" 43#define ACPI_EC_CLASS "embedded_controller"
45#define ACPI_EC_HID "PNP0C09" 44#define ACPI_EC_HID "PNP0C09"
46#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" 45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
47#define ACPI_EC_DEVICE_NAME "Embedded Controller" 46#define ACPI_EC_DEVICE_NAME "Embedded Controller"
48#define ACPI_EC_FILE_INFO "info" 47#define ACPI_EC_FILE_INFO "info"
49
50
51#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 48#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 49#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
53#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ 50#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
54#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 51#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
55
56#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ 52#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */
57#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ 53#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */
58
59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ 54#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 55#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
61 56#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
62#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ 57#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
63#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
64
65#define ACPI_EC_COMMAND_READ 0x80 58#define ACPI_EC_COMMAND_READ 0x80
66#define ACPI_EC_COMMAND_WRITE 0x81 59#define ACPI_EC_COMMAND_WRITE 0x81
67#define ACPI_EC_BURST_ENABLE 0x82 60#define ACPI_EC_BURST_ENABLE 0x82
68#define ACPI_EC_BURST_DISABLE 0x83 61#define ACPI_EC_BURST_DISABLE 0x83
69#define ACPI_EC_COMMAND_QUERY 0x84 62#define ACPI_EC_COMMAND_QUERY 0x84
70
71#define EC_POLLING 0xFF 63#define EC_POLLING 0xFF
72#define EC_BURST 0x00 64#define EC_BURST 0x00
73 65static int acpi_ec_remove(struct acpi_device *device, int type);
74 66static int acpi_ec_start(struct acpi_device *device);
75static int acpi_ec_remove (struct acpi_device *device, int type); 67static int acpi_ec_stop(struct acpi_device *device, int type);
76static int acpi_ec_start (struct acpi_device *device); 68static int acpi_ec_burst_add(struct acpi_device *device);
77static int acpi_ec_stop (struct acpi_device *device, int type); 69static int acpi_ec_polling_add(struct acpi_device *device);
78static int acpi_ec_burst_add ( struct acpi_device *device);
79static int acpi_ec_polling_add ( struct acpi_device *device);
80 70
81static struct acpi_driver acpi_ec_driver = { 71static struct acpi_driver acpi_ec_driver = {
82 .name = ACPI_EC_DRIVER_NAME, 72 .name = ACPI_EC_DRIVER_NAME,
83 .class = ACPI_EC_CLASS, 73 .class = ACPI_EC_CLASS,
84 .ids = ACPI_EC_HID, 74 .ids = ACPI_EC_HID,
85 .ops = { 75 .ops = {
86 .add = acpi_ec_polling_add, 76 .add = acpi_ec_polling_add,
87 .remove = acpi_ec_remove, 77 .remove = acpi_ec_remove,
88 .start = acpi_ec_start, 78 .start = acpi_ec_start,
89 .stop = acpi_ec_stop, 79 .stop = acpi_ec_stop,
90 }, 80 },
91}; 81};
92union acpi_ec { 82union acpi_ec {
93 struct { 83 struct {
94 u32 mode; 84 u32 mode;
95 acpi_handle handle; 85 acpi_handle handle;
96 unsigned long uid; 86 unsigned long uid;
97 unsigned long gpe_bit; 87 unsigned long gpe_bit;
98 struct acpi_generic_address status_addr; 88 struct acpi_generic_address status_addr;
99 struct acpi_generic_address command_addr; 89 struct acpi_generic_address command_addr;
100 struct acpi_generic_address data_addr; 90 struct acpi_generic_address data_addr;
101 unsigned long global_lock; 91 unsigned long global_lock;
102 } common; 92 } common;
103 93
104 struct { 94 struct {
105 u32 mode; 95 u32 mode;
106 acpi_handle handle; 96 acpi_handle handle;
107 unsigned long uid; 97 unsigned long uid;
108 unsigned long gpe_bit; 98 unsigned long gpe_bit;
109 struct acpi_generic_address status_addr; 99 struct acpi_generic_address status_addr;
110 struct acpi_generic_address command_addr; 100 struct acpi_generic_address command_addr;
111 struct acpi_generic_address data_addr; 101 struct acpi_generic_address data_addr;
112 unsigned long global_lock; 102 unsigned long global_lock;
113 unsigned int expect_event; 103 unsigned int expect_event;
114 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ 104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
115 atomic_t pending_gpe; 105 atomic_t pending_gpe;
116 struct semaphore sem; 106 struct semaphore sem;
117 wait_queue_head_t wait; 107 wait_queue_head_t wait;
118 }burst; 108 } burst;
119 109
120 struct { 110 struct {
121 u32 mode; 111 u32 mode;
122 acpi_handle handle; 112 acpi_handle handle;
123 unsigned long uid; 113 unsigned long uid;
124 unsigned long gpe_bit; 114 unsigned long gpe_bit;
125 struct acpi_generic_address status_addr; 115 struct acpi_generic_address status_addr;
126 struct acpi_generic_address command_addr; 116 struct acpi_generic_address command_addr;
127 struct acpi_generic_address data_addr; 117 struct acpi_generic_address data_addr;
128 unsigned long global_lock; 118 unsigned long global_lock;
129 spinlock_t lock; 119 spinlock_t lock;
130 }polling; 120 } polling;
131}; 121};
132 122
133static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event); 123static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event);
134static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); 124static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event);
135static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data); 125static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data);
136static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data); 126static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data);
137static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data); 127static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data);
138static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data); 128static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data);
139static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data); 129static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data);
140static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data); 130static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data);
141static void acpi_ec_gpe_polling_query ( void *ec_cxt); 131static void acpi_ec_gpe_polling_query(void *ec_cxt);
142static void acpi_ec_gpe_burst_query ( void *ec_cxt); 132static void acpi_ec_gpe_burst_query(void *ec_cxt);
143static u32 acpi_ec_gpe_polling_handler ( void *data); 133static u32 acpi_ec_gpe_polling_handler(void *data);
144static u32 acpi_ec_gpe_burst_handler ( void *data); 134static u32 acpi_ec_gpe_burst_handler(void *data);
145static acpi_status __init 135static acpi_status __init
146acpi_fake_ecdt_polling_callback ( 136acpi_fake_ecdt_polling_callback(acpi_handle handle,
147 acpi_handle handle, 137 u32 Level, void *context, void **retval);
148 u32 Level,
149 void *context,
150 void **retval);
151 138
152static acpi_status __init 139static acpi_status __init
153acpi_fake_ecdt_burst_callback ( 140acpi_fake_ecdt_burst_callback(acpi_handle handle,
154 acpi_handle handle, 141 u32 Level, void *context, void **retval);
155 u32 Level, 142
156 void *context, 143static int __init acpi_ec_polling_get_real_ecdt(void);
157 void **retval); 144static int __init acpi_ec_burst_get_real_ecdt(void);
158
159static int __init
160acpi_ec_polling_get_real_ecdt(void);
161static int __init
162acpi_ec_burst_get_real_ecdt(void);
163/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 145/* If we find an EC via the ECDT, we need to keep a ptr to its context */
164static union acpi_ec *ec_ecdt; 146static union acpi_ec *ec_ecdt;
165 147
166/* External interfaces use first EC only, so remember */ 148/* External interfaces use first EC only, so remember */
167static struct acpi_device *first_ec; 149static struct acpi_device *first_ec;
@@ -173,30 +155,24 @@ static int acpi_ec_polling_mode = EC_POLLING;
173 155
174static inline u32 acpi_ec_read_status(union acpi_ec *ec) 156static inline u32 acpi_ec_read_status(union acpi_ec *ec)
175{ 157{
176 u32 status = 0; 158 u32 status = 0;
177 159
178 acpi_hw_low_level_read(8, &status, &ec->common.status_addr); 160 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
179 return status; 161 return status;
180} 162}
181 163
182static int 164static int acpi_ec_wait(union acpi_ec *ec, u8 event)
183acpi_ec_wait (
184 union acpi_ec *ec,
185 u8 event)
186{ 165{
187 if (acpi_ec_polling_mode) 166 if (acpi_ec_polling_mode)
188 return acpi_ec_polling_wait (ec, event); 167 return acpi_ec_polling_wait(ec, event);
189 else 168 else
190 return acpi_ec_burst_wait (ec, event); 169 return acpi_ec_burst_wait(ec, event);
191} 170}
192 171
193static int 172static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event)
194acpi_ec_polling_wait (
195 union acpi_ec *ec,
196 u8 event)
197{ 173{
198 u32 acpi_ec_status = 0; 174 u32 acpi_ec_status = 0;
199 u32 i = ACPI_EC_UDELAY_COUNT; 175 u32 i = ACPI_EC_UDELAY_COUNT;
200 176
201 if (!ec) 177 if (!ec)
202 return -EINVAL; 178 return -EINVAL;
@@ -205,19 +181,21 @@ acpi_ec_polling_wait (
205 switch (event) { 181 switch (event) {
206 case ACPI_EC_EVENT_OBF: 182 case ACPI_EC_EVENT_OBF:
207 do { 183 do {
208 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); 184 acpi_hw_low_level_read(8, &acpi_ec_status,
185 &ec->common.status_addr);
209 if (acpi_ec_status & ACPI_EC_FLAG_OBF) 186 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
210 return 0; 187 return 0;
211 udelay(ACPI_EC_UDELAY); 188 udelay(ACPI_EC_UDELAY);
212 } while (--i>0); 189 } while (--i > 0);
213 break; 190 break;
214 case ACPI_EC_EVENT_IBE: 191 case ACPI_EC_EVENT_IBE:
215 do { 192 do {
216 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); 193 acpi_hw_low_level_read(8, &acpi_ec_status,
194 &ec->common.status_addr);
217 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) 195 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
218 return 0; 196 return 0;
219 udelay(ACPI_EC_UDELAY); 197 udelay(ACPI_EC_UDELAY);
220 } while (--i>0); 198 } while (--i > 0);
221 break; 199 break;
222 default: 200 default:
223 return -EINVAL; 201 return -EINVAL;
@@ -227,25 +205,36 @@ acpi_ec_polling_wait (
227} 205}
228static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) 206static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
229{ 207{
230 int result = 0; 208 int result = 0;
231 209
232 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 210 ACPI_FUNCTION_TRACE("acpi_ec_wait");
233 211
234 ec->burst.expect_event = event; 212 ec->burst.expect_event = event;
235 smp_mb(); 213 smp_mb();
236 214
237 result = wait_event_interruptible_timeout(ec->burst.wait, 215 switch (event) {
238 !ec->burst.expect_event, 216 case ACPI_EC_EVENT_OBF:
239 msecs_to_jiffies(ACPI_EC_DELAY)); 217 if (acpi_ec_read_status(ec) & event) {
240 218 ec->burst.expect_event = 0;
241 ec->burst.expect_event = 0; 219 return_VALUE(0);
242 smp_mb(); 220 }
221 break;
243 222
244 if (result < 0){ 223 case ACPI_EC_EVENT_IBE:
245 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result)); 224 if (~acpi_ec_read_status(ec) & event) {
246 return_VALUE(result); 225 ec->burst.expect_event = 0;
226 return_VALUE(0);
227 }
228 break;
247 } 229 }
248 230
231 result = wait_event_timeout(ec->burst.wait,
232 !ec->burst.expect_event,
233 msecs_to_jiffies(ACPI_EC_DELAY));
234
235 ec->burst.expect_event = 0;
236 smp_mb();
237
249 /* 238 /*
250 * Verify that the event in question has actually happened by 239 * Verify that the event in question has actually happened by
251 * querying EC status. Do the check even if operation timed-out 240 * querying EC status. Do the check even if operation timed-out
@@ -266,95 +255,65 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
266 return_VALUE(-ETIME); 255 return_VALUE(-ETIME);
267} 256}
268 257
269 258static int acpi_ec_enter_burst_mode(union acpi_ec *ec)
270
271static int
272acpi_ec_enter_burst_mode (
273 union acpi_ec *ec)
274{ 259{
275 u32 tmp = 0; 260 u32 tmp = 0;
276 int status = 0; 261 int status = 0;
277 262
278 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); 263 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
279 264
280 status = acpi_ec_read_status(ec); 265 status = acpi_ec_read_status(ec);
281 if (status != -EINVAL && 266 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
282 !(status & ACPI_EC_FLAG_BURST)){ 267 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
283 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); 268 if (status)
269 goto end;
270 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE,
271 &ec->common.command_addr);
284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
285 if (status){ 273 if (status)
286 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
287 return_VALUE(-EINVAL); 274 return_VALUE(-EINVAL);
288 }
289 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 275 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
290 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 276 if (tmp != 0x90) { /* Burst ACK byte */
291 if(tmp != 0x90 ) {/* Burst ACK byte*/
292 return_VALUE(-EINVAL); 277 return_VALUE(-EINVAL);
293 } 278 }
294 } 279 }
295 280
296 atomic_set(&ec->burst.leaving_burst , 0); 281 atomic_set(&ec->burst.leaving_burst, 0);
297 return_VALUE(0); 282 return_VALUE(0);
283 end:
284 printk("Error in acpi_ec_wait\n");
285 return_VALUE(-1);
298} 286}
299 287
300static int 288static int acpi_ec_leave_burst_mode(union acpi_ec *ec)
301acpi_ec_leave_burst_mode (
302 union acpi_ec *ec)
303{ 289{
304 int status =0;
305 290
306 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 291 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
307 292
308 atomic_set(&ec->burst.leaving_burst , 1); 293 atomic_set(&ec->burst.leaving_burst, 1);
309 status = acpi_ec_read_status(ec);
310 if (status != -EINVAL &&
311 (status & ACPI_EC_FLAG_BURST)){
312 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
313 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
314 if (status){
315 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
316 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
317 return_VALUE(-EINVAL);
318 }
319 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
320 status = acpi_ec_read_status(ec);
321 }
322
323 return_VALUE(0); 294 return_VALUE(0);
324} 295}
325 296
326static int 297static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data)
327acpi_ec_read (
328 union acpi_ec *ec,
329 u8 address,
330 u32 *data)
331{ 298{
332 if (acpi_ec_polling_mode) 299 if (acpi_ec_polling_mode)
333 return acpi_ec_polling_read(ec, address, data); 300 return acpi_ec_polling_read(ec, address, data);
334 else 301 else
335 return acpi_ec_burst_read(ec, address, data); 302 return acpi_ec_burst_read(ec, address, data);
336} 303}
337static int 304static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
338acpi_ec_write (
339 union acpi_ec *ec,
340 u8 address,
341 u8 data)
342{ 305{
343 if (acpi_ec_polling_mode) 306 if (acpi_ec_polling_mode)
344 return acpi_ec_polling_write(ec, address, data); 307 return acpi_ec_polling_write(ec, address, data);
345 else 308 else
346 return acpi_ec_burst_write(ec, address, data); 309 return acpi_ec_burst_write(ec, address, data);
347} 310}
348static int 311static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
349acpi_ec_polling_read (
350 union acpi_ec *ec,
351 u8 address,
352 u32 *data)
353{ 312{
354 acpi_status status = AE_OK; 313 acpi_status status = AE_OK;
355 int result = 0; 314 int result = 0;
356 unsigned long flags = 0; 315 unsigned long flags = 0;
357 u32 glk = 0; 316 u32 glk = 0;
358 317
359 ACPI_FUNCTION_TRACE("acpi_ec_read"); 318 ACPI_FUNCTION_TRACE("acpi_ec_read");
360 319
@@ -371,7 +330,8 @@ acpi_ec_polling_read (
371 330
372 spin_lock_irqsave(&ec->polling.lock, flags); 331 spin_lock_irqsave(&ec->polling.lock, flags);
373 332
374 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); 333 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
334 &ec->common.command_addr);
375 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 335 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
376 if (result) 336 if (result)
377 goto end; 337 goto end;
@@ -384,9 +344,9 @@ acpi_ec_polling_read (
384 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 344 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
385 345
386 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 346 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
387 *data, address)); 347 *data, address));
388 348
389end: 349 end:
390 spin_unlock_irqrestore(&ec->polling.lock, flags); 350 spin_unlock_irqrestore(&ec->polling.lock, flags);
391 351
392 if (ec->common.global_lock) 352 if (ec->common.global_lock)
@@ -395,17 +355,12 @@ end:
395 return_VALUE(result); 355 return_VALUE(result);
396} 356}
397 357
398 358static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
399static int
400acpi_ec_polling_write (
401 union acpi_ec *ec,
402 u8 address,
403 u8 data)
404{ 359{
405 int result = 0; 360 int result = 0;
406 acpi_status status = AE_OK; 361 acpi_status status = AE_OK;
407 unsigned long flags = 0; 362 unsigned long flags = 0;
408 u32 glk = 0; 363 u32 glk = 0;
409 364
410 ACPI_FUNCTION_TRACE("acpi_ec_write"); 365 ACPI_FUNCTION_TRACE("acpi_ec_write");
411 366
@@ -420,7 +375,8 @@ acpi_ec_polling_write (
420 375
421 spin_lock_irqsave(&ec->polling.lock, flags); 376 spin_lock_irqsave(&ec->polling.lock, flags);
422 377
423 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); 378 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
379 &ec->common.command_addr);
424 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 380 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
425 if (result) 381 if (result)
426 goto end; 382 goto end;
@@ -436,9 +392,9 @@ acpi_ec_polling_write (
436 goto end; 392 goto end;
437 393
438 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 394 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
439 data, address)); 395 data, address));
440 396
441end: 397 end:
442 spin_unlock_irqrestore(&ec->polling.lock, flags); 398 spin_unlock_irqrestore(&ec->polling.lock, flags);
443 399
444 if (ec->common.global_lock) 400 if (ec->common.global_lock)
@@ -447,21 +403,16 @@ end:
447 return_VALUE(result); 403 return_VALUE(result);
448} 404}
449 405
450static int 406static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
451acpi_ec_burst_read (
452 union acpi_ec *ec,
453 u8 address,
454 u32 *data)
455{ 407{
456 int status = 0; 408 int status = 0;
457 u32 glk; 409 u32 glk;
458 410
459 ACPI_FUNCTION_TRACE("acpi_ec_read"); 411 ACPI_FUNCTION_TRACE("acpi_ec_read");
460 412
461 if (!ec || !data) 413 if (!ec || !data)
462 return_VALUE(-EINVAL); 414 return_VALUE(-EINVAL);
463 415
464retry:
465 *data = 0; 416 *data = 0;
466 417
467 if (ec->common.global_lock) { 418 if (ec->common.global_lock) {
@@ -473,64 +424,49 @@ retry:
473 WARN_ON(in_interrupt()); 424 WARN_ON(in_interrupt());
474 down(&ec->burst.sem); 425 down(&ec->burst.sem);
475 426
476 if(acpi_ec_enter_burst_mode(ec)) 427 acpi_ec_enter_burst_mode(ec);
477 goto end;
478
479 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
480 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 428 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
481 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
482 if (status) { 429 if (status) {
430 printk("read EC, IB not empty\n");
483 goto end; 431 goto end;
484 } 432 }
433 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
434 &ec->common.command_addr);
435 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
436 if (status) {
437 printk("read EC, IB not empty\n");
438 }
485 439
486 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 440 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
487 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 441 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
488 if (status){ 442 if (status) {
489 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 443 printk("read EC, OB not full\n");
490 goto end; 444 goto end;
491 } 445 }
492
493 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 446 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
494 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
495
496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 447 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
497 *data, address)); 448 *data, address));
498 449
499end: 450 end:
500 acpi_ec_leave_burst_mode(ec); 451 acpi_ec_leave_burst_mode(ec);
501 up(&ec->burst.sem); 452 up(&ec->burst.sem);
502 453
503 if (ec->common.global_lock) 454 if (ec->common.global_lock)
504 acpi_release_global_lock(glk); 455 acpi_release_global_lock(glk);
505 456
506 if(atomic_read(&ec->burst.leaving_burst) == 2){
507 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
508 while(atomic_read(&ec->burst.pending_gpe)){
509 msleep(1);
510 }
511 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
512 goto retry;
513 }
514
515 return_VALUE(status); 457 return_VALUE(status);
516} 458}
517 459
518 460static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data)
519static int
520acpi_ec_burst_write (
521 union acpi_ec *ec,
522 u8 address,
523 u8 data)
524{ 461{
525 int status = 0; 462 int status = 0;
526 u32 glk; 463 u32 glk;
527 u32 tmp;
528 464
529 ACPI_FUNCTION_TRACE("acpi_ec_write"); 465 ACPI_FUNCTION_TRACE("acpi_ec_write");
530 466
531 if (!ec) 467 if (!ec)
532 return_VALUE(-EINVAL); 468 return_VALUE(-EINVAL);
533retry: 469
534 if (ec->common.global_lock) { 470 if (ec->common.global_lock) {
535 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 471 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
536 if (ACPI_FAILURE(status)) 472 if (ACPI_FAILURE(status))
@@ -540,69 +476,43 @@ retry:
540 WARN_ON(in_interrupt()); 476 WARN_ON(in_interrupt());
541 down(&ec->burst.sem); 477 down(&ec->burst.sem);
542 478
543 if(acpi_ec_enter_burst_mode(ec)) 479 acpi_ec_enter_burst_mode(ec);
544 goto end;
545 480
546 status = acpi_ec_read_status(ec); 481 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
547 if (status != -EINVAL && 482 if (status) {
548 !(status & ACPI_EC_FLAG_BURST)){ 483 printk("write EC, IB not empty\n");
549 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
550 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
551 if (status)
552 goto end;
553 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
554 if(tmp != 0x90 ) /* Burst ACK byte*/
555 goto end;
556 } 484 }
557 /*Now we are in burst mode*/ 485 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
558 486 &ec->common.command_addr);
559 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
560 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 487 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
561 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 488 if (status) {
562 if (status){ 489 printk("write EC, IB not empty\n");
563 goto end;
564 } 490 }
565 491
566 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 492 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
567 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 493 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
568 if (status){ 494 if (status) {
569 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 495 printk("write EC, IB not empty\n");
570 goto end;
571 } 496 }
572 497
573 acpi_hw_low_level_write(8, data, &ec->common.data_addr); 498 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
574 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
575 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
576 if (status)
577 goto end;
578 499
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 500 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
580 data, address)); 501 data, address));
581 502
582end:
583 acpi_ec_leave_burst_mode(ec); 503 acpi_ec_leave_burst_mode(ec);
584 up(&ec->burst.sem); 504 up(&ec->burst.sem);
585 505
586 if (ec->common.global_lock) 506 if (ec->common.global_lock)
587 acpi_release_global_lock(glk); 507 acpi_release_global_lock(glk);
588 508
589 if(atomic_read(&ec->burst.leaving_burst) == 2){
590 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
591 while(atomic_read(&ec->burst.pending_gpe)){
592 msleep(1);
593 }
594 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
595 goto retry;
596 }
597
598 return_VALUE(status); 509 return_VALUE(status);
599} 510}
600 511
601/* 512/*
602 * Externally callable EC access functions. For now, assume 1 EC only 513 * Externally callable EC access functions. For now, assume 1 EC only
603 */ 514 */
604int 515int ec_read(u8 addr, u8 * val)
605ec_read(u8 addr, u8 *val)
606{ 516{
607 union acpi_ec *ec; 517 union acpi_ec *ec;
608 int err; 518 int err;
@@ -618,14 +528,13 @@ ec_read(u8 addr, u8 *val)
618 if (!err) { 528 if (!err) {
619 *val = temp_data; 529 *val = temp_data;
620 return 0; 530 return 0;
621 } 531 } else
622 else
623 return err; 532 return err;
624} 533}
534
625EXPORT_SYMBOL(ec_read); 535EXPORT_SYMBOL(ec_read);
626 536
627int 537int ec_write(u8 addr, u8 val)
628ec_write(u8 addr, u8 val)
629{ 538{
630 union acpi_ec *ec; 539 union acpi_ec *ec;
631 int err; 540 int err;
@@ -639,27 +548,22 @@ ec_write(u8 addr, u8 val)
639 548
640 return err; 549 return err;
641} 550}
551
642EXPORT_SYMBOL(ec_write); 552EXPORT_SYMBOL(ec_write);
643 553
644static int 554static int acpi_ec_query(union acpi_ec *ec, u32 * data)
645acpi_ec_query (
646 union acpi_ec *ec,
647 u32 *data)
648{ 555{
649 if (acpi_ec_polling_mode) 556 if (acpi_ec_polling_mode)
650 return acpi_ec_polling_query(ec, data); 557 return acpi_ec_polling_query(ec, data);
651 else 558 else
652 return acpi_ec_burst_query(ec, data); 559 return acpi_ec_burst_query(ec, data);
653} 560}
654static int 561static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
655acpi_ec_polling_query (
656 union acpi_ec *ec,
657 u32 *data)
658{ 562{
659 int result = 0; 563 int result = 0;
660 acpi_status status = AE_OK; 564 acpi_status status = AE_OK;
661 unsigned long flags = 0; 565 unsigned long flags = 0;
662 u32 glk = 0; 566 u32 glk = 0;
663 567
664 ACPI_FUNCTION_TRACE("acpi_ec_query"); 568 ACPI_FUNCTION_TRACE("acpi_ec_query");
665 569
@@ -681,7 +585,8 @@ acpi_ec_polling_query (
681 */ 585 */
682 spin_lock_irqsave(&ec->polling.lock, flags); 586 spin_lock_irqsave(&ec->polling.lock, flags);
683 587
684 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); 588 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
589 &ec->common.command_addr);
685 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 590 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
686 if (result) 591 if (result)
687 goto end; 592 goto end;
@@ -690,7 +595,7 @@ acpi_ec_polling_query (
690 if (!*data) 595 if (!*data)
691 result = -ENODATA; 596 result = -ENODATA;
692 597
693end: 598 end:
694 spin_unlock_irqrestore(&ec->polling.lock, flags); 599 spin_unlock_irqrestore(&ec->polling.lock, flags);
695 600
696 if (ec->common.global_lock) 601 if (ec->common.global_lock)
@@ -698,13 +603,10 @@ end:
698 603
699 return_VALUE(result); 604 return_VALUE(result);
700} 605}
701static int 606static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
702acpi_ec_burst_query (
703 union acpi_ec *ec,
704 u32 *data)
705{ 607{
706 int status = 0; 608 int status = 0;
707 u32 glk; 609 u32 glk;
708 610
709 ACPI_FUNCTION_TRACE("acpi_ec_query"); 611 ACPI_FUNCTION_TRACE("acpi_ec_query");
710 612
@@ -719,70 +621,64 @@ acpi_ec_burst_query (
719 } 621 }
720 622
721 down(&ec->burst.sem); 623 down(&ec->burst.sem);
722 if(acpi_ec_enter_burst_mode(ec)) 624
625 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
626 if (status) {
627 printk("query EC, IB not empty\n");
723 goto end; 628 goto end;
629 }
724 /* 630 /*
725 * Query the EC to find out which _Qxx method we need to evaluate. 631 * Query the EC to find out which _Qxx method we need to evaluate.
726 * Note that successful completion of the query causes the ACPI_EC_SCI 632 * Note that successful completion of the query causes the ACPI_EC_SCI
727 * bit to be cleared (and thus clearing the interrupt source). 633 * bit to be cleared (and thus clearing the interrupt source).
728 */ 634 */
729 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); 635 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
636 &ec->common.command_addr);
730 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 637 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
731 if (status){ 638 if (status) {
732 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 639 printk("query EC, OB not full\n");
733 goto end; 640 goto end;
734 } 641 }
735 642
736 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 643 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
737 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
738 if (!*data) 644 if (!*data)
739 status = -ENODATA; 645 status = -ENODATA;
740 646
741end: 647 end:
742 acpi_ec_leave_burst_mode(ec);
743 up(&ec->burst.sem); 648 up(&ec->burst.sem);
744 649
745 if (ec->common.global_lock) 650 if (ec->common.global_lock)
746 acpi_release_global_lock(glk); 651 acpi_release_global_lock(glk);
747 652
748 if(atomic_read(&ec->burst.leaving_burst) == 2){
749 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
750 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
751 status = -ENODATA;
752 }
753 return_VALUE(status); 653 return_VALUE(status);
754} 654}
755 655
756
757/* -------------------------------------------------------------------------- 656/* --------------------------------------------------------------------------
758 Event Management 657 Event Management
759 -------------------------------------------------------------------------- */ 658 -------------------------------------------------------------------------- */
760 659
761union acpi_ec_query_data { 660union acpi_ec_query_data {
762 acpi_handle handle; 661 acpi_handle handle;
763 u8 data; 662 u8 data;
764}; 663};
765 664
766static void 665static void acpi_ec_gpe_query(void *ec_cxt)
767acpi_ec_gpe_query (
768 void *ec_cxt)
769{ 666{
770 if (acpi_ec_polling_mode) 667 if (acpi_ec_polling_mode)
771 acpi_ec_gpe_polling_query(ec_cxt); 668 acpi_ec_gpe_polling_query(ec_cxt);
772 else 669 else
773 acpi_ec_gpe_burst_query(ec_cxt); 670 acpi_ec_gpe_burst_query(ec_cxt);
774} 671}
775 672
776static void 673static void acpi_ec_gpe_polling_query(void *ec_cxt)
777acpi_ec_gpe_polling_query (
778 void *ec_cxt)
779{ 674{
780 union acpi_ec *ec = (union acpi_ec *) ec_cxt; 675 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
781 u32 value = 0; 676 u32 value = 0;
782 unsigned long flags = 0; 677 unsigned long flags = 0;
783 static char object_name[5] = {'_','Q','0','0','\0'}; 678 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
784 const char hex[] = {'0','1','2','3','4','5','6','7', 679 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
785 '8','9','A','B','C','D','E','F'}; 680 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
681 };
786 682
787 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); 683 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
788 684
@@ -812,19 +708,18 @@ acpi_ec_gpe_polling_query (
812 708
813 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 709 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
814 710
815end: 711 end:
816 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 712 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
817} 713}
818static void 714static void acpi_ec_gpe_burst_query(void *ec_cxt)
819acpi_ec_gpe_burst_query (
820 void *ec_cxt)
821{ 715{
822 union acpi_ec *ec = (union acpi_ec *) ec_cxt; 716 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
823 u32 value; 717 u32 value;
824 int result = -ENODATA; 718 int result = -ENODATA;
825 static char object_name[5] = {'_','Q','0','0','\0'}; 719 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
826 const char hex[] = {'0','1','2','3','4','5','6','7', 720 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
827 '8','9','A','B','C','D','E','F'}; 721 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
722 };
828 723
829 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); 724 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
830 725
@@ -840,26 +735,22 @@ acpi_ec_gpe_burst_query (
840 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 735 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
841 736
842 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 737 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
843end: 738 end:
844 atomic_dec(&ec->burst.pending_gpe); 739 atomic_dec(&ec->burst.pending_gpe);
845 return; 740 return;
846} 741}
847 742
848static u32 743static u32 acpi_ec_gpe_handler(void *data)
849acpi_ec_gpe_handler (
850 void *data)
851{ 744{
852 if (acpi_ec_polling_mode) 745 if (acpi_ec_polling_mode)
853 return acpi_ec_gpe_polling_handler(data); 746 return acpi_ec_gpe_polling_handler(data);
854 else 747 else
855 return acpi_ec_gpe_burst_handler(data); 748 return acpi_ec_gpe_burst_handler(data);
856} 749}
857static u32 750static u32 acpi_ec_gpe_polling_handler(void *data)
858acpi_ec_gpe_polling_handler (
859 void *data)
860{ 751{
861 acpi_status status = AE_OK; 752 acpi_status status = AE_OK;
862 union acpi_ec *ec = (union acpi_ec *) data; 753 union acpi_ec *ec = (union acpi_ec *)data;
863 754
864 if (!ec) 755 if (!ec)
865 return ACPI_INTERRUPT_NOT_HANDLED; 756 return ACPI_INTERRUPT_NOT_HANDLED;
@@ -867,61 +758,49 @@ acpi_ec_gpe_polling_handler (
867 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 758 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
868 759
869 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 760 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
870 acpi_ec_gpe_query, ec); 761 acpi_ec_gpe_query, ec);
871 762
872 if (status == AE_OK) 763 if (status == AE_OK)
873 return ACPI_INTERRUPT_HANDLED; 764 return ACPI_INTERRUPT_HANDLED;
874 else 765 else
875 return ACPI_INTERRUPT_NOT_HANDLED; 766 return ACPI_INTERRUPT_NOT_HANDLED;
876} 767}
877static u32 768static u32 acpi_ec_gpe_burst_handler(void *data)
878acpi_ec_gpe_burst_handler (
879 void *data)
880{ 769{
881 acpi_status status = AE_OK; 770 acpi_status status = AE_OK;
882 u32 value; 771 u32 value;
883 union acpi_ec *ec = (union acpi_ec *) data; 772 union acpi_ec *ec = (union acpi_ec *)data;
884 773
885 if (!ec) 774 if (!ec)
886 return ACPI_INTERRUPT_NOT_HANDLED; 775 return ACPI_INTERRUPT_NOT_HANDLED;
887 776
888 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 777 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
889
890 value = acpi_ec_read_status(ec); 778 value = acpi_ec_read_status(ec);
891 779
892 if((value & ACPI_EC_FLAG_IBF) && 780 switch (ec->burst.expect_event) {
893 !(value & ACPI_EC_FLAG_BURST) && 781 case ACPI_EC_EVENT_OBF:
894 (atomic_read(&ec->burst.leaving_burst) == 0)) { 782 if (!(value & ACPI_EC_FLAG_OBF))
895 /* 783 break;
896 * the embedded controller disables 784 case ACPI_EC_EVENT_IBE:
897 * burst mode for any reason other 785 if ((value & ACPI_EC_FLAG_IBF))
898 * than the burst disable command 786 break;
899 * to process critical event. 787 ec->burst.expect_event = 0;
900 */
901 atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction
902 and retry */
903 wake_up(&ec->burst.wait); 788 wake_up(&ec->burst.wait);
904 }else { 789 return ACPI_INTERRUPT_HANDLED;
905 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF && 790 default:
906 (value & ACPI_EC_FLAG_OBF)) || 791 break;
907 (ec->burst.expect_event == ACPI_EC_EVENT_IBE &&
908 !(value & ACPI_EC_FLAG_IBF))) {
909 ec->burst.expect_event = 0;
910 wake_up(&ec->burst.wait);
911 return ACPI_INTERRUPT_HANDLED;
912 }
913 } 792 }
914 793
915 if (value & ACPI_EC_FLAG_SCI){ 794 if (value & ACPI_EC_FLAG_SCI) {
916 atomic_add(1, &ec->burst.pending_gpe) ; 795 atomic_add(1, &ec->burst.pending_gpe);
917 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 796 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
918 acpi_ec_gpe_query, ec); 797 acpi_ec_gpe_query, ec);
919 return status == AE_OK ? 798 return status == AE_OK ?
920 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 799 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
921 } 800 }
922 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 801 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
923 return status == AE_OK ? 802 return status == AE_OK ?
924 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 803 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
925} 804}
926 805
927/* -------------------------------------------------------------------------- 806/* --------------------------------------------------------------------------
@@ -929,37 +808,31 @@ acpi_ec_gpe_burst_handler (
929 -------------------------------------------------------------------------- */ 808 -------------------------------------------------------------------------- */
930 809
931static acpi_status 810static acpi_status
932acpi_ec_space_setup ( 811acpi_ec_space_setup(acpi_handle region_handle,
933 acpi_handle region_handle, 812 u32 function, void *handler_context, void **return_context)
934 u32 function,
935 void *handler_context,
936 void **return_context)
937{ 813{
938 /* 814 /*
939 * The EC object is in the handler context and is needed 815 * The EC object is in the handler context and is needed
940 * when calling the acpi_ec_space_handler. 816 * when calling the acpi_ec_space_handler.
941 */ 817 */
942 *return_context = (function != ACPI_REGION_DEACTIVATE) ? 818 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
943 handler_context : NULL; 819 handler_context : NULL;
944 820
945 return AE_OK; 821 return AE_OK;
946} 822}
947 823
948
949static acpi_status 824static acpi_status
950acpi_ec_space_handler ( 825acpi_ec_space_handler(u32 function,
951 u32 function, 826 acpi_physical_address address,
952 acpi_physical_address address, 827 u32 bit_width,
953 u32 bit_width, 828 acpi_integer * value,
954 acpi_integer *value, 829 void *handler_context, void *region_context)
955 void *handler_context,
956 void *region_context)
957{ 830{
958 int result = 0; 831 int result = 0;
959 union acpi_ec *ec = NULL; 832 union acpi_ec *ec = NULL;
960 u64 temp = *value; 833 u64 temp = *value;
961 acpi_integer f_v = 0; 834 acpi_integer f_v = 0;
962 int i = 0; 835 int i = 0;
963 836
964 ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); 837 ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
965 838
@@ -967,17 +840,18 @@ acpi_ec_space_handler (
967 return_VALUE(AE_BAD_PARAMETER); 840 return_VALUE(AE_BAD_PARAMETER);
968 841
969 if (bit_width != 8 && acpi_strict) { 842 if (bit_width != 8 && acpi_strict) {
970 printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); 843 printk(KERN_WARNING PREFIX
844 "acpi_ec_space_handler: bit_width should be 8\n");
971 return_VALUE(AE_BAD_PARAMETER); 845 return_VALUE(AE_BAD_PARAMETER);
972 } 846 }
973 847
974 ec = (union acpi_ec *) handler_context; 848 ec = (union acpi_ec *)handler_context;
975 849
976next_byte: 850 next_byte:
977 switch (function) { 851 switch (function) {
978 case ACPI_READ: 852 case ACPI_READ:
979 temp = 0; 853 temp = 0;
980 result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); 854 result = acpi_ec_read(ec, (u8) address, (u32 *) & temp);
981 break; 855 break;
982 case ACPI_WRITE: 856 case ACPI_WRITE:
983 result = acpi_ec_write(ec, (u8) address, (u8) temp); 857 result = acpi_ec_write(ec, (u8) address, (u8) temp);
@@ -1004,8 +878,7 @@ next_byte:
1004 *value = f_v; 878 *value = f_v;
1005 } 879 }
1006 880
1007 881 out:
1008out:
1009 switch (result) { 882 switch (result) {
1010 case -EINVAL: 883 case -EINVAL:
1011 return_VALUE(AE_BAD_PARAMETER); 884 return_VALUE(AE_BAD_PARAMETER);
@@ -1021,18 +894,15 @@ out:
1021 } 894 }
1022} 895}
1023 896
1024
1025/* -------------------------------------------------------------------------- 897/* --------------------------------------------------------------------------
1026 FS Interface (/proc) 898 FS Interface (/proc)
1027 -------------------------------------------------------------------------- */ 899 -------------------------------------------------------------------------- */
1028 900
1029static struct proc_dir_entry *acpi_ec_dir; 901static struct proc_dir_entry *acpi_ec_dir;
1030
1031 902
1032static int 903static int acpi_ec_read_info(struct seq_file *seq, void *offset)
1033acpi_ec_read_info (struct seq_file *seq, void *offset)
1034{ 904{
1035 union acpi_ec *ec = (union acpi_ec *) seq->private; 905 union acpi_ec *ec = (union acpi_ec *)seq->private;
1036 906
1037 ACPI_FUNCTION_TRACE("acpi_ec_read_info"); 907 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
1038 908
@@ -1040,14 +910,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
1040 goto end; 910 goto end;
1041 911
1042 seq_printf(seq, "gpe bit: 0x%02x\n", 912 seq_printf(seq, "gpe bit: 0x%02x\n",
1043 (u32) ec->common.gpe_bit); 913 (u32) ec->common.gpe_bit);
1044 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 914 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
1045 (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address); 915 (u32) ec->common.status_addr.address,
916 (u32) ec->common.data_addr.address);
1046 seq_printf(seq, "use global lock: %s\n", 917 seq_printf(seq, "use global lock: %s\n",
1047 ec->common.global_lock?"yes":"no"); 918 ec->common.global_lock ? "yes" : "no");
1048 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 919 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
1049 920
1050end: 921 end:
1051 return_VALUE(0); 922 return_VALUE(0);
1052} 923}
1053 924
@@ -1057,34 +928,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
1057} 928}
1058 929
1059static struct file_operations acpi_ec_info_ops = { 930static struct file_operations acpi_ec_info_ops = {
1060 .open = acpi_ec_info_open_fs, 931 .open = acpi_ec_info_open_fs,
1061 .read = seq_read, 932 .read = seq_read,
1062 .llseek = seq_lseek, 933 .llseek = seq_lseek,
1063 .release = single_release, 934 .release = single_release,
1064 .owner = THIS_MODULE, 935 .owner = THIS_MODULE,
1065}; 936};
1066 937
1067static int 938static int acpi_ec_add_fs(struct acpi_device *device)
1068acpi_ec_add_fs (
1069 struct acpi_device *device)
1070{ 939{
1071 struct proc_dir_entry *entry = NULL; 940 struct proc_dir_entry *entry = NULL;
1072 941
1073 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 942 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
1074 943
1075 if (!acpi_device_dir(device)) { 944 if (!acpi_device_dir(device)) {
1076 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 945 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1077 acpi_ec_dir); 946 acpi_ec_dir);
1078 if (!acpi_device_dir(device)) 947 if (!acpi_device_dir(device))
1079 return_VALUE(-ENODEV); 948 return_VALUE(-ENODEV);
1080 } 949 }
1081 950
1082 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, 951 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
1083 acpi_device_dir(device)); 952 acpi_device_dir(device));
1084 if (!entry) 953 if (!entry)
1085 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 954 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
1086 "Unable to create '%s' fs entry\n", 955 "Unable to create '%s' fs entry\n",
1087 ACPI_EC_FILE_INFO)); 956 ACPI_EC_FILE_INFO));
1088 else { 957 else {
1089 entry->proc_fops = &acpi_ec_info_ops; 958 entry->proc_fops = &acpi_ec_info_ops;
1090 entry->data = acpi_driver_data(device); 959 entry->data = acpi_driver_data(device);
@@ -1094,10 +963,7 @@ acpi_ec_add_fs (
1094 return_VALUE(0); 963 return_VALUE(0);
1095} 964}
1096 965
1097 966static int acpi_ec_remove_fs(struct acpi_device *device)
1098static int
1099acpi_ec_remove_fs (
1100 struct acpi_device *device)
1101{ 967{
1102 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); 968 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
1103 969
@@ -1110,20 +976,16 @@ acpi_ec_remove_fs (
1110 return_VALUE(0); 976 return_VALUE(0);
1111} 977}
1112 978
1113
1114/* -------------------------------------------------------------------------- 979/* --------------------------------------------------------------------------
1115 Driver Interface 980 Driver Interface
1116 -------------------------------------------------------------------------- */ 981 -------------------------------------------------------------------------- */
1117 982
1118 983static int acpi_ec_polling_add(struct acpi_device *device)
1119static int
1120acpi_ec_polling_add (
1121 struct acpi_device *device)
1122{ 984{
1123 int result = 0; 985 int result = 0;
1124 acpi_status status = AE_OK; 986 acpi_status status = AE_OK;
1125 union acpi_ec *ec = NULL; 987 union acpi_ec *ec = NULL;
1126 unsigned long uid; 988 unsigned long uid;
1127 989
1128 ACPI_FUNCTION_TRACE("acpi_ec_add"); 990 ACPI_FUNCTION_TRACE("acpi_ec_add");
1129 991
@@ -1143,26 +1005,31 @@ acpi_ec_polling_add (
1143 acpi_driver_data(device) = ec; 1005 acpi_driver_data(device) = ec;
1144 1006
1145 /* Use the global lock for all EC transactions? */ 1007 /* Use the global lock for all EC transactions? */
1146 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); 1008 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1009 &ec->common.global_lock);
1147 1010
1148 /* If our UID matches the UID for the ECDT-enumerated EC, 1011 /* If our UID matches the UID for the ECDT-enumerated EC,
1149 we now have the *real* EC info, so kill the makeshift one.*/ 1012 we now have the *real* EC info, so kill the makeshift one. */
1150 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); 1013 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1151 if (ec_ecdt && ec_ecdt->common.uid == uid) { 1014 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1152 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1015 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1153 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1016 ACPI_ADR_SPACE_EC,
1154 1017 &acpi_ec_space_handler);
1155 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); 1018
1019 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1020 &acpi_ec_gpe_handler);
1156 1021
1157 kfree(ec_ecdt); 1022 kfree(ec_ecdt);
1158 } 1023 }
1159 1024
1160 /* Get GPE bit assignment (EC events). */ 1025 /* Get GPE bit assignment (EC events). */
1161 /* TODO: Add support for _GPE returning a package */ 1026 /* TODO: Add support for _GPE returning a package */
1162 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); 1027 status =
1028 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1029 &ec->common.gpe_bit);
1163 if (ACPI_FAILURE(status)) { 1030 if (ACPI_FAILURE(status)) {
1164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1031 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1165 "Error obtaining GPE bit assignment\n")); 1032 "Error obtaining GPE bit assignment\n"));
1166 result = -ENODEV; 1033 result = -ENODEV;
1167 goto end; 1034 goto end;
1168 } 1035 }
@@ -1172,26 +1039,24 @@ acpi_ec_polling_add (
1172 goto end; 1039 goto end;
1173 1040
1174 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1041 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1175 acpi_device_name(device), acpi_device_bid(device), 1042 acpi_device_name(device), acpi_device_bid(device),
1176 (u32) ec->common.gpe_bit); 1043 (u32) ec->common.gpe_bit);
1177 1044
1178 if (!first_ec) 1045 if (!first_ec)
1179 first_ec = device; 1046 first_ec = device;
1180 1047
1181end: 1048 end:
1182 if (result) 1049 if (result)
1183 kfree(ec); 1050 kfree(ec);
1184 1051
1185 return_VALUE(result); 1052 return_VALUE(result);
1186} 1053}
1187static int 1054static int acpi_ec_burst_add(struct acpi_device *device)
1188acpi_ec_burst_add (
1189 struct acpi_device *device)
1190{ 1055{
1191 int result = 0; 1056 int result = 0;
1192 acpi_status status = AE_OK; 1057 acpi_status status = AE_OK;
1193 union acpi_ec *ec = NULL; 1058 union acpi_ec *ec = NULL;
1194 unsigned long uid; 1059 unsigned long uid;
1195 1060
1196 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1061 ACPI_FUNCTION_TRACE("acpi_ec_add");
1197 1062
@@ -1205,35 +1070,40 @@ acpi_ec_burst_add (
1205 1070
1206 ec->common.handle = device->handle; 1071 ec->common.handle = device->handle;
1207 ec->common.uid = -1; 1072 ec->common.uid = -1;
1208 atomic_set(&ec->burst.pending_gpe, 0); 1073 atomic_set(&ec->burst.pending_gpe, 0);
1209 atomic_set(&ec->burst.leaving_burst , 1); 1074 atomic_set(&ec->burst.leaving_burst, 1);
1210 init_MUTEX(&ec->burst.sem); 1075 init_MUTEX(&ec->burst.sem);
1211 init_waitqueue_head(&ec->burst.wait); 1076 init_waitqueue_head(&ec->burst.wait);
1212 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1077 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1213 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1078 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1214 acpi_driver_data(device) = ec; 1079 acpi_driver_data(device) = ec;
1215 1080
1216 /* Use the global lock for all EC transactions? */ 1081 /* Use the global lock for all EC transactions? */
1217 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); 1082 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1083 &ec->common.global_lock);
1218 1084
1219 /* If our UID matches the UID for the ECDT-enumerated EC, 1085 /* If our UID matches the UID for the ECDT-enumerated EC,
1220 we now have the *real* EC info, so kill the makeshift one.*/ 1086 we now have the *real* EC info, so kill the makeshift one. */
1221 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); 1087 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1222 if (ec_ecdt && ec_ecdt->common.uid == uid) { 1088 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1223 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1089 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1224 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1090 ACPI_ADR_SPACE_EC,
1091 &acpi_ec_space_handler);
1225 1092
1226 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); 1093 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1094 &acpi_ec_gpe_handler);
1227 1095
1228 kfree(ec_ecdt); 1096 kfree(ec_ecdt);
1229 } 1097 }
1230 1098
1231 /* Get GPE bit assignment (EC events). */ 1099 /* Get GPE bit assignment (EC events). */
1232 /* TODO: Add support for _GPE returning a package */ 1100 /* TODO: Add support for _GPE returning a package */
1233 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); 1101 status =
1102 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1103 &ec->common.gpe_bit);
1234 if (ACPI_FAILURE(status)) { 1104 if (ACPI_FAILURE(status)) {
1235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1105 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1236 "Error obtaining GPE bit assignment\n")); 1106 "Error obtaining GPE bit assignment\n"));
1237 result = -ENODEV; 1107 result = -ENODEV;
1238 goto end; 1108 goto end;
1239 } 1109 }
@@ -1242,27 +1112,24 @@ acpi_ec_burst_add (
1242 if (result) 1112 if (result)
1243 goto end; 1113 goto end;
1244 1114
1115 printk("burst-mode-ec-10-Aug\n");
1245 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1116 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1246 acpi_device_name(device), acpi_device_bid(device), 1117 acpi_device_name(device), acpi_device_bid(device),
1247 (u32) ec->common.gpe_bit); 1118 (u32) ec->common.gpe_bit);
1248 1119
1249 if (!first_ec) 1120 if (!first_ec)
1250 first_ec = device; 1121 first_ec = device;
1251 1122
1252end: 1123 end:
1253 if (result) 1124 if (result)
1254 kfree(ec); 1125 kfree(ec);
1255 1126
1256 return_VALUE(result); 1127 return_VALUE(result);
1257} 1128}
1258 1129
1259 1130static int acpi_ec_remove(struct acpi_device *device, int type)
1260static int
1261acpi_ec_remove (
1262 struct acpi_device *device,
1263 int type)
1264{ 1131{
1265 union acpi_ec *ec = NULL; 1132 union acpi_ec *ec = NULL;
1266 1133
1267 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 1134 ACPI_FUNCTION_TRACE("acpi_ec_remove");
1268 1135
@@ -1278,13 +1145,10 @@ acpi_ec_remove (
1278 return_VALUE(0); 1145 return_VALUE(0);
1279} 1146}
1280 1147
1281
1282static acpi_status 1148static acpi_status
1283acpi_ec_io_ports ( 1149acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1284 struct acpi_resource *resource,
1285 void *context)
1286{ 1150{
1287 union acpi_ec *ec = (union acpi_ec *) context; 1151 union acpi_ec *ec = (union acpi_ec *)context;
1288 struct acpi_generic_address *addr; 1152 struct acpi_generic_address *addr;
1289 1153
1290 if (resource->id != ACPI_RSTYPE_IO) { 1154 if (resource->id != ACPI_RSTYPE_IO) {
@@ -1312,13 +1176,10 @@ acpi_ec_io_ports (
1312 return AE_OK; 1176 return AE_OK;
1313} 1177}
1314 1178
1315 1179static int acpi_ec_start(struct acpi_device *device)
1316static int
1317acpi_ec_start (
1318 struct acpi_device *device)
1319{ 1180{
1320 acpi_status status = AE_OK; 1181 acpi_status status = AE_OK;
1321 union acpi_ec *ec = NULL; 1182 union acpi_ec *ec = NULL;
1322 1183
1323 ACPI_FUNCTION_TRACE("acpi_ec_start"); 1184 ACPI_FUNCTION_TRACE("acpi_ec_start");
1324 1185
@@ -1334,49 +1195,50 @@ acpi_ec_start (
1334 * Get I/O port addresses. Convert to GAS format. 1195 * Get I/O port addresses. Convert to GAS format.
1335 */ 1196 */
1336 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, 1197 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS,
1337 acpi_ec_io_ports, ec); 1198 acpi_ec_io_ports, ec);
1338 if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { 1199 if (ACPI_FAILURE(status)
1339 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); 1200 || ec->common.command_addr.register_bit_width == 0) {
1201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1202 "Error getting I/O port addresses"));
1340 return_VALUE(-ENODEV); 1203 return_VALUE(-ENODEV);
1341 } 1204 }
1342 1205
1343 ec->common.status_addr = ec->common.command_addr; 1206 ec->common.status_addr = ec->common.command_addr;
1344 1207
1345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", 1208 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
1346 (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address, 1209 (u32) ec->common.gpe_bit,
1347 (u32) ec->common.data_addr.address)); 1210 (u32) ec->common.command_addr.address,
1348 1211 (u32) ec->common.data_addr.address));
1349 1212
1350 /* 1213 /*
1351 * Install GPE handler 1214 * Install GPE handler
1352 */ 1215 */
1353 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, 1216 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit,
1354 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); 1217 ACPI_GPE_EDGE_TRIGGERED,
1218 &acpi_ec_gpe_handler, ec);
1355 if (ACPI_FAILURE(status)) { 1219 if (ACPI_FAILURE(status)) {
1356 return_VALUE(-ENODEV); 1220 return_VALUE(-ENODEV);
1357 } 1221 }
1358 acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1222 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1359 acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 1223 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
1360 1224
1361 status = acpi_install_address_space_handler (ec->common.handle, 1225 status = acpi_install_address_space_handler(ec->common.handle,
1362 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1226 ACPI_ADR_SPACE_EC,
1363 &acpi_ec_space_setup, ec); 1227 &acpi_ec_space_handler,
1228 &acpi_ec_space_setup, ec);
1364 if (ACPI_FAILURE(status)) { 1229 if (ACPI_FAILURE(status)) {
1365 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); 1230 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1231 &acpi_ec_gpe_handler);
1366 return_VALUE(-ENODEV); 1232 return_VALUE(-ENODEV);
1367 } 1233 }
1368 1234
1369 return_VALUE(AE_OK); 1235 return_VALUE(AE_OK);
1370} 1236}
1371 1237
1372 1238static int acpi_ec_stop(struct acpi_device *device, int type)
1373static int
1374acpi_ec_stop (
1375 struct acpi_device *device,
1376 int type)
1377{ 1239{
1378 acpi_status status = AE_OK; 1240 acpi_status status = AE_OK;
1379 union acpi_ec *ec = NULL; 1241 union acpi_ec *ec = NULL;
1380 1242
1381 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 1243 ACPI_FUNCTION_TRACE("acpi_ec_stop");
1382 1244
@@ -1386,11 +1248,14 @@ acpi_ec_stop (
1386 ec = acpi_driver_data(device); 1248 ec = acpi_driver_data(device);
1387 1249
1388 status = acpi_remove_address_space_handler(ec->common.handle, 1250 status = acpi_remove_address_space_handler(ec->common.handle,
1389 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1251 ACPI_ADR_SPACE_EC,
1252 &acpi_ec_space_handler);
1390 if (ACPI_FAILURE(status)) 1253 if (ACPI_FAILURE(status))
1391 return_VALUE(-ENODEV); 1254 return_VALUE(-ENODEV);
1392 1255
1393 status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); 1256 status =
1257 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1258 &acpi_ec_gpe_handler);
1394 if (ACPI_FAILURE(status)) 1259 if (ACPI_FAILURE(status))
1395 return_VALUE(-ENODEV); 1260 return_VALUE(-ENODEV);
1396 1261
@@ -1398,32 +1263,26 @@ acpi_ec_stop (
1398} 1263}
1399 1264
1400static acpi_status __init 1265static acpi_status __init
1401acpi_fake_ecdt_callback ( 1266acpi_fake_ecdt_callback(acpi_handle handle,
1402 acpi_handle handle, 1267 u32 Level, void *context, void **retval)
1403 u32 Level,
1404 void *context,
1405 void **retval)
1406{ 1268{
1407 1269
1408 if (acpi_ec_polling_mode) 1270 if (acpi_ec_polling_mode)
1409 return acpi_fake_ecdt_polling_callback(handle, 1271 return acpi_fake_ecdt_polling_callback(handle,
1410 Level, context, retval); 1272 Level, context, retval);
1411 else 1273 else
1412 return acpi_fake_ecdt_burst_callback(handle, 1274 return acpi_fake_ecdt_burst_callback(handle,
1413 Level, context, retval); 1275 Level, context, retval);
1414} 1276}
1415 1277
1416static acpi_status __init 1278static acpi_status __init
1417acpi_fake_ecdt_polling_callback ( 1279acpi_fake_ecdt_polling_callback(acpi_handle handle,
1418 acpi_handle handle, 1280 u32 Level, void *context, void **retval)
1419 u32 Level,
1420 void *context,
1421 void **retval)
1422{ 1281{
1423 acpi_status status; 1282 acpi_status status;
1424 1283
1425 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1284 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1426 acpi_ec_io_ports, ec_ecdt); 1285 acpi_ec_io_ports, ec_ecdt);
1427 if (ACPI_FAILURE(status)) 1286 if (ACPI_FAILURE(status))
1428 return status; 1287 return status;
1429 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; 1288 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
@@ -1431,33 +1290,33 @@ acpi_fake_ecdt_polling_callback (
1431 ec_ecdt->common.uid = -1; 1290 ec_ecdt->common.uid = -1;
1432 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 1291 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1433 1292
1434 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); 1293 status =
1294 acpi_evaluate_integer(handle, "_GPE", NULL,
1295 &ec_ecdt->common.gpe_bit);
1435 if (ACPI_FAILURE(status)) 1296 if (ACPI_FAILURE(status))
1436 return status; 1297 return status;
1437 spin_lock_init(&ec_ecdt->polling.lock); 1298 spin_lock_init(&ec_ecdt->polling.lock);
1438 ec_ecdt->common.global_lock = TRUE; 1299 ec_ecdt->common.global_lock = TRUE;
1439 ec_ecdt->common.handle = handle; 1300 ec_ecdt->common.handle = handle;
1440 1301
1441 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1302 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1442 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, 1303 (u32) ec_ecdt->common.gpe_bit,
1443 (u32) ec_ecdt->common.data_addr.address); 1304 (u32) ec_ecdt->common.command_addr.address,
1305 (u32) ec_ecdt->common.data_addr.address);
1444 1306
1445 return AE_CTRL_TERMINATE; 1307 return AE_CTRL_TERMINATE;
1446} 1308}
1447 1309
1448static acpi_status __init 1310static acpi_status __init
1449acpi_fake_ecdt_burst_callback ( 1311acpi_fake_ecdt_burst_callback(acpi_handle handle,
1450 acpi_handle handle, 1312 u32 Level, void *context, void **retval)
1451 u32 Level,
1452 void *context,
1453 void **retval)
1454{ 1313{
1455 acpi_status status; 1314 acpi_status status;
1456 1315
1457 init_MUTEX(&ec_ecdt->burst.sem); 1316 init_MUTEX(&ec_ecdt->burst.sem);
1458 init_waitqueue_head(&ec_ecdt->burst.wait); 1317 init_waitqueue_head(&ec_ecdt->burst.wait);
1459 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1318 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1460 acpi_ec_io_ports, ec_ecdt); 1319 acpi_ec_io_ports, ec_ecdt);
1461 if (ACPI_FAILURE(status)) 1320 if (ACPI_FAILURE(status))
1462 return status; 1321 return status;
1463 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; 1322 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
@@ -1465,15 +1324,18 @@ acpi_fake_ecdt_burst_callback (
1465 ec_ecdt->common.uid = -1; 1324 ec_ecdt->common.uid = -1;
1466 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 1325 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1467 1326
1468 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); 1327 status =
1328 acpi_evaluate_integer(handle, "_GPE", NULL,
1329 &ec_ecdt->common.gpe_bit);
1469 if (ACPI_FAILURE(status)) 1330 if (ACPI_FAILURE(status))
1470 return status; 1331 return status;
1471 ec_ecdt->common.global_lock = TRUE; 1332 ec_ecdt->common.global_lock = TRUE;
1472 ec_ecdt->common.handle = handle; 1333 ec_ecdt->common.handle = handle;
1473 1334
1474 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1335 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1475 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, 1336 (u32) ec_ecdt->common.gpe_bit,
1476 (u32) ec_ecdt->common.data_addr.address); 1337 (u32) ec_ecdt->common.command_addr.address,
1338 (u32) ec_ecdt->common.data_addr.address);
1477 1339
1478 return AE_CTRL_TERMINATE; 1340 return AE_CTRL_TERMINATE;
1479} 1341}
@@ -1488,11 +1350,10 @@ acpi_fake_ecdt_burst_callback (
1488 * op region (since _REG isn't invoked yet). The assumption is true for 1350 * op region (since _REG isn't invoked yet). The assumption is true for
1489 * all systems found. 1351 * all systems found.
1490 */ 1352 */
1491static int __init 1353static int __init acpi_ec_fake_ecdt(void)
1492acpi_ec_fake_ecdt(void)
1493{ 1354{
1494 acpi_status status; 1355 acpi_status status;
1495 int ret = 0; 1356 int ret = 0;
1496 1357
1497 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 1358 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
1498 1359
@@ -1503,10 +1364,8 @@ acpi_ec_fake_ecdt(void)
1503 } 1364 }
1504 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1365 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1505 1366
1506 status = acpi_get_devices (ACPI_EC_HID, 1367 status = acpi_get_devices(ACPI_EC_HID,
1507 acpi_fake_ecdt_callback, 1368 acpi_fake_ecdt_callback, NULL, NULL);
1508 NULL,
1509 NULL);
1510 if (ACPI_FAILURE(status)) { 1369 if (ACPI_FAILURE(status)) {
1511 kfree(ec_ecdt); 1370 kfree(ec_ecdt);
1512 ec_ecdt = NULL; 1371 ec_ecdt = NULL;
@@ -1514,13 +1373,12 @@ acpi_ec_fake_ecdt(void)
1514 goto error; 1373 goto error;
1515 } 1374 }
1516 return 0; 1375 return 0;
1517error: 1376 error:
1518 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); 1377 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n");
1519 return ret; 1378 return ret;
1520} 1379}
1521 1380
1522static int __init 1381static int __init acpi_ec_get_real_ecdt(void)
1523acpi_ec_get_real_ecdt(void)
1524{ 1382{
1525 if (acpi_ec_polling_mode) 1383 if (acpi_ec_polling_mode)
1526 return acpi_ec_polling_get_real_ecdt(); 1384 return acpi_ec_polling_get_real_ecdt();
@@ -1528,14 +1386,14 @@ acpi_ec_get_real_ecdt(void)
1528 return acpi_ec_burst_get_real_ecdt(); 1386 return acpi_ec_burst_get_real_ecdt();
1529} 1387}
1530 1388
1531static int __init 1389static int __init acpi_ec_polling_get_real_ecdt(void)
1532acpi_ec_polling_get_real_ecdt(void)
1533{ 1390{
1534 acpi_status status; 1391 acpi_status status;
1535 struct acpi_table_ecdt *ecdt_ptr; 1392 struct acpi_table_ecdt *ecdt_ptr;
1536 1393
1537 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 1394 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1538 (struct acpi_table_header **) &ecdt_ptr); 1395 (struct acpi_table_header **)
1396 &ecdt_ptr);
1539 if (ACPI_FAILURE(status)) 1397 if (ACPI_FAILURE(status))
1540 return -ENODEV; 1398 return -ENODEV;
1541 1399
@@ -1558,13 +1416,14 @@ acpi_ec_polling_get_real_ecdt(void)
1558 ec_ecdt->common.global_lock = TRUE; 1416 ec_ecdt->common.global_lock = TRUE;
1559 ec_ecdt->common.uid = ecdt_ptr->uid; 1417 ec_ecdt->common.uid = ecdt_ptr->uid;
1560 1418
1561 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 1419 status =
1420 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1562 if (ACPI_FAILURE(status)) { 1421 if (ACPI_FAILURE(status)) {
1563 goto error; 1422 goto error;
1564 } 1423 }
1565 1424
1566 return 0; 1425 return 0;
1567error: 1426 error:
1568 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1427 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1569 kfree(ec_ecdt); 1428 kfree(ec_ecdt);
1570 ec_ecdt = NULL; 1429 ec_ecdt = NULL;
@@ -1572,15 +1431,14 @@ error:
1572 return -ENODEV; 1431 return -ENODEV;
1573} 1432}
1574 1433
1575 1434static int __init acpi_ec_burst_get_real_ecdt(void)
1576static int __init
1577acpi_ec_burst_get_real_ecdt(void)
1578{ 1435{
1579 acpi_status status; 1436 acpi_status status;
1580 struct acpi_table_ecdt *ecdt_ptr; 1437 struct acpi_table_ecdt *ecdt_ptr;
1581 1438
1582 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 1439 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1583 (struct acpi_table_header **) &ecdt_ptr); 1440 (struct acpi_table_header **)
1441 &ecdt_ptr);
1584 if (ACPI_FAILURE(status)) 1442 if (ACPI_FAILURE(status))
1585 return -ENODEV; 1443 return -ENODEV;
1586 1444
@@ -1594,8 +1452,8 @@ acpi_ec_burst_get_real_ecdt(void)
1594 return -ENOMEM; 1452 return -ENOMEM;
1595 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1453 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1596 1454
1597 init_MUTEX(&ec_ecdt->burst.sem); 1455 init_MUTEX(&ec_ecdt->burst.sem);
1598 init_waitqueue_head(&ec_ecdt->burst.wait); 1456 init_waitqueue_head(&ec_ecdt->burst.wait);
1599 ec_ecdt->common.command_addr = ecdt_ptr->ec_control; 1457 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1600 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1458 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1601 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1459 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
@@ -1604,13 +1462,14 @@ acpi_ec_burst_get_real_ecdt(void)
1604 ec_ecdt->common.global_lock = TRUE; 1462 ec_ecdt->common.global_lock = TRUE;
1605 ec_ecdt->common.uid = ecdt_ptr->uid; 1463 ec_ecdt->common.uid = ecdt_ptr->uid;
1606 1464
1607 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 1465 status =
1466 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1608 if (ACPI_FAILURE(status)) { 1467 if (ACPI_FAILURE(status)) {
1609 goto error; 1468 goto error;
1610 } 1469 }
1611 1470
1612 return 0; 1471 return 0;
1613error: 1472 error:
1614 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1473 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1615 kfree(ec_ecdt); 1474 kfree(ec_ecdt);
1616 ec_ecdt = NULL; 1475 ec_ecdt = NULL;
@@ -1619,11 +1478,10 @@ error:
1619} 1478}
1620 1479
1621static int __initdata acpi_fake_ecdt_enabled; 1480static int __initdata acpi_fake_ecdt_enabled;
1622int __init 1481int __init acpi_ec_ecdt_probe(void)
1623acpi_ec_ecdt_probe (void)
1624{ 1482{
1625 acpi_status status; 1483 acpi_status status;
1626 int ret; 1484 int ret;
1627 1485
1628 ret = acpi_ec_get_real_ecdt(); 1486 ret = acpi_ec_get_real_ecdt();
1629 /* Try to make a fake ECDT */ 1487 /* Try to make a fake ECDT */
@@ -1638,26 +1496,28 @@ acpi_ec_ecdt_probe (void)
1638 * Install GPE handler 1496 * Install GPE handler
1639 */ 1497 */
1640 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 1498 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1641 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, 1499 ACPI_GPE_EDGE_TRIGGERED,
1642 ec_ecdt); 1500 &acpi_ec_gpe_handler, ec_ecdt);
1643 if (ACPI_FAILURE(status)) { 1501 if (ACPI_FAILURE(status)) {
1644 goto error; 1502 goto error;
1645 } 1503 }
1646 acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1504 acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1647 acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); 1505 acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR);
1648 1506
1649 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, 1507 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
1650 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1508 ACPI_ADR_SPACE_EC,
1651 &acpi_ec_space_setup, ec_ecdt); 1509 &acpi_ec_space_handler,
1510 &acpi_ec_space_setup,
1511 ec_ecdt);
1652 if (ACPI_FAILURE(status)) { 1512 if (ACPI_FAILURE(status)) {
1653 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 1513 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1654 &acpi_ec_gpe_handler); 1514 &acpi_ec_gpe_handler);
1655 goto error; 1515 goto error;
1656 } 1516 }
1657 1517
1658 return 0; 1518 return 0;
1659 1519
1660error: 1520 error:
1661 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1521 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1662 kfree(ec_ecdt); 1522 kfree(ec_ecdt);
1663 ec_ecdt = NULL; 1523 ec_ecdt = NULL;
@@ -1665,10 +1525,9 @@ error:
1665 return -ENODEV; 1525 return -ENODEV;
1666} 1526}
1667 1527
1668 1528static int __init acpi_ec_init(void)
1669static int __init acpi_ec_init (void)
1670{ 1529{
1671 int result = 0; 1530 int result = 0;
1672 1531
1673 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1532 ACPI_FUNCTION_TRACE("acpi_ec_init");
1674 1533
@@ -1693,8 +1552,7 @@ subsys_initcall(acpi_ec_init);
1693 1552
1694/* EC driver currently not unloadable */ 1553/* EC driver currently not unloadable */
1695#if 0 1554#if 0
1696static void __exit 1555static void __exit acpi_ec_exit(void)
1697acpi_ec_exit (void)
1698{ 1556{
1699 ACPI_FUNCTION_TRACE("acpi_ec_exit"); 1557 ACPI_FUNCTION_TRACE("acpi_ec_exit");
1700 1558
@@ -1704,7 +1562,7 @@ acpi_ec_exit (void)
1704 1562
1705 return_VOID; 1563 return_VOID;
1706} 1564}
1707#endif /* 0 */ 1565#endif /* 0 */
1708 1566
1709static int __init acpi_fake_ecdt_setup(char *str) 1567static int __init acpi_fake_ecdt_setup(char *str)
1710{ 1568{
@@ -1727,8 +1585,8 @@ static int __init acpi_ec_set_polling_mode(char *str)
1727 acpi_ec_polling_mode = EC_POLLING; 1585 acpi_ec_polling_mode = EC_POLLING;
1728 acpi_ec_driver.ops.add = acpi_ec_polling_add; 1586 acpi_ec_driver.ops.add = acpi_ec_polling_add;
1729 } 1587 }
1730 printk(KERN_INFO PREFIX "EC %s mode.\n", 1588 printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling");
1731 burst ? "burst": "polling");
1732 return 0; 1589 return 0;
1733} 1590}
1591
1734__setup("ec_burst=", acpi_ec_set_polling_mode); 1592__setup("ec_burst=", acpi_ec_set_polling_mode);
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 43c49f66a328..bfa8b76de403 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -13,45 +13,40 @@
13#include <acpi/acpi_drivers.h> 13#include <acpi/acpi_drivers.h>
14 14
15#define _COMPONENT ACPI_SYSTEM_COMPONENT 15#define _COMPONENT ACPI_SYSTEM_COMPONENT
16ACPI_MODULE_NAME ("event") 16ACPI_MODULE_NAME("event")
17 17
18/* Global vars for handling event proc entry */ 18/* Global vars for handling event proc entry */
19static DEFINE_SPINLOCK(acpi_system_event_lock); 19static DEFINE_SPINLOCK(acpi_system_event_lock);
20int event_is_open = 0; 20int event_is_open = 0;
21extern struct list_head acpi_bus_event_list; 21extern struct list_head acpi_bus_event_list;
22extern wait_queue_head_t acpi_bus_event_queue; 22extern wait_queue_head_t acpi_bus_event_queue;
23 23
24static int 24static int acpi_system_open_event(struct inode *inode, struct file *file)
25acpi_system_open_event(struct inode *inode, struct file *file)
26{ 25{
27 spin_lock_irq (&acpi_system_event_lock); 26 spin_lock_irq(&acpi_system_event_lock);
28 27
29 if(event_is_open) 28 if (event_is_open)
30 goto out_busy; 29 goto out_busy;
31 30
32 event_is_open = 1; 31 event_is_open = 1;
33 32
34 spin_unlock_irq (&acpi_system_event_lock); 33 spin_unlock_irq(&acpi_system_event_lock);
35 return 0; 34 return 0;
36 35
37out_busy: 36 out_busy:
38 spin_unlock_irq (&acpi_system_event_lock); 37 spin_unlock_irq(&acpi_system_event_lock);
39 return -EBUSY; 38 return -EBUSY;
40} 39}
41 40
42static ssize_t 41static ssize_t
43acpi_system_read_event ( 42acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
44 struct file *file, 43 loff_t * ppos)
45 char __user *buffer,
46 size_t count,
47 loff_t *ppos)
48{ 44{
49 int result = 0; 45 int result = 0;
50 struct acpi_bus_event event; 46 struct acpi_bus_event event;
51 static char str[ACPI_MAX_STRING]; 47 static char str[ACPI_MAX_STRING];
52 static int chars_remaining = 0; 48 static int chars_remaining = 0;
53 static char *ptr; 49 static char *ptr;
54
55 50
56 ACPI_FUNCTION_TRACE("acpi_system_read_event"); 51 ACPI_FUNCTION_TRACE("acpi_system_read_event");
57 52
@@ -67,10 +62,12 @@ acpi_system_read_event (
67 return_VALUE(-EIO); 62 return_VALUE(-EIO);
68 } 63 }
69 64
70 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 65 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
71 event.device_class?event.device_class:"<unknown>", 66 event.device_class ? event.
72 event.bus_id?event.bus_id:"<unknown>", 67 device_class : "<unknown>",
73 event.type, event.data); 68 event.bus_id ? event.
69 bus_id : "<unknown>", event.type,
70 event.data);
74 ptr = str; 71 ptr = str;
75 } 72 }
76 73
@@ -88,19 +85,15 @@ acpi_system_read_event (
88 return_VALUE(count); 85 return_VALUE(count);
89} 86}
90 87
91static int 88static int acpi_system_close_event(struct inode *inode, struct file *file)
92acpi_system_close_event(struct inode *inode, struct file *file)
93{ 89{
94 spin_lock_irq (&acpi_system_event_lock); 90 spin_lock_irq(&acpi_system_event_lock);
95 event_is_open = 0; 91 event_is_open = 0;
96 spin_unlock_irq (&acpi_system_event_lock); 92 spin_unlock_irq(&acpi_system_event_lock);
97 return 0; 93 return 0;
98} 94}
99 95
100static unsigned int 96static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
101acpi_system_poll_event(
102 struct file *file,
103 poll_table *wait)
104{ 97{
105 poll_wait(file, &acpi_bus_event_queue, wait); 98 poll_wait(file, &acpi_bus_event_queue, wait);
106 if (!list_empty(&acpi_bus_event_list)) 99 if (!list_empty(&acpi_bus_event_list))
@@ -109,15 +102,15 @@ acpi_system_poll_event(
109} 102}
110 103
111static struct file_operations acpi_system_event_ops = { 104static struct file_operations acpi_system_event_ops = {
112 .open = acpi_system_open_event, 105 .open = acpi_system_open_event,
113 .read = acpi_system_read_event, 106 .read = acpi_system_read_event,
114 .release = acpi_system_close_event, 107 .release = acpi_system_close_event,
115 .poll = acpi_system_poll_event, 108 .poll = acpi_system_poll_event,
116}; 109};
117 110
118static int __init acpi_event_init(void) 111static int __init acpi_event_init(void)
119{ 112{
120 struct proc_dir_entry *entry; 113 struct proc_dir_entry *entry;
121 int error = 0; 114 int error = 0;
122 115
123 ACPI_FUNCTION_TRACE("acpi_event_init"); 116 ACPI_FUNCTION_TRACE("acpi_event_init");
@@ -130,8 +123,9 @@ static int __init acpi_event_init(void)
130 if (entry) 123 if (entry)
131 entry->proc_fops = &acpi_system_event_ops; 124 entry->proc_fops = &acpi_system_event_ops;
132 else { 125 else {
133 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
134 "Unable to create '%s' proc fs entry\n","event" )); 127 "Unable to create '%s' proc fs entry\n",
128 "event"));
135 error = -EFAULT; 129 error = -EFAULT;
136 } 130 }
137 return_VALUE(error); 131 return_VALUE(error);
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index dd3a72a869f4..842d1e3fb37b 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -45,18 +45,12 @@
45#include <acpi/acevents.h> 45#include <acpi/acevents.h>
46 46
47#define _COMPONENT ACPI_EVENTS 47#define _COMPONENT ACPI_EVENTS
48 ACPI_MODULE_NAME ("evevent") 48ACPI_MODULE_NAME("evevent")
49 49
50/* Local prototypes */ 50/* Local prototypes */
51static acpi_status acpi_ev_fixed_event_initialize(void);
51 52
52static acpi_status 53static u32 acpi_ev_fixed_event_dispatch(u32 event);
53acpi_ev_fixed_event_initialize (
54 void);
55
56static u32
57acpi_ev_fixed_event_dispatch (
58 u32 event);
59
60 54
61/******************************************************************************* 55/*******************************************************************************
62 * 56 *
@@ -70,21 +64,17 @@ acpi_ev_fixed_event_dispatch (
70 * 64 *
71 ******************************************************************************/ 65 ******************************************************************************/
72 66
73acpi_status 67acpi_status acpi_ev_initialize_events(void)
74acpi_ev_initialize_events (
75 void)
76{ 68{
77 acpi_status status; 69 acpi_status status;
78
79
80 ACPI_FUNCTION_TRACE ("ev_initialize_events");
81 70
71 ACPI_FUNCTION_TRACE("ev_initialize_events");
82 72
83 /* Make sure we have ACPI tables */ 73 /* Make sure we have ACPI tables */
84 74
85 if (!acpi_gbl_DSDT) { 75 if (!acpi_gbl_DSDT) {
86 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n")); 76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n"));
87 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 77 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
88 } 78 }
89 79
90 /* 80 /*
@@ -92,26 +82,22 @@ acpi_ev_initialize_events (
92 * enabling SCIs to prevent interrupts from occurring before the handlers are 82 * enabling SCIs to prevent interrupts from occurring before the handlers are
93 * installed. 83 * installed.
94 */ 84 */
95 status = acpi_ev_fixed_event_initialize (); 85 status = acpi_ev_fixed_event_initialize();
96 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR (( 87 ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n",
98 "Unable to initialize fixed events, %s\n", 88 acpi_format_exception(status)));
99 acpi_format_exception (status))); 89 return_ACPI_STATUS(status);
100 return_ACPI_STATUS (status);
101 } 90 }
102 91
103 status = acpi_ev_gpe_initialize (); 92 status = acpi_ev_gpe_initialize();
104 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR (( 94 ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status)));
106 "Unable to initialize general purpose events, %s\n", 95 return_ACPI_STATUS(status);
107 acpi_format_exception (status)));
108 return_ACPI_STATUS (status);
109 } 96 }
110 97
111 return_ACPI_STATUS (status); 98 return_ACPI_STATUS(status);
112} 99}
113 100
114
115/******************************************************************************* 101/*******************************************************************************
116 * 102 *
117 * FUNCTION: acpi_ev_install_xrupt_handlers 103 * FUNCTION: acpi_ev_install_xrupt_handlers
@@ -124,41 +110,32 @@ acpi_ev_initialize_events (
124 * 110 *
125 ******************************************************************************/ 111 ******************************************************************************/
126 112
127acpi_status 113acpi_status acpi_ev_install_xrupt_handlers(void)
128acpi_ev_install_xrupt_handlers (
129 void)
130{ 114{
131 acpi_status status; 115 acpi_status status;
132
133
134 ACPI_FUNCTION_TRACE ("ev_install_xrupt_handlers");
135 116
117 ACPI_FUNCTION_TRACE("ev_install_xrupt_handlers");
136 118
137 /* Install the SCI handler */ 119 /* Install the SCI handler */
138 120
139 status = acpi_ev_install_sci_handler (); 121 status = acpi_ev_install_sci_handler();
140 if (ACPI_FAILURE (status)) { 122 if (ACPI_FAILURE(status)) {
141 ACPI_REPORT_ERROR (( 123 ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status)));
142 "Unable to install System Control Interrupt Handler, %s\n", 124 return_ACPI_STATUS(status);
143 acpi_format_exception (status)));
144 return_ACPI_STATUS (status);
145 } 125 }
146 126
147 /* Install the handler for the Global Lock */ 127 /* Install the handler for the Global Lock */
148 128
149 status = acpi_ev_init_global_lock_handler (); 129 status = acpi_ev_init_global_lock_handler();
150 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
151 ACPI_REPORT_ERROR (( 131 ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status)));
152 "Unable to initialize Global Lock handler, %s\n", 132 return_ACPI_STATUS(status);
153 acpi_format_exception (status)));
154 return_ACPI_STATUS (status);
155 } 133 }
156 134
157 acpi_gbl_events_initialized = TRUE; 135 acpi_gbl_events_initialized = TRUE;
158 return_ACPI_STATUS (status); 136 return_ACPI_STATUS(status);
159} 137}
160 138
161
162/******************************************************************************* 139/*******************************************************************************
163 * 140 *
164 * FUNCTION: acpi_ev_fixed_event_initialize 141 * FUNCTION: acpi_ev_fixed_event_initialize
@@ -171,13 +148,10 @@ acpi_ev_install_xrupt_handlers (
171 * 148 *
172 ******************************************************************************/ 149 ******************************************************************************/
173 150
174static acpi_status 151static acpi_status acpi_ev_fixed_event_initialize(void)
175acpi_ev_fixed_event_initialize (
176 void)
177{ 152{
178 acpi_native_uint i; 153 acpi_native_uint i;
179 acpi_status status; 154 acpi_status status;
180
181 155
182 /* 156 /*
183 * Initialize the structure that keeps track of fixed event handlers 157 * Initialize the structure that keeps track of fixed event handlers
@@ -190,10 +164,11 @@ acpi_ev_fixed_event_initialize (
190 /* Enable the fixed event */ 164 /* Enable the fixed event */
191 165
192 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { 166 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
193 status = acpi_set_register ( 167 status =
194 acpi_gbl_fixed_event_info[i].enable_register_id, 168 acpi_set_register(acpi_gbl_fixed_event_info[i].
195 0, ACPI_MTX_LOCK); 169 enable_register_id, 0,
196 if (ACPI_FAILURE (status)) { 170 ACPI_MTX_LOCK);
171 if (ACPI_FAILURE(status)) {
197 return (status); 172 return (status);
198 } 173 }
199 } 174 }
@@ -202,7 +177,6 @@ acpi_ev_fixed_event_initialize (
202 return (AE_OK); 177 return (AE_OK);
203} 178}
204 179
205
206/******************************************************************************* 180/*******************************************************************************
207 * 181 *
208 * FUNCTION: acpi_ev_fixed_event_detect 182 * FUNCTION: acpi_ev_fixed_event_detect
@@ -215,31 +189,27 @@ acpi_ev_fixed_event_initialize (
215 * 189 *
216 ******************************************************************************/ 190 ******************************************************************************/
217 191
218u32 192u32 acpi_ev_fixed_event_detect(void)
219acpi_ev_fixed_event_detect (
220 void)
221{ 193{
222 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 194 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
223 u32 fixed_status; 195 u32 fixed_status;
224 u32 fixed_enable; 196 u32 fixed_enable;
225 acpi_native_uint i; 197 acpi_native_uint i;
226
227
228 ACPI_FUNCTION_NAME ("ev_fixed_event_detect");
229 198
199 ACPI_FUNCTION_NAME("ev_fixed_event_detect");
230 200
231 /* 201 /*
232 * Read the fixed feature status and enable registers, as all the cases 202 * Read the fixed feature status and enable registers, as all the cases
233 * depend on their values. Ignore errors here. 203 * depend on their values. Ignore errors here.
234 */ 204 */
235 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, 205 (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
236 &fixed_status); 206 ACPI_REGISTER_PM1_STATUS, &fixed_status);
237 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, 207 (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
238 &fixed_enable); 208 ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
239 209
240 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 210 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
241 "Fixed Event Block: Enable %08X Status %08X\n", 211 "Fixed Event Block: Enable %08X Status %08X\n",
242 fixed_enable, fixed_status)); 212 fixed_enable, fixed_status));
243 213
244 /* 214 /*
245 * Check for all possible Fixed Events and dispatch those that are active 215 * Check for all possible Fixed Events and dispatch those that are active
@@ -247,18 +217,19 @@ acpi_ev_fixed_event_detect (
247 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 217 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
248 /* Both the status and enable bits must be on for this event */ 218 /* Both the status and enable bits must be on for this event */
249 219
250 if ((fixed_status & acpi_gbl_fixed_event_info[i].status_bit_mask) && 220 if ((fixed_status & acpi_gbl_fixed_event_info[i].
251 (fixed_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) { 221 status_bit_mask)
222 && (fixed_enable & acpi_gbl_fixed_event_info[i].
223 enable_bit_mask)) {
252 /* Found an active (signalled) event */ 224 /* Found an active (signalled) event */
253 225
254 int_status |= acpi_ev_fixed_event_dispatch ((u32) i); 226 int_status |= acpi_ev_fixed_event_dispatch((u32) i);
255 } 227 }
256 } 228 }
257 229
258 return (int_status); 230 return (int_status);
259} 231}
260 232
261
262/******************************************************************************* 233/*******************************************************************************
263 * 234 *
264 * FUNCTION: acpi_ev_fixed_event_dispatch 235 * FUNCTION: acpi_ev_fixed_event_dispatch
@@ -272,39 +243,32 @@ acpi_ev_fixed_event_detect (
272 * 243 *
273 ******************************************************************************/ 244 ******************************************************************************/
274 245
275static u32 246static u32 acpi_ev_fixed_event_dispatch(u32 event)
276acpi_ev_fixed_event_dispatch (
277 u32 event)
278{ 247{
279 248
280 249 ACPI_FUNCTION_ENTRY();
281 ACPI_FUNCTION_ENTRY ();
282
283 250
284 /* Clear the status bit */ 251 /* Clear the status bit */
285 252
286 (void) acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, 253 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
287 1, ACPI_MTX_DO_NOT_LOCK); 254 status_register_id, 1, ACPI_MTX_DO_NOT_LOCK);
288 255
289 /* 256 /*
290 * Make sure we've got a handler. If not, report an error. 257 * Make sure we've got a handler. If not, report an error.
291 * The event is disabled to prevent further interrupts. 258 * The event is disabled to prevent further interrupts.
292 */ 259 */
293 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 260 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
294 (void) acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 261 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
295 0, ACPI_MTX_DO_NOT_LOCK); 262 enable_register_id, 0,
263 ACPI_MTX_DO_NOT_LOCK);
296 264
297 ACPI_REPORT_ERROR ( 265 ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event));
298 ("No installed handler for fixed event [%08X]\n",
299 event));
300 266
301 return (ACPI_INTERRUPT_NOT_HANDLED); 267 return (ACPI_INTERRUPT_NOT_HANDLED);
302 } 268 }
303 269
304 /* Invoke the Fixed Event handler */ 270 /* Invoke the Fixed Event handler */
305 271
306 return ((acpi_gbl_fixed_event_handlers[event].handler)( 272 return ((acpi_gbl_fixed_event_handlers[event].
307 acpi_gbl_fixed_event_handlers[event].context)); 273 handler) (acpi_gbl_fixed_event_handlers[event].context));
308} 274}
309
310
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index 081120b109ba..b2f232df13d8 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -46,14 +46,10 @@
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpe") 49ACPI_MODULE_NAME("evgpe")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52 52static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
53static void ACPI_SYSTEM_XFACE
54acpi_ev_asynch_execute_gpe_method (
55 void *context);
56
57 53
58/******************************************************************************* 54/*******************************************************************************
59 * 55 *
@@ -69,15 +65,11 @@ acpi_ev_asynch_execute_gpe_method (
69 ******************************************************************************/ 65 ******************************************************************************/
70 66
71acpi_status 67acpi_status
72acpi_ev_set_gpe_type ( 68acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
73 struct acpi_gpe_event_info *gpe_event_info,
74 u8 type)
75{ 69{
76 acpi_status status; 70 acpi_status status;
77
78
79 ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
80 71
72 ACPI_FUNCTION_TRACE("ev_set_gpe_type");
81 73
82 /* Validate type and update register enable masks */ 74 /* Validate type and update register enable masks */
83 75
@@ -88,21 +80,20 @@ acpi_ev_set_gpe_type (
88 break; 80 break;
89 81
90 default: 82 default:
91 return_ACPI_STATUS (AE_BAD_PARAMETER); 83 return_ACPI_STATUS(AE_BAD_PARAMETER);
92 } 84 }
93 85
94 /* Disable the GPE if currently enabled */ 86 /* Disable the GPE if currently enabled */
95 87
96 status = acpi_ev_disable_gpe (gpe_event_info); 88 status = acpi_ev_disable_gpe(gpe_event_info);
97 89
98 /* Type was validated above */ 90 /* Type was validated above */
99 91
100 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ 92 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
101 gpe_event_info->flags |= type; /* Insert type */ 93 gpe_event_info->flags |= type; /* Insert type */
102 return_ACPI_STATUS (status); 94 return_ACPI_STATUS(status);
103} 95}
104 96
105
106/******************************************************************************* 97/*******************************************************************************
107 * 98 *
108 * FUNCTION: acpi_ev_update_gpe_enable_masks 99 * FUNCTION: acpi_ev_update_gpe_enable_masks
@@ -118,57 +109,55 @@ acpi_ev_set_gpe_type (
118 ******************************************************************************/ 109 ******************************************************************************/
119 110
120acpi_status 111acpi_status
121acpi_ev_update_gpe_enable_masks ( 112acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
122 struct acpi_gpe_event_info *gpe_event_info, 113 u8 type)
123 u8 type)
124{ 114{
125 struct acpi_gpe_register_info *gpe_register_info; 115 struct acpi_gpe_register_info *gpe_register_info;
126 u8 register_bit; 116 u8 register_bit;
127
128
129 ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
130 117
118 ACPI_FUNCTION_TRACE("ev_update_gpe_enable_masks");
131 119
132 gpe_register_info = gpe_event_info->register_info; 120 gpe_register_info = gpe_event_info->register_info;
133 if (!gpe_register_info) { 121 if (!gpe_register_info) {
134 return_ACPI_STATUS (AE_NOT_EXIST); 122 return_ACPI_STATUS(AE_NOT_EXIST);
135 } 123 }
136 register_bit = gpe_event_info->register_bit; 124 register_bit = gpe_event_info->register_bit;
137 125
138 /* 1) Disable case. Simply clear all enable bits */ 126 /* 1) Disable case. Simply clear all enable bits */
139 127
140 if (type == ACPI_GPE_DISABLE) { 128 if (type == ACPI_GPE_DISABLE) {
141 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 129 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
142 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 130 register_bit);
143 return_ACPI_STATUS (AE_OK); 131 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
132 return_ACPI_STATUS(AE_OK);
144 } 133 }
145 134
146 /* 2) Enable case. Set/Clear the appropriate enable bits */ 135 /* 2) Enable case. Set/Clear the appropriate enable bits */
147 136
148 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 137 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
149 case ACPI_GPE_TYPE_WAKE: 138 case ACPI_GPE_TYPE_WAKE:
150 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 139 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
151 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 140 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
152 break; 141 break;
153 142
154 case ACPI_GPE_TYPE_RUNTIME: 143 case ACPI_GPE_TYPE_RUNTIME:
155 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 144 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
156 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 145 register_bit);
146 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
157 break; 147 break;
158 148
159 case ACPI_GPE_TYPE_WAKE_RUN: 149 case ACPI_GPE_TYPE_WAKE_RUN:
160 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 150 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
161 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 151 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
162 break; 152 break;
163 153
164 default: 154 default:
165 return_ACPI_STATUS (AE_BAD_PARAMETER); 155 return_ACPI_STATUS(AE_BAD_PARAMETER);
166 } 156 }
167 157
168 return_ACPI_STATUS (AE_OK); 158 return_ACPI_STATUS(AE_OK);
169} 159}
170 160
171
172/******************************************************************************* 161/*******************************************************************************
173 * 162 *
174 * FUNCTION: acpi_ev_enable_gpe 163 * FUNCTION: acpi_ev_enable_gpe
@@ -184,21 +173,19 @@ acpi_ev_update_gpe_enable_masks (
184 ******************************************************************************/ 173 ******************************************************************************/
185 174
186acpi_status 175acpi_status
187acpi_ev_enable_gpe ( 176acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
188 struct acpi_gpe_event_info *gpe_event_info, 177 u8 write_to_hardware)
189 u8 write_to_hardware)
190{ 178{
191 acpi_status status; 179 acpi_status status;
192
193
194 ACPI_FUNCTION_TRACE ("ev_enable_gpe");
195 180
181 ACPI_FUNCTION_TRACE("ev_enable_gpe");
196 182
197 /* Make sure HW enable masks are updated */ 183 /* Make sure HW enable masks are updated */
198 184
199 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE); 185 status =
200 if (ACPI_FAILURE (status)) { 186 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE);
201 return_ACPI_STATUS (status); 187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
202 } 189 }
203 190
204 /* Mark wake-enabled or HW enable, or both */ 191 /* Mark wake-enabled or HW enable, or both */
@@ -206,41 +193,40 @@ acpi_ev_enable_gpe (
206 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 193 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
207 case ACPI_GPE_TYPE_WAKE: 194 case ACPI_GPE_TYPE_WAKE:
208 195
209 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 196 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
210 break; 197 break;
211 198
212 case ACPI_GPE_TYPE_WAKE_RUN: 199 case ACPI_GPE_TYPE_WAKE_RUN:
213 200
214 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 201 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
215 202
216 /*lint -fallthrough */ 203 /*lint -fallthrough */
217 204
218 case ACPI_GPE_TYPE_RUNTIME: 205 case ACPI_GPE_TYPE_RUNTIME:
219 206
220 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 207 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
221 208
222 if (write_to_hardware) { 209 if (write_to_hardware) {
223 /* Clear the GPE (of stale events), then enable it */ 210 /* Clear the GPE (of stale events), then enable it */
224 211
225 status = acpi_hw_clear_gpe (gpe_event_info); 212 status = acpi_hw_clear_gpe(gpe_event_info);
226 if (ACPI_FAILURE (status)) { 213 if (ACPI_FAILURE(status)) {
227 return_ACPI_STATUS (status); 214 return_ACPI_STATUS(status);
228 } 215 }
229 216
230 /* Enable the requested runtime GPE */ 217 /* Enable the requested runtime GPE */
231 218
232 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 219 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
233 } 220 }
234 break; 221 break;
235 222
236 default: 223 default:
237 return_ACPI_STATUS (AE_BAD_PARAMETER); 224 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 } 225 }
239 226
240 return_ACPI_STATUS (AE_OK); 227 return_ACPI_STATUS(AE_OK);
241} 228}
242 229
243
244/******************************************************************************* 230/*******************************************************************************
245 * 231 *
246 * FUNCTION: acpi_ev_disable_gpe 232 * FUNCTION: acpi_ev_disable_gpe
@@ -253,36 +239,33 @@ acpi_ev_enable_gpe (
253 * 239 *
254 ******************************************************************************/ 240 ******************************************************************************/
255 241
256acpi_status 242acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
257acpi_ev_disable_gpe (
258 struct acpi_gpe_event_info *gpe_event_info)
259{ 243{
260 acpi_status status; 244 acpi_status status;
261
262
263 ACPI_FUNCTION_TRACE ("ev_disable_gpe");
264 245
246 ACPI_FUNCTION_TRACE("ev_disable_gpe");
265 247
266 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) { 248 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
267 return_ACPI_STATUS (AE_OK); 249 return_ACPI_STATUS(AE_OK);
268 } 250 }
269 251
270 /* Make sure HW enable masks are updated */ 252 /* Make sure HW enable masks are updated */
271 253
272 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); 254 status =
273 if (ACPI_FAILURE (status)) { 255 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE);
274 return_ACPI_STATUS (status); 256 if (ACPI_FAILURE(status)) {
257 return_ACPI_STATUS(status);
275 } 258 }
276 259
277 /* Mark wake-disabled or HW disable, or both */ 260 /* Mark wake-disabled or HW disable, or both */
278 261
279 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 262 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
280 case ACPI_GPE_TYPE_WAKE: 263 case ACPI_GPE_TYPE_WAKE:
281 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 264 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
282 break; 265 break;
283 266
284 case ACPI_GPE_TYPE_WAKE_RUN: 267 case ACPI_GPE_TYPE_WAKE_RUN:
285 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 268 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
286 269
287 /*lint -fallthrough */ 270 /*lint -fallthrough */
288 271
@@ -290,18 +273,17 @@ acpi_ev_disable_gpe (
290 273
291 /* Disable the requested runtime GPE */ 274 /* Disable the requested runtime GPE */
292 275
293 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 276 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
294 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 277 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
295 break; 278 break;
296 279
297 default: 280 default:
298 return_ACPI_STATUS (AE_BAD_PARAMETER); 281 return_ACPI_STATUS(AE_BAD_PARAMETER);
299 } 282 }
300 283
301 return_ACPI_STATUS (AE_OK); 284 return_ACPI_STATUS(AE_OK);
302} 285}
303 286
304
305/******************************************************************************* 287/*******************************************************************************
306 * 288 *
307 * FUNCTION: acpi_ev_get_gpe_event_info 289 * FUNCTION: acpi_ev_get_gpe_event_info
@@ -319,18 +301,14 @@ acpi_ev_disable_gpe (
319 * 301 *
320 ******************************************************************************/ 302 ******************************************************************************/
321 303
322struct acpi_gpe_event_info * 304struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
323acpi_ev_get_gpe_event_info ( 305 u32 gpe_number)
324 acpi_handle gpe_device,
325 u32 gpe_number)
326{ 306{
327 union acpi_operand_object *obj_desc; 307 union acpi_operand_object *obj_desc;
328 struct acpi_gpe_block_info *gpe_block; 308 struct acpi_gpe_block_info *gpe_block;
329 acpi_native_uint i; 309 acpi_native_uint i;
330
331
332 ACPI_FUNCTION_ENTRY ();
333 310
311 ACPI_FUNCTION_ENTRY();
334 312
335 /* A NULL gpe_block means use the FADT-defined GPE block(s) */ 313 /* A NULL gpe_block means use the FADT-defined GPE block(s) */
336 314
@@ -340,11 +318,14 @@ acpi_ev_get_gpe_event_info (
340 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { 318 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
341 gpe_block = acpi_gbl_gpe_fadt_blocks[i]; 319 gpe_block = acpi_gbl_gpe_fadt_blocks[i];
342 if (gpe_block) { 320 if (gpe_block) {
343 if ((gpe_number >= gpe_block->block_base_number) && 321 if ((gpe_number >= gpe_block->block_base_number)
344 (gpe_number < gpe_block->block_base_number + 322 && (gpe_number <
345 (gpe_block->register_count * 8))) { 323 gpe_block->block_base_number +
346 return (&gpe_block->event_info[gpe_number - 324 (gpe_block->register_count * 8))) {
347 gpe_block->block_base_number]); 325 return (&gpe_block->
326 event_info[gpe_number -
327 gpe_block->
328 block_base_number]);
348 } 329 }
349 } 330 }
350 } 331 }
@@ -356,23 +337,25 @@ acpi_ev_get_gpe_event_info (
356 337
357 /* A Non-NULL gpe_device means this is a GPE Block Device */ 338 /* A Non-NULL gpe_device means this is a GPE Block Device */
358 339
359 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device); 340 obj_desc =
360 if (!obj_desc || 341 acpi_ns_get_attached_object((struct acpi_namespace_node *)
361 !obj_desc->device.gpe_block) { 342 gpe_device);
343 if (!obj_desc || !obj_desc->device.gpe_block) {
362 return (NULL); 344 return (NULL);
363 } 345 }
364 346
365 gpe_block = obj_desc->device.gpe_block; 347 gpe_block = obj_desc->device.gpe_block;
366 348
367 if ((gpe_number >= gpe_block->block_base_number) && 349 if ((gpe_number >= gpe_block->block_base_number) &&
368 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 350 (gpe_number <
369 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]); 351 gpe_block->block_base_number + (gpe_block->register_count * 8))) {
352 return (&gpe_block->
353 event_info[gpe_number - gpe_block->block_base_number]);
370 } 354 }
371 355
372 return (NULL); 356 return (NULL);
373} 357}
374 358
375
376/******************************************************************************* 359/*******************************************************************************
377 * 360 *
378 * FUNCTION: acpi_ev_gpe_detect 361 * FUNCTION: acpi_ev_gpe_detect
@@ -387,22 +370,20 @@ acpi_ev_get_gpe_event_info (
387 * 370 *
388 ******************************************************************************/ 371 ******************************************************************************/
389 372
390u32 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
391acpi_ev_gpe_detect (
392 struct acpi_gpe_xrupt_info *gpe_xrupt_list)
393{ 374{
394 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
395 u8 enabled_status_byte; 376 u8 enabled_status_byte;
396 struct acpi_gpe_register_info *gpe_register_info; 377 struct acpi_gpe_register_info *gpe_register_info;
397 u32 status_reg; 378 u32 status_reg;
398 u32 enable_reg; 379 u32 enable_reg;
399 acpi_status status; 380 u32 flags;
400 struct acpi_gpe_block_info *gpe_block; 381 acpi_status status;
401 acpi_native_uint i; 382 struct acpi_gpe_block_info *gpe_block;
402 acpi_native_uint j; 383 acpi_native_uint i;
403 384 acpi_native_uint j;
404 385
405 ACPI_FUNCTION_NAME ("ev_gpe_detect"); 386 ACPI_FUNCTION_NAME("ev_gpe_detect");
406 387
407 /* Check for the case where there are no GPEs */ 388 /* Check for the case where there are no GPEs */
408 389
@@ -412,7 +393,7 @@ acpi_ev_gpe_detect (
412 393
413 /* Examine all GPE blocks attached to this interrupt level */ 394 /* Examine all GPE blocks attached to this interrupt level */
414 395
415 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR); 396 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
416 gpe_block = gpe_xrupt_list->gpe_block_list_head; 397 gpe_block = gpe_xrupt_list->gpe_block_list_head;
417 while (gpe_block) { 398 while (gpe_block) {
418 /* 399 /*
@@ -427,23 +408,30 @@ acpi_ev_gpe_detect (
427 408
428 /* Read the Status Register */ 409 /* Read the Status Register */
429 410
430 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg, 411 status =
431 &gpe_register_info->status_address); 412 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
432 if (ACPI_FAILURE (status)) { 413 &status_reg,
414 &gpe_register_info->
415 status_address);
416 if (ACPI_FAILURE(status)) {
433 goto unlock_and_exit; 417 goto unlock_and_exit;
434 } 418 }
435 419
436 /* Read the Enable Register */ 420 /* Read the Enable Register */
437 421
438 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg, 422 status =
439 &gpe_register_info->enable_address); 423 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
440 if (ACPI_FAILURE (status)) { 424 &enable_reg,
425 &gpe_register_info->
426 enable_address);
427 if (ACPI_FAILURE(status)) {
441 goto unlock_and_exit; 428 goto unlock_and_exit;
442 } 429 }
443 430
444 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 431 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
445 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", 432 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
446 gpe_register_info->base_gpe_number, status_reg, enable_reg)); 433 gpe_register_info->base_gpe_number,
434 status_reg, enable_reg));
447 435
448 /* Check if there is anything active at all in this register */ 436 /* Check if there is anything active at all in this register */
449 437
@@ -459,14 +447,21 @@ acpi_ev_gpe_detect (
459 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 447 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
460 /* Examine one GPE bit */ 448 /* Examine one GPE bit */
461 449
462 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) { 450 if (enabled_status_byte &
451 acpi_gbl_decode_to8bit[j]) {
463 /* 452 /*
464 * Found an active GPE. Dispatch the event to a handler 453 * Found an active GPE. Dispatch the event to a handler
465 * or method. 454 * or method.
466 */ 455 */
467 int_status |= acpi_ev_gpe_dispatch ( 456 int_status |=
468 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], 457 acpi_ev_gpe_dispatch(&gpe_block->
469 (u32) j + gpe_register_info->base_gpe_number); 458 event_info[(i *
459 ACPI_GPE_REGISTER_WIDTH)
460 +
461 j],
462 (u32) j +
463 gpe_register_info->
464 base_gpe_number);
470 } 465 }
471 } 466 }
472 } 467 }
@@ -474,13 +469,12 @@ acpi_ev_gpe_detect (
474 gpe_block = gpe_block->next; 469 gpe_block = gpe_block->next;
475 } 470 }
476 471
477unlock_and_exit: 472 unlock_and_exit:
478 473
479 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR); 474 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
480 return (int_status); 475 return (int_status);
481} 476}
482 477
483
484/******************************************************************************* 478/*******************************************************************************
485 * 479 *
486 * FUNCTION: acpi_ev_asynch_execute_gpe_method 480 * FUNCTION: acpi_ev_asynch_execute_gpe_method
@@ -497,45 +491,41 @@ unlock_and_exit:
497 * 491 *
498 ******************************************************************************/ 492 ******************************************************************************/
499 493
500static void ACPI_SYSTEM_XFACE 494static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
501acpi_ev_asynch_execute_gpe_method (
502 void *context)
503{ 495{
504 struct acpi_gpe_event_info *gpe_event_info = (void *) context; 496 struct acpi_gpe_event_info *gpe_event_info = (void *)context;
505 u32 gpe_number = 0; 497 u32 gpe_number = 0;
506 acpi_status status; 498 acpi_status status;
507 struct acpi_gpe_event_info local_gpe_event_info; 499 struct acpi_gpe_event_info local_gpe_event_info;
508 struct acpi_parameter_info info; 500 struct acpi_parameter_info info;
509
510 501
511 ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method"); 502 ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method");
512 503
513 504 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
514 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 505 if (ACPI_FAILURE(status)) {
515 if (ACPI_FAILURE (status)) {
516 return_VOID; 506 return_VOID;
517 } 507 }
518 508
519 /* Must revalidate the gpe_number/gpe_block */ 509 /* Must revalidate the gpe_number/gpe_block */
520 510
521 if (!acpi_ev_valid_gpe_event (gpe_event_info)) { 511 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
522 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 512 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
523 return_VOID; 513 return_VOID;
524 } 514 }
525 515
526 /* Set the GPE flags for return to enabled state */ 516 /* Set the GPE flags for return to enabled state */
527 517
528 (void) acpi_ev_enable_gpe (gpe_event_info, FALSE); 518 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
529 519
530 /* 520 /*
531 * Take a snapshot of the GPE info for this level - we copy the 521 * Take a snapshot of the GPE info for this level - we copy the
532 * info to prevent a race condition with remove_handler/remove_block. 522 * info to prevent a race condition with remove_handler/remove_block.
533 */ 523 */
534 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, 524 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
535 sizeof (struct acpi_gpe_event_info)); 525 sizeof(struct acpi_gpe_event_info));
536 526
537 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 527 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
538 if (ACPI_FAILURE (status)) { 528 if (ACPI_FAILURE(status)) {
539 return_VOID; 529 return_VOID;
540 } 530 }
541 531
@@ -544,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method (
544 * time to avoid race with ev_gpe_install_handler 534 * time to avoid race with ev_gpe_install_handler
545 */ 535 */
546 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 536 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
547 ACPI_GPE_DISPATCH_METHOD) { 537 ACPI_GPE_DISPATCH_METHOD) {
548 /* 538 /*
549 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx 539 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
550 * control method that corresponds to this GPE 540 * control method that corresponds to this GPE
551 */ 541 */
552 info.node = local_gpe_event_info.dispatch.method_node; 542 info.node = local_gpe_event_info.dispatch.method_node;
553 info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info); 543 info.parameters =
544 ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info);
554 info.parameter_type = ACPI_PARAM_GPE; 545 info.parameter_type = ACPI_PARAM_GPE;
555 546
556 status = acpi_ns_evaluate_by_handle (&info); 547 status = acpi_ns_evaluate_by_handle(&info);
557 if (ACPI_FAILURE (status)) { 548 if (ACPI_FAILURE(status)) {
558 ACPI_REPORT_ERROR (( 549 ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number));
559 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
560 acpi_format_exception (status),
561 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
562 gpe_number));
563 } 550 }
564 } 551 }
565 552
566 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == 553 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
567 ACPI_GPE_LEVEL_TRIGGERED) { 554 ACPI_GPE_LEVEL_TRIGGERED) {
568 /* 555 /*
569 * GPE is level-triggered, we clear the GPE status bit after 556 * GPE is level-triggered, we clear the GPE status bit after
570 * handling the event. 557 * handling the event.
571 */ 558 */
572 status = acpi_hw_clear_gpe (&local_gpe_event_info); 559 status = acpi_hw_clear_gpe(&local_gpe_event_info);
573 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
574 return_VOID; 561 return_VOID;
575 } 562 }
576 } 563 }
577 564
578 /* Enable this GPE */ 565 /* Enable this GPE */
579 566
580 (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info); 567 (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info);
581 return_VOID; 568 return_VOID;
582} 569}
583 570
584
585/******************************************************************************* 571/*******************************************************************************
586 * 572 *
587 * FUNCTION: acpi_ev_gpe_dispatch 573 * FUNCTION: acpi_ev_gpe_dispatch
@@ -599,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method (
599 ******************************************************************************/ 585 ******************************************************************************/
600 586
601u32 587u32
602acpi_ev_gpe_dispatch ( 588acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
603 struct acpi_gpe_event_info *gpe_event_info,
604 u32 gpe_number)
605{ 589{
606 acpi_status status; 590 acpi_status status;
607
608
609 ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
610 591
592 ACPI_FUNCTION_TRACE("ev_gpe_dispatch");
611 593
612 /* 594 /*
613 * If edge-triggered, clear the GPE status bit now. Note that 595 * If edge-triggered, clear the GPE status bit now. Note that
614 * level-triggered events are cleared after the GPE is serviced. 596 * level-triggered events are cleared after the GPE is serviced.
615 */ 597 */
616 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 598 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
617 ACPI_GPE_EDGE_TRIGGERED) { 599 ACPI_GPE_EDGE_TRIGGERED) {
618 status = acpi_hw_clear_gpe (gpe_event_info); 600 status = acpi_hw_clear_gpe(gpe_event_info);
619 if (ACPI_FAILURE (status)) { 601 if (ACPI_FAILURE(status)) {
620 ACPI_REPORT_ERROR (( 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
621 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
622 acpi_format_exception (status), gpe_number));
623 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
624 } 604 }
625 } 605 }
626 606
627 /* Save current system state */ 607 /* Save current system state */
628 608
629 if (acpi_gbl_system_awake_and_running) { 609 if (acpi_gbl_system_awake_and_running) {
630 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); 610 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
631 } 611 } else {
632 else { 612 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
633 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
634 } 613 }
635 614
636 /* 615 /*
@@ -647,19 +626,19 @@ acpi_ev_gpe_dispatch (
647 * Invoke the installed handler (at interrupt level) 626 * Invoke the installed handler (at interrupt level)
648 * Ignore return status for now. TBD: leave GPE disabled on error? 627 * Ignore return status for now. TBD: leave GPE disabled on error?
649 */ 628 */
650 (void) gpe_event_info->dispatch.handler->address ( 629 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
651 gpe_event_info->dispatch.handler->context); 630 dispatch.
631 handler->
632 context);
652 633
653 /* It is now safe to clear level-triggered events. */ 634 /* It is now safe to clear level-triggered events. */
654 635
655 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 636 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
656 ACPI_GPE_LEVEL_TRIGGERED) { 637 ACPI_GPE_LEVEL_TRIGGERED) {
657 status = acpi_hw_clear_gpe (gpe_event_info); 638 status = acpi_hw_clear_gpe(gpe_event_info);
658 if (ACPI_FAILURE (status)) { 639 if (ACPI_FAILURE(status)) {
659 ACPI_REPORT_ERROR (( 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
660 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
661 acpi_format_exception (status), gpe_number));
662 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
663 } 642 }
664 } 643 }
665 break; 644 break;
@@ -670,24 +649,21 @@ acpi_ev_gpe_dispatch (
670 * Disable GPE, so it doesn't keep firing before the method has a 649 * Disable GPE, so it doesn't keep firing before the method has a
671 * chance to run. 650 * chance to run.
672 */ 651 */
673 status = acpi_ev_disable_gpe (gpe_event_info); 652 status = acpi_ev_disable_gpe(gpe_event_info);
674 if (ACPI_FAILURE (status)) { 653 if (ACPI_FAILURE(status)) {
675 ACPI_REPORT_ERROR (( 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
676 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
677 acpi_format_exception (status), gpe_number));
678 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
679 } 656 }
680 657
681 /* 658 /*
682 * Execute the method associated with the GPE 659 * Execute the method associated with the GPE
683 * NOTE: Level-triggered GPEs are cleared after the method completes. 660 * NOTE: Level-triggered GPEs are cleared after the method completes.
684 */ 661 */
685 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE, 662 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
686 acpi_ev_asynch_execute_gpe_method, gpe_event_info); 663 acpi_ev_asynch_execute_gpe_method,
687 if (ACPI_FAILURE (status)) { 664 gpe_event_info);
688 ACPI_REPORT_ERROR (( 665 if (ACPI_FAILURE(status)) {
689 "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", 666 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number));
690 acpi_format_exception (status), gpe_number));
691 } 667 }
692 break; 668 break;
693 669
@@ -695,28 +671,23 @@ acpi_ev_gpe_dispatch (
695 671
696 /* No handler or method to run! */ 672 /* No handler or method to run! */
697 673
698 ACPI_REPORT_ERROR (( 674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number));
699 "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
700 gpe_number));
701 675
702 /* 676 /*
703 * Disable the GPE. The GPE will remain disabled until the ACPI 677 * Disable the GPE. The GPE will remain disabled until the ACPI
704 * Core Subsystem is restarted, or a handler is installed. 678 * Core Subsystem is restarted, or a handler is installed.
705 */ 679 */
706 status = acpi_ev_disable_gpe (gpe_event_info); 680 status = acpi_ev_disable_gpe(gpe_event_info);
707 if (ACPI_FAILURE (status)) { 681 if (ACPI_FAILURE(status)) {
708 ACPI_REPORT_ERROR (( 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
709 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
710 acpi_format_exception (status), gpe_number));
711 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
712 } 684 }
713 break; 685 break;
714 } 686 }
715 687
716 return_VALUE (ACPI_INTERRUPT_HANDLED); 688 return_VALUE(ACPI_INTERRUPT_HANDLED);
717} 689}
718 690
719
720#ifdef ACPI_GPE_NOTIFY_CHECK 691#ifdef ACPI_GPE_NOTIFY_CHECK
721/******************************************************************************* 692/*******************************************************************************
722 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED 693 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
@@ -735,35 +706,29 @@ acpi_ev_gpe_dispatch (
735 ******************************************************************************/ 706 ******************************************************************************/
736 707
737acpi_status 708acpi_status
738acpi_ev_check_for_wake_only_gpe ( 709acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
739 struct acpi_gpe_event_info *gpe_event_info)
740{ 710{
741 acpi_status status; 711 acpi_status status;
742 712
713 ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe");
743 714
744 ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe"); 715 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
745 716 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */
746
747 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
748 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
749 /* This must be a wake-only GPE, disable it */ 717 /* This must be a wake-only GPE, disable it */
750 718
751 status = acpi_ev_disable_gpe (gpe_event_info); 719 status = acpi_ev_disable_gpe(gpe_event_info);
752 720
753 /* Set GPE to wake-only. Do not change wake disabled/enabled status */ 721 /* Set GPE to wake-only. Do not change wake disabled/enabled status */
754 722
755 acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 723 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
756 724
757 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", 725 ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info));
758 gpe_event_info));
759 726
760 /* This was a wake-only GPE */ 727 /* This was a wake-only GPE */
761 728
762 return_ACPI_STATUS (AE_WAKE_ONLY_GPE); 729 return_ACPI_STATUS(AE_WAKE_ONLY_GPE);
763 } 730 }
764 731
765 return_ACPI_STATUS (AE_OK); 732 return_ACPI_STATUS(AE_OK);
766} 733}
767#endif 734#endif
768
769
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 84186a7d17b2..b312eb33c43e 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -46,41 +46,29 @@
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpeblk") 49ACPI_MODULE_NAME("evgpeblk")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52
53static acpi_status 52static acpi_status
54acpi_ev_save_method_info ( 53acpi_ev_save_method_info(acpi_handle obj_handle,
55 acpi_handle obj_handle, 54 u32 level, void *obj_desc, void **return_value);
56 u32 level,
57 void *obj_desc,
58 void **return_value);
59 55
60static acpi_status 56static acpi_status
61acpi_ev_match_prw_and_gpe ( 57acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
62 acpi_handle obj_handle, 58 u32 level, void *info, void **return_value);
63 u32 level,
64 void *info,
65 void **return_value);
66 59
67static struct acpi_gpe_xrupt_info * 60static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
68acpi_ev_get_gpe_xrupt_block ( 61 interrupt_number);
69 u32 interrupt_level);
70 62
71static acpi_status 63static acpi_status
72acpi_ev_delete_gpe_xrupt ( 64acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
73 struct acpi_gpe_xrupt_info *gpe_xrupt);
74 65
75static acpi_status 66static acpi_status
76acpi_ev_install_gpe_block ( 67acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
77 struct acpi_gpe_block_info *gpe_block, 68 u32 interrupt_number);
78 u32 interrupt_level);
79 69
80static acpi_status 70static acpi_status
81acpi_ev_create_gpe_info_blocks ( 71acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
82 struct acpi_gpe_block_info *gpe_block);
83
84 72
85/******************************************************************************* 73/*******************************************************************************
86 * 74 *
@@ -96,16 +84,12 @@ acpi_ev_create_gpe_info_blocks (
96 * 84 *
97 ******************************************************************************/ 85 ******************************************************************************/
98 86
99u8 87u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
100acpi_ev_valid_gpe_event (
101 struct acpi_gpe_event_info *gpe_event_info)
102{ 88{
103 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 89 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
104 struct acpi_gpe_block_info *gpe_block; 90 struct acpi_gpe_block_info *gpe_block;
105
106
107 ACPI_FUNCTION_ENTRY ();
108 91
92 ACPI_FUNCTION_ENTRY();
109 93
110 /* No need for spin lock since we are not changing any list elements */ 94 /* No need for spin lock since we are not changing any list elements */
111 95
@@ -119,7 +103,10 @@ acpi_ev_valid_gpe_event (
119 103
120 while (gpe_block) { 104 while (gpe_block) {
121 if ((&gpe_block->event_info[0] <= gpe_event_info) && 105 if ((&gpe_block->event_info[0] <= gpe_event_info) &&
122 (&gpe_block->event_info[((acpi_size) gpe_block->register_count) * 8] > gpe_event_info)) { 106 (&gpe_block->
107 event_info[((acpi_size) gpe_block->
108 register_count) * 8] >
109 gpe_event_info)) {
123 return (TRUE); 110 return (TRUE);
124 } 111 }
125 112
@@ -132,13 +119,11 @@ acpi_ev_valid_gpe_event (
132 return (FALSE); 119 return (FALSE);
133} 120}
134 121
135
136/******************************************************************************* 122/*******************************************************************************
137 * 123 *
138 * FUNCTION: acpi_ev_walk_gpe_list 124 * FUNCTION: acpi_ev_walk_gpe_list
139 * 125 *
140 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block 126 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
141 * Flags - ACPI_NOT_ISR or ACPI_ISR
142 * 127 *
143 * RETURN: Status 128 * RETURN: Status
144 * 129 *
@@ -146,20 +131,16 @@ acpi_ev_valid_gpe_event (
146 * 131 *
147 ******************************************************************************/ 132 ******************************************************************************/
148 133
149acpi_status 134acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
150acpi_ev_walk_gpe_list (
151 ACPI_GPE_CALLBACK gpe_walk_callback,
152 u32 flags)
153{ 135{
154 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
155 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
156 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
157 139 u32 flags;
158 140
159 ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
160 142
161 143 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
162 acpi_os_acquire_lock (acpi_gbl_gpe_lock, flags);
163 144
164 /* Walk the interrupt level descriptor list */ 145 /* Walk the interrupt level descriptor list */
165 146
@@ -171,8 +152,8 @@ acpi_ev_walk_gpe_list (
171 while (gpe_block) { 152 while (gpe_block) {
172 /* One callback per GPE block */ 153 /* One callback per GPE block */
173 154
174 status = gpe_walk_callback (gpe_xrupt_info, gpe_block); 155 status = gpe_walk_callback(gpe_xrupt_info, gpe_block);
175 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
176 goto unlock_and_exit; 157 goto unlock_and_exit;
177 } 158 }
178 159
@@ -182,12 +163,11 @@ acpi_ev_walk_gpe_list (
182 gpe_xrupt_info = gpe_xrupt_info->next; 163 gpe_xrupt_info = gpe_xrupt_info->next;
183 } 164 }
184 165
185unlock_and_exit: 166 unlock_and_exit:
186 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 167 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
187 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
188} 169}
189 170
190
191/******************************************************************************* 171/*******************************************************************************
192 * 172 *
193 * FUNCTION: acpi_ev_delete_gpe_handlers 173 * FUNCTION: acpi_ev_delete_gpe_handlers
@@ -203,17 +183,14 @@ unlock_and_exit:
203 ******************************************************************************/ 183 ******************************************************************************/
204 184
205acpi_status 185acpi_status
206acpi_ev_delete_gpe_handlers ( 186acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
207 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 187 struct acpi_gpe_block_info *gpe_block)
208 struct acpi_gpe_block_info *gpe_block)
209{ 188{
210 struct acpi_gpe_event_info *gpe_event_info; 189 struct acpi_gpe_event_info *gpe_event_info;
211 acpi_native_uint i; 190 acpi_native_uint i;
212 acpi_native_uint j; 191 acpi_native_uint j;
213
214
215 ACPI_FUNCTION_TRACE ("ev_delete_gpe_handlers");
216 192
193 ACPI_FUNCTION_TRACE("ev_delete_gpe_handlers");
217 194
218 /* Examine each GPE Register within the block */ 195 /* Examine each GPE Register within the block */
219 196
@@ -221,21 +198,23 @@ acpi_ev_delete_gpe_handlers (
221 /* Now look at the individual GPEs in this byte register */ 198 /* Now look at the individual GPEs in this byte register */
222 199
223 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 200 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
224 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; 201 gpe_event_info =
202 &gpe_block->
203 event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
225 204
226 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 205 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
227 ACPI_GPE_DISPATCH_HANDLER) { 206 ACPI_GPE_DISPATCH_HANDLER) {
228 ACPI_MEM_FREE (gpe_event_info->dispatch.handler); 207 ACPI_MEM_FREE(gpe_event_info->dispatch.handler);
229 gpe_event_info->dispatch.handler = NULL; 208 gpe_event_info->dispatch.handler = NULL;
230 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; 209 gpe_event_info->flags &=
210 ~ACPI_GPE_DISPATCH_MASK;
231 } 211 }
232 } 212 }
233 } 213 }
234 214
235 return_ACPI_STATUS (AE_OK); 215 return_ACPI_STATUS(AE_OK);
236} 216}
237 217
238
239/******************************************************************************* 218/*******************************************************************************
240 * 219 *
241 * FUNCTION: acpi_ev_save_method_info 220 * FUNCTION: acpi_ev_save_method_info
@@ -259,30 +238,26 @@ acpi_ev_delete_gpe_handlers (
259 ******************************************************************************/ 238 ******************************************************************************/
260 239
261static acpi_status 240static acpi_status
262acpi_ev_save_method_info ( 241acpi_ev_save_method_info(acpi_handle obj_handle,
263 acpi_handle obj_handle, 242 u32 level, void *obj_desc, void **return_value)
264 u32 level,
265 void *obj_desc,
266 void **return_value)
267{ 243{
268 struct acpi_gpe_block_info *gpe_block = (void *) obj_desc; 244 struct acpi_gpe_block_info *gpe_block = (void *)obj_desc;
269 struct acpi_gpe_event_info *gpe_event_info; 245 struct acpi_gpe_event_info *gpe_event_info;
270 u32 gpe_number; 246 u32 gpe_number;
271 char name[ACPI_NAME_SIZE + 1]; 247 char name[ACPI_NAME_SIZE + 1];
272 u8 type; 248 u8 type;
273 acpi_status status; 249 acpi_status status;
274
275
276 ACPI_FUNCTION_TRACE ("ev_save_method_info");
277 250
251 ACPI_FUNCTION_TRACE("ev_save_method_info");
278 252
279 /* 253 /*
280 * _Lxx and _Exx GPE method support 254 * _Lxx and _Exx GPE method support
281 * 255 *
282 * 1) Extract the name from the object and convert to a string 256 * 1) Extract the name from the object and convert to a string
283 */ 257 */
284 ACPI_MOVE_32_TO_32 (name, 258 ACPI_MOVE_32_TO_32(name,
285 &((struct acpi_namespace_node *) obj_handle)->name.integer); 259 &((struct acpi_namespace_node *)obj_handle)->name.
260 integer);
286 name[ACPI_NAME_SIZE] = 0; 261 name[ACPI_NAME_SIZE] = 0;
287 262
288 /* 263 /*
@@ -304,34 +279,36 @@ acpi_ev_save_method_info (
304 default: 279 default:
305 /* Unknown method type, just ignore it! */ 280 /* Unknown method type, just ignore it! */
306 281
307 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
308 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", 283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n",
309 name)); 284 name));
310 return_ACPI_STATUS (AE_OK); 285 return_ACPI_STATUS(AE_OK);
311 } 286 }
312 287
313 /* Convert the last two characters of the name to the GPE Number */ 288 /* Convert the last two characters of the name to the GPE Number */
314 289
315 gpe_number = ACPI_STRTOUL (&name[2], NULL, 16); 290 gpe_number = ACPI_STRTOUL(&name[2], NULL, 16);
316 if (gpe_number == ACPI_UINT32_MAX) { 291 if (gpe_number == ACPI_UINT32_MAX) {
317 /* Conversion failed; invalid method, just ignore it */ 292 /* Conversion failed; invalid method, just ignore it */
318 293
319 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
320 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", 295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n",
321 name)); 296 name));
322 return_ACPI_STATUS (AE_OK); 297 return_ACPI_STATUS(AE_OK);
323 } 298 }
324 299
325 /* Ensure that we have a valid GPE number for this GPE block */ 300 /* Ensure that we have a valid GPE number for this GPE block */
326 301
327 if ((gpe_number < gpe_block->block_base_number) || 302 if ((gpe_number < gpe_block->block_base_number) ||
328 (gpe_number >= (gpe_block->block_base_number + (gpe_block->register_count * 8)))) { 303 (gpe_number >=
304 (gpe_block->block_base_number +
305 (gpe_block->register_count * 8)))) {
329 /* 306 /*
330 * Not valid for this GPE block, just ignore it 307 * Not valid for this GPE block, just ignore it
331 * However, it may be valid for a different GPE block, since GPE0 and GPE1 308 * However, it may be valid for a different GPE block, since GPE0 and GPE1
332 * methods both appear under \_GPE. 309 * methods both appear under \_GPE.
333 */ 310 */
334 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
335 } 312 }
336 313
337 /* 314 /*
@@ -339,24 +316,25 @@ acpi_ev_save_method_info (
339 * for use during dispatch of this GPE. Default type is RUNTIME, although 316 * for use during dispatch of this GPE. Default type is RUNTIME, although
340 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
341 */ 318 */
342 gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
343 321
344 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD |
345 ACPI_GPE_TYPE_RUNTIME); 323 ACPI_GPE_TYPE_RUNTIME);
346 324
347 gpe_event_info->dispatch.method_node = (struct acpi_namespace_node *) obj_handle; 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle;
348 327
349 /* Update enable mask, but don't enable the HW GPE as of yet */ 328 /* Update enable mask, but don't enable the HW GPE as of yet */
350 329
351 status = acpi_ev_enable_gpe (gpe_event_info, FALSE); 330 status = acpi_ev_enable_gpe(gpe_event_info, FALSE);
352 331
353 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, 332 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
354 "Registered GPE method %s as GPE number 0x%.2X\n", 333 "Registered GPE method %s as GPE number 0x%.2X\n",
355 name, gpe_number)); 334 name, gpe_number));
356 return_ACPI_STATUS (status); 335 return_ACPI_STATUS(status);
357} 336}
358 337
359
360/******************************************************************************* 338/*******************************************************************************
361 * 339 *
362 * FUNCTION: acpi_ev_match_prw_and_gpe 340 * FUNCTION: acpi_ev_match_prw_and_gpe
@@ -373,34 +351,29 @@ acpi_ev_save_method_info (
373 ******************************************************************************/ 351 ******************************************************************************/
374 352
375static acpi_status 353static acpi_status
376acpi_ev_match_prw_and_gpe ( 354acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
377 acpi_handle obj_handle, 355 u32 level, void *info, void **return_value)
378 u32 level,
379 void *info,
380 void **return_value)
381{ 356{
382 struct acpi_gpe_walk_info *gpe_info = (void *) info; 357 struct acpi_gpe_walk_info *gpe_info = (void *)info;
383 struct acpi_namespace_node *gpe_device; 358 struct acpi_namespace_node *gpe_device;
384 struct acpi_gpe_block_info *gpe_block; 359 struct acpi_gpe_block_info *gpe_block;
385 struct acpi_namespace_node *target_gpe_device; 360 struct acpi_namespace_node *target_gpe_device;
386 struct acpi_gpe_event_info *gpe_event_info; 361 struct acpi_gpe_event_info *gpe_event_info;
387 union acpi_operand_object *pkg_desc; 362 union acpi_operand_object *pkg_desc;
388 union acpi_operand_object *obj_desc; 363 union acpi_operand_object *obj_desc;
389 u32 gpe_number; 364 u32 gpe_number;
390 acpi_status status; 365 acpi_status status;
391 366
392 367 ACPI_FUNCTION_TRACE("ev_match_prw_and_gpe");
393 ACPI_FUNCTION_TRACE ("ev_match_prw_and_gpe");
394
395 368
396 /* Check for a _PRW method under this device */ 369 /* Check for a _PRW method under this device */
397 370
398 status = acpi_ut_evaluate_object (obj_handle, METHOD_NAME__PRW, 371 status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW,
399 ACPI_BTYPE_PACKAGE, &pkg_desc); 372 ACPI_BTYPE_PACKAGE, &pkg_desc);
400 if (ACPI_FAILURE (status)) { 373 if (ACPI_FAILURE(status)) {
401 /* Ignore all errors from _PRW, we don't want to abort the subsystem */ 374 /* Ignore all errors from _PRW, we don't want to abort the subsystem */
402 375
403 return_ACPI_STATUS (AE_OK); 376 return_ACPI_STATUS(AE_OK);
404 } 377 }
405 378
406 /* The returned _PRW package must have at least two elements */ 379 /* The returned _PRW package must have at least two elements */
@@ -420,7 +393,7 @@ acpi_ev_match_prw_and_gpe (
420 */ 393 */
421 obj_desc = pkg_desc->package.elements[0]; 394 obj_desc = pkg_desc->package.elements[0];
422 395
423 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 396 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
424 /* Use FADT-defined GPE device (from definition of _PRW) */ 397 /* Use FADT-defined GPE device (from definition of _PRW) */
425 398
426 target_gpe_device = acpi_gbl_fadt_gpe_device; 399 target_gpe_device = acpi_gbl_fadt_gpe_device;
@@ -428,22 +401,23 @@ acpi_ev_match_prw_and_gpe (
428 /* Integer is the GPE number in the FADT described GPE blocks */ 401 /* Integer is the GPE number in the FADT described GPE blocks */
429 402
430 gpe_number = (u32) obj_desc->integer.value; 403 gpe_number = (u32) obj_desc->integer.value;
431 } 404 } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
432 else if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) {
433 /* Package contains a GPE reference and GPE number within a GPE block */ 405 /* Package contains a GPE reference and GPE number within a GPE block */
434 406
435 if ((obj_desc->package.count < 2) || 407 if ((obj_desc->package.count < 2) ||
436 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || 408 (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) !=
437 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[1]) != ACPI_TYPE_INTEGER)) { 409 ACPI_TYPE_LOCAL_REFERENCE)
410 || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) !=
411 ACPI_TYPE_INTEGER)) {
438 goto cleanup; 412 goto cleanup;
439 } 413 }
440 414
441 /* Get GPE block reference and decode */ 415 /* Get GPE block reference and decode */
442 416
443 target_gpe_device = obj_desc->package.elements[0]->reference.node; 417 target_gpe_device =
418 obj_desc->package.elements[0]->reference.node;
444 gpe_number = (u32) obj_desc->package.elements[1]->integer.value; 419 gpe_number = (u32) obj_desc->package.elements[1]->integer.value;
445 } 420 } else {
446 else {
447 /* Unknown type, just ignore it */ 421 /* Unknown type, just ignore it */
448 422
449 goto cleanup; 423 goto cleanup;
@@ -458,31 +432,37 @@ acpi_ev_match_prw_and_gpe (
458 * associated with the GPE device. 432 * associated with the GPE device.
459 */ 433 */
460 if ((gpe_device == target_gpe_device) && 434 if ((gpe_device == target_gpe_device) &&
461 (gpe_number >= gpe_block->block_base_number) && 435 (gpe_number >= gpe_block->block_base_number) &&
462 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 436 (gpe_number <
463 gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 437 gpe_block->block_base_number + (gpe_block->register_count * 8))) {
438 gpe_event_info =
439 &gpe_block->event_info[gpe_number -
440 gpe_block->block_base_number];
464 441
465 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ 442 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
466 443
467 gpe_event_info->flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 444 gpe_event_info->flags &=
468 status = acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
469 if (ACPI_FAILURE (status)) { 446 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) {
470 goto cleanup; 449 goto cleanup;
471 } 450 }
472 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); 451 status =
452 acpi_ev_update_gpe_enable_masks(gpe_event_info,
453 ACPI_GPE_DISABLE);
473 } 454 }
474 455
475cleanup: 456 cleanup:
476 acpi_ut_remove_reference (pkg_desc); 457 acpi_ut_remove_reference(pkg_desc);
477 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS(AE_OK);
478} 459}
479 460
480
481/******************************************************************************* 461/*******************************************************************************
482 * 462 *
483 * FUNCTION: acpi_ev_get_gpe_xrupt_block 463 * FUNCTION: acpi_ev_get_gpe_xrupt_block
484 * 464 *
485 * PARAMETERS: interrupt_level - Interrupt for a GPE block 465 * PARAMETERS: interrupt_number - Interrupt for a GPE block
486 * 466 *
487 * RETURN: A GPE interrupt block 467 * RETURN: A GPE interrupt block
488 * 468 *
@@ -493,24 +473,22 @@ cleanup:
493 * 473 *
494 ******************************************************************************/ 474 ******************************************************************************/
495 475
496static struct acpi_gpe_xrupt_info * 476static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
497acpi_ev_get_gpe_xrupt_block ( 477 interrupt_number)
498 u32 interrupt_level)
499{ 478{
500 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 479 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
501 struct acpi_gpe_xrupt_info *gpe_xrupt; 480 struct acpi_gpe_xrupt_info *gpe_xrupt;
502 acpi_status status; 481 acpi_status status;
503 482 u32 flags;
504
505 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
506 483
484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block");
507 485
508 /* No need for lock since we are not changing any list elements here */ 486 /* No need for lock since we are not changing any list elements here */
509 487
510 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 488 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
511 while (next_gpe_xrupt) { 489 while (next_gpe_xrupt) {
512 if (next_gpe_xrupt->interrupt_level == interrupt_level) { 490 if (next_gpe_xrupt->interrupt_number == interrupt_number) {
513 return_PTR (next_gpe_xrupt); 491 return_PTR(next_gpe_xrupt);
514 } 492 }
515 493
516 next_gpe_xrupt = next_gpe_xrupt->next; 494 next_gpe_xrupt = next_gpe_xrupt->next;
@@ -518,16 +496,16 @@ acpi_ev_get_gpe_xrupt_block (
518 496
519 /* Not found, must allocate a new xrupt descriptor */ 497 /* Not found, must allocate a new xrupt descriptor */
520 498
521 gpe_xrupt = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_xrupt_info)); 499 gpe_xrupt = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_xrupt_info));
522 if (!gpe_xrupt) { 500 if (!gpe_xrupt) {
523 return_PTR (NULL); 501 return_PTR(NULL);
524 } 502 }
525 503
526 gpe_xrupt->interrupt_level = interrupt_level; 504 gpe_xrupt->interrupt_number = interrupt_number;
527 505
528 /* Install new interrupt descriptor with spin lock */ 506 /* Install new interrupt descriptor with spin lock */
529 507
530 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 508 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
531 if (acpi_gbl_gpe_xrupt_list_head) { 509 if (acpi_gbl_gpe_xrupt_list_head) {
532 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 510 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
533 while (next_gpe_xrupt->next) { 511 while (next_gpe_xrupt->next) {
@@ -536,29 +514,28 @@ acpi_ev_get_gpe_xrupt_block (
536 514
537 next_gpe_xrupt->next = gpe_xrupt; 515 next_gpe_xrupt->next = gpe_xrupt;
538 gpe_xrupt->previous = next_gpe_xrupt; 516 gpe_xrupt->previous = next_gpe_xrupt;
539 } 517 } else {
540 else {
541 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; 518 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
542 } 519 }
543 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 520 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
544 521
545 /* Install new interrupt handler if not SCI_INT */ 522 /* Install new interrupt handler if not SCI_INT */
546 523
547 if (interrupt_level != acpi_gbl_FADT->sci_int) { 524 if (interrupt_number != acpi_gbl_FADT->sci_int) {
548 status = acpi_os_install_interrupt_handler (interrupt_level, 525 status = acpi_os_install_interrupt_handler(interrupt_number,
549 acpi_ev_gpe_xrupt_handler, gpe_xrupt); 526 acpi_ev_gpe_xrupt_handler,
550 if (ACPI_FAILURE (status)) { 527 gpe_xrupt);
551 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 528 if (ACPI_FAILURE(status)) {
552 "Could not install GPE interrupt handler at level 0x%X\n", 529 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
553 interrupt_level)); 530 "Could not install GPE interrupt handler at level 0x%X\n",
554 return_PTR (NULL); 531 interrupt_number));
532 return_PTR(NULL);
555 } 533 }
556 } 534 }
557 535
558 return_PTR (gpe_xrupt); 536 return_PTR(gpe_xrupt);
559} 537}
560 538
561
562/******************************************************************************* 539/*******************************************************************************
563 * 540 *
564 * FUNCTION: acpi_ev_delete_gpe_xrupt 541 * FUNCTION: acpi_ev_delete_gpe_xrupt
@@ -573,33 +550,31 @@ acpi_ev_get_gpe_xrupt_block (
573 ******************************************************************************/ 550 ******************************************************************************/
574 551
575static acpi_status 552static acpi_status
576acpi_ev_delete_gpe_xrupt ( 553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
577 struct acpi_gpe_xrupt_info *gpe_xrupt)
578{ 554{
579 acpi_status status; 555 acpi_status status;
580 556 u32 flags;
581
582 ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
583 557
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
584 559
585 /* We never want to remove the SCI interrupt handler */ 560 /* We never want to remove the SCI interrupt handler */
586 561
587 if (gpe_xrupt->interrupt_level == acpi_gbl_FADT->sci_int) { 562 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) {
588 gpe_xrupt->gpe_block_list_head = NULL; 563 gpe_xrupt->gpe_block_list_head = NULL;
589 return_ACPI_STATUS (AE_OK); 564 return_ACPI_STATUS(AE_OK);
590 } 565 }
591 566
592 /* Disable this interrupt */ 567 /* Disable this interrupt */
593 568
594 status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_level, 569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
595 acpi_ev_gpe_xrupt_handler); 570 acpi_ev_gpe_xrupt_handler);
596 if (ACPI_FAILURE (status)) { 571 if (ACPI_FAILURE(status)) {
597 return_ACPI_STATUS (status); 572 return_ACPI_STATUS(status);
598 } 573 }
599 574
600 /* Unlink the interrupt block with lock */ 575 /* Unlink the interrupt block with lock */
601 576
602 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 577 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
603 if (gpe_xrupt->previous) { 578 if (gpe_xrupt->previous) {
604 gpe_xrupt->previous->next = gpe_xrupt->next; 579 gpe_xrupt->previous->next = gpe_xrupt->next;
605 } 580 }
@@ -607,21 +582,20 @@ acpi_ev_delete_gpe_xrupt (
607 if (gpe_xrupt->next) { 582 if (gpe_xrupt->next) {
608 gpe_xrupt->next->previous = gpe_xrupt->previous; 583 gpe_xrupt->next->previous = gpe_xrupt->previous;
609 } 584 }
610 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 585 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
611 586
612 /* Free the block */ 587 /* Free the block */
613 588
614 ACPI_MEM_FREE (gpe_xrupt); 589 ACPI_MEM_FREE(gpe_xrupt);
615 return_ACPI_STATUS (AE_OK); 590 return_ACPI_STATUS(AE_OK);
616} 591}
617 592
618
619/******************************************************************************* 593/*******************************************************************************
620 * 594 *
621 * FUNCTION: acpi_ev_install_gpe_block 595 * FUNCTION: acpi_ev_install_gpe_block
622 * 596 *
623 * PARAMETERS: gpe_block - New GPE block 597 * PARAMETERS: gpe_block - New GPE block
624 * interrupt_level - Level to be associated with this GPE block 598 * interrupt_number - Xrupt to be associated with this GPE block
625 * 599 *
626 * RETURN: Status 600 * RETURN: Status
627 * 601 *
@@ -630,24 +604,22 @@ acpi_ev_delete_gpe_xrupt (
630 ******************************************************************************/ 604 ******************************************************************************/
631 605
632static acpi_status 606static acpi_status
633acpi_ev_install_gpe_block ( 607acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
634 struct acpi_gpe_block_info *gpe_block, 608 u32 interrupt_number)
635 u32 interrupt_level)
636{ 609{
637 struct acpi_gpe_block_info *next_gpe_block; 610 struct acpi_gpe_block_info *next_gpe_block;
638 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 611 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
639 acpi_status status; 612 acpi_status status;
613 u32 flags;
640 614
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
641 616
642 ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); 617 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
643 618 if (ACPI_FAILURE(status)) {
644 619 return_ACPI_STATUS(status);
645 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
646 if (ACPI_FAILURE (status)) {
647 return_ACPI_STATUS (status);
648 } 620 }
649 621
650 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_level); 622 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number);
651 if (!gpe_xrupt_block) { 623 if (!gpe_xrupt_block) {
652 status = AE_NO_MEMORY; 624 status = AE_NO_MEMORY;
653 goto unlock_and_exit; 625 goto unlock_and_exit;
@@ -655,7 +627,7 @@ acpi_ev_install_gpe_block (
655 627
656 /* Install the new block at the end of the list with lock */ 628 /* Install the new block at the end of the list with lock */
657 629
658 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 630 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
659 if (gpe_xrupt_block->gpe_block_list_head) { 631 if (gpe_xrupt_block->gpe_block_list_head) {
660 next_gpe_block = gpe_xrupt_block->gpe_block_list_head; 632 next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
661 while (next_gpe_block->next) { 633 while (next_gpe_block->next) {
@@ -664,20 +636,18 @@ acpi_ev_install_gpe_block (
664 636
665 next_gpe_block->next = gpe_block; 637 next_gpe_block->next = gpe_block;
666 gpe_block->previous = next_gpe_block; 638 gpe_block->previous = next_gpe_block;
667 } 639 } else {
668 else {
669 gpe_xrupt_block->gpe_block_list_head = gpe_block; 640 gpe_xrupt_block->gpe_block_list_head = gpe_block;
670 } 641 }
671 642
672 gpe_block->xrupt_block = gpe_xrupt_block; 643 gpe_block->xrupt_block = gpe_xrupt_block;
673 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 644 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
674 645
675unlock_and_exit: 646 unlock_and_exit:
676 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 647 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
677 return_ACPI_STATUS (status); 648 return_ACPI_STATUS(status);
678} 649}
679 650
680
681/******************************************************************************* 651/*******************************************************************************
682 * 652 *
683 * FUNCTION: acpi_ev_delete_gpe_block 653 * FUNCTION: acpi_ev_delete_gpe_block
@@ -690,62 +660,57 @@ unlock_and_exit:
690 * 660 *
691 ******************************************************************************/ 661 ******************************************************************************/
692 662
693acpi_status 663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
694acpi_ev_delete_gpe_block (
695 struct acpi_gpe_block_info *gpe_block)
696{ 664{
697 acpi_status status; 665 acpi_status status;
698 666 u32 flags;
699
700 ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
701 667
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
702 669
703 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 670 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
704 if (ACPI_FAILURE (status)) { 671 if (ACPI_FAILURE(status)) {
705 return_ACPI_STATUS (status); 672 return_ACPI_STATUS(status);
706 } 673 }
707 674
708 /* Disable all GPEs in this block */ 675 /* Disable all GPEs in this block */
709 676
710 status = acpi_hw_disable_gpe_block (gpe_block->xrupt_block, gpe_block); 677 status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block);
711 678
712 if (!gpe_block->previous && !gpe_block->next) { 679 if (!gpe_block->previous && !gpe_block->next) {
713 /* This is the last gpe_block on this interrupt */ 680 /* This is the last gpe_block on this interrupt */
714 681
715 status = acpi_ev_delete_gpe_xrupt (gpe_block->xrupt_block); 682 status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block);
716 if (ACPI_FAILURE (status)) { 683 if (ACPI_FAILURE(status)) {
717 goto unlock_and_exit; 684 goto unlock_and_exit;
718 } 685 }
719 } 686 } else {
720 else {
721 /* Remove the block on this interrupt with lock */ 687 /* Remove the block on this interrupt with lock */
722 688
723 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 689 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
724 if (gpe_block->previous) { 690 if (gpe_block->previous) {
725 gpe_block->previous->next = gpe_block->next; 691 gpe_block->previous->next = gpe_block->next;
726 } 692 } else {
727 else { 693 gpe_block->xrupt_block->gpe_block_list_head =
728 gpe_block->xrupt_block->gpe_block_list_head = gpe_block->next; 694 gpe_block->next;
729 } 695 }
730 696
731 if (gpe_block->next) { 697 if (gpe_block->next) {
732 gpe_block->next->previous = gpe_block->previous; 698 gpe_block->next->previous = gpe_block->previous;
733 } 699 }
734 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 700 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
735 } 701 }
736 702
737 /* Free the gpe_block */ 703 /* Free the gpe_block */
738 704
739 ACPI_MEM_FREE (gpe_block->register_info); 705 ACPI_MEM_FREE(gpe_block->register_info);
740 ACPI_MEM_FREE (gpe_block->event_info); 706 ACPI_MEM_FREE(gpe_block->event_info);
741 ACPI_MEM_FREE (gpe_block); 707 ACPI_MEM_FREE(gpe_block);
742 708
743unlock_and_exit: 709 unlock_and_exit:
744 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 710 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
745 return_ACPI_STATUS (status); 711 return_ACPI_STATUS(status);
746} 712}
747 713
748
749/******************************************************************************* 714/*******************************************************************************
750 * 715 *
751 * FUNCTION: acpi_ev_create_gpe_info_blocks 716 * FUNCTION: acpi_ev_create_gpe_info_blocks
@@ -759,43 +724,41 @@ unlock_and_exit:
759 ******************************************************************************/ 724 ******************************************************************************/
760 725
761static acpi_status 726static acpi_status
762acpi_ev_create_gpe_info_blocks ( 727acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
763 struct acpi_gpe_block_info *gpe_block)
764{ 728{
765 struct acpi_gpe_register_info *gpe_register_info = NULL; 729 struct acpi_gpe_register_info *gpe_register_info = NULL;
766 struct acpi_gpe_event_info *gpe_event_info = NULL; 730 struct acpi_gpe_event_info *gpe_event_info = NULL;
767 struct acpi_gpe_event_info *this_event; 731 struct acpi_gpe_event_info *this_event;
768 struct acpi_gpe_register_info *this_register; 732 struct acpi_gpe_register_info *this_register;
769 acpi_native_uint i; 733 acpi_native_uint i;
770 acpi_native_uint j; 734 acpi_native_uint j;
771 acpi_status status; 735 acpi_status status;
772
773
774 ACPI_FUNCTION_TRACE ("ev_create_gpe_info_blocks");
775 736
737 ACPI_FUNCTION_TRACE("ev_create_gpe_info_blocks");
776 738
777 /* Allocate the GPE register information block */ 739 /* Allocate the GPE register information block */
778 740
779 gpe_register_info = ACPI_MEM_CALLOCATE ( 741 gpe_register_info = ACPI_MEM_CALLOCATE((acpi_size) gpe_block->
780 (acpi_size) gpe_block->register_count * 742 register_count *
781 sizeof (struct acpi_gpe_register_info)); 743 sizeof(struct
744 acpi_gpe_register_info));
782 if (!gpe_register_info) { 745 if (!gpe_register_info) {
783 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 746 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
784 "Could not allocate the gpe_register_info table\n")); 747 "Could not allocate the gpe_register_info table\n"));
785 return_ACPI_STATUS (AE_NO_MEMORY); 748 return_ACPI_STATUS(AE_NO_MEMORY);
786 } 749 }
787 750
788 /* 751 /*
789 * Allocate the GPE event_info block. There are eight distinct GPEs 752 * Allocate the GPE event_info block. There are eight distinct GPEs
790 * per register. Initialization to zeros is sufficient. 753 * per register. Initialization to zeros is sufficient.
791 */ 754 */
792 gpe_event_info = ACPI_MEM_CALLOCATE ( 755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
793 ((acpi_size) gpe_block->register_count * 756 register_count *
794 ACPI_GPE_REGISTER_WIDTH) * 757 ACPI_GPE_REGISTER_WIDTH) *
795 sizeof (struct acpi_gpe_event_info)); 758 sizeof(struct acpi_gpe_event_info));
796 if (!gpe_event_info) { 759 if (!gpe_event_info) {
797 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 760 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
798 "Could not allocate the gpe_event_info table\n")); 761 "Could not allocate the gpe_event_info table\n"));
799 status = AE_NO_MEMORY; 762 status = AE_NO_MEMORY;
800 goto error_exit; 763 goto error_exit;
801 } 764 }
@@ -803,7 +766,7 @@ acpi_ev_create_gpe_info_blocks (
803 /* Save the new Info arrays in the GPE block */ 766 /* Save the new Info arrays in the GPE block */
804 767
805 gpe_block->register_info = gpe_register_info; 768 gpe_block->register_info = gpe_register_info;
806 gpe_block->event_info = gpe_event_info; 769 gpe_block->event_info = gpe_event_info;
807 770
808 /* 771 /*
809 * Initialize the GPE Register and Event structures. A goal of these 772 * Initialize the GPE Register and Event structures. A goal of these
@@ -812,29 +775,34 @@ acpi_ev_create_gpe_info_blocks (
812 * and the enable registers occupy the second half. 775 * and the enable registers occupy the second half.
813 */ 776 */
814 this_register = gpe_register_info; 777 this_register = gpe_register_info;
815 this_event = gpe_event_info; 778 this_event = gpe_event_info;
816 779
817 for (i = 0; i < gpe_block->register_count; i++) { 780 for (i = 0; i < gpe_block->register_count; i++) {
818 /* Init the register_info for this GPE register (8 GPEs) */ 781 /* Init the register_info for this GPE register (8 GPEs) */
819 782
820 this_register->base_gpe_number = (u8) (gpe_block->block_base_number + 783 this_register->base_gpe_number =
821 (i * ACPI_GPE_REGISTER_WIDTH)); 784 (u8) (gpe_block->block_base_number +
822 785 (i * ACPI_GPE_REGISTER_WIDTH));
823 ACPI_STORE_ADDRESS (this_register->status_address.address, 786
824 (gpe_block->block_address.address 787 ACPI_STORE_ADDRESS(this_register->status_address.address,
825 + i)); 788 (gpe_block->block_address.address + i));
826 789
827 ACPI_STORE_ADDRESS (this_register->enable_address.address, 790 ACPI_STORE_ADDRESS(this_register->enable_address.address,
828 (gpe_block->block_address.address 791 (gpe_block->block_address.address
829 + i 792 + i + gpe_block->register_count));
830 + gpe_block->register_count)); 793
831 794 this_register->status_address.address_space_id =
832 this_register->status_address.address_space_id = gpe_block->block_address.address_space_id; 795 gpe_block->block_address.address_space_id;
833 this_register->enable_address.address_space_id = gpe_block->block_address.address_space_id; 796 this_register->enable_address.address_space_id =
834 this_register->status_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 797 gpe_block->block_address.address_space_id;
835 this_register->enable_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 798 this_register->status_address.register_bit_width =
836 this_register->status_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; 799 ACPI_GPE_REGISTER_WIDTH;
837 this_register->enable_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; 800 this_register->enable_address.register_bit_width =
801 ACPI_GPE_REGISTER_WIDTH;
802 this_register->status_address.register_bit_offset =
803 ACPI_GPE_REGISTER_WIDTH;
804 this_register->enable_address.register_bit_offset =
805 ACPI_GPE_REGISTER_WIDTH;
838 806
839 /* Init the event_info for each GPE within this register */ 807 /* Init the event_info for each GPE within this register */
840 808
@@ -849,36 +817,36 @@ acpi_ev_create_gpe_info_blocks (
849 * are cleared by writing a '1', while enable registers are cleared 817 * are cleared by writing a '1', while enable registers are cleared
850 * by writing a '0'. 818 * by writing a '0'.
851 */ 819 */
852 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0x00, 820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
853 &this_register->enable_address); 821 &this_register->
854 if (ACPI_FAILURE (status)) { 822 enable_address);
823 if (ACPI_FAILURE(status)) {
855 goto error_exit; 824 goto error_exit;
856 } 825 }
857 826
858 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0xFF, 827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
859 &this_register->status_address); 828 &this_register->
860 if (ACPI_FAILURE (status)) { 829 status_address);
830 if (ACPI_FAILURE(status)) {
861 goto error_exit; 831 goto error_exit;
862 } 832 }
863 833
864 this_register++; 834 this_register++;
865 } 835 }
866 836
867 return_ACPI_STATUS (AE_OK); 837 return_ACPI_STATUS(AE_OK);
868
869 838
870error_exit: 839 error_exit:
871 if (gpe_register_info) { 840 if (gpe_register_info) {
872 ACPI_MEM_FREE (gpe_register_info); 841 ACPI_MEM_FREE(gpe_register_info);
873 } 842 }
874 if (gpe_event_info) { 843 if (gpe_event_info) {
875 ACPI_MEM_FREE (gpe_event_info); 844 ACPI_MEM_FREE(gpe_event_info);
876 } 845 }
877 846
878 return_ACPI_STATUS (status); 847 return_ACPI_STATUS(status);
879} 848}
880 849
881
882/******************************************************************************* 850/*******************************************************************************
883 * 851 *
884 * FUNCTION: acpi_ev_create_gpe_block 852 * FUNCTION: acpi_ev_create_gpe_block
@@ -887,7 +855,7 @@ error_exit:
887 * gpe_block_address - Address and space_iD 855 * gpe_block_address - Address and space_iD
888 * register_count - Number of GPE register pairs in the block 856 * register_count - Number of GPE register pairs in the block
889 * gpe_block_base_number - Starting GPE number for the block 857 * gpe_block_base_number - Starting GPE number for the block
890 * interrupt_level - H/W interrupt for the block 858 * interrupt_number - H/W interrupt for the block
891 * return_gpe_block - Where the new block descriptor is returned 859 * return_gpe_block - Where the new block descriptor is returned
892 * 860 *
893 * RETURN: Status 861 * RETURN: Status
@@ -897,68 +865,66 @@ error_exit:
897 ******************************************************************************/ 865 ******************************************************************************/
898 866
899acpi_status 867acpi_status
900acpi_ev_create_gpe_block ( 868acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
901 struct acpi_namespace_node *gpe_device, 869 struct acpi_generic_address *gpe_block_address,
902 struct acpi_generic_address *gpe_block_address, 870 u32 register_count,
903 u32 register_count, 871 u8 gpe_block_base_number,
904 u8 gpe_block_base_number, 872 u32 interrupt_number,
905 u32 interrupt_level, 873 struct acpi_gpe_block_info **return_gpe_block)
906 struct acpi_gpe_block_info **return_gpe_block)
907{ 874{
908 struct acpi_gpe_block_info *gpe_block; 875 struct acpi_gpe_block_info *gpe_block;
909 struct acpi_gpe_event_info *gpe_event_info; 876 struct acpi_gpe_event_info *gpe_event_info;
910 acpi_native_uint i; 877 acpi_native_uint i;
911 acpi_native_uint j; 878 acpi_native_uint j;
912 u32 wake_gpe_count; 879 u32 wake_gpe_count;
913 u32 gpe_enabled_count; 880 u32 gpe_enabled_count;
914 acpi_status status; 881 acpi_status status;
915 struct acpi_gpe_walk_info gpe_info; 882 struct acpi_gpe_walk_info gpe_info;
916
917
918 ACPI_FUNCTION_TRACE ("ev_create_gpe_block");
919 883
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
920 885
921 if (!register_count) { 886 if (!register_count) {
922 return_ACPI_STATUS (AE_OK); 887 return_ACPI_STATUS(AE_OK);
923 } 888 }
924 889
925 /* Allocate a new GPE block */ 890 /* Allocate a new GPE block */
926 891
927 gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info)); 892 gpe_block = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_block_info));
928 if (!gpe_block) { 893 if (!gpe_block) {
929 return_ACPI_STATUS (AE_NO_MEMORY); 894 return_ACPI_STATUS(AE_NO_MEMORY);
930 } 895 }
931 896
932 /* Initialize the new GPE block */ 897 /* Initialize the new GPE block */
933 898
934 gpe_block->register_count = register_count; 899 gpe_block->register_count = register_count;
935 gpe_block->block_base_number = gpe_block_base_number; 900 gpe_block->block_base_number = gpe_block_base_number;
936 gpe_block->node = gpe_device; 901 gpe_block->node = gpe_device;
937 902
938 ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, 903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
939 sizeof (struct acpi_generic_address)); 904 sizeof(struct acpi_generic_address));
940 905
941 /* Create the register_info and event_info sub-structures */ 906 /* Create the register_info and event_info sub-structures */
942 907
943 status = acpi_ev_create_gpe_info_blocks (gpe_block); 908 status = acpi_ev_create_gpe_info_blocks(gpe_block);
944 if (ACPI_FAILURE (status)) { 909 if (ACPI_FAILURE(status)) {
945 ACPI_MEM_FREE (gpe_block); 910 ACPI_MEM_FREE(gpe_block);
946 return_ACPI_STATUS (status); 911 return_ACPI_STATUS(status);
947 } 912 }
948 913
949 /* Install the new block in the global list(s) */ 914 /* Install the new block in the global list(s) */
950 915
951 status = acpi_ev_install_gpe_block (gpe_block, interrupt_level); 916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
952 if (ACPI_FAILURE (status)) { 917 if (ACPI_FAILURE(status)) {
953 ACPI_MEM_FREE (gpe_block); 918 ACPI_MEM_FREE(gpe_block);
954 return_ACPI_STATUS (status); 919 return_ACPI_STATUS(status);
955 } 920 }
956 921
957 /* Find all GPE methods (_Lxx, _Exx) for this block */ 922 /* Find all GPE methods (_Lxx, _Exx) for this block */
958 923
959 status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device, 924 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
960 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, 925 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
961 gpe_block, NULL); 926 acpi_ev_save_method_info, gpe_block,
927 NULL);
962 928
963 /* 929 /*
964 * Runtime option: Should Wake GPEs be enabled at runtime? The default 930 * Runtime option: Should Wake GPEs be enabled at runtime? The default
@@ -974,9 +940,11 @@ acpi_ev_create_gpe_block (
974 gpe_info.gpe_block = gpe_block; 940 gpe_info.gpe_block = gpe_block;
975 gpe_info.gpe_device = gpe_device; 941 gpe_info.gpe_device = gpe_device;
976 942
977 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 943 status =
978 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ev_match_prw_and_gpe, 944 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
979 &gpe_info, NULL); 945 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
946 acpi_ev_match_prw_and_gpe, &gpe_info,
947 NULL);
980 } 948 }
981 949
982 /* 950 /*
@@ -991,10 +959,14 @@ acpi_ev_create_gpe_block (
991 for (j = 0; j < 8; j++) { 959 for (j = 0; j < 8; j++) {
992 /* Get the info block for this particular GPE */ 960 /* Get the info block for this particular GPE */
993 961
994 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; 962 gpe_event_info =
963 &gpe_block->
964 event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
995 965
996 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && 966 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
997 (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { 967 ACPI_GPE_DISPATCH_METHOD)
968 && (gpe_event_info->
969 flags & ACPI_GPE_TYPE_RUNTIME)) {
998 gpe_enabled_count++; 970 gpe_enabled_count++;
999 } 971 }
1000 972
@@ -1006,22 +978,22 @@ acpi_ev_create_gpe_block (
1006 978
1007 /* Dump info about this GPE block */ 979 /* Dump info about this GPE block */
1008 980
1009 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1010 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", 982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
1011 (u32) gpe_block->block_base_number, 983 (u32) gpe_block->block_base_number,
1012 (u32) (gpe_block->block_base_number + 984 (u32) (gpe_block->block_base_number +
1013 ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), 985 ((gpe_block->register_count *
1014 gpe_device->name.ascii, 986 ACPI_GPE_REGISTER_WIDTH) - 1)),
1015 gpe_block->register_count, 987 gpe_device->name.ascii, gpe_block->register_count,
1016 interrupt_level)); 988 interrupt_number));
1017 989
1018 /* Enable all valid GPEs found above */ 990 /* Enable all valid GPEs found above */
1019 991
1020 status = acpi_hw_enable_runtime_gpe_block (NULL, gpe_block); 992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1021 993
1022 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 994 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1023 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
1024 wake_gpe_count, gpe_enabled_count)); 996 wake_gpe_count, gpe_enabled_count));
1025 997
1026 /* Return the new block */ 998 /* Return the new block */
1027 999
@@ -1029,10 +1001,9 @@ acpi_ev_create_gpe_block (
1029 (*return_gpe_block) = gpe_block; 1001 (*return_gpe_block) = gpe_block;
1030 } 1002 }
1031 1003
1032 return_ACPI_STATUS (AE_OK); 1004 return_ACPI_STATUS(AE_OK);
1033} 1005}
1034 1006
1035
1036/******************************************************************************* 1007/*******************************************************************************
1037 * 1008 *
1038 * FUNCTION: acpi_ev_gpe_initialize 1009 * FUNCTION: acpi_ev_gpe_initialize
@@ -1045,22 +1016,18 @@ acpi_ev_create_gpe_block (
1045 * 1016 *
1046 ******************************************************************************/ 1017 ******************************************************************************/
1047 1018
1048acpi_status 1019acpi_status acpi_ev_gpe_initialize(void)
1049acpi_ev_gpe_initialize (
1050 void)
1051{ 1020{
1052 u32 register_count0 = 0; 1021 u32 register_count0 = 0;
1053 u32 register_count1 = 0; 1022 u32 register_count1 = 0;
1054 u32 gpe_number_max = 0; 1023 u32 gpe_number_max = 0;
1055 acpi_status status; 1024 acpi_status status;
1056 1025
1026 ACPI_FUNCTION_TRACE("ev_gpe_initialize");
1057 1027
1058 ACPI_FUNCTION_TRACE ("ev_gpe_initialize"); 1028 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1059 1029 if (ACPI_FAILURE(status)) {
1060 1030 return_ACPI_STATUS(status);
1061 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
1062 if (ACPI_FAILURE (status)) {
1063 return_ACPI_STATUS (status);
1064 } 1031 }
1065 1032
1066 /* 1033 /*
@@ -1088,29 +1055,29 @@ acpi_ev_gpe_initialize (
1088 * If EITHER the register length OR the block address are zero, then that 1055 * If EITHER the register length OR the block address are zero, then that
1089 * particular block is not supported. 1056 * particular block is not supported.
1090 */ 1057 */
1091 if (acpi_gbl_FADT->gpe0_blk_len && 1058 if (acpi_gbl_FADT->gpe0_blk_len && acpi_gbl_FADT->xgpe0_blk.address) {
1092 acpi_gbl_FADT->xgpe0_blk.address) {
1093 /* GPE block 0 exists (has both length and address > 0) */ 1059 /* GPE block 0 exists (has both length and address > 0) */
1094 1060
1095 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2); 1061 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2);
1096 1062
1097 gpe_number_max = (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; 1063 gpe_number_max =
1064 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
1098 1065
1099 /* Install GPE Block 0 */ 1066 /* Install GPE Block 0 */
1100 1067
1101 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1068 status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1102 &acpi_gbl_FADT->xgpe0_blk, register_count0, 0, 1069 &acpi_gbl_FADT->xgpe0_blk,
1103 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]); 1070 register_count0, 0,
1071 acpi_gbl_FADT->sci_int,
1072 &acpi_gbl_gpe_fadt_blocks[0]);
1104 1073
1105 if (ACPI_FAILURE (status)) { 1074 if (ACPI_FAILURE(status)) {
1106 ACPI_REPORT_ERROR (( 1075 ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n",
1107 "Could not create GPE Block 0, %s\n", 1076 acpi_format_exception(status)));
1108 acpi_format_exception (status)));
1109 } 1077 }
1110 } 1078 }
1111 1079
1112 if (acpi_gbl_FADT->gpe1_blk_len && 1080 if (acpi_gbl_FADT->gpe1_blk_len && acpi_gbl_FADT->xgpe1_blk.address) {
1113 acpi_gbl_FADT->xgpe1_blk.address) {
1114 /* GPE block 1 exists (has both length and address > 0) */ 1081 /* GPE block 1 exists (has both length and address > 0) */
1115 1082
1116 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2); 1083 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2);
@@ -1118,29 +1085,26 @@ acpi_ev_gpe_initialize (
1118 /* Check for GPE0/GPE1 overlap (if both banks exist) */ 1085 /* Check for GPE0/GPE1 overlap (if both banks exist) */
1119 1086
1120 if ((register_count0) && 1087 if ((register_count0) &&
1121 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { 1088 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
1122 ACPI_REPORT_ERROR (( 1089 ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
1123 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n",
1124 gpe_number_max, acpi_gbl_FADT->gpe1_base,
1125 acpi_gbl_FADT->gpe1_base +
1126 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
1127 1090
1128 /* Ignore GPE1 block by setting the register count to zero */ 1091 /* Ignore GPE1 block by setting the register count to zero */
1129 1092
1130 register_count1 = 0; 1093 register_count1 = 0;
1131 } 1094 } else {
1132 else {
1133 /* Install GPE Block 1 */ 1095 /* Install GPE Block 1 */
1134 1096
1135 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1097 status =
1136 &acpi_gbl_FADT->xgpe1_blk, register_count1, 1098 acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1137 acpi_gbl_FADT->gpe1_base, 1099 &acpi_gbl_FADT->xgpe1_blk,
1138 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]); 1100 register_count1,
1139 1101 acpi_gbl_FADT->gpe1_base,
1140 if (ACPI_FAILURE (status)) { 1102 acpi_gbl_FADT->sci_int,
1141 ACPI_REPORT_ERROR (( 1103 &acpi_gbl_gpe_fadt_blocks
1142 "Could not create GPE Block 1, %s\n", 1104 [1]);
1143 acpi_format_exception (status))); 1105
1106 if (ACPI_FAILURE(status)) {
1107 ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status)));
1144 } 1108 }
1145 1109
1146 /* 1110 /*
@@ -1148,7 +1112,7 @@ acpi_ev_gpe_initialize (
1148 * space. However, GPE0 always starts at GPE number zero. 1112 * space. However, GPE0 always starts at GPE number zero.
1149 */ 1113 */
1150 gpe_number_max = acpi_gbl_FADT->gpe1_base + 1114 gpe_number_max = acpi_gbl_FADT->gpe1_base +
1151 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); 1115 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
1152 } 1116 }
1153 } 1117 }
1154 1118
@@ -1157,8 +1121,8 @@ acpi_ev_gpe_initialize (
1157 if ((register_count0 + register_count1) == 0) { 1121 if ((register_count0 + register_count1) == 0) {
1158 /* GPEs are not required by ACPI, this is OK */ 1122 /* GPEs are not required by ACPI, this is OK */
1159 1123
1160 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 1124 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1161 "There are no GPE blocks defined in the FADT\n")); 1125 "There are no GPE blocks defined in the FADT\n"));
1162 status = AE_OK; 1126 status = AE_OK;
1163 goto cleanup; 1127 goto cleanup;
1164 } 1128 }
@@ -1166,15 +1130,12 @@ acpi_ev_gpe_initialize (
1166 /* Check for Max GPE number out-of-range */ 1130 /* Check for Max GPE number out-of-range */
1167 1131
1168 if (gpe_number_max > ACPI_GPE_MAX) { 1132 if (gpe_number_max > ACPI_GPE_MAX) {
1169 ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", 1133 ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max));
1170 gpe_number_max));
1171 status = AE_BAD_VALUE; 1134 status = AE_BAD_VALUE;
1172 goto cleanup; 1135 goto cleanup;
1173 } 1136 }
1174 1137
1175cleanup: 1138 cleanup:
1176 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 1139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1177 return_ACPI_STATUS (AE_OK); 1140 return_ACPI_STATUS(AE_OK);
1178} 1141}
1179
1180
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 659e90956112..7e57b8470f55 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -47,12 +47,10 @@
47#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evmisc") 50ACPI_MODULE_NAME("evmisc")
51
52 51
53#ifdef ACPI_DEBUG_OUTPUT 52#ifdef ACPI_DEBUG_OUTPUT
54static const char *acpi_notify_value_names[] = 53static const char *acpi_notify_value_names[] = {
55{
56 "Bus Check", 54 "Bus Check",
57 "Device Check", 55 "Device Check",
58 "Device Wake", 56 "Device Wake",
@@ -66,18 +64,11 @@ static const char *acpi_notify_value_names[] =
66 64
67/* Local prototypes */ 65/* Local prototypes */
68 66
69static void ACPI_SYSTEM_XFACE 67static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
70acpi_ev_notify_dispatch (
71 void *context);
72
73static void ACPI_SYSTEM_XFACE
74acpi_ev_global_lock_thread (
75 void *context);
76 68
77static u32 69static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context);
78acpi_ev_global_lock_handler (
79 void *context);
80 70
71static u32 acpi_ev_global_lock_handler(void *context);
81 72
82/******************************************************************************* 73/*******************************************************************************
83 * 74 *
@@ -93,9 +84,7 @@ acpi_ev_global_lock_handler (
93 * 84 *
94 ******************************************************************************/ 85 ******************************************************************************/
95 86
96u8 87u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
97acpi_ev_is_notify_object (
98 struct acpi_namespace_node *node)
99{ 88{
100 switch (node->type) { 89 switch (node->type) {
101 case ACPI_TYPE_DEVICE: 90 case ACPI_TYPE_DEVICE:
@@ -112,7 +101,6 @@ acpi_ev_is_notify_object (
112 } 101 }
113} 102}
114 103
115
116/******************************************************************************* 104/*******************************************************************************
117 * 105 *
118 * FUNCTION: acpi_ev_queue_notify_request 106 * FUNCTION: acpi_ev_queue_notify_request
@@ -128,18 +116,15 @@ acpi_ev_is_notify_object (
128 ******************************************************************************/ 116 ******************************************************************************/
129 117
130acpi_status 118acpi_status
131acpi_ev_queue_notify_request ( 119acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
132 struct acpi_namespace_node *node, 120 u32 notify_value)
133 u32 notify_value)
134{ 121{
135 union acpi_operand_object *obj_desc; 122 union acpi_operand_object *obj_desc;
136 union acpi_operand_object *handler_obj = NULL; 123 union acpi_operand_object *handler_obj = NULL;
137 union acpi_generic_state *notify_info; 124 union acpi_generic_state *notify_info;
138 acpi_status status = AE_OK; 125 acpi_status status = AE_OK;
139
140
141 ACPI_FUNCTION_NAME ("ev_queue_notify_request");
142 126
127 ACPI_FUNCTION_NAME("ev_queue_notify_request");
143 128
144 /* 129 /*
145 * For value 3 (Ejection Request), some device method may need to be run. 130 * For value 3 (Ejection Request), some device method may need to be run.
@@ -148,22 +133,22 @@ acpi_ev_queue_notify_request (
148 * For value 0x80 (Status Change) on the power button or sleep button, 133 * For value 0x80 (Status Change) on the power button or sleep button,
149 * initiate soft-off or sleep operation? 134 * initiate soft-off or sleep operation?
150 */ 135 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "Dispatching Notify(%X) on node %p\n", notify_value, node)); 137 "Dispatching Notify(%X) on node %p\n", notify_value,
138 node));
153 139
154 if (notify_value <= 7) { 140 if (notify_value <= 7) {
155 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", 141 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notify value: %s\n",
156 acpi_notify_value_names[notify_value])); 142 acpi_notify_value_names[notify_value]));
157 } 143 } else {
158 else { 144 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 145 "Notify value: 0x%2.2X **Device Specific**\n",
160 "Notify value: 0x%2.2X **Device Specific**\n", 146 notify_value));
161 notify_value));
162 } 147 }
163 148
164 /* Get the notify object attached to the NS Node */ 149 /* Get the notify object attached to the NS Node */
165 150
166 obj_desc = acpi_ns_get_attached_object (node); 151 obj_desc = acpi_ns_get_attached_object(node);
167 if (obj_desc) { 152 if (obj_desc) {
168 /* We have the notify object, Get the right handler */ 153 /* We have the notify object, Get the right handler */
169 154
@@ -174,10 +159,11 @@ acpi_ev_queue_notify_request (
174 case ACPI_TYPE_POWER: 159 case ACPI_TYPE_POWER:
175 160
176 if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 161 if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
177 handler_obj = obj_desc->common_notify.system_notify; 162 handler_obj =
178 } 163 obj_desc->common_notify.system_notify;
179 else { 164 } else {
180 handler_obj = obj_desc->common_notify.device_notify; 165 handler_obj =
166 obj_desc->common_notify.device_notify;
181 } 167 }
182 break; 168 break;
183 169
@@ -189,23 +175,25 @@ acpi_ev_queue_notify_request (
189 175
190 /* If there is any handler to run, schedule the dispatcher */ 176 /* If there is any handler to run, schedule the dispatcher */
191 177
192 if ((acpi_gbl_system_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) || 178 if ((acpi_gbl_system_notify.handler
193 (acpi_gbl_device_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) || 179 && (notify_value <= ACPI_MAX_SYS_NOTIFY))
194 handler_obj) { 180 || (acpi_gbl_device_notify.handler
195 notify_info = acpi_ut_create_generic_state (); 181 && (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) {
182 notify_info = acpi_ut_create_generic_state();
196 if (!notify_info) { 183 if (!notify_info) {
197 return (AE_NO_MEMORY); 184 return (AE_NO_MEMORY);
198 } 185 }
199 186
200 notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY; 187 notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY;
201 notify_info->notify.node = node; 188 notify_info->notify.node = node;
202 notify_info->notify.value = (u16) notify_value; 189 notify_info->notify.value = (u16) notify_value;
203 notify_info->notify.handler_obj = handler_obj; 190 notify_info->notify.handler_obj = handler_obj;
204 191
205 status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, 192 status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
206 acpi_ev_notify_dispatch, notify_info); 193 acpi_ev_notify_dispatch,
207 if (ACPI_FAILURE (status)) { 194 notify_info);
208 acpi_ut_delete_generic_state (notify_info); 195 if (ACPI_FAILURE(status)) {
196 acpi_ut_delete_generic_state(notify_info);
209 } 197 }
210 } 198 }
211 199
@@ -214,15 +202,15 @@ acpi_ev_queue_notify_request (
214 * There is no per-device notify handler for this device. 202 * There is no per-device notify handler for this device.
215 * This may or may not be a problem. 203 * This may or may not be a problem.
216 */ 204 */
217 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
218 "No notify handler for Notify(%4.4s, %X) node %p\n", 206 "No notify handler for Notify(%4.4s, %X) node %p\n",
219 acpi_ut_get_node_name (node), notify_value, node)); 207 acpi_ut_get_node_name(node), notify_value,
208 node));
220 } 209 }
221 210
222 return (status); 211 return (status);
223} 212}
224 213
225
226/******************************************************************************* 214/*******************************************************************************
227 * 215 *
228 * FUNCTION: acpi_ev_notify_dispatch 216 * FUNCTION: acpi_ev_notify_dispatch
@@ -236,18 +224,15 @@ acpi_ev_queue_notify_request (
236 * 224 *
237 ******************************************************************************/ 225 ******************************************************************************/
238 226
239static void ACPI_SYSTEM_XFACE 227static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
240acpi_ev_notify_dispatch (
241 void *context)
242{ 228{
243 union acpi_generic_state *notify_info = (union acpi_generic_state *) context; 229 union acpi_generic_state *notify_info =
244 acpi_notify_handler global_handler = NULL; 230 (union acpi_generic_state *)context;
245 void *global_context = NULL; 231 acpi_notify_handler global_handler = NULL;
246 union acpi_operand_object *handler_obj; 232 void *global_context = NULL;
247 233 union acpi_operand_object *handler_obj;
248
249 ACPI_FUNCTION_ENTRY ();
250 234
235 ACPI_FUNCTION_ENTRY();
251 236
252 /* 237 /*
253 * We will invoke a global notify handler if installed. 238 * We will invoke a global notify handler if installed.
@@ -261,8 +246,7 @@ acpi_ev_notify_dispatch (
261 global_handler = acpi_gbl_system_notify.handler; 246 global_handler = acpi_gbl_system_notify.handler;
262 global_context = acpi_gbl_system_notify.context; 247 global_context = acpi_gbl_system_notify.context;
263 } 248 }
264 } 249 } else {
265 else {
266 /* Global driver notification handler */ 250 /* Global driver notification handler */
267 251
268 if (acpi_gbl_device_notify.handler) { 252 if (acpi_gbl_device_notify.handler) {
@@ -274,25 +258,24 @@ acpi_ev_notify_dispatch (
274 /* Invoke the system handler first, if present */ 258 /* Invoke the system handler first, if present */
275 259
276 if (global_handler) { 260 if (global_handler) {
277 global_handler (notify_info->notify.node, notify_info->notify.value, 261 global_handler(notify_info->notify.node,
278 global_context); 262 notify_info->notify.value, global_context);
279 } 263 }
280 264
281 /* Now invoke the per-device handler, if present */ 265 /* Now invoke the per-device handler, if present */
282 266
283 handler_obj = notify_info->notify.handler_obj; 267 handler_obj = notify_info->notify.handler_obj;
284 if (handler_obj) { 268 if (handler_obj) {
285 handler_obj->notify.handler (notify_info->notify.node, 269 handler_obj->notify.handler(notify_info->notify.node,
286 notify_info->notify.value, 270 notify_info->notify.value,
287 handler_obj->notify.context); 271 handler_obj->notify.context);
288 } 272 }
289 273
290 /* All done with the info object */ 274 /* All done with the info object */
291 275
292 acpi_ut_delete_generic_state (notify_info); 276 acpi_ut_delete_generic_state(notify_info);
293} 277}
294 278
295
296/******************************************************************************* 279/*******************************************************************************
297 * 280 *
298 * FUNCTION: acpi_ev_global_lock_thread 281 * FUNCTION: acpi_ev_global_lock_thread
@@ -307,27 +290,24 @@ acpi_ev_notify_dispatch (
307 * 290 *
308 ******************************************************************************/ 291 ******************************************************************************/
309 292
310static void ACPI_SYSTEM_XFACE 293static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
311acpi_ev_global_lock_thread (
312 void *context)
313{ 294{
314 acpi_status status; 295 acpi_status status;
315
316 296
317 /* Signal threads that are waiting for the lock */ 297 /* Signal threads that are waiting for the lock */
318 298
319 if (acpi_gbl_global_lock_thread_count) { 299 if (acpi_gbl_global_lock_thread_count) {
320 /* Send sufficient units to the semaphore */ 300 /* Send sufficient units to the semaphore */
321 301
322 status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore, 302 status =
323 acpi_gbl_global_lock_thread_count); 303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore,
324 if (ACPI_FAILURE (status)) { 304 acpi_gbl_global_lock_thread_count);
325 ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n")); 305 if (ACPI_FAILURE(status)) {
306 ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n"));
326 } 307 }
327 } 308 }
328} 309}
329 310
330
331/******************************************************************************* 311/*******************************************************************************
332 * 312 *
333 * FUNCTION: acpi_ev_global_lock_handler 313 * FUNCTION: acpi_ev_global_lock_handler
@@ -342,20 +322,17 @@ acpi_ev_global_lock_thread (
342 * 322 *
343 ******************************************************************************/ 323 ******************************************************************************/
344 324
345static u32 325static u32 acpi_ev_global_lock_handler(void *context)
346acpi_ev_global_lock_handler (
347 void *context)
348{ 326{
349 u8 acquired = FALSE; 327 u8 acquired = FALSE;
350 acpi_status status; 328 acpi_status status;
351
352 329
353 /* 330 /*
354 * Attempt to get the lock 331 * Attempt to get the lock
355 * If we don't get it now, it will be marked pending and we will 332 * If we don't get it now, it will be marked pending and we will
356 * take another interrupt when it becomes free. 333 * take another interrupt when it becomes free.
357 */ 334 */
358 ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); 335 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
359 if (acquired) { 336 if (acquired) {
360 /* Got the lock, now wake all threads waiting for it */ 337 /* Got the lock, now wake all threads waiting for it */
361 338
@@ -363,11 +340,11 @@ acpi_ev_global_lock_handler (
363 340
364 /* Run the Global Lock thread which will signal all waiting threads */ 341 /* Run the Global Lock thread which will signal all waiting threads */
365 342
366 status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, 343 status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
367 acpi_ev_global_lock_thread, context); 344 acpi_ev_global_lock_thread,
368 if (ACPI_FAILURE (status)) { 345 context);
369 ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n", 346 if (ACPI_FAILURE(status)) {
370 acpi_format_exception (status))); 347 ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status)));
371 348
372 return (ACPI_INTERRUPT_NOT_HANDLED); 349 return (ACPI_INTERRUPT_NOT_HANDLED);
373 } 350 }
@@ -376,7 +353,6 @@ acpi_ev_global_lock_handler (
376 return (ACPI_INTERRUPT_HANDLED); 353 return (ACPI_INTERRUPT_HANDLED);
377} 354}
378 355
379
380/******************************************************************************* 356/*******************************************************************************
381 * 357 *
382 * FUNCTION: acpi_ev_init_global_lock_handler 358 * FUNCTION: acpi_ev_init_global_lock_handler
@@ -389,19 +365,16 @@ acpi_ev_global_lock_handler (
389 * 365 *
390 ******************************************************************************/ 366 ******************************************************************************/
391 367
392acpi_status 368acpi_status acpi_ev_init_global_lock_handler(void)
393acpi_ev_init_global_lock_handler (
394 void)
395{ 369{
396 acpi_status status; 370 acpi_status status;
397
398
399 ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler");
400 371
372 ACPI_FUNCTION_TRACE("ev_init_global_lock_handler");
401 373
402 acpi_gbl_global_lock_present = TRUE; 374 acpi_gbl_global_lock_present = TRUE;
403 status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, 375 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
404 acpi_ev_global_lock_handler, NULL); 376 acpi_ev_global_lock_handler,
377 NULL);
405 378
406 /* 379 /*
407 * If the global lock does not exist on this platform, the attempt 380 * If the global lock does not exist on this platform, the attempt
@@ -411,14 +384,15 @@ acpi_ev_init_global_lock_handler (
411 * with an error. 384 * with an error.
412 */ 385 */
413 if (status == AE_NO_HARDWARE_RESPONSE) { 386 if (status == AE_NO_HARDWARE_RESPONSE) {
387 ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n"));
388
414 acpi_gbl_global_lock_present = FALSE; 389 acpi_gbl_global_lock_present = FALSE;
415 status = AE_OK; 390 status = AE_OK;
416 } 391 }
417 392
418 return_ACPI_STATUS (status); 393 return_ACPI_STATUS(status);
419} 394}
420 395
421
422/****************************************************************************** 396/******************************************************************************
423 * 397 *
424 * FUNCTION: acpi_ev_acquire_global_lock 398 * FUNCTION: acpi_ev_acquire_global_lock
@@ -431,22 +405,18 @@ acpi_ev_init_global_lock_handler (
431 * 405 *
432 *****************************************************************************/ 406 *****************************************************************************/
433 407
434acpi_status 408acpi_status acpi_ev_acquire_global_lock(u16 timeout)
435acpi_ev_acquire_global_lock (
436 u16 timeout)
437{ 409{
438 acpi_status status = AE_OK; 410 acpi_status status = AE_OK;
439 u8 acquired = FALSE; 411 u8 acquired = FALSE;
440
441
442 ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");
443 412
413 ACPI_FUNCTION_TRACE("ev_acquire_global_lock");
444 414
445#ifndef ACPI_APPLICATION 415#ifndef ACPI_APPLICATION
446 /* Make sure that we actually have a global lock */ 416 /* Make sure that we actually have a global lock */
447 417
448 if (!acpi_gbl_global_lock_present) { 418 if (!acpi_gbl_global_lock_present) {
449 return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); 419 return_ACPI_STATUS(AE_NO_GLOBAL_LOCK);
450 } 420 }
451#endif 421#endif
452 422
@@ -459,37 +429,37 @@ acpi_ev_acquire_global_lock (
459 * we are done 429 * we are done
460 */ 430 */
461 if (acpi_gbl_global_lock_acquired) { 431 if (acpi_gbl_global_lock_acquired) {
462 return_ACPI_STATUS (AE_OK); 432 return_ACPI_STATUS(AE_OK);
463 } 433 }
464 434
465 /* We must acquire the actual hardware lock */ 435 /* We must acquire the actual hardware lock */
466 436
467 ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); 437 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
468 if (acquired) { 438 if (acquired) {
469 /* We got the lock */ 439 /* We got the lock */
470 440
471 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n")); 441 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
442 "Acquired the HW Global Lock\n"));
472 443
473 acpi_gbl_global_lock_acquired = TRUE; 444 acpi_gbl_global_lock_acquired = TRUE;
474 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS(AE_OK);
475 } 446 }
476 447
477 /* 448 /*
478 * Did not get the lock. The pending bit was set above, and we must now 449 * Did not get the lock. The pending bit was set above, and we must now
479 * wait until we get the global lock released interrupt. 450 * wait until we get the global lock released interrupt.
480 */ 451 */
481 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); 452 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
482 453
483 /* 454 /*
484 * Acquire the global lock semaphore first. 455 * Acquire the global lock semaphore first.
485 * Since this wait will block, we must release the interpreter 456 * Since this wait will block, we must release the interpreter
486 */ 457 */
487 status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore, 458 status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
488 timeout); 459 timeout);
489 return_ACPI_STATUS (status); 460 return_ACPI_STATUS(status);
490} 461}
491 462
492
493/******************************************************************************* 463/*******************************************************************************
494 * 464 *
495 * FUNCTION: acpi_ev_release_global_lock 465 * FUNCTION: acpi_ev_release_global_lock
@@ -502,21 +472,16 @@ acpi_ev_acquire_global_lock (
502 * 472 *
503 ******************************************************************************/ 473 ******************************************************************************/
504 474
505acpi_status 475acpi_status acpi_ev_release_global_lock(void)
506acpi_ev_release_global_lock (
507 void)
508{ 476{
509 u8 pending = FALSE; 477 u8 pending = FALSE;
510 acpi_status status = AE_OK; 478 acpi_status status = AE_OK;
511
512
513 ACPI_FUNCTION_TRACE ("ev_release_global_lock");
514 479
480 ACPI_FUNCTION_TRACE("ev_release_global_lock");
515 481
516 if (!acpi_gbl_global_lock_thread_count) { 482 if (!acpi_gbl_global_lock_thread_count) {
517 ACPI_REPORT_WARNING(( 483 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
518 "Cannot release HW Global Lock, it has not been acquired\n")); 484 return_ACPI_STATUS(AE_NOT_ACQUIRED);
519 return_ACPI_STATUS (AE_NOT_ACQUIRED);
520 } 485 }
521 486
522 /* One fewer thread has the global lock */ 487 /* One fewer thread has the global lock */
@@ -525,14 +490,14 @@ acpi_ev_release_global_lock (
525 if (acpi_gbl_global_lock_thread_count) { 490 if (acpi_gbl_global_lock_thread_count) {
526 /* There are still some threads holding the lock, cannot release */ 491 /* There are still some threads holding the lock, cannot release */
527 492
528 return_ACPI_STATUS (AE_OK); 493 return_ACPI_STATUS(AE_OK);
529 } 494 }
530 495
531 /* 496 /*
532 * No more threads holding lock, we can do the actual hardware 497 * No more threads holding lock, we can do the actual hardware
533 * release 498 * release
534 */ 499 */
535 ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending); 500 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, pending);
536 acpi_gbl_global_lock_acquired = FALSE; 501 acpi_gbl_global_lock_acquired = FALSE;
537 502
538 /* 503 /*
@@ -540,14 +505,13 @@ acpi_ev_release_global_lock (
540 * register 505 * register
541 */ 506 */
542 if (pending) { 507 if (pending) {
543 status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 508 status = acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE,
544 1, ACPI_MTX_LOCK); 509 1, ACPI_MTX_LOCK);
545 } 510 }
546 511
547 return_ACPI_STATUS (status); 512 return_ACPI_STATUS(status);
548} 513}
549 514
550
551/****************************************************************************** 515/******************************************************************************
552 * 516 *
553 * FUNCTION: acpi_ev_terminate 517 * FUNCTION: acpi_ev_terminate
@@ -560,16 +524,12 @@ acpi_ev_release_global_lock (
560 * 524 *
561 ******************************************************************************/ 525 ******************************************************************************/
562 526
563void 527void acpi_ev_terminate(void)
564acpi_ev_terminate (
565 void)
566{ 528{
567 acpi_native_uint i; 529 acpi_native_uint i;
568 acpi_status status; 530 acpi_status status;
569
570
571 ACPI_FUNCTION_TRACE ("ev_terminate");
572 531
532 ACPI_FUNCTION_TRACE("ev_terminate");
573 533
574 if (acpi_gbl_events_initialized) { 534 if (acpi_gbl_events_initialized) {
575 /* 535 /*
@@ -580,38 +540,39 @@ acpi_ev_terminate (
580 /* Disable all fixed events */ 540 /* Disable all fixed events */
581 541
582 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 542 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
583 status = acpi_disable_event ((u32) i, 0); 543 status = acpi_disable_event((u32) i, 0);
584 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
585 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
586 "Could not disable fixed event %d\n", (u32) i)); 546 "Could not disable fixed event %d\n",
547 (u32) i));
587 } 548 }
588 } 549 }
589 550
590 /* Disable all GPEs in all GPE blocks */ 551 /* Disable all GPEs in all GPE blocks */
591 552
592 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR); 553 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
593 554
594 /* Remove SCI handler */ 555 /* Remove SCI handler */
595 556
596 status = acpi_ev_remove_sci_handler (); 557 status = acpi_ev_remove_sci_handler();
597 if (ACPI_FAILURE(status)) { 558 if (ACPI_FAILURE(status)) {
598 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 559 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
599 "Could not remove SCI handler\n")); 560 "Could not remove SCI handler\n"));
600 } 561 }
601 } 562 }
602 563
603 /* Deallocate all handler objects installed within GPE info structs */ 564 /* Deallocate all handler objects installed within GPE info structs */
604 565
605 status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR); 566 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers);
606 567
607 /* Return to original mode if necessary */ 568 /* Return to original mode if necessary */
608 569
609 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { 570 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
610 status = acpi_disable (); 571 status = acpi_disable();
611 if (ACPI_FAILURE (status)) { 572 if (ACPI_FAILURE(status)) {
612 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n")); 573 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
574 "acpi_disable failed\n"));
613 } 575 }
614 } 576 }
615 return_VOID; 577 return_VOID;
616} 578}
617
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index a1d7276c5742..84fad082d80d 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -41,39 +41,30 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acevents.h> 45#include <acpi/acevents.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
50#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evregion") 50ACPI_MODULE_NAME("evregion")
52
53#define ACPI_NUM_DEFAULT_SPACES 4 51#define ACPI_NUM_DEFAULT_SPACES 4
54 52static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
55static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { 53 ACPI_ADR_SPACE_SYSTEM_MEMORY,
56 ACPI_ADR_SPACE_SYSTEM_MEMORY, 54 ACPI_ADR_SPACE_SYSTEM_IO,
57 ACPI_ADR_SPACE_SYSTEM_IO, 55 ACPI_ADR_SPACE_PCI_CONFIG,
58 ACPI_ADR_SPACE_PCI_CONFIG, 56 ACPI_ADR_SPACE_DATA_TABLE
59 ACPI_ADR_SPACE_DATA_TABLE}; 57};
60 58
61/* Local prototypes */ 59/* Local prototypes */
62 60
63static acpi_status 61static acpi_status
64acpi_ev_reg_run ( 62acpi_ev_reg_run(acpi_handle obj_handle,
65 acpi_handle obj_handle, 63 u32 level, void *context, void **return_value);
66 u32 level,
67 void *context,
68 void **return_value);
69 64
70static acpi_status 65static acpi_status
71acpi_ev_install_handler ( 66acpi_ev_install_handler(acpi_handle obj_handle,
72 acpi_handle obj_handle, 67 u32 level, void *context, void **return_value);
73 u32 level,
74 void *context,
75 void **return_value);
76
77 68
78/******************************************************************************* 69/*******************************************************************************
79 * 70 *
@@ -87,19 +78,16 @@ acpi_ev_install_handler (
87 * 78 *
88 ******************************************************************************/ 79 ******************************************************************************/
89 80
90acpi_status 81acpi_status acpi_ev_install_region_handlers(void)
91acpi_ev_install_region_handlers ( 82{
92 void) { 83 acpi_status status;
93 acpi_status status; 84 acpi_native_uint i;
94 acpi_native_uint i;
95
96
97 ACPI_FUNCTION_TRACE ("ev_install_region_handlers");
98 85
86 ACPI_FUNCTION_TRACE("ev_install_region_handlers");
99 87
100 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 88 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
101 if (ACPI_FAILURE (status)) { 89 if (ACPI_FAILURE(status)) {
102 return_ACPI_STATUS (status); 90 return_ACPI_STATUS(status);
103 } 91 }
104 92
105 /* 93 /*
@@ -121,9 +109,11 @@ acpi_ev_install_region_handlers (
121 * Similar for AE_SAME_HANDLER. 109 * Similar for AE_SAME_HANDLER.
122 */ 110 */
123 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { 111 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
124 status = acpi_ev_install_space_handler (acpi_gbl_root_node, 112 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
125 acpi_gbl_default_address_spaces[i], 113 acpi_gbl_default_address_spaces
126 ACPI_DEFAULT_HANDLER, NULL, NULL); 114 [i],
115 ACPI_DEFAULT_HANDLER,
116 NULL, NULL);
127 switch (status) { 117 switch (status) {
128 case AE_OK: 118 case AE_OK:
129 case AE_SAME_HANDLER: 119 case AE_SAME_HANDLER:
@@ -140,12 +130,11 @@ acpi_ev_install_region_handlers (
140 } 130 }
141 } 131 }
142 132
143unlock_and_exit: 133 unlock_and_exit:
144 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 134 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
145 return_ACPI_STATUS (status); 135 return_ACPI_STATUS(status);
146} 136}
147 137
148
149/******************************************************************************* 138/*******************************************************************************
150 * 139 *
151 * FUNCTION: acpi_ev_initialize_op_regions 140 * FUNCTION: acpi_ev_initialize_op_regions
@@ -159,20 +148,16 @@ unlock_and_exit:
159 * 148 *
160 ******************************************************************************/ 149 ******************************************************************************/
161 150
162acpi_status 151acpi_status acpi_ev_initialize_op_regions(void)
163acpi_ev_initialize_op_regions (
164 void)
165{ 152{
166 acpi_status status; 153 acpi_status status;
167 acpi_native_uint i; 154 acpi_native_uint i;
168
169 155
170 ACPI_FUNCTION_TRACE ("ev_initialize_op_regions"); 156 ACPI_FUNCTION_TRACE("ev_initialize_op_regions");
171 157
172 158 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
173 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 159 if (ACPI_FAILURE(status)) {
174 if (ACPI_FAILURE (status)) { 160 return_ACPI_STATUS(status);
175 return_ACPI_STATUS (status);
176 } 161 }
177 162
178 /* 163 /*
@@ -182,15 +167,15 @@ acpi_ev_initialize_op_regions (
182 /* TBD: Make sure handler is the DEFAULT handler, otherwise 167 /* TBD: Make sure handler is the DEFAULT handler, otherwise
183 * _REG will have already been run. 168 * _REG will have already been run.
184 */ 169 */
185 status = acpi_ev_execute_reg_methods (acpi_gbl_root_node, 170 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
186 acpi_gbl_default_address_spaces[i]); 171 acpi_gbl_default_address_spaces
172 [i]);
187 } 173 }
188 174
189 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 175 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
190 return_ACPI_STATUS (status); 176 return_ACPI_STATUS(status);
191} 177}
192 178
193
194/******************************************************************************* 179/*******************************************************************************
195 * 180 *
196 * FUNCTION: acpi_ev_execute_reg_method 181 * FUNCTION: acpi_ev_execute_reg_method
@@ -205,26 +190,22 @@ acpi_ev_initialize_op_regions (
205 ******************************************************************************/ 190 ******************************************************************************/
206 191
207acpi_status 192acpi_status
208acpi_ev_execute_reg_method ( 193acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
209 union acpi_operand_object *region_obj,
210 u32 function)
211{ 194{
212 struct acpi_parameter_info info; 195 struct acpi_parameter_info info;
213 union acpi_operand_object *params[3]; 196 union acpi_operand_object *params[3];
214 union acpi_operand_object *region_obj2; 197 union acpi_operand_object *region_obj2;
215 acpi_status status; 198 acpi_status status;
216
217 199
218 ACPI_FUNCTION_TRACE ("ev_execute_reg_method"); 200 ACPI_FUNCTION_TRACE("ev_execute_reg_method");
219 201
220 202 region_obj2 = acpi_ns_get_secondary_object(region_obj);
221 region_obj2 = acpi_ns_get_secondary_object (region_obj);
222 if (!region_obj2) { 203 if (!region_obj2) {
223 return_ACPI_STATUS (AE_NOT_EXIST); 204 return_ACPI_STATUS(AE_NOT_EXIST);
224 } 205 }
225 206
226 if (region_obj2->extra.method_REG == NULL) { 207 if (region_obj2->extra.method_REG == NULL) {
227 return_ACPI_STATUS (AE_OK); 208 return_ACPI_STATUS(AE_OK);
228 } 209 }
229 210
230 /* 211 /*
@@ -237,12 +218,12 @@ acpi_ev_execute_reg_method (
237 * 0 for disconnecting the handler 218 * 0 for disconnecting the handler
238 * Passed as a parameter 219 * Passed as a parameter
239 */ 220 */
240 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 221 params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
241 if (!params[0]) { 222 if (!params[0]) {
242 return_ACPI_STATUS (AE_NO_MEMORY); 223 return_ACPI_STATUS(AE_NO_MEMORY);
243 } 224 }
244 225
245 params[1] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 226 params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
246 if (!params[1]) { 227 if (!params[1]) {
247 status = AE_NO_MEMORY; 228 status = AE_NO_MEMORY;
248 goto cleanup; 229 goto cleanup;
@@ -260,19 +241,18 @@ acpi_ev_execute_reg_method (
260 241
261 /* Execute the method, no return value */ 242 /* Execute the method, no return value */
262 243
263 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname ( 244 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
264 ACPI_TYPE_METHOD, info.node, NULL)); 245 (ACPI_TYPE_METHOD, info.node, NULL));
265 status = acpi_ns_evaluate_by_handle (&info); 246 status = acpi_ns_evaluate_by_handle(&info);
266 247
267 acpi_ut_remove_reference (params[1]); 248 acpi_ut_remove_reference(params[1]);
268 249
269cleanup: 250 cleanup:
270 acpi_ut_remove_reference (params[0]); 251 acpi_ut_remove_reference(params[0]);
271 252
272 return_ACPI_STATUS (status); 253 return_ACPI_STATUS(status);
273} 254}
274 255
275
276/******************************************************************************* 256/*******************************************************************************
277 * 257 *
278 * FUNCTION: acpi_ev_address_space_dispatch 258 * FUNCTION: acpi_ev_address_space_dispatch
@@ -291,40 +271,38 @@ cleanup:
291 ******************************************************************************/ 271 ******************************************************************************/
292 272
293acpi_status 273acpi_status
294acpi_ev_address_space_dispatch ( 274acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
295 union acpi_operand_object *region_obj, 275 u32 function,
296 u32 function, 276 acpi_physical_address address,
297 acpi_physical_address address, 277 u32 bit_width, void *value)
298 u32 bit_width,
299 void *value)
300{ 278{
301 acpi_status status; 279 acpi_status status;
302 acpi_status status2; 280 acpi_status status2;
303 acpi_adr_space_handler handler; 281 acpi_adr_space_handler handler;
304 acpi_adr_space_setup region_setup; 282 acpi_adr_space_setup region_setup;
305 union acpi_operand_object *handler_desc; 283 union acpi_operand_object *handler_desc;
306 union acpi_operand_object *region_obj2; 284 union acpi_operand_object *region_obj2;
307 void *region_context = NULL; 285 void *region_context = NULL;
308 286
287 ACPI_FUNCTION_TRACE("ev_address_space_dispatch");
309 288
310 ACPI_FUNCTION_TRACE ("ev_address_space_dispatch"); 289 region_obj2 = acpi_ns_get_secondary_object(region_obj);
311
312
313 region_obj2 = acpi_ns_get_secondary_object (region_obj);
314 if (!region_obj2) { 290 if (!region_obj2) {
315 return_ACPI_STATUS (AE_NOT_EXIST); 291 return_ACPI_STATUS(AE_NOT_EXIST);
316 } 292 }
317 293
318 /* Ensure that there is a handler associated with this region */ 294 /* Ensure that there is a handler associated with this region */
319 295
320 handler_desc = region_obj->region.handler; 296 handler_desc = region_obj->region.handler;
321 if (!handler_desc) { 297 if (!handler_desc) {
322 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
323 "No handler for Region [%4.4s] (%p) [%s]\n", 299 "No handler for Region [%4.4s] (%p) [%s]\n",
324 acpi_ut_get_node_name (region_obj->region.node), 300 acpi_ut_get_node_name(region_obj->region.
325 region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); 301 node), region_obj,
326 302 acpi_ut_get_region_name(region_obj->region.
327 return_ACPI_STATUS (AE_NOT_EXIST); 303 space_id)));
304
305 return_ACPI_STATUS(AE_NOT_EXIST);
328 } 306 }
329 307
330 /* 308 /*
@@ -339,10 +317,13 @@ acpi_ev_address_space_dispatch (
339 if (!region_setup) { 317 if (!region_setup) {
340 /* No initialization routine, exit with error */ 318 /* No initialization routine, exit with error */
341 319
342 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 320 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
343 "No init routine for region(%p) [%s]\n", 321 "No init routine for region(%p) [%s]\n",
344 region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); 322 region_obj,
345 return_ACPI_STATUS (AE_NOT_EXIST); 323 acpi_ut_get_region_name(region_obj->
324 region.
325 space_id)));
326 return_ACPI_STATUS(AE_NOT_EXIST);
346 } 327 }
347 328
348 /* 329 /*
@@ -350,25 +331,29 @@ acpi_ev_address_space_dispatch (
350 * setup will potentially execute control methods 331 * setup will potentially execute control methods
351 * (e.g., _REG method for this region) 332 * (e.g., _REG method for this region)
352 */ 333 */
353 acpi_ex_exit_interpreter (); 334 acpi_ex_exit_interpreter();
354 335
355 status = region_setup (region_obj, ACPI_REGION_ACTIVATE, 336 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
356 handler_desc->address_space.context, &region_context); 337 handler_desc->address_space.context,
338 &region_context);
357 339
358 /* Re-enter the interpreter */ 340 /* Re-enter the interpreter */
359 341
360 status2 = acpi_ex_enter_interpreter (); 342 status2 = acpi_ex_enter_interpreter();
361 if (ACPI_FAILURE (status2)) { 343 if (ACPI_FAILURE(status2)) {
362 return_ACPI_STATUS (status2); 344 return_ACPI_STATUS(status2);
363 } 345 }
364 346
365 /* Check for failure of the Region Setup */ 347 /* Check for failure of the Region Setup */
366 348
367 if (ACPI_FAILURE (status)) { 349 if (ACPI_FAILURE(status)) {
368 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n", 350 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 acpi_format_exception (status), 351 "Region Init: %s [%s]\n",
370 acpi_ut_get_region_name (region_obj->region.space_id))); 352 acpi_format_exception(status),
371 return_ACPI_STATUS (status); 353 acpi_ut_get_region_name(region_obj->
354 region.
355 space_id)));
356 return_ACPI_STATUS(status);
372 } 357 }
373 358
374 /* 359 /*
@@ -380,14 +365,14 @@ acpi_ev_address_space_dispatch (
380 if (region_obj2->extra.region_context) { 365 if (region_obj2->extra.region_context) {
381 /* The handler for this region was already installed */ 366 /* The handler for this region was already installed */
382 367
383 ACPI_MEM_FREE (region_context); 368 ACPI_MEM_FREE(region_context);
384 } 369 } else {
385 else {
386 /* 370 /*
387 * Save the returned context for use in all accesses to 371 * Save the returned context for use in all accesses to
388 * this particular region 372 * this particular region
389 */ 373 */
390 region_obj2->extra.region_context = region_context; 374 region_obj2->extra.region_context =
375 region_context;
391 } 376 }
392 } 377 }
393 } 378 }
@@ -396,13 +381,16 @@ acpi_ev_address_space_dispatch (
396 381
397 handler = handler_desc->address_space.handler; 382 handler = handler_desc->address_space.handler;
398 383
399 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 384 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
400 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", 385 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
401 &region_obj->region.handler->address_space, handler, 386 &region_obj->region.handler->address_space, handler,
402 ACPI_FORMAT_UINT64 (address), 387 ACPI_FORMAT_UINT64(address),
403 acpi_ut_get_region_name (region_obj->region.space_id))); 388 acpi_ut_get_region_name(region_obj->region.
389 space_id)));
404 390
405 if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { 391 if (!
392 (handler_desc->address_space.
393 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
406 /* 394 /*
407 * For handlers other than the default (supplied) handlers, we must 395 * For handlers other than the default (supplied) handlers, we must
408 * exit the interpreter because the handler *might* block -- we don't 396 * exit the interpreter because the handler *might* block -- we don't
@@ -413,31 +401,33 @@ acpi_ev_address_space_dispatch (
413 401
414 /* Call the handler */ 402 /* Call the handler */
415 403
416 status = handler (function, address, bit_width, value, 404 status = handler(function, address, bit_width, value,
417 handler_desc->address_space.context, 405 handler_desc->address_space.context,
418 region_obj2->extra.region_context); 406 region_obj2->extra.region_context);
419 407
420 if (ACPI_FAILURE (status)) { 408 if (ACPI_FAILURE(status)) {
421 ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n", 409 ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n",
422 acpi_ut_get_region_name (region_obj->region.space_id), 410 acpi_ut_get_region_name(region_obj->region.
423 acpi_format_exception (status))); 411 space_id),
412 acpi_format_exception(status)));
424 } 413 }
425 414
426 if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { 415 if (!
416 (handler_desc->address_space.
417 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
427 /* 418 /*
428 * We just returned from a non-default handler, we must re-enter the 419 * We just returned from a non-default handler, we must re-enter the
429 * interpreter 420 * interpreter
430 */ 421 */
431 status2 = acpi_ex_enter_interpreter (); 422 status2 = acpi_ex_enter_interpreter();
432 if (ACPI_FAILURE (status2)) { 423 if (ACPI_FAILURE(status2)) {
433 return_ACPI_STATUS (status2); 424 return_ACPI_STATUS(status2);
434 } 425 }
435 } 426 }
436 427
437 return_ACPI_STATUS (status); 428 return_ACPI_STATUS(status);
438} 429}
439 430
440
441/******************************************************************************* 431/*******************************************************************************
442 * 432 *
443 * FUNCTION: acpi_ev_detach_region 433 * FUNCTION: acpi_ev_detach_region
@@ -453,23 +443,20 @@ acpi_ev_address_space_dispatch (
453 ******************************************************************************/ 443 ******************************************************************************/
454 444
455void 445void
456acpi_ev_detach_region( 446acpi_ev_detach_region(union acpi_operand_object *region_obj,
457 union acpi_operand_object *region_obj, 447 u8 acpi_ns_is_locked)
458 u8 acpi_ns_is_locked)
459{ 448{
460 union acpi_operand_object *handler_obj; 449 union acpi_operand_object *handler_obj;
461 union acpi_operand_object *obj_desc; 450 union acpi_operand_object *obj_desc;
462 union acpi_operand_object **last_obj_ptr; 451 union acpi_operand_object **last_obj_ptr;
463 acpi_adr_space_setup region_setup; 452 acpi_adr_space_setup region_setup;
464 void **region_context; 453 void **region_context;
465 union acpi_operand_object *region_obj2; 454 union acpi_operand_object *region_obj2;
466 acpi_status status; 455 acpi_status status;
467
468
469 ACPI_FUNCTION_TRACE ("ev_detach_region");
470 456
457 ACPI_FUNCTION_TRACE("ev_detach_region");
471 458
472 region_obj2 = acpi_ns_get_secondary_object (region_obj); 459 region_obj2 = acpi_ns_get_secondary_object(region_obj);
473 if (!region_obj2) { 460 if (!region_obj2) {
474 return_VOID; 461 return_VOID;
475 } 462 }
@@ -493,34 +480,39 @@ acpi_ev_detach_region(
493 /* Is this the correct Region? */ 480 /* Is this the correct Region? */
494 481
495 if (obj_desc == region_obj) { 482 if (obj_desc == region_obj) {
496 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 483 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
497 "Removing Region %p from address handler %p\n", 484 "Removing Region %p from address handler %p\n",
498 region_obj, handler_obj)); 485 region_obj, handler_obj));
499 486
500 /* This is it, remove it from the handler's list */ 487 /* This is it, remove it from the handler's list */
501 488
502 *last_obj_ptr = obj_desc->region.next; 489 *last_obj_ptr = obj_desc->region.next;
503 obj_desc->region.next = NULL; /* Must clear field */ 490 obj_desc->region.next = NULL; /* Must clear field */
504 491
505 if (acpi_ns_is_locked) { 492 if (acpi_ns_is_locked) {
506 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 493 status =
507 if (ACPI_FAILURE (status)) { 494 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
495 if (ACPI_FAILURE(status)) {
508 return_VOID; 496 return_VOID;
509 } 497 }
510 } 498 }
511 499
512 /* Now stop region accesses by executing the _REG method */ 500 /* Now stop region accesses by executing the _REG method */
513 501
514 status = acpi_ev_execute_reg_method (region_obj, 0); 502 status = acpi_ev_execute_reg_method(region_obj, 0);
515 if (ACPI_FAILURE (status)) { 503 if (ACPI_FAILURE(status)) {
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n", 504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
517 acpi_format_exception (status), 505 "%s from region _REG, [%s]\n",
518 acpi_ut_get_region_name (region_obj->region.space_id))); 506 acpi_format_exception(status),
507 acpi_ut_get_region_name
508 (region_obj->region.
509 space_id)));
519 } 510 }
520 511
521 if (acpi_ns_is_locked) { 512 if (acpi_ns_is_locked) {
522 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 513 status =
523 if (ACPI_FAILURE (status)) { 514 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
515 if (ACPI_FAILURE(status)) {
524 return_VOID; 516 return_VOID;
525 } 517 }
526 } 518 }
@@ -528,15 +520,20 @@ acpi_ev_detach_region(
528 /* Call the setup handler with the deactivate notification */ 520 /* Call the setup handler with the deactivate notification */
529 521
530 region_setup = handler_obj->address_space.setup; 522 region_setup = handler_obj->address_space.setup;
531 status = region_setup (region_obj, ACPI_REGION_DEACTIVATE, 523 status =
532 handler_obj->address_space.context, region_context); 524 region_setup(region_obj, ACPI_REGION_DEACTIVATE,
525 handler_obj->address_space.context,
526 region_context);
533 527
534 /* Init routine may fail, Just ignore errors */ 528 /* Init routine may fail, Just ignore errors */
535 529
536 if (ACPI_FAILURE (status)) { 530 if (ACPI_FAILURE(status)) {
537 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n", 531 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
538 acpi_format_exception (status), 532 "%s from region init, [%s]\n",
539 acpi_ut_get_region_name (region_obj->region.space_id))); 533 acpi_format_exception(status),
534 acpi_ut_get_region_name
535 (region_obj->region.
536 space_id)));
540 } 537 }
541 538
542 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); 539 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
@@ -552,7 +549,7 @@ acpi_ev_detach_region(
552 * this better be the region's handler 549 * this better be the region's handler
553 */ 550 */
554 region_obj->region.handler = NULL; 551 region_obj->region.handler = NULL;
555 acpi_ut_remove_reference (handler_obj); 552 acpi_ut_remove_reference(handler_obj);
556 553
557 return_VOID; 554 return_VOID;
558 } 555 }
@@ -565,14 +562,13 @@ acpi_ev_detach_region(
565 562
566 /* If we get here, the region was not in the handler's region list */ 563 /* If we get here, the region was not in the handler's region list */
567 564
568 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 565 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
569 "Cannot remove region %p from address handler %p\n", 566 "Cannot remove region %p from address handler %p\n",
570 region_obj, handler_obj)); 567 region_obj, handler_obj));
571 568
572 return_VOID; 569 return_VOID;
573} 570}
574 571
575
576/******************************************************************************* 572/*******************************************************************************
577 * 573 *
578 * FUNCTION: acpi_ev_attach_region 574 * FUNCTION: acpi_ev_attach_region
@@ -589,20 +585,19 @@ acpi_ev_detach_region(
589 ******************************************************************************/ 585 ******************************************************************************/
590 586
591acpi_status 587acpi_status
592acpi_ev_attach_region ( 588acpi_ev_attach_region(union acpi_operand_object *handler_obj,
593 union acpi_operand_object *handler_obj, 589 union acpi_operand_object *region_obj,
594 union acpi_operand_object *region_obj, 590 u8 acpi_ns_is_locked)
595 u8 acpi_ns_is_locked)
596{ 591{
597 592
598 ACPI_FUNCTION_TRACE ("ev_attach_region"); 593 ACPI_FUNCTION_TRACE("ev_attach_region");
599
600 594
601 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 595 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
602 "Adding Region [%4.4s] %p to address handler %p [%s]\n", 596 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
603 acpi_ut_get_node_name (region_obj->region.node), 597 acpi_ut_get_node_name(region_obj->region.node),
604 region_obj, handler_obj, 598 region_obj, handler_obj,
605 acpi_ut_get_region_name (region_obj->region.space_id))); 599 acpi_ut_get_region_name(region_obj->region.
600 space_id)));
606 601
607 /* Link this region to the front of the handler's list */ 602 /* Link this region to the front of the handler's list */
608 603
@@ -612,16 +607,15 @@ acpi_ev_attach_region (
612 /* Install the region's handler */ 607 /* Install the region's handler */
613 608
614 if (region_obj->region.handler) { 609 if (region_obj->region.handler) {
615 return_ACPI_STATUS (AE_ALREADY_EXISTS); 610 return_ACPI_STATUS(AE_ALREADY_EXISTS);
616 } 611 }
617 612
618 region_obj->region.handler = handler_obj; 613 region_obj->region.handler = handler_obj;
619 acpi_ut_add_reference (handler_obj); 614 acpi_ut_add_reference(handler_obj);
620 615
621 return_ACPI_STATUS (AE_OK); 616 return_ACPI_STATUS(AE_OK);
622} 617}
623 618
624
625/******************************************************************************* 619/*******************************************************************************
626 * 620 *
627 * FUNCTION: acpi_ev_install_handler 621 * FUNCTION: acpi_ev_install_handler
@@ -640,23 +634,18 @@ acpi_ev_attach_region (
640 ******************************************************************************/ 634 ******************************************************************************/
641 635
642static acpi_status 636static acpi_status
643acpi_ev_install_handler ( 637acpi_ev_install_handler(acpi_handle obj_handle,
644 acpi_handle obj_handle, 638 u32 level, void *context, void **return_value)
645 u32 level,
646 void *context,
647 void **return_value)
648{ 639{
649 union acpi_operand_object *handler_obj; 640 union acpi_operand_object *handler_obj;
650 union acpi_operand_object *next_handler_obj; 641 union acpi_operand_object *next_handler_obj;
651 union acpi_operand_object *obj_desc; 642 union acpi_operand_object *obj_desc;
652 struct acpi_namespace_node *node; 643 struct acpi_namespace_node *node;
653 acpi_status status; 644 acpi_status status;
654 645
646 ACPI_FUNCTION_NAME("ev_install_handler");
655 647
656 ACPI_FUNCTION_NAME ("ev_install_handler"); 648 handler_obj = (union acpi_operand_object *)context;
657
658
659 handler_obj = (union acpi_operand_object *) context;
660 649
661 /* Parameter validation */ 650 /* Parameter validation */
662 651
@@ -666,7 +655,7 @@ acpi_ev_install_handler (
666 655
667 /* Convert and validate the device handle */ 656 /* Convert and validate the device handle */
668 657
669 node = acpi_ns_map_handle_to_node (obj_handle); 658 node = acpi_ns_map_handle_to_node(obj_handle);
670 if (!node) { 659 if (!node) {
671 return (AE_BAD_PARAMETER); 660 return (AE_BAD_PARAMETER);
672 } 661 }
@@ -676,14 +665,13 @@ acpi_ev_install_handler (
676 * that are allowed to have address space handlers 665 * that are allowed to have address space handlers
677 */ 666 */
678 if ((node->type != ACPI_TYPE_DEVICE) && 667 if ((node->type != ACPI_TYPE_DEVICE) &&
679 (node->type != ACPI_TYPE_REGION) && 668 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
680 (node != acpi_gbl_root_node)) {
681 return (AE_OK); 669 return (AE_OK);
682 } 670 }
683 671
684 /* Check for an existing internal object */ 672 /* Check for an existing internal object */
685 673
686 obj_desc = acpi_ns_get_attached_object (node); 674 obj_desc = acpi_ns_get_attached_object(node);
687 if (!obj_desc) { 675 if (!obj_desc) {
688 /* No object, just exit */ 676 /* No object, just exit */
689 677
@@ -692,18 +680,22 @@ acpi_ev_install_handler (
692 680
693 /* Devices are handled different than regions */ 681 /* Devices are handled different than regions */
694 682
695 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_DEVICE) { 683 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) {
696 /* Check if this Device already has a handler for this address space */ 684 /* Check if this Device already has a handler for this address space */
697 685
698 next_handler_obj = obj_desc->device.handler; 686 next_handler_obj = obj_desc->device.handler;
699 while (next_handler_obj) { 687 while (next_handler_obj) {
700 /* Found a handler, is it for the same address space? */ 688 /* Found a handler, is it for the same address space? */
701 689
702 if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) { 690 if (next_handler_obj->address_space.space_id ==
703 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 691 handler_obj->address_space.space_id) {
704 "Found handler for region [%s] in device %p(%p) handler %p\n", 692 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
705 acpi_ut_get_region_name (handler_obj->address_space.space_id), 693 "Found handler for region [%s] in device %p(%p) handler %p\n",
706 obj_desc, next_handler_obj, handler_obj)); 694 acpi_ut_get_region_name
695 (handler_obj->address_space.
696 space_id), obj_desc,
697 next_handler_obj,
698 handler_obj));
707 699
708 /* 700 /*
709 * Since the object we found it on was a device, then it 701 * Since the object we found it on was a device, then it
@@ -744,15 +736,14 @@ acpi_ev_install_handler (
744 * 736 *
745 * First disconnect region for any previous handler (if any) 737 * First disconnect region for any previous handler (if any)
746 */ 738 */
747 acpi_ev_detach_region (obj_desc, FALSE); 739 acpi_ev_detach_region(obj_desc, FALSE);
748 740
749 /* Connect the region to the new handler */ 741 /* Connect the region to the new handler */
750 742
751 status = acpi_ev_attach_region (handler_obj, obj_desc, FALSE); 743 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
752 return (status); 744 return (status);
753} 745}
754 746
755
756/******************************************************************************* 747/*******************************************************************************
757 * 748 *
758 * FUNCTION: acpi_ev_install_space_handler 749 * FUNCTION: acpi_ev_install_space_handler
@@ -771,32 +762,27 @@ acpi_ev_install_handler (
771 ******************************************************************************/ 762 ******************************************************************************/
772 763
773acpi_status 764acpi_status
774acpi_ev_install_space_handler ( 765acpi_ev_install_space_handler(struct acpi_namespace_node * node,
775 struct acpi_namespace_node *node, 766 acpi_adr_space_type space_id,
776 acpi_adr_space_type space_id, 767 acpi_adr_space_handler handler,
777 acpi_adr_space_handler handler, 768 acpi_adr_space_setup setup, void *context)
778 acpi_adr_space_setup setup,
779 void *context)
780{ 769{
781 union acpi_operand_object *obj_desc; 770 union acpi_operand_object *obj_desc;
782 union acpi_operand_object *handler_obj; 771 union acpi_operand_object *handler_obj;
783 acpi_status status; 772 acpi_status status;
784 acpi_object_type type; 773 acpi_object_type type;
785 u16 flags = 0; 774 u16 flags = 0;
786
787
788 ACPI_FUNCTION_TRACE ("ev_install_space_handler");
789 775
776 ACPI_FUNCTION_TRACE("ev_install_space_handler");
790 777
791 /* 778 /*
792 * This registration is valid for only the types below 779 * This registration is valid for only the types below
793 * and the root. This is where the default handlers 780 * and the root. This is where the default handlers
794 * get placed. 781 * get placed.
795 */ 782 */
796 if ((node->type != ACPI_TYPE_DEVICE) && 783 if ((node->type != ACPI_TYPE_DEVICE) &&
797 (node->type != ACPI_TYPE_PROCESSOR) && 784 (node->type != ACPI_TYPE_PROCESSOR) &&
798 (node->type != ACPI_TYPE_THERMAL) && 785 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
799 (node != acpi_gbl_root_node)) {
800 status = AE_BAD_PARAMETER; 786 status = AE_BAD_PARAMETER;
801 goto unlock_and_exit; 787 goto unlock_and_exit;
802 } 788 }
@@ -807,32 +793,32 @@ acpi_ev_install_space_handler (
807 switch (space_id) { 793 switch (space_id) {
808 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 794 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
809 handler = acpi_ex_system_memory_space_handler; 795 handler = acpi_ex_system_memory_space_handler;
810 setup = acpi_ev_system_memory_region_setup; 796 setup = acpi_ev_system_memory_region_setup;
811 break; 797 break;
812 798
813 case ACPI_ADR_SPACE_SYSTEM_IO: 799 case ACPI_ADR_SPACE_SYSTEM_IO:
814 handler = acpi_ex_system_io_space_handler; 800 handler = acpi_ex_system_io_space_handler;
815 setup = acpi_ev_io_space_region_setup; 801 setup = acpi_ev_io_space_region_setup;
816 break; 802 break;
817 803
818 case ACPI_ADR_SPACE_PCI_CONFIG: 804 case ACPI_ADR_SPACE_PCI_CONFIG:
819 handler = acpi_ex_pci_config_space_handler; 805 handler = acpi_ex_pci_config_space_handler;
820 setup = acpi_ev_pci_config_region_setup; 806 setup = acpi_ev_pci_config_region_setup;
821 break; 807 break;
822 808
823 case ACPI_ADR_SPACE_CMOS: 809 case ACPI_ADR_SPACE_CMOS:
824 handler = acpi_ex_cmos_space_handler; 810 handler = acpi_ex_cmos_space_handler;
825 setup = acpi_ev_cmos_region_setup; 811 setup = acpi_ev_cmos_region_setup;
826 break; 812 break;
827 813
828 case ACPI_ADR_SPACE_PCI_BAR_TARGET: 814 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
829 handler = acpi_ex_pci_bar_space_handler; 815 handler = acpi_ex_pci_bar_space_handler;
830 setup = acpi_ev_pci_bar_region_setup; 816 setup = acpi_ev_pci_bar_region_setup;
831 break; 817 break;
832 818
833 case ACPI_ADR_SPACE_DATA_TABLE: 819 case ACPI_ADR_SPACE_DATA_TABLE:
834 handler = acpi_ex_data_table_space_handler; 820 handler = acpi_ex_data_table_space_handler;
835 setup = NULL; 821 setup = NULL;
836 break; 822 break;
837 823
838 default: 824 default:
@@ -849,7 +835,7 @@ acpi_ev_install_space_handler (
849 835
850 /* Check for an existing internal object */ 836 /* Check for an existing internal object */
851 837
852 obj_desc = acpi_ns_get_attached_object (node); 838 obj_desc = acpi_ns_get_attached_object(node);
853 if (obj_desc) { 839 if (obj_desc) {
854 /* 840 /*
855 * The attached device object already exists. 841 * The attached device object already exists.
@@ -863,7 +849,8 @@ acpi_ev_install_space_handler (
863 /* Same space_id indicates a handler already installed */ 849 /* Same space_id indicates a handler already installed */
864 850
865 if (handler_obj->address_space.space_id == space_id) { 851 if (handler_obj->address_space.space_id == space_id) {
866 if (handler_obj->address_space.handler == handler) { 852 if (handler_obj->address_space.handler ==
853 handler) {
867 /* 854 /*
868 * It is (relatively) OK to attempt to install the SAME 855 * It is (relatively) OK to attempt to install the SAME
869 * handler twice. This can easily happen 856 * handler twice. This can easily happen
@@ -871,8 +858,7 @@ acpi_ev_install_space_handler (
871 */ 858 */
872 status = AE_SAME_HANDLER; 859 status = AE_SAME_HANDLER;
873 goto unlock_and_exit; 860 goto unlock_and_exit;
874 } 861 } else {
875 else {
876 /* A handler is already installed */ 862 /* A handler is already installed */
877 863
878 status = AE_ALREADY_EXISTS; 864 status = AE_ALREADY_EXISTS;
@@ -884,21 +870,20 @@ acpi_ev_install_space_handler (
884 870
885 handler_obj = handler_obj->address_space.next; 871 handler_obj = handler_obj->address_space.next;
886 } 872 }
887 } 873 } else {
888 else { 874 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
889 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 875 "Creating object on Device %p while installing handler\n",
890 "Creating object on Device %p while installing handler\n", node)); 876 node));
891 877
892 /* obj_desc does not exist, create one */ 878 /* obj_desc does not exist, create one */
893 879
894 if (node->type == ACPI_TYPE_ANY) { 880 if (node->type == ACPI_TYPE_ANY) {
895 type = ACPI_TYPE_DEVICE; 881 type = ACPI_TYPE_DEVICE;
896 } 882 } else {
897 else {
898 type = node->type; 883 type = node->type;
899 } 884 }
900 885
901 obj_desc = acpi_ut_create_internal_object (type); 886 obj_desc = acpi_ut_create_internal_object(type);
902 if (!obj_desc) { 887 if (!obj_desc) {
903 status = AE_NO_MEMORY; 888 status = AE_NO_MEMORY;
904 goto unlock_and_exit; 889 goto unlock_and_exit;
@@ -910,21 +895,21 @@ acpi_ev_install_space_handler (
910 895
911 /* Attach the new object to the Node */ 896 /* Attach the new object to the Node */
912 897
913 status = acpi_ns_attach_object (node, obj_desc, type); 898 status = acpi_ns_attach_object(node, obj_desc, type);
914 899
915 /* Remove local reference to the object */ 900 /* Remove local reference to the object */
916 901
917 acpi_ut_remove_reference (obj_desc); 902 acpi_ut_remove_reference(obj_desc);
918 903
919 if (ACPI_FAILURE (status)) { 904 if (ACPI_FAILURE(status)) {
920 goto unlock_and_exit; 905 goto unlock_and_exit;
921 } 906 }
922 } 907 }
923 908
924 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 909 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
925 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", 910 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
926 acpi_ut_get_region_name (space_id), space_id, 911 acpi_ut_get_region_name(space_id), space_id,
927 acpi_ut_get_node_name (node), node, obj_desc)); 912 acpi_ut_get_node_name(node), node, obj_desc));
928 913
929 /* 914 /*
930 * Install the handler 915 * Install the handler
@@ -933,7 +918,8 @@ acpi_ev_install_space_handler (
933 * Just allocate the object for the handler and link it 918 * Just allocate the object for the handler and link it
934 * into the list. 919 * into the list.
935 */ 920 */
936 handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); 921 handler_obj =
922 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
937 if (!handler_obj) { 923 if (!handler_obj) {
938 status = AE_NO_MEMORY; 924 status = AE_NO_MEMORY;
939 goto unlock_and_exit; 925 goto unlock_and_exit;
@@ -941,17 +927,17 @@ acpi_ev_install_space_handler (
941 927
942 /* Init handler obj */ 928 /* Init handler obj */
943 929
944 handler_obj->address_space.space_id = (u8) space_id; 930 handler_obj->address_space.space_id = (u8) space_id;
945 handler_obj->address_space.hflags = flags; 931 handler_obj->address_space.hflags = flags;
946 handler_obj->address_space.region_list = NULL; 932 handler_obj->address_space.region_list = NULL;
947 handler_obj->address_space.node = node; 933 handler_obj->address_space.node = node;
948 handler_obj->address_space.handler = handler; 934 handler_obj->address_space.handler = handler;
949 handler_obj->address_space.context = context; 935 handler_obj->address_space.context = context;
950 handler_obj->address_space.setup = setup; 936 handler_obj->address_space.setup = setup;
951 937
952 /* Install at head of Device.address_space list */ 938 /* Install at head of Device.address_space list */
953 939
954 handler_obj->address_space.next = obj_desc->device.handler; 940 handler_obj->address_space.next = obj_desc->device.handler;
955 941
956 /* 942 /*
957 * The Device object is the first reference on the handler_obj. 943 * The Device object is the first reference on the handler_obj.
@@ -971,15 +957,15 @@ acpi_ev_install_space_handler (
971 * In either case, back up and search down the remainder 957 * In either case, back up and search down the remainder
972 * of the branch 958 * of the branch
973 */ 959 */
974 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 960 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
975 ACPI_NS_WALK_UNLOCK, acpi_ev_install_handler, 961 ACPI_NS_WALK_UNLOCK,
976 handler_obj, NULL); 962 acpi_ev_install_handler, handler_obj,
963 NULL);
977 964
978unlock_and_exit: 965 unlock_and_exit:
979 return_ACPI_STATUS (status); 966 return_ACPI_STATUS(status);
980} 967}
981 968
982
983/******************************************************************************* 969/*******************************************************************************
984 * 970 *
985 * FUNCTION: acpi_ev_execute_reg_methods 971 * FUNCTION: acpi_ev_execute_reg_methods
@@ -995,15 +981,12 @@ unlock_and_exit:
995 ******************************************************************************/ 981 ******************************************************************************/
996 982
997acpi_status 983acpi_status
998acpi_ev_execute_reg_methods ( 984acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
999 struct acpi_namespace_node *node, 985 acpi_adr_space_type space_id)
1000 acpi_adr_space_type space_id)
1001{ 986{
1002 acpi_status status; 987 acpi_status status;
1003
1004
1005 ACPI_FUNCTION_TRACE ("ev_execute_reg_methods");
1006 988
989 ACPI_FUNCTION_TRACE("ev_execute_reg_methods");
1007 990
1008 /* 991 /*
1009 * Run all _REG methods for all Operation Regions for this 992 * Run all _REG methods for all Operation Regions for this
@@ -1012,14 +995,13 @@ acpi_ev_execute_reg_methods (
1012 * must be installed for all regions of this Space ID before we 995 * must be installed for all regions of this Space ID before we
1013 * can run any _REG methods) 996 * can run any _REG methods)
1014 */ 997 */
1015 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 998 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1016 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 999 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1017 &space_id, NULL); 1000 &space_id, NULL);
1018 1001
1019 return_ACPI_STATUS (status); 1002 return_ACPI_STATUS(status);
1020} 1003}
1021 1004
1022
1023/******************************************************************************* 1005/*******************************************************************************
1024 * 1006 *
1025 * FUNCTION: acpi_ev_reg_run 1007 * FUNCTION: acpi_ev_reg_run
@@ -1031,23 +1013,19 @@ acpi_ev_execute_reg_methods (
1031 ******************************************************************************/ 1013 ******************************************************************************/
1032 1014
1033static acpi_status 1015static acpi_status
1034acpi_ev_reg_run ( 1016acpi_ev_reg_run(acpi_handle obj_handle,
1035 acpi_handle obj_handle, 1017 u32 level, void *context, void **return_value)
1036 u32 level,
1037 void *context,
1038 void **return_value)
1039{ 1018{
1040 union acpi_operand_object *obj_desc; 1019 union acpi_operand_object *obj_desc;
1041 struct acpi_namespace_node *node; 1020 struct acpi_namespace_node *node;
1042 acpi_adr_space_type space_id; 1021 acpi_adr_space_type space_id;
1043 acpi_status status; 1022 acpi_status status;
1044 1023
1045 1024 space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context);
1046 space_id = *ACPI_CAST_PTR (acpi_adr_space_type, context);
1047 1025
1048 /* Convert and validate the device handle */ 1026 /* Convert and validate the device handle */
1049 1027
1050 node = acpi_ns_map_handle_to_node (obj_handle); 1028 node = acpi_ns_map_handle_to_node(obj_handle);
1051 if (!node) { 1029 if (!node) {
1052 return (AE_BAD_PARAMETER); 1030 return (AE_BAD_PARAMETER);
1053 } 1031 }
@@ -1056,14 +1034,13 @@ acpi_ev_reg_run (
1056 * We only care about regions.and objects 1034 * We only care about regions.and objects
1057 * that are allowed to have address space handlers 1035 * that are allowed to have address space handlers
1058 */ 1036 */
1059 if ((node->type != ACPI_TYPE_REGION) && 1037 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1060 (node != acpi_gbl_root_node)) {
1061 return (AE_OK); 1038 return (AE_OK);
1062 } 1039 }
1063 1040
1064 /* Check for an existing internal object */ 1041 /* Check for an existing internal object */
1065 1042
1066 obj_desc = acpi_ns_get_attached_object (node); 1043 obj_desc = acpi_ns_get_attached_object(node);
1067 if (!obj_desc) { 1044 if (!obj_desc) {
1068 /* No object, just exit */ 1045 /* No object, just exit */
1069 1046
@@ -1080,7 +1057,6 @@ acpi_ev_reg_run (
1080 return (AE_OK); 1057 return (AE_OK);
1081 } 1058 }
1082 1059
1083 status = acpi_ev_execute_reg_method (obj_desc, 1); 1060 status = acpi_ev_execute_reg_method(obj_desc, 1);
1084 return (status); 1061 return (status);
1085} 1062}
1086
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 95bc09c73a6a..a1bd2da27c45 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -41,14 +41,12 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acevents.h> 45#include <acpi/acevents.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evrgnini") 49ACPI_MODULE_NAME("evrgnini")
51
52 50
53/******************************************************************************* 51/*******************************************************************************
54 * 52 *
@@ -64,34 +62,31 @@
64 * DESCRIPTION: Setup a system_memory operation region 62 * DESCRIPTION: Setup a system_memory operation region
65 * 63 *
66 ******************************************************************************/ 64 ******************************************************************************/
67
68acpi_status 65acpi_status
69acpi_ev_system_memory_region_setup ( 66acpi_ev_system_memory_region_setup(acpi_handle handle,
70 acpi_handle handle, 67 u32 function,
71 u32 function, 68 void *handler_context, void **region_context)
72 void *handler_context,
73 void **region_context)
74{ 69{
75 union acpi_operand_object *region_desc = (union acpi_operand_object *) handle; 70 union acpi_operand_object *region_desc =
76 struct acpi_mem_space_context *local_region_context; 71 (union acpi_operand_object *)handle;
77 72 struct acpi_mem_space_context *local_region_context;
78
79 ACPI_FUNCTION_TRACE ("ev_system_memory_region_setup");
80 73
74 ACPI_FUNCTION_TRACE("ev_system_memory_region_setup");
81 75
82 if (function == ACPI_REGION_DEACTIVATE) { 76 if (function == ACPI_REGION_DEACTIVATE) {
83 if (*region_context) { 77 if (*region_context) {
84 ACPI_MEM_FREE (*region_context); 78 ACPI_MEM_FREE(*region_context);
85 *region_context = NULL; 79 *region_context = NULL;
86 } 80 }
87 return_ACPI_STATUS (AE_OK); 81 return_ACPI_STATUS(AE_OK);
88 } 82 }
89 83
90 /* Create a new context */ 84 /* Create a new context */
91 85
92 local_region_context = ACPI_MEM_CALLOCATE (sizeof (struct acpi_mem_space_context)); 86 local_region_context =
87 ACPI_MEM_CALLOCATE(sizeof(struct acpi_mem_space_context));
93 if (!(local_region_context)) { 88 if (!(local_region_context)) {
94 return_ACPI_STATUS (AE_NO_MEMORY); 89 return_ACPI_STATUS(AE_NO_MEMORY);
95 } 90 }
96 91
97 /* Save the region length and address for use in the handler */ 92 /* Save the region length and address for use in the handler */
@@ -100,10 +95,9 @@ acpi_ev_system_memory_region_setup (
100 local_region_context->address = region_desc->region.address; 95 local_region_context->address = region_desc->region.address;
101 96
102 *region_context = local_region_context; 97 *region_context = local_region_context;
103 return_ACPI_STATUS (AE_OK); 98 return_ACPI_STATUS(AE_OK);
104} 99}
105 100
106
107/******************************************************************************* 101/*******************************************************************************
108 * 102 *
109 * FUNCTION: acpi_ev_io_space_region_setup 103 * FUNCTION: acpi_ev_io_space_region_setup
@@ -120,26 +114,21 @@ acpi_ev_system_memory_region_setup (
120 ******************************************************************************/ 114 ******************************************************************************/
121 115
122acpi_status 116acpi_status
123acpi_ev_io_space_region_setup ( 117acpi_ev_io_space_region_setup(acpi_handle handle,
124 acpi_handle handle, 118 u32 function,
125 u32 function, 119 void *handler_context, void **region_context)
126 void *handler_context,
127 void **region_context)
128{ 120{
129 ACPI_FUNCTION_TRACE ("ev_io_space_region_setup"); 121 ACPI_FUNCTION_TRACE("ev_io_space_region_setup");
130
131 122
132 if (function == ACPI_REGION_DEACTIVATE) { 123 if (function == ACPI_REGION_DEACTIVATE) {
133 *region_context = NULL; 124 *region_context = NULL;
134 } 125 } else {
135 else {
136 *region_context = handler_context; 126 *region_context = handler_context;
137 } 127 }
138 128
139 return_ACPI_STATUS (AE_OK); 129 return_ACPI_STATUS(AE_OK);
140} 130}
141 131
142
143/******************************************************************************* 132/*******************************************************************************
144 * 133 *
145 * FUNCTION: acpi_ev_pci_config_region_setup 134 * FUNCTION: acpi_ev_pci_config_region_setup
@@ -158,24 +147,21 @@ acpi_ev_io_space_region_setup (
158 ******************************************************************************/ 147 ******************************************************************************/
159 148
160acpi_status 149acpi_status
161acpi_ev_pci_config_region_setup ( 150acpi_ev_pci_config_region_setup(acpi_handle handle,
162 acpi_handle handle, 151 u32 function,
163 u32 function, 152 void *handler_context, void **region_context)
164 void *handler_context,
165 void **region_context)
166{ 153{
167 acpi_status status = AE_OK; 154 acpi_status status = AE_OK;
168 acpi_integer pci_value; 155 acpi_integer pci_value;
169 struct acpi_pci_id *pci_id = *region_context; 156 struct acpi_pci_id *pci_id = *region_context;
170 union acpi_operand_object *handler_obj; 157 union acpi_operand_object *handler_obj;
171 struct acpi_namespace_node *parent_node; 158 struct acpi_namespace_node *parent_node;
172 struct acpi_namespace_node *pci_root_node; 159 struct acpi_namespace_node *pci_root_node;
173 union acpi_operand_object *region_obj = (union acpi_operand_object *) handle; 160 union acpi_operand_object *region_obj =
174 struct acpi_device_id object_hID; 161 (union acpi_operand_object *)handle;
175 162 struct acpi_device_id object_hID;
176 163
177 ACPI_FUNCTION_TRACE ("ev_pci_config_region_setup"); 164 ACPI_FUNCTION_TRACE("ev_pci_config_region_setup");
178
179 165
180 handler_obj = region_obj->region.handler; 166 handler_obj = region_obj->region.handler;
181 if (!handler_obj) { 167 if (!handler_obj) {
@@ -183,20 +169,21 @@ acpi_ev_pci_config_region_setup (
183 * No installed handler. This shouldn't happen because the dispatch 169 * No installed handler. This shouldn't happen because the dispatch
184 * routine checks before we get here, but we check again just in case. 170 * routine checks before we get here, but we check again just in case.
185 */ 171 */
186 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 172 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
187 "Attempting to init a region %p, with no handler\n", region_obj)); 173 "Attempting to init a region %p, with no handler\n",
188 return_ACPI_STATUS (AE_NOT_EXIST); 174 region_obj));
175 return_ACPI_STATUS(AE_NOT_EXIST);
189 } 176 }
190 177
191 *region_context = NULL; 178 *region_context = NULL;
192 if (function == ACPI_REGION_DEACTIVATE) { 179 if (function == ACPI_REGION_DEACTIVATE) {
193 if (pci_id) { 180 if (pci_id) {
194 ACPI_MEM_FREE (pci_id); 181 ACPI_MEM_FREE(pci_id);
195 } 182 }
196 return_ACPI_STATUS (status); 183 return_ACPI_STATUS(status);
197 } 184 }
198 185
199 parent_node = acpi_ns_get_parent_node (region_obj->region.node); 186 parent_node = acpi_ns_get_parent_node(region_obj->region.node);
200 187
201 /* 188 /*
202 * Get the _SEG and _BBN values from the device upon which the handler 189 * Get the _SEG and _BBN values from the device upon which the handler
@@ -216,18 +203,28 @@ acpi_ev_pci_config_region_setup (
216 203
217 pci_root_node = parent_node; 204 pci_root_node = parent_node;
218 while (pci_root_node != acpi_gbl_root_node) { 205 while (pci_root_node != acpi_gbl_root_node) {
219 status = acpi_ut_execute_HID (pci_root_node, &object_hID); 206 status =
220 if (ACPI_SUCCESS (status)) { 207 acpi_ut_execute_HID(pci_root_node, &object_hID);
221 /* Got a valid _HID, check if this is a PCI root */ 208 if (ACPI_SUCCESS(status)) {
222 209 /*
223 if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, 210 * Got a valid _HID string, check if this is a PCI root.
224 sizeof (PCI_ROOT_HID_STRING)))) { 211 * New for ACPI 3.0: check for a PCI Express root also.
212 */
213 if (!
214 (ACPI_STRNCMP
215 (object_hID.value, PCI_ROOT_HID_STRING,
216 sizeof(PCI_ROOT_HID_STRING))
217 ||
218 !(ACPI_STRNCMP
219 (object_hID.value,
220 PCI_EXPRESS_ROOT_HID_STRING,
221 sizeof(PCI_EXPRESS_ROOT_HID_STRING)))))
222 {
225 /* Install a handler for this PCI root bridge */ 223 /* Install a handler for this PCI root bridge */
226 224
227 status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, 225 status =
228 ACPI_ADR_SPACE_PCI_CONFIG, 226 acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
229 ACPI_DEFAULT_HANDLER, NULL, NULL); 227 if (ACPI_FAILURE(status)) {
230 if (ACPI_FAILURE (status)) {
231 if (status == AE_SAME_HANDLER) { 228 if (status == AE_SAME_HANDLER) {
232 /* 229 /*
233 * It is OK if the handler is already installed on the root 230 * It is OK if the handler is already installed on the root
@@ -235,23 +232,19 @@ acpi_ev_pci_config_region_setup (
235 * new PCI_Config operation region, however. 232 * new PCI_Config operation region, however.
236 */ 233 */
237 status = AE_OK; 234 status = AE_OK;
238 } 235 } else {
239 else { 236 ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status)));
240 ACPI_REPORT_ERROR ((
241 "Could not install pci_config handler for Root Bridge %4.4s, %s\n",
242 acpi_ut_get_node_name (pci_root_node), acpi_format_exception (status)));
243 } 237 }
244 } 238 }
245 break; 239 break;
246 } 240 }
247 } 241 }
248 242
249 pci_root_node = acpi_ns_get_parent_node (pci_root_node); 243 pci_root_node = acpi_ns_get_parent_node(pci_root_node);
250 } 244 }
251 245
252 /* PCI root bridge not found, use namespace root node */ 246 /* PCI root bridge not found, use namespace root node */
253 } 247 } else {
254 else {
255 pci_root_node = handler_obj->address_space.node; 248 pci_root_node = handler_obj->address_space.node;
256 } 249 }
257 250
@@ -260,14 +253,14 @@ acpi_ev_pci_config_region_setup (
260 * (install_address_space_handler could have initialized it) 253 * (install_address_space_handler could have initialized it)
261 */ 254 */
262 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 255 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
263 return_ACPI_STATUS (AE_OK); 256 return_ACPI_STATUS(AE_OK);
264 } 257 }
265 258
266 /* Region is still not initialized. Create a new context */ 259 /* Region is still not initialized. Create a new context */
267 260
268 pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id)); 261 pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id));
269 if (!pci_id) { 262 if (!pci_id) {
270 return_ACPI_STATUS (AE_NO_MEMORY); 263 return_ACPI_STATUS(AE_NO_MEMORY);
271 } 264 }
272 265
273 /* 266 /*
@@ -279,40 +272,45 @@ acpi_ev_pci_config_region_setup (
279 * Get the PCI device and function numbers from the _ADR object 272 * Get the PCI device and function numbers from the _ADR object
280 * contained in the parent's scope. 273 * contained in the parent's scope.
281 */ 274 */
282 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, parent_node, &pci_value); 275 status =
276 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node,
277 &pci_value);
283 278
284 /* 279 /*
285 * The default is zero, and since the allocation above zeroed 280 * The default is zero, and since the allocation above zeroed
286 * the data, just do nothing on failure. 281 * the data, just do nothing on failure.
287 */ 282 */
288 if (ACPI_SUCCESS (status)) { 283 if (ACPI_SUCCESS(status)) {
289 pci_id->device = ACPI_HIWORD (ACPI_LODWORD (pci_value)); 284 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
290 pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value)); 285 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
291 } 286 }
292 287
293 /* The PCI segment number comes from the _SEG method */ 288 /* The PCI segment number comes from the _SEG method */
294 289
295 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value); 290 status =
296 if (ACPI_SUCCESS (status)) { 291 acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node,
297 pci_id->segment = ACPI_LOWORD (pci_value); 292 &pci_value);
293 if (ACPI_SUCCESS(status)) {
294 pci_id->segment = ACPI_LOWORD(pci_value);
298 } 295 }
299 296
300 /* The PCI bus number comes from the _BBN method */ 297 /* The PCI bus number comes from the _BBN method */
301 298
302 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value); 299 status =
303 if (ACPI_SUCCESS (status)) { 300 acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node,
304 pci_id->bus = ACPI_LOWORD (pci_value); 301 &pci_value);
302 if (ACPI_SUCCESS(status)) {
303 pci_id->bus = ACPI_LOWORD(pci_value);
305 } 304 }
306 305
307 /* Complete this device's pci_id */ 306 /* Complete this device's pci_id */
308 307
309 acpi_os_derive_pci_id (pci_root_node, region_obj->region.node, &pci_id); 308 acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id);
310 309
311 *region_context = pci_id; 310 *region_context = pci_id;
312 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
313} 312}
314 313
315
316/******************************************************************************* 314/*******************************************************************************
317 * 315 *
318 * FUNCTION: acpi_ev_pci_bar_region_setup 316 * FUNCTION: acpi_ev_pci_bar_region_setup
@@ -331,19 +329,15 @@ acpi_ev_pci_config_region_setup (
331 ******************************************************************************/ 329 ******************************************************************************/
332 330
333acpi_status 331acpi_status
334acpi_ev_pci_bar_region_setup ( 332acpi_ev_pci_bar_region_setup(acpi_handle handle,
335 acpi_handle handle, 333 u32 function,
336 u32 function, 334 void *handler_context, void **region_context)
337 void *handler_context,
338 void **region_context)
339{ 335{
340 ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup"); 336 ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup");
341
342 337
343 return_ACPI_STATUS (AE_OK); 338 return_ACPI_STATUS(AE_OK);
344} 339}
345 340
346
347/******************************************************************************* 341/*******************************************************************************
348 * 342 *
349 * FUNCTION: acpi_ev_cmos_region_setup 343 * FUNCTION: acpi_ev_cmos_region_setup
@@ -362,19 +356,15 @@ acpi_ev_pci_bar_region_setup (
362 ******************************************************************************/ 356 ******************************************************************************/
363 357
364acpi_status 358acpi_status
365acpi_ev_cmos_region_setup ( 359acpi_ev_cmos_region_setup(acpi_handle handle,
366 acpi_handle handle, 360 u32 function,
367 u32 function, 361 void *handler_context, void **region_context)
368 void *handler_context,
369 void **region_context)
370{ 362{
371 ACPI_FUNCTION_TRACE ("ev_cmos_region_setup"); 363 ACPI_FUNCTION_TRACE("ev_cmos_region_setup");
372
373 364
374 return_ACPI_STATUS (AE_OK); 365 return_ACPI_STATUS(AE_OK);
375} 366}
376 367
377
378/******************************************************************************* 368/*******************************************************************************
379 * 369 *
380 * FUNCTION: acpi_ev_default_region_setup 370 * FUNCTION: acpi_ev_default_region_setup
@@ -391,26 +381,21 @@ acpi_ev_cmos_region_setup (
391 ******************************************************************************/ 381 ******************************************************************************/
392 382
393acpi_status 383acpi_status
394acpi_ev_default_region_setup ( 384acpi_ev_default_region_setup(acpi_handle handle,
395 acpi_handle handle, 385 u32 function,
396 u32 function, 386 void *handler_context, void **region_context)
397 void *handler_context,
398 void **region_context)
399{ 387{
400 ACPI_FUNCTION_TRACE ("ev_default_region_setup"); 388 ACPI_FUNCTION_TRACE("ev_default_region_setup");
401
402 389
403 if (function == ACPI_REGION_DEACTIVATE) { 390 if (function == ACPI_REGION_DEACTIVATE) {
404 *region_context = NULL; 391 *region_context = NULL;
405 } 392 } else {
406 else {
407 *region_context = handler_context; 393 *region_context = handler_context;
408 } 394 }
409 395
410 return_ACPI_STATUS (AE_OK); 396 return_ACPI_STATUS(AE_OK);
411} 397}
412 398
413
414/******************************************************************************* 399/*******************************************************************************
415 * 400 *
416 * FUNCTION: acpi_ev_initialize_region 401 * FUNCTION: acpi_ev_initialize_region
@@ -434,37 +419,34 @@ acpi_ev_default_region_setup (
434 ******************************************************************************/ 419 ******************************************************************************/
435 420
436acpi_status 421acpi_status
437acpi_ev_initialize_region ( 422acpi_ev_initialize_region(union acpi_operand_object *region_obj,
438 union acpi_operand_object *region_obj, 423 u8 acpi_ns_locked)
439 u8 acpi_ns_locked)
440{ 424{
441 union acpi_operand_object *handler_obj; 425 union acpi_operand_object *handler_obj;
442 union acpi_operand_object *obj_desc; 426 union acpi_operand_object *obj_desc;
443 acpi_adr_space_type space_id; 427 acpi_adr_space_type space_id;
444 struct acpi_namespace_node *node; 428 struct acpi_namespace_node *node;
445 acpi_status status; 429 acpi_status status;
446 struct acpi_namespace_node *method_node; 430 struct acpi_namespace_node *method_node;
447 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; 431 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
448 union acpi_operand_object *region_obj2; 432 union acpi_operand_object *region_obj2;
449
450
451 ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked);
452 433
434 ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked);
453 435
454 if (!region_obj) { 436 if (!region_obj) {
455 return_ACPI_STATUS (AE_BAD_PARAMETER); 437 return_ACPI_STATUS(AE_BAD_PARAMETER);
456 } 438 }
457 439
458 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { 440 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
459 return_ACPI_STATUS (AE_OK); 441 return_ACPI_STATUS(AE_OK);
460 } 442 }
461 443
462 region_obj2 = acpi_ns_get_secondary_object (region_obj); 444 region_obj2 = acpi_ns_get_secondary_object(region_obj);
463 if (!region_obj2) { 445 if (!region_obj2) {
464 return_ACPI_STATUS (AE_NOT_EXIST); 446 return_ACPI_STATUS(AE_NOT_EXIST);
465 } 447 }
466 448
467 node = acpi_ns_get_parent_node (region_obj->region.node); 449 node = acpi_ns_get_parent_node(region_obj->region.node);
468 space_id = region_obj->region.space_id; 450 space_id = region_obj->region.space_id;
469 451
470 /* Setup defaults */ 452 /* Setup defaults */
@@ -476,9 +458,9 @@ acpi_ev_initialize_region (
476 458
477 /* Find any "_REG" method associated with this region definition */ 459 /* Find any "_REG" method associated with this region definition */
478 460
479 status = acpi_ns_search_node (*reg_name_ptr, node, 461 status = acpi_ns_search_node(*reg_name_ptr, node,
480 ACPI_TYPE_METHOD, &method_node); 462 ACPI_TYPE_METHOD, &method_node);
481 if (ACPI_SUCCESS (status)) { 463 if (ACPI_SUCCESS(status)) {
482 /* 464 /*
483 * The _REG method is optional and there can be only one per region 465 * The _REG method is optional and there can be only one per region
484 * definition. This will be executed when the handler is attached 466 * definition. This will be executed when the handler is attached
@@ -495,7 +477,7 @@ acpi_ev_initialize_region (
495 /* Check to see if a handler exists */ 477 /* Check to see if a handler exists */
496 478
497 handler_obj = NULL; 479 handler_obj = NULL;
498 obj_desc = acpi_ns_get_attached_object (node); 480 obj_desc = acpi_ns_get_attached_object(node);
499 if (obj_desc) { 481 if (obj_desc) {
500 /* Can only be a handler if the object exists */ 482 /* Can only be a handler if the object exists */
501 483
@@ -523,37 +505,50 @@ acpi_ev_initialize_region (
523 while (handler_obj) { 505 while (handler_obj) {
524 /* Is this handler of the correct type? */ 506 /* Is this handler of the correct type? */
525 507
526 if (handler_obj->address_space.space_id == space_id) { 508 if (handler_obj->address_space.space_id ==
509 space_id) {
527 /* Found correct handler */ 510 /* Found correct handler */
528 511
529 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 512 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
530 "Found handler %p for region %p in obj %p\n", 513 "Found handler %p for region %p in obj %p\n",
531 handler_obj, region_obj, obj_desc)); 514 handler_obj,
515 region_obj,
516 obj_desc));
532 517
533 status = acpi_ev_attach_region (handler_obj, region_obj, 518 status =
534 acpi_ns_locked); 519 acpi_ev_attach_region(handler_obj,
520 region_obj,
521 acpi_ns_locked);
535 522
536 /* 523 /*
537 * Tell all users that this region is usable by running the _REG 524 * Tell all users that this region is usable by running the _REG
538 * method 525 * method
539 */ 526 */
540 if (acpi_ns_locked) { 527 if (acpi_ns_locked) {
541 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 528 status =
542 if (ACPI_FAILURE (status)) { 529 acpi_ut_release_mutex
543 return_ACPI_STATUS (status); 530 (ACPI_MTX_NAMESPACE);
531 if (ACPI_FAILURE(status)) {
532 return_ACPI_STATUS
533 (status);
544 } 534 }
545 } 535 }
546 536
547 status = acpi_ev_execute_reg_method (region_obj, 1); 537 status =
538 acpi_ev_execute_reg_method
539 (region_obj, 1);
548 540
549 if (acpi_ns_locked) { 541 if (acpi_ns_locked) {
550 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 542 status =
551 if (ACPI_FAILURE (status)) { 543 acpi_ut_acquire_mutex
552 return_ACPI_STATUS (status); 544 (ACPI_MTX_NAMESPACE);
545 if (ACPI_FAILURE(status)) {
546 return_ACPI_STATUS
547 (status);
553 } 548 }
554 } 549 }
555 550
556 return_ACPI_STATUS (AE_OK); 551 return_ACPI_STATUS(AE_OK);
557 } 552 }
558 553
559 /* Try next handler in the list */ 554 /* Try next handler in the list */
@@ -566,15 +561,15 @@ acpi_ev_initialize_region (
566 * This node does not have the handler we need; 561 * This node does not have the handler we need;
567 * Pop up one level 562 * Pop up one level
568 */ 563 */
569 node = acpi_ns_get_parent_node (node); 564 node = acpi_ns_get_parent_node(node);
570 } 565 }
571 566
572 /* If we get here, there is no handler for this region */ 567 /* If we get here, there is no handler for this region */
573 568
574 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 569 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
575 "No handler for region_type %s(%X) (region_obj %p)\n", 570 "No handler for region_type %s(%X) (region_obj %p)\n",
576 acpi_ut_get_region_name (space_id), space_id, region_obj)); 571 acpi_ut_get_region_name(space_id), space_id,
572 region_obj));
577 573
578 return_ACPI_STATUS (AE_NOT_EXIST); 574 return_ACPI_STATUS(AE_NOT_EXIST);
579} 575}
580
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index f3123c26ae98..141835977002 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -45,16 +45,11 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include <acpi/acevents.h>
47 47
48
49#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evsci") 49ACPI_MODULE_NAME("evsci")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53 52static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
54static u32 ACPI_SYSTEM_XFACE
55acpi_ev_sci_xrupt_handler (
56 void *context);
57
58 53
59/******************************************************************************* 54/*******************************************************************************
60 * 55 *
@@ -69,17 +64,13 @@ acpi_ev_sci_xrupt_handler (
69 * 64 *
70 ******************************************************************************/ 65 ******************************************************************************/
71 66
72static u32 ACPI_SYSTEM_XFACE 67static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
73acpi_ev_sci_xrupt_handler (
74 void *context)
75{ 68{
76 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 69 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
77 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 70 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
78
79 71
80 ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler"); 72 ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
81 73
82
83 /* 74 /*
84 * We are guaranteed by the ACPI CA initialization/shutdown code that 75 * We are guaranteed by the ACPI CA initialization/shutdown code that
85 * if this interrupt handler is installed, ACPI is enabled. 76 * if this interrupt handler is installed, ACPI is enabled.
@@ -89,18 +80,17 @@ acpi_ev_sci_xrupt_handler (
89 * Fixed Events: 80 * Fixed Events:
90 * Check for and dispatch any Fixed Events that have occurred 81 * Check for and dispatch any Fixed Events that have occurred
91 */ 82 */
92 interrupt_handled |= acpi_ev_fixed_event_detect (); 83 interrupt_handled |= acpi_ev_fixed_event_detect();
93 84
94 /* 85 /*
95 * General Purpose Events: 86 * General Purpose Events:
96 * Check for and dispatch any GPEs that have occurred 87 * Check for and dispatch any GPEs that have occurred
97 */ 88 */
98 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
99 90
100 return_VALUE (interrupt_handled); 91 return_VALUE(interrupt_handled);
101} 92}
102 93
103
104/******************************************************************************* 94/*******************************************************************************
105 * 95 *
106 * FUNCTION: acpi_ev_gpe_xrupt_handler 96 * FUNCTION: acpi_ev_gpe_xrupt_handler
@@ -113,17 +103,13 @@ acpi_ev_sci_xrupt_handler (
113 * 103 *
114 ******************************************************************************/ 104 ******************************************************************************/
115 105
116u32 ACPI_SYSTEM_XFACE 106u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
117acpi_ev_gpe_xrupt_handler (
118 void *context)
119{ 107{
120 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 108 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
121 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 109 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
122
123 110
124 ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler"); 111 ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
125 112
126
127 /* 113 /*
128 * We are guaranteed by the ACPI CA initialization/shutdown code that 114 * We are guaranteed by the ACPI CA initialization/shutdown code that
129 * if this interrupt handler is installed, ACPI is enabled. 115 * if this interrupt handler is installed, ACPI is enabled.
@@ -133,12 +119,11 @@ acpi_ev_gpe_xrupt_handler (
133 * GPEs: 119 * GPEs:
134 * Check for and dispatch any GPEs that have occurred 120 * Check for and dispatch any GPEs that have occurred
135 */ 121 */
136 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
137 123
138 return_VALUE (interrupt_handled); 124 return_VALUE(interrupt_handled);
139} 125}
140 126
141
142/****************************************************************************** 127/******************************************************************************
143 * 128 *
144 * FUNCTION: acpi_ev_install_sci_handler 129 * FUNCTION: acpi_ev_install_sci_handler
@@ -151,22 +136,18 @@ acpi_ev_gpe_xrupt_handler (
151 * 136 *
152 ******************************************************************************/ 137 ******************************************************************************/
153 138
154u32 139u32 acpi_ev_install_sci_handler(void)
155acpi_ev_install_sci_handler (
156 void)
157{ 140{
158 u32 status = AE_OK; 141 u32 status = AE_OK;
159
160 142
161 ACPI_FUNCTION_TRACE ("ev_install_sci_handler"); 143 ACPI_FUNCTION_TRACE("ev_install_sci_handler");
162 144
163 145 status = acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
164 status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, 146 acpi_ev_sci_xrupt_handler,
165 acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head); 147 acpi_gbl_gpe_xrupt_list_head);
166 return_ACPI_STATUS (status); 148 return_ACPI_STATUS(status);
167} 149}
168 150
169
170/****************************************************************************** 151/******************************************************************************
171 * 152 *
172 * FUNCTION: acpi_ev_remove_sci_handler 153 * FUNCTION: acpi_ev_remove_sci_handler
@@ -186,22 +167,16 @@ acpi_ev_install_sci_handler (
186 * 167 *
187 ******************************************************************************/ 168 ******************************************************************************/
188 169
189acpi_status 170acpi_status acpi_ev_remove_sci_handler(void)
190acpi_ev_remove_sci_handler (
191 void)
192{ 171{
193 acpi_status status; 172 acpi_status status;
194
195
196 ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
197 173
174 ACPI_FUNCTION_TRACE("ev_remove_sci_handler");
198 175
199 /* Just let the OS remove the handler and disable the level */ 176 /* Just let the OS remove the handler and disable the level */
200 177
201 status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, 178 status = acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
202 acpi_ev_sci_xrupt_handler); 179 acpi_ev_sci_xrupt_handler);
203 180
204 return_ACPI_STATUS (status); 181 return_ACPI_STATUS(status);
205} 182}
206
207
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 4092d47f6758..43b33d19cdf9 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -49,8 +49,7 @@
49#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
50 50
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxface") 52ACPI_MODULE_NAME("evxface")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -64,21 +63,16 @@
64 * DESCRIPTION: Saves the pointer to the handler function 63 * DESCRIPTION: Saves the pointer to the handler function
65 * 64 *
66 ******************************************************************************/ 65 ******************************************************************************/
67
68#ifdef ACPI_FUTURE_USAGE 66#ifdef ACPI_FUTURE_USAGE
69acpi_status 67acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
70acpi_install_exception_handler (
71 acpi_exception_handler handler)
72{ 68{
73 acpi_status status; 69 acpi_status status;
74
75 70
76 ACPI_FUNCTION_TRACE ("acpi_install_exception_handler"); 71 ACPI_FUNCTION_TRACE("acpi_install_exception_handler");
77 72
78 73 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
79 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 74 if (ACPI_FAILURE(status)) {
80 if (ACPI_FAILURE (status)) { 75 return_ACPI_STATUS(status);
81 return_ACPI_STATUS (status);
82 } 76 }
83 77
84 /* Don't allow two handlers. */ 78 /* Don't allow two handlers. */
@@ -92,12 +86,11 @@ acpi_install_exception_handler (
92 86
93 acpi_gbl_exception_handler = handler; 87 acpi_gbl_exception_handler = handler;
94 88
95cleanup: 89 cleanup:
96 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 90 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
97 return_ACPI_STATUS (status); 91 return_ACPI_STATUS(status);
98} 92}
99#endif /* ACPI_FUTURE_USAGE */ 93#endif /* ACPI_FUTURE_USAGE */
100
101 94
102/******************************************************************************* 95/*******************************************************************************
103 * 96 *
@@ -116,26 +109,22 @@ cleanup:
116 ******************************************************************************/ 109 ******************************************************************************/
117 110
118acpi_status 111acpi_status
119acpi_install_fixed_event_handler ( 112acpi_install_fixed_event_handler(u32 event,
120 u32 event, 113 acpi_event_handler handler, void *context)
121 acpi_event_handler handler,
122 void *context)
123{ 114{
124 acpi_status status; 115 acpi_status status;
125
126
127 ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler");
128 116
117 ACPI_FUNCTION_TRACE("acpi_install_fixed_event_handler");
129 118
130 /* Parameter validation */ 119 /* Parameter validation */
131 120
132 if (event > ACPI_EVENT_MAX) { 121 if (event > ACPI_EVENT_MAX) {
133 return_ACPI_STATUS (AE_BAD_PARAMETER); 122 return_ACPI_STATUS(AE_BAD_PARAMETER);
134 } 123 }
135 124
136 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 125 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
137 if (ACPI_FAILURE (status)) { 126 if (ACPI_FAILURE(status)) {
138 return_ACPI_STATUS (status); 127 return_ACPI_STATUS(status);
139 } 128 }
140 129
141 /* Don't allow two handlers. */ 130 /* Don't allow two handlers. */
@@ -150,29 +139,29 @@ acpi_install_fixed_event_handler (
150 acpi_gbl_fixed_event_handlers[event].handler = handler; 139 acpi_gbl_fixed_event_handlers[event].handler = handler;
151 acpi_gbl_fixed_event_handlers[event].context = context; 140 acpi_gbl_fixed_event_handlers[event].context = context;
152 141
153 status = acpi_clear_event (event); 142 status = acpi_clear_event(event);
154 if (ACPI_SUCCESS(status)) 143 if (ACPI_SUCCESS(status))
155 status = acpi_enable_event (event, 0); 144 status = acpi_enable_event(event, 0);
156 if (ACPI_FAILURE (status)) { 145 if (ACPI_FAILURE(status)) {
157 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); 146 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
147 "Could not enable fixed event.\n"));
158 148
159 /* Remove the handler */ 149 /* Remove the handler */
160 150
161 acpi_gbl_fixed_event_handlers[event].handler = NULL; 151 acpi_gbl_fixed_event_handlers[event].handler = NULL;
162 acpi_gbl_fixed_event_handlers[event].context = NULL; 152 acpi_gbl_fixed_event_handlers[event].context = NULL;
163 } 153 } else {
164 else { 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
165 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 155 "Enabled fixed event %X, Handler=%p\n", event,
166 "Enabled fixed event %X, Handler=%p\n", event, handler)); 156 handler));
167 } 157 }
168 158
169 159 cleanup:
170cleanup: 160 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
171 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 161 return_ACPI_STATUS(status);
172 return_ACPI_STATUS (status);
173} 162}
174EXPORT_SYMBOL(acpi_install_fixed_event_handler);
175 163
164EXPORT_SYMBOL(acpi_install_fixed_event_handler);
176 165
177/******************************************************************************* 166/*******************************************************************************
178 * 167 *
@@ -188,49 +177,45 @@ EXPORT_SYMBOL(acpi_install_fixed_event_handler);
188 ******************************************************************************/ 177 ******************************************************************************/
189 178
190acpi_status 179acpi_status
191acpi_remove_fixed_event_handler ( 180acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
192 u32 event,
193 acpi_event_handler handler)
194{ 181{
195 acpi_status status = AE_OK; 182 acpi_status status = AE_OK;
196
197
198 ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler");
199 183
184 ACPI_FUNCTION_TRACE("acpi_remove_fixed_event_handler");
200 185
201 /* Parameter validation */ 186 /* Parameter validation */
202 187
203 if (event > ACPI_EVENT_MAX) { 188 if (event > ACPI_EVENT_MAX) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 189 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 190 }
206 191
207 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 192 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
208 if (ACPI_FAILURE (status)) { 193 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
210 } 195 }
211 196
212 /* Disable the event before removing the handler */ 197 /* Disable the event before removing the handler */
213 198
214 status = acpi_disable_event (event, 0); 199 status = acpi_disable_event(event, 0);
215 200
216 /* Always Remove the handler */ 201 /* Always Remove the handler */
217 202
218 acpi_gbl_fixed_event_handlers[event].handler = NULL; 203 acpi_gbl_fixed_event_handlers[event].handler = NULL;
219 acpi_gbl_fixed_event_handlers[event].context = NULL; 204 acpi_gbl_fixed_event_handlers[event].context = NULL;
220 205
221 if (ACPI_FAILURE (status)) { 206 if (ACPI_FAILURE(status)) {
222 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 207 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
223 "Could not write to fixed event enable register.\n")); 208 "Could not write to fixed event enable register.\n"));
224 } 209 } else {
225 else { 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n",
226 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event)); 211 event));
227 } 212 }
228 213
229 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 214 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
230 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
231} 216}
232EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
233 217
218EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
234 219
235/******************************************************************************* 220/*******************************************************************************
236 * 221 *
@@ -251,37 +236,32 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
251 ******************************************************************************/ 236 ******************************************************************************/
252 237
253acpi_status 238acpi_status
254acpi_install_notify_handler ( 239acpi_install_notify_handler(acpi_handle device,
255 acpi_handle device, 240 u32 handler_type,
256 u32 handler_type, 241 acpi_notify_handler handler, void *context)
257 acpi_notify_handler handler,
258 void *context)
259{ 242{
260 union acpi_operand_object *obj_desc; 243 union acpi_operand_object *obj_desc;
261 union acpi_operand_object *notify_obj; 244 union acpi_operand_object *notify_obj;
262 struct acpi_namespace_node *node; 245 struct acpi_namespace_node *node;
263 acpi_status status; 246 acpi_status status;
264
265
266 ACPI_FUNCTION_TRACE ("acpi_install_notify_handler");
267 247
248 ACPI_FUNCTION_TRACE("acpi_install_notify_handler");
268 249
269 /* Parameter validation */ 250 /* Parameter validation */
270 251
271 if ((!device) || 252 if ((!device) ||
272 (!handler) || 253 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
273 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 254 return_ACPI_STATUS(AE_BAD_PARAMETER);
274 return_ACPI_STATUS (AE_BAD_PARAMETER);
275 } 255 }
276 256
277 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 257 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
278 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 259 return_ACPI_STATUS(status);
280 } 260 }
281 261
282 /* Convert and validate the device handle */ 262 /* Convert and validate the device handle */
283 263
284 node = acpi_ns_map_handle_to_node (device); 264 node = acpi_ns_map_handle_to_node(device);
285 if (!node) { 265 if (!node) {
286 status = AE_BAD_PARAMETER; 266 status = AE_BAD_PARAMETER;
287 goto unlock_and_exit; 267 goto unlock_and_exit;
@@ -297,21 +277,21 @@ acpi_install_notify_handler (
297 /* Make sure the handler is not already installed */ 277 /* Make sure the handler is not already installed */
298 278
299 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 279 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
300 acpi_gbl_system_notify.handler) || 280 acpi_gbl_system_notify.handler) ||
301 ((handler_type & ACPI_DEVICE_NOTIFY) && 281 ((handler_type & ACPI_DEVICE_NOTIFY) &&
302 acpi_gbl_device_notify.handler)) { 282 acpi_gbl_device_notify.handler)) {
303 status = AE_ALREADY_EXISTS; 283 status = AE_ALREADY_EXISTS;
304 goto unlock_and_exit; 284 goto unlock_and_exit;
305 } 285 }
306 286
307 if (handler_type & ACPI_SYSTEM_NOTIFY) { 287 if (handler_type & ACPI_SYSTEM_NOTIFY) {
308 acpi_gbl_system_notify.node = node; 288 acpi_gbl_system_notify.node = node;
309 acpi_gbl_system_notify.handler = handler; 289 acpi_gbl_system_notify.handler = handler;
310 acpi_gbl_system_notify.context = context; 290 acpi_gbl_system_notify.context = context;
311 } 291 }
312 292
313 if (handler_type & ACPI_DEVICE_NOTIFY) { 293 if (handler_type & ACPI_DEVICE_NOTIFY) {
314 acpi_gbl_device_notify.node = node; 294 acpi_gbl_device_notify.node = node;
315 acpi_gbl_device_notify.handler = handler; 295 acpi_gbl_device_notify.handler = handler;
316 acpi_gbl_device_notify.context = context; 296 acpi_gbl_device_notify.context = context;
317 } 297 }
@@ -327,29 +307,28 @@ acpi_install_notify_handler (
327 else { 307 else {
328 /* Notifies allowed on this object? */ 308 /* Notifies allowed on this object? */
329 309
330 if (!acpi_ev_is_notify_object (node)) { 310 if (!acpi_ev_is_notify_object(node)) {
331 status = AE_TYPE; 311 status = AE_TYPE;
332 goto unlock_and_exit; 312 goto unlock_and_exit;
333 } 313 }
334 314
335 /* Check for an existing internal object */ 315 /* Check for an existing internal object */
336 316
337 obj_desc = acpi_ns_get_attached_object (node); 317 obj_desc = acpi_ns_get_attached_object(node);
338 if (obj_desc) { 318 if (obj_desc) {
339 /* Object exists - make sure there's no handler */ 319 /* Object exists - make sure there's no handler */
340 320
341 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 321 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
342 obj_desc->common_notify.system_notify) || 322 obj_desc->common_notify.system_notify) ||
343 ((handler_type & ACPI_DEVICE_NOTIFY) && 323 ((handler_type & ACPI_DEVICE_NOTIFY) &&
344 obj_desc->common_notify.device_notify)) { 324 obj_desc->common_notify.device_notify)) {
345 status = AE_ALREADY_EXISTS; 325 status = AE_ALREADY_EXISTS;
346 goto unlock_and_exit; 326 goto unlock_and_exit;
347 } 327 }
348 } 328 } else {
349 else {
350 /* Create a new object */ 329 /* Create a new object */
351 330
352 obj_desc = acpi_ut_create_internal_object (node->type); 331 obj_desc = acpi_ut_create_internal_object(node->type);
353 if (!obj_desc) { 332 if (!obj_desc) {
354 status = AE_NO_MEMORY; 333 status = AE_NO_MEMORY;
355 goto unlock_and_exit; 334 goto unlock_and_exit;
@@ -357,25 +336,27 @@ acpi_install_notify_handler (
357 336
358 /* Attach new object to the Node */ 337 /* Attach new object to the Node */
359 338
360 status = acpi_ns_attach_object (device, obj_desc, node->type); 339 status =
340 acpi_ns_attach_object(device, obj_desc, node->type);
361 341
362 /* Remove local reference to the object */ 342 /* Remove local reference to the object */
363 343
364 acpi_ut_remove_reference (obj_desc); 344 acpi_ut_remove_reference(obj_desc);
365 if (ACPI_FAILURE (status)) { 345 if (ACPI_FAILURE(status)) {
366 goto unlock_and_exit; 346 goto unlock_and_exit;
367 } 347 }
368 } 348 }
369 349
370 /* Install the handler */ 350 /* Install the handler */
371 351
372 notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY); 352 notify_obj =
353 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
373 if (!notify_obj) { 354 if (!notify_obj) {
374 status = AE_NO_MEMORY; 355 status = AE_NO_MEMORY;
375 goto unlock_and_exit; 356 goto unlock_and_exit;
376 } 357 }
377 358
378 notify_obj->notify.node = node; 359 notify_obj->notify.node = node;
379 notify_obj->notify.handler = handler; 360 notify_obj->notify.handler = handler;
380 notify_obj->notify.context = context; 361 notify_obj->notify.context = context;
381 362
@@ -390,17 +371,16 @@ acpi_install_notify_handler (
390 if (handler_type == ACPI_ALL_NOTIFY) { 371 if (handler_type == ACPI_ALL_NOTIFY) {
391 /* Extra ref if installed in both */ 372 /* Extra ref if installed in both */
392 373
393 acpi_ut_add_reference (notify_obj); 374 acpi_ut_add_reference(notify_obj);
394 } 375 }
395 } 376 }
396 377
397 378 unlock_and_exit:
398unlock_and_exit: 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
399 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 380 return_ACPI_STATUS(status);
400 return_ACPI_STATUS (status);
401} 381}
402EXPORT_SYMBOL(acpi_install_notify_handler);
403 382
383EXPORT_SYMBOL(acpi_install_notify_handler);
404 384
405/******************************************************************************* 385/*******************************************************************************
406 * 386 *
@@ -420,36 +400,31 @@ EXPORT_SYMBOL(acpi_install_notify_handler);
420 ******************************************************************************/ 400 ******************************************************************************/
421 401
422acpi_status 402acpi_status
423acpi_remove_notify_handler ( 403acpi_remove_notify_handler(acpi_handle device,
424 acpi_handle device, 404 u32 handler_type, acpi_notify_handler handler)
425 u32 handler_type,
426 acpi_notify_handler handler)
427{ 405{
428 union acpi_operand_object *notify_obj; 406 union acpi_operand_object *notify_obj;
429 union acpi_operand_object *obj_desc; 407 union acpi_operand_object *obj_desc;
430 struct acpi_namespace_node *node; 408 struct acpi_namespace_node *node;
431 acpi_status status; 409 acpi_status status;
432
433
434 ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler");
435 410
411 ACPI_FUNCTION_TRACE("acpi_remove_notify_handler");
436 412
437 /* Parameter validation */ 413 /* Parameter validation */
438 414
439 if ((!device) || 415 if ((!device) ||
440 (!handler) || 416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
441 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 417 return_ACPI_STATUS(AE_BAD_PARAMETER);
442 return_ACPI_STATUS (AE_BAD_PARAMETER);
443 } 418 }
444 419
445 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 420 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
446 if (ACPI_FAILURE (status)) { 421 if (ACPI_FAILURE(status)) {
447 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
448 } 423 }
449 424
450 /* Convert and validate the device handle */ 425 /* Convert and validate the device handle */
451 426
452 node = acpi_ns_map_handle_to_node (device); 427 node = acpi_ns_map_handle_to_node(device);
453 if (!node) { 428 if (!node) {
454 status = AE_BAD_PARAMETER; 429 status = AE_BAD_PARAMETER;
455 goto unlock_and_exit; 430 goto unlock_and_exit;
@@ -458,34 +433,34 @@ acpi_remove_notify_handler (
458 /* Root Object */ 433 /* Root Object */
459 434
460 if (device == ACPI_ROOT_OBJECT) { 435 if (device == ACPI_ROOT_OBJECT) {
461 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 436 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
462 "Removing notify handler for ROOT object.\n")); 437 "Removing notify handler for ROOT object.\n"));
463 438
464 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 439 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
465 !acpi_gbl_system_notify.handler) || 440 !acpi_gbl_system_notify.handler) ||
466 ((handler_type & ACPI_DEVICE_NOTIFY) && 441 ((handler_type & ACPI_DEVICE_NOTIFY) &&
467 !acpi_gbl_device_notify.handler)) { 442 !acpi_gbl_device_notify.handler)) {
468 status = AE_NOT_EXIST; 443 status = AE_NOT_EXIST;
469 goto unlock_and_exit; 444 goto unlock_and_exit;
470 } 445 }
471 446
472 /* Make sure all deferred tasks are completed */ 447 /* Make sure all deferred tasks are completed */
473 448
474 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 449 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
475 acpi_os_wait_events_complete(NULL); 450 acpi_os_wait_events_complete(NULL);
476 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 451 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
477 if (ACPI_FAILURE (status)) { 452 if (ACPI_FAILURE(status)) {
478 return_ACPI_STATUS (status); 453 return_ACPI_STATUS(status);
479 } 454 }
480 455
481 if (handler_type & ACPI_SYSTEM_NOTIFY) { 456 if (handler_type & ACPI_SYSTEM_NOTIFY) {
482 acpi_gbl_system_notify.node = NULL; 457 acpi_gbl_system_notify.node = NULL;
483 acpi_gbl_system_notify.handler = NULL; 458 acpi_gbl_system_notify.handler = NULL;
484 acpi_gbl_system_notify.context = NULL; 459 acpi_gbl_system_notify.context = NULL;
485 } 460 }
486 461
487 if (handler_type & ACPI_DEVICE_NOTIFY) { 462 if (handler_type & ACPI_DEVICE_NOTIFY) {
488 acpi_gbl_device_notify.node = NULL; 463 acpi_gbl_device_notify.node = NULL;
489 acpi_gbl_device_notify.handler = NULL; 464 acpi_gbl_device_notify.handler = NULL;
490 acpi_gbl_device_notify.context = NULL; 465 acpi_gbl_device_notify.context = NULL;
491 } 466 }
@@ -496,14 +471,14 @@ acpi_remove_notify_handler (
496 else { 471 else {
497 /* Notifies allowed on this object? */ 472 /* Notifies allowed on this object? */
498 473
499 if (!acpi_ev_is_notify_object (node)) { 474 if (!acpi_ev_is_notify_object(node)) {
500 status = AE_TYPE; 475 status = AE_TYPE;
501 goto unlock_and_exit; 476 goto unlock_and_exit;
502 } 477 }
503 478
504 /* Check for an existing internal object */ 479 /* Check for an existing internal object */
505 480
506 obj_desc = acpi_ns_get_attached_object (node); 481 obj_desc = acpi_ns_get_attached_object(node);
507 if (!obj_desc) { 482 if (!obj_desc) {
508 status = AE_NOT_EXIST; 483 status = AE_NOT_EXIST;
509 goto unlock_and_exit; 484 goto unlock_and_exit;
@@ -514,53 +489,52 @@ acpi_remove_notify_handler (
514 if (handler_type & ACPI_SYSTEM_NOTIFY) { 489 if (handler_type & ACPI_SYSTEM_NOTIFY) {
515 notify_obj = obj_desc->common_notify.system_notify; 490 notify_obj = obj_desc->common_notify.system_notify;
516 if ((!notify_obj) || 491 if ((!notify_obj) ||
517 (notify_obj->notify.handler != handler)) { 492 (notify_obj->notify.handler != handler)) {
518 status = AE_BAD_PARAMETER; 493 status = AE_BAD_PARAMETER;
519 goto unlock_and_exit; 494 goto unlock_and_exit;
520 } 495 }
521 /* Make sure all deferred tasks are completed */ 496 /* Make sure all deferred tasks are completed */
522 497
523 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 498 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
524 acpi_os_wait_events_complete(NULL); 499 acpi_os_wait_events_complete(NULL);
525 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 500 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
526 if (ACPI_FAILURE (status)) { 501 if (ACPI_FAILURE(status)) {
527 return_ACPI_STATUS (status); 502 return_ACPI_STATUS(status);
528 } 503 }
529 504
530 /* Remove the handler */ 505 /* Remove the handler */
531 obj_desc->common_notify.system_notify = NULL; 506 obj_desc->common_notify.system_notify = NULL;
532 acpi_ut_remove_reference (notify_obj); 507 acpi_ut_remove_reference(notify_obj);
533 } 508 }
534 509
535 if (handler_type & ACPI_DEVICE_NOTIFY) { 510 if (handler_type & ACPI_DEVICE_NOTIFY) {
536 notify_obj = obj_desc->common_notify.device_notify; 511 notify_obj = obj_desc->common_notify.device_notify;
537 if ((!notify_obj) || 512 if ((!notify_obj) ||
538 (notify_obj->notify.handler != handler)) { 513 (notify_obj->notify.handler != handler)) {
539 status = AE_BAD_PARAMETER; 514 status = AE_BAD_PARAMETER;
540 goto unlock_and_exit; 515 goto unlock_and_exit;
541 } 516 }
542 /* Make sure all deferred tasks are completed */ 517 /* Make sure all deferred tasks are completed */
543 518
544 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 519 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
545 acpi_os_wait_events_complete(NULL); 520 acpi_os_wait_events_complete(NULL);
546 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 521 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
547 if (ACPI_FAILURE (status)) { 522 if (ACPI_FAILURE(status)) {
548 return_ACPI_STATUS (status); 523 return_ACPI_STATUS(status);
549 } 524 }
550 525
551 /* Remove the handler */ 526 /* Remove the handler */
552 obj_desc->common_notify.device_notify = NULL; 527 obj_desc->common_notify.device_notify = NULL;
553 acpi_ut_remove_reference (notify_obj); 528 acpi_ut_remove_reference(notify_obj);
554 } 529 }
555 } 530 }
556 531
557 532 unlock_and_exit:
558unlock_and_exit: 533 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
559 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 534 return_ACPI_STATUS(status);
560 return_ACPI_STATUS (status);
561} 535}
562EXPORT_SYMBOL(acpi_remove_notify_handler);
563 536
537EXPORT_SYMBOL(acpi_remove_notify_handler);
564 538
565/******************************************************************************* 539/*******************************************************************************
566 * 540 *
@@ -581,35 +555,31 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
581 ******************************************************************************/ 555 ******************************************************************************/
582 556
583acpi_status 557acpi_status
584acpi_install_gpe_handler ( 558acpi_install_gpe_handler(acpi_handle gpe_device,
585 acpi_handle gpe_device, 559 u32 gpe_number,
586 u32 gpe_number, 560 u32 type, acpi_event_handler address, void *context)
587 u32 type,
588 acpi_event_handler address,
589 void *context)
590{ 561{
591 struct acpi_gpe_event_info *gpe_event_info; 562 struct acpi_gpe_event_info *gpe_event_info;
592 struct acpi_handler_info *handler; 563 struct acpi_handler_info *handler;
593 acpi_status status; 564 acpi_status status;
594 565 u32 flags;
595
596 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
597 566
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
598 568
599 /* Parameter validation */ 569 /* Parameter validation */
600 570
601 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 571 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
602 return_ACPI_STATUS (AE_BAD_PARAMETER); 572 return_ACPI_STATUS(AE_BAD_PARAMETER);
603 } 573 }
604 574
605 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
606 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
607 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
608 } 578 }
609 579
610 /* Ensure that we have a valid GPE number */ 580 /* Ensure that we have a valid GPE number */
611 581
612 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 582 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
613 if (!gpe_event_info) { 583 if (!gpe_event_info) {
614 status = AE_BAD_PARAMETER; 584 status = AE_BAD_PARAMETER;
615 goto unlock_and_exit; 585 goto unlock_and_exit;
@@ -617,49 +587,49 @@ acpi_install_gpe_handler (
617 587
618 /* Make sure that there isn't a handler there already */ 588 /* Make sure that there isn't a handler there already */
619 589
620 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { 590 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
591 ACPI_GPE_DISPATCH_HANDLER) {
621 status = AE_ALREADY_EXISTS; 592 status = AE_ALREADY_EXISTS;
622 goto unlock_and_exit; 593 goto unlock_and_exit;
623 } 594 }
624 595
625 /* Allocate and init handler object */ 596 /* Allocate and init handler object */
626 597
627 handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info)); 598 handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info));
628 if (!handler) { 599 if (!handler) {
629 status = AE_NO_MEMORY; 600 status = AE_NO_MEMORY;
630 goto unlock_and_exit; 601 goto unlock_and_exit;
631 } 602 }
632 603
633 handler->address = address; 604 handler->address = address;
634 handler->context = context; 605 handler->context = context;
635 handler->method_node = gpe_event_info->dispatch.method_node; 606 handler->method_node = gpe_event_info->dispatch.method_node;
636 607
637 /* Disable the GPE before installing the handler */ 608 /* Disable the GPE before installing the handler */
638 609
639 status = acpi_ev_disable_gpe (gpe_event_info); 610 status = acpi_ev_disable_gpe(gpe_event_info);
640 if (ACPI_FAILURE (status)) { 611 if (ACPI_FAILURE(status)) {
641 goto unlock_and_exit; 612 goto unlock_and_exit;
642 } 613 }
643 614
644 /* Install the handler */ 615 /* Install the handler */
645 616
646 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 617 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
647 gpe_event_info->dispatch.handler = handler; 618 gpe_event_info->dispatch.handler = handler;
648 619
649 /* Setup up dispatch flags to indicate handler (vs. method) */ 620 /* Setup up dispatch flags to indicate handler (vs. method) */
650 621
651 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ 622 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
652 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 623 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
653 624
654 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 625 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
655
656 626
657unlock_and_exit: 627 unlock_and_exit:
658 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 628 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
659 return_ACPI_STATUS (status); 629 return_ACPI_STATUS(status);
660} 630}
661EXPORT_SYMBOL(acpi_install_gpe_handler);
662 631
632EXPORT_SYMBOL(acpi_install_gpe_handler);
663 633
664/******************************************************************************* 634/*******************************************************************************
665 * 635 *
@@ -677,33 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
677 ******************************************************************************/ 647 ******************************************************************************/
678 648
679acpi_status 649acpi_status
680acpi_remove_gpe_handler ( 650acpi_remove_gpe_handler(acpi_handle gpe_device,
681 acpi_handle gpe_device, 651 u32 gpe_number, acpi_event_handler address)
682 u32 gpe_number,
683 acpi_event_handler address)
684{ 652{
685 struct acpi_gpe_event_info *gpe_event_info; 653 struct acpi_gpe_event_info *gpe_event_info;
686 struct acpi_handler_info *handler; 654 struct acpi_handler_info *handler;
687 acpi_status status; 655 acpi_status status;
688 656 u32 flags;
689
690 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
691 657
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
692 659
693 /* Parameter validation */ 660 /* Parameter validation */
694 661
695 if (!address) { 662 if (!address) {
696 return_ACPI_STATUS (AE_BAD_PARAMETER); 663 return_ACPI_STATUS(AE_BAD_PARAMETER);
697 } 664 }
698 665
699 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
700 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
701 return_ACPI_STATUS (status); 668 return_ACPI_STATUS(status);
702 } 669 }
703 670
704 /* Ensure that we have a valid GPE number */ 671 /* Ensure that we have a valid GPE number */
705 672
706 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 673 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
707 if (!gpe_event_info) { 674 if (!gpe_event_info) {
708 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
709 goto unlock_and_exit; 676 goto unlock_and_exit;
@@ -711,7 +678,8 @@ acpi_remove_gpe_handler (
711 678
712 /* Make sure that a handler is indeed installed */ 679 /* Make sure that a handler is indeed installed */
713 680
714 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { 681 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
682 ACPI_GPE_DISPATCH_HANDLER) {
715 status = AE_NOT_EXIST; 683 status = AE_NOT_EXIST;
716 goto unlock_and_exit; 684 goto unlock_and_exit;
717 } 685 }
@@ -725,45 +693,44 @@ acpi_remove_gpe_handler (
725 693
726 /* Disable the GPE before removing the handler */ 694 /* Disable the GPE before removing the handler */
727 695
728 status = acpi_ev_disable_gpe (gpe_event_info); 696 status = acpi_ev_disable_gpe(gpe_event_info);
729 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
730 goto unlock_and_exit; 698 goto unlock_and_exit;
731 } 699 }
732 700
733 /* Make sure all deferred tasks are completed */ 701 /* Make sure all deferred tasks are completed */
734 702
735 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 703 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
736 acpi_os_wait_events_complete(NULL); 704 acpi_os_wait_events_complete(NULL);
737 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 705 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
738 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
739 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
740 } 708 }
741 709
742 /* Remove the handler */ 710 /* Remove the handler */
743 711
744 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 712 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
745 handler = gpe_event_info->dispatch.handler; 713 handler = gpe_event_info->dispatch.handler;
746 714
747 /* Restore Method node (if any), set dispatch flags */ 715 /* Restore Method node (if any), set dispatch flags */
748 716
749 gpe_event_info->dispatch.method_node = handler->method_node; 717 gpe_event_info->dispatch.method_node = handler->method_node;
750 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ 718 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
751 if (handler->method_node) { 719 if (handler->method_node) {
752 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 720 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
753 } 721 }
754 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 722 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
755 723
756 /* Now we can free the handler object */ 724 /* Now we can free the handler object */
757 725
758 ACPI_MEM_FREE (handler); 726 ACPI_MEM_FREE(handler);
759 727
760 728 unlock_and_exit:
761unlock_and_exit: 729 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
762 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 730 return_ACPI_STATUS(status);
763 return_ACPI_STATUS (status);
764} 731}
765EXPORT_SYMBOL(acpi_remove_gpe_handler);
766 732
733EXPORT_SYMBOL(acpi_remove_gpe_handler);
767 734
768/******************************************************************************* 735/*******************************************************************************
769 * 736 *
@@ -779,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
779 * 746 *
780 ******************************************************************************/ 747 ******************************************************************************/
781 748
782acpi_status 749acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
783acpi_acquire_global_lock (
784 u16 timeout,
785 u32 *handle)
786{ 750{
787 acpi_status status; 751 acpi_status status;
788
789 752
790 if (!handle) { 753 if (!handle) {
791 return (AE_BAD_PARAMETER); 754 return (AE_BAD_PARAMETER);
792 } 755 }
793 756
794 status = acpi_ex_enter_interpreter (); 757 status = acpi_ex_enter_interpreter();
795 if (ACPI_FAILURE (status)) { 758 if (ACPI_FAILURE(status)) {
796 return (status); 759 return (status);
797 } 760 }
798 761
799 status = acpi_ev_acquire_global_lock (timeout); 762 status = acpi_ev_acquire_global_lock(timeout);
800 acpi_ex_exit_interpreter (); 763 acpi_ex_exit_interpreter();
801 764
802 if (ACPI_SUCCESS (status)) { 765 if (ACPI_SUCCESS(status)) {
803 acpi_gbl_global_lock_handle++; 766 acpi_gbl_global_lock_handle++;
804 *handle = acpi_gbl_global_lock_handle; 767 *handle = acpi_gbl_global_lock_handle;
805 } 768 }
806 769
807 return (status); 770 return (status);
808} 771}
809EXPORT_SYMBOL(acpi_acquire_global_lock);
810 772
773EXPORT_SYMBOL(acpi_acquire_global_lock);
811 774
812/******************************************************************************* 775/*******************************************************************************
813 * 776 *
@@ -821,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
821 * 784 *
822 ******************************************************************************/ 785 ******************************************************************************/
823 786
824acpi_status 787acpi_status acpi_release_global_lock(u32 handle)
825acpi_release_global_lock (
826 u32 handle)
827{ 788{
828 acpi_status status; 789 acpi_status status;
829
830 790
831 if (handle != acpi_gbl_global_lock_handle) { 791 if (handle != acpi_gbl_global_lock_handle) {
832 return (AE_NOT_ACQUIRED); 792 return (AE_NOT_ACQUIRED);
833 } 793 }
834 794
835 status = acpi_ev_release_global_lock (); 795 status = acpi_ev_release_global_lock();
836 return (status); 796 return (status);
837} 797}
838EXPORT_SYMBOL(acpi_release_global_lock);
839 798
799EXPORT_SYMBOL(acpi_release_global_lock);
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index f337dc2cc569..887ff9f28a0d 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -48,8 +48,7 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evxfevnt") 51ACPI_MODULE_NAME("evxfevnt")
52
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -62,44 +61,39 @@
62 * DESCRIPTION: Transfers the system into ACPI mode. 61 * DESCRIPTION: Transfers the system into ACPI mode.
63 * 62 *
64 ******************************************************************************/ 63 ******************************************************************************/
65 64acpi_status acpi_enable(void)
66acpi_status
67acpi_enable (
68 void)
69{ 65{
70 acpi_status status = AE_OK; 66 acpi_status status = AE_OK;
71
72 67
73 ACPI_FUNCTION_TRACE ("acpi_enable"); 68 ACPI_FUNCTION_TRACE("acpi_enable");
74 69
75 70 /* Make sure we have the FADT */
76 /* Make sure we have the FADT*/
77 71
78 if (!acpi_gbl_FADT) { 72 if (!acpi_gbl_FADT) {
79 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); 73 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
80 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 74 "No FADT information present!\n"));
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
81 } 76 }
82 77
83 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { 78 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
84 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); 79 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
85 } 80 "System is already in ACPI mode\n"));
86 else { 81 } else {
87 /* Transition to ACPI mode */ 82 /* Transition to ACPI mode */
88 83
89 status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI); 84 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
90 if (ACPI_FAILURE (status)) { 85 if (ACPI_FAILURE(status)) {
91 ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n")); 86 ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n"));
92 return_ACPI_STATUS (status); 87 return_ACPI_STATUS(status);
93 } 88 }
94 89
95 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 90 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
96 "Transition to ACPI mode successful\n")); 91 "Transition to ACPI mode successful\n"));
97 } 92 }
98 93
99 return_ACPI_STATUS (status); 94 return_ACPI_STATUS(status);
100} 95}
101 96
102
103/******************************************************************************* 97/*******************************************************************************
104 * 98 *
105 * FUNCTION: acpi_disable 99 * FUNCTION: acpi_disable
@@ -112,43 +106,38 @@ acpi_enable (
112 * 106 *
113 ******************************************************************************/ 107 ******************************************************************************/
114 108
115acpi_status 109acpi_status acpi_disable(void)
116acpi_disable (
117 void)
118{ 110{
119 acpi_status status = AE_OK; 111 acpi_status status = AE_OK;
120
121
122 ACPI_FUNCTION_TRACE ("acpi_disable");
123 112
113 ACPI_FUNCTION_TRACE("acpi_disable");
124 114
125 if (!acpi_gbl_FADT) { 115 if (!acpi_gbl_FADT) {
126 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); 116 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
127 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 117 "No FADT information present!\n"));
118 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
128 } 119 }
129 120
130 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { 121 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
131 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 122 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
132 "System is already in legacy (non-ACPI) mode\n")); 123 "System is already in legacy (non-ACPI) mode\n"));
133 } 124 } else {
134 else {
135 /* Transition to LEGACY mode */ 125 /* Transition to LEGACY mode */
136 126
137 status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY); 127 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
138 128
139 if (ACPI_FAILURE (status)) { 129 if (ACPI_FAILURE(status)) {
140 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 130 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
141 "Could not exit ACPI mode to legacy mode")); 131 "Could not exit ACPI mode to legacy mode"));
142 return_ACPI_STATUS (status); 132 return_ACPI_STATUS(status);
143 } 133 }
144 134
145 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); 135 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
146 } 136 }
147 137
148 return_ACPI_STATUS (status); 138 return_ACPI_STATUS(status);
149} 139}
150 140
151
152/******************************************************************************* 141/*******************************************************************************
153 * 142 *
154 * FUNCTION: acpi_enable_event 143 * FUNCTION: acpi_enable_event
@@ -162,52 +151,50 @@ acpi_disable (
162 * 151 *
163 ******************************************************************************/ 152 ******************************************************************************/
164 153
165acpi_status 154acpi_status acpi_enable_event(u32 event, u32 flags)
166acpi_enable_event (
167 u32 event,
168 u32 flags)
169{ 155{
170 acpi_status status = AE_OK; 156 acpi_status status = AE_OK;
171 u32 value; 157 u32 value;
172
173
174 ACPI_FUNCTION_TRACE ("acpi_enable_event");
175 158
159 ACPI_FUNCTION_TRACE("acpi_enable_event");
176 160
177 /* Decode the Fixed Event */ 161 /* Decode the Fixed Event */
178 162
179 if (event > ACPI_EVENT_MAX) { 163 if (event > ACPI_EVENT_MAX) {
180 return_ACPI_STATUS (AE_BAD_PARAMETER); 164 return_ACPI_STATUS(AE_BAD_PARAMETER);
181 } 165 }
182 166
183 /* 167 /*
184 * Enable the requested fixed event (by writing a one to the 168 * Enable the requested fixed event (by writing a one to the
185 * enable register bit) 169 * enable register bit)
186 */ 170 */
187 status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 171 status =
188 1, ACPI_MTX_LOCK); 172 acpi_set_register(acpi_gbl_fixed_event_info[event].
189 if (ACPI_FAILURE (status)) { 173 enable_register_id, 1, ACPI_MTX_LOCK);
190 return_ACPI_STATUS (status); 174 if (ACPI_FAILURE(status)) {
175 return_ACPI_STATUS(status);
191 } 176 }
192 177
193 /* Make sure that the hardware responded */ 178 /* Make sure that the hardware responded */
194 179
195 status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, 180 status =
196 &value, ACPI_MTX_LOCK); 181 acpi_get_register(acpi_gbl_fixed_event_info[event].
197 if (ACPI_FAILURE (status)) { 182 enable_register_id, &value, ACPI_MTX_LOCK);
198 return_ACPI_STATUS (status); 183 if (ACPI_FAILURE(status)) {
184 return_ACPI_STATUS(status);
199 } 185 }
200 186
201 if (value != 1) { 187 if (value != 1) {
202 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 188 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
203 "Could not enable %s event\n", acpi_ut_get_event_name (event))); 189 "Could not enable %s event\n",
204 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 190 acpi_ut_get_event_name(event)));
191 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
205 } 192 }
206 193
207 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
208} 195}
209EXPORT_SYMBOL(acpi_enable_event);
210 196
197EXPORT_SYMBOL(acpi_enable_event);
211 198
212/******************************************************************************* 199/*******************************************************************************
213 * 200 *
@@ -223,40 +210,34 @@ EXPORT_SYMBOL(acpi_enable_event);
223 * 210 *
224 ******************************************************************************/ 211 ******************************************************************************/
225 212
226acpi_status 213acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
227acpi_set_gpe_type (
228 acpi_handle gpe_device,
229 u32 gpe_number,
230 u8 type)
231{ 214{
232 acpi_status status = AE_OK; 215 acpi_status status = AE_OK;
233 struct acpi_gpe_event_info *gpe_event_info; 216 struct acpi_gpe_event_info *gpe_event_info;
234
235
236 ACPI_FUNCTION_TRACE ("acpi_set_gpe_type");
237 217
218 ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
238 219
239 /* Ensure that we have a valid GPE number */ 220 /* Ensure that we have a valid GPE number */
240 221
241 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 222 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
242 if (!gpe_event_info) { 223 if (!gpe_event_info) {
243 status = AE_BAD_PARAMETER; 224 status = AE_BAD_PARAMETER;
244 goto unlock_and_exit; 225 goto unlock_and_exit;
245 } 226 }
246 227
247 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { 228 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
248 return_ACPI_STATUS (AE_OK); 229 return_ACPI_STATUS(AE_OK);
249 } 230 }
250 231
251 /* Set the new type (will disable GPE if currently enabled) */ 232 /* Set the new type (will disable GPE if currently enabled) */
252 233
253 status = acpi_ev_set_gpe_type (gpe_event_info, type); 234 status = acpi_ev_set_gpe_type(gpe_event_info, type);
254 235
255unlock_and_exit: 236 unlock_and_exit:
256 return_ACPI_STATUS (status); 237 return_ACPI_STATUS(status);
257} 238}
258EXPORT_SYMBOL(acpi_set_gpe_type);
259 239
240EXPORT_SYMBOL(acpi_set_gpe_type);
260 241
261/******************************************************************************* 242/*******************************************************************************
262 * 243 *
@@ -273,31 +254,25 @@ EXPORT_SYMBOL(acpi_set_gpe_type);
273 * 254 *
274 ******************************************************************************/ 255 ******************************************************************************/
275 256
276acpi_status 257acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
277acpi_enable_gpe (
278 acpi_handle gpe_device,
279 u32 gpe_number,
280 u32 flags)
281{ 258{
282 acpi_status status = AE_OK; 259 acpi_status status = AE_OK;
283 struct acpi_gpe_event_info *gpe_event_info; 260 struct acpi_gpe_event_info *gpe_event_info;
284
285
286 ACPI_FUNCTION_TRACE ("acpi_enable_gpe");
287 261
262 ACPI_FUNCTION_TRACE("acpi_enable_gpe");
288 263
289 /* Use semaphore lock if not executing at interrupt level */ 264 /* Use semaphore lock if not executing at interrupt level */
290 265
291 if (flags & ACPI_NOT_ISR) { 266 if (flags & ACPI_NOT_ISR) {
292 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 267 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
293 if (ACPI_FAILURE (status)) { 268 if (ACPI_FAILURE(status)) {
294 return_ACPI_STATUS (status); 269 return_ACPI_STATUS(status);
295 } 270 }
296 } 271 }
297 272
298 /* Ensure that we have a valid GPE number */ 273 /* Ensure that we have a valid GPE number */
299 274
300 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 275 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
301 if (!gpe_event_info) { 276 if (!gpe_event_info) {
302 status = AE_BAD_PARAMETER; 277 status = AE_BAD_PARAMETER;
303 goto unlock_and_exit; 278 goto unlock_and_exit;
@@ -305,16 +280,16 @@ acpi_enable_gpe (
305 280
306 /* Perform the enable */ 281 /* Perform the enable */
307 282
308 status = acpi_ev_enable_gpe (gpe_event_info, TRUE); 283 status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
309 284
310unlock_and_exit: 285 unlock_and_exit:
311 if (flags & ACPI_NOT_ISR) { 286 if (flags & ACPI_NOT_ISR) {
312 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 287 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
313 } 288 }
314 return_ACPI_STATUS (status); 289 return_ACPI_STATUS(status);
315} 290}
316EXPORT_SYMBOL(acpi_enable_gpe);
317 291
292EXPORT_SYMBOL(acpi_enable_gpe);
318 293
319/******************************************************************************* 294/*******************************************************************************
320 * 295 *
@@ -331,46 +306,39 @@ EXPORT_SYMBOL(acpi_enable_gpe);
331 * 306 *
332 ******************************************************************************/ 307 ******************************************************************************/
333 308
334acpi_status 309acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
335acpi_disable_gpe (
336 acpi_handle gpe_device,
337 u32 gpe_number,
338 u32 flags)
339{ 310{
340 acpi_status status = AE_OK; 311 acpi_status status = AE_OK;
341 struct acpi_gpe_event_info *gpe_event_info; 312 struct acpi_gpe_event_info *gpe_event_info;
342
343
344 ACPI_FUNCTION_TRACE ("acpi_disable_gpe");
345 313
314 ACPI_FUNCTION_TRACE("acpi_disable_gpe");
346 315
347 /* Use semaphore lock if not executing at interrupt level */ 316 /* Use semaphore lock if not executing at interrupt level */
348 317
349 if (flags & ACPI_NOT_ISR) { 318 if (flags & ACPI_NOT_ISR) {
350 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 319 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
351 if (ACPI_FAILURE (status)) { 320 if (ACPI_FAILURE(status)) {
352 return_ACPI_STATUS (status); 321 return_ACPI_STATUS(status);
353 } 322 }
354 } 323 }
355 324
356 /* Ensure that we have a valid GPE number */ 325 /* Ensure that we have a valid GPE number */
357 326
358 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 327 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
359 if (!gpe_event_info) { 328 if (!gpe_event_info) {
360 status = AE_BAD_PARAMETER; 329 status = AE_BAD_PARAMETER;
361 goto unlock_and_exit; 330 goto unlock_and_exit;
362 } 331 }
363 332
364 status = acpi_ev_disable_gpe (gpe_event_info); 333 status = acpi_ev_disable_gpe(gpe_event_info);
365 334
366unlock_and_exit: 335 unlock_and_exit:
367 if (flags & ACPI_NOT_ISR) { 336 if (flags & ACPI_NOT_ISR) {
368 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 337 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
369 } 338 }
370 return_ACPI_STATUS (status); 339 return_ACPI_STATUS(status);
371} 340}
372 341
373
374/******************************************************************************* 342/*******************************************************************************
375 * 343 *
376 * FUNCTION: acpi_disable_event 344 * FUNCTION: acpi_disable_event
@@ -384,50 +352,48 @@ unlock_and_exit:
384 * 352 *
385 ******************************************************************************/ 353 ******************************************************************************/
386 354
387acpi_status 355acpi_status acpi_disable_event(u32 event, u32 flags)
388acpi_disable_event (
389 u32 event,
390 u32 flags)
391{ 356{
392 acpi_status status = AE_OK; 357 acpi_status status = AE_OK;
393 u32 value; 358 u32 value;
394
395
396 ACPI_FUNCTION_TRACE ("acpi_disable_event");
397 359
360 ACPI_FUNCTION_TRACE("acpi_disable_event");
398 361
399 /* Decode the Fixed Event */ 362 /* Decode the Fixed Event */
400 363
401 if (event > ACPI_EVENT_MAX) { 364 if (event > ACPI_EVENT_MAX) {
402 return_ACPI_STATUS (AE_BAD_PARAMETER); 365 return_ACPI_STATUS(AE_BAD_PARAMETER);
403 } 366 }
404 367
405 /* 368 /*
406 * Disable the requested fixed event (by writing a zero to the 369 * Disable the requested fixed event (by writing a zero to the
407 * enable register bit) 370 * enable register bit)
408 */ 371 */
409 status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 372 status =
410 0, ACPI_MTX_LOCK); 373 acpi_set_register(acpi_gbl_fixed_event_info[event].
411 if (ACPI_FAILURE (status)) { 374 enable_register_id, 0, ACPI_MTX_LOCK);
412 return_ACPI_STATUS (status); 375 if (ACPI_FAILURE(status)) {
376 return_ACPI_STATUS(status);
413 } 377 }
414 378
415 status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, 379 status =
416 &value, ACPI_MTX_LOCK); 380 acpi_get_register(acpi_gbl_fixed_event_info[event].
417 if (ACPI_FAILURE (status)) { 381 enable_register_id, &value, ACPI_MTX_LOCK);
418 return_ACPI_STATUS (status); 382 if (ACPI_FAILURE(status)) {
383 return_ACPI_STATUS(status);
419 } 384 }
420 385
421 if (value != 0) { 386 if (value != 0) {
422 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
423 "Could not disable %s events\n", acpi_ut_get_event_name (event))); 388 "Could not disable %s events\n",
424 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 389 acpi_ut_get_event_name(event)));
390 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
425 } 391 }
426 392
427 return_ACPI_STATUS (status); 393 return_ACPI_STATUS(status);
428} 394}
429EXPORT_SYMBOL(acpi_disable_event);
430 395
396EXPORT_SYMBOL(acpi_disable_event);
431 397
432/******************************************************************************* 398/*******************************************************************************
433 * 399 *
@@ -441,33 +407,30 @@ EXPORT_SYMBOL(acpi_disable_event);
441 * 407 *
442 ******************************************************************************/ 408 ******************************************************************************/
443 409
444acpi_status 410acpi_status acpi_clear_event(u32 event)
445acpi_clear_event (
446 u32 event)
447{ 411{
448 acpi_status status = AE_OK; 412 acpi_status status = AE_OK;
449
450
451 ACPI_FUNCTION_TRACE ("acpi_clear_event");
452 413
414 ACPI_FUNCTION_TRACE("acpi_clear_event");
453 415
454 /* Decode the Fixed Event */ 416 /* Decode the Fixed Event */
455 417
456 if (event > ACPI_EVENT_MAX) { 418 if (event > ACPI_EVENT_MAX) {
457 return_ACPI_STATUS (AE_BAD_PARAMETER); 419 return_ACPI_STATUS(AE_BAD_PARAMETER);
458 } 420 }
459 421
460 /* 422 /*
461 * Clear the requested fixed event (By writing a one to the 423 * Clear the requested fixed event (By writing a one to the
462 * status register bit) 424 * status register bit)
463 */ 425 */
464 status = acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, 426 status =
465 1, ACPI_MTX_LOCK); 427 acpi_set_register(acpi_gbl_fixed_event_info[event].
428 status_register_id, 1, ACPI_MTX_LOCK);
466 429
467 return_ACPI_STATUS (status); 430 return_ACPI_STATUS(status);
468} 431}
469EXPORT_SYMBOL(acpi_clear_event);
470 432
433EXPORT_SYMBOL(acpi_clear_event);
471 434
472/******************************************************************************* 435/*******************************************************************************
473 * 436 *
@@ -483,46 +446,39 @@ EXPORT_SYMBOL(acpi_clear_event);
483 * 446 *
484 ******************************************************************************/ 447 ******************************************************************************/
485 448
486acpi_status 449acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
487acpi_clear_gpe (
488 acpi_handle gpe_device,
489 u32 gpe_number,
490 u32 flags)
491{ 450{
492 acpi_status status = AE_OK; 451 acpi_status status = AE_OK;
493 struct acpi_gpe_event_info *gpe_event_info; 452 struct acpi_gpe_event_info *gpe_event_info;
494
495
496 ACPI_FUNCTION_TRACE ("acpi_clear_gpe");
497 453
454 ACPI_FUNCTION_TRACE("acpi_clear_gpe");
498 455
499 /* Use semaphore lock if not executing at interrupt level */ 456 /* Use semaphore lock if not executing at interrupt level */
500 457
501 if (flags & ACPI_NOT_ISR) { 458 if (flags & ACPI_NOT_ISR) {
502 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 459 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
503 if (ACPI_FAILURE (status)) { 460 if (ACPI_FAILURE(status)) {
504 return_ACPI_STATUS (status); 461 return_ACPI_STATUS(status);
505 } 462 }
506 } 463 }
507 464
508 /* Ensure that we have a valid GPE number */ 465 /* Ensure that we have a valid GPE number */
509 466
510 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 467 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
511 if (!gpe_event_info) { 468 if (!gpe_event_info) {
512 status = AE_BAD_PARAMETER; 469 status = AE_BAD_PARAMETER;
513 goto unlock_and_exit; 470 goto unlock_and_exit;
514 } 471 }
515 472
516 status = acpi_hw_clear_gpe (gpe_event_info); 473 status = acpi_hw_clear_gpe(gpe_event_info);
517 474
518unlock_and_exit: 475 unlock_and_exit:
519 if (flags & ACPI_NOT_ISR) { 476 if (flags & ACPI_NOT_ISR) {
520 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 477 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
521 } 478 }
522 return_ACPI_STATUS (status); 479 return_ACPI_STATUS(status);
523} 480}
524 481
525
526#ifdef ACPI_FUTURE_USAGE 482#ifdef ACPI_FUTURE_USAGE
527/******************************************************************************* 483/*******************************************************************************
528 * 484 *
@@ -538,36 +494,31 @@ unlock_and_exit:
538 * 494 *
539 ******************************************************************************/ 495 ******************************************************************************/
540 496
541acpi_status 497acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
542acpi_get_event_status (
543 u32 event,
544 acpi_event_status *event_status)
545{ 498{
546 acpi_status status = AE_OK; 499 acpi_status status = AE_OK;
547
548
549 ACPI_FUNCTION_TRACE ("acpi_get_event_status");
550 500
501 ACPI_FUNCTION_TRACE("acpi_get_event_status");
551 502
552 if (!event_status) { 503 if (!event_status) {
553 return_ACPI_STATUS (AE_BAD_PARAMETER); 504 return_ACPI_STATUS(AE_BAD_PARAMETER);
554 } 505 }
555 506
556 /* Decode the Fixed Event */ 507 /* Decode the Fixed Event */
557 508
558 if (event > ACPI_EVENT_MAX) { 509 if (event > ACPI_EVENT_MAX) {
559 return_ACPI_STATUS (AE_BAD_PARAMETER); 510 return_ACPI_STATUS(AE_BAD_PARAMETER);
560 } 511 }
561 512
562 /* Get the status of the requested fixed event */ 513 /* Get the status of the requested fixed event */
563 514
564 status = acpi_get_register (acpi_gbl_fixed_event_info[event].status_register_id, 515 status =
565 event_status, ACPI_MTX_LOCK); 516 acpi_get_register(acpi_gbl_fixed_event_info[event].
517 status_register_id, event_status, ACPI_MTX_LOCK);
566 518
567 return_ACPI_STATUS (status); 519 return_ACPI_STATUS(status);
568} 520}
569 521
570
571/******************************************************************************* 522/*******************************************************************************
572 * 523 *
573 * FUNCTION: acpi_get_gpe_status 524 * FUNCTION: acpi_get_gpe_status
@@ -585,31 +536,26 @@ acpi_get_event_status (
585 ******************************************************************************/ 536 ******************************************************************************/
586 537
587acpi_status 538acpi_status
588acpi_get_gpe_status ( 539acpi_get_gpe_status(acpi_handle gpe_device,
589 acpi_handle gpe_device, 540 u32 gpe_number, u32 flags, acpi_event_status * event_status)
590 u32 gpe_number,
591 u32 flags,
592 acpi_event_status *event_status)
593{ 541{
594 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
595 struct acpi_gpe_event_info *gpe_event_info; 543 struct acpi_gpe_event_info *gpe_event_info;
596
597
598 ACPI_FUNCTION_TRACE ("acpi_get_gpe_status");
599 544
545 ACPI_FUNCTION_TRACE("acpi_get_gpe_status");
600 546
601 /* Use semaphore lock if not executing at interrupt level */ 547 /* Use semaphore lock if not executing at interrupt level */
602 548
603 if (flags & ACPI_NOT_ISR) { 549 if (flags & ACPI_NOT_ISR) {
604 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 550 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
605 if (ACPI_FAILURE (status)) { 551 if (ACPI_FAILURE(status)) {
606 return_ACPI_STATUS (status); 552 return_ACPI_STATUS(status);
607 } 553 }
608 } 554 }
609 555
610 /* Ensure that we have a valid GPE number */ 556 /* Ensure that we have a valid GPE number */
611 557
612 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 558 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
613 if (!gpe_event_info) { 559 if (!gpe_event_info) {
614 status = AE_BAD_PARAMETER; 560 status = AE_BAD_PARAMETER;
615 goto unlock_and_exit; 561 goto unlock_and_exit;
@@ -617,16 +563,15 @@ acpi_get_gpe_status (
617 563
618 /* Obtain status on the requested GPE number */ 564 /* Obtain status on the requested GPE number */
619 565
620 status = acpi_hw_get_gpe_status (gpe_event_info, event_status); 566 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
621 567
622unlock_and_exit: 568 unlock_and_exit:
623 if (flags & ACPI_NOT_ISR) { 569 if (flags & ACPI_NOT_ISR) {
624 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 570 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
625 } 571 }
626 return_ACPI_STATUS (status); 572 return_ACPI_STATUS(status);
627} 573}
628#endif /* ACPI_FUTURE_USAGE */ 574#endif /* ACPI_FUTURE_USAGE */
629
630 575
631/******************************************************************************* 576/*******************************************************************************
632 * 577 *
@@ -635,7 +580,7 @@ unlock_and_exit:
635 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device 580 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
636 * gpe_block_address - Address and space_iD 581 * gpe_block_address - Address and space_iD
637 * register_count - Number of GPE register pairs in the block 582 * register_count - Number of GPE register pairs in the block
638 * interrupt_level - H/W interrupt for the block 583 * interrupt_number - H/W interrupt for the block
639 * 584 *
640 * RETURN: Status 585 * RETURN: Status
641 * 586 *
@@ -644,33 +589,27 @@ unlock_and_exit:
644 ******************************************************************************/ 589 ******************************************************************************/
645 590
646acpi_status 591acpi_status
647acpi_install_gpe_block ( 592acpi_install_gpe_block(acpi_handle gpe_device,
648 acpi_handle gpe_device, 593 struct acpi_generic_address *gpe_block_address,
649 struct acpi_generic_address *gpe_block_address, 594 u32 register_count, u32 interrupt_number)
650 u32 register_count,
651 u32 interrupt_level)
652{ 595{
653 acpi_status status; 596 acpi_status status;
654 union acpi_operand_object *obj_desc; 597 union acpi_operand_object *obj_desc;
655 struct acpi_namespace_node *node; 598 struct acpi_namespace_node *node;
656 struct acpi_gpe_block_info *gpe_block; 599 struct acpi_gpe_block_info *gpe_block;
657
658 600
659 ACPI_FUNCTION_TRACE ("acpi_install_gpe_block"); 601 ACPI_FUNCTION_TRACE("acpi_install_gpe_block");
660 602
661 603 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
662 if ((!gpe_device) || 604 return_ACPI_STATUS(AE_BAD_PARAMETER);
663 (!gpe_block_address) ||
664 (!register_count)) {
665 return_ACPI_STATUS (AE_BAD_PARAMETER);
666 } 605 }
667 606
668 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 607 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
669 if (ACPI_FAILURE (status)) { 608 if (ACPI_FAILURE(status)) {
670 return (status); 609 return (status);
671 } 610 }
672 611
673 node = acpi_ns_map_handle_to_node (gpe_device); 612 node = acpi_ns_map_handle_to_node(gpe_device);
674 if (!node) { 613 if (!node) {
675 status = AE_BAD_PARAMETER; 614 status = AE_BAD_PARAMETER;
676 goto unlock_and_exit; 615 goto unlock_and_exit;
@@ -680,31 +619,33 @@ acpi_install_gpe_block (
680 * For user-installed GPE Block Devices, the gpe_block_base_number 619 * For user-installed GPE Block Devices, the gpe_block_base_number
681 * is always zero 620 * is always zero
682 */ 621 */
683 status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, 622 status =
684 0, interrupt_level, &gpe_block); 623 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
685 if (ACPI_FAILURE (status)) { 624 interrupt_number, &gpe_block);
625 if (ACPI_FAILURE(status)) {
686 goto unlock_and_exit; 626 goto unlock_and_exit;
687 } 627 }
688 628
689 /* Get the device_object attached to the node */ 629 /* Get the device_object attached to the node */
690 630
691 obj_desc = acpi_ns_get_attached_object (node); 631 obj_desc = acpi_ns_get_attached_object(node);
692 if (!obj_desc) { 632 if (!obj_desc) {
693 /* No object, create a new one */ 633 /* No object, create a new one */
694 634
695 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_DEVICE); 635 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
696 if (!obj_desc) { 636 if (!obj_desc) {
697 status = AE_NO_MEMORY; 637 status = AE_NO_MEMORY;
698 goto unlock_and_exit; 638 goto unlock_and_exit;
699 } 639 }
700 640
701 status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_DEVICE); 641 status =
642 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
702 643
703 /* Remove local reference to the object */ 644 /* Remove local reference to the object */
704 645
705 acpi_ut_remove_reference (obj_desc); 646 acpi_ut_remove_reference(obj_desc);
706 647
707 if (ACPI_FAILURE (status)) { 648 if (ACPI_FAILURE(status)) {
708 goto unlock_and_exit; 649 goto unlock_and_exit;
709 } 650 }
710 } 651 }
@@ -713,13 +654,12 @@ acpi_install_gpe_block (
713 654
714 obj_desc->device.gpe_block = gpe_block; 655 obj_desc->device.gpe_block = gpe_block;
715 656
716 657 unlock_and_exit:
717unlock_and_exit: 658 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
718 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 659 return_ACPI_STATUS(status);
719 return_ACPI_STATUS (status);
720} 660}
721EXPORT_SYMBOL(acpi_install_gpe_block);
722 661
662EXPORT_SYMBOL(acpi_install_gpe_block);
723 663
724/******************************************************************************* 664/*******************************************************************************
725 * 665 *
@@ -733,28 +673,24 @@ EXPORT_SYMBOL(acpi_install_gpe_block);
733 * 673 *
734 ******************************************************************************/ 674 ******************************************************************************/
735 675
736acpi_status 676acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
737acpi_remove_gpe_block (
738 acpi_handle gpe_device)
739{ 677{
740 union acpi_operand_object *obj_desc; 678 union acpi_operand_object *obj_desc;
741 acpi_status status; 679 acpi_status status;
742 struct acpi_namespace_node *node; 680 struct acpi_namespace_node *node;
743
744
745 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_block");
746 681
682 ACPI_FUNCTION_TRACE("acpi_remove_gpe_block");
747 683
748 if (!gpe_device) { 684 if (!gpe_device) {
749 return_ACPI_STATUS (AE_BAD_PARAMETER); 685 return_ACPI_STATUS(AE_BAD_PARAMETER);
750 } 686 }
751 687
752 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 688 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
753 if (ACPI_FAILURE (status)) { 689 if (ACPI_FAILURE(status)) {
754 return (status); 690 return (status);
755 } 691 }
756 692
757 node = acpi_ns_map_handle_to_node (gpe_device); 693 node = acpi_ns_map_handle_to_node(gpe_device);
758 if (!node) { 694 if (!node) {
759 status = AE_BAD_PARAMETER; 695 status = AE_BAD_PARAMETER;
760 goto unlock_and_exit; 696 goto unlock_and_exit;
@@ -762,22 +698,21 @@ acpi_remove_gpe_block (
762 698
763 /* Get the device_object attached to the node */ 699 /* Get the device_object attached to the node */
764 700
765 obj_desc = acpi_ns_get_attached_object (node); 701 obj_desc = acpi_ns_get_attached_object(node);
766 if (!obj_desc || 702 if (!obj_desc || !obj_desc->device.gpe_block) {
767 !obj_desc->device.gpe_block) { 703 return_ACPI_STATUS(AE_NULL_OBJECT);
768 return_ACPI_STATUS (AE_NULL_OBJECT);
769 } 704 }
770 705
771 /* Delete the GPE block (but not the device_object) */ 706 /* Delete the GPE block (but not the device_object) */
772 707
773 status = acpi_ev_delete_gpe_block (obj_desc->device.gpe_block); 708 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
774 if (ACPI_SUCCESS (status)) { 709 if (ACPI_SUCCESS(status)) {
775 obj_desc->device.gpe_block = NULL; 710 obj_desc->device.gpe_block = NULL;
776 } 711 }
777 712
778unlock_and_exit: 713 unlock_and_exit:
779 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 714 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
780 return_ACPI_STATUS (status); 715 return_ACPI_STATUS(status);
781} 716}
782 717
783EXPORT_SYMBOL(acpi_remove_gpe_block); 718EXPORT_SYMBOL(acpi_remove_gpe_block);
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
index d058587b3427..6f28ea2db5ba 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/events/evxfregn.c
@@ -49,8 +49,7 @@
49#include <acpi/acevents.h> 49#include <acpi/acevents.h>
50 50
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxfregn") 52ACPI_MODULE_NAME("evxfregn")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -67,36 +66,31 @@
67 * DESCRIPTION: Install a handler for all op_regions of a given space_id. 66 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
68 * 67 *
69 ******************************************************************************/ 68 ******************************************************************************/
70
71acpi_status 69acpi_status
72acpi_install_address_space_handler ( 70acpi_install_address_space_handler(acpi_handle device,
73 acpi_handle device, 71 acpi_adr_space_type space_id,
74 acpi_adr_space_type space_id, 72 acpi_adr_space_handler handler,
75 acpi_adr_space_handler handler, 73 acpi_adr_space_setup setup, void *context)
76 acpi_adr_space_setup setup,
77 void *context)
78{ 74{
79 struct acpi_namespace_node *node; 75 struct acpi_namespace_node *node;
80 acpi_status status; 76 acpi_status status;
81
82
83 ACPI_FUNCTION_TRACE ("acpi_install_address_space_handler");
84 77
78 ACPI_FUNCTION_TRACE("acpi_install_address_space_handler");
85 79
86 /* Parameter validation */ 80 /* Parameter validation */
87 81
88 if (!device) { 82 if (!device) {
89 return_ACPI_STATUS (AE_BAD_PARAMETER); 83 return_ACPI_STATUS(AE_BAD_PARAMETER);
90 } 84 }
91 85
92 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 86 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
93 if (ACPI_FAILURE (status)) { 87 if (ACPI_FAILURE(status)) {
94 return_ACPI_STATUS (status); 88 return_ACPI_STATUS(status);
95 } 89 }
96 90
97 /* Convert and validate the device handle */ 91 /* Convert and validate the device handle */
98 92
99 node = acpi_ns_map_handle_to_node (device); 93 node = acpi_ns_map_handle_to_node(device);
100 if (!node) { 94 if (!node) {
101 status = AE_BAD_PARAMETER; 95 status = AE_BAD_PARAMETER;
102 goto unlock_and_exit; 96 goto unlock_and_exit;
@@ -104,21 +98,23 @@ acpi_install_address_space_handler (
104 98
105 /* Install the handler for all Regions for this Space ID */ 99 /* Install the handler for all Regions for this Space ID */
106 100
107 status = acpi_ev_install_space_handler (node, space_id, handler, setup, context); 101 status =
108 if (ACPI_FAILURE (status)) { 102 acpi_ev_install_space_handler(node, space_id, handler, setup,
103 context);
104 if (ACPI_FAILURE(status)) {
109 goto unlock_and_exit; 105 goto unlock_and_exit;
110 } 106 }
111 107
112 /* Run all _REG methods for this address space */ 108 /* Run all _REG methods for this address space */
113 109
114 status = acpi_ev_execute_reg_methods (node, space_id); 110 status = acpi_ev_execute_reg_methods(node, space_id);
115 111
116unlock_and_exit: 112 unlock_and_exit:
117 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 113 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
118 return_ACPI_STATUS (status); 114 return_ACPI_STATUS(status);
119} 115}
120EXPORT_SYMBOL(acpi_install_address_space_handler);
121 116
117EXPORT_SYMBOL(acpi_install_address_space_handler);
122 118
123/******************************************************************************* 119/*******************************************************************************
124 * 120 *
@@ -135,36 +131,33 @@ EXPORT_SYMBOL(acpi_install_address_space_handler);
135 ******************************************************************************/ 131 ******************************************************************************/
136 132
137acpi_status 133acpi_status
138acpi_remove_address_space_handler ( 134acpi_remove_address_space_handler(acpi_handle device,
139 acpi_handle device, 135 acpi_adr_space_type space_id,
140 acpi_adr_space_type space_id, 136 acpi_adr_space_handler handler)
141 acpi_adr_space_handler handler)
142{ 137{
143 union acpi_operand_object *obj_desc; 138 union acpi_operand_object *obj_desc;
144 union acpi_operand_object *handler_obj; 139 union acpi_operand_object *handler_obj;
145 union acpi_operand_object *region_obj; 140 union acpi_operand_object *region_obj;
146 union acpi_operand_object **last_obj_ptr; 141 union acpi_operand_object **last_obj_ptr;
147 struct acpi_namespace_node *node; 142 struct acpi_namespace_node *node;
148 acpi_status status; 143 acpi_status status;
149
150
151 ACPI_FUNCTION_TRACE ("acpi_remove_address_space_handler");
152 144
145 ACPI_FUNCTION_TRACE("acpi_remove_address_space_handler");
153 146
154 /* Parameter validation */ 147 /* Parameter validation */
155 148
156 if (!device) { 149 if (!device) {
157 return_ACPI_STATUS (AE_BAD_PARAMETER); 150 return_ACPI_STATUS(AE_BAD_PARAMETER);
158 } 151 }
159 152
160 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 153 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
161 if (ACPI_FAILURE (status)) { 154 if (ACPI_FAILURE(status)) {
162 return_ACPI_STATUS (status); 155 return_ACPI_STATUS(status);
163 } 156 }
164 157
165 /* Convert and validate the device handle */ 158 /* Convert and validate the device handle */
166 159
167 node = acpi_ns_map_handle_to_node (device); 160 node = acpi_ns_map_handle_to_node(device);
168 if (!node) { 161 if (!node) {
169 status = AE_BAD_PARAMETER; 162 status = AE_BAD_PARAMETER;
170 goto unlock_and_exit; 163 goto unlock_and_exit;
@@ -172,7 +165,7 @@ acpi_remove_address_space_handler (
172 165
173 /* Make sure the internal object exists */ 166 /* Make sure the internal object exists */
174 167
175 obj_desc = acpi_ns_get_attached_object (node); 168 obj_desc = acpi_ns_get_attached_object(node);
176 if (!obj_desc) { 169 if (!obj_desc) {
177 status = AE_NOT_EXIST; 170 status = AE_NOT_EXIST;
178 goto unlock_and_exit; 171 goto unlock_and_exit;
@@ -188,10 +181,11 @@ acpi_remove_address_space_handler (
188 if (handler_obj->address_space.space_id == space_id) { 181 if (handler_obj->address_space.space_id == space_id) {
189 /* Matched space_id, first dereference this in the Regions */ 182 /* Matched space_id, first dereference this in the Regions */
190 183
191 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 184 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
192 "Removing address handler %p(%p) for region %s on Device %p(%p)\n", 185 "Removing address handler %p(%p) for region %s on Device %p(%p)\n",
193 handler_obj, handler, acpi_ut_get_region_name (space_id), 186 handler_obj, handler,
194 node, obj_desc)); 187 acpi_ut_get_region_name(space_id),
188 node, obj_desc));
195 189
196 region_obj = handler_obj->address_space.region_list; 190 region_obj = handler_obj->address_space.region_list;
197 191
@@ -205,13 +199,14 @@ acpi_remove_address_space_handler (
205 * The region is just inaccessible as indicated to 199 * The region is just inaccessible as indicated to
206 * the _REG method 200 * the _REG method
207 */ 201 */
208 acpi_ev_detach_region (region_obj, TRUE); 202 acpi_ev_detach_region(region_obj, TRUE);
209 203
210 /* 204 /*
211 * Walk the list: Just grab the head because the 205 * Walk the list: Just grab the head because the
212 * detach_region removed the previous head. 206 * detach_region removed the previous head.
213 */ 207 */
214 region_obj = handler_obj->address_space.region_list; 208 region_obj =
209 handler_obj->address_space.region_list;
215 210
216 } 211 }
217 212
@@ -221,7 +216,7 @@ acpi_remove_address_space_handler (
221 216
222 /* Now we can delete the handler object */ 217 /* Now we can delete the handler object */
223 218
224 acpi_ut_remove_reference (handler_obj); 219 acpi_ut_remove_reference(handler_obj);
225 goto unlock_and_exit; 220 goto unlock_and_exit;
226 } 221 }
227 222
@@ -233,15 +228,16 @@ acpi_remove_address_space_handler (
233 228
234 /* The handler does not exist */ 229 /* The handler does not exist */
235 230
236 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 231 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
237 "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n", 232 "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
238 handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc)); 233 handler, acpi_ut_get_region_name(space_id), space_id,
234 node, obj_desc));
239 235
240 status = AE_NOT_EXIST; 236 status = AE_NOT_EXIST;
241 237
242unlock_and_exit: 238 unlock_and_exit:
243 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 239 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
244 return_ACPI_STATUS (status); 240 return_ACPI_STATUS(status);
245} 241}
246EXPORT_SYMBOL(acpi_remove_address_space_handler);
247 242
243EXPORT_SYMBOL(acpi_remove_address_space_handler);
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 734b2f24af48..1ce365d651d8 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -50,18 +49,14 @@
50#include <acpi/actables.h> 49#include <acpi/actables.h>
51#include <acpi/acdispat.h> 50#include <acpi/acdispat.h>
52 51
53
54#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exconfig") 53ACPI_MODULE_NAME("exconfig")
56 54
57/* Local prototypes */ 55/* Local prototypes */
58
59static acpi_status 56static acpi_status
60acpi_ex_add_table ( 57acpi_ex_add_table(struct acpi_table_header *table,
61 struct acpi_table_header *table, 58 struct acpi_namespace_node *parent_node,
62 struct acpi_namespace_node *parent_node, 59 union acpi_operand_object **ddb_handle);
63 union acpi_operand_object **ddb_handle);
64
65 60
66/******************************************************************************* 61/*******************************************************************************
67 * 62 *
@@ -79,64 +74,67 @@ acpi_ex_add_table (
79 ******************************************************************************/ 74 ******************************************************************************/
80 75
81static acpi_status 76static acpi_status
82acpi_ex_add_table ( 77acpi_ex_add_table(struct acpi_table_header *table,
83 struct acpi_table_header *table, 78 struct acpi_namespace_node *parent_node,
84 struct acpi_namespace_node *parent_node, 79 union acpi_operand_object **ddb_handle)
85 union acpi_operand_object **ddb_handle)
86{ 80{
87 acpi_status status; 81 acpi_status status;
88 struct acpi_table_desc table_info; 82 struct acpi_table_desc table_info;
89 union acpi_operand_object *obj_desc; 83 union acpi_operand_object *obj_desc;
90
91
92 ACPI_FUNCTION_TRACE ("ex_add_table");
93 84
85 ACPI_FUNCTION_TRACE("ex_add_table");
94 86
95 /* Create an object to be the table handle */ 87 /* Create an object to be the table handle */
96 88
97 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); 89 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
98 if (!obj_desc) { 90 if (!obj_desc) {
99 return_ACPI_STATUS (AE_NO_MEMORY); 91 return_ACPI_STATUS(AE_NO_MEMORY);
100 } 92 }
101 93
94 /* Init the table handle */
95
96 obj_desc->reference.opcode = AML_LOAD_OP;
97 *ddb_handle = obj_desc;
98
102 /* Install the new table into the local data structures */ 99 /* Install the new table into the local data structures */
103 100
104 ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); 101 ACPI_MEMSET(&table_info, 0, sizeof(struct acpi_table_desc));
105 102
106 table_info.type = ACPI_TABLE_SSDT; 103 table_info.type = ACPI_TABLE_SSDT;
107 table_info.pointer = table; 104 table_info.pointer = table;
108 table_info.length = (acpi_size) table->length; 105 table_info.length = (acpi_size) table->length;
109 table_info.allocation = ACPI_MEM_ALLOCATED; 106 table_info.allocation = ACPI_MEM_ALLOCATED;
110 107
111 status = acpi_tb_install_table (&table_info); 108 status = acpi_tb_install_table(&table_info);
112 if (ACPI_FAILURE (status)) { 109 obj_desc->reference.object = table_info.installed_desc;
110
111 if (ACPI_FAILURE(status)) {
112 if (status == AE_ALREADY_EXISTS) {
113 /* Table already exists, just return the handle */
114
115 return_ACPI_STATUS(AE_OK);
116 }
113 goto cleanup; 117 goto cleanup;
114 } 118 }
115 119
116 /* Add the table to the namespace */ 120 /* Add the table to the namespace */
117 121
118 status = acpi_ns_load_table (table_info.installed_desc, parent_node); 122 status = acpi_ns_load_table(table_info.installed_desc, parent_node);
119 if (ACPI_FAILURE (status)) { 123 if (ACPI_FAILURE(status)) {
120 /* Uninstall table on error */ 124 /* Uninstall table on error */
121 125
122 (void) acpi_tb_uninstall_table (table_info.installed_desc); 126 (void)acpi_tb_uninstall_table(table_info.installed_desc);
123 goto cleanup; 127 goto cleanup;
124 } 128 }
125 129
126 /* Init the table handle */ 130 return_ACPI_STATUS(AE_OK);
127 131
128 obj_desc->reference.opcode = AML_LOAD_OP; 132 cleanup:
129 obj_desc->reference.object = table_info.installed_desc; 133 acpi_ut_remove_reference(obj_desc);
130 *ddb_handle = obj_desc; 134 *ddb_handle = NULL;
131 return_ACPI_STATUS (AE_OK); 135 return_ACPI_STATUS(status);
132
133
134cleanup:
135 acpi_ut_remove_reference (obj_desc);
136 return_ACPI_STATUS (status);
137} 136}
138 137
139
140/******************************************************************************* 138/*******************************************************************************
141 * 139 *
142 * FUNCTION: acpi_ex_load_table_op 140 * FUNCTION: acpi_ex_load_table_op
@@ -151,56 +149,53 @@ cleanup:
151 ******************************************************************************/ 149 ******************************************************************************/
152 150
153acpi_status 151acpi_status
154acpi_ex_load_table_op ( 152acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
155 struct acpi_walk_state *walk_state, 153 union acpi_operand_object **return_desc)
156 union acpi_operand_object **return_desc)
157{ 154{
158 acpi_status status; 155 acpi_status status;
159 union acpi_operand_object **operand = &walk_state->operands[0]; 156 union acpi_operand_object **operand = &walk_state->operands[0];
160 struct acpi_table_header *table; 157 struct acpi_table_header *table;
161 struct acpi_namespace_node *parent_node; 158 struct acpi_namespace_node *parent_node;
162 struct acpi_namespace_node *start_node; 159 struct acpi_namespace_node *start_node;
163 struct acpi_namespace_node *parameter_node = NULL; 160 struct acpi_namespace_node *parameter_node = NULL;
164 union acpi_operand_object *ddb_handle; 161 union acpi_operand_object *ddb_handle;
165
166
167 ACPI_FUNCTION_TRACE ("ex_load_table_op");
168 162
163 ACPI_FUNCTION_TRACE("ex_load_table_op");
169 164
170#if 0 165#if 0
171 /* 166 /*
172 * Make sure that the signature does not match one of the tables that 167 * Make sure that the signature does not match one of the tables that
173 * is already loaded. 168 * is already loaded.
174 */ 169 */
175 status = acpi_tb_match_signature (operand[0]->string.pointer, NULL); 170 status = acpi_tb_match_signature(operand[0]->string.pointer, NULL);
176 if (status == AE_OK) { 171 if (status == AE_OK) {
177 /* Signature matched -- don't allow override */ 172 /* Signature matched -- don't allow override */
178 173
179 return_ACPI_STATUS (AE_ALREADY_EXISTS); 174 return_ACPI_STATUS(AE_ALREADY_EXISTS);
180 } 175 }
181#endif 176#endif
182 177
183 /* Find the ACPI table */ 178 /* Find the ACPI table */
184 179
185 status = acpi_tb_find_table (operand[0]->string.pointer, 180 status = acpi_tb_find_table(operand[0]->string.pointer,
186 operand[1]->string.pointer, 181 operand[1]->string.pointer,
187 operand[2]->string.pointer, &table); 182 operand[2]->string.pointer, &table);
188 if (ACPI_FAILURE (status)) { 183 if (ACPI_FAILURE(status)) {
189 if (status != AE_NOT_FOUND) { 184 if (status != AE_NOT_FOUND) {
190 return_ACPI_STATUS (status); 185 return_ACPI_STATUS(status);
191 } 186 }
192 187
193 /* Table not found, return an Integer=0 and AE_OK */ 188 /* Table not found, return an Integer=0 and AE_OK */
194 189
195 ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 190 ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
196 if (!ddb_handle) { 191 if (!ddb_handle) {
197 return_ACPI_STATUS (AE_NO_MEMORY); 192 return_ACPI_STATUS(AE_NO_MEMORY);
198 } 193 }
199 194
200 ddb_handle->integer.value = 0; 195 ddb_handle->integer.value = 0;
201 *return_desc = ddb_handle; 196 *return_desc = ddb_handle;
202 197
203 return_ACPI_STATUS (AE_OK); 198 return_ACPI_STATUS(AE_OK);
204 } 199 }
205 200
206 /* Default nodes */ 201 /* Default nodes */
@@ -215,10 +210,12 @@ acpi_ex_load_table_op (
215 * Find the node referenced by the root_path_string. This is the 210 * Find the node referenced by the root_path_string. This is the
216 * location within the namespace where the table will be loaded. 211 * location within the namespace where the table will be loaded.
217 */ 212 */
218 status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node, 213 status =
219 ACPI_NS_SEARCH_PARENT, &parent_node); 214 acpi_ns_get_node_by_path(operand[3]->string.pointer,
220 if (ACPI_FAILURE (status)) { 215 start_node, ACPI_NS_SEARCH_PARENT,
221 return_ACPI_STATUS (status); 216 &parent_node);
217 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS(status);
222 } 219 }
223 } 220 }
224 221
@@ -226,7 +223,7 @@ acpi_ex_load_table_op (
226 223
227 if (operand[4]->string.length > 0) { 224 if (operand[4]->string.length > 0) {
228 if ((operand[4]->string.pointer[0] != '\\') && 225 if ((operand[4]->string.pointer[0] != '\\') &&
229 (operand[4]->string.pointer[0] != '^')) { 226 (operand[4]->string.pointer[0] != '^')) {
230 /* 227 /*
231 * Path is not absolute, so it will be relative to the node 228 * Path is not absolute, so it will be relative to the node
232 * referenced by the root_path_string (or the NS root if omitted) 229 * referenced by the root_path_string (or the NS root if omitted)
@@ -236,18 +233,20 @@ acpi_ex_load_table_op (
236 233
237 /* Find the node referenced by the parameter_path_string */ 234 /* Find the node referenced by the parameter_path_string */
238 235
239 status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node, 236 status =
240 ACPI_NS_SEARCH_PARENT, &parameter_node); 237 acpi_ns_get_node_by_path(operand[4]->string.pointer,
241 if (ACPI_FAILURE (status)) { 238 start_node, ACPI_NS_SEARCH_PARENT,
242 return_ACPI_STATUS (status); 239 &parameter_node);
240 if (ACPI_FAILURE(status)) {
241 return_ACPI_STATUS(status);
243 } 242 }
244 } 243 }
245 244
246 /* Load the table into the namespace */ 245 /* Load the table into the namespace */
247 246
248 status = acpi_ex_add_table (table, parent_node, &ddb_handle); 247 status = acpi_ex_add_table(table, parent_node, &ddb_handle);
249 if (ACPI_FAILURE (status)) { 248 if (ACPI_FAILURE(status)) {
250 return_ACPI_STATUS (status); 249 return_ACPI_STATUS(status);
251 } 250 }
252 251
253 /* Parameter Data (optional) */ 252 /* Parameter Data (optional) */
@@ -255,20 +254,20 @@ acpi_ex_load_table_op (
255 if (parameter_node) { 254 if (parameter_node) {
256 /* Store the parameter data into the optional parameter object */ 255 /* Store the parameter data into the optional parameter object */
257 256
258 status = acpi_ex_store (operand[5], 257 status = acpi_ex_store(operand[5],
259 ACPI_CAST_PTR (union acpi_operand_object, parameter_node), 258 ACPI_CAST_PTR(union acpi_operand_object,
260 walk_state); 259 parameter_node),
261 if (ACPI_FAILURE (status)) { 260 walk_state);
262 (void) acpi_ex_unload_table (ddb_handle); 261 if (ACPI_FAILURE(status)) {
263 return_ACPI_STATUS (status); 262 (void)acpi_ex_unload_table(ddb_handle);
263 return_ACPI_STATUS(status);
264 } 264 }
265 } 265 }
266 266
267 *return_desc = ddb_handle; 267 *return_desc = ddb_handle;
268 return_ACPI_STATUS (status); 268 return_ACPI_STATUS(status);
269} 269}
270 270
271
272/******************************************************************************* 271/*******************************************************************************
273 * 272 *
274 * FUNCTION: acpi_ex_load_op 273 * FUNCTION: acpi_ex_load_op
@@ -285,38 +284,37 @@ acpi_ex_load_table_op (
285 ******************************************************************************/ 284 ******************************************************************************/
286 285
287acpi_status 286acpi_status
288acpi_ex_load_op ( 287acpi_ex_load_op(union acpi_operand_object *obj_desc,
289 union acpi_operand_object *obj_desc, 288 union acpi_operand_object *target,
290 union acpi_operand_object *target, 289 struct acpi_walk_state *walk_state)
291 struct acpi_walk_state *walk_state)
292{ 290{
293 acpi_status status; 291 acpi_status status;
294 union acpi_operand_object *ddb_handle; 292 union acpi_operand_object *ddb_handle;
295 union acpi_operand_object *buffer_desc = NULL; 293 union acpi_operand_object *buffer_desc = NULL;
296 struct acpi_table_header *table_ptr = NULL; 294 struct acpi_table_header *table_ptr = NULL;
297 acpi_physical_address address; 295 acpi_physical_address address;
298 struct acpi_table_header table_header; 296 struct acpi_table_header table_header;
299 u32 i; 297 u32 i;
300
301 ACPI_FUNCTION_TRACE ("ex_load_op");
302 298
299 ACPI_FUNCTION_TRACE("ex_load_op");
303 300
304 /* Object can be either an op_region or a Field */ 301 /* Object can be either an op_region or a Field */
305 302
306 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 303 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
307 case ACPI_TYPE_REGION: 304 case ACPI_TYPE_REGION:
308 305
309 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", 306 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n",
310 obj_desc, acpi_ut_get_object_type_name (obj_desc))); 307 obj_desc,
308 acpi_ut_get_object_type_name(obj_desc)));
311 309
312 /* 310 /*
313 * If the Region Address and Length have not been previously evaluated, 311 * If the Region Address and Length have not been previously evaluated,
314 * evaluate them now and save the results. 312 * evaluate them now and save the results.
315 */ 313 */
316 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 314 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
317 status = acpi_ds_get_region_arguments (obj_desc); 315 status = acpi_ds_get_region_arguments(obj_desc);
318 if (ACPI_FAILURE (status)) { 316 if (ACPI_FAILURE(status)) {
319 return_ACPI_STATUS (status); 317 return_ACPI_STATUS(status);
320 } 318 }
321 } 319 }
322 320
@@ -328,116 +326,127 @@ acpi_ex_load_op (
328 326
329 table_header.length = 0; 327 table_header.length = 0;
330 for (i = 0; i < 8; i++) { 328 for (i = 0; i < 8; i++) {
331 status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, 329 status =
332 (acpi_physical_address) (i + address), 8, 330 acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
333 ((u8 *) &table_header) + i); 331 (acpi_physical_address)
334 if (ACPI_FAILURE (status)) { 332 (i + address), 8,
335 return_ACPI_STATUS (status); 333 ((u8 *) &
334 table_header) + i);
335 if (ACPI_FAILURE(status)) {
336 return_ACPI_STATUS(status);
336 } 337 }
337 } 338 }
338 339
339 /* Sanity check the table length */ 340 /* Sanity check the table length */
340 341
341 if (table_header.length < sizeof (struct acpi_table_header)) { 342 if (table_header.length < sizeof(struct acpi_table_header)) {
342 return_ACPI_STATUS (AE_BAD_HEADER); 343 return_ACPI_STATUS(AE_BAD_HEADER);
343 } 344 }
344 345
345 /* Allocate a buffer for the entire table */ 346 /* Allocate a buffer for the entire table */
346 347
347 table_ptr = ACPI_MEM_ALLOCATE (table_header.length); 348 table_ptr = ACPI_MEM_ALLOCATE(table_header.length);
348 if (!table_ptr) { 349 if (!table_ptr) {
349 return_ACPI_STATUS (AE_NO_MEMORY); 350 return_ACPI_STATUS(AE_NO_MEMORY);
350 } 351 }
351 352
352 /* Get the entire table from the op region */ 353 /* Get the entire table from the op region */
353 354
354 for (i = 0; i < table_header.length; i++) { 355 for (i = 0; i < table_header.length; i++) {
355 status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, 356 status =
356 (acpi_physical_address) (i + address), 8, 357 acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
357 ((u8 *) table_ptr + i)); 358 (acpi_physical_address)
358 if (ACPI_FAILURE (status)) { 359 (i + address), 8,
360 ((u8 *) table_ptr +
361 i));
362 if (ACPI_FAILURE(status)) {
359 goto cleanup; 363 goto cleanup;
360 } 364 }
361 } 365 }
362 break; 366 break;
363 367
364
365 case ACPI_TYPE_LOCAL_REGION_FIELD: 368 case ACPI_TYPE_LOCAL_REGION_FIELD:
366 case ACPI_TYPE_LOCAL_BANK_FIELD: 369 case ACPI_TYPE_LOCAL_BANK_FIELD:
367 case ACPI_TYPE_LOCAL_INDEX_FIELD: 370 case ACPI_TYPE_LOCAL_INDEX_FIELD:
368 371
369 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", 372 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Field %p %s\n",
370 obj_desc, acpi_ut_get_object_type_name (obj_desc))); 373 obj_desc,
374 acpi_ut_get_object_type_name(obj_desc)));
371 375
372 /* 376 /*
373 * The length of the field must be at least as large as the table. 377 * The length of the field must be at least as large as the table.
374 * Read the entire field and thus the entire table. Buffer is 378 * Read the entire field and thus the entire table. Buffer is
375 * allocated during the read. 379 * allocated during the read.
376 */ 380 */
377 status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); 381 status =
378 if (ACPI_FAILURE (status)) { 382 acpi_ex_read_data_from_field(walk_state, obj_desc,
379 goto cleanup; 383 &buffer_desc);
384 if (ACPI_FAILURE(status)) {
385 return_ACPI_STATUS(status);
380 } 386 }
381 387
382 table_ptr = ACPI_CAST_PTR (struct acpi_table_header, 388 table_ptr = ACPI_CAST_PTR(struct acpi_table_header,
383 buffer_desc->buffer.pointer); 389 buffer_desc->buffer.pointer);
384 390
385 /* Sanity check the table length */ 391 /* All done with the buffer_desc, delete it */
386 392
387 if (table_ptr->length < sizeof (struct acpi_table_header)) { 393 buffer_desc->buffer.pointer = NULL;
388 return_ACPI_STATUS (AE_BAD_HEADER); 394 acpi_ut_remove_reference(buffer_desc);
395
396 /* Sanity check the table length */
397
398 if (table_ptr->length < sizeof(struct acpi_table_header)) {
399 status = AE_BAD_HEADER;
400 goto cleanup;
389 } 401 }
390 break; 402 break;
391 403
392
393 default: 404 default:
394 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 405 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
395 } 406 }
396 407
397 /* The table must be either an SSDT or a PSDT */ 408 /* The table must be either an SSDT or a PSDT */
398 409
399 if ((!ACPI_STRNCMP (table_ptr->signature, 410 if ((!ACPI_STRNCMP(table_ptr->signature,
400 acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, 411 acpi_gbl_table_data[ACPI_TABLE_PSDT].signature,
401 acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && 412 acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) &&
402 (!ACPI_STRNCMP (table_ptr->signature, 413 (!ACPI_STRNCMP(table_ptr->signature,
403 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, 414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
404 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { 415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
405 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
406 "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", 417 "Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
407 table_ptr->signature)); 418 table_ptr->signature));
408 status = AE_BAD_SIGNATURE; 419 status = AE_BAD_SIGNATURE;
409 goto cleanup; 420 goto cleanup;
410 } 421 }
411 422
412 /* Install the new table into the local data structures */ 423 /* Install the new table into the local data structures */
413 424
414 status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); 425 status = acpi_ex_add_table(table_ptr, acpi_gbl_root_node, &ddb_handle);
415 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
416 goto cleanup; 427 /* On error, table_ptr was deallocated above */
417 }
418
419 /* Store the ddb_handle into the Target operand */
420 428
421 status = acpi_ex_store (ddb_handle, target, walk_state); 429 return_ACPI_STATUS(status);
422 if (ACPI_FAILURE (status)) {
423 (void) acpi_ex_unload_table (ddb_handle);
424 } 430 }
425 431
426 return_ACPI_STATUS (status); 432 /* Store the ddb_handle into the Target operand */
427 433
434 status = acpi_ex_store(ddb_handle, target, walk_state);
435 if (ACPI_FAILURE(status)) {
436 (void)acpi_ex_unload_table(ddb_handle);
428 437
429cleanup: 438 /* table_ptr was deallocated above */
430 439
431 if (buffer_desc) { 440 return_ACPI_STATUS(status);
432 acpi_ut_remove_reference (buffer_desc);
433 } 441 }
434 else { 442
435 ACPI_MEM_FREE (table_ptr); 443 cleanup:
444 if (ACPI_FAILURE(status)) {
445 ACPI_MEM_FREE(table_ptr);
436 } 446 }
437 return_ACPI_STATUS (status); 447 return_ACPI_STATUS(status);
438} 448}
439 449
440
441/******************************************************************************* 450/*******************************************************************************
442 * 451 *
443 * FUNCTION: acpi_ex_unload_table 452 * FUNCTION: acpi_ex_unload_table
@@ -450,17 +459,13 @@ cleanup:
450 * 459 *
451 ******************************************************************************/ 460 ******************************************************************************/
452 461
453acpi_status 462acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
454acpi_ex_unload_table (
455 union acpi_operand_object *ddb_handle)
456{ 463{
457 acpi_status status = AE_OK; 464 acpi_status status = AE_OK;
458 union acpi_operand_object *table_desc = ddb_handle; 465 union acpi_operand_object *table_desc = ddb_handle;
459 struct acpi_table_desc *table_info; 466 struct acpi_table_desc *table_info;
460
461
462 ACPI_FUNCTION_TRACE ("ex_unload_table");
463 467
468 ACPI_FUNCTION_TRACE("ex_unload_table");
464 469
465 /* 470 /*
466 * Validate the handle 471 * Validate the handle
@@ -469,28 +474,28 @@ acpi_ex_unload_table (
469 * validated here. 474 * validated here.
470 */ 475 */
471 if ((!ddb_handle) || 476 if ((!ddb_handle) ||
472 (ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) || 477 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
473 (ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { 478 (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
474 return_ACPI_STATUS (AE_BAD_PARAMETER); 479 return_ACPI_STATUS(AE_BAD_PARAMETER);
475 } 480 }
476 481
477 /* Get the actual table descriptor from the ddb_handle */ 482 /* Get the actual table descriptor from the ddb_handle */
478 483
479 table_info = (struct acpi_table_desc *) table_desc->reference.object; 484 table_info = (struct acpi_table_desc *)table_desc->reference.object;
480 485
481 /* 486 /*
482 * Delete the entire namespace under this table Node 487 * Delete the entire namespace under this table Node
483 * (Offset contains the table_id) 488 * (Offset contains the table_id)
484 */ 489 */
485 acpi_ns_delete_namespace_by_owner (table_info->table_id); 490 acpi_ns_delete_namespace_by_owner(table_info->owner_id);
491 acpi_ut_release_owner_id(&table_info->owner_id);
486 492
487 /* Delete the table itself */ 493 /* Delete the table itself */
488 494
489 (void) acpi_tb_uninstall_table (table_info->installed_desc); 495 (void)acpi_tb_uninstall_table(table_info->installed_desc);
490 496
491 /* Delete the table descriptor (ddb_handle) */ 497 /* Delete the table descriptor (ddb_handle) */
492 498
493 acpi_ut_remove_reference (table_desc); 499 acpi_ut_remove_reference(table_desc);
494 return_ACPI_STATUS (status); 500 return_ACPI_STATUS(status);
495} 501}
496
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 97856c48bd74..04e5194989a6 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -41,24 +41,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48 47
49
50#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exconvrt") 49ACPI_MODULE_NAME("exconvrt")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static u32 52static u32
56acpi_ex_convert_to_ascii ( 53acpi_ex_convert_to_ascii(acpi_integer integer,
57 acpi_integer integer, 54 u16 base, u8 * string, u8 max_length);
58 u16 base,
59 u8 *string,
60 u8 max_length);
61
62 55
63/******************************************************************************* 56/*******************************************************************************
64 * 57 *
@@ -76,29 +69,25 @@ acpi_ex_convert_to_ascii (
76 ******************************************************************************/ 69 ******************************************************************************/
77 70
78acpi_status 71acpi_status
79acpi_ex_convert_to_integer ( 72acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
80 union acpi_operand_object *obj_desc, 73 union acpi_operand_object **result_desc, u32 flags)
81 union acpi_operand_object **result_desc,
82 u32 flags)
83{ 74{
84 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
85 u8 *pointer; 76 u8 *pointer;
86 acpi_integer result; 77 acpi_integer result;
87 u32 i; 78 u32 i;
88 u32 count; 79 u32 count;
89 acpi_status status; 80 acpi_status status;
90
91 81
92 ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_integer", obj_desc); 82 ACPI_FUNCTION_TRACE_PTR("ex_convert_to_integer", obj_desc);
93 83
94 84 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
95 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
96 case ACPI_TYPE_INTEGER: 85 case ACPI_TYPE_INTEGER:
97 86
98 /* No conversion necessary */ 87 /* No conversion necessary */
99 88
100 *result_desc = obj_desc; 89 *result_desc = obj_desc;
101 return_ACPI_STATUS (AE_OK); 90 return_ACPI_STATUS(AE_OK);
102 91
103 case ACPI_TYPE_BUFFER: 92 case ACPI_TYPE_BUFFER:
104 case ACPI_TYPE_STRING: 93 case ACPI_TYPE_STRING:
@@ -106,11 +95,11 @@ acpi_ex_convert_to_integer (
106 /* Note: Takes advantage of common buffer/string fields */ 95 /* Note: Takes advantage of common buffer/string fields */
107 96
108 pointer = obj_desc->buffer.pointer; 97 pointer = obj_desc->buffer.pointer;
109 count = obj_desc->buffer.length; 98 count = obj_desc->buffer.length;
110 break; 99 break;
111 100
112 default: 101 default:
113 return_ACPI_STATUS (AE_TYPE); 102 return_ACPI_STATUS(AE_TYPE);
114 } 103 }
115 104
116 /* 105 /*
@@ -126,7 +115,7 @@ acpi_ex_convert_to_integer (
126 115
127 /* String conversion is different than Buffer conversion */ 116 /* String conversion is different than Buffer conversion */
128 117
129 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 118 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
130 case ACPI_TYPE_STRING: 119 case ACPI_TYPE_STRING:
131 120
132 /* 121 /*
@@ -135,19 +124,18 @@ acpi_ex_convert_to_integer (
135 * of ACPI 3.0) is that the to_integer() operator allows both decimal 124 * of ACPI 3.0) is that the to_integer() operator allows both decimal
136 * and hexadecimal strings (hex prefixed with "0x"). 125 * and hexadecimal strings (hex prefixed with "0x").
137 */ 126 */
138 status = acpi_ut_strtoul64 ((char *) pointer, flags, &result); 127 status = acpi_ut_strtoul64((char *)pointer, flags, &result);
139 if (ACPI_FAILURE (status)) { 128 if (ACPI_FAILURE(status)) {
140 return_ACPI_STATUS (status); 129 return_ACPI_STATUS(status);
141 } 130 }
142 break; 131 break;
143 132
144
145 case ACPI_TYPE_BUFFER: 133 case ACPI_TYPE_BUFFER:
146 134
147 /* Check for zero-length buffer */ 135 /* Check for zero-length buffer */
148 136
149 if (!count) { 137 if (!count) {
150 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); 138 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
151 } 139 }
152 140
153 /* Transfer no more than an integer's worth of data */ 141 /* Transfer no more than an integer's worth of data */
@@ -170,7 +158,6 @@ acpi_ex_convert_to_integer (
170 } 158 }
171 break; 159 break;
172 160
173
174 default: 161 default:
175 /* No other types can get here */ 162 /* No other types can get here */
176 break; 163 break;
@@ -178,20 +165,19 @@ acpi_ex_convert_to_integer (
178 165
179 /* Create a new integer */ 166 /* Create a new integer */
180 167
181 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 168 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
182 if (!return_desc) { 169 if (!return_desc) {
183 return_ACPI_STATUS (AE_NO_MEMORY); 170 return_ACPI_STATUS(AE_NO_MEMORY);
184 } 171 }
185 172
186 /* Save the Result */ 173 /* Save the Result */
187 174
188 return_desc->integer.value = result; 175 return_desc->integer.value = result;
189 acpi_ex_truncate_for32bit_table (return_desc); 176 acpi_ex_truncate_for32bit_table(return_desc);
190 *result_desc = return_desc; 177 *result_desc = return_desc;
191 return_ACPI_STATUS (AE_OK); 178 return_ACPI_STATUS(AE_OK);
192} 179}
193 180
194
195/******************************************************************************* 181/*******************************************************************************
196 * 182 *
197 * FUNCTION: acpi_ex_convert_to_buffer 183 * FUNCTION: acpi_ex_convert_to_buffer
@@ -207,25 +193,21 @@ acpi_ex_convert_to_integer (
207 ******************************************************************************/ 193 ******************************************************************************/
208 194
209acpi_status 195acpi_status
210acpi_ex_convert_to_buffer ( 196acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
211 union acpi_operand_object *obj_desc, 197 union acpi_operand_object **result_desc)
212 union acpi_operand_object **result_desc)
213{ 198{
214 union acpi_operand_object *return_desc; 199 union acpi_operand_object *return_desc;
215 u8 *new_buf; 200 u8 *new_buf;
216 201
202 ACPI_FUNCTION_TRACE_PTR("ex_convert_to_buffer", obj_desc);
217 203
218 ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_buffer", obj_desc); 204 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
219
220
221 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
222 case ACPI_TYPE_BUFFER: 205 case ACPI_TYPE_BUFFER:
223 206
224 /* No conversion necessary */ 207 /* No conversion necessary */
225 208
226 *result_desc = obj_desc; 209 *result_desc = obj_desc;
227 return_ACPI_STATUS (AE_OK); 210 return_ACPI_STATUS(AE_OK);
228
229 211
230 case ACPI_TYPE_INTEGER: 212 case ACPI_TYPE_INTEGER:
231 213
@@ -233,20 +215,20 @@ acpi_ex_convert_to_buffer (
233 * Create a new Buffer object. 215 * Create a new Buffer object.
234 * Need enough space for one integer 216 * Need enough space for one integer
235 */ 217 */
236 return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width); 218 return_desc =
219 acpi_ut_create_buffer_object(acpi_gbl_integer_byte_width);
237 if (!return_desc) { 220 if (!return_desc) {
238 return_ACPI_STATUS (AE_NO_MEMORY); 221 return_ACPI_STATUS(AE_NO_MEMORY);
239 } 222 }
240 223
241 /* Copy the integer to the buffer, LSB first */ 224 /* Copy the integer to the buffer, LSB first */
242 225
243 new_buf = return_desc->buffer.pointer; 226 new_buf = return_desc->buffer.pointer;
244 ACPI_MEMCPY (new_buf, 227 ACPI_MEMCPY(new_buf,
245 &obj_desc->integer.value, 228 &obj_desc->integer.value,
246 acpi_gbl_integer_byte_width); 229 acpi_gbl_integer_byte_width);
247 break; 230 break;
248 231
249
250 case ACPI_TYPE_STRING: 232 case ACPI_TYPE_STRING:
251 233
252 /* 234 /*
@@ -258,32 +240,31 @@ acpi_ex_convert_to_buffer (
258 * ASL/AML code that depends on the null being transferred to the new 240 * ASL/AML code that depends on the null being transferred to the new
259 * buffer. 241 * buffer.
260 */ 242 */
261 return_desc = acpi_ut_create_buffer_object ( 243 return_desc = acpi_ut_create_buffer_object((acpi_size)
262 (acpi_size) obj_desc->string.length + 1); 244 obj_desc->string.
245 length + 1);
263 if (!return_desc) { 246 if (!return_desc) {
264 return_ACPI_STATUS (AE_NO_MEMORY); 247 return_ACPI_STATUS(AE_NO_MEMORY);
265 } 248 }
266 249
267 /* Copy the string to the buffer */ 250 /* Copy the string to the buffer */
268 251
269 new_buf = return_desc->buffer.pointer; 252 new_buf = return_desc->buffer.pointer;
270 ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer, 253 ACPI_STRNCPY((char *)new_buf, (char *)obj_desc->string.pointer,
271 obj_desc->string.length); 254 obj_desc->string.length);
272 break; 255 break;
273 256
274
275 default: 257 default:
276 return_ACPI_STATUS (AE_TYPE); 258 return_ACPI_STATUS(AE_TYPE);
277 } 259 }
278 260
279 /* Mark buffer initialized */ 261 /* Mark buffer initialized */
280 262
281 return_desc->common.flags |= AOPOBJ_DATA_VALID; 263 return_desc->common.flags |= AOPOBJ_DATA_VALID;
282 *result_desc = return_desc; 264 *result_desc = return_desc;
283 return_ACPI_STATUS (AE_OK); 265 return_ACPI_STATUS(AE_OK);
284} 266}
285 267
286
287/******************************************************************************* 268/*******************************************************************************
288 * 269 *
289 * FUNCTION: acpi_ex_convert_to_ascii 270 * FUNCTION: acpi_ex_convert_to_ascii
@@ -300,24 +281,19 @@ acpi_ex_convert_to_buffer (
300 ******************************************************************************/ 281 ******************************************************************************/
301 282
302static u32 283static u32
303acpi_ex_convert_to_ascii ( 284acpi_ex_convert_to_ascii(acpi_integer integer,
304 acpi_integer integer, 285 u16 base, u8 * string, u8 data_width)
305 u16 base,
306 u8 *string,
307 u8 data_width)
308{ 286{
309 acpi_integer digit; 287 acpi_integer digit;
310 acpi_native_uint i; 288 acpi_native_uint i;
311 acpi_native_uint j; 289 acpi_native_uint j;
312 acpi_native_uint k = 0; 290 acpi_native_uint k = 0;
313 acpi_native_uint hex_length; 291 acpi_native_uint hex_length;
314 acpi_native_uint decimal_length; 292 acpi_native_uint decimal_length;
315 u32 remainder; 293 u32 remainder;
316 u8 supress_zeros; 294 u8 supress_zeros;
317
318
319 ACPI_FUNCTION_ENTRY ();
320 295
296 ACPI_FUNCTION_ENTRY();
321 297
322 switch (base) { 298 switch (base) {
323 case 10: 299 case 10:
@@ -339,7 +315,7 @@ acpi_ex_convert_to_ascii (
339 break; 315 break;
340 } 316 }
341 317
342 supress_zeros = TRUE; /* No leading zeros */ 318 supress_zeros = TRUE; /* No leading zeros */
343 remainder = 0; 319 remainder = 0;
344 320
345 for (i = decimal_length; i > 0; i--) { 321 for (i = decimal_length; i > 0; i--) {
@@ -347,7 +323,8 @@ acpi_ex_convert_to_ascii (
347 323
348 digit = integer; 324 digit = integer;
349 for (j = 0; j < i; j++) { 325 for (j = 0; j < i; j++) {
350 (void) acpi_ut_short_divide (digit, 10, &digit, &remainder); 326 (void)acpi_ut_short_divide(digit, 10, &digit,
327 &remainder);
351 } 328 }
352 329
353 /* Handle leading zeros */ 330 /* Handle leading zeros */
@@ -367,11 +344,13 @@ acpi_ex_convert_to_ascii (
367 344
368 /* hex_length: 2 ascii hex chars per data byte */ 345 /* hex_length: 2 ascii hex chars per data byte */
369 346
370 hex_length = ACPI_MUL_2 (data_width); 347 hex_length = (acpi_native_uint) ACPI_MUL_2(data_width);
371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { 348 for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) {
372 /* Get one hex digit, most significant digits first */ 349 /* Get one hex digit, most significant digits first */
373 350
374 string[k] = (u8) acpi_ut_hex_to_ascii_char (integer, ACPI_MUL_4 (j)); 351 string[k] =
352 (u8) acpi_ut_hex_to_ascii_char(integer,
353 ACPI_MUL_4(j));
375 k++; 354 k++;
376 } 355 }
377 break; 356 break;
@@ -387,15 +366,14 @@ acpi_ex_convert_to_ascii (
387 * Finally, null terminate the string and return the length 366 * Finally, null terminate the string and return the length
388 */ 367 */
389 if (!k) { 368 if (!k) {
390 string [0] = ACPI_ASCII_ZERO; 369 string[0] = ACPI_ASCII_ZERO;
391 k = 1; 370 k = 1;
392 } 371 }
393 372
394 string [k] = 0; 373 string[k] = 0;
395 return ((u32) k); 374 return ((u32) k);
396} 375}
397 376
398
399/******************************************************************************* 377/*******************************************************************************
400 * 378 *
401 * FUNCTION: acpi_ex_convert_to_string 379 * FUNCTION: acpi_ex_convert_to_string
@@ -412,30 +390,25 @@ acpi_ex_convert_to_ascii (
412 ******************************************************************************/ 390 ******************************************************************************/
413 391
414acpi_status 392acpi_status
415acpi_ex_convert_to_string ( 393acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
416 union acpi_operand_object *obj_desc, 394 union acpi_operand_object ** result_desc, u32 type)
417 union acpi_operand_object **result_desc,
418 u32 type)
419{ 395{
420 union acpi_operand_object *return_desc; 396 union acpi_operand_object *return_desc;
421 u8 *new_buf; 397 u8 *new_buf;
422 u32 i; 398 u32 i;
423 u32 string_length = 0; 399 u32 string_length = 0;
424 u16 base = 16; 400 u16 base = 16;
425 u8 separator = ','; 401 u8 separator = ',';
426 402
403 ACPI_FUNCTION_TRACE_PTR("ex_convert_to_string", obj_desc);
427 404
428 ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc); 405 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
429
430
431 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
432 case ACPI_TYPE_STRING: 406 case ACPI_TYPE_STRING:
433 407
434 /* No conversion necessary */ 408 /* No conversion necessary */
435 409
436 *result_desc = obj_desc; 410 *result_desc = obj_desc;
437 return_ACPI_STATUS (AE_OK); 411 return_ACPI_STATUS(AE_OK);
438
439 412
440 case ACPI_TYPE_INTEGER: 413 case ACPI_TYPE_INTEGER:
441 414
@@ -452,7 +425,7 @@ acpi_ex_convert_to_string (
452 425
453 /* Two hex string characters for each integer byte */ 426 /* Two hex string characters for each integer byte */
454 427
455 string_length = ACPI_MUL_2 (acpi_gbl_integer_byte_width); 428 string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width);
456 break; 429 break;
457 } 430 }
458 431
@@ -460,31 +433,33 @@ acpi_ex_convert_to_string (
460 * Create a new String 433 * Create a new String
461 * Need enough space for one ASCII integer (plus null terminator) 434 * Need enough space for one ASCII integer (plus null terminator)
462 */ 435 */
463 return_desc = acpi_ut_create_string_object ((acpi_size) string_length); 436 return_desc =
437 acpi_ut_create_string_object((acpi_size) string_length);
464 if (!return_desc) { 438 if (!return_desc) {
465 return_ACPI_STATUS (AE_NO_MEMORY); 439 return_ACPI_STATUS(AE_NO_MEMORY);
466 } 440 }
467 441
468 new_buf = return_desc->buffer.pointer; 442 new_buf = return_desc->buffer.pointer;
469 443
470 /* Convert integer to string */ 444 /* Convert integer to string */
471 445
472 string_length = acpi_ex_convert_to_ascii (obj_desc->integer.value, base, 446 string_length =
473 new_buf, acpi_gbl_integer_byte_width); 447 acpi_ex_convert_to_ascii(obj_desc->integer.value, base,
448 new_buf,
449 acpi_gbl_integer_byte_width);
474 450
475 /* Null terminate at the correct place */ 451 /* Null terminate at the correct place */
476 452
477 return_desc->string.length = string_length; 453 return_desc->string.length = string_length;
478 new_buf [string_length] = 0; 454 new_buf[string_length] = 0;
479 break; 455 break;
480 456
481
482 case ACPI_TYPE_BUFFER: 457 case ACPI_TYPE_BUFFER:
483 458
484 /* Setup string length, base, and separator */ 459 /* Setup string length, base, and separator */
485 460
486 switch (type) { 461 switch (type) {
487 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ 462 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
488 /* 463 /*
489 * From ACPI: "If Data is a buffer, it is converted to a string of 464 * From ACPI: "If Data is a buffer, it is converted to a string of
490 * decimal values separated by commas." 465 * decimal values separated by commas."
@@ -498,11 +473,9 @@ acpi_ex_convert_to_string (
498 for (i = 0; i < obj_desc->buffer.length; i++) { 473 for (i = 0; i < obj_desc->buffer.length; i++) {
499 if (obj_desc->buffer.pointer[i] >= 100) { 474 if (obj_desc->buffer.pointer[i] >= 100) {
500 string_length += 4; 475 string_length += 4;
501 } 476 } else if (obj_desc->buffer.pointer[i] >= 10) {
502 else if (obj_desc->buffer.pointer[i] >= 10) {
503 string_length += 3; 477 string_length += 3;
504 } 478 } else {
505 else {
506 string_length += 2; 479 string_length += 2;
507 } 480 }
508 } 481 }
@@ -518,7 +491,7 @@ acpi_ex_convert_to_string (
518 string_length = (obj_desc->buffer.length * 3); 491 string_length = (obj_desc->buffer.length * 3);
519 break; 492 break;
520 493
521 case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ 494 case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
522 /* 495 /*
523 * From ACPI: "If Data is a buffer, it is converted to a string of 496 * From ACPI: "If Data is a buffer, it is converted to a string of
524 * hexadecimal values separated by commas." 497 * hexadecimal values separated by commas."
@@ -527,7 +500,7 @@ acpi_ex_convert_to_string (
527 break; 500 break;
528 501
529 default: 502 default:
530 return_ACPI_STATUS (AE_BAD_PARAMETER); 503 return_ACPI_STATUS(AE_BAD_PARAMETER);
531 } 504 }
532 505
533 /* 506 /*
@@ -535,15 +508,16 @@ acpi_ex_convert_to_string (
535 * (-1 because of extra separator included in string_length from above) 508 * (-1 because of extra separator included in string_length from above)
536 */ 509 */
537 string_length--; 510 string_length--;
538 if (string_length > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ { 511 if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */
539 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 512 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
540 } 513 }
541 514
542 /* Create a new string object and string buffer */ 515 /* Create a new string object and string buffer */
543 516
544 return_desc = acpi_ut_create_string_object ((acpi_size) string_length); 517 return_desc =
518 acpi_ut_create_string_object((acpi_size) string_length);
545 if (!return_desc) { 519 if (!return_desc) {
546 return_ACPI_STATUS (AE_NO_MEMORY); 520 return_ACPI_STATUS(AE_NO_MEMORY);
547 } 521 }
548 522
549 new_buf = return_desc->buffer.pointer; 523 new_buf = return_desc->buffer.pointer;
@@ -553,10 +527,11 @@ acpi_ex_convert_to_string (
553 * (separated by commas or spaces) 527 * (separated by commas or spaces)
554 */ 528 */
555 for (i = 0; i < obj_desc->buffer.length; i++) { 529 for (i = 0; i < obj_desc->buffer.length; i++) {
556 new_buf += acpi_ex_convert_to_ascii ( 530 new_buf += acpi_ex_convert_to_ascii((acpi_integer)
557 (acpi_integer) obj_desc->buffer.pointer[i], base, 531 obj_desc->buffer.
558 new_buf, 1); 532 pointer[i], base,
559 *new_buf++ = separator; /* each separated by a comma or space */ 533 new_buf, 1);
534 *new_buf++ = separator; /* each separated by a comma or space */
560 } 535 }
561 536
562 /* 537 /*
@@ -568,14 +543,13 @@ acpi_ex_convert_to_string (
568 break; 543 break;
569 544
570 default: 545 default:
571 return_ACPI_STATUS (AE_TYPE); 546 return_ACPI_STATUS(AE_TYPE);
572 } 547 }
573 548
574 *result_desc = return_desc; 549 *result_desc = return_desc;
575 return_ACPI_STATUS (AE_OK); 550 return_ACPI_STATUS(AE_OK);
576} 551}
577 552
578
579/******************************************************************************* 553/*******************************************************************************
580 * 554 *
581 * FUNCTION: acpi_ex_convert_to_target_type 555 * FUNCTION: acpi_ex_convert_to_target_type
@@ -592,17 +566,14 @@ acpi_ex_convert_to_string (
592 ******************************************************************************/ 566 ******************************************************************************/
593 567
594acpi_status 568acpi_status
595acpi_ex_convert_to_target_type ( 569acpi_ex_convert_to_target_type(acpi_object_type destination_type,
596 acpi_object_type destination_type, 570 union acpi_operand_object *source_desc,
597 union acpi_operand_object *source_desc, 571 union acpi_operand_object **result_desc,
598 union acpi_operand_object **result_desc, 572 struct acpi_walk_state *walk_state)
599 struct acpi_walk_state *walk_state)
600{ 573{
601 acpi_status status = AE_OK; 574 acpi_status status = AE_OK;
602
603
604 ACPI_FUNCTION_TRACE ("ex_convert_to_target_type");
605 575
576 ACPI_FUNCTION_TRACE("ex_convert_to_target_type");
606 577
607 /* Default behavior */ 578 /* Default behavior */
608 579
@@ -612,10 +583,10 @@ acpi_ex_convert_to_target_type (
612 * If required by the target, 583 * If required by the target,
613 * perform implicit conversion on the source before we store it. 584 * perform implicit conversion on the source before we store it.
614 */ 585 */
615 switch (GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)) { 586 switch (GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args)) {
616 case ARGI_SIMPLE_TARGET: 587 case ARGI_SIMPLE_TARGET:
617 case ARGI_FIXED_TARGET: 588 case ARGI_FIXED_TARGET:
618 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ 589 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
619 590
620 switch (destination_type) { 591 switch (destination_type) {
621 case ACPI_TYPE_LOCAL_REGION_FIELD: 592 case ACPI_TYPE_LOCAL_REGION_FIELD:
@@ -627,17 +598,19 @@ acpi_ex_convert_to_target_type (
627 default: 598 default:
628 /* No conversion allowed for these types */ 599 /* No conversion allowed for these types */
629 600
630 if (destination_type != ACPI_GET_OBJECT_TYPE (source_desc)) { 601 if (destination_type !=
631 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 602 ACPI_GET_OBJECT_TYPE(source_desc)) {
632 "Explicit operator, will store (%s) over existing type (%s)\n", 603 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
633 acpi_ut_get_object_type_name (source_desc), 604 "Explicit operator, will store (%s) over existing type (%s)\n",
634 acpi_ut_get_type_name (destination_type))); 605 acpi_ut_get_object_type_name
606 (source_desc),
607 acpi_ut_get_type_name
608 (destination_type)));
635 status = AE_TYPE; 609 status = AE_TYPE;
636 } 610 }
637 } 611 }
638 break; 612 break;
639 613
640
641 case ARGI_TARGETREF: 614 case ARGI_TARGETREF:
642 615
643 switch (destination_type) { 616 switch (destination_type) {
@@ -649,55 +622,55 @@ acpi_ex_convert_to_target_type (
649 * These types require an Integer operand. We can convert 622 * These types require an Integer operand. We can convert
650 * a Buffer or a String to an Integer if necessary. 623 * a Buffer or a String to an Integer if necessary.
651 */ 624 */
652 status = acpi_ex_convert_to_integer (source_desc, result_desc, 625 status =
653 16); 626 acpi_ex_convert_to_integer(source_desc, result_desc,
627 16);
654 break; 628 break;
655 629
656
657 case ACPI_TYPE_STRING: 630 case ACPI_TYPE_STRING:
658 /* 631 /*
659 * The operand must be a String. We can convert an 632 * The operand must be a String. We can convert an
660 * Integer or Buffer if necessary 633 * Integer or Buffer if necessary
661 */ 634 */
662 status = acpi_ex_convert_to_string (source_desc, result_desc, 635 status =
663 ACPI_IMPLICIT_CONVERT_HEX); 636 acpi_ex_convert_to_string(source_desc, result_desc,
637 ACPI_IMPLICIT_CONVERT_HEX);
664 break; 638 break;
665 639
666
667 case ACPI_TYPE_BUFFER: 640 case ACPI_TYPE_BUFFER:
668 /* 641 /*
669 * The operand must be a Buffer. We can convert an 642 * The operand must be a Buffer. We can convert an
670 * Integer or String if necessary 643 * Integer or String if necessary
671 */ 644 */
672 status = acpi_ex_convert_to_buffer (source_desc, result_desc); 645 status =
646 acpi_ex_convert_to_buffer(source_desc, result_desc);
673 break; 647 break;
674 648
675
676 default: 649 default:
677 ACPI_REPORT_ERROR (("Bad destination type during conversion: %X\n", 650 ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type));
678 destination_type));
679 status = AE_AML_INTERNAL; 651 status = AE_AML_INTERNAL;
680 break; 652 break;
681 } 653 }
682 break; 654 break;
683 655
684
685 case ARGI_REFERENCE: 656 case ARGI_REFERENCE:
686 /* 657 /*
687 * create_xxxx_field cases - we are storing the field object into the name 658 * create_xxxx_field cases - we are storing the field object into the name
688 */ 659 */
689 break; 660 break;
690 661
691
692 default: 662 default:
693 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 663 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
694 "Unknown Target type ID 0x%X Op %s dest_type %s\n", 664 "Unknown Target type ID 0x%X Op %s dest_type %s\n",
695 GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args), 665 GET_CURRENT_ARG_TYPE(walk_state->op_info->
696 walk_state->op_info->name, acpi_ut_get_type_name (destination_type))); 666 runtime_args),
697 667 walk_state->op_info->name,
698 ACPI_REPORT_ERROR (("Bad Target Type (ARGI): %X\n", 668 acpi_ut_get_type_name(destination_type)));
699 GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args))) 669
700 status = AE_AML_INTERNAL; 670 ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n",
671 GET_CURRENT_ARG_TYPE(walk_state->op_info->
672 runtime_args)))
673 status = AE_AML_INTERNAL;
701 } 674 }
702 675
703 /* 676 /*
@@ -710,7 +683,5 @@ acpi_ex_convert_to_target_type (
710 status = AE_OK; 683 status = AE_OK;
711 } 684 }
712 685
713 return_ACPI_STATUS (status); 686 return_ACPI_STATUS(status);
714} 687}
715
716
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 812cdcb2e370..91c49188fb07 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -49,10 +48,8 @@
49#include <acpi/acevents.h> 48#include <acpi/acevents.h>
50#include <acpi/actables.h> 49#include <acpi/actables.h>
51 50
52
53#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
54 ACPI_MODULE_NAME ("excreate") 52ACPI_MODULE_NAME("excreate")
55
56 53
57#ifndef ACPI_NO_METHOD_EXECUTION 54#ifndef ACPI_NO_METHOD_EXECUTION
58/******************************************************************************* 55/*******************************************************************************
@@ -66,33 +63,30 @@
66 * DESCRIPTION: Create a new named alias 63 * DESCRIPTION: Create a new named alias
67 * 64 *
68 ******************************************************************************/ 65 ******************************************************************************/
69 66acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
70acpi_status
71acpi_ex_create_alias (
72 struct acpi_walk_state *walk_state)
73{ 67{
74 struct acpi_namespace_node *target_node; 68 struct acpi_namespace_node *target_node;
75 struct acpi_namespace_node *alias_node; 69 struct acpi_namespace_node *alias_node;
76 acpi_status status = AE_OK; 70 acpi_status status = AE_OK;
77
78
79 ACPI_FUNCTION_TRACE ("ex_create_alias");
80 71
72 ACPI_FUNCTION_TRACE("ex_create_alias");
81 73
82 /* Get the source/alias operands (both namespace nodes) */ 74 /* Get the source/alias operands (both namespace nodes) */
83 75
84 alias_node = (struct acpi_namespace_node *) walk_state->operands[0]; 76 alias_node = (struct acpi_namespace_node *)walk_state->operands[0];
85 target_node = (struct acpi_namespace_node *) walk_state->operands[1]; 77 target_node = (struct acpi_namespace_node *)walk_state->operands[1];
86 78
87 if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) || 79 if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) ||
88 (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { 80 (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
89 /* 81 /*
90 * Dereference an existing alias so that we don't create a chain 82 * Dereference an existing alias so that we don't create a chain
91 * of aliases. With this code, we guarantee that an alias is 83 * of aliases. With this code, we guarantee that an alias is
92 * always exactly one level of indirection away from the 84 * always exactly one level of indirection away from the
93 * actual aliased name. 85 * actual aliased name.
94 */ 86 */
95 target_node = ACPI_CAST_PTR (struct acpi_namespace_node, target_node->object); 87 target_node =
88 ACPI_CAST_PTR(struct acpi_namespace_node,
89 target_node->object);
96 } 90 }
97 91
98 /* 92 /*
@@ -115,7 +109,8 @@ acpi_ex_create_alias (
115 * types, the object can change dynamically via a Store. 109 * types, the object can change dynamically via a Store.
116 */ 110 */
117 alias_node->type = ACPI_TYPE_LOCAL_ALIAS; 111 alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
118 alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node); 112 alias_node->object =
113 ACPI_CAST_PTR(union acpi_operand_object, target_node);
119 break; 114 break;
120 115
121 case ACPI_TYPE_METHOD: 116 case ACPI_TYPE_METHOD:
@@ -126,7 +121,8 @@ acpi_ex_create_alias (
126 * types, the object can change dynamically via a Store. 121 * types, the object can change dynamically via a Store.
127 */ 122 */
128 alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 123 alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
129 alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node); 124 alias_node->object =
125 ACPI_CAST_PTR(union acpi_operand_object, target_node);
130 break; 126 break;
131 127
132 default: 128 default:
@@ -139,17 +135,18 @@ acpi_ex_create_alias (
139 * additional reference to prevent deletion out from under either the 135 * additional reference to prevent deletion out from under either the
140 * target node or the alias Node 136 * target node or the alias Node
141 */ 137 */
142 status = acpi_ns_attach_object (alias_node, 138 status = acpi_ns_attach_object(alias_node,
143 acpi_ns_get_attached_object (target_node), target_node->type); 139 acpi_ns_get_attached_object
140 (target_node),
141 target_node->type);
144 break; 142 break;
145 } 143 }
146 144
147 /* Since both operands are Nodes, we don't need to delete them */ 145 /* Since both operands are Nodes, we don't need to delete them */
148 146
149 return_ACPI_STATUS (status); 147 return_ACPI_STATUS(status);
150} 148}
151 149
152
153/******************************************************************************* 150/*******************************************************************************
154 * 151 *
155 * FUNCTION: acpi_ex_create_event 152 * FUNCTION: acpi_ex_create_event
@@ -162,18 +159,14 @@ acpi_ex_create_alias (
162 * 159 *
163 ******************************************************************************/ 160 ******************************************************************************/
164 161
165acpi_status 162acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
166acpi_ex_create_event (
167 struct acpi_walk_state *walk_state)
168{ 163{
169 acpi_status status; 164 acpi_status status;
170 union acpi_operand_object *obj_desc; 165 union acpi_operand_object *obj_desc;
171
172
173 ACPI_FUNCTION_TRACE ("ex_create_event");
174 166
167 ACPI_FUNCTION_TRACE("ex_create_event");
175 168
176 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_EVENT); 169 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT);
177 if (!obj_desc) { 170 if (!obj_desc) {
178 status = AE_NO_MEMORY; 171 status = AE_NO_MEMORY;
179 goto cleanup; 172 goto cleanup;
@@ -183,27 +176,27 @@ acpi_ex_create_event (
183 * Create the actual OS semaphore, with zero initial units -- meaning 176 * Create the actual OS semaphore, with zero initial units -- meaning
184 * that the event is created in an unsignalled state 177 * that the event is created in an unsignalled state
185 */ 178 */
186 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, 179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
187 &obj_desc->event.semaphore); 180 &obj_desc->event.semaphore);
188 if (ACPI_FAILURE (status)) { 181 if (ACPI_FAILURE(status)) {
189 goto cleanup; 182 goto cleanup;
190 } 183 }
191 184
192 /* Attach object to the Node */ 185 /* Attach object to the Node */
193 186
194 status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0], 187 status =
195 obj_desc, ACPI_TYPE_EVENT); 188 acpi_ns_attach_object((struct acpi_namespace_node *)walk_state->
189 operands[0], obj_desc, ACPI_TYPE_EVENT);
196 190
197cleanup: 191 cleanup:
198 /* 192 /*
199 * Remove local reference to the object (on error, will cause deletion 193 * Remove local reference to the object (on error, will cause deletion
200 * of both object and semaphore if present.) 194 * of both object and semaphore if present.)
201 */ 195 */
202 acpi_ut_remove_reference (obj_desc); 196 acpi_ut_remove_reference(obj_desc);
203 return_ACPI_STATUS (status); 197 return_ACPI_STATUS(status);
204} 198}
205 199
206
207/******************************************************************************* 200/*******************************************************************************
208 * 201 *
209 * FUNCTION: acpi_ex_create_mutex 202 * FUNCTION: acpi_ex_create_mutex
@@ -218,20 +211,16 @@ cleanup:
218 * 211 *
219 ******************************************************************************/ 212 ******************************************************************************/
220 213
221acpi_status 214acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
222acpi_ex_create_mutex (
223 struct acpi_walk_state *walk_state)
224{ 215{
225 acpi_status status = AE_OK; 216 acpi_status status = AE_OK;
226 union acpi_operand_object *obj_desc; 217 union acpi_operand_object *obj_desc;
227
228
229 ACPI_FUNCTION_TRACE_PTR ("ex_create_mutex", ACPI_WALK_OPERANDS);
230 218
219 ACPI_FUNCTION_TRACE_PTR("ex_create_mutex", ACPI_WALK_OPERANDS);
231 220
232 /* Create the new mutex object */ 221 /* Create the new mutex object */
233 222
234 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_MUTEX); 223 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
235 if (!obj_desc) { 224 if (!obj_desc) {
236 status = AE_NO_MEMORY; 225 status = AE_NO_MEMORY;
237 goto cleanup; 226 goto cleanup;
@@ -242,30 +231,30 @@ acpi_ex_create_mutex (
242 * One unit max to make it a mutex, with one initial unit to allow 231 * One unit max to make it a mutex, with one initial unit to allow
243 * the mutex to be acquired. 232 * the mutex to be acquired.
244 */ 233 */
245 status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore); 234 status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
246 if (ACPI_FAILURE (status)) { 235 if (ACPI_FAILURE(status)) {
247 goto cleanup; 236 goto cleanup;
248 } 237 }
249 238
250 /* Init object and attach to NS node */ 239 /* Init object and attach to NS node */
251 240
252 obj_desc->mutex.sync_level = (u8) walk_state->operands[1]->integer.value; 241 obj_desc->mutex.sync_level =
253 obj_desc->mutex.node = (struct acpi_namespace_node *) walk_state->operands[0]; 242 (u8) walk_state->operands[1]->integer.value;
254 243 obj_desc->mutex.node =
255 status = acpi_ns_attach_object (obj_desc->mutex.node, 244 (struct acpi_namespace_node *)walk_state->operands[0];
256 obj_desc, ACPI_TYPE_MUTEX);
257 245
246 status = acpi_ns_attach_object(obj_desc->mutex.node,
247 obj_desc, ACPI_TYPE_MUTEX);
258 248
259cleanup: 249 cleanup:
260 /* 250 /*
261 * Remove local reference to the object (on error, will cause deletion 251 * Remove local reference to the object (on error, will cause deletion
262 * of both object and semaphore if present.) 252 * of both object and semaphore if present.)
263 */ 253 */
264 acpi_ut_remove_reference (obj_desc); 254 acpi_ut_remove_reference(obj_desc);
265 return_ACPI_STATUS (status); 255 return_ACPI_STATUS(status);
266} 256}
267 257
268
269/******************************************************************************* 258/*******************************************************************************
270 * 259 *
271 * FUNCTION: acpi_ex_create_region 260 * FUNCTION: acpi_ex_create_region
@@ -282,20 +271,16 @@ cleanup:
282 ******************************************************************************/ 271 ******************************************************************************/
283 272
284acpi_status 273acpi_status
285acpi_ex_create_region ( 274acpi_ex_create_region(u8 * aml_start,
286 u8 *aml_start, 275 u32 aml_length,
287 u32 aml_length, 276 u8 region_space, struct acpi_walk_state *walk_state)
288 u8 region_space,
289 struct acpi_walk_state *walk_state)
290{ 277{
291 acpi_status status; 278 acpi_status status;
292 union acpi_operand_object *obj_desc; 279 union acpi_operand_object *obj_desc;
293 struct acpi_namespace_node *node; 280 struct acpi_namespace_node *node;
294 union acpi_operand_object *region_obj2; 281 union acpi_operand_object *region_obj2;
295
296
297 ACPI_FUNCTION_TRACE ("ex_create_region");
298 282
283 ACPI_FUNCTION_TRACE("ex_create_region");
299 284
300 /* Get the Namespace Node */ 285 /* Get the Namespace Node */
301 286
@@ -305,8 +290,8 @@ acpi_ex_create_region (
305 * If the region object is already attached to this node, 290 * If the region object is already attached to this node,
306 * just return 291 * just return
307 */ 292 */
308 if (acpi_ns_get_attached_object (node)) { 293 if (acpi_ns_get_attached_object(node)) {
309 return_ACPI_STATUS (AE_OK); 294 return_ACPI_STATUS(AE_OK);
310 } 295 }
311 296
312 /* 297 /*
@@ -314,17 +299,18 @@ acpi_ex_create_region (
314 * range 299 * range
315 */ 300 */
316 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && 301 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
317 (region_space < ACPI_USER_REGION_BEGIN)) { 302 (region_space < ACPI_USER_REGION_BEGIN)) {
318 ACPI_REPORT_ERROR (("Invalid address_space type %X\n", region_space)); 303 ACPI_REPORT_ERROR(("Invalid address_space type %X\n",
319 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); 304 region_space));
305 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
320 } 306 }
321 307
322 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", 308 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
323 acpi_ut_get_region_name (region_space), region_space)); 309 acpi_ut_get_region_name(region_space), region_space));
324 310
325 /* Create the region descriptor */ 311 /* Create the region descriptor */
326 312
327 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION); 313 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
328 if (!obj_desc) { 314 if (!obj_desc) {
329 status = AE_NO_MEMORY; 315 status = AE_NO_MEMORY;
330 goto cleanup; 316 goto cleanup;
@@ -334,7 +320,7 @@ acpi_ex_create_region (
334 * Remember location in AML stream of address & length 320 * Remember location in AML stream of address & length
335 * operands since they need to be evaluated at run time. 321 * operands since they need to be evaluated at run time.
336 */ 322 */
337 region_obj2 = obj_desc->common.next_object; 323 region_obj2 = obj_desc->common.next_object;
338 region_obj2->extra.aml_start = aml_start; 324 region_obj2->extra.aml_start = aml_start;
339 region_obj2->extra.aml_length = aml_length; 325 region_obj2->extra.aml_length = aml_length;
340 326
@@ -343,22 +329,20 @@ acpi_ex_create_region (
343 obj_desc->region.space_id = region_space; 329 obj_desc->region.space_id = region_space;
344 obj_desc->region.address = 0; 330 obj_desc->region.address = 0;
345 obj_desc->region.length = 0; 331 obj_desc->region.length = 0;
346 obj_desc->region.node = node; 332 obj_desc->region.node = node;
347 333
348 /* Install the new region object in the parent Node */ 334 /* Install the new region object in the parent Node */
349 335
350 status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION); 336 status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
351 337
352 338 cleanup:
353cleanup:
354 339
355 /* Remove local reference to the object */ 340 /* Remove local reference to the object */
356 341
357 acpi_ut_remove_reference (obj_desc); 342 acpi_ut_remove_reference(obj_desc);
358 return_ACPI_STATUS (status); 343 return_ACPI_STATUS(status);
359} 344}
360 345
361
362/******************************************************************************* 346/*******************************************************************************
363 * 347 *
364 * FUNCTION: acpi_ex_create_table_region 348 * FUNCTION: acpi_ex_create_table_region
@@ -371,20 +355,16 @@ cleanup:
371 * 355 *
372 ******************************************************************************/ 356 ******************************************************************************/
373 357
374acpi_status 358acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state)
375acpi_ex_create_table_region (
376 struct acpi_walk_state *walk_state)
377{ 359{
378 acpi_status status; 360 acpi_status status;
379 union acpi_operand_object **operand = &walk_state->operands[0]; 361 union acpi_operand_object **operand = &walk_state->operands[0];
380 union acpi_operand_object *obj_desc; 362 union acpi_operand_object *obj_desc;
381 struct acpi_namespace_node *node; 363 struct acpi_namespace_node *node;
382 struct acpi_table_header *table; 364 struct acpi_table_header *table;
383 union acpi_operand_object *region_obj2; 365 union acpi_operand_object *region_obj2;
384
385
386 ACPI_FUNCTION_TRACE ("ex_create_table_region");
387 366
367 ACPI_FUNCTION_TRACE("ex_create_table_region");
388 368
389 /* Get the Node from the object stack */ 369 /* Get the Node from the object stack */
390 370
@@ -394,66 +374,64 @@ acpi_ex_create_table_region (
394 * If the region object is already attached to this node, 374 * If the region object is already attached to this node,
395 * just return 375 * just return
396 */ 376 */
397 if (acpi_ns_get_attached_object (node)) { 377 if (acpi_ns_get_attached_object(node)) {
398 return_ACPI_STATUS (AE_OK); 378 return_ACPI_STATUS(AE_OK);
399 } 379 }
400 380
401 /* Find the ACPI table */ 381 /* Find the ACPI table */
402 382
403 status = acpi_tb_find_table (operand[1]->string.pointer, 383 status = acpi_tb_find_table(operand[1]->string.pointer,
404 operand[2]->string.pointer, 384 operand[2]->string.pointer,
405 operand[3]->string.pointer, &table); 385 operand[3]->string.pointer, &table);
406 if (ACPI_FAILURE (status)) { 386 if (ACPI_FAILURE(status)) {
407 return_ACPI_STATUS (status); 387 return_ACPI_STATUS(status);
408 } 388 }
409 389
410 /* Create the region descriptor */ 390 /* Create the region descriptor */
411 391
412 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION); 392 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
413 if (!obj_desc) { 393 if (!obj_desc) {
414 return_ACPI_STATUS (AE_NO_MEMORY); 394 return_ACPI_STATUS(AE_NO_MEMORY);
415 } 395 }
416 396
417 region_obj2 = obj_desc->common.next_object; 397 region_obj2 = obj_desc->common.next_object;
418 region_obj2->extra.region_context = NULL; 398 region_obj2->extra.region_context = NULL;
419 399
420 /* Init the region from the operands */ 400 /* Init the region from the operands */
421 401
422 obj_desc->region.space_id = REGION_DATA_TABLE; 402 obj_desc->region.space_id = REGION_DATA_TABLE;
423 obj_desc->region.address = (acpi_physical_address) ACPI_TO_INTEGER (table); 403 obj_desc->region.address =
404 (acpi_physical_address) ACPI_TO_INTEGER(table);
424 obj_desc->region.length = table->length; 405 obj_desc->region.length = table->length;
425 obj_desc->region.node = node; 406 obj_desc->region.node = node;
426 obj_desc->region.flags = AOPOBJ_DATA_VALID; 407 obj_desc->region.flags = AOPOBJ_DATA_VALID;
427 408
428 /* Install the new region object in the parent Node */ 409 /* Install the new region object in the parent Node */
429 410
430 status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION); 411 status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
431 if (ACPI_FAILURE (status)) { 412 if (ACPI_FAILURE(status)) {
432 goto cleanup; 413 goto cleanup;
433 } 414 }
434 415
435 status = acpi_ev_initialize_region (obj_desc, FALSE); 416 status = acpi_ev_initialize_region(obj_desc, FALSE);
436 if (ACPI_FAILURE (status)) { 417 if (ACPI_FAILURE(status)) {
437 if (status == AE_NOT_EXIST) { 418 if (status == AE_NOT_EXIST) {
438 status = AE_OK; 419 status = AE_OK;
439 } 420 } else {
440 else {
441 goto cleanup; 421 goto cleanup;
442 } 422 }
443 } 423 }
444 424
445 obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE; 425 obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE;
446 426
447 427 cleanup:
448cleanup:
449 428
450 /* Remove local reference to the object */ 429 /* Remove local reference to the object */
451 430
452 acpi_ut_remove_reference (obj_desc); 431 acpi_ut_remove_reference(obj_desc);
453 return_ACPI_STATUS (status); 432 return_ACPI_STATUS(status);
454} 433}
455 434
456
457/******************************************************************************* 435/*******************************************************************************
458 * 436 *
459 * FUNCTION: acpi_ex_create_processor 437 * FUNCTION: acpi_ex_create_processor
@@ -468,43 +446,39 @@ cleanup:
468 * 446 *
469 ******************************************************************************/ 447 ******************************************************************************/
470 448
471acpi_status 449acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
472acpi_ex_create_processor (
473 struct acpi_walk_state *walk_state)
474{ 450{
475 union acpi_operand_object **operand = &walk_state->operands[0]; 451 union acpi_operand_object **operand = &walk_state->operands[0];
476 union acpi_operand_object *obj_desc; 452 union acpi_operand_object *obj_desc;
477 acpi_status status; 453 acpi_status status;
478
479
480 ACPI_FUNCTION_TRACE_PTR ("ex_create_processor", walk_state);
481 454
455 ACPI_FUNCTION_TRACE_PTR("ex_create_processor", walk_state);
482 456
483 /* Create the processor object */ 457 /* Create the processor object */
484 458
485 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PROCESSOR); 459 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PROCESSOR);
486 if (!obj_desc) { 460 if (!obj_desc) {
487 return_ACPI_STATUS (AE_NO_MEMORY); 461 return_ACPI_STATUS(AE_NO_MEMORY);
488 } 462 }
489 463
490 /* Initialize the processor object from the operands */ 464 /* Initialize the processor object from the operands */
491 465
492 obj_desc->processor.proc_id = (u8) operand[1]->integer.value; 466 obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
493 obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value; 467 obj_desc->processor.address =
494 obj_desc->processor.length = (u8) operand[3]->integer.value; 468 (acpi_io_address) operand[2]->integer.value;
469 obj_desc->processor.length = (u8) operand[3]->integer.value;
495 470
496 /* Install the processor object in the parent Node */ 471 /* Install the processor object in the parent Node */
497 472
498 status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], 473 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
499 obj_desc, ACPI_TYPE_PROCESSOR); 474 obj_desc, ACPI_TYPE_PROCESSOR);
500 475
501 /* Remove local reference to the object */ 476 /* Remove local reference to the object */
502 477
503 acpi_ut_remove_reference (obj_desc); 478 acpi_ut_remove_reference(obj_desc);
504 return_ACPI_STATUS (status); 479 return_ACPI_STATUS(status);
505} 480}
506 481
507
508/******************************************************************************* 482/*******************************************************************************
509 * 483 *
510 * FUNCTION: acpi_ex_create_power_resource 484 * FUNCTION: acpi_ex_create_power_resource
@@ -519,43 +493,39 @@ acpi_ex_create_processor (
519 * 493 *
520 ******************************************************************************/ 494 ******************************************************************************/
521 495
522acpi_status 496acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state)
523acpi_ex_create_power_resource (
524 struct acpi_walk_state *walk_state)
525{ 497{
526 union acpi_operand_object **operand = &walk_state->operands[0]; 498 union acpi_operand_object **operand = &walk_state->operands[0];
527 acpi_status status; 499 acpi_status status;
528 union acpi_operand_object *obj_desc; 500 union acpi_operand_object *obj_desc;
529
530
531 ACPI_FUNCTION_TRACE_PTR ("ex_create_power_resource", walk_state);
532 501
502 ACPI_FUNCTION_TRACE_PTR("ex_create_power_resource", walk_state);
533 503
534 /* Create the power resource object */ 504 /* Create the power resource object */
535 505
536 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_POWER); 506 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_POWER);
537 if (!obj_desc) { 507 if (!obj_desc) {
538 return_ACPI_STATUS (AE_NO_MEMORY); 508 return_ACPI_STATUS(AE_NO_MEMORY);
539 } 509 }
540 510
541 /* Initialize the power object from the operands */ 511 /* Initialize the power object from the operands */
542 512
543 obj_desc->power_resource.system_level = (u8) operand[1]->integer.value; 513 obj_desc->power_resource.system_level = (u8) operand[1]->integer.value;
544 obj_desc->power_resource.resource_order = (u16) operand[2]->integer.value; 514 obj_desc->power_resource.resource_order =
515 (u16) operand[2]->integer.value;
545 516
546 /* Install the power resource object in the parent Node */ 517 /* Install the power resource object in the parent Node */
547 518
548 status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], 519 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
549 obj_desc, ACPI_TYPE_POWER); 520 obj_desc, ACPI_TYPE_POWER);
550 521
551 /* Remove local reference to the object */ 522 /* Remove local reference to the object */
552 523
553 acpi_ut_remove_reference (obj_desc); 524 acpi_ut_remove_reference(obj_desc);
554 return_ACPI_STATUS (status); 525 return_ACPI_STATUS(status);
555} 526}
556#endif 527#endif
557 528
558
559/******************************************************************************* 529/*******************************************************************************
560 * 530 *
561 * FUNCTION: acpi_ex_create_method 531 * FUNCTION: acpi_ex_create_method
@@ -571,25 +541,21 @@ acpi_ex_create_power_resource (
571 ******************************************************************************/ 541 ******************************************************************************/
572 542
573acpi_status 543acpi_status
574acpi_ex_create_method ( 544acpi_ex_create_method(u8 * aml_start,
575 u8 *aml_start, 545 u32 aml_length, struct acpi_walk_state *walk_state)
576 u32 aml_length,
577 struct acpi_walk_state *walk_state)
578{ 546{
579 union acpi_operand_object **operand = &walk_state->operands[0]; 547 union acpi_operand_object **operand = &walk_state->operands[0];
580 union acpi_operand_object *obj_desc; 548 union acpi_operand_object *obj_desc;
581 acpi_status status; 549 acpi_status status;
582 u8 method_flags; 550 u8 method_flags;
583
584
585 ACPI_FUNCTION_TRACE_PTR ("ex_create_method", walk_state);
586 551
552 ACPI_FUNCTION_TRACE_PTR("ex_create_method", walk_state);
587 553
588 /* Create a new method object */ 554 /* Create a new method object */
589 555
590 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_METHOD); 556 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
591 if (!obj_desc) { 557 if (!obj_desc) {
592 return_ACPI_STATUS (AE_NO_MEMORY); 558 return_ACPI_STATUS(AE_NO_MEMORY);
593 } 559 }
594 560
595 /* Save the method's AML pointer and length */ 561 /* Save the method's AML pointer and length */
@@ -603,8 +569,10 @@ acpi_ex_create_method (
603 */ 569 */
604 method_flags = (u8) operand[1]->integer.value; 570 method_flags = (u8) operand[1]->integer.value;
605 571
606 obj_desc->method.method_flags = (u8) (method_flags & ~AML_METHOD_ARG_COUNT); 572 obj_desc->method.method_flags =
607 obj_desc->method.param_count = (u8) (method_flags & AML_METHOD_ARG_COUNT); 573 (u8) (method_flags & ~AML_METHOD_ARG_COUNT);
574 obj_desc->method.param_count =
575 (u8) (method_flags & AML_METHOD_ARG_COUNT);
608 576
609 /* 577 /*
610 * Get the concurrency count. If required, a semaphore will be 578 * Get the concurrency count. If required, a semaphore will be
@@ -613,32 +581,28 @@ acpi_ex_create_method (
613 if (acpi_gbl_all_methods_serialized) { 581 if (acpi_gbl_all_methods_serialized) {
614 obj_desc->method.concurrency = 1; 582 obj_desc->method.concurrency = 1;
615 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; 583 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
616 } 584 } else if (method_flags & AML_METHOD_SERIALIZED) {
617 else if (method_flags & AML_METHOD_SERIALIZED) {
618 /* 585 /*
619 * ACPI 1.0: Concurrency = 1 586 * ACPI 1.0: Concurrency = 1
620 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1) 587 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)
621 */ 588 */
622 obj_desc->method.concurrency = (u8) 589 obj_desc->method.concurrency = (u8)
623 (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); 590 (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
624 } 591 } else {
625 else {
626 obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY; 592 obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
627 } 593 }
628 594
629 /* Attach the new object to the method Node */ 595 /* Attach the new object to the method Node */
630 596
631 status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], 597 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
632 obj_desc, ACPI_TYPE_METHOD); 598 obj_desc, ACPI_TYPE_METHOD);
633 599
634 /* Remove local reference to the object */ 600 /* Remove local reference to the object */
635 601
636 acpi_ut_remove_reference (obj_desc); 602 acpi_ut_remove_reference(obj_desc);
637 603
638 /* Remove a reference to the operand */ 604 /* Remove a reference to the operand */
639 605
640 acpi_ut_remove_reference (operand[1]); 606 acpi_ut_remove_reference(operand[1]);
641 return_ACPI_STATUS (status); 607 return_ACPI_STATUS(status);
642} 608}
643
644
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 408500648114..bc2fa996047e 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -49,37 +48,27 @@
49#include <acpi/acparser.h> 48#include <acpi/acparser.h>
50 49
51#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdump") 51ACPI_MODULE_NAME("exdump")
53 52
53/*
54 * The following routines are used for debug output only
55 */
56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
54/* Local prototypes */ 57/* Local prototypes */
55
56#ifdef ACPI_FUTURE_USAGE 58#ifdef ACPI_FUTURE_USAGE
57static void 59static void acpi_ex_out_string(char *title, char *value);
58acpi_ex_out_string (
59 char *title,
60 char *value);
61 60
62static void 61static void acpi_ex_out_pointer(char *title, void *value);
63acpi_ex_out_pointer (
64 char *title,
65 void *value);
66 62
67static void 63static void acpi_ex_out_integer(char *title, u32 value);
68acpi_ex_out_integer (
69 char *title,
70 u32 value);
71 64
72static void 65static void acpi_ex_out_address(char *title, acpi_physical_address value);
73acpi_ex_out_address (
74 char *title,
75 acpi_physical_address value);
76#endif /* ACPI_FUTURE_USAGE */
77 66
67static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc);
78 68
79/* 69static void
80 * The following routines are used for debug output only 70acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index);
81 */ 71#endif /* ACPI_FUTURE_USAGE */
82#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
83 72
84/******************************************************************************* 73/*******************************************************************************
85 * 74 *
@@ -94,143 +83,140 @@ acpi_ex_out_address (
94 * 83 *
95 ******************************************************************************/ 84 ******************************************************************************/
96 85
97void 86void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
98acpi_ex_dump_operand (
99 union acpi_operand_object *obj_desc,
100 u32 depth)
101{ 87{
102 u32 length; 88 u32 length;
103 u32 index; 89 u32 index;
104
105 90
106 ACPI_FUNCTION_NAME ("ex_dump_operand") 91 ACPI_FUNCTION_NAME("ex_dump_operand")
107 92
108 93 if (!
109 if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { 94 ((ACPI_LV_EXEC & acpi_dbg_level)
95 && (_COMPONENT & acpi_dbg_layer))) {
110 return; 96 return;
111 } 97 }
112 98
113 if (!obj_desc) { 99 if (!obj_desc) {
114 /* This could be a null element of a package */ 100 /* This could be a null element of a package */
115 101
116 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); 102 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
117 return; 103 return;
118 } 104 }
119 105
120 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 106 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
121 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc)); 107 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
122 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); 108 obj_desc));
109 ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
123 return; 110 return;
124 } 111 }
125 112
126 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 113 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
127 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 114 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
128 "%p is not a node or operand object: [%s]\n", 115 "%p is not a node or operand object: [%s]\n",
129 obj_desc, acpi_ut_get_descriptor_name (obj_desc))); 116 obj_desc,
130 ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object)); 117 acpi_ut_get_descriptor_name(obj_desc)));
118 ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object));
131 return; 119 return;
132 } 120 }
133 121
134 /* obj_desc is a valid object */ 122 /* obj_desc is a valid object */
135 123
136 if (depth > 0) { 124 if (depth > 0) {
137 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", 125 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ",
138 depth, " ", depth, obj_desc)); 126 depth, " ", depth, obj_desc));
139 } 127 } else {
140 else { 128 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc));
141 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
142 } 129 }
143 130
144 /* Decode object type */ 131 /* Decode object type */
145 132
146 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 133 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
147 case ACPI_TYPE_LOCAL_REFERENCE: 134 case ACPI_TYPE_LOCAL_REFERENCE:
148 135
149 switch (obj_desc->reference.opcode) { 136 switch (obj_desc->reference.opcode) {
150 case AML_DEBUG_OP: 137 case AML_DEBUG_OP:
151 138
152 acpi_os_printf ("Reference: Debug\n"); 139 acpi_os_printf("Reference: Debug\n");
153 break; 140 break;
154 141
155
156 case AML_NAME_OP: 142 case AML_NAME_OP:
157 143
158 ACPI_DUMP_PATHNAME (obj_desc->reference.object, 144 ACPI_DUMP_PATHNAME(obj_desc->reference.object,
159 "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); 145 "Reference: Name: ", ACPI_LV_INFO,
160 ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO); 146 _COMPONENT);
147 ACPI_DUMP_ENTRY(obj_desc->reference.object,
148 ACPI_LV_INFO);
161 break; 149 break;
162 150
163
164 case AML_INDEX_OP: 151 case AML_INDEX_OP:
165 152
166 acpi_os_printf ("Reference: Index %p\n", 153 acpi_os_printf("Reference: Index %p\n",
167 obj_desc->reference.object); 154 obj_desc->reference.object);
168 break; 155 break;
169 156
170
171 case AML_REF_OF_OP: 157 case AML_REF_OF_OP:
172 158
173 acpi_os_printf ("Reference: (ref_of) %p\n", 159 acpi_os_printf("Reference: (ref_of) %p\n",
174 obj_desc->reference.object); 160 obj_desc->reference.object);
175 break; 161 break;
176 162
177
178 case AML_ARG_OP: 163 case AML_ARG_OP:
179 164
180 acpi_os_printf ("Reference: Arg%d", 165 acpi_os_printf("Reference: Arg%d",
181 obj_desc->reference.offset); 166 obj_desc->reference.offset);
182 167
183 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 168 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
184 /* Value is an Integer */ 169 /* Value is an Integer */
185 170
186 acpi_os_printf (" value is [%8.8X%8.8x]", 171 acpi_os_printf(" value is [%8.8X%8.8x]",
187 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 172 ACPI_FORMAT_UINT64(obj_desc->
173 integer.
174 value));
188 } 175 }
189 176
190 acpi_os_printf ("\n"); 177 acpi_os_printf("\n");
191 break; 178 break;
192 179
193
194 case AML_LOCAL_OP: 180 case AML_LOCAL_OP:
195 181
196 acpi_os_printf ("Reference: Local%d", 182 acpi_os_printf("Reference: Local%d",
197 obj_desc->reference.offset); 183 obj_desc->reference.offset);
198 184
199 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 185 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
200 186
201 /* Value is an Integer */ 187 /* Value is an Integer */
202 188
203 acpi_os_printf (" value is [%8.8X%8.8x]", 189 acpi_os_printf(" value is [%8.8X%8.8x]",
204 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 190 ACPI_FORMAT_UINT64(obj_desc->
191 integer.
192 value));
205 } 193 }
206 194
207 acpi_os_printf ("\n"); 195 acpi_os_printf("\n");
208 break; 196 break;
209 197
210
211 case AML_INT_NAMEPATH_OP: 198 case AML_INT_NAMEPATH_OP:
212 199
213 acpi_os_printf ("Reference.Node->Name %X\n", 200 acpi_os_printf("Reference.Node->Name %X\n",
214 obj_desc->reference.node->name.integer); 201 obj_desc->reference.node->name.integer);
215 break; 202 break;
216 203
217
218 default: 204 default:
219 205
220 /* Unknown opcode */ 206 /* Unknown opcode */
221 207
222 acpi_os_printf ("Unknown Reference opcode=%X\n", 208 acpi_os_printf("Unknown Reference opcode=%X\n",
223 obj_desc->reference.opcode); 209 obj_desc->reference.opcode);
224 break; 210 break;
225 211
226 } 212 }
227 break; 213 break;
228 214
229
230 case ACPI_TYPE_BUFFER: 215 case ACPI_TYPE_BUFFER:
231 216
232 acpi_os_printf ("Buffer len %X @ %p \n", 217 acpi_os_printf("Buffer len %X @ %p \n",
233 obj_desc->buffer.length, obj_desc->buffer.pointer); 218 obj_desc->buffer.length,
219 obj_desc->buffer.pointer);
234 220
235 length = obj_desc->buffer.length; 221 length = obj_desc->buffer.length;
236 if (length > 64) { 222 if (length > 64) {
@@ -240,178 +226,166 @@ acpi_ex_dump_operand (
240 /* Debug only -- dump the buffer contents */ 226 /* Debug only -- dump the buffer contents */
241 227
242 if (obj_desc->buffer.pointer) { 228 if (obj_desc->buffer.pointer) {
243 acpi_os_printf ("Buffer Contents: "); 229 acpi_os_printf("Buffer Contents: ");
244 230
245 for (index = 0; index < length; index++) { 231 for (index = 0; index < length; index++) {
246 acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]); 232 acpi_os_printf(" %02x",
233 obj_desc->buffer.pointer[index]);
247 } 234 }
248 acpi_os_printf ("\n"); 235 acpi_os_printf("\n");
249 } 236 }
250 break; 237 break;
251 238
252
253 case ACPI_TYPE_INTEGER: 239 case ACPI_TYPE_INTEGER:
254 240
255 acpi_os_printf ("Integer %8.8X%8.8X\n", 241 acpi_os_printf("Integer %8.8X%8.8X\n",
256 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 242 ACPI_FORMAT_UINT64(obj_desc->integer.value));
257 break; 243 break;
258 244
259
260 case ACPI_TYPE_PACKAGE: 245 case ACPI_TYPE_PACKAGE:
261 246
262 acpi_os_printf ("Package [Len %X] element_array %p\n", 247 acpi_os_printf("Package [Len %X] element_array %p\n",
263 obj_desc->package.count, obj_desc->package.elements); 248 obj_desc->package.count,
249 obj_desc->package.elements);
264 250
265 /* 251 /*
266 * If elements exist, package element pointer is valid, 252 * If elements exist, package element pointer is valid,
267 * and debug_level exceeds 1, dump package's elements. 253 * and debug_level exceeds 1, dump package's elements.
268 */ 254 */
269 if (obj_desc->package.count && 255 if (obj_desc->package.count &&
270 obj_desc->package.elements && 256 obj_desc->package.elements && acpi_dbg_level > 1) {
271 acpi_dbg_level > 1) { 257 for (index = 0; index < obj_desc->package.count;
272 for (index = 0; index < obj_desc->package.count; index++) { 258 index++) {
273 acpi_ex_dump_operand (obj_desc->package.elements[index], depth+1); 259 acpi_ex_dump_operand(obj_desc->package.
260 elements[index],
261 depth + 1);
274 } 262 }
275 } 263 }
276 break; 264 break;
277 265
278
279 case ACPI_TYPE_REGION: 266 case ACPI_TYPE_REGION:
280 267
281 acpi_os_printf ("Region %s (%X)", 268 acpi_os_printf("Region %s (%X)",
282 acpi_ut_get_region_name (obj_desc->region.space_id), 269 acpi_ut_get_region_name(obj_desc->region.
283 obj_desc->region.space_id); 270 space_id),
271 obj_desc->region.space_id);
284 272
285 /* 273 /*
286 * If the address and length have not been evaluated, 274 * If the address and length have not been evaluated,
287 * don't print them. 275 * don't print them.
288 */ 276 */
289 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) { 277 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
290 acpi_os_printf ("\n"); 278 acpi_os_printf("\n");
291 } 279 } else {
292 else { 280 acpi_os_printf(" base %8.8X%8.8X Length %X\n",
293 acpi_os_printf (" base %8.8X%8.8X Length %X\n", 281 ACPI_FORMAT_UINT64(obj_desc->region.
294 ACPI_FORMAT_UINT64 (obj_desc->region.address), 282 address),
295 obj_desc->region.length); 283 obj_desc->region.length);
296 } 284 }
297 break; 285 break;
298 286
299
300 case ACPI_TYPE_STRING: 287 case ACPI_TYPE_STRING:
301 288
302 acpi_os_printf ("String length %X @ %p ", 289 acpi_os_printf("String length %X @ %p ",
303 obj_desc->string.length, 290 obj_desc->string.length,
304 obj_desc->string.pointer); 291 obj_desc->string.pointer);
305 292
306 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); 293 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
307 acpi_os_printf ("\n"); 294 acpi_os_printf("\n");
308 break; 295 break;
309 296
310
311 case ACPI_TYPE_LOCAL_BANK_FIELD: 297 case ACPI_TYPE_LOCAL_BANK_FIELD:
312 298
313 acpi_os_printf ("bank_field\n"); 299 acpi_os_printf("bank_field\n");
314 break; 300 break;
315 301
316
317 case ACPI_TYPE_LOCAL_REGION_FIELD: 302 case ACPI_TYPE_LOCAL_REGION_FIELD:
318 303
319 acpi_os_printf ( 304 acpi_os_printf
320 "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", 305 ("region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
321 obj_desc->field.bit_length, 306 obj_desc->field.bit_length,
322 obj_desc->field.access_byte_width, 307 obj_desc->field.access_byte_width,
323 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, 308 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
324 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, 309 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
325 obj_desc->field.base_byte_offset, 310 obj_desc->field.base_byte_offset,
326 obj_desc->field.start_field_bit_offset); 311 obj_desc->field.start_field_bit_offset);
327 312
328 acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1); 313 acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
329 break; 314 break;
330 315
331
332 case ACPI_TYPE_LOCAL_INDEX_FIELD: 316 case ACPI_TYPE_LOCAL_INDEX_FIELD:
333 317
334 acpi_os_printf ("index_field\n"); 318 acpi_os_printf("index_field\n");
335 break; 319 break;
336 320
337
338 case ACPI_TYPE_BUFFER_FIELD: 321 case ACPI_TYPE_BUFFER_FIELD:
339 322
340 acpi_os_printf ( 323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n",
341 "buffer_field: %X bits at byte %X bit %X of \n", 324 obj_desc->buffer_field.bit_length,
342 obj_desc->buffer_field.bit_length, 325 obj_desc->buffer_field.base_byte_offset,
343 obj_desc->buffer_field.base_byte_offset, 326 obj_desc->buffer_field.start_field_bit_offset);
344 obj_desc->buffer_field.start_field_bit_offset);
345 327
346 if (!obj_desc->buffer_field.buffer_obj) { 328 if (!obj_desc->buffer_field.buffer_obj) {
347 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); 329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n"));
348 } 330 } else
349 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != 331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
350 ACPI_TYPE_BUFFER) { 332 != ACPI_TYPE_BUFFER) {
351 acpi_os_printf ("*not a Buffer* \n"); 333 acpi_os_printf("*not a Buffer* \n");
352 } 334 } else {
353 else { 335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
354 acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1); 336 depth + 1);
355 } 337 }
356 break; 338 break;
357 339
358
359 case ACPI_TYPE_EVENT: 340 case ACPI_TYPE_EVENT:
360 341
361 acpi_os_printf ("Event\n"); 342 acpi_os_printf("Event\n");
362 break; 343 break;
363 344
364
365 case ACPI_TYPE_METHOD: 345 case ACPI_TYPE_METHOD:
366 346
367 acpi_os_printf ("Method(%X) @ %p:%X\n", 347 acpi_os_printf("Method(%X) @ %p:%X\n",
368 obj_desc->method.param_count, 348 obj_desc->method.param_count,
369 obj_desc->method.aml_start, 349 obj_desc->method.aml_start,
370 obj_desc->method.aml_length); 350 obj_desc->method.aml_length);
371 break; 351 break;
372 352
373
374 case ACPI_TYPE_MUTEX: 353 case ACPI_TYPE_MUTEX:
375 354
376 acpi_os_printf ("Mutex\n"); 355 acpi_os_printf("Mutex\n");
377 break; 356 break;
378 357
379
380 case ACPI_TYPE_DEVICE: 358 case ACPI_TYPE_DEVICE:
381 359
382 acpi_os_printf ("Device\n"); 360 acpi_os_printf("Device\n");
383 break; 361 break;
384 362
385
386 case ACPI_TYPE_POWER: 363 case ACPI_TYPE_POWER:
387 364
388 acpi_os_printf ("Power\n"); 365 acpi_os_printf("Power\n");
389 break; 366 break;
390 367
391
392 case ACPI_TYPE_PROCESSOR: 368 case ACPI_TYPE_PROCESSOR:
393 369
394 acpi_os_printf ("Processor\n"); 370 acpi_os_printf("Processor\n");
395 break; 371 break;
396 372
397
398 case ACPI_TYPE_THERMAL: 373 case ACPI_TYPE_THERMAL:
399 374
400 acpi_os_printf ("Thermal\n"); 375 acpi_os_printf("Thermal\n");
401 break; 376 break;
402 377
403
404 default: 378 default:
405 /* Unknown Type */ 379 /* Unknown Type */
406 380
407 acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); 381 acpi_os_printf("Unknown Type %X\n",
382 ACPI_GET_OBJECT_TYPE(obj_desc));
408 break; 383 break;
409 } 384 }
410 385
411 return; 386 return;
412} 387}
413 388
414
415/******************************************************************************* 389/*******************************************************************************
416 * 390 *
417 * FUNCTION: acpi_ex_dump_operands 391 * FUNCTION: acpi_ex_dump_operands
@@ -429,20 +403,15 @@ acpi_ex_dump_operand (
429 ******************************************************************************/ 403 ******************************************************************************/
430 404
431void 405void
432acpi_ex_dump_operands ( 406acpi_ex_dump_operands(union acpi_operand_object **operands,
433 union acpi_operand_object **operands, 407 acpi_interpreter_mode interpreter_mode,
434 acpi_interpreter_mode interpreter_mode, 408 char *ident,
435 char *ident, 409 u32 num_levels,
436 u32 num_levels, 410 char *note, char *module_name, u32 line_number)
437 char *note,
438 char *module_name,
439 u32 line_number)
440{ 411{
441 acpi_native_uint i; 412 acpi_native_uint i;
442
443
444 ACPI_FUNCTION_NAME ("ex_dump_operands");
445 413
414 ACPI_FUNCTION_NAME("ex_dump_operands");
446 415
447 if (!ident) { 416 if (!ident) {
448 ident = "?"; 417 ident = "?";
@@ -452,9 +421,9 @@ acpi_ex_dump_operands (
452 note = "?"; 421 note = "?";
453 } 422 }
454 423
455 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 424 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
456 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", 425 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
457 ident, num_levels)); 426 ident, num_levels));
458 427
459 if (num_levels == 0) { 428 if (num_levels == 0) {
460 num_levels = 1; 429 num_levels = 1;
@@ -463,16 +432,15 @@ acpi_ex_dump_operands (
463 /* Dump the operand stack starting at the top */ 432 /* Dump the operand stack starting at the top */
464 433
465 for (i = 0; num_levels > 0; i--, num_levels--) { 434 for (i = 0; num_levels > 0; i--, num_levels--) {
466 acpi_ex_dump_operand (operands[i], 0); 435 acpi_ex_dump_operand(operands[i], 0);
467 } 436 }
468 437
469 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 438 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
470 "************* Stack dump from %s(%d), %s\n", 439 "************* Operand Stack dump from %s(%d), %s\n",
471 module_name, line_number, note)); 440 module_name, line_number, note));
472 return; 441 return;
473} 442}
474 443
475
476#ifdef ACPI_FUTURE_USAGE 444#ifdef ACPI_FUTURE_USAGE
477/******************************************************************************* 445/*******************************************************************************
478 * 446 *
@@ -487,44 +455,31 @@ acpi_ex_dump_operands (
487 * 455 *
488 ******************************************************************************/ 456 ******************************************************************************/
489 457
490static void 458static void acpi_ex_out_string(char *title, char *value)
491acpi_ex_out_string (
492 char *title,
493 char *value)
494{ 459{
495 acpi_os_printf ("%20s : %s\n", title, value); 460 acpi_os_printf("%20s : %s\n", title, value);
496} 461}
497 462
498static void 463static void acpi_ex_out_pointer(char *title, void *value)
499acpi_ex_out_pointer (
500 char *title,
501 void *value)
502{ 464{
503 acpi_os_printf ("%20s : %p\n", title, value); 465 acpi_os_printf("%20s : %p\n", title, value);
504} 466}
505 467
506static void 468static void acpi_ex_out_integer(char *title, u32 value)
507acpi_ex_out_integer (
508 char *title,
509 u32 value)
510{ 469{
511 acpi_os_printf ("%20s : %X\n", title, value); 470 acpi_os_printf("%20s : %.2X\n", title, value);
512} 471}
513 472
514static void 473static void acpi_ex_out_address(char *title, acpi_physical_address value)
515acpi_ex_out_address (
516 char *title,
517 acpi_physical_address value)
518{ 474{
519 475
520#if ACPI_MACHINE_WIDTH == 16 476#if ACPI_MACHINE_WIDTH == 16
521 acpi_os_printf ("%20s : %p\n", title, value); 477 acpi_os_printf("%20s : %p\n", title, value);
522#else 478#else
523 acpi_os_printf ("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64 (value)); 479 acpi_os_printf("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
524#endif 480#endif
525} 481}
526 482
527
528/******************************************************************************* 483/*******************************************************************************
529 * 484 *
530 * FUNCTION: acpi_ex_dump_node 485 * FUNCTION: acpi_ex_dump_node
@@ -536,38 +491,161 @@ acpi_ex_out_address (
536 * 491 *
537 ******************************************************************************/ 492 ******************************************************************************/
538 493
539void 494void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
540acpi_ex_dump_node (
541 struct acpi_namespace_node *node,
542 u32 flags)
543{ 495{
544 496
545 ACPI_FUNCTION_ENTRY (); 497 ACPI_FUNCTION_ENTRY();
546
547 498
548 if (!flags) { 499 if (!flags) {
549 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { 500 if (!
501 ((ACPI_LV_OBJECTS & acpi_dbg_level)
502 && (_COMPONENT & acpi_dbg_layer))) {
550 return; 503 return;
551 } 504 }
552 } 505 }
553 506
554 acpi_os_printf ("%20s : %4.4s\n", "Name", acpi_ut_get_node_name (node)); 507 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
555 acpi_ex_out_string ("Type", acpi_ut_get_type_name (node->type)); 508 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
556 acpi_ex_out_integer ("Flags", node->flags); 509 acpi_ex_out_integer("Flags", node->flags);
557 acpi_ex_out_integer ("Owner Id", node->owner_id); 510 acpi_ex_out_integer("Owner Id", node->owner_id);
558 acpi_ex_out_integer ("Reference Count", node->reference_count); 511 acpi_ex_out_integer("Reference Count", node->reference_count);
559 acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node)); 512 acpi_ex_out_pointer("Attached Object",
560 acpi_ex_out_pointer ("child_list", node->child); 513 acpi_ns_get_attached_object(node));
561 acpi_ex_out_pointer ("next_peer", node->peer); 514 acpi_ex_out_pointer("child_list", node->child);
562 acpi_ex_out_pointer ("Parent", acpi_ns_get_parent_node (node)); 515 acpi_ex_out_pointer("next_peer", node->peer);
516 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
563} 517}
564 518
519/*******************************************************************************
520 *
521 * FUNCTION: acpi_ex_dump_reference
522 *
523 * PARAMETERS: Object - Descriptor to dump
524 *
525 * DESCRIPTION: Dumps a reference object
526 *
527 ******************************************************************************/
528
529static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
530{
531 struct acpi_buffer ret_buf;
532 acpi_status status;
533
534 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
535 acpi_os_printf("Named Object %p ", obj_desc->reference.node);
536 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
537 status =
538 acpi_ns_handle_to_pathname(obj_desc->reference.node,
539 &ret_buf);
540 if (ACPI_FAILURE(status)) {
541 acpi_os_printf("Could not convert name to pathname\n");
542 } else {
543 acpi_os_printf("%s\n", (char *)ret_buf.pointer);
544 ACPI_MEM_FREE(ret_buf.pointer);
545 }
546 } else if (obj_desc->reference.object) {
547 acpi_os_printf("\nReferenced Object: %p\n",
548 obj_desc->reference.object);
549 }
550}
551
552/*******************************************************************************
553 *
554 * FUNCTION: acpi_ex_dump_package
555 *
556 * PARAMETERS: Object - Descriptor to dump
557 * Level - Indentation Level
558 * Index - Package index for this object
559 *
560 * DESCRIPTION: Dumps the elements of the package
561 *
562 ******************************************************************************/
563
564static void
565acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
566{
567 u32 i;
568
569 /* Indentation and index output */
570
571 if (level > 0) {
572 for (i = 0; i < level; i++) {
573 acpi_os_printf(" ");
574 }
575
576 acpi_os_printf("[%.2d] ", index);
577 }
578
579 acpi_os_printf("%p ", obj_desc);
580
581 /* Null package elements are allowed */
582
583 if (!obj_desc) {
584 acpi_os_printf("[Null Object]\n");
585 return;
586 }
587
588 /* Packages may only contain a few object types */
589
590 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
591 case ACPI_TYPE_INTEGER:
592
593 acpi_os_printf("[Integer] = %8.8X%8.8X\n",
594 ACPI_FORMAT_UINT64(obj_desc->integer.value));
595 break;
596
597 case ACPI_TYPE_STRING:
598
599 acpi_os_printf("[String] Value: ");
600 for (i = 0; i < obj_desc->string.length; i++) {
601 acpi_os_printf("%c", obj_desc->string.pointer[i]);
602 }
603 acpi_os_printf("\n");
604 break;
605
606 case ACPI_TYPE_BUFFER:
607
608 acpi_os_printf("[Buffer] Length %.2X = ",
609 obj_desc->buffer.length);
610 if (obj_desc->buffer.length) {
611 acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer,
612 obj_desc->buffer.length,
613 DB_DWORD_DISPLAY, _COMPONENT);
614 } else {
615 acpi_os_printf("\n");
616 }
617 break;
618
619 case ACPI_TYPE_PACKAGE:
620
621 acpi_os_printf("[Package] Contains %d Elements: \n",
622 obj_desc->package.count);
623
624 for (i = 0; i < obj_desc->package.count; i++) {
625 acpi_ex_dump_package(obj_desc->package.elements[i],
626 level + 1, i);
627 }
628 break;
629
630 case ACPI_TYPE_LOCAL_REFERENCE:
631
632 acpi_os_printf("[Object Reference] ");
633 acpi_ex_dump_reference(obj_desc);
634 break;
635
636 default:
637
638 acpi_os_printf("[Unknown Type] %X\n",
639 ACPI_GET_OBJECT_TYPE(obj_desc));
640 break;
641 }
642}
565 643
566/******************************************************************************* 644/*******************************************************************************
567 * 645 *
568 * FUNCTION: acpi_ex_dump_object_descriptor 646 * FUNCTION: acpi_ex_dump_object_descriptor
569 * 647 *
570 * PARAMETERS: *Object - Descriptor to dump 648 * PARAMETERS: Object - Descriptor to dump
571 * Flags - Force display if TRUE 649 * Flags - Force display if TRUE
572 * 650 *
573 * DESCRIPTION: Dumps the members of the object descriptor given. 651 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -575,202 +653,213 @@ acpi_ex_dump_node (
575 ******************************************************************************/ 653 ******************************************************************************/
576 654
577void 655void
578acpi_ex_dump_object_descriptor ( 656acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
579 union acpi_operand_object *obj_desc,
580 u32 flags)
581{ 657{
582 u32 i; 658 ACPI_FUNCTION_TRACE("ex_dump_object_descriptor");
583
584
585 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
586
587 659
588 if (!obj_desc) { 660 if (!obj_desc) {
589 return_VOID; 661 return_VOID;
590 } 662 }
591 663
592 if (!flags) { 664 if (!flags) {
593 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { 665 if (!
666 ((ACPI_LV_OBJECTS & acpi_dbg_level)
667 && (_COMPONENT & acpi_dbg_layer))) {
594 return_VOID; 668 return_VOID;
595 } 669 }
596 } 670 }
597 671
598 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
599 acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags); 673 acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc,
600 acpi_os_printf ("\nAttached Object (%p):\n", 674 flags);
601 ((struct acpi_namespace_node *) obj_desc)->object); 675 acpi_os_printf("\nAttached Object (%p):\n",
602 acpi_ex_dump_object_descriptor ( 676 ((struct acpi_namespace_node *)obj_desc)->
603 ((struct acpi_namespace_node *) obj_desc)->object, flags); 677 object);
678 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
679 obj_desc)->object, flags);
604 return_VOID; 680 return_VOID;
605 } 681 }
606 682
607 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 683 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
608 acpi_os_printf ( 684 acpi_os_printf
609 "ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n", 685 ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
610 obj_desc, acpi_ut_get_descriptor_name (obj_desc)); 686 obj_desc, acpi_ut_get_descriptor_name(obj_desc));
611 return_VOID; 687 return_VOID;
612 } 688 }
613 689
614 /* Common Fields */ 690 /* Common Fields */
615 691
616 acpi_ex_out_string ("Type", acpi_ut_get_object_type_name (obj_desc)); 692 acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc));
617 acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count); 693 acpi_ex_out_integer("Reference Count",
618 acpi_ex_out_integer ("Flags", obj_desc->common.flags); 694 obj_desc->common.reference_count);
695 acpi_ex_out_integer("Flags", obj_desc->common.flags);
619 696
620 /* Object-specific Fields */ 697 /* Object-specific Fields */
621 698
622 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 699 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
623 case ACPI_TYPE_INTEGER: 700 case ACPI_TYPE_INTEGER:
624 701
625 acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value", 702 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
626 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 703 ACPI_FORMAT_UINT64(obj_desc->integer.value));
627 break; 704 break;
628 705
629
630 case ACPI_TYPE_STRING: 706 case ACPI_TYPE_STRING:
631 707
632 acpi_ex_out_integer ("Length", obj_desc->string.length); 708 acpi_ex_out_integer("Length", obj_desc->string.length);
633 709
634 acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer); 710 acpi_os_printf("%20s : %p ", "Pointer",
635 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); 711 obj_desc->string.pointer);
636 acpi_os_printf ("\n"); 712 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
713 acpi_os_printf("\n");
637 break; 714 break;
638 715
639
640 case ACPI_TYPE_BUFFER: 716 case ACPI_TYPE_BUFFER:
641 717
642 acpi_ex_out_integer ("Length", obj_desc->buffer.length); 718 acpi_ex_out_integer("Length", obj_desc->buffer.length);
643 acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer); 719 acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
644 ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length); 720 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
721 obj_desc->buffer.length);
645 break; 722 break;
646 723
647
648 case ACPI_TYPE_PACKAGE: 724 case ACPI_TYPE_PACKAGE:
649 725
650 acpi_ex_out_integer ("Flags", obj_desc->package.flags); 726 acpi_ex_out_integer("Flags", obj_desc->package.flags);
651 acpi_ex_out_integer ("Count", obj_desc->package.count); 727 acpi_ex_out_integer("Elements", obj_desc->package.count);
652 acpi_ex_out_pointer ("Elements", obj_desc->package.elements); 728 acpi_ex_out_pointer("Element List", obj_desc->package.elements);
653 729
654 /* Dump the package contents */ 730 /* Dump the package contents */
655 731
656 if (obj_desc->package.count > 0) { 732 acpi_os_printf("\nPackage Contents:\n");
657 acpi_os_printf ("\nPackage Contents:\n"); 733 acpi_ex_dump_package(obj_desc, 0, 0);
658 for (i = 0; i < obj_desc->package.count; i++) {
659 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
660 if (obj_desc->package.elements[i]) {
661 acpi_os_printf (" %s",
662 acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
663 }
664 acpi_os_printf ("\n");
665 }
666 }
667 break; 734 break;
668 735
669
670 case ACPI_TYPE_DEVICE: 736 case ACPI_TYPE_DEVICE:
671 737
672 acpi_ex_out_pointer ("Handler", obj_desc->device.handler); 738 acpi_ex_out_pointer("Handler", obj_desc->device.handler);
673 acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify); 739 acpi_ex_out_pointer("system_notify",
674 acpi_ex_out_pointer ("device_notify", obj_desc->device.device_notify); 740 obj_desc->device.system_notify);
741 acpi_ex_out_pointer("device_notify",
742 obj_desc->device.device_notify);
675 break; 743 break;
676 744
677
678 case ACPI_TYPE_EVENT: 745 case ACPI_TYPE_EVENT:
679 746
680 acpi_ex_out_pointer ("Semaphore", obj_desc->event.semaphore); 747 acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
681 break; 748 break;
682 749
683
684 case ACPI_TYPE_METHOD: 750 case ACPI_TYPE_METHOD:
685 751
686 acpi_ex_out_integer ("param_count", obj_desc->method.param_count); 752 acpi_ex_out_integer("param_count",
687 acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); 753 obj_desc->method.param_count);
688 acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); 754 acpi_ex_out_integer("Concurrency",
689 acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id); 755 obj_desc->method.concurrency);
690 acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); 756 acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
691 acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); 757 acpi_ex_out_integer("owner_id", obj_desc->method.owner_id);
758 acpi_ex_out_integer("aml_length", obj_desc->method.aml_length);
759 acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start);
692 break; 760 break;
693 761
694
695 case ACPI_TYPE_MUTEX: 762 case ACPI_TYPE_MUTEX:
696 763
697 acpi_ex_out_integer ("sync_level", obj_desc->mutex.sync_level); 764 acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
698 acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread); 765 acpi_ex_out_pointer("owner_thread",
699 acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth); 766 obj_desc->mutex.owner_thread);
700 acpi_ex_out_pointer ("Semaphore", obj_desc->mutex.semaphore); 767 acpi_ex_out_integer("acquire_depth",
768 obj_desc->mutex.acquisition_depth);
769 acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore);
701 break; 770 break;
702 771
703
704 case ACPI_TYPE_REGION: 772 case ACPI_TYPE_REGION:
705 773
706 acpi_ex_out_integer ("space_id", obj_desc->region.space_id); 774 acpi_ex_out_integer("space_id", obj_desc->region.space_id);
707 acpi_ex_out_integer ("Flags", obj_desc->region.flags); 775 acpi_ex_out_integer("Flags", obj_desc->region.flags);
708 acpi_ex_out_address ("Address", obj_desc->region.address); 776 acpi_ex_out_address("Address", obj_desc->region.address);
709 acpi_ex_out_integer ("Length", obj_desc->region.length); 777 acpi_ex_out_integer("Length", obj_desc->region.length);
710 acpi_ex_out_pointer ("Handler", obj_desc->region.handler); 778 acpi_ex_out_pointer("Handler", obj_desc->region.handler);
711 acpi_ex_out_pointer ("Next", obj_desc->region.next); 779 acpi_ex_out_pointer("Next", obj_desc->region.next);
712 break; 780 break;
713 781
714
715 case ACPI_TYPE_POWER: 782 case ACPI_TYPE_POWER:
716 783
717 acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level); 784 acpi_ex_out_integer("system_level",
718 acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order); 785 obj_desc->power_resource.system_level);
719 acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify); 786 acpi_ex_out_integer("resource_order",
720 acpi_ex_out_pointer ("device_notify", obj_desc->power_resource.device_notify); 787 obj_desc->power_resource.resource_order);
788 acpi_ex_out_pointer("system_notify",
789 obj_desc->power_resource.system_notify);
790 acpi_ex_out_pointer("device_notify",
791 obj_desc->power_resource.device_notify);
721 break; 792 break;
722 793
723
724 case ACPI_TYPE_PROCESSOR: 794 case ACPI_TYPE_PROCESSOR:
725 795
726 acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id); 796 acpi_ex_out_integer("Processor ID",
727 acpi_ex_out_integer ("Length", obj_desc->processor.length); 797 obj_desc->processor.proc_id);
728 acpi_ex_out_address ("Address", (acpi_physical_address) obj_desc->processor.address); 798 acpi_ex_out_integer("Length", obj_desc->processor.length);
729 acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify); 799 acpi_ex_out_address("Address",
730 acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify); 800 (acpi_physical_address) obj_desc->processor.
731 acpi_ex_out_pointer ("Handler", obj_desc->processor.handler); 801 address);
802 acpi_ex_out_pointer("system_notify",
803 obj_desc->processor.system_notify);
804 acpi_ex_out_pointer("device_notify",
805 obj_desc->processor.device_notify);
806 acpi_ex_out_pointer("Handler", obj_desc->processor.handler);
732 break; 807 break;
733 808
734
735 case ACPI_TYPE_THERMAL: 809 case ACPI_TYPE_THERMAL:
736 810
737 acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify); 811 acpi_ex_out_pointer("system_notify",
738 acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify); 812 obj_desc->thermal_zone.system_notify);
739 acpi_ex_out_pointer ("Handler", obj_desc->thermal_zone.handler); 813 acpi_ex_out_pointer("device_notify",
814 obj_desc->thermal_zone.device_notify);
815 acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler);
740 break; 816 break;
741 817
742
743 case ACPI_TYPE_BUFFER_FIELD: 818 case ACPI_TYPE_BUFFER_FIELD:
744 case ACPI_TYPE_LOCAL_REGION_FIELD: 819 case ACPI_TYPE_LOCAL_REGION_FIELD:
745 case ACPI_TYPE_LOCAL_BANK_FIELD: 820 case ACPI_TYPE_LOCAL_BANK_FIELD:
746 case ACPI_TYPE_LOCAL_INDEX_FIELD: 821 case ACPI_TYPE_LOCAL_INDEX_FIELD:
747 822
748 acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags); 823 acpi_ex_out_integer("field_flags",
749 acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width); 824 obj_desc->common_field.field_flags);
750 acpi_ex_out_integer ("bit_length", obj_desc->common_field.bit_length); 825 acpi_ex_out_integer("access_byte_width",
751 acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset); 826 obj_desc->common_field.access_byte_width);
752 acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset); 827 acpi_ex_out_integer("bit_length",
753 acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node); 828 obj_desc->common_field.bit_length);
754 829 acpi_ex_out_integer("fld_bit_offset",
755 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 830 obj_desc->common_field.
831 start_field_bit_offset);
832 acpi_ex_out_integer("base_byte_offset",
833 obj_desc->common_field.base_byte_offset);
834 acpi_ex_out_pointer("parent_node", obj_desc->common_field.node);
835
836 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
756 case ACPI_TYPE_BUFFER_FIELD: 837 case ACPI_TYPE_BUFFER_FIELD:
757 acpi_ex_out_pointer ("buffer_obj", obj_desc->buffer_field.buffer_obj); 838 acpi_ex_out_pointer("buffer_obj",
839 obj_desc->buffer_field.buffer_obj);
758 break; 840 break;
759 841
760 case ACPI_TYPE_LOCAL_REGION_FIELD: 842 case ACPI_TYPE_LOCAL_REGION_FIELD:
761 acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj); 843 acpi_ex_out_pointer("region_obj",
844 obj_desc->field.region_obj);
762 break; 845 break;
763 846
764 case ACPI_TYPE_LOCAL_BANK_FIELD: 847 case ACPI_TYPE_LOCAL_BANK_FIELD:
765 acpi_ex_out_integer ("Value", obj_desc->bank_field.value); 848 acpi_ex_out_integer("Value",
766 acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj); 849 obj_desc->bank_field.value);
767 acpi_ex_out_pointer ("bank_obj", obj_desc->bank_field.bank_obj); 850 acpi_ex_out_pointer("region_obj",
851 obj_desc->bank_field.region_obj);
852 acpi_ex_out_pointer("bank_obj",
853 obj_desc->bank_field.bank_obj);
768 break; 854 break;
769 855
770 case ACPI_TYPE_LOCAL_INDEX_FIELD: 856 case ACPI_TYPE_LOCAL_INDEX_FIELD:
771 acpi_ex_out_integer ("Value", obj_desc->index_field.value); 857 acpi_ex_out_integer("Value",
772 acpi_ex_out_pointer ("Index", obj_desc->index_field.index_obj); 858 obj_desc->index_field.value);
773 acpi_ex_out_pointer ("Data", obj_desc->index_field.data_obj); 859 acpi_ex_out_pointer("Index",
860 obj_desc->index_field.index_obj);
861 acpi_ex_out_pointer("Data",
862 obj_desc->index_field.data_obj);
774 break; 863 break;
775 864
776 default: 865 default:
@@ -779,56 +868,52 @@ acpi_ex_dump_object_descriptor (
779 } 868 }
780 break; 869 break;
781 870
782
783 case ACPI_TYPE_LOCAL_REFERENCE: 871 case ACPI_TYPE_LOCAL_REFERENCE:
784 872
785 acpi_ex_out_integer ("target_type", obj_desc->reference.target_type); 873 acpi_ex_out_integer("target_type",
786 acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info ( 874 obj_desc->reference.target_type);
787 obj_desc->reference.opcode))->name); 875 acpi_ex_out_string("Opcode",
788 acpi_ex_out_integer ("Offset", obj_desc->reference.offset); 876 (acpi_ps_get_opcode_info
789 acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object); 877 (obj_desc->reference.opcode))->name);
790 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 878 acpi_ex_out_integer("Offset", obj_desc->reference.offset);
791 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 879 acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
792 880 acpi_ex_out_pointer("Node", obj_desc->reference.node);
793 if (obj_desc->reference.object) { 881 acpi_ex_out_pointer("Where", obj_desc->reference.where);
794 acpi_os_printf ("\nReferenced Object:\n");
795 acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
796 }
797 break;
798 882
883 acpi_ex_dump_reference(obj_desc);
884 break;
799 885
800 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: 886 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
801 887
802 acpi_ex_out_integer ("space_id", obj_desc->address_space.space_id); 888 acpi_ex_out_integer("space_id",
803 acpi_ex_out_pointer ("Next", obj_desc->address_space.next); 889 obj_desc->address_space.space_id);
804 acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list); 890 acpi_ex_out_pointer("Next", obj_desc->address_space.next);
805 acpi_ex_out_pointer ("Node", obj_desc->address_space.node); 891 acpi_ex_out_pointer("region_list",
806 acpi_ex_out_pointer ("Context", obj_desc->address_space.context); 892 obj_desc->address_space.region_list);
893 acpi_ex_out_pointer("Node", obj_desc->address_space.node);
894 acpi_ex_out_pointer("Context", obj_desc->address_space.context);
807 break; 895 break;
808 896
809
810 case ACPI_TYPE_LOCAL_NOTIFY: 897 case ACPI_TYPE_LOCAL_NOTIFY:
811 898
812 acpi_ex_out_pointer ("Node", obj_desc->notify.node); 899 acpi_ex_out_pointer("Node", obj_desc->notify.node);
813 acpi_ex_out_pointer ("Context", obj_desc->notify.context); 900 acpi_ex_out_pointer("Context", obj_desc->notify.context);
814 break; 901 break;
815 902
816
817 case ACPI_TYPE_LOCAL_ALIAS: 903 case ACPI_TYPE_LOCAL_ALIAS:
818 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 904 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
819 case ACPI_TYPE_LOCAL_EXTRA: 905 case ACPI_TYPE_LOCAL_EXTRA:
820 case ACPI_TYPE_LOCAL_DATA: 906 case ACPI_TYPE_LOCAL_DATA:
821 default: 907 default:
822 908
823 acpi_os_printf ( 909 acpi_os_printf
824 "ex_dump_object_descriptor: Display not implemented for object type %s\n", 910 ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
825 acpi_ut_get_object_type_name (obj_desc)); 911 acpi_ut_get_object_type_name(obj_desc));
826 break; 912 break;
827 } 913 }
828 914
829 return_VOID; 915 return_VOID;
830} 916}
831 917
832#endif /* ACPI_FUTURE_USAGE */ 918#endif /* ACPI_FUTURE_USAGE */
833#endif 919#endif
834
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index 22c8fa480f60..ab1ba399aa28 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -41,15 +41,12 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 45#include <acpi/acdispat.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exfield") 49ACPI_MODULE_NAME("exfield")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -65,64 +62,70 @@
65 * Buffer, depending on the size of the field. 62 * Buffer, depending on the size of the field.
66 * 63 *
67 ******************************************************************************/ 64 ******************************************************************************/
68
69acpi_status 65acpi_status
70acpi_ex_read_data_from_field ( 66acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
71 struct acpi_walk_state *walk_state, 67 union acpi_operand_object *obj_desc,
72 union acpi_operand_object *obj_desc, 68 union acpi_operand_object **ret_buffer_desc)
73 union acpi_operand_object **ret_buffer_desc)
74{ 69{
75 acpi_status status; 70 acpi_status status;
76 union acpi_operand_object *buffer_desc; 71 union acpi_operand_object *buffer_desc;
77 acpi_size length; 72 acpi_size length;
78 void *buffer; 73 void *buffer;
79 u8 locked; 74 u8 locked;
80
81
82 ACPI_FUNCTION_TRACE_PTR ("ex_read_data_from_field", obj_desc);
83 75
76 ACPI_FUNCTION_TRACE_PTR("ex_read_data_from_field", obj_desc);
84 77
85 /* Parameter validation */ 78 /* Parameter validation */
86 79
87 if (!obj_desc) { 80 if (!obj_desc) {
88 return_ACPI_STATUS (AE_AML_NO_OPERAND); 81 return_ACPI_STATUS(AE_AML_NO_OPERAND);
82 }
83 if (!ret_buffer_desc) {
84 return_ACPI_STATUS(AE_BAD_PARAMETER);
89 } 85 }
90 86
91 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 87 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
92 /* 88 /*
93 * If the buffer_field arguments have not been previously evaluated, 89 * If the buffer_field arguments have not been previously evaluated,
94 * evaluate them now and save the results. 90 * evaluate them now and save the results.
95 */ 91 */
96 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 92 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
97 status = acpi_ds_get_buffer_field_arguments (obj_desc); 93 status = acpi_ds_get_buffer_field_arguments(obj_desc);
98 if (ACPI_FAILURE (status)) { 94 if (ACPI_FAILURE(status)) {
99 return_ACPI_STATUS (status); 95 return_ACPI_STATUS(status);
100 } 96 }
101 } 97 }
102 } 98 } else
103 else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) && 99 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD)
104 (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { 100 && (obj_desc->field.region_obj->region.space_id ==
101 ACPI_ADR_SPACE_SMBUS)) {
105 /* 102 /*
106 * This is an SMBus read. We must create a buffer to hold the data 103 * This is an SMBus read. We must create a buffer to hold the data
107 * and directly access the region handler. 104 * and directly access the region handler.
108 */ 105 */
109 buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); 106 buffer_desc =
107 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
110 if (!buffer_desc) { 108 if (!buffer_desc) {
111 return_ACPI_STATUS (AE_NO_MEMORY); 109 return_ACPI_STATUS(AE_NO_MEMORY);
112 } 110 }
113 111
114 /* Lock entire transaction if requested */ 112 /* Lock entire transaction if requested */
115 113
116 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); 114 locked =
115 acpi_ex_acquire_global_lock(obj_desc->common_field.
116 field_flags);
117 117
118 /* 118 /*
119 * Perform the read. 119 * Perform the read.
120 * Note: Smbus protocol value is passed in upper 16-bits of Function 120 * Note: Smbus protocol value is passed in upper 16-bits of Function
121 */ 121 */
122 status = acpi_ex_access_region (obj_desc, 0, 122 status = acpi_ex_access_region(obj_desc, 0,
123 ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer), 123 ACPI_CAST_PTR(acpi_integer,
124 ACPI_READ | (obj_desc->field.attribute << 16)); 124 buffer_desc->
125 acpi_ex_release_global_lock (locked); 125 buffer.pointer),
126 ACPI_READ | (obj_desc->field.
127 attribute << 16));
128 acpi_ex_release_global_lock(locked);
126 goto exit; 129 goto exit;
127 } 130 }
128 131
@@ -136,22 +139,22 @@ acpi_ex_read_data_from_field (
136 * 139 *
137 * Note: Field.length is in bits. 140 * Note: Field.length is in bits.
138 */ 141 */
139 length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length); 142 length =
143 (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
140 if (length > acpi_gbl_integer_byte_width) { 144 if (length > acpi_gbl_integer_byte_width) {
141 /* Field is too large for an Integer, create a Buffer instead */ 145 /* Field is too large for an Integer, create a Buffer instead */
142 146
143 buffer_desc = acpi_ut_create_buffer_object (length); 147 buffer_desc = acpi_ut_create_buffer_object(length);
144 if (!buffer_desc) { 148 if (!buffer_desc) {
145 return_ACPI_STATUS (AE_NO_MEMORY); 149 return_ACPI_STATUS(AE_NO_MEMORY);
146 } 150 }
147 buffer = buffer_desc->buffer.pointer; 151 buffer = buffer_desc->buffer.pointer;
148 } 152 } else {
149 else {
150 /* Field will fit within an Integer (normal case) */ 153 /* Field will fit within an Integer (normal case) */
151 154
152 buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 155 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
153 if (!buffer_desc) { 156 if (!buffer_desc) {
154 return_ACPI_STATUS (AE_NO_MEMORY); 157 return_ACPI_STATUS(AE_NO_MEMORY);
155 } 158 }
156 159
157 length = acpi_gbl_integer_byte_width; 160 length = acpi_gbl_integer_byte_width;
@@ -159,37 +162,36 @@ acpi_ex_read_data_from_field (
159 buffer = &buffer_desc->integer.value; 162 buffer = &buffer_desc->integer.value;
160 } 163 }
161 164
162 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 165 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
163 "field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n", 166 "field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n",
164 obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, (u32) length)); 167 obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer,
165 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 168 (u32) length));
166 "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
167 obj_desc->common_field.bit_length, 170 "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n",
168 obj_desc->common_field.start_field_bit_offset, 171 obj_desc->common_field.bit_length,
169 obj_desc->common_field.base_byte_offset)); 172 obj_desc->common_field.start_field_bit_offset,
173 obj_desc->common_field.base_byte_offset));
170 174
171 /* Lock entire transaction if requested */ 175 /* Lock entire transaction if requested */
172 176
173 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); 177 locked =
178 acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
174 179
175 /* Read from the field */ 180 /* Read from the field */
176 181
177 status = acpi_ex_extract_from_field (obj_desc, buffer, (u32) length); 182 status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length);
178 acpi_ex_release_global_lock (locked); 183 acpi_ex_release_global_lock(locked);
179 184
180 185 exit:
181exit: 186 if (ACPI_FAILURE(status)) {
182 if (ACPI_FAILURE (status)) { 187 acpi_ut_remove_reference(buffer_desc);
183 acpi_ut_remove_reference (buffer_desc); 188 } else {
184 }
185 else if (ret_buffer_desc) {
186 *ret_buffer_desc = buffer_desc; 189 *ret_buffer_desc = buffer_desc;
187 } 190 }
188 191
189 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
190} 193}
191 194
192
193/******************************************************************************* 195/*******************************************************************************
194 * 196 *
195 * FUNCTION: acpi_ex_write_data_to_field 197 * FUNCTION: acpi_ex_write_data_to_field
@@ -205,97 +207,96 @@ exit:
205 ******************************************************************************/ 207 ******************************************************************************/
206 208
207acpi_status 209acpi_status
208acpi_ex_write_data_to_field ( 210acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
209 union acpi_operand_object *source_desc, 211 union acpi_operand_object *obj_desc,
210 union acpi_operand_object *obj_desc, 212 union acpi_operand_object **result_desc)
211 union acpi_operand_object **result_desc)
212{ 213{
213 acpi_status status; 214 acpi_status status;
214 u32 length; 215 u32 length;
215 u32 required_length; 216 u32 required_length;
216 void *buffer; 217 void *buffer;
217 void *new_buffer; 218 void *new_buffer;
218 u8 locked; 219 u8 locked;
219 union acpi_operand_object *buffer_desc; 220 union acpi_operand_object *buffer_desc;
220
221
222 ACPI_FUNCTION_TRACE_PTR ("ex_write_data_to_field", obj_desc);
223 221
222 ACPI_FUNCTION_TRACE_PTR("ex_write_data_to_field", obj_desc);
224 223
225 /* Parameter validation */ 224 /* Parameter validation */
226 225
227 if (!source_desc || !obj_desc) { 226 if (!source_desc || !obj_desc) {
228 return_ACPI_STATUS (AE_AML_NO_OPERAND); 227 return_ACPI_STATUS(AE_AML_NO_OPERAND);
229 } 228 }
230 229
231 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 230 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
232 /* 231 /*
233 * If the buffer_field arguments have not been previously evaluated, 232 * If the buffer_field arguments have not been previously evaluated,
234 * evaluate them now and save the results. 233 * evaluate them now and save the results.
235 */ 234 */
236 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 235 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
237 status = acpi_ds_get_buffer_field_arguments (obj_desc); 236 status = acpi_ds_get_buffer_field_arguments(obj_desc);
238 if (ACPI_FAILURE (status)) { 237 if (ACPI_FAILURE(status)) {
239 return_ACPI_STATUS (status); 238 return_ACPI_STATUS(status);
240 } 239 }
241 } 240 }
242 } 241 } else
243 else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) && 242 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD)
244 (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { 243 && (obj_desc->field.region_obj->region.space_id ==
244 ACPI_ADR_SPACE_SMBUS)) {
245 /* 245 /*
246 * This is an SMBus write. We will bypass the entire field mechanism 246 * This is an SMBus write. We will bypass the entire field mechanism
247 * and handoff the buffer directly to the handler. 247 * and handoff the buffer directly to the handler.
248 * 248 *
249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). 249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
250 */ 250 */
251 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { 251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
252 ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n", 252 ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc)));
253 acpi_ut_get_object_type_name (source_desc)));
254 253
255 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 254 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
256 } 255 }
257 256
258 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 257 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
259 ACPI_REPORT_ERROR (( 258 ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
260 "SMBus write requires Buffer of length %X, found length %X\n",
261 ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
262 259
263 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); 260 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
264 } 261 }
265 262
266 buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); 263 buffer_desc =
264 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
267 if (!buffer_desc) { 265 if (!buffer_desc) {
268 return_ACPI_STATUS (AE_NO_MEMORY); 266 return_ACPI_STATUS(AE_NO_MEMORY);
269 } 267 }
270 268
271 buffer = buffer_desc->buffer.pointer; 269 buffer = buffer_desc->buffer.pointer;
272 ACPI_MEMCPY (buffer, source_desc->buffer.pointer, 270 ACPI_MEMCPY(buffer, source_desc->buffer.pointer,
273 ACPI_SMBUS_BUFFER_SIZE); 271 ACPI_SMBUS_BUFFER_SIZE);
274 272
275 /* Lock entire transaction if requested */ 273 /* Lock entire transaction if requested */
276 274
277 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); 275 locked =
276 acpi_ex_acquire_global_lock(obj_desc->common_field.
277 field_flags);
278 278
279 /* 279 /*
280 * Perform the write (returns status and perhaps data in the 280 * Perform the write (returns status and perhaps data in the
281 * same buffer) 281 * same buffer)
282 * Note: SMBus protocol type is passed in upper 16-bits of Function. 282 * Note: SMBus protocol type is passed in upper 16-bits of Function.
283 */ 283 */
284 status = acpi_ex_access_region (obj_desc, 0, 284 status = acpi_ex_access_region(obj_desc, 0,
285 (acpi_integer *) buffer, 285 (acpi_integer *) buffer,
286 ACPI_WRITE | (obj_desc->field.attribute << 16)); 286 ACPI_WRITE | (obj_desc->field.
287 acpi_ex_release_global_lock (locked); 287 attribute << 16));
288 acpi_ex_release_global_lock(locked);
288 289
289 *result_desc = buffer_desc; 290 *result_desc = buffer_desc;
290 return_ACPI_STATUS (status); 291 return_ACPI_STATUS(status);
291 } 292 }
292 293
293 /* Get a pointer to the data to be written */ 294 /* Get a pointer to the data to be written */
294 295
295 switch (ACPI_GET_OBJECT_TYPE (source_desc)) { 296 switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
296 case ACPI_TYPE_INTEGER: 297 case ACPI_TYPE_INTEGER:
297 buffer = &source_desc->integer.value; 298 buffer = &source_desc->integer.value;
298 length = sizeof (source_desc->integer.value); 299 length = sizeof(source_desc->integer.value);
299 break; 300 break;
300 301
301 case ACPI_TYPE_BUFFER: 302 case ACPI_TYPE_BUFFER:
@@ -309,7 +310,7 @@ acpi_ex_write_data_to_field (
309 break; 310 break;
310 311
311 default: 312 default:
312 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 313 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
313 } 314 }
314 315
315 /* 316 /*
@@ -319,15 +320,15 @@ acpi_ex_write_data_to_field (
319 * the ACPI specification. 320 * the ACPI specification.
320 */ 321 */
321 new_buffer = NULL; 322 new_buffer = NULL;
322 required_length = ACPI_ROUND_BITS_UP_TO_BYTES ( 323 required_length =
323 obj_desc->common_field.bit_length); 324 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
324 325
325 if (length < required_length) { 326 if (length < required_length) {
326 /* We need to create a new buffer */ 327 /* We need to create a new buffer */
327 328
328 new_buffer = ACPI_MEM_CALLOCATE (required_length); 329 new_buffer = ACPI_MEM_CALLOCATE(required_length);
329 if (!new_buffer) { 330 if (!new_buffer) {
330 return_ACPI_STATUS (AE_NO_MEMORY); 331 return_ACPI_STATUS(AE_NO_MEMORY);
331 } 332 }
332 333
333 /* 334 /*
@@ -335,40 +336,42 @@ acpi_ex_write_data_to_field (
335 * at Byte zero. All unused (upper) bytes of the 336 * at Byte zero. All unused (upper) bytes of the
336 * buffer will be 0. 337 * buffer will be 0.
337 */ 338 */
338 ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length); 339 ACPI_MEMCPY((char *)new_buffer, (char *)buffer, length);
339 buffer = new_buffer; 340 buffer = new_buffer;
340 length = required_length; 341 length = required_length;
341 } 342 }
342 343
343 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 344 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
344 "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n", 345 "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
345 source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)), 346 source_desc,
346 ACPI_GET_OBJECT_TYPE (source_desc), buffer, length)); 347 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
347 348 (source_desc)),
348 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 349 ACPI_GET_OBJECT_TYPE(source_desc), buffer, length));
349 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n", 350
350 obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)), 351 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
351 ACPI_GET_OBJECT_TYPE (obj_desc), 352 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
352 obj_desc->common_field.bit_length, 353 obj_desc,
353 obj_desc->common_field.start_field_bit_offset, 354 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)),
354 obj_desc->common_field.base_byte_offset)); 355 ACPI_GET_OBJECT_TYPE(obj_desc),
356 obj_desc->common_field.bit_length,
357 obj_desc->common_field.start_field_bit_offset,
358 obj_desc->common_field.base_byte_offset));
355 359
356 /* Lock entire transaction if requested */ 360 /* Lock entire transaction if requested */
357 361
358 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); 362 locked =
363 acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
359 364
360 /* Write to the field */ 365 /* Write to the field */
361 366
362 status = acpi_ex_insert_into_field (obj_desc, buffer, length); 367 status = acpi_ex_insert_into_field(obj_desc, buffer, length);
363 acpi_ex_release_global_lock (locked); 368 acpi_ex_release_global_lock(locked);
364 369
365 /* Free temporary buffer if we used one */ 370 /* Free temporary buffer if we used one */
366 371
367 if (new_buffer) { 372 if (new_buffer) {
368 ACPI_MEM_FREE (new_buffer); 373 ACPI_MEM_FREE(new_buffer);
369 } 374 }
370 375
371 return_ACPI_STATUS (status); 376 return_ACPI_STATUS(status);
372} 377}
373
374
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 3c2f89e00f78..ba6e08843c29 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -41,36 +41,28 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acevents.h> 47#include <acpi/acevents.h>
49#include <acpi/acdispat.h> 48#include <acpi/acdispat.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exfldio") 51ACPI_MODULE_NAME("exfldio")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static acpi_status 54static acpi_status
58acpi_ex_field_datum_io ( 55acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
59 union acpi_operand_object *obj_desc, 56 u32 field_datum_byte_offset,
60 u32 field_datum_byte_offset, 57 acpi_integer * value, u32 read_write);
61 acpi_integer *value,
62 u32 read_write);
63 58
64static u8 59static u8
65acpi_ex_register_overflow ( 60acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
66 union acpi_operand_object *obj_desc, 61 acpi_integer value);
67 acpi_integer value);
68 62
69static acpi_status 63static acpi_status
70acpi_ex_setup_region ( 64acpi_ex_setup_region(union acpi_operand_object *obj_desc,
71 union acpi_operand_object *obj_desc, 65 u32 field_datum_byte_offset);
72 u32 field_datum_byte_offset);
73
74 66
75/******************************************************************************* 67/*******************************************************************************
76 * 68 *
@@ -89,27 +81,25 @@ acpi_ex_setup_region (
89 ******************************************************************************/ 81 ******************************************************************************/
90 82
91static acpi_status 83static acpi_status
92acpi_ex_setup_region ( 84acpi_ex_setup_region(union acpi_operand_object *obj_desc,
93 union acpi_operand_object *obj_desc, 85 u32 field_datum_byte_offset)
94 u32 field_datum_byte_offset)
95{ 86{
96 acpi_status status = AE_OK; 87 acpi_status status = AE_OK;
97 union acpi_operand_object *rgn_desc; 88 union acpi_operand_object *rgn_desc;
98
99
100 ACPI_FUNCTION_TRACE_U32 ("ex_setup_region", field_datum_byte_offset);
101 89
90 ACPI_FUNCTION_TRACE_U32("ex_setup_region", field_datum_byte_offset);
102 91
103 rgn_desc = obj_desc->common_field.region_obj; 92 rgn_desc = obj_desc->common_field.region_obj;
104 93
105 /* We must have a valid region */ 94 /* We must have a valid region */
106 95
107 if (ACPI_GET_OBJECT_TYPE (rgn_desc) != ACPI_TYPE_REGION) { 96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X (%s)\n", 97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
109 ACPI_GET_OBJECT_TYPE (rgn_desc), 98 "Needed Region, found type %X (%s)\n",
110 acpi_ut_get_object_type_name (rgn_desc))); 99 ACPI_GET_OBJECT_TYPE(rgn_desc),
100 acpi_ut_get_object_type_name(rgn_desc)));
111 101
112 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 102 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
113 } 103 }
114 104
115 /* 105 /*
@@ -117,26 +107,25 @@ acpi_ex_setup_region (
117 * evaluate them now and save the results. 107 * evaluate them now and save the results.
118 */ 108 */
119 if (!(rgn_desc->common.flags & AOPOBJ_DATA_VALID)) { 109 if (!(rgn_desc->common.flags & AOPOBJ_DATA_VALID)) {
120 status = acpi_ds_get_region_arguments (rgn_desc); 110 status = acpi_ds_get_region_arguments(rgn_desc);
121 if (ACPI_FAILURE (status)) { 111 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS (status); 112 return_ACPI_STATUS(status);
123 } 113 }
124 } 114 }
125 115
126 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) { 116 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) {
127 /* SMBus has a non-linear address space */ 117 /* SMBus has a non-linear address space */
128 118
129 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
130 } 120 }
131
132#ifdef ACPI_UNDER_DEVELOPMENT 121#ifdef ACPI_UNDER_DEVELOPMENT
133 /* 122 /*
134 * If the Field access is any_acc, we can now compute the optimal 123 * If the Field access is any_acc, we can now compute the optimal
135 * access (because we know know the length of the parent region) 124 * access (because we know know the length of the parent region)
136 */ 125 */
137 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 126 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
138 if (ACPI_FAILURE (status)) { 127 if (ACPI_FAILURE(status)) {
139 return_ACPI_STATUS (status); 128 return_ACPI_STATUS(status);
140 } 129 }
141 } 130 }
142#endif 131#endif
@@ -147,56 +136,64 @@ acpi_ex_setup_region (
147 * (Region length is specified in bytes) 136 * (Region length is specified in bytes)
148 */ 137 */
149 if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset + 138 if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
150 field_datum_byte_offset + 139 field_datum_byte_offset +
151 obj_desc->common_field.access_byte_width)) { 140 obj_desc->common_field.
141 access_byte_width)) {
152 if (acpi_gbl_enable_interpreter_slack) { 142 if (acpi_gbl_enable_interpreter_slack) {
153 /* 143 /*
154 * Slack mode only: We will go ahead and allow access to this 144 * Slack mode only: We will go ahead and allow access to this
155 * field if it is within the region length rounded up to the next 145 * field if it is within the region length rounded up to the next
156 * access width boundary. 146 * access width boundary.
157 */ 147 */
158 if (ACPI_ROUND_UP (rgn_desc->region.length, 148 if (ACPI_ROUND_UP(rgn_desc->region.length,
159 obj_desc->common_field.access_byte_width) >= 149 obj_desc->common_field.
160 (obj_desc->common_field.base_byte_offset + 150 access_byte_width) >=
161 (acpi_native_uint) obj_desc->common_field.access_byte_width + 151 (obj_desc->common_field.base_byte_offset +
162 field_datum_byte_offset)) { 152 (acpi_native_uint) obj_desc->common_field.
163 return_ACPI_STATUS (AE_OK); 153 access_byte_width + field_datum_byte_offset)) {
154 return_ACPI_STATUS(AE_OK);
164 } 155 }
165 } 156 }
166 157
167 if (rgn_desc->region.length < obj_desc->common_field.access_byte_width) { 158 if (rgn_desc->region.length <
159 obj_desc->common_field.access_byte_width) {
168 /* 160 /*
169 * This is the case where the access_type (acc_word, etc.) is wider 161 * This is the case where the access_type (acc_word, etc.) is wider
170 * than the region itself. For example, a region of length one 162 * than the region itself. For example, a region of length one
171 * byte, and a field with Dword access specified. 163 * byte, and a field with Dword access specified.
172 */ 164 */
173 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
174 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", 166 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
175 acpi_ut_get_node_name (obj_desc->common_field.node), 167 acpi_ut_get_node_name(obj_desc->
176 obj_desc->common_field.access_byte_width, 168 common_field.
177 acpi_ut_get_node_name (rgn_desc->region.node), 169 node),
178 rgn_desc->region.length)); 170 obj_desc->common_field.
171 access_byte_width,
172 acpi_ut_get_node_name(rgn_desc->
173 region.node),
174 rgn_desc->region.length));
179 } 175 }
180 176
181 /* 177 /*
182 * Offset rounded up to next multiple of field width 178 * Offset rounded up to next multiple of field width
183 * exceeds region length, indicate an error 179 * exceeds region length, indicate an error
184 */ 180 */
185 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 181 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
186 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", 182 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n",
187 acpi_ut_get_node_name (obj_desc->common_field.node), 183 acpi_ut_get_node_name(obj_desc->common_field.
188 obj_desc->common_field.base_byte_offset, 184 node),
189 field_datum_byte_offset, obj_desc->common_field.access_byte_width, 185 obj_desc->common_field.base_byte_offset,
190 acpi_ut_get_node_name (rgn_desc->region.node), 186 field_datum_byte_offset,
191 rgn_desc->region.length)); 187 obj_desc->common_field.access_byte_width,
192 188 acpi_ut_get_node_name(rgn_desc->region.node),
193 return_ACPI_STATUS (AE_AML_REGION_LIMIT); 189 rgn_desc->region.length));
190
191 return_ACPI_STATUS(AE_AML_REGION_LIMIT);
194 } 192 }
195 193
196 return_ACPI_STATUS (AE_OK); 194 return_ACPI_STATUS(AE_OK);
197} 195}
198 196
199
200/******************************************************************************* 197/*******************************************************************************
201 * 198 *
202 * FUNCTION: acpi_ex_access_region 199 * FUNCTION: acpi_ex_access_region
@@ -216,27 +213,23 @@ acpi_ex_setup_region (
216 ******************************************************************************/ 213 ******************************************************************************/
217 214
218acpi_status 215acpi_status
219acpi_ex_access_region ( 216acpi_ex_access_region(union acpi_operand_object *obj_desc,
220 union acpi_operand_object *obj_desc, 217 u32 field_datum_byte_offset,
221 u32 field_datum_byte_offset, 218 acpi_integer * value, u32 function)
222 acpi_integer *value,
223 u32 function)
224{ 219{
225 acpi_status status; 220 acpi_status status;
226 union acpi_operand_object *rgn_desc; 221 union acpi_operand_object *rgn_desc;
227 acpi_physical_address address; 222 acpi_physical_address address;
228
229
230 ACPI_FUNCTION_TRACE ("ex_access_region");
231 223
224 ACPI_FUNCTION_TRACE("ex_access_region");
232 225
233 /* 226 /*
234 * Ensure that the region operands are fully evaluated and verify 227 * Ensure that the region operands are fully evaluated and verify
235 * the validity of the request 228 * the validity of the request
236 */ 229 */
237 status = acpi_ex_setup_region (obj_desc, field_datum_byte_offset); 230 status = acpi_ex_setup_region(obj_desc, field_datum_byte_offset);
238 if (ACPI_FAILURE (status)) { 231 if (ACPI_FAILURE(status)) {
239 return_ACPI_STATUS (status); 232 return_ACPI_STATUS(status);
240 } 233 }
241 234
242 /* 235 /*
@@ -248,50 +241,53 @@ acpi_ex_access_region (
248 */ 241 */
249 rgn_desc = obj_desc->common_field.region_obj; 242 rgn_desc = obj_desc->common_field.region_obj;
250 address = rgn_desc->region.address + 243 address = rgn_desc->region.address +
251 obj_desc->common_field.base_byte_offset + 244 obj_desc->common_field.base_byte_offset + field_datum_byte_offset;
252 field_datum_byte_offset;
253 245
254 if ((function & ACPI_IO_MASK) == ACPI_READ) { 246 if ((function & ACPI_IO_MASK) == ACPI_READ) {
255 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); 247 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[READ]"));
256 } 248 } else {
257 else { 249 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[WRITE]"));
258 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
259 } 250 }
260 251
261 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, 252 ACPI_DEBUG_PRINT_RAW((ACPI_DB_BFIELD,
262 " Region [%s:%X], Width %X, byte_base %X, Offset %X at %8.8X%8.8X\n", 253 " Region [%s:%X], Width %X, byte_base %X, Offset %X at %8.8X%8.8X\n",
263 acpi_ut_get_region_name (rgn_desc->region.space_id), 254 acpi_ut_get_region_name(rgn_desc->region.
264 rgn_desc->region.space_id, 255 space_id),
265 obj_desc->common_field.access_byte_width, 256 rgn_desc->region.space_id,
266 obj_desc->common_field.base_byte_offset, 257 obj_desc->common_field.access_byte_width,
267 field_datum_byte_offset, 258 obj_desc->common_field.base_byte_offset,
268 ACPI_FORMAT_UINT64 (address))); 259 field_datum_byte_offset,
260 ACPI_FORMAT_UINT64(address)));
269 261
270 /* Invoke the appropriate address_space/op_region handler */ 262 /* Invoke the appropriate address_space/op_region handler */
271 263
272 status = acpi_ev_address_space_dispatch (rgn_desc, function, 264 status = acpi_ev_address_space_dispatch(rgn_desc, function,
273 address, 265 address,
274 ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value); 266 ACPI_MUL_8(obj_desc->
267 common_field.
268 access_byte_width),
269 value);
275 270
276 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
277 if (status == AE_NOT_IMPLEMENTED) { 272 if (status == AE_NOT_IMPLEMENTED) {
278 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 273 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
279 "Region %s(%X) not implemented\n", 274 "Region %s(%X) not implemented\n",
280 acpi_ut_get_region_name (rgn_desc->region.space_id), 275 acpi_ut_get_region_name(rgn_desc->
281 rgn_desc->region.space_id)); 276 region.
282 } 277 space_id),
283 else if (status == AE_NOT_EXIST) { 278 rgn_desc->region.space_id));
284 ACPI_REPORT_ERROR (( 279 } else if (status == AE_NOT_EXIST) {
285 "Region %s(%X) has no handler\n", 280 ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n",
286 acpi_ut_get_region_name (rgn_desc->region.space_id), 281 acpi_ut_get_region_name(rgn_desc->
287 rgn_desc->region.space_id)); 282 region.
283 space_id),
284 rgn_desc->region.space_id));
288 } 285 }
289 } 286 }
290 287
291 return_ACPI_STATUS (status); 288 return_ACPI_STATUS(status);
292} 289}
293 290
294
295/******************************************************************************* 291/*******************************************************************************
296 * 292 *
297 * FUNCTION: acpi_ex_register_overflow 293 * FUNCTION: acpi_ex_register_overflow
@@ -310,9 +306,8 @@ acpi_ex_access_region (
310 ******************************************************************************/ 306 ******************************************************************************/
311 307
312static u8 308static u8
313acpi_ex_register_overflow ( 309acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
314 union acpi_operand_object *obj_desc, 310 acpi_integer value)
315 acpi_integer value)
316{ 311{
317 312
318 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 313 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
@@ -336,7 +331,6 @@ acpi_ex_register_overflow (
336 return (FALSE); 331 return (FALSE);
337} 332}
338 333
339
340/******************************************************************************* 334/*******************************************************************************
341 * 335 *
342 * FUNCTION: acpi_ex_field_datum_io 336 * FUNCTION: acpi_ex_field_datum_io
@@ -356,18 +350,14 @@ acpi_ex_register_overflow (
356 ******************************************************************************/ 350 ******************************************************************************/
357 351
358static acpi_status 352static acpi_status
359acpi_ex_field_datum_io ( 353acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
360 union acpi_operand_object *obj_desc, 354 u32 field_datum_byte_offset,
361 u32 field_datum_byte_offset, 355 acpi_integer * value, u32 read_write)
362 acpi_integer *value,
363 u32 read_write)
364{ 356{
365 acpi_status status; 357 acpi_status status;
366 acpi_integer local_value; 358 acpi_integer local_value;
367
368
369 ACPI_FUNCTION_TRACE_U32 ("ex_field_datum_io", field_datum_byte_offset);
370 359
360 ACPI_FUNCTION_TRACE_U32("ex_field_datum_io", field_datum_byte_offset);
371 361
372 if (read_write == ACPI_READ) { 362 if (read_write == ACPI_READ) {
373 if (!value) { 363 if (!value) {
@@ -392,16 +382,16 @@ acpi_ex_field_datum_io (
392 * index_field - Write to an Index Register, then read/write from/to a 382 * index_field - Write to an Index Register, then read/write from/to a
393 * Data Register 383 * Data Register
394 */ 384 */
395 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 385 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
396 case ACPI_TYPE_BUFFER_FIELD: 386 case ACPI_TYPE_BUFFER_FIELD:
397 /* 387 /*
398 * If the buffer_field arguments have not been previously evaluated, 388 * If the buffer_field arguments have not been previously evaluated,
399 * evaluate them now and save the results. 389 * evaluate them now and save the results.
400 */ 390 */
401 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 391 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
402 status = acpi_ds_get_buffer_field_arguments (obj_desc); 392 status = acpi_ds_get_buffer_field_arguments(obj_desc);
403 if (ACPI_FAILURE (status)) { 393 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS (status); 394 return_ACPI_STATUS(status);
405 } 395 }
406 } 396 }
407 397
@@ -410,47 +400,50 @@ acpi_ex_field_datum_io (
410 * Copy the data from the source buffer. 400 * Copy the data from the source buffer.
411 * Length is the field width in bytes. 401 * Length is the field width in bytes.
412 */ 402 */
413 ACPI_MEMCPY (value, 403 ACPI_MEMCPY(value,
414 (obj_desc->buffer_field.buffer_obj)->buffer.pointer + 404 (obj_desc->buffer_field.buffer_obj)->buffer.
415 obj_desc->buffer_field.base_byte_offset + 405 pointer +
416 field_datum_byte_offset, 406 obj_desc->buffer_field.base_byte_offset +
417 obj_desc->common_field.access_byte_width); 407 field_datum_byte_offset,
418 } 408 obj_desc->common_field.access_byte_width);
419 else { 409 } else {
420 /* 410 /*
421 * Copy the data to the target buffer. 411 * Copy the data to the target buffer.
422 * Length is the field width in bytes. 412 * Length is the field width in bytes.
423 */ 413 */
424 ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer + 414 ACPI_MEMCPY((obj_desc->buffer_field.buffer_obj)->buffer.
425 obj_desc->buffer_field.base_byte_offset + 415 pointer +
426 field_datum_byte_offset, 416 obj_desc->buffer_field.base_byte_offset +
427 value, obj_desc->common_field.access_byte_width); 417 field_datum_byte_offset, value,
418 obj_desc->common_field.access_byte_width);
428 } 419 }
429 420
430 status = AE_OK; 421 status = AE_OK;
431 break; 422 break;
432 423
433
434 case ACPI_TYPE_LOCAL_BANK_FIELD: 424 case ACPI_TYPE_LOCAL_BANK_FIELD:
435 425
436 /* 426 /*
437 * Ensure that the bank_value is not beyond the capacity of 427 * Ensure that the bank_value is not beyond the capacity of
438 * the register 428 * the register
439 */ 429 */
440 if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj, 430 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
441 (acpi_integer) obj_desc->bank_field.value)) { 431 (acpi_integer) obj_desc->
442 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); 432 bank_field.value)) {
433 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
443 } 434 }
444 435
445 /* 436 /*
446 * For bank_fields, we must write the bank_value to the bank_register 437 * For bank_fields, we must write the bank_value to the bank_register
447 * (itself a region_field) before we can access the data. 438 * (itself a region_field) before we can access the data.
448 */ 439 */
449 status = acpi_ex_insert_into_field (obj_desc->bank_field.bank_obj, 440 status =
450 &obj_desc->bank_field.value, 441 acpi_ex_insert_into_field(obj_desc->bank_field.bank_obj,
451 sizeof (obj_desc->bank_field.value)); 442 &obj_desc->bank_field.value,
452 if (ACPI_FAILURE (status)) { 443 sizeof(obj_desc->bank_field.
453 return_ACPI_STATUS (status); 444 value));
445 if (ACPI_FAILURE(status)) {
446 return_ACPI_STATUS(status);
454 } 447 }
455 448
456 /* 449 /*
@@ -460,90 +453,92 @@ acpi_ex_field_datum_io (
460 453
461 /*lint -fallthrough */ 454 /*lint -fallthrough */
462 455
463
464 case ACPI_TYPE_LOCAL_REGION_FIELD: 456 case ACPI_TYPE_LOCAL_REGION_FIELD:
465 /* 457 /*
466 * For simple region_fields, we just directly access the owning 458 * For simple region_fields, we just directly access the owning
467 * Operation Region. 459 * Operation Region.
468 */ 460 */
469 status = acpi_ex_access_region (obj_desc, field_datum_byte_offset, value, 461 status =
470 read_write); 462 acpi_ex_access_region(obj_desc, field_datum_byte_offset,
463 value, read_write);
471 break; 464 break;
472 465
473
474 case ACPI_TYPE_LOCAL_INDEX_FIELD: 466 case ACPI_TYPE_LOCAL_INDEX_FIELD:
475 467
476
477 /* 468 /*
478 * Ensure that the index_value is not beyond the capacity of 469 * Ensure that the index_value is not beyond the capacity of
479 * the register 470 * the register
480 */ 471 */
481 if (acpi_ex_register_overflow (obj_desc->index_field.index_obj, 472 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
482 (acpi_integer) obj_desc->index_field.value)) { 473 (acpi_integer) obj_desc->
483 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); 474 index_field.value)) {
475 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
484 } 476 }
485 477
486 /* Write the index value to the index_register (itself a region_field) */ 478 /* Write the index value to the index_register (itself a region_field) */
487 479
488 field_datum_byte_offset += obj_desc->index_field.value; 480 field_datum_byte_offset += obj_desc->index_field.value;
489 481
490 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 482 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
491 "Write to Index Register: Value %8.8X\n", 483 "Write to Index Register: Value %8.8X\n",
492 field_datum_byte_offset)); 484 field_datum_byte_offset));
493 485
494 status = acpi_ex_insert_into_field (obj_desc->index_field.index_obj, 486 status =
495 &field_datum_byte_offset, 487 acpi_ex_insert_into_field(obj_desc->index_field.index_obj,
496 sizeof (field_datum_byte_offset)); 488 &field_datum_byte_offset,
497 if (ACPI_FAILURE (status)) { 489 sizeof(field_datum_byte_offset));
498 return_ACPI_STATUS (status); 490 if (ACPI_FAILURE(status)) {
491 return_ACPI_STATUS(status);
499 } 492 }
500 493
501 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 494 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
502 "I/O to Data Register: value_ptr %p\n", 495 "I/O to Data Register: value_ptr %p\n",
503 value)); 496 value));
504 497
505 if (read_write == ACPI_READ) { 498 if (read_write == ACPI_READ) {
506 /* Read the datum from the data_register */ 499 /* Read the datum from the data_register */
507 500
508 status = acpi_ex_extract_from_field (obj_desc->index_field.data_obj, 501 status =
509 value, sizeof (acpi_integer)); 502 acpi_ex_extract_from_field(obj_desc->index_field.
510 } 503 data_obj, value,
511 else { 504 sizeof(acpi_integer));
505 } else {
512 /* Write the datum to the data_register */ 506 /* Write the datum to the data_register */
513 507
514 status = acpi_ex_insert_into_field (obj_desc->index_field.data_obj, 508 status =
515 value, sizeof (acpi_integer)); 509 acpi_ex_insert_into_field(obj_desc->index_field.
510 data_obj, value,
511 sizeof(acpi_integer));
516 } 512 }
517 break; 513 break;
518 514
519
520 default: 515 default:
521 516
522 ACPI_REPORT_ERROR (("Wrong object type in field I/O %X\n", 517 ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n",
523 ACPI_GET_OBJECT_TYPE (obj_desc))); 518 ACPI_GET_OBJECT_TYPE(obj_desc)));
524 status = AE_AML_INTERNAL; 519 status = AE_AML_INTERNAL;
525 break; 520 break;
526 } 521 }
527 522
528 if (ACPI_SUCCESS (status)) { 523 if (ACPI_SUCCESS(status)) {
529 if (read_write == ACPI_READ) { 524 if (read_write == ACPI_READ) {
530 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 525 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
531 "Value Read %8.8X%8.8X, Width %d\n", 526 "Value Read %8.8X%8.8X, Width %d\n",
532 ACPI_FORMAT_UINT64 (*value), 527 ACPI_FORMAT_UINT64(*value),
533 obj_desc->common_field.access_byte_width)); 528 obj_desc->common_field.
534 } 529 access_byte_width));
535 else { 530 } else {
536 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 531 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
537 "Value Written %8.8X%8.8X, Width %d\n", 532 "Value Written %8.8X%8.8X, Width %d\n",
538 ACPI_FORMAT_UINT64 (*value), 533 ACPI_FORMAT_UINT64(*value),
539 obj_desc->common_field.access_byte_width)); 534 obj_desc->common_field.
535 access_byte_width));
540 } 536 }
541 } 537 }
542 538
543 return_ACPI_STATUS (status); 539 return_ACPI_STATUS(status);
544} 540}
545 541
546
547/******************************************************************************* 542/*******************************************************************************
548 * 543 *
549 * FUNCTION: acpi_ex_write_with_update_rule 544 * FUNCTION: acpi_ex_write_with_update_rule
@@ -560,19 +555,16 @@ acpi_ex_field_datum_io (
560 ******************************************************************************/ 555 ******************************************************************************/
561 556
562acpi_status 557acpi_status
563acpi_ex_write_with_update_rule ( 558acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
564 union acpi_operand_object *obj_desc, 559 acpi_integer mask,
565 acpi_integer mask, 560 acpi_integer field_value,
566 acpi_integer field_value, 561 u32 field_datum_byte_offset)
567 u32 field_datum_byte_offset)
568{ 562{
569 acpi_status status = AE_OK; 563 acpi_status status = AE_OK;
570 acpi_integer merged_value; 564 acpi_integer merged_value;
571 acpi_integer current_value; 565 acpi_integer current_value;
572
573
574 ACPI_FUNCTION_TRACE_U32 ("ex_write_with_update_rule", mask);
575 566
567 ACPI_FUNCTION_TRACE_U32("ex_write_with_update_rule", mask);
576 568
577 /* Start with the new bits */ 569 /* Start with the new bits */
578 570
@@ -583,22 +575,27 @@ acpi_ex_write_with_update_rule (
583 if (mask != ACPI_INTEGER_MAX) { 575 if (mask != ACPI_INTEGER_MAX) {
584 /* Decode the update rule */ 576 /* Decode the update rule */
585 577
586 switch (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK) { 578 switch (obj_desc->common_field.
579 field_flags & AML_FIELD_UPDATE_RULE_MASK) {
587 case AML_FIELD_UPDATE_PRESERVE: 580 case AML_FIELD_UPDATE_PRESERVE:
588 /* 581 /*
589 * Check if update rule needs to be applied (not if mask is all 582 * Check if update rule needs to be applied (not if mask is all
590 * ones) The left shift drops the bits we want to ignore. 583 * ones) The left shift drops the bits we want to ignore.
591 */ 584 */
592 if ((~mask << (ACPI_MUL_8 (sizeof (mask)) - 585 if ((~mask << (ACPI_MUL_8(sizeof(mask)) -
593 ACPI_MUL_8 (obj_desc->common_field.access_byte_width))) != 0) { 586 ACPI_MUL_8(obj_desc->common_field.
587 access_byte_width))) != 0) {
594 /* 588 /*
595 * Read the current contents of the byte/word/dword containing 589 * Read the current contents of the byte/word/dword containing
596 * the field, and merge with the new field value. 590 * the field, and merge with the new field value.
597 */ 591 */
598 status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset, 592 status =
599 &current_value, ACPI_READ); 593 acpi_ex_field_datum_io(obj_desc,
600 if (ACPI_FAILURE (status)) { 594 field_datum_byte_offset,
601 return_ACPI_STATUS (status); 595 &current_value,
596 ACPI_READ);
597 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS(status);
602 } 599 }
603 600
604 merged_value |= (current_value & ~mask); 601 merged_value |= (current_value & ~mask);
@@ -621,30 +618,31 @@ acpi_ex_write_with_update_rule (
621 618
622 default: 619 default:
623 620
624 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 621 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
625 "write_with_update_rule: Unknown update_rule setting: %X\n", 622 "write_with_update_rule: Unknown update_rule setting: %X\n",
626 (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK))); 623 (obj_desc->common_field.
627 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 624 field_flags &
625 AML_FIELD_UPDATE_RULE_MASK)));
626 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
628 } 627 }
629 } 628 }
630 629
631 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 630 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
632 "Mask %8.8X%8.8X, datum_offset %X, Width %X, Value %8.8X%8.8X, merged_value %8.8X%8.8X\n", 631 "Mask %8.8X%8.8X, datum_offset %X, Width %X, Value %8.8X%8.8X, merged_value %8.8X%8.8X\n",
633 ACPI_FORMAT_UINT64 (mask), 632 ACPI_FORMAT_UINT64(mask),
634 field_datum_byte_offset, 633 field_datum_byte_offset,
635 obj_desc->common_field.access_byte_width, 634 obj_desc->common_field.access_byte_width,
636 ACPI_FORMAT_UINT64 (field_value), 635 ACPI_FORMAT_UINT64(field_value),
637 ACPI_FORMAT_UINT64 (merged_value))); 636 ACPI_FORMAT_UINT64(merged_value)));
638 637
639 /* Write the merged value */ 638 /* Write the merged value */
640 639
641 status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset, 640 status = acpi_ex_field_datum_io(obj_desc, field_datum_byte_offset,
642 &merged_value, ACPI_WRITE); 641 &merged_value, ACPI_WRITE);
643 642
644 return_ACPI_STATUS (status); 643 return_ACPI_STATUS(status);
645} 644}
646 645
647
648/******************************************************************************* 646/*******************************************************************************
649 * 647 *
650 * FUNCTION: acpi_ex_extract_from_field 648 * FUNCTION: acpi_ex_extract_from_field
@@ -660,54 +658,54 @@ acpi_ex_write_with_update_rule (
660 ******************************************************************************/ 658 ******************************************************************************/
661 659
662acpi_status 660acpi_status
663acpi_ex_extract_from_field ( 661acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
664 union acpi_operand_object *obj_desc, 662 void *buffer, u32 buffer_length)
665 void *buffer,
666 u32 buffer_length)
667{ 663{
668 acpi_status status; 664 acpi_status status;
669 acpi_integer raw_datum; 665 acpi_integer raw_datum;
670 acpi_integer merged_datum; 666 acpi_integer merged_datum;
671 u32 field_offset = 0; 667 u32 field_offset = 0;
672 u32 buffer_offset = 0; 668 u32 buffer_offset = 0;
673 u32 buffer_tail_bits; 669 u32 buffer_tail_bits;
674 u32 datum_count; 670 u32 datum_count;
675 u32 field_datum_count; 671 u32 field_datum_count;
676 u32 i; 672 u32 i;
677 673
678 674 ACPI_FUNCTION_TRACE("ex_extract_from_field");
679 ACPI_FUNCTION_TRACE ("ex_extract_from_field");
680
681 675
682 /* Validate target buffer and clear it */ 676 /* Validate target buffer and clear it */
683 677
684 if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES ( 678 if (buffer_length <
685 obj_desc->common_field.bit_length)) { 679 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
686 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 680 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
687 "Field size %X (bits) is too large for buffer (%X)\n", 681 "Field size %X (bits) is too large for buffer (%X)\n",
688 obj_desc->common_field.bit_length, buffer_length)); 682 obj_desc->common_field.bit_length,
683 buffer_length));
689 684
690 return_ACPI_STATUS (AE_BUFFER_OVERFLOW); 685 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
691 } 686 }
692 ACPI_MEMSET (buffer, 0, buffer_length); 687 ACPI_MEMSET(buffer, 0, buffer_length);
693 688
694 /* Compute the number of datums (access width data items) */ 689 /* Compute the number of datums (access width data items) */
695 690
696 datum_count = ACPI_ROUND_UP_TO ( 691 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
697 obj_desc->common_field.bit_length, 692 obj_desc->common_field.access_bit_width);
698 obj_desc->common_field.access_bit_width); 693 field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
699 field_datum_count = ACPI_ROUND_UP_TO ( 694 obj_desc->common_field.
700 obj_desc->common_field.bit_length + 695 start_field_bit_offset,
701 obj_desc->common_field.start_field_bit_offset, 696 obj_desc->common_field.
702 obj_desc->common_field.access_bit_width); 697 access_bit_width);
703 698
704 /* Priming read from the field */ 699 /* Priming read from the field */
705 700
706 status = acpi_ex_field_datum_io (obj_desc, field_offset, &raw_datum, ACPI_READ); 701 status =
707 if (ACPI_FAILURE (status)) { 702 acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum,
708 return_ACPI_STATUS (status); 703 ACPI_READ);
704 if (ACPI_FAILURE(status)) {
705 return_ACPI_STATUS(status);
709 } 706 }
710 merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; 707 merged_datum =
708 raw_datum >> obj_desc->common_field.start_field_bit_offset;
711 709
712 /* Read the rest of the field */ 710 /* Read the rest of the field */
713 711
@@ -715,17 +713,17 @@ acpi_ex_extract_from_field (
715 /* Get next input datum from the field */ 713 /* Get next input datum from the field */
716 714
717 field_offset += obj_desc->common_field.access_byte_width; 715 field_offset += obj_desc->common_field.access_byte_width;
718 status = acpi_ex_field_datum_io (obj_desc, field_offset, 716 status = acpi_ex_field_datum_io(obj_desc, field_offset,
719 &raw_datum, ACPI_READ); 717 &raw_datum, ACPI_READ);
720 if (ACPI_FAILURE (status)) { 718 if (ACPI_FAILURE(status)) {
721 return_ACPI_STATUS (status); 719 return_ACPI_STATUS(status);
722 } 720 }
723 721
724 /* Merge with previous datum if necessary */ 722 /* Merge with previous datum if necessary */
725 723
726 merged_datum |= raw_datum << 724 merged_datum |= raw_datum <<
727 (obj_desc->common_field.access_bit_width - 725 (obj_desc->common_field.access_bit_width -
728 obj_desc->common_field.start_field_bit_offset); 726 obj_desc->common_field.start_field_bit_offset);
729 727
730 if (i == datum_count) { 728 if (i == datum_count) {
731 break; 729 break;
@@ -733,32 +731,32 @@ acpi_ex_extract_from_field (
733 731
734 /* Write merged datum to target buffer */ 732 /* Write merged datum to target buffer */
735 733
736 ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum, 734 ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
737 ACPI_MIN(obj_desc->common_field.access_byte_width, 735 ACPI_MIN(obj_desc->common_field.access_byte_width,
738 buffer_length - buffer_offset)); 736 buffer_length - buffer_offset));
739 737
740 buffer_offset += obj_desc->common_field.access_byte_width; 738 buffer_offset += obj_desc->common_field.access_byte_width;
741 merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; 739 merged_datum =
740 raw_datum >> obj_desc->common_field.start_field_bit_offset;
742 } 741 }
743 742
744 /* Mask off any extra bits in the last datum */ 743 /* Mask off any extra bits in the last datum */
745 744
746 buffer_tail_bits = obj_desc->common_field.bit_length % 745 buffer_tail_bits = obj_desc->common_field.bit_length %
747 obj_desc->common_field.access_bit_width; 746 obj_desc->common_field.access_bit_width;
748 if (buffer_tail_bits) { 747 if (buffer_tail_bits) {
749 merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); 748 merged_datum &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
750 } 749 }
751 750
752 /* Write the last datum to the buffer */ 751 /* Write the last datum to the buffer */
753 752
754 ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum, 753 ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
755 ACPI_MIN(obj_desc->common_field.access_byte_width, 754 ACPI_MIN(obj_desc->common_field.access_byte_width,
756 buffer_length - buffer_offset)); 755 buffer_length - buffer_offset));
757 756
758 return_ACPI_STATUS (AE_OK); 757 return_ACPI_STATUS(AE_OK);
759} 758}
760 759
761
762/******************************************************************************* 760/*******************************************************************************
763 * 761 *
764 * FUNCTION: acpi_ex_insert_into_field 762 * FUNCTION: acpi_ex_insert_into_field
@@ -774,53 +772,54 @@ acpi_ex_extract_from_field (
774 ******************************************************************************/ 772 ******************************************************************************/
775 773
776acpi_status 774acpi_status
777acpi_ex_insert_into_field ( 775acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
778 union acpi_operand_object *obj_desc, 776 void *buffer, u32 buffer_length)
779 void *buffer,
780 u32 buffer_length)
781{ 777{
782 acpi_status status; 778 acpi_status status;
783 acpi_integer mask; 779 acpi_integer mask;
784 acpi_integer merged_datum; 780 acpi_integer merged_datum;
785 acpi_integer raw_datum = 0; 781 acpi_integer raw_datum = 0;
786 u32 field_offset = 0; 782 u32 field_offset = 0;
787 u32 buffer_offset = 0; 783 u32 buffer_offset = 0;
788 u32 buffer_tail_bits; 784 u32 buffer_tail_bits;
789 u32 datum_count; 785 u32 datum_count;
790 u32 field_datum_count; 786 u32 field_datum_count;
791 u32 i; 787 u32 i;
792 788
793 789 ACPI_FUNCTION_TRACE("ex_insert_into_field");
794 ACPI_FUNCTION_TRACE ("ex_insert_into_field");
795
796 790
797 /* Validate input buffer */ 791 /* Validate input buffer */
798 792
799 if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES ( 793 if (buffer_length <
800 obj_desc->common_field.bit_length)) { 794 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
801 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
802 "Field size %X (bits) is too large for buffer (%X)\n", 796 "Field size %X (bits) is too large for buffer (%X)\n",
803 obj_desc->common_field.bit_length, buffer_length)); 797 obj_desc->common_field.bit_length,
798 buffer_length));
804 799
805 return_ACPI_STATUS (AE_BUFFER_OVERFLOW); 800 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
806 } 801 }
807 802
808 /* Compute the number of datums (access width data items) */ 803 /* Compute the number of datums (access width data items) */
809 804
810 mask = ACPI_MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset); 805 mask =
811 datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length, 806 ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
812 obj_desc->common_field.access_bit_width); 807 datum_count =
813 field_datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length + 808 ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
814 obj_desc->common_field.start_field_bit_offset, 809 obj_desc->common_field.access_bit_width);
815 obj_desc->common_field.access_bit_width); 810 field_datum_count =
811 ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
812 obj_desc->common_field.start_field_bit_offset,
813 obj_desc->common_field.access_bit_width);
816 814
817 /* Get initial Datum from the input buffer */ 815 /* Get initial Datum from the input buffer */
818 816
819 ACPI_MEMCPY (&raw_datum, buffer, 817 ACPI_MEMCPY(&raw_datum, buffer,
820 ACPI_MIN(obj_desc->common_field.access_byte_width, 818 ACPI_MIN(obj_desc->common_field.access_byte_width,
821 buffer_length - buffer_offset)); 819 buffer_length - buffer_offset));
822 820
823 merged_datum = raw_datum << obj_desc->common_field.start_field_bit_offset; 821 merged_datum =
822 raw_datum << obj_desc->common_field.start_field_bit_offset;
824 823
825 /* Write the entire field */ 824 /* Write the entire field */
826 825
@@ -828,18 +827,19 @@ acpi_ex_insert_into_field (
828 /* Write merged datum to the target field */ 827 /* Write merged datum to the target field */
829 828
830 merged_datum &= mask; 829 merged_datum &= mask;
831 status = acpi_ex_write_with_update_rule (obj_desc, mask, 830 status = acpi_ex_write_with_update_rule(obj_desc, mask,
832 merged_datum, field_offset); 831 merged_datum,
833 if (ACPI_FAILURE (status)) { 832 field_offset);
834 return_ACPI_STATUS (status); 833 if (ACPI_FAILURE(status)) {
834 return_ACPI_STATUS(status);
835 } 835 }
836 836
837 /* Start new output datum by merging with previous input datum */ 837 /* Start new output datum by merging with previous input datum */
838 838
839 field_offset += obj_desc->common_field.access_byte_width; 839 field_offset += obj_desc->common_field.access_byte_width;
840 merged_datum = raw_datum >> 840 merged_datum = raw_datum >>
841 (obj_desc->common_field.access_bit_width - 841 (obj_desc->common_field.access_bit_width -
842 obj_desc->common_field.start_field_bit_offset); 842 obj_desc->common_field.start_field_bit_offset);
843 mask = ACPI_INTEGER_MAX; 843 mask = ACPI_INTEGER_MAX;
844 844
845 if (i == datum_count) { 845 if (i == datum_count) {
@@ -849,28 +849,28 @@ acpi_ex_insert_into_field (
849 /* Get the next input datum from the buffer */ 849 /* Get the next input datum from the buffer */
850 850
851 buffer_offset += obj_desc->common_field.access_byte_width; 851 buffer_offset += obj_desc->common_field.access_byte_width;
852 ACPI_MEMCPY (&raw_datum, ((char *) buffer) + buffer_offset, 852 ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset,
853 ACPI_MIN(obj_desc->common_field.access_byte_width, 853 ACPI_MIN(obj_desc->common_field.access_byte_width,
854 buffer_length - buffer_offset)); 854 buffer_length - buffer_offset));
855 merged_datum |= raw_datum << obj_desc->common_field.start_field_bit_offset; 855 merged_datum |=
856 raw_datum << obj_desc->common_field.start_field_bit_offset;
856 } 857 }
857 858
858 /* Mask off any extra bits in the last datum */ 859 /* Mask off any extra bits in the last datum */
859 860
860 buffer_tail_bits = (obj_desc->common_field.bit_length + 861 buffer_tail_bits = (obj_desc->common_field.bit_length +
861 obj_desc->common_field.start_field_bit_offset) % 862 obj_desc->common_field.start_field_bit_offset) %
862 obj_desc->common_field.access_bit_width; 863 obj_desc->common_field.access_bit_width;
863 if (buffer_tail_bits) { 864 if (buffer_tail_bits) {
864 mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); 865 mask &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
865 } 866 }
866 867
867 /* Write the last datum to the field */ 868 /* Write the last datum to the field */
868 869
869 merged_datum &= mask; 870 merged_datum &= mask;
870 status = acpi_ex_write_with_update_rule (obj_desc, 871 status = acpi_ex_write_with_update_rule(obj_desc,
871 mask, merged_datum, field_offset); 872 mask, merged_datum,
873 field_offset);
872 874
873 return_ACPI_STATUS (status); 875 return_ACPI_STATUS(status);
874} 876}
875
876
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 022f281345b8..a3f4d72bedc9 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -42,15 +42,12 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49 48
50
51#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exmisc") 50ACPI_MODULE_NAME("exmisc")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -66,27 +63,23 @@
66 * Common code for the ref_of_op and the cond_ref_of_op. 63 * Common code for the ref_of_op and the cond_ref_of_op.
67 * 64 *
68 ******************************************************************************/ 65 ******************************************************************************/
69
70acpi_status 66acpi_status
71acpi_ex_get_object_reference ( 67acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
72 union acpi_operand_object *obj_desc, 68 union acpi_operand_object **return_desc,
73 union acpi_operand_object **return_desc, 69 struct acpi_walk_state *walk_state)
74 struct acpi_walk_state *walk_state)
75{ 70{
76 union acpi_operand_object *reference_obj; 71 union acpi_operand_object *reference_obj;
77 union acpi_operand_object *referenced_obj; 72 union acpi_operand_object *referenced_obj;
78
79
80 ACPI_FUNCTION_TRACE_PTR ("ex_get_object_reference", obj_desc);
81 73
74 ACPI_FUNCTION_TRACE_PTR("ex_get_object_reference", obj_desc);
82 75
83 *return_desc = NULL; 76 *return_desc = NULL;
84 77
85 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 78 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
86 case ACPI_DESC_TYPE_OPERAND: 79 case ACPI_DESC_TYPE_OPERAND:
87 80
88 if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { 81 if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) {
89 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 82 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
90 } 83 }
91 84
92 /* 85 /*
@@ -104,13 +97,11 @@ acpi_ex_get_object_reference (
104 97
105 default: 98 default:
106 99
107 ACPI_REPORT_ERROR (("Unknown Reference opcode in get_reference %X\n", 100 ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode));
108 obj_desc->reference.opcode)); 101 return_ACPI_STATUS(AE_AML_INTERNAL);
109 return_ACPI_STATUS (AE_AML_INTERNAL);
110 } 102 }
111 break; 103 break;
112 104
113
114 case ACPI_DESC_TYPE_NAMED: 105 case ACPI_DESC_TYPE_NAMED:
115 106
116 /* 107 /*
@@ -119,34 +110,32 @@ acpi_ex_get_object_reference (
119 referenced_obj = obj_desc; 110 referenced_obj = obj_desc;
120 break; 111 break;
121 112
122
123 default: 113 default:
124 114
125 ACPI_REPORT_ERROR (("Invalid descriptor type in get_reference: %X\n", 115 ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
126 ACPI_GET_DESCRIPTOR_TYPE (obj_desc))); 116 return_ACPI_STATUS(AE_TYPE);
127 return_ACPI_STATUS (AE_TYPE);
128 } 117 }
129 118
130
131 /* Create a new reference object */ 119 /* Create a new reference object */
132 120
133 reference_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); 121 reference_obj =
122 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
134 if (!reference_obj) { 123 if (!reference_obj) {
135 return_ACPI_STATUS (AE_NO_MEMORY); 124 return_ACPI_STATUS(AE_NO_MEMORY);
136 } 125 }
137 126
138 reference_obj->reference.opcode = AML_REF_OF_OP; 127 reference_obj->reference.opcode = AML_REF_OF_OP;
139 reference_obj->reference.object = referenced_obj; 128 reference_obj->reference.object = referenced_obj;
140 *return_desc = reference_obj; 129 *return_desc = reference_obj;
141 130
142 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 131 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
143 "Object %p Type [%s], returning Reference %p\n", 132 "Object %p Type [%s], returning Reference %p\n",
144 obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc)); 133 obj_desc, acpi_ut_get_object_type_name(obj_desc),
134 *return_desc));
145 135
146 return_ACPI_STATUS (AE_OK); 136 return_ACPI_STATUS(AE_OK);
147} 137}
148 138
149
150/******************************************************************************* 139/*******************************************************************************
151 * 140 *
152 * FUNCTION: acpi_ex_concat_template 141 * FUNCTION: acpi_ex_concat_template
@@ -163,63 +152,58 @@ acpi_ex_get_object_reference (
163 ******************************************************************************/ 152 ******************************************************************************/
164 153
165acpi_status 154acpi_status
166acpi_ex_concat_template ( 155acpi_ex_concat_template(union acpi_operand_object *operand0,
167 union acpi_operand_object *operand0, 156 union acpi_operand_object *operand1,
168 union acpi_operand_object *operand1, 157 union acpi_operand_object **actual_return_desc,
169 union acpi_operand_object **actual_return_desc, 158 struct acpi_walk_state *walk_state)
170 struct acpi_walk_state *walk_state)
171{ 159{
172 union acpi_operand_object *return_desc; 160 union acpi_operand_object *return_desc;
173 u8 *new_buf; 161 u8 *new_buf;
174 u8 *end_tag1; 162 u8 *end_tag1;
175 u8 *end_tag2; 163 u8 *end_tag2;
176 acpi_size length1; 164 acpi_size length1;
177 acpi_size length2; 165 acpi_size length2;
178
179
180 ACPI_FUNCTION_TRACE ("ex_concat_template");
181 166
167 ACPI_FUNCTION_TRACE("ex_concat_template");
182 168
183 /* Find the end_tags in each resource template */ 169 /* Find the end_tags in each resource template */
184 170
185 end_tag1 = acpi_ut_get_resource_end_tag (operand0); 171 end_tag1 = acpi_ut_get_resource_end_tag(operand0);
186 end_tag2 = acpi_ut_get_resource_end_tag (operand1); 172 end_tag2 = acpi_ut_get_resource_end_tag(operand1);
187 if (!end_tag1 || !end_tag2) { 173 if (!end_tag1 || !end_tag2) {
188 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 174 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
189 } 175 }
190 176
191 /* Compute the length of each part */ 177 /* Compute the length of each part */
192 178
193 length1 = ACPI_PTR_DIFF (end_tag1, operand0->buffer.pointer); 179 length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer);
194 length2 = ACPI_PTR_DIFF (end_tag2, operand1->buffer.pointer) + 180 length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */
195 2; /* Size of END_TAG */
196 181
197 /* Create a new buffer object for the result */ 182 /* Create a new buffer object for the result */
198 183
199 return_desc = acpi_ut_create_buffer_object (length1 + length2); 184 return_desc = acpi_ut_create_buffer_object(length1 + length2);
200 if (!return_desc) { 185 if (!return_desc) {
201 return_ACPI_STATUS (AE_NO_MEMORY); 186 return_ACPI_STATUS(AE_NO_MEMORY);
202 } 187 }
203 188
204 /* Copy the templates to the new descriptor */ 189 /* Copy the templates to the new descriptor */
205 190
206 new_buf = return_desc->buffer.pointer; 191 new_buf = return_desc->buffer.pointer;
207 ACPI_MEMCPY (new_buf, operand0->buffer.pointer, length1); 192 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1);
208 ACPI_MEMCPY (new_buf + length1, operand1->buffer.pointer, length2); 193 ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2);
209 194
210 /* Compute the new checksum */ 195 /* Compute the new checksum */
211 196
212 new_buf[return_desc->buffer.length - 1] = 197 new_buf[return_desc->buffer.length - 1] =
213 acpi_ut_generate_checksum (return_desc->buffer.pointer, 198 acpi_ut_generate_checksum(return_desc->buffer.pointer,
214 (return_desc->buffer.length - 1)); 199 (return_desc->buffer.length - 1));
215 200
216 /* Return the completed template descriptor */ 201 /* Return the completed template descriptor */
217 202
218 *actual_return_desc = return_desc; 203 *actual_return_desc = return_desc;
219 return_ACPI_STATUS (AE_OK); 204 return_ACPI_STATUS(AE_OK);
220} 205}
221 206
222
223/******************************************************************************* 207/*******************************************************************************
224 * 208 *
225 * FUNCTION: acpi_ex_do_concatenate 209 * FUNCTION: acpi_ex_do_concatenate
@@ -236,21 +220,18 @@ acpi_ex_concat_template (
236 ******************************************************************************/ 220 ******************************************************************************/
237 221
238acpi_status 222acpi_status
239acpi_ex_do_concatenate ( 223acpi_ex_do_concatenate(union acpi_operand_object *operand0,
240 union acpi_operand_object *operand0, 224 union acpi_operand_object *operand1,
241 union acpi_operand_object *operand1, 225 union acpi_operand_object **actual_return_desc,
242 union acpi_operand_object **actual_return_desc, 226 struct acpi_walk_state *walk_state)
243 struct acpi_walk_state *walk_state)
244{ 227{
245 union acpi_operand_object *local_operand1 = operand1; 228 union acpi_operand_object *local_operand1 = operand1;
246 union acpi_operand_object *return_desc; 229 union acpi_operand_object *return_desc;
247 char *new_buf; 230 char *new_buf;
248 acpi_status status; 231 acpi_status status;
249 acpi_size new_length; 232 acpi_size new_length;
250
251
252 ACPI_FUNCTION_TRACE ("ex_do_concatenate");
253 233
234 ACPI_FUNCTION_TRACE("ex_do_concatenate");
254 235
255 /* 236 /*
256 * Convert the second operand if necessary. The first operand 237 * Convert the second operand if necessary. The first operand
@@ -259,27 +240,28 @@ acpi_ex_do_concatenate (
259 * guaranteed to be either Integer/String/Buffer by the operand 240 * guaranteed to be either Integer/String/Buffer by the operand
260 * resolution mechanism. 241 * resolution mechanism.
261 */ 242 */
262 switch (ACPI_GET_OBJECT_TYPE (operand0)) { 243 switch (ACPI_GET_OBJECT_TYPE(operand0)) {
263 case ACPI_TYPE_INTEGER: 244 case ACPI_TYPE_INTEGER:
264 status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16); 245 status =
246 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
265 break; 247 break;
266 248
267 case ACPI_TYPE_STRING: 249 case ACPI_TYPE_STRING:
268 status = acpi_ex_convert_to_string (operand1, &local_operand1, 250 status = acpi_ex_convert_to_string(operand1, &local_operand1,
269 ACPI_IMPLICIT_CONVERT_HEX); 251 ACPI_IMPLICIT_CONVERT_HEX);
270 break; 252 break;
271 253
272 case ACPI_TYPE_BUFFER: 254 case ACPI_TYPE_BUFFER:
273 status = acpi_ex_convert_to_buffer (operand1, &local_operand1); 255 status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
274 break; 256 break;
275 257
276 default: 258 default:
277 ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", 259 ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n",
278 ACPI_GET_OBJECT_TYPE (operand0))); 260 ACPI_GET_OBJECT_TYPE(operand0)));
279 status = AE_AML_INTERNAL; 261 status = AE_AML_INTERNAL;
280 } 262 }
281 263
282 if (ACPI_FAILURE (status)) { 264 if (ACPI_FAILURE(status)) {
283 goto cleanup; 265 goto cleanup;
284 } 266 }
285 267
@@ -296,32 +278,33 @@ acpi_ex_do_concatenate (
296 * 2) Two Strings concatenated to produce a new String 278 * 2) Two Strings concatenated to produce a new String
297 * 3) Two Buffers concatenated to produce a new Buffer 279 * 3) Two Buffers concatenated to produce a new Buffer
298 */ 280 */
299 switch (ACPI_GET_OBJECT_TYPE (operand0)) { 281 switch (ACPI_GET_OBJECT_TYPE(operand0)) {
300 case ACPI_TYPE_INTEGER: 282 case ACPI_TYPE_INTEGER:
301 283
302 /* Result of two Integers is a Buffer */ 284 /* Result of two Integers is a Buffer */
303 /* Need enough buffer space for two integers */ 285 /* Need enough buffer space for two integers */
304 286
305 return_desc = acpi_ut_create_buffer_object ( 287 return_desc = acpi_ut_create_buffer_object((acpi_size)
306 ACPI_MUL_2 (acpi_gbl_integer_byte_width)); 288 ACPI_MUL_2
289 (acpi_gbl_integer_byte_width));
307 if (!return_desc) { 290 if (!return_desc) {
308 status = AE_NO_MEMORY; 291 status = AE_NO_MEMORY;
309 goto cleanup; 292 goto cleanup;
310 } 293 }
311 294
312 new_buf = (char *) return_desc->buffer.pointer; 295 new_buf = (char *)return_desc->buffer.pointer;
313 296
314 /* Copy the first integer, LSB first */ 297 /* Copy the first integer, LSB first */
315 298
316 ACPI_MEMCPY (new_buf, 299 ACPI_MEMCPY(new_buf,
317 &operand0->integer.value, 300 &operand0->integer.value,
318 acpi_gbl_integer_byte_width); 301 acpi_gbl_integer_byte_width);
319 302
320 /* Copy the second integer (LSB first) after the first */ 303 /* Copy the second integer (LSB first) after the first */
321 304
322 ACPI_MEMCPY (new_buf + acpi_gbl_integer_byte_width, 305 ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width,
323 &local_operand1->integer.value, 306 &local_operand1->integer.value,
324 acpi_gbl_integer_byte_width); 307 acpi_gbl_integer_byte_width);
325 break; 308 break;
326 309
327 case ACPI_TYPE_STRING: 310 case ACPI_TYPE_STRING:
@@ -329,13 +312,13 @@ acpi_ex_do_concatenate (
329 /* Result of two Strings is a String */ 312 /* Result of two Strings is a String */
330 313
331 new_length = (acpi_size) operand0->string.length + 314 new_length = (acpi_size) operand0->string.length +
332 (acpi_size) local_operand1->string.length; 315 (acpi_size) local_operand1->string.length;
333 if (new_length > ACPI_MAX_STRING_CONVERSION) { 316 if (new_length > ACPI_MAX_STRING_CONVERSION) {
334 status = AE_AML_STRING_LIMIT; 317 status = AE_AML_STRING_LIMIT;
335 goto cleanup; 318 goto cleanup;
336 } 319 }
337 320
338 return_desc = acpi_ut_create_string_object (new_length); 321 return_desc = acpi_ut_create_string_object(new_length);
339 if (!return_desc) { 322 if (!return_desc) {
340 status = AE_NO_MEMORY; 323 status = AE_NO_MEMORY;
341 goto cleanup; 324 goto cleanup;
@@ -345,56 +328,56 @@ acpi_ex_do_concatenate (
345 328
346 /* Concatenate the strings */ 329 /* Concatenate the strings */
347 330
348 ACPI_STRCPY (new_buf, 331 ACPI_STRCPY(new_buf, operand0->string.pointer);
349 operand0->string.pointer); 332 ACPI_STRCPY(new_buf + operand0->string.length,
350 ACPI_STRCPY (new_buf + operand0->string.length, 333 local_operand1->string.pointer);
351 local_operand1->string.pointer);
352 break; 334 break;
353 335
354 case ACPI_TYPE_BUFFER: 336 case ACPI_TYPE_BUFFER:
355 337
356 /* Result of two Buffers is a Buffer */ 338 /* Result of two Buffers is a Buffer */
357 339
358 return_desc = acpi_ut_create_buffer_object ( 340 return_desc = acpi_ut_create_buffer_object((acpi_size)
359 (acpi_size) operand0->buffer.length + 341 operand0->buffer.
360 (acpi_size) local_operand1->buffer.length); 342 length +
343 (acpi_size)
344 local_operand1->
345 buffer.length);
361 if (!return_desc) { 346 if (!return_desc) {
362 status = AE_NO_MEMORY; 347 status = AE_NO_MEMORY;
363 goto cleanup; 348 goto cleanup;
364 } 349 }
365 350
366 new_buf = (char *) return_desc->buffer.pointer; 351 new_buf = (char *)return_desc->buffer.pointer;
367 352
368 /* Concatenate the buffers */ 353 /* Concatenate the buffers */
369 354
370 ACPI_MEMCPY (new_buf, 355 ACPI_MEMCPY(new_buf,
371 operand0->buffer.pointer, 356 operand0->buffer.pointer, operand0->buffer.length);
372 operand0->buffer.length); 357 ACPI_MEMCPY(new_buf + operand0->buffer.length,
373 ACPI_MEMCPY (new_buf + operand0->buffer.length, 358 local_operand1->buffer.pointer,
374 local_operand1->buffer.pointer, 359 local_operand1->buffer.length);
375 local_operand1->buffer.length);
376 break; 360 break;
377 361
378 default: 362 default:
379 363
380 /* Invalid object type, should not happen here */ 364 /* Invalid object type, should not happen here */
381 365
382 ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n", 366 ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n",
383 ACPI_GET_OBJECT_TYPE (operand0))); 367 ACPI_GET_OBJECT_TYPE(operand0)));
384 status =AE_AML_INTERNAL; 368 status = AE_AML_INTERNAL;
385 goto cleanup; 369 goto cleanup;
386 } 370 }
387 371
388 *actual_return_desc = return_desc; 372 *actual_return_desc = return_desc;
389 373
390cleanup: 374 cleanup:
391 if (local_operand1 != operand1) { 375 if (local_operand1 != operand1) {
392 acpi_ut_remove_reference (local_operand1); 376 acpi_ut_remove_reference(local_operand1);
393 } 377 }
394 return_ACPI_STATUS (status); 378 return_ACPI_STATUS(status);
395} 379}
396 380
397
398/******************************************************************************* 381/*******************************************************************************
399 * 382 *
400 * FUNCTION: acpi_ex_do_math_op 383 * FUNCTION: acpi_ex_do_math_op
@@ -412,62 +395,49 @@ cleanup:
412 ******************************************************************************/ 395 ******************************************************************************/
413 396
414acpi_integer 397acpi_integer
415acpi_ex_do_math_op ( 398acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
416 u16 opcode,
417 acpi_integer integer0,
418 acpi_integer integer1)
419{ 399{
420 400
421 ACPI_FUNCTION_ENTRY (); 401 ACPI_FUNCTION_ENTRY();
422
423 402
424 switch (opcode) { 403 switch (opcode) {
425 case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ 404 case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
426 405
427 return (integer0 + integer1); 406 return (integer0 + integer1);
428 407
429 408 case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
430 case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
431 409
432 return (integer0 & integer1); 410 return (integer0 & integer1);
433 411
434 412 case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
435 case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
436 413
437 return (~(integer0 & integer1)); 414 return (~(integer0 & integer1));
438 415
439 416 case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
440 case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
441 417
442 return (integer0 | integer1); 418 return (integer0 | integer1);
443 419
444 420 case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
445 case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
446 421
447 return (~(integer0 | integer1)); 422 return (~(integer0 | integer1));
448 423
449 424 case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
450 case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
451 425
452 return (integer0 ^ integer1); 426 return (integer0 ^ integer1);
453 427
454 428 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
455 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
456 429
457 return (integer0 * integer1); 430 return (integer0 * integer1);
458 431
459 432 case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */
460 case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result)*/
461 433
462 return (integer0 << integer1); 434 return (integer0 << integer1);
463 435
464 436 case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */
465 case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */
466 437
467 return (integer0 >> integer1); 438 return (integer0 >> integer1);
468 439
469 440 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
470 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
471 441
472 return (integer0 - integer1); 442 return (integer0 - integer1);
473 443
@@ -477,7 +447,6 @@ acpi_ex_do_math_op (
477 } 447 }
478} 448}
479 449
480
481/******************************************************************************* 450/*******************************************************************************
482 * 451 *
483 * FUNCTION: acpi_ex_do_logical_numeric_op 452 * FUNCTION: acpi_ex_do_logical_numeric_op
@@ -499,28 +468,24 @@ acpi_ex_do_math_op (
499 ******************************************************************************/ 468 ******************************************************************************/
500 469
501acpi_status 470acpi_status
502acpi_ex_do_logical_numeric_op ( 471acpi_ex_do_logical_numeric_op(u16 opcode,
503 u16 opcode, 472 acpi_integer integer0,
504 acpi_integer integer0, 473 acpi_integer integer1, u8 * logical_result)
505 acpi_integer integer1,
506 u8 *logical_result)
507{ 474{
508 acpi_status status = AE_OK; 475 acpi_status status = AE_OK;
509 u8 local_result = FALSE; 476 u8 local_result = FALSE;
510
511
512 ACPI_FUNCTION_TRACE ("ex_do_logical_numeric_op");
513 477
478 ACPI_FUNCTION_TRACE("ex_do_logical_numeric_op");
514 479
515 switch (opcode) { 480 switch (opcode) {
516 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ 481 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
517 482
518 if (integer0 && integer1) { 483 if (integer0 && integer1) {
519 local_result = TRUE; 484 local_result = TRUE;
520 } 485 }
521 break; 486 break;
522 487
523 case AML_LOR_OP: /* LOr (Integer0, Integer1) */ 488 case AML_LOR_OP: /* LOr (Integer0, Integer1) */
524 489
525 if (integer0 || integer1) { 490 if (integer0 || integer1) {
526 local_result = TRUE; 491 local_result = TRUE;
@@ -535,10 +500,9 @@ acpi_ex_do_logical_numeric_op (
535 /* Return the logical result and status */ 500 /* Return the logical result and status */
536 501
537 *logical_result = local_result; 502 *logical_result = local_result;
538 return_ACPI_STATUS (status); 503 return_ACPI_STATUS(status);
539} 504}
540 505
541
542/******************************************************************************* 506/*******************************************************************************
543 * 507 *
544 * FUNCTION: acpi_ex_do_logical_op 508 * FUNCTION: acpi_ex_do_logical_op
@@ -566,24 +530,20 @@ acpi_ex_do_logical_numeric_op (
566 ******************************************************************************/ 530 ******************************************************************************/
567 531
568acpi_status 532acpi_status
569acpi_ex_do_logical_op ( 533acpi_ex_do_logical_op(u16 opcode,
570 u16 opcode, 534 union acpi_operand_object *operand0,
571 union acpi_operand_object *operand0, 535 union acpi_operand_object *operand1, u8 * logical_result)
572 union acpi_operand_object *operand1,
573 u8 *logical_result)
574{ 536{
575 union acpi_operand_object *local_operand1 = operand1; 537 union acpi_operand_object *local_operand1 = operand1;
576 acpi_integer integer0; 538 acpi_integer integer0;
577 acpi_integer integer1; 539 acpi_integer integer1;
578 u32 length0; 540 u32 length0;
579 u32 length1; 541 u32 length1;
580 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
581 u8 local_result = FALSE; 543 u8 local_result = FALSE;
582 int compare; 544 int compare;
583
584
585 ACPI_FUNCTION_TRACE ("ex_do_logical_op");
586 545
546 ACPI_FUNCTION_TRACE("ex_do_logical_op");
587 547
588 /* 548 /*
589 * Convert the second operand if necessary. The first operand 549 * Convert the second operand if necessary. The first operand
@@ -592,18 +552,19 @@ acpi_ex_do_logical_op (
592 * guaranteed to be either Integer/String/Buffer by the operand 552 * guaranteed to be either Integer/String/Buffer by the operand
593 * resolution mechanism. 553 * resolution mechanism.
594 */ 554 */
595 switch (ACPI_GET_OBJECT_TYPE (operand0)) { 555 switch (ACPI_GET_OBJECT_TYPE(operand0)) {
596 case ACPI_TYPE_INTEGER: 556 case ACPI_TYPE_INTEGER:
597 status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16); 557 status =
558 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
598 break; 559 break;
599 560
600 case ACPI_TYPE_STRING: 561 case ACPI_TYPE_STRING:
601 status = acpi_ex_convert_to_string (operand1, &local_operand1, 562 status = acpi_ex_convert_to_string(operand1, &local_operand1,
602 ACPI_IMPLICIT_CONVERT_HEX); 563 ACPI_IMPLICIT_CONVERT_HEX);
603 break; 564 break;
604 565
605 case ACPI_TYPE_BUFFER: 566 case ACPI_TYPE_BUFFER:
606 status = acpi_ex_convert_to_buffer (operand1, &local_operand1); 567 status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
607 break; 568 break;
608 569
609 default: 570 default:
@@ -611,14 +572,14 @@ acpi_ex_do_logical_op (
611 break; 572 break;
612 } 573 }
613 574
614 if (ACPI_FAILURE (status)) { 575 if (ACPI_FAILURE(status)) {
615 goto cleanup; 576 goto cleanup;
616 } 577 }
617 578
618 /* 579 /*
619 * Two cases: 1) Both Integers, 2) Both Strings or Buffers 580 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
620 */ 581 */
621 if (ACPI_GET_OBJECT_TYPE (operand0) == ACPI_TYPE_INTEGER) { 582 if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) {
622 /* 583 /*
623 * 1) Both operands are of type integer 584 * 1) Both operands are of type integer
624 * Note: local_operand1 may have changed above 585 * Note: local_operand1 may have changed above
@@ -627,21 +588,21 @@ acpi_ex_do_logical_op (
627 integer1 = local_operand1->integer.value; 588 integer1 = local_operand1->integer.value;
628 589
629 switch (opcode) { 590 switch (opcode) {
630 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ 591 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
631 592
632 if (integer0 == integer1) { 593 if (integer0 == integer1) {
633 local_result = TRUE; 594 local_result = TRUE;
634 } 595 }
635 break; 596 break;
636 597
637 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ 598 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
638 599
639 if (integer0 > integer1) { 600 if (integer0 > integer1) {
640 local_result = TRUE; 601 local_result = TRUE;
641 } 602 }
642 break; 603 break;
643 604
644 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ 605 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
645 606
646 if (integer0 < integer1) { 607 if (integer0 < integer1) {
647 local_result = TRUE; 608 local_result = TRUE;
@@ -652,8 +613,7 @@ acpi_ex_do_logical_op (
652 status = AE_AML_INTERNAL; 613 status = AE_AML_INTERNAL;
653 break; 614 break;
654 } 615 }
655 } 616 } else {
656 else {
657 /* 617 /*
658 * 2) Both operands are Strings or both are Buffers 618 * 2) Both operands are Strings or both are Buffers
659 * Note: Code below takes advantage of common Buffer/String 619 * Note: Code below takes advantage of common Buffer/String
@@ -665,31 +625,31 @@ acpi_ex_do_logical_op (
665 625
666 /* Lexicographic compare: compare the data bytes */ 626 /* Lexicographic compare: compare the data bytes */
667 627
668 compare = ACPI_MEMCMP ((const char * ) operand0->buffer.pointer, 628 compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer,
669 (const char * ) local_operand1->buffer.pointer, 629 (const char *)local_operand1->buffer.
670 (length0 > length1) ? length1 : length0); 630 pointer,
631 (length0 > length1) ? length1 : length0);
671 632
672 switch (opcode) { 633 switch (opcode) {
673 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ 634 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
674 635
675 /* Length and all bytes must be equal */ 636 /* Length and all bytes must be equal */
676 637
677 if ((length0 == length1) && 638 if ((length0 == length1) && (compare == 0)) {
678 (compare == 0)) {
679 /* Length and all bytes match ==> TRUE */ 639 /* Length and all bytes match ==> TRUE */
680 640
681 local_result = TRUE; 641 local_result = TRUE;
682 } 642 }
683 break; 643 break;
684 644
685 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ 645 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
686 646
687 if (compare > 0) { 647 if (compare > 0) {
688 local_result = TRUE; 648 local_result = TRUE;
689 goto cleanup; /* TRUE */ 649 goto cleanup; /* TRUE */
690 } 650 }
691 if (compare < 0) { 651 if (compare < 0) {
692 goto cleanup; /* FALSE */ 652 goto cleanup; /* FALSE */
693 } 653 }
694 654
695 /* Bytes match (to shortest length), compare lengths */ 655 /* Bytes match (to shortest length), compare lengths */
@@ -699,14 +659,14 @@ acpi_ex_do_logical_op (
699 } 659 }
700 break; 660 break;
701 661
702 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ 662 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
703 663
704 if (compare > 0) { 664 if (compare > 0) {
705 goto cleanup; /* FALSE */ 665 goto cleanup; /* FALSE */
706 } 666 }
707 if (compare < 0) { 667 if (compare < 0) {
708 local_result = TRUE; 668 local_result = TRUE;
709 goto cleanup; /* TRUE */ 669 goto cleanup; /* TRUE */
710 } 670 }
711 671
712 /* Bytes match (to shortest length), compare lengths */ 672 /* Bytes match (to shortest length), compare lengths */
@@ -722,18 +682,16 @@ acpi_ex_do_logical_op (
722 } 682 }
723 } 683 }
724 684
725cleanup: 685 cleanup:
726 686
727 /* New object was created if implicit conversion performed - delete */ 687 /* New object was created if implicit conversion performed - delete */
728 688
729 if (local_operand1 != operand1) { 689 if (local_operand1 != operand1) {
730 acpi_ut_remove_reference (local_operand1); 690 acpi_ut_remove_reference(local_operand1);
731 } 691 }
732 692
733 /* Return the logical result and status */ 693 /* Return the logical result and status */
734 694
735 *logical_result = local_result; 695 *logical_result = local_result;
736 return_ACPI_STATUS (status); 696 return_ACPI_STATUS(status);
737} 697}
738
739
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index c3cb714d2cba..ab47f6d8b5c0 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -42,20 +42,16 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
50 ACPI_MODULE_NAME ("exmutex") 49ACPI_MODULE_NAME("exmutex")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54static void 52static void
55acpi_ex_link_mutex ( 53acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
56 union acpi_operand_object *obj_desc, 54 struct acpi_thread_state *thread);
57 struct acpi_thread_state *thread);
58
59 55
60/******************************************************************************* 56/*******************************************************************************
61 * 57 *
@@ -69,12 +65,9 @@ acpi_ex_link_mutex (
69 * 65 *
70 ******************************************************************************/ 66 ******************************************************************************/
71 67
72void 68void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
73acpi_ex_unlink_mutex (
74 union acpi_operand_object *obj_desc)
75{ 69{
76 struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; 70 struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
77
78 71
79 if (!thread) { 72 if (!thread) {
80 return; 73 return;
@@ -88,13 +81,11 @@ acpi_ex_unlink_mutex (
88 81
89 if (obj_desc->mutex.prev) { 82 if (obj_desc->mutex.prev) {
90 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; 83 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
91 } 84 } else {
92 else {
93 thread->acquired_mutex_list = obj_desc->mutex.next; 85 thread->acquired_mutex_list = obj_desc->mutex.next;
94 } 86 }
95} 87}
96 88
97
98/******************************************************************************* 89/*******************************************************************************
99 * 90 *
100 * FUNCTION: acpi_ex_link_mutex 91 * FUNCTION: acpi_ex_link_mutex
@@ -109,12 +100,10 @@ acpi_ex_unlink_mutex (
109 ******************************************************************************/ 100 ******************************************************************************/
110 101
111static void 102static void
112acpi_ex_link_mutex ( 103acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
113 union acpi_operand_object *obj_desc, 104 struct acpi_thread_state *thread)
114 struct acpi_thread_state *thread)
115{ 105{
116 union acpi_operand_object *list_head; 106 union acpi_operand_object *list_head;
117
118 107
119 list_head = thread->acquired_mutex_list; 108 list_head = thread->acquired_mutex_list;
120 109
@@ -134,7 +123,6 @@ acpi_ex_link_mutex (
134 thread->acquired_mutex_list = obj_desc; 123 thread->acquired_mutex_list = obj_desc;
135} 124}
136 125
137
138/******************************************************************************* 126/*******************************************************************************
139 * 127 *
140 * FUNCTION: acpi_ex_acquire_mutex 128 * FUNCTION: acpi_ex_acquire_mutex
@@ -150,27 +138,23 @@ acpi_ex_link_mutex (
150 ******************************************************************************/ 138 ******************************************************************************/
151 139
152acpi_status 140acpi_status
153acpi_ex_acquire_mutex ( 141acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
154 union acpi_operand_object *time_desc, 142 union acpi_operand_object *obj_desc,
155 union acpi_operand_object *obj_desc, 143 struct acpi_walk_state *walk_state)
156 struct acpi_walk_state *walk_state)
157{ 144{
158 acpi_status status; 145 acpi_status status;
159
160
161 ACPI_FUNCTION_TRACE_PTR ("ex_acquire_mutex", obj_desc);
162 146
147 ACPI_FUNCTION_TRACE_PTR("ex_acquire_mutex", obj_desc);
163 148
164 if (!obj_desc) { 149 if (!obj_desc) {
165 return_ACPI_STATUS (AE_BAD_PARAMETER); 150 return_ACPI_STATUS(AE_BAD_PARAMETER);
166 } 151 }
167 152
168 /* Sanity check -- we must have a valid thread ID */ 153 /* Sanity check -- we must have a valid thread ID */
169 154
170 if (!walk_state->thread) { 155 if (!walk_state->thread) {
171 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", 156 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
172 acpi_ut_get_node_name (obj_desc->mutex.node))); 157 return_ACPI_STATUS(AE_AML_INTERNAL);
173 return_ACPI_STATUS (AE_AML_INTERNAL);
174 } 158 }
175 159
176 /* 160 /*
@@ -178,10 +162,8 @@ acpi_ex_acquire_mutex (
178 * mutex. This mechanism provides some deadlock prevention 162 * mutex. This mechanism provides some deadlock prevention
179 */ 163 */
180 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 164 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
181 ACPI_REPORT_ERROR (( 165 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
182 "Cannot acquire Mutex [%4.4s], incorrect sync_level\n", 166 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
183 acpi_ut_get_node_name (obj_desc->mutex.node)));
184 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
185 } 167 }
186 168
187 /* Support for multiple acquires by the owning thread */ 169 /* Support for multiple acquires by the owning thread */
@@ -190,43 +172,43 @@ acpi_ex_acquire_mutex (
190 /* Special case for Global Lock, allow all threads */ 172 /* Special case for Global Lock, allow all threads */
191 173
192 if ((obj_desc->mutex.owner_thread->thread_id == 174 if ((obj_desc->mutex.owner_thread->thread_id ==
193 walk_state->thread->thread_id) || 175 walk_state->thread->thread_id) ||
194 (obj_desc->mutex.semaphore == 176 (obj_desc->mutex.semaphore ==
195 acpi_gbl_global_lock_semaphore)) { 177 acpi_gbl_global_lock_semaphore)) {
196 /* 178 /*
197 * The mutex is already owned by this thread, 179 * The mutex is already owned by this thread,
198 * just increment the acquisition depth 180 * just increment the acquisition depth
199 */ 181 */
200 obj_desc->mutex.acquisition_depth++; 182 obj_desc->mutex.acquisition_depth++;
201 return_ACPI_STATUS (AE_OK); 183 return_ACPI_STATUS(AE_OK);
202 } 184 }
203 } 185 }
204 186
205 /* Acquire the mutex, wait if necessary */ 187 /* Acquire the mutex, wait if necessary */
206 188
207 status = acpi_ex_system_acquire_mutex (time_desc, obj_desc); 189 status = acpi_ex_system_acquire_mutex(time_desc, obj_desc);
208 if (ACPI_FAILURE (status)) { 190 if (ACPI_FAILURE(status)) {
209 /* Includes failure from a timeout on time_desc */ 191 /* Includes failure from a timeout on time_desc */
210 192
211 return_ACPI_STATUS (status); 193 return_ACPI_STATUS(status);
212 } 194 }
213 195
214 /* Have the mutex: update mutex and walk info and save the sync_level */ 196 /* Have the mutex: update mutex and walk info and save the sync_level */
215 197
216 obj_desc->mutex.owner_thread = walk_state->thread; 198 obj_desc->mutex.owner_thread = walk_state->thread;
217 obj_desc->mutex.acquisition_depth = 1; 199 obj_desc->mutex.acquisition_depth = 1;
218 obj_desc->mutex.original_sync_level = walk_state->thread->current_sync_level; 200 obj_desc->mutex.original_sync_level =
201 walk_state->thread->current_sync_level;
219 202
220 walk_state->thread->current_sync_level = obj_desc->mutex.sync_level; 203 walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
221 204
222 /* Link the mutex to the current thread for force-unlock at method exit */ 205 /* Link the mutex to the current thread for force-unlock at method exit */
223 206
224 acpi_ex_link_mutex (obj_desc, walk_state->thread); 207 acpi_ex_link_mutex(obj_desc, walk_state->thread);
225 208
226 return_ACPI_STATUS (AE_OK); 209 return_ACPI_STATUS(AE_OK);
227} 210}
228 211
229
230/******************************************************************************* 212/*******************************************************************************
231 * 213 *
232 * FUNCTION: acpi_ex_release_mutex 214 * FUNCTION: acpi_ex_release_mutex
@@ -241,48 +223,40 @@ acpi_ex_acquire_mutex (
241 ******************************************************************************/ 223 ******************************************************************************/
242 224
243acpi_status 225acpi_status
244acpi_ex_release_mutex ( 226acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
245 union acpi_operand_object *obj_desc, 227 struct acpi_walk_state *walk_state)
246 struct acpi_walk_state *walk_state)
247{ 228{
248 acpi_status status; 229 acpi_status status;
249
250
251 ACPI_FUNCTION_TRACE ("ex_release_mutex");
252 230
231 ACPI_FUNCTION_TRACE("ex_release_mutex");
253 232
254 if (!obj_desc) { 233 if (!obj_desc) {
255 return_ACPI_STATUS (AE_BAD_PARAMETER); 234 return_ACPI_STATUS(AE_BAD_PARAMETER);
256 } 235 }
257 236
258 /* The mutex must have been previously acquired in order to release it */ 237 /* The mutex must have been previously acquired in order to release it */
259 238
260 if (!obj_desc->mutex.owner_thread) { 239 if (!obj_desc->mutex.owner_thread) {
261 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n", 240 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
262 acpi_ut_get_node_name (obj_desc->mutex.node))); 241 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
263 return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
264 } 242 }
265 243
266 /* Sanity check -- we must have a valid thread ID */ 244 /* Sanity check -- we must have a valid thread ID */
267 245
268 if (!walk_state->thread) { 246 if (!walk_state->thread) {
269 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", 247 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
270 acpi_ut_get_node_name (obj_desc->mutex.node))); 248 return_ACPI_STATUS(AE_AML_INTERNAL);
271 return_ACPI_STATUS (AE_AML_INTERNAL);
272 } 249 }
273 250
274 /* 251 /*
275 * The Mutex is owned, but this thread must be the owner. 252 * The Mutex is owned, but this thread must be the owner.
276 * Special case for Global Lock, any thread can release 253 * Special case for Global Lock, any thread can release
277 */ 254 */
278 if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) && 255 if ((obj_desc->mutex.owner_thread->thread_id !=
279 (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 256 walk_state->thread->thread_id)
280 ACPI_REPORT_ERROR (( 257 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
281 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", 258 ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id));
282 walk_state->thread->thread_id, 259 return_ACPI_STATUS(AE_AML_NOT_OWNER);
283 acpi_ut_get_node_name (obj_desc->mutex.node),
284 obj_desc->mutex.owner_thread->thread_id));
285 return_ACPI_STATUS (AE_AML_NOT_OWNER);
286 } 260 }
287 261
288 /* 262 /*
@@ -290,10 +264,8 @@ acpi_ex_release_mutex (
290 * equal to the current sync level 264 * equal to the current sync level
291 */ 265 */
292 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { 266 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
293 ACPI_REPORT_ERROR (( 267 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
294 "Cannot release Mutex [%4.4s], incorrect sync_level\n", 268 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
295 acpi_ut_get_node_name (obj_desc->mutex.node)));
296 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
297 } 269 }
298 270
299 /* Match multiple Acquires with multiple Releases */ 271 /* Match multiple Acquires with multiple Releases */
@@ -302,26 +274,26 @@ acpi_ex_release_mutex (
302 if (obj_desc->mutex.acquisition_depth != 0) { 274 if (obj_desc->mutex.acquisition_depth != 0) {
303 /* Just decrement the depth and return */ 275 /* Just decrement the depth and return */
304 276
305 return_ACPI_STATUS (AE_OK); 277 return_ACPI_STATUS(AE_OK);
306 } 278 }
307 279
308 /* Unlink the mutex from the owner's list */ 280 /* Unlink the mutex from the owner's list */
309 281
310 acpi_ex_unlink_mutex (obj_desc); 282 acpi_ex_unlink_mutex(obj_desc);
311 283
312 /* Release the mutex */ 284 /* Release the mutex */
313 285
314 status = acpi_ex_system_release_mutex (obj_desc); 286 status = acpi_ex_system_release_mutex(obj_desc);
315 287
316 /* Update the mutex and walk state, restore sync_level before acquire */ 288 /* Update the mutex and walk state, restore sync_level before acquire */
317 289
318 obj_desc->mutex.owner_thread = NULL; 290 obj_desc->mutex.owner_thread = NULL;
319 walk_state->thread->current_sync_level = obj_desc->mutex.original_sync_level; 291 walk_state->thread->current_sync_level =
292 obj_desc->mutex.original_sync_level;
320 293
321 return_ACPI_STATUS (status); 294 return_ACPI_STATUS(status);
322} 295}
323 296
324
325/******************************************************************************* 297/*******************************************************************************
326 * 298 *
327 * FUNCTION: acpi_ex_release_all_mutexes 299 * FUNCTION: acpi_ex_release_all_mutexes
@@ -334,17 +306,13 @@ acpi_ex_release_mutex (
334 * 306 *
335 ******************************************************************************/ 307 ******************************************************************************/
336 308
337void 309void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
338acpi_ex_release_all_mutexes (
339 struct acpi_thread_state *thread)
340{ 310{
341 union acpi_operand_object *next = thread->acquired_mutex_list; 311 union acpi_operand_object *next = thread->acquired_mutex_list;
342 union acpi_operand_object *this; 312 union acpi_operand_object *this;
343 acpi_status status; 313 acpi_status status;
344
345
346 ACPI_FUNCTION_ENTRY ();
347 314
315 ACPI_FUNCTION_ENTRY();
348 316
349 /* Traverse the list of owned mutexes, releasing each one */ 317 /* Traverse the list of owned mutexes, releasing each one */
350 318
@@ -353,13 +321,13 @@ acpi_ex_release_all_mutexes (
353 next = this->mutex.next; 321 next = this->mutex.next;
354 322
355 this->mutex.acquisition_depth = 1; 323 this->mutex.acquisition_depth = 1;
356 this->mutex.prev = NULL; 324 this->mutex.prev = NULL;
357 this->mutex.next = NULL; 325 this->mutex.next = NULL;
358 326
359 /* Release the mutex */ 327 /* Release the mutex */
360 328
361 status = acpi_ex_system_release_mutex (this); 329 status = acpi_ex_system_release_mutex(this);
362 if (ACPI_FAILURE (status)) { 330 if (ACPI_FAILURE(status)) {
363 continue; 331 continue;
364 } 332 }
365 333
@@ -372,5 +340,3 @@ acpi_ex_release_all_mutexes (
372 thread->current_sync_level = this->mutex.original_sync_level; 340 thread->current_sync_level = this->mutex.original_sync_level;
373 } 341 }
374} 342}
375
376
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 639f0bd3f6d8..239d8473e9a5 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -42,26 +42,18 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49 48
50#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exnames") 50ACPI_MODULE_NAME("exnames")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54 53static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs);
55static char *
56acpi_ex_allocate_name_string (
57 u32 prefix_count,
58 u32 num_name_segs);
59 54
60static acpi_status 55static acpi_status
61acpi_ex_name_segment ( 56acpi_ex_name_segment(u8 ** in_aml_address, char *name_string);
62 u8 **in_aml_address,
63 char *name_string);
64
65 57
66/******************************************************************************* 58/*******************************************************************************
67 * 59 *
@@ -79,17 +71,13 @@ acpi_ex_name_segment (
79 * 71 *
80 ******************************************************************************/ 72 ******************************************************************************/
81 73
82static char * 74static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
83acpi_ex_allocate_name_string (
84 u32 prefix_count,
85 u32 num_name_segs)
86{ 75{
87 char *temp_ptr; 76 char *temp_ptr;
88 char *name_string; 77 char *name_string;
89 u32 size_needed; 78 u32 size_needed;
90
91 ACPI_FUNCTION_TRACE ("ex_allocate_name_string");
92 79
80 ACPI_FUNCTION_TRACE("ex_allocate_name_string");
93 81
94 /* 82 /*
95 * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix. 83 * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
@@ -100,20 +88,19 @@ acpi_ex_allocate_name_string (
100 /* Special case for root */ 88 /* Special case for root */
101 89
102 size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; 90 size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
103 } 91 } else {
104 else { 92 size_needed =
105 size_needed = prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; 93 prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
106 } 94 }
107 95
108 /* 96 /*
109 * Allocate a buffer for the name. 97 * Allocate a buffer for the name.
110 * This buffer must be deleted by the caller! 98 * This buffer must be deleted by the caller!
111 */ 99 */
112 name_string = ACPI_MEM_ALLOCATE (size_needed); 100 name_string = ACPI_MEM_ALLOCATE(size_needed);
113 if (!name_string) { 101 if (!name_string) {
114 ACPI_REPORT_ERROR (( 102 ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed));
115 "ex_allocate_name_string: Could not allocate size %d\n", size_needed)); 103 return_PTR(NULL);
116 return_PTR (NULL);
117 } 104 }
118 105
119 temp_ptr = name_string; 106 temp_ptr = name_string;
@@ -122,23 +109,20 @@ acpi_ex_allocate_name_string (
122 109
123 if (prefix_count == ACPI_UINT32_MAX) { 110 if (prefix_count == ACPI_UINT32_MAX) {
124 *temp_ptr++ = AML_ROOT_PREFIX; 111 *temp_ptr++ = AML_ROOT_PREFIX;
125 } 112 } else {
126 else {
127 while (prefix_count--) { 113 while (prefix_count--) {
128 *temp_ptr++ = AML_PARENT_PREFIX; 114 *temp_ptr++ = AML_PARENT_PREFIX;
129 } 115 }
130 } 116 }
131 117
132
133 /* Set up Dual or Multi prefixes if needed */ 118 /* Set up Dual or Multi prefixes if needed */
134 119
135 if (num_name_segs > 2) { 120 if (num_name_segs > 2) {
136 /* Set up multi prefixes */ 121 /* Set up multi prefixes */
137 122
138 *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP; 123 *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
139 *temp_ptr++ = (char) num_name_segs; 124 *temp_ptr++ = (char)num_name_segs;
140 } 125 } else if (2 == num_name_segs) {
141 else if (2 == num_name_segs) {
142 /* Set up dual prefixes */ 126 /* Set up dual prefixes */
143 127
144 *temp_ptr++ = AML_DUAL_NAME_PREFIX; 128 *temp_ptr++ = AML_DUAL_NAME_PREFIX;
@@ -150,7 +134,7 @@ acpi_ex_allocate_name_string (
150 */ 134 */
151 *temp_ptr = 0; 135 *temp_ptr = 0;
152 136
153 return_PTR (name_string); 137 return_PTR(name_string);
154} 138}
155 139
156/******************************************************************************* 140/*******************************************************************************
@@ -167,19 +151,14 @@ acpi_ex_allocate_name_string (
167 * 151 *
168 ******************************************************************************/ 152 ******************************************************************************/
169 153
170static acpi_status 154static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
171acpi_ex_name_segment (
172 u8 **in_aml_address,
173 char *name_string)
174{ 155{
175 char *aml_address = (void *) *in_aml_address; 156 char *aml_address = (void *)*in_aml_address;
176 acpi_status status = AE_OK; 157 acpi_status status = AE_OK;
177 u32 index; 158 u32 index;
178 char char_buf[5]; 159 char char_buf[5];
179
180
181 ACPI_FUNCTION_TRACE ("ex_name_segment");
182 160
161 ACPI_FUNCTION_TRACE("ex_name_segment");
183 162
184 /* 163 /*
185 * If first character is a digit, then we know that we aren't looking at a 164 * If first character is a digit, then we know that we aren't looking at a
@@ -188,20 +167,20 @@ acpi_ex_name_segment (
188 char_buf[0] = *aml_address; 167 char_buf[0] = *aml_address;
189 168
190 if ('0' <= char_buf[0] && char_buf[0] <= '9') { 169 if ('0' <= char_buf[0] && char_buf[0] <= '9') {
191 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", char_buf[0])); 170 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n",
192 return_ACPI_STATUS (AE_CTRL_PENDING); 171 char_buf[0]));
172 return_ACPI_STATUS(AE_CTRL_PENDING);
193 } 173 }
194 174
195 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); 175 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n"));
196 176
197 for (index = 0; 177 for (index = 0;
198 (index < ACPI_NAME_SIZE) && (acpi_ut_valid_acpi_character (*aml_address)); 178 (index < ACPI_NAME_SIZE)
199 index++) { 179 && (acpi_ut_valid_acpi_character(*aml_address)); index++) {
200 char_buf[index] = *aml_address++; 180 char_buf[index] = *aml_address++;
201 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[index])); 181 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index]));
202 } 182 }
203 183
204
205 /* Valid name segment */ 184 /* Valid name segment */
206 185
207 if (index == 4) { 186 if (index == 4) {
@@ -210,41 +189,37 @@ acpi_ex_name_segment (
210 char_buf[4] = '\0'; 189 char_buf[4] = '\0';
211 190
212 if (name_string) { 191 if (name_string) {
213 ACPI_STRCAT (name_string, char_buf); 192 ACPI_STRCAT(name_string, char_buf);
214 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
215 "Appended to - %s \n", name_string)); 194 "Appended to - %s \n", name_string));
216 } 195 } else {
217 else { 196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
218 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 197 "No Name string - %s \n", char_buf));
219 "No Name string - %s \n", char_buf));
220 } 198 }
221 } 199 } else if (index == 0) {
222 else if (index == 0) {
223 /* 200 /*
224 * First character was not a valid name character, 201 * First character was not a valid name character,
225 * so we are looking at something other than a name. 202 * so we are looking at something other than a name.
226 */ 203 */
227 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 204 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
228 "Leading character is not alpha: %02Xh (not a name)\n", 205 "Leading character is not alpha: %02Xh (not a name)\n",
229 char_buf[0])); 206 char_buf[0]));
230 status = AE_CTRL_PENDING; 207 status = AE_CTRL_PENDING;
231 } 208 } else {
232 else {
233 /* 209 /*
234 * Segment started with one or more valid characters, but fewer than 210 * Segment started with one or more valid characters, but fewer than
235 * the required 4 211 * the required 4
236 */ 212 */
237 status = AE_AML_BAD_NAME; 213 status = AE_AML_BAD_NAME;
238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
239 "Bad character %02x in name, at %p\n", 215 "Bad character %02x in name, at %p\n",
240 *aml_address, aml_address)); 216 *aml_address, aml_address));
241 } 217 }
242 218
243 *in_aml_address = (u8 *) aml_address; 219 *in_aml_address = (u8 *) aml_address;
244 return_ACPI_STATUS (status); 220 return_ACPI_STATUS(status);
245} 221}
246 222
247
248/******************************************************************************* 223/*******************************************************************************
249 * 224 *
250 * FUNCTION: acpi_ex_get_name_string 225 * FUNCTION: acpi_ex_get_name_string
@@ -263,37 +238,32 @@ acpi_ex_name_segment (
263 ******************************************************************************/ 238 ******************************************************************************/
264 239
265acpi_status 240acpi_status
266acpi_ex_get_name_string ( 241acpi_ex_get_name_string(acpi_object_type data_type,
267 acpi_object_type data_type, 242 u8 * in_aml_address,
268 u8 *in_aml_address, 243 char **out_name_string, u32 * out_name_length)
269 char **out_name_string,
270 u32 *out_name_length)
271{ 244{
272 acpi_status status = AE_OK; 245 acpi_status status = AE_OK;
273 u8 *aml_address = in_aml_address; 246 u8 *aml_address = in_aml_address;
274 char *name_string = NULL; 247 char *name_string = NULL;
275 u32 num_segments; 248 u32 num_segments;
276 u32 prefix_count = 0; 249 u32 prefix_count = 0;
277 u8 has_prefix = FALSE; 250 u8 has_prefix = FALSE;
278 251
279 252 ACPI_FUNCTION_TRACE_PTR("ex_get_name_string", aml_address);
280 ACPI_FUNCTION_TRACE_PTR ("ex_get_name_string", aml_address); 253
281 254 if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type ||
282 255 ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
283 if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type || 256 ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
284 ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
285 ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
286 /* Disallow prefixes for types associated with field_unit names */ 257 /* Disallow prefixes for types associated with field_unit names */
287 258
288 name_string = acpi_ex_allocate_name_string (0, 1); 259 name_string = acpi_ex_allocate_name_string(0, 1);
289 if (!name_string) { 260 if (!name_string) {
290 status = AE_NO_MEMORY; 261 status = AE_NO_MEMORY;
262 } else {
263 status =
264 acpi_ex_name_segment(&aml_address, name_string);
291 } 265 }
292 else { 266 } else {
293 status = acpi_ex_name_segment (&aml_address, name_string);
294 }
295 }
296 else {
297 /* 267 /*
298 * data_type is not a field name. 268 * data_type is not a field name.
299 * Examine first character of name for root or parent prefix operators 269 * Examine first character of name for root or parent prefix operators
@@ -301,8 +271,9 @@ acpi_ex_get_name_string (
301 switch (*aml_address) { 271 switch (*aml_address) {
302 case AML_ROOT_PREFIX: 272 case AML_ROOT_PREFIX:
303 273
304 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", 274 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
305 aml_address)); 275 "root_prefix(\\) at %p\n",
276 aml_address));
306 277
307 /* 278 /*
308 * Remember that we have a root_prefix -- 279 * Remember that we have a root_prefix --
@@ -313,14 +284,14 @@ acpi_ex_get_name_string (
313 has_prefix = TRUE; 284 has_prefix = TRUE;
314 break; 285 break;
315 286
316
317 case AML_PARENT_PREFIX: 287 case AML_PARENT_PREFIX:
318 288
319 /* Increment past possibly multiple parent prefixes */ 289 /* Increment past possibly multiple parent prefixes */
320 290
321 do { 291 do {
322 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", 292 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
323 aml_address)); 293 "parent_prefix (^) at %p\n",
294 aml_address));
324 295
325 aml_address++; 296 aml_address++;
326 prefix_count++; 297 prefix_count++;
@@ -330,7 +301,6 @@ acpi_ex_get_name_string (
330 has_prefix = TRUE; 301 has_prefix = TRUE;
331 break; 302 break;
332 303
333
334 default: 304 default:
335 305
336 /* Not a prefix character */ 306 /* Not a prefix character */
@@ -343,11 +313,13 @@ acpi_ex_get_name_string (
343 switch (*aml_address) { 313 switch (*aml_address) {
344 case AML_DUAL_NAME_PREFIX: 314 case AML_DUAL_NAME_PREFIX:
345 315
346 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", 316 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
347 aml_address)); 317 "dual_name_prefix at %p\n",
318 aml_address));
348 319
349 aml_address++; 320 aml_address++;
350 name_string = acpi_ex_allocate_name_string (prefix_count, 2); 321 name_string =
322 acpi_ex_allocate_name_string(prefix_count, 2);
351 if (!name_string) { 323 if (!name_string) {
352 status = AE_NO_MEMORY; 324 status = AE_NO_MEMORY;
353 break; 325 break;
@@ -357,24 +329,29 @@ acpi_ex_get_name_string (
357 329
358 has_prefix = TRUE; 330 has_prefix = TRUE;
359 331
360 status = acpi_ex_name_segment (&aml_address, name_string); 332 status =
361 if (ACPI_SUCCESS (status)) { 333 acpi_ex_name_segment(&aml_address, name_string);
362 status = acpi_ex_name_segment (&aml_address, name_string); 334 if (ACPI_SUCCESS(status)) {
335 status =
336 acpi_ex_name_segment(&aml_address,
337 name_string);
363 } 338 }
364 break; 339 break;
365 340
366
367 case AML_MULTI_NAME_PREFIX_OP: 341 case AML_MULTI_NAME_PREFIX_OP:
368 342
369 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", 343 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
370 aml_address)); 344 "multi_name_prefix at %p\n",
345 aml_address));
371 346
372 /* Fetch count of segments remaining in name path */ 347 /* Fetch count of segments remaining in name path */
373 348
374 aml_address++; 349 aml_address++;
375 num_segments = *aml_address; 350 num_segments = *aml_address;
376 351
377 name_string = acpi_ex_allocate_name_string (prefix_count, num_segments); 352 name_string =
353 acpi_ex_allocate_name_string(prefix_count,
354 num_segments);
378 if (!name_string) { 355 if (!name_string) {
379 status = AE_NO_MEMORY; 356 status = AE_NO_MEMORY;
380 break; 357 break;
@@ -386,27 +363,28 @@ acpi_ex_get_name_string (
386 has_prefix = TRUE; 363 has_prefix = TRUE;
387 364
388 while (num_segments && 365 while (num_segments &&
389 (status = acpi_ex_name_segment (&aml_address, name_string)) == 366 (status =
390 AE_OK) { 367 acpi_ex_name_segment(&aml_address,
368 name_string)) == AE_OK) {
391 num_segments--; 369 num_segments--;
392 } 370 }
393 371
394 break; 372 break;
395 373
396
397 case 0: 374 case 0:
398 375
399 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */ 376 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */
400 377
401 if (prefix_count == ACPI_UINT32_MAX) { 378 if (prefix_count == ACPI_UINT32_MAX) {
402 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 379 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
403 "name_seg is \"\\\" followed by NULL\n")); 380 "name_seg is \"\\\" followed by NULL\n"));
404 } 381 }
405 382
406 /* Consume the NULL byte */ 383 /* Consume the NULL byte */
407 384
408 aml_address++; 385 aml_address++;
409 name_string = acpi_ex_allocate_name_string (prefix_count, 0); 386 name_string =
387 acpi_ex_allocate_name_string(prefix_count, 0);
410 if (!name_string) { 388 if (!name_string) {
411 status = AE_NO_MEMORY; 389 status = AE_NO_MEMORY;
412 break; 390 break;
@@ -414,18 +392,19 @@ acpi_ex_get_name_string (
414 392
415 break; 393 break;
416 394
417
418 default: 395 default:
419 396
420 /* Name segment string */ 397 /* Name segment string */
421 398
422 name_string = acpi_ex_allocate_name_string (prefix_count, 1); 399 name_string =
400 acpi_ex_allocate_name_string(prefix_count, 1);
423 if (!name_string) { 401 if (!name_string) {
424 status = AE_NO_MEMORY; 402 status = AE_NO_MEMORY;
425 break; 403 break;
426 } 404 }
427 405
428 status = acpi_ex_name_segment (&aml_address, name_string); 406 status =
407 acpi_ex_name_segment(&aml_address, name_string);
429 break; 408 break;
430 } 409 }
431 } 410 }
@@ -433,15 +412,20 @@ acpi_ex_get_name_string (
433 if (AE_CTRL_PENDING == status && has_prefix) { 412 if (AE_CTRL_PENDING == status && has_prefix) {
434 /* Ran out of segments after processing a prefix */ 413 /* Ran out of segments after processing a prefix */
435 414
436 ACPI_REPORT_ERROR ( 415 ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n",
437 ("ex_do_name: Malformed Name at %p\n", name_string)); 416 name_string));
438 status = AE_AML_BAD_NAME; 417 status = AE_AML_BAD_NAME;
439 } 418 }
440 419
420 if (ACPI_FAILURE(status)) {
421 if (name_string) {
422 ACPI_MEM_FREE(name_string);
423 }
424 return_ACPI_STATUS(status);
425 }
426
441 *out_name_string = name_string; 427 *out_name_string = name_string;
442 *out_name_length = (u32) (aml_address - in_aml_address); 428 *out_name_length = (u32) (aml_address - in_aml_address);
443 429
444 return_ACPI_STATUS (status); 430 return_ACPI_STATUS(status);
445} 431}
446
447
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index dbdf8262ba00..97e34542f5e4 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
@@ -50,10 +49,8 @@
50#include <acpi/amlcode.h> 49#include <acpi/amlcode.h>
51#include <acpi/acnamesp.h> 50#include <acpi/acnamesp.h>
52 51
53
54#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exoparg1") 53ACPI_MODULE_NAME("exoparg1")
56
57 54
58/*! 55/*!
59 * Naming convention for AML interpreter execution routines. 56 * Naming convention for AML interpreter execution routines.
@@ -76,7 +73,6 @@
76 * The AcpiExOpcode* functions are called via the Dispatcher component with 73 * The AcpiExOpcode* functions are called via the Dispatcher component with
77 * fully resolved operands. 74 * fully resolved operands.
78!*/ 75!*/
79
80/******************************************************************************* 76/*******************************************************************************
81 * 77 *
82 * FUNCTION: acpi_ex_opcode_0A_0T_1R 78 * FUNCTION: acpi_ex_opcode_0A_0T_1R
@@ -88,59 +84,53 @@
88 * DESCRIPTION: Execute operator with no operands, one return value 84 * DESCRIPTION: Execute operator with no operands, one return value
89 * 85 *
90 ******************************************************************************/ 86 ******************************************************************************/
91 87acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
92acpi_status
93acpi_ex_opcode_0A_0T_1R (
94 struct acpi_walk_state *walk_state)
95{ 88{
96 acpi_status status = AE_OK; 89 acpi_status status = AE_OK;
97 union acpi_operand_object *return_desc = NULL; 90 union acpi_operand_object *return_desc = NULL;
98
99
100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R",
101 acpi_ps_get_opcode_name (walk_state->opcode));
102 91
92 ACPI_FUNCTION_TRACE_STR("ex_opcode_0A_0T_1R",
93 acpi_ps_get_opcode_name(walk_state->opcode));
103 94
104 /* Examine the AML opcode */ 95 /* Examine the AML opcode */
105 96
106 switch (walk_state->opcode) { 97 switch (walk_state->opcode) {
107 case AML_TIMER_OP: /* Timer () */ 98 case AML_TIMER_OP: /* Timer () */
108 99
109 /* Create a return object of type Integer */ 100 /* Create a return object of type Integer */
110 101
111 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 102 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
112 if (!return_desc) { 103 if (!return_desc) {
113 status = AE_NO_MEMORY; 104 status = AE_NO_MEMORY;
114 goto cleanup; 105 goto cleanup;
115 } 106 }
116 107#if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer (); 108 return_desc->integer.value = acpi_os_get_timer();
109#endif
118 break; 110 break;
119 111
120 default: /* Unknown opcode */ 112 default: /* Unknown opcode */
121 113
122 ACPI_REPORT_ERROR (("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", 114 ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
123 walk_state->opcode));
124 status = AE_AML_BAD_OPCODE; 115 status = AE_AML_BAD_OPCODE;
125 break; 116 break;
126 } 117 }
127 118
128cleanup: 119 cleanup:
129
130 if (!walk_state->result_obj) {
131 walk_state->result_obj = return_desc;
132 }
133 120
134 /* Delete return object on error */ 121 /* Delete return object on error */
135 122
136 if (ACPI_FAILURE (status)) { 123 if ((ACPI_FAILURE(status)) || walk_state->result_obj) {
137 acpi_ut_remove_reference (return_desc); 124 acpi_ut_remove_reference(return_desc);
125 } else {
126 /* Save the return value */
127
128 walk_state->result_obj = return_desc;
138 } 129 }
139 130
140 return_ACPI_STATUS (status); 131 return_ACPI_STATUS(status);
141} 132}
142 133
143
144/******************************************************************************* 134/*******************************************************************************
145 * 135 *
146 * FUNCTION: acpi_ex_opcode_1A_0T_0R 136 * FUNCTION: acpi_ex_opcode_1A_0T_0R
@@ -154,69 +144,58 @@ cleanup:
154 * 144 *
155 ******************************************************************************/ 145 ******************************************************************************/
156 146
157acpi_status 147acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
158acpi_ex_opcode_1A_0T_0R (
159 struct acpi_walk_state *walk_state)
160{ 148{
161 union acpi_operand_object **operand = &walk_state->operands[0]; 149 union acpi_operand_object **operand = &walk_state->operands[0];
162 acpi_status status = AE_OK; 150 acpi_status status = AE_OK;
163
164
165 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
166 acpi_ps_get_opcode_name (walk_state->opcode));
167 151
152 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_0R",
153 acpi_ps_get_opcode_name(walk_state->opcode));
168 154
169 /* Examine the AML opcode */ 155 /* Examine the AML opcode */
170 156
171 switch (walk_state->opcode) { 157 switch (walk_state->opcode) {
172 case AML_RELEASE_OP: /* Release (mutex_object) */ 158 case AML_RELEASE_OP: /* Release (mutex_object) */
173 159
174 status = acpi_ex_release_mutex (operand[0], walk_state); 160 status = acpi_ex_release_mutex(operand[0], walk_state);
175 break; 161 break;
176 162
163 case AML_RESET_OP: /* Reset (event_object) */
177 164
178 case AML_RESET_OP: /* Reset (event_object) */ 165 status = acpi_ex_system_reset_event(operand[0]);
179
180 status = acpi_ex_system_reset_event (operand[0]);
181 break; 166 break;
182 167
168 case AML_SIGNAL_OP: /* Signal (event_object) */
183 169
184 case AML_SIGNAL_OP: /* Signal (event_object) */ 170 status = acpi_ex_system_signal_event(operand[0]);
185
186 status = acpi_ex_system_signal_event (operand[0]);
187 break; 171 break;
188 172
173 case AML_SLEEP_OP: /* Sleep (msec_time) */
189 174
190 case AML_SLEEP_OP: /* Sleep (msec_time) */ 175 status = acpi_ex_system_do_suspend(operand[0]->integer.value);
191
192 status = acpi_ex_system_do_suspend (operand[0]->integer.value);
193 break; 176 break;
194 177
178 case AML_STALL_OP: /* Stall (usec_time) */
195 179
196 case AML_STALL_OP: /* Stall (usec_time) */ 180 status =
197 181 acpi_ex_system_do_stall((u32) operand[0]->integer.value);
198 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
199 break; 182 break;
200 183
184 case AML_UNLOAD_OP: /* Unload (Handle) */
201 185
202 case AML_UNLOAD_OP: /* Unload (Handle) */ 186 status = acpi_ex_unload_table(operand[0]);
203
204 status = acpi_ex_unload_table (operand[0]);
205 break; 187 break;
206 188
189 default: /* Unknown opcode */
207 190
208 default: /* Unknown opcode */ 191 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
209
210 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
211 walk_state->opcode));
212 status = AE_AML_BAD_OPCODE; 192 status = AE_AML_BAD_OPCODE;
213 break; 193 break;
214 } 194 }
215 195
216 return_ACPI_STATUS (status); 196 return_ACPI_STATUS(status);
217} 197}
218 198
219
220/******************************************************************************* 199/*******************************************************************************
221 * 200 *
222 * FUNCTION: acpi_ex_opcode_1A_1T_0R 201 * FUNCTION: acpi_ex_opcode_1A_1T_0R
@@ -230,41 +209,34 @@ acpi_ex_opcode_1A_0T_0R (
230 * 209 *
231 ******************************************************************************/ 210 ******************************************************************************/
232 211
233acpi_status 212acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
234acpi_ex_opcode_1A_1T_0R (
235 struct acpi_walk_state *walk_state)
236{ 213{
237 acpi_status status = AE_OK; 214 acpi_status status = AE_OK;
238 union acpi_operand_object **operand = &walk_state->operands[0]; 215 union acpi_operand_object **operand = &walk_state->operands[0];
239
240
241 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
242 acpi_ps_get_opcode_name (walk_state->opcode));
243 216
217 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_0R",
218 acpi_ps_get_opcode_name(walk_state->opcode));
244 219
245 /* Examine the AML opcode */ 220 /* Examine the AML opcode */
246 221
247 switch (walk_state->opcode) { 222 switch (walk_state->opcode) {
248 case AML_LOAD_OP: 223 case AML_LOAD_OP:
249 224
250 status = acpi_ex_load_op (operand[0], operand[1], walk_state); 225 status = acpi_ex_load_op(operand[0], operand[1], walk_state);
251 break; 226 break;
252 227
253 default: /* Unknown opcode */ 228 default: /* Unknown opcode */
254 229
255 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", 230 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode));
256 walk_state->opcode));
257 status = AE_AML_BAD_OPCODE; 231 status = AE_AML_BAD_OPCODE;
258 goto cleanup; 232 goto cleanup;
259 } 233 }
260 234
235 cleanup:
261 236
262cleanup: 237 return_ACPI_STATUS(status);
263
264 return_ACPI_STATUS (status);
265} 238}
266 239
267
268/******************************************************************************* 240/*******************************************************************************
269 * 241 *
270 * FUNCTION: acpi_ex_opcode_1A_1T_1R 242 * FUNCTION: acpi_ex_opcode_1A_1T_1R
@@ -278,23 +250,19 @@ cleanup:
278 * 250 *
279 ******************************************************************************/ 251 ******************************************************************************/
280 252
281acpi_status 253acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
282acpi_ex_opcode_1A_1T_1R (
283 struct acpi_walk_state *walk_state)
284{ 254{
285 acpi_status status = AE_OK; 255 acpi_status status = AE_OK;
286 union acpi_operand_object **operand = &walk_state->operands[0]; 256 union acpi_operand_object **operand = &walk_state->operands[0];
287 union acpi_operand_object *return_desc = NULL; 257 union acpi_operand_object *return_desc = NULL;
288 union acpi_operand_object *return_desc2 = NULL; 258 union acpi_operand_object *return_desc2 = NULL;
289 u32 temp32; 259 u32 temp32;
290 u32 i; 260 u32 i;
291 acpi_integer power_of_ten; 261 acpi_integer power_of_ten;
292 acpi_integer digit; 262 acpi_integer digit;
293 263
294 264 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_1R",
295 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", 265 acpi_ps_get_opcode_name(walk_state->opcode));
296 acpi_ps_get_opcode_name (walk_state->opcode));
297
298 266
299 /* Examine the AML opcode */ 267 /* Examine the AML opcode */
300 268
@@ -308,20 +276,19 @@ acpi_ex_opcode_1A_1T_1R (
308 276
309 /* Create a return object of type Integer for these opcodes */ 277 /* Create a return object of type Integer for these opcodes */
310 278
311 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 279 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
312 if (!return_desc) { 280 if (!return_desc) {
313 status = AE_NO_MEMORY; 281 status = AE_NO_MEMORY;
314 goto cleanup; 282 goto cleanup;
315 } 283 }
316 284
317 switch (walk_state->opcode) { 285 switch (walk_state->opcode) {
318 case AML_BIT_NOT_OP: /* Not (Operand, Result) */ 286 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
319 287
320 return_desc->integer.value = ~operand[0]->integer.value; 288 return_desc->integer.value = ~operand[0]->integer.value;
321 break; 289 break;
322 290
323 291 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
324 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
325 292
326 return_desc->integer.value = operand[0]->integer.value; 293 return_desc->integer.value = operand[0]->integer.value;
327 294
@@ -330,15 +297,14 @@ acpi_ex_opcode_1A_1T_1R (
330 * endian unsigned value, so this boundary condition is valid. 297 * endian unsigned value, so this boundary condition is valid.
331 */ 298 */
332 for (temp32 = 0; return_desc->integer.value && 299 for (temp32 = 0; return_desc->integer.value &&
333 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { 300 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
334 return_desc->integer.value >>= 1; 301 return_desc->integer.value >>= 1;
335 } 302 }
336 303
337 return_desc->integer.value = temp32; 304 return_desc->integer.value = temp32;
338 break; 305 break;
339 306
340 307 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
341 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
342 308
343 return_desc->integer.value = operand[0]->integer.value; 309 return_desc->integer.value = operand[0]->integer.value;
344 310
@@ -347,18 +313,17 @@ acpi_ex_opcode_1A_1T_1R (
347 * endian unsigned value, so this boundary condition is valid. 313 * endian unsigned value, so this boundary condition is valid.
348 */ 314 */
349 for (temp32 = 0; return_desc->integer.value && 315 for (temp32 = 0; return_desc->integer.value &&
350 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { 316 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
351 return_desc->integer.value <<= 1; 317 return_desc->integer.value <<= 1;
352 } 318 }
353 319
354 /* Since the bit position is one-based, subtract from 33 (65) */ 320 /* Since the bit position is one-based, subtract from 33 (65) */
355 321
356 return_desc->integer.value = temp32 == 0 ? 0 : 322 return_desc->integer.value = temp32 == 0 ? 0 :
357 (ACPI_INTEGER_BIT_SIZE + 1) - temp32; 323 (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
358 break; 324 break;
359 325
360 326 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
361 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
362 327
363 /* 328 /*
364 * The 64-bit ACPI integer can hold 16 4-bit BCD characters 329 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
@@ -371,7 +336,9 @@ acpi_ex_opcode_1A_1T_1R (
371 336
372 /* Convert each BCD digit (each is one nybble wide) */ 337 /* Convert each BCD digit (each is one nybble wide) */
373 338
374 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { 339 for (i = 0;
340 (i < acpi_gbl_integer_nybble_width) && (digit > 0);
341 i++) {
375 /* Get the least significant 4-bit BCD digit */ 342 /* Get the least significant 4-bit BCD digit */
376 343
377 temp32 = ((u32) digit) & 0xF; 344 temp32 = ((u32) digit) & 0xF;
@@ -379,9 +346,9 @@ acpi_ex_opcode_1A_1T_1R (
379 /* Check the range of the digit */ 346 /* Check the range of the digit */
380 347
381 if (temp32 > 9) { 348 if (temp32 > 9) {
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 349 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
383 "BCD digit too large (not decimal): 0x%X\n", 350 "BCD digit too large (not decimal): 0x%X\n",
384 temp32)); 351 temp32));
385 352
386 status = AE_AML_NUMERIC_OVERFLOW; 353 status = AE_AML_NUMERIC_OVERFLOW;
387 goto cleanup; 354 goto cleanup;
@@ -389,8 +356,8 @@ acpi_ex_opcode_1A_1T_1R (
389 356
390 /* Sum the digit into the result with the current power of 10 */ 357 /* Sum the digit into the result with the current power of 10 */
391 358
392 return_desc->integer.value += (((acpi_integer) temp32) * 359 return_desc->integer.value +=
393 power_of_ten); 360 (((acpi_integer) temp32) * power_of_ten);
394 361
395 /* Shift to next BCD digit */ 362 /* Shift to next BCD digit */
396 363
@@ -402,45 +369,50 @@ acpi_ex_opcode_1A_1T_1R (
402 } 369 }
403 break; 370 break;
404 371
405 372 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
406 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
407 373
408 return_desc->integer.value = 0; 374 return_desc->integer.value = 0;
409 digit = operand[0]->integer.value; 375 digit = operand[0]->integer.value;
410 376
411 /* Each BCD digit is one nybble wide */ 377 /* Each BCD digit is one nybble wide */
412 378
413 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { 379 for (i = 0;
414 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32); 380 (i < acpi_gbl_integer_nybble_width) && (digit > 0);
381 i++) {
382 (void)acpi_ut_short_divide(digit, 10, &digit,
383 &temp32);
415 384
416 /* 385 /*
417 * Insert the BCD digit that resides in the 386 * Insert the BCD digit that resides in the
418 * remainder from above 387 * remainder from above
419 */ 388 */
420 return_desc->integer.value |= (((acpi_integer) temp32) << 389 return_desc->integer.value |=
421 ACPI_MUL_4 (i)); 390 (((acpi_integer) temp32) << ACPI_MUL_4(i));
422 } 391 }
423 392
424 /* Overflow if there is any data left in Digit */ 393 /* Overflow if there is any data left in Digit */
425 394
426 if (digit > 0) { 395 if (digit > 0) {
427 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
428 "Integer too large to convert to BCD: %8.8X%8.8X\n", 397 "Integer too large to convert to BCD: %8.8X%8.8X\n",
429 ACPI_FORMAT_UINT64 (operand[0]->integer.value))); 398 ACPI_FORMAT_UINT64(operand
399 [0]->
400 integer.
401 value)));
430 status = AE_AML_NUMERIC_OVERFLOW; 402 status = AE_AML_NUMERIC_OVERFLOW;
431 goto cleanup; 403 goto cleanup;
432 } 404 }
433 break; 405 break;
434 406
435 407 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
436 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
437 408
438 /* 409 /*
439 * This op is a little strange because the internal return value is 410 * This op is a little strange because the internal return value is
440 * different than the return value stored in the result descriptor 411 * different than the return value stored in the result descriptor
441 * (There are really two return values) 412 * (There are really two return values)
442 */ 413 */
443 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) { 414 if ((struct acpi_namespace_node *)operand[0] ==
415 acpi_gbl_root_node) {
444 /* 416 /*
445 * This means that the object does not exist in the namespace, 417 * This means that the object does not exist in the namespace,
446 * return FALSE 418 * return FALSE
@@ -451,38 +423,38 @@ acpi_ex_opcode_1A_1T_1R (
451 423
452 /* Get the object reference, store it, and remove our reference */ 424 /* Get the object reference, store it, and remove our reference */
453 425
454 status = acpi_ex_get_object_reference (operand[0], 426 status = acpi_ex_get_object_reference(operand[0],
455 &return_desc2, walk_state); 427 &return_desc2,
456 if (ACPI_FAILURE (status)) { 428 walk_state);
429 if (ACPI_FAILURE(status)) {
457 goto cleanup; 430 goto cleanup;
458 } 431 }
459 432
460 status = acpi_ex_store (return_desc2, operand[1], walk_state); 433 status =
461 acpi_ut_remove_reference (return_desc2); 434 acpi_ex_store(return_desc2, operand[1], walk_state);
435 acpi_ut_remove_reference(return_desc2);
462 436
463 /* The object exists in the namespace, return TRUE */ 437 /* The object exists in the namespace, return TRUE */
464 438
465 return_desc->integer.value = ACPI_INTEGER_MAX; 439 return_desc->integer.value = ACPI_INTEGER_MAX;
466 goto cleanup; 440 goto cleanup;
467 441
468
469 default: 442 default:
470 /* No other opcodes get here */ 443 /* No other opcodes get here */
471 break; 444 break;
472 } 445 }
473 break; 446 break;
474 447
475 448 case AML_STORE_OP: /* Store (Source, Target) */
476 case AML_STORE_OP: /* Store (Source, Target) */
477 449
478 /* 450 /*
479 * A store operand is typically a number, string, buffer or lvalue 451 * A store operand is typically a number, string, buffer or lvalue
480 * Be careful about deleting the source object, 452 * Be careful about deleting the source object,
481 * since the object itself may have been stored. 453 * since the object itself may have been stored.
482 */ 454 */
483 status = acpi_ex_store (operand[0], operand[1], walk_state); 455 status = acpi_ex_store(operand[0], operand[1], walk_state);
484 if (ACPI_FAILURE (status)) { 456 if (ACPI_FAILURE(status)) {
485 return_ACPI_STATUS (status); 457 return_ACPI_STATUS(status);
486 } 458 }
487 459
488 /* It is possible that the Store already produced a return object */ 460 /* It is possible that the Store already produced a return object */
@@ -495,92 +467,84 @@ acpi_ex_opcode_1A_1T_1R (
495 * cancel out, and we simply don't do anything. 467 * cancel out, and we simply don't do anything.
496 */ 468 */
497 walk_state->result_obj = operand[0]; 469 walk_state->result_obj = operand[0];
498 walk_state->operands[0] = NULL; /* Prevent deletion */ 470 walk_state->operands[0] = NULL; /* Prevent deletion */
499 } 471 }
500 return_ACPI_STATUS (status); 472 return_ACPI_STATUS(status);
501 473
474 /*
475 * ACPI 2.0 Opcodes
476 */
477 case AML_COPY_OP: /* Copy (Source, Target) */
502 478
503 /* 479 status =
504 * ACPI 2.0 Opcodes 480 acpi_ut_copy_iobject_to_iobject(operand[0], &return_desc,
505 */ 481 walk_state);
506 case AML_COPY_OP: /* Copy (Source, Target) */
507
508 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc,
509 walk_state);
510 break; 482 break;
511 483
484 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
512 485
513 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */ 486 status = acpi_ex_convert_to_string(operand[0], &return_desc,
514 487 ACPI_EXPLICIT_CONVERT_DECIMAL);
515 status = acpi_ex_convert_to_string (operand[0], &return_desc,
516 ACPI_EXPLICIT_CONVERT_DECIMAL);
517 if (return_desc == operand[0]) { 488 if (return_desc == operand[0]) {
518 /* No conversion performed, add ref to handle return value */ 489 /* No conversion performed, add ref to handle return value */
519 acpi_ut_add_reference (return_desc); 490 acpi_ut_add_reference(return_desc);
520 } 491 }
521 break; 492 break;
522 493
494 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
523 495
524 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */ 496 status = acpi_ex_convert_to_string(operand[0], &return_desc,
525 497 ACPI_EXPLICIT_CONVERT_HEX);
526 status = acpi_ex_convert_to_string (operand[0], &return_desc,
527 ACPI_EXPLICIT_CONVERT_HEX);
528 if (return_desc == operand[0]) { 498 if (return_desc == operand[0]) {
529 /* No conversion performed, add ref to handle return value */ 499 /* No conversion performed, add ref to handle return value */
530 acpi_ut_add_reference (return_desc); 500 acpi_ut_add_reference(return_desc);
531 } 501 }
532 break; 502 break;
533 503
504 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
534 505
535 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */ 506 status = acpi_ex_convert_to_buffer(operand[0], &return_desc);
536
537 status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
538 if (return_desc == operand[0]) { 507 if (return_desc == operand[0]) {
539 /* No conversion performed, add ref to handle return value */ 508 /* No conversion performed, add ref to handle return value */
540 acpi_ut_add_reference (return_desc); 509 acpi_ut_add_reference(return_desc);
541 } 510 }
542 break; 511 break;
543 512
513 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
544 514
545 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */ 515 status = acpi_ex_convert_to_integer(operand[0], &return_desc,
546 516 ACPI_ANY_BASE);
547 status = acpi_ex_convert_to_integer (operand[0], &return_desc,
548 ACPI_ANY_BASE);
549 if (return_desc == operand[0]) { 517 if (return_desc == operand[0]) {
550 /* No conversion performed, add ref to handle return value */ 518 /* No conversion performed, add ref to handle return value */
551 acpi_ut_add_reference (return_desc); 519 acpi_ut_add_reference(return_desc);
552 } 520 }
553 break; 521 break;
554 522
555 523 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
556 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */ 524 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
557 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
558 525
559 /* These are two obsolete opcodes */ 526 /* These are two obsolete opcodes */
560 527
561 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 528 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
562 "%s is obsolete and not implemented\n", 529 "%s is obsolete and not implemented\n",
563 acpi_ps_get_opcode_name (walk_state->opcode))); 530 acpi_ps_get_opcode_name(walk_state->opcode)));
564 status = AE_SUPPORT; 531 status = AE_SUPPORT;
565 goto cleanup; 532 goto cleanup;
566 533
534 default: /* Unknown opcode */
567 535
568 default: /* Unknown opcode */ 536 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode));
569
570 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
571 walk_state->opcode));
572 status = AE_AML_BAD_OPCODE; 537 status = AE_AML_BAD_OPCODE;
573 goto cleanup; 538 goto cleanup;
574 } 539 }
575 540
576 if (ACPI_SUCCESS (status)) { 541 if (ACPI_SUCCESS(status)) {
577 /* Store the return value computed above into the target object */ 542 /* Store the return value computed above into the target object */
578 543
579 status = acpi_ex_store (return_desc, operand[1], walk_state); 544 status = acpi_ex_store(return_desc, operand[1], walk_state);
580 } 545 }
581 546
582 547 cleanup:
583cleanup:
584 548
585 if (!walk_state->result_obj) { 549 if (!walk_state->result_obj) {
586 walk_state->result_obj = return_desc; 550 walk_state->result_obj = return_desc;
@@ -588,14 +552,13 @@ cleanup:
588 552
589 /* Delete return object on error */ 553 /* Delete return object on error */
590 554
591 if (ACPI_FAILURE (status)) { 555 if (ACPI_FAILURE(status)) {
592 acpi_ut_remove_reference (return_desc); 556 acpi_ut_remove_reference(return_desc);
593 } 557 }
594 558
595 return_ACPI_STATUS (status); 559 return_ACPI_STATUS(status);
596} 560}
597 561
598
599/******************************************************************************* 562/*******************************************************************************
600 * 563 *
601 * FUNCTION: acpi_ex_opcode_1A_0T_1R 564 * FUNCTION: acpi_ex_opcode_1A_0T_1R
@@ -608,28 +571,24 @@ cleanup:
608 * 571 *
609 ******************************************************************************/ 572 ******************************************************************************/
610 573
611acpi_status 574acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
612acpi_ex_opcode_1A_0T_1R (
613 struct acpi_walk_state *walk_state)
614{ 575{
615 union acpi_operand_object **operand = &walk_state->operands[0]; 576 union acpi_operand_object **operand = &walk_state->operands[0];
616 union acpi_operand_object *temp_desc; 577 union acpi_operand_object *temp_desc;
617 union acpi_operand_object *return_desc = NULL; 578 union acpi_operand_object *return_desc = NULL;
618 acpi_status status = AE_OK; 579 acpi_status status = AE_OK;
619 u32 type; 580 u32 type;
620 acpi_integer value; 581 acpi_integer value;
621
622
623 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
624 acpi_ps_get_opcode_name (walk_state->opcode));
625 582
583 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_1R",
584 acpi_ps_get_opcode_name(walk_state->opcode));
626 585
627 /* Examine the AML opcode */ 586 /* Examine the AML opcode */
628 587
629 switch (walk_state->opcode) { 588 switch (walk_state->opcode) {
630 case AML_LNOT_OP: /* LNot (Operand) */ 589 case AML_LNOT_OP: /* LNot (Operand) */
631 590
632 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 591 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
633 if (!return_desc) { 592 if (!return_desc) {
634 status = AE_NO_MEMORY; 593 status = AE_NO_MEMORY;
635 goto cleanup; 594 goto cleanup;
@@ -644,15 +603,14 @@ acpi_ex_opcode_1A_0T_1R (
644 } 603 }
645 break; 604 break;
646 605
647 606 case AML_DECREMENT_OP: /* Decrement (Operand) */
648 case AML_DECREMENT_OP: /* Decrement (Operand) */ 607 case AML_INCREMENT_OP: /* Increment (Operand) */
649 case AML_INCREMENT_OP: /* Increment (Operand) */
650 608
651 /* 609 /*
652 * Create a new integer. Can't just get the base integer and 610 * Create a new integer. Can't just get the base integer and
653 * increment it because it may be an Arg or Field. 611 * increment it because it may be an Arg or Field.
654 */ 612 */
655 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 613 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
656 if (!return_desc) { 614 if (!return_desc) {
657 status = AE_NO_MEMORY; 615 status = AE_NO_MEMORY;
658 goto cleanup; 616 goto cleanup;
@@ -663,10 +621,11 @@ acpi_ex_opcode_1A_0T_1R (
663 * NS Node or an internal object. 621 * NS Node or an internal object.
664 */ 622 */
665 temp_desc = operand[0]; 623 temp_desc = operand[0];
666 if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) { 624 if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) ==
625 ACPI_DESC_TYPE_OPERAND) {
667 /* Internal reference object - prevent deletion */ 626 /* Internal reference object - prevent deletion */
668 627
669 acpi_ut_add_reference (temp_desc); 628 acpi_ut_add_reference(temp_desc);
670 } 629 }
671 630
672 /* 631 /*
@@ -676,11 +635,15 @@ acpi_ex_opcode_1A_0T_1R (
676 * NOTE: We use LNOT_OP here in order to force resolution of the 635 * NOTE: We use LNOT_OP here in order to force resolution of the
677 * reference operand to an actual integer. 636 * reference operand to an actual integer.
678 */ 637 */
679 status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state); 638 status =
680 if (ACPI_FAILURE (status)) { 639 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc,
681 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", 640 walk_state);
682 acpi_ps_get_opcode_name (walk_state->opcode), 641 if (ACPI_FAILURE(status)) {
683 acpi_format_exception(status))); 642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "%s: bad operand(s) %s\n",
644 acpi_ps_get_opcode_name(walk_state->
645 opcode),
646 acpi_format_exception(status)));
684 647
685 goto cleanup; 648 goto cleanup;
686 } 649 }
@@ -690,25 +653,25 @@ acpi_ex_opcode_1A_0T_1R (
690 * Perform the actual increment or decrement 653 * Perform the actual increment or decrement
691 */ 654 */
692 if (walk_state->opcode == AML_INCREMENT_OP) { 655 if (walk_state->opcode == AML_INCREMENT_OP) {
693 return_desc->integer.value = temp_desc->integer.value +1; 656 return_desc->integer.value =
694 } 657 temp_desc->integer.value + 1;
695 else { 658 } else {
696 return_desc->integer.value = temp_desc->integer.value -1; 659 return_desc->integer.value =
660 temp_desc->integer.value - 1;
697 } 661 }
698 662
699 /* Finished with this Integer object */ 663 /* Finished with this Integer object */
700 664
701 acpi_ut_remove_reference (temp_desc); 665 acpi_ut_remove_reference(temp_desc);
702 666
703 /* 667 /*
704 * Store the result back (indirectly) through the original 668 * Store the result back (indirectly) through the original
705 * Reference object 669 * Reference object
706 */ 670 */
707 status = acpi_ex_store (return_desc, operand[0], walk_state); 671 status = acpi_ex_store(return_desc, operand[0], walk_state);
708 break; 672 break;
709 673
710 674 case AML_TYPE_OP: /* object_type (source_object) */
711 case AML_TYPE_OP: /* object_type (source_object) */
712 675
713 /* 676 /*
714 * Note: The operand is not resolved at this point because we want to 677 * Note: The operand is not resolved at this point because we want to
@@ -719,13 +682,15 @@ acpi_ex_opcode_1A_0T_1R (
719 682
720 /* Get the type of the base object */ 683 /* Get the type of the base object */
721 684
722 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL); 685 status =
723 if (ACPI_FAILURE (status)) { 686 acpi_ex_resolve_multiple(walk_state, operand[0], &type,
687 NULL);
688 if (ACPI_FAILURE(status)) {
724 goto cleanup; 689 goto cleanup;
725 } 690 }
726 /* Allocate a descriptor to hold the type. */ 691 /* Allocate a descriptor to hold the type. */
727 692
728 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 693 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
729 if (!return_desc) { 694 if (!return_desc) {
730 status = AE_NO_MEMORY; 695 status = AE_NO_MEMORY;
731 goto cleanup; 696 goto cleanup;
@@ -734,8 +699,7 @@ acpi_ex_opcode_1A_0T_1R (
734 return_desc->integer.value = type; 699 return_desc->integer.value = type;
735 break; 700 break;
736 701
737 702 case AML_SIZE_OF_OP: /* size_of (source_object) */
738 case AML_SIZE_OF_OP: /* size_of (source_object) */
739 703
740 /* 704 /*
741 * Note: The operand is not resolved at this point because we want to 705 * Note: The operand is not resolved at this point because we want to
@@ -744,9 +708,10 @@ acpi_ex_opcode_1A_0T_1R (
744 708
745 /* Get the base object */ 709 /* Get the base object */
746 710
747 status = acpi_ex_resolve_multiple (walk_state, 711 status = acpi_ex_resolve_multiple(walk_state,
748 operand[0], &type, &temp_desc); 712 operand[0], &type,
749 if (ACPI_FAILURE (status)) { 713 &temp_desc);
714 if (ACPI_FAILURE(status)) {
750 goto cleanup; 715 goto cleanup;
751 } 716 }
752 717
@@ -777,9 +742,9 @@ acpi_ex_opcode_1A_0T_1R (
777 break; 742 break;
778 743
779 default: 744 default:
780 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 745 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
781 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", 746 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
782 acpi_ut_get_type_name (type))); 747 acpi_ut_get_type_name(type)));
783 status = AE_AML_OPERAND_TYPE; 748 status = AE_AML_OPERAND_TYPE;
784 goto cleanup; 749 goto cleanup;
785 } 750 }
@@ -788,7 +753,7 @@ acpi_ex_opcode_1A_0T_1R (
788 * Now that we have the size of the object, create a result 753 * Now that we have the size of the object, create a result
789 * object to hold the value 754 * object to hold the value
790 */ 755 */
791 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 756 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
792 if (!return_desc) { 757 if (!return_desc) {
793 status = AE_NO_MEMORY; 758 status = AE_NO_MEMORY;
794 goto cleanup; 759 goto cleanup;
@@ -797,22 +762,23 @@ acpi_ex_opcode_1A_0T_1R (
797 return_desc->integer.value = value; 762 return_desc->integer.value = value;
798 break; 763 break;
799 764
765 case AML_REF_OF_OP: /* ref_of (source_object) */
800 766
801 case AML_REF_OF_OP: /* ref_of (source_object) */ 767 status =
802 768 acpi_ex_get_object_reference(operand[0], &return_desc,
803 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state); 769 walk_state);
804 if (ACPI_FAILURE (status)) { 770 if (ACPI_FAILURE(status)) {
805 goto cleanup; 771 goto cleanup;
806 } 772 }
807 break; 773 break;
808 774
809 775 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
810 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
811 776
812 /* Check for a method local or argument, or standalone String */ 777 /* Check for a method local or argument, or standalone String */
813 778
814 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) { 779 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
815 switch (ACPI_GET_OBJECT_TYPE (operand[0])) { 780 ACPI_DESC_TYPE_NAMED) {
781 switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
816 case ACPI_TYPE_LOCAL_REFERENCE: 782 case ACPI_TYPE_LOCAL_REFERENCE:
817 /* 783 /*
818 * This is a deref_of (local_x | arg_x) 784 * This is a deref_of (local_x | arg_x)
@@ -825,11 +791,12 @@ acpi_ex_opcode_1A_0T_1R (
825 791
826 /* Set Operand[0] to the value of the local/arg */ 792 /* Set Operand[0] to the value of the local/arg */
827 793
828 status = acpi_ds_method_data_get_value ( 794 status =
829 operand[0]->reference.opcode, 795 acpi_ds_method_data_get_value
830 operand[0]->reference.offset, 796 (operand[0]->reference.opcode,
831 walk_state, &temp_desc); 797 operand[0]->reference.offset,
832 if (ACPI_FAILURE (status)) { 798 walk_state, &temp_desc);
799 if (ACPI_FAILURE(status)) {
833 goto cleanup; 800 goto cleanup;
834 } 801 }
835 802
@@ -837,7 +804,7 @@ acpi_ex_opcode_1A_0T_1R (
837 * Delete our reference to the input object and 804 * Delete our reference to the input object and
838 * point to the object just retrieved 805 * point to the object just retrieved
839 */ 806 */
840 acpi_ut_remove_reference (operand[0]); 807 acpi_ut_remove_reference(operand[0]);
841 operand[0] = temp_desc; 808 operand[0] = temp_desc;
842 break; 809 break;
843 810
@@ -845,8 +812,9 @@ acpi_ex_opcode_1A_0T_1R (
845 812
846 /* Get the object to which the reference refers */ 813 /* Get the object to which the reference refers */
847 814
848 temp_desc = operand[0]->reference.object; 815 temp_desc =
849 acpi_ut_remove_reference (operand[0]); 816 operand[0]->reference.object;
817 acpi_ut_remove_reference(operand[0]);
850 operand[0] = temp_desc; 818 operand[0] = temp_desc;
851 break; 819 break;
852 820
@@ -857,7 +825,6 @@ acpi_ex_opcode_1A_0T_1R (
857 } 825 }
858 break; 826 break;
859 827
860
861 case ACPI_TYPE_STRING: 828 case ACPI_TYPE_STRING:
862 829
863 /* 830 /*
@@ -868,22 +835,28 @@ acpi_ex_opcode_1A_0T_1R (
868 * 2) Dereference the node to an actual object. Could be a 835 * 2) Dereference the node to an actual object. Could be a
869 * Field, so we need to resolve the node to a value. 836 * Field, so we need to resolve the node to a value.
870 */ 837 */
871 status = acpi_ns_get_node_by_path (operand[0]->string.pointer, 838 status =
872 walk_state->scope_info->scope.node, 839 acpi_ns_get_node_by_path(operand[0]->string.
873 ACPI_NS_SEARCH_PARENT, 840 pointer,
874 ACPI_CAST_INDIRECT_PTR ( 841 walk_state->
875 struct acpi_namespace_node, &return_desc)); 842 scope_info->scope.
876 if (ACPI_FAILURE (status)) { 843 node,
844 ACPI_NS_SEARCH_PARENT,
845 ACPI_CAST_INDIRECT_PTR
846 (struct
847 acpi_namespace_node,
848 &return_desc));
849 if (ACPI_FAILURE(status)) {
877 goto cleanup; 850 goto cleanup;
878 } 851 }
879 852
880 status = acpi_ex_resolve_node_to_value ( 853 status =
881 ACPI_CAST_INDIRECT_PTR ( 854 acpi_ex_resolve_node_to_value
882 struct acpi_namespace_node, &return_desc), 855 (ACPI_CAST_INDIRECT_PTR
883 walk_state); 856 (struct acpi_namespace_node, &return_desc),
857 walk_state);
884 goto cleanup; 858 goto cleanup;
885 859
886
887 default: 860 default:
888 861
889 status = AE_AML_OPERAND_TYPE; 862 status = AE_AML_OPERAND_TYPE;
@@ -893,17 +866,20 @@ acpi_ex_opcode_1A_0T_1R (
893 866
894 /* Operand[0] may have changed from the code above */ 867 /* Operand[0] may have changed from the code above */
895 868
896 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) { 869 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) ==
870 ACPI_DESC_TYPE_NAMED) {
897 /* 871 /*
898 * This is a deref_of (object_reference) 872 * This is a deref_of (object_reference)
899 * Get the actual object from the Node (This is the dereference). 873 * Get the actual object from the Node (This is the dereference).
900 * This case may only happen when a local_x or arg_x is 874 * This case may only happen when a local_x or arg_x is
901 * dereferenced above. 875 * dereferenced above.
902 */ 876 */
903 return_desc = acpi_ns_get_attached_object ( 877 return_desc = acpi_ns_get_attached_object((struct
904 (struct acpi_namespace_node *) operand[0]); 878 acpi_namespace_node
905 } 879 *)
906 else { 880 operand[0]);
881 acpi_ut_add_reference(return_desc);
882 } else {
907 /* 883 /*
908 * This must be a reference object produced by either the 884 * This must be a reference object produced by either the
909 * Index() or ref_of() operator 885 * Index() or ref_of() operator
@@ -918,7 +894,8 @@ acpi_ex_opcode_1A_0T_1R (
918 switch (operand[0]->reference.target_type) { 894 switch (operand[0]->reference.target_type) {
919 case ACPI_TYPE_BUFFER_FIELD: 895 case ACPI_TYPE_BUFFER_FIELD:
920 896
921 temp_desc = operand[0]->reference.object; 897 temp_desc =
898 operand[0]->reference.object;
922 899
923 /* 900 /*
924 * Create a new object that contains one element of the 901 * Create a new object that contains one element of the
@@ -928,7 +905,9 @@ acpi_ex_opcode_1A_0T_1R (
928 * sub-buffer of the main buffer, it is only a pointer to a 905 * sub-buffer of the main buffer, it is only a pointer to a
929 * single element (byte) of the buffer! 906 * single element (byte) of the buffer!
930 */ 907 */
931 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 908 return_desc =
909 acpi_ut_create_internal_object
910 (ACPI_TYPE_INTEGER);
932 if (!return_desc) { 911 if (!return_desc) {
933 status = AE_NO_MEMORY; 912 status = AE_NO_MEMORY;
934 goto cleanup; 913 goto cleanup;
@@ -940,66 +919,63 @@ acpi_ex_opcode_1A_0T_1R (
940 * reference to the buffer itself. 919 * reference to the buffer itself.
941 */ 920 */
942 return_desc->integer.value = 921 return_desc->integer.value =
943 temp_desc->buffer.pointer[operand[0]->reference.offset]; 922 temp_desc->buffer.
923 pointer[operand[0]->reference.
924 offset];
944 break; 925 break;
945 926
946
947 case ACPI_TYPE_PACKAGE: 927 case ACPI_TYPE_PACKAGE:
948 928
949 /* 929 /*
950 * Return the referenced element of the package. We must 930 * Return the referenced element of the package. We must
951 * add another reference to the referenced object, however. 931 * add another reference to the referenced object, however.
952 */ 932 */
953 return_desc = *(operand[0]->reference.where); 933 return_desc =
954 if (!return_desc) { 934 *(operand[0]->reference.where);
955 /* 935 if (return_desc) {
956 * We can't return a NULL dereferenced value. This is 936 acpi_ut_add_reference
957 * an uninitialized package element and is thus a 937 (return_desc);
958 * severe error.
959 */
960 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
961 "NULL package element obj %p\n",
962 operand[0]));
963 status = AE_AML_UNINITIALIZED_ELEMENT;
964 goto cleanup;
965 } 938 }
966 939
967 acpi_ut_add_reference (return_desc);
968 break; 940 break;
969 941
970
971 default: 942 default:
972 943
973 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 944 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
974 "Unknown Index target_type %X in obj %p\n", 945 "Unknown Index target_type %X in obj %p\n",
975 operand[0]->reference.target_type, operand[0])); 946 operand[0]->reference.
947 target_type,
948 operand[0]));
976 status = AE_AML_OPERAND_TYPE; 949 status = AE_AML_OPERAND_TYPE;
977 goto cleanup; 950 goto cleanup;
978 } 951 }
979 break; 952 break;
980 953
981
982 case AML_REF_OF_OP: 954 case AML_REF_OF_OP:
983 955
984 return_desc = operand[0]->reference.object; 956 return_desc = operand[0]->reference.object;
985 957
986 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == 958 if (ACPI_GET_DESCRIPTOR_TYPE(return_desc) ==
987 ACPI_DESC_TYPE_NAMED) { 959 ACPI_DESC_TYPE_NAMED) {
988 960
989 return_desc = acpi_ns_get_attached_object ( 961 return_desc =
990 (struct acpi_namespace_node *) return_desc); 962 acpi_ns_get_attached_object((struct
963 acpi_namespace_node
964 *)
965 return_desc);
991 } 966 }
992 967
993 /* Add another reference to the object! */ 968 /* Add another reference to the object! */
994 969
995 acpi_ut_add_reference (return_desc); 970 acpi_ut_add_reference(return_desc);
996 break; 971 break;
997 972
998
999 default: 973 default:
1000 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 974 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1001 "Unknown opcode in ref(%p) - %X\n", 975 "Unknown opcode in ref(%p) - %X\n",
1002 operand[0], operand[0]->reference.opcode)); 976 operand[0],
977 operand[0]->reference.
978 opcode));
1003 979
1004 status = AE_TYPE; 980 status = AE_TYPE;
1005 goto cleanup; 981 goto cleanup;
@@ -1007,25 +983,21 @@ acpi_ex_opcode_1A_0T_1R (
1007 } 983 }
1008 break; 984 break;
1009 985
1010
1011 default: 986 default:
1012 987
1013 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", 988 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
1014 walk_state->opcode));
1015 status = AE_AML_BAD_OPCODE; 989 status = AE_AML_BAD_OPCODE;
1016 goto cleanup; 990 goto cleanup;
1017 } 991 }
1018 992
1019 993 cleanup:
1020cleanup:
1021 994
1022 /* Delete return object on error */ 995 /* Delete return object on error */
1023 996
1024 if (ACPI_FAILURE (status)) { 997 if (ACPI_FAILURE(status)) {
1025 acpi_ut_remove_reference (return_desc); 998 acpi_ut_remove_reference(return_desc);
1026 } 999 }
1027 1000
1028 walk_state->result_obj = return_desc; 1001 walk_state->result_obj = return_desc;
1029 return_ACPI_STATUS (status); 1002 return_ACPI_STATUS(status);
1030} 1003}
1031
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 7429032c2b6c..8d70c6beef00 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -41,17 +41,14 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/acevents.h> 47#include <acpi/acevents.h>
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exoparg2") 51ACPI_MODULE_NAME("exoparg2")
54
55 52
56/*! 53/*!
57 * Naming convention for AML interpreter execution routines. 54 * Naming convention for AML interpreter execution routines.
@@ -74,8 +71,6 @@
74 * The AcpiExOpcode* functions are called via the Dispatcher component with 71 * The AcpiExOpcode* functions are called via the Dispatcher component with
75 * fully resolved operands. 72 * fully resolved operands.
76!*/ 73!*/
77
78
79/******************************************************************************* 74/*******************************************************************************
80 * 75 *
81 * FUNCTION: acpi_ex_opcode_2A_0T_0R 76 * FUNCTION: acpi_ex_opcode_2A_0T_0R
@@ -90,29 +85,24 @@
90 * ALLOCATION: Deletes both operands 85 * ALLOCATION: Deletes both operands
91 * 86 *
92 ******************************************************************************/ 87 ******************************************************************************/
93 88acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
94acpi_status
95acpi_ex_opcode_2A_0T_0R (
96 struct acpi_walk_state *walk_state)
97{ 89{
98 union acpi_operand_object **operand = &walk_state->operands[0]; 90 union acpi_operand_object **operand = &walk_state->operands[0];
99 struct acpi_namespace_node *node; 91 struct acpi_namespace_node *node;
100 u32 value; 92 u32 value;
101 acpi_status status = AE_OK; 93 acpi_status status = AE_OK;
102
103
104 ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_0R",
105 acpi_ps_get_opcode_name (walk_state->opcode));
106 94
95 ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_0R",
96 acpi_ps_get_opcode_name(walk_state->opcode));
107 97
108 /* Examine the opcode */ 98 /* Examine the opcode */
109 99
110 switch (walk_state->opcode) { 100 switch (walk_state->opcode) {
111 case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */ 101 case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */
112 102
113 /* The first operand is a namespace node */ 103 /* The first operand is a namespace node */
114 104
115 node = (struct acpi_namespace_node *) operand[0]; 105 node = (struct acpi_namespace_node *)operand[0];
116 106
117 /* Second value is the notify value */ 107 /* Second value is the notify value */
118 108
@@ -120,15 +110,14 @@ acpi_ex_opcode_2A_0T_0R (
120 110
121 /* Are notifies allowed on this object? */ 111 /* Are notifies allowed on this object? */
122 112
123 if (!acpi_ev_is_notify_object (node)) { 113 if (!acpi_ev_is_notify_object(node)) {
124 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 114 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
125 "Unexpected notify object type [%s]\n", 115 "Unexpected notify object type [%s]\n",
126 acpi_ut_get_type_name (node->type))); 116 acpi_ut_get_type_name(node->type)));
127 117
128 status = AE_AML_OPERAND_TYPE; 118 status = AE_AML_OPERAND_TYPE;
129 break; 119 break;
130 } 120 }
131
132#ifdef ACPI_GPE_NOTIFY_CHECK 121#ifdef ACPI_GPE_NOTIFY_CHECK
133 /* 122 /*
134 * GPE method wake/notify check. Here, we want to ensure that we 123 * GPE method wake/notify check. Here, we want to ensure that we
@@ -144,12 +133,14 @@ acpi_ex_opcode_2A_0T_0R (
144 * If all three cases are true, this is a wake-only GPE that should 133 * If all three cases are true, this is a wake-only GPE that should
145 * be disabled at runtime. 134 * be disabled at runtime.
146 */ 135 */
147 if (value == 2) /* device_wake */ { 136 if (value == 2) { /* device_wake */
148 status = acpi_ev_check_for_wake_only_gpe (walk_state->gpe_event_info); 137 status =
149 if (ACPI_FAILURE (status)) { 138 acpi_ev_check_for_wake_only_gpe(walk_state->
139 gpe_event_info);
140 if (ACPI_FAILURE(status)) {
150 /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ 141 /* AE_WAKE_ONLY_GPE only error, means ignore this notify */
151 142
152 return_ACPI_STATUS (AE_OK) 143 return_ACPI_STATUS(AE_OK)
153 } 144 }
154 } 145 }
155#endif 146#endif
@@ -161,21 +152,18 @@ acpi_ex_opcode_2A_0T_0R (
161 * from this thread -- because handlers may in turn run other 152 * from this thread -- because handlers may in turn run other
162 * control methods. 153 * control methods.
163 */ 154 */
164 status = acpi_ev_queue_notify_request (node, value); 155 status = acpi_ev_queue_notify_request(node, value);
165 break; 156 break;
166 157
167
168 default: 158 default:
169 159
170 ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", 160 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
171 walk_state->opcode));
172 status = AE_AML_BAD_OPCODE; 161 status = AE_AML_BAD_OPCODE;
173 } 162 }
174 163
175 return_ACPI_STATUS (status); 164 return_ACPI_STATUS(status);
176} 165}
177 166
178
179/******************************************************************************* 167/*******************************************************************************
180 * 168 *
181 * FUNCTION: acpi_ex_opcode_2A_2T_1R 169 * FUNCTION: acpi_ex_opcode_2A_2T_1R
@@ -189,19 +177,15 @@ acpi_ex_opcode_2A_0T_0R (
189 * 177 *
190 ******************************************************************************/ 178 ******************************************************************************/
191 179
192acpi_status 180acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state)
193acpi_ex_opcode_2A_2T_1R (
194 struct acpi_walk_state *walk_state)
195{ 181{
196 union acpi_operand_object **operand = &walk_state->operands[0]; 182 union acpi_operand_object **operand = &walk_state->operands[0];
197 union acpi_operand_object *return_desc1 = NULL; 183 union acpi_operand_object *return_desc1 = NULL;
198 union acpi_operand_object *return_desc2 = NULL; 184 union acpi_operand_object *return_desc2 = NULL;
199 acpi_status status; 185 acpi_status status;
200
201
202 ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R",
203 acpi_ps_get_opcode_name (walk_state->opcode));
204 186
187 ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_2T_1R",
188 acpi_ps_get_opcode_name(walk_state->opcode));
205 189
206 /* Execute the opcode */ 190 /* Execute the opcode */
207 191
@@ -210,13 +194,15 @@ acpi_ex_opcode_2A_2T_1R (
210 194
211 /* Divide (Dividend, Divisor, remainder_result quotient_result) */ 195 /* Divide (Dividend, Divisor, remainder_result quotient_result) */
212 196
213 return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 197 return_desc1 =
198 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
214 if (!return_desc1) { 199 if (!return_desc1) {
215 status = AE_NO_MEMORY; 200 status = AE_NO_MEMORY;
216 goto cleanup; 201 goto cleanup;
217 } 202 }
218 203
219 return_desc2 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 204 return_desc2 =
205 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
220 if (!return_desc2) { 206 if (!return_desc2) {
221 status = AE_NO_MEMORY; 207 status = AE_NO_MEMORY;
222 goto cleanup; 208 goto cleanup;
@@ -224,33 +210,31 @@ acpi_ex_opcode_2A_2T_1R (
224 210
225 /* Quotient to return_desc1, remainder to return_desc2 */ 211 /* Quotient to return_desc1, remainder to return_desc2 */
226 212
227 status = acpi_ut_divide (operand[0]->integer.value, 213 status = acpi_ut_divide(operand[0]->integer.value,
228 operand[1]->integer.value, 214 operand[1]->integer.value,
229 &return_desc1->integer.value, 215 &return_desc1->integer.value,
230 &return_desc2->integer.value); 216 &return_desc2->integer.value);
231 if (ACPI_FAILURE (status)) { 217 if (ACPI_FAILURE(status)) {
232 goto cleanup; 218 goto cleanup;
233 } 219 }
234 break; 220 break;
235 221
236
237 default: 222 default:
238 223
239 ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", 224 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode));
240 walk_state->opcode));
241 status = AE_AML_BAD_OPCODE; 225 status = AE_AML_BAD_OPCODE;
242 goto cleanup; 226 goto cleanup;
243 } 227 }
244 228
245 /* Store the results to the target reference operands */ 229 /* Store the results to the target reference operands */
246 230
247 status = acpi_ex_store (return_desc2, operand[2], walk_state); 231 status = acpi_ex_store(return_desc2, operand[2], walk_state);
248 if (ACPI_FAILURE (status)) { 232 if (ACPI_FAILURE(status)) {
249 goto cleanup; 233 goto cleanup;
250 } 234 }
251 235
252 status = acpi_ex_store (return_desc1, operand[3], walk_state); 236 status = acpi_ex_store(return_desc1, operand[3], walk_state);
253 if (ACPI_FAILURE (status)) { 237 if (ACPI_FAILURE(status)) {
254 goto cleanup; 238 goto cleanup;
255 } 239 }
256 240
@@ -258,24 +242,22 @@ acpi_ex_opcode_2A_2T_1R (
258 242
259 walk_state->result_obj = return_desc1; 243 walk_state->result_obj = return_desc1;
260 244
261 245 cleanup:
262cleanup:
263 /* 246 /*
264 * Since the remainder is not returned indirectly, remove a reference to 247 * Since the remainder is not returned indirectly, remove a reference to
265 * it. Only the quotient is returned indirectly. 248 * it. Only the quotient is returned indirectly.
266 */ 249 */
267 acpi_ut_remove_reference (return_desc2); 250 acpi_ut_remove_reference(return_desc2);
268 251
269 if (ACPI_FAILURE (status)) { 252 if (ACPI_FAILURE(status)) {
270 /* Delete the return object */ 253 /* Delete the return object */
271 254
272 acpi_ut_remove_reference (return_desc1); 255 acpi_ut_remove_reference(return_desc1);
273 } 256 }
274 257
275 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
276} 259}
277 260
278
279/******************************************************************************* 261/*******************************************************************************
280 * 262 *
281 * FUNCTION: acpi_ex_opcode_2A_1T_1R 263 * FUNCTION: acpi_ex_opcode_2A_1T_1R
@@ -289,42 +271,39 @@ cleanup:
289 * 271 *
290 ******************************************************************************/ 272 ******************************************************************************/
291 273
292acpi_status 274acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
293acpi_ex_opcode_2A_1T_1R (
294 struct acpi_walk_state *walk_state)
295{ 275{
296 union acpi_operand_object **operand = &walk_state->operands[0]; 276 union acpi_operand_object **operand = &walk_state->operands[0];
297 union acpi_operand_object *return_desc = NULL; 277 union acpi_operand_object *return_desc = NULL;
298 acpi_integer index; 278 acpi_integer index;
299 acpi_status status = AE_OK; 279 acpi_status status = AE_OK;
300 acpi_size length; 280 acpi_size length;
301
302
303 ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R",
304 acpi_ps_get_opcode_name (walk_state->opcode));
305 281
282 ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_1T_1R",
283 acpi_ps_get_opcode_name(walk_state->opcode));
306 284
307 /* Execute the opcode */ 285 /* Execute the opcode */
308 286
309 if (walk_state->op_info->flags & AML_MATH) { 287 if (walk_state->op_info->flags & AML_MATH) {
310 /* All simple math opcodes (add, etc.) */ 288 /* All simple math opcodes (add, etc.) */
311 289
312 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 290 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
313 if (!return_desc) { 291 if (!return_desc) {
314 status = AE_NO_MEMORY; 292 status = AE_NO_MEMORY;
315 goto cleanup; 293 goto cleanup;
316 } 294 }
317 295
318 return_desc->integer.value = acpi_ex_do_math_op (walk_state->opcode, 296 return_desc->integer.value =
319 operand[0]->integer.value, 297 acpi_ex_do_math_op(walk_state->opcode,
320 operand[1]->integer.value); 298 operand[0]->integer.value,
299 operand[1]->integer.value);
321 goto store_result_to_target; 300 goto store_result_to_target;
322 } 301 }
323 302
324 switch (walk_state->opcode) { 303 switch (walk_state->opcode) {
325 case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */ 304 case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
326 305
327 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 306 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
328 if (!return_desc) { 307 if (!return_desc) {
329 status = AE_NO_MEMORY; 308 status = AE_NO_MEMORY;
330 goto cleanup; 309 goto cleanup;
@@ -332,21 +311,18 @@ acpi_ex_opcode_2A_1T_1R (
332 311
333 /* return_desc will contain the remainder */ 312 /* return_desc will contain the remainder */
334 313
335 status = acpi_ut_divide (operand[0]->integer.value, 314 status = acpi_ut_divide(operand[0]->integer.value,
336 operand[1]->integer.value, 315 operand[1]->integer.value,
337 NULL, 316 NULL, &return_desc->integer.value);
338 &return_desc->integer.value);
339 break; 317 break;
340 318
319 case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
341 320
342 case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ 321 status = acpi_ex_do_concatenate(operand[0], operand[1],
343 322 &return_desc, walk_state);
344 status = acpi_ex_do_concatenate (operand[0], operand[1],
345 &return_desc, walk_state);
346 break; 323 break;
347 324
348 325 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
349 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
350 326
351 /* 327 /*
352 * Input object is guaranteed to be a buffer at this point (it may have 328 * Input object is guaranteed to be a buffer at this point (it may have
@@ -365,8 +341,8 @@ acpi_ex_opcode_2A_1T_1R (
365 */ 341 */
366 length = 0; 342 length = 0;
367 while ((length < operand[0]->buffer.length) && 343 while ((length < operand[0]->buffer.length) &&
368 (length < operand[1]->integer.value) && 344 (length < operand[1]->integer.value) &&
369 (operand[0]->buffer.pointer[length])) { 345 (operand[0]->buffer.pointer[length])) {
370 length++; 346 length++;
371 if (length > ACPI_MAX_STRING_CONVERSION) { 347 if (length > ACPI_MAX_STRING_CONVERSION) {
372 status = AE_AML_STRING_LIMIT; 348 status = AE_AML_STRING_LIMIT;
@@ -376,33 +352,32 @@ acpi_ex_opcode_2A_1T_1R (
376 352
377 /* Allocate a new string object */ 353 /* Allocate a new string object */
378 354
379 return_desc = acpi_ut_create_string_object (length); 355 return_desc = acpi_ut_create_string_object(length);
380 if (!return_desc) { 356 if (!return_desc) {
381 status = AE_NO_MEMORY; 357 status = AE_NO_MEMORY;
382 goto cleanup; 358 goto cleanup;
383 } 359 }
384 360
385 /* Copy the raw buffer data with no transform. NULL terminated already*/ 361 /* Copy the raw buffer data with no transform. NULL terminated already */
386 362
387 ACPI_MEMCPY (return_desc->string.pointer, 363 ACPI_MEMCPY(return_desc->string.pointer,
388 operand[0]->buffer.pointer, length); 364 operand[0]->buffer.pointer, length);
389 break; 365 break;
390 366
391
392 case AML_CONCAT_RES_OP: 367 case AML_CONCAT_RES_OP:
393 368
394 /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */ 369 /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
395 370
396 status = acpi_ex_concat_template (operand[0], operand[1], 371 status = acpi_ex_concat_template(operand[0], operand[1],
397 &return_desc, walk_state); 372 &return_desc, walk_state);
398 break; 373 break;
399 374
400 375 case AML_INDEX_OP: /* Index (Source Index Result) */
401 case AML_INDEX_OP: /* Index (Source Index Result) */
402 376
403 /* Create the internal return object */ 377 /* Create the internal return object */
404 378
405 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); 379 return_desc =
380 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
406 if (!return_desc) { 381 if (!return_desc) {
407 status = AE_NO_MEMORY; 382 status = AE_NO_MEMORY;
408 goto cleanup; 383 goto cleanup;
@@ -412,76 +387,75 @@ acpi_ex_opcode_2A_1T_1R (
412 387
413 /* At this point, the Source operand is a Package, Buffer, or String */ 388 /* At this point, the Source operand is a Package, Buffer, or String */
414 389
415 if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) { 390 if (ACPI_GET_OBJECT_TYPE(operand[0]) == ACPI_TYPE_PACKAGE) {
416 /* Object to be indexed is a Package */ 391 /* Object to be indexed is a Package */
417 392
418 if (index >= operand[0]->package.count) { 393 if (index >= operand[0]->package.count) {
419 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 394 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
420 "Index value (%X%8.8X) beyond package end (%X)\n", 395 "Index value (%X%8.8X) beyond package end (%X)\n",
421 ACPI_FORMAT_UINT64 (index), operand[0]->package.count)); 396 ACPI_FORMAT_UINT64(index),
397 operand[0]->package.count));
422 status = AE_AML_PACKAGE_LIMIT; 398 status = AE_AML_PACKAGE_LIMIT;
423 goto cleanup; 399 goto cleanup;
424 } 400 }
425 401
426 return_desc->reference.target_type = ACPI_TYPE_PACKAGE; 402 return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
427 return_desc->reference.object = operand[0]; 403 return_desc->reference.object = operand[0];
428 return_desc->reference.where = &operand[0]->package.elements [ 404 return_desc->reference.where =
429 index]; 405 &operand[0]->package.elements[index];
430 } 406 } else {
431 else {
432 /* Object to be indexed is a Buffer/String */ 407 /* Object to be indexed is a Buffer/String */
433 408
434 if (index >= operand[0]->buffer.length) { 409 if (index >= operand[0]->buffer.length) {
435 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 410 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
436 "Index value (%X%8.8X) beyond end of buffer (%X)\n", 411 "Index value (%X%8.8X) beyond end of buffer (%X)\n",
437 ACPI_FORMAT_UINT64 (index), operand[0]->buffer.length)); 412 ACPI_FORMAT_UINT64(index),
413 operand[0]->buffer.length));
438 status = AE_AML_BUFFER_LIMIT; 414 status = AE_AML_BUFFER_LIMIT;
439 goto cleanup; 415 goto cleanup;
440 } 416 }
441 417
442 return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD; 418 return_desc->reference.target_type =
443 return_desc->reference.object = operand[0]; 419 ACPI_TYPE_BUFFER_FIELD;
420 return_desc->reference.object = operand[0];
444 } 421 }
445 422
446 /* 423 /*
447 * Add a reference to the target package/buffer/string for the life 424 * Add a reference to the target package/buffer/string for the life
448 * of the index. 425 * of the index.
449 */ 426 */
450 acpi_ut_add_reference (operand[0]); 427 acpi_ut_add_reference(operand[0]);
451 428
452 /* Complete the Index reference object */ 429 /* Complete the Index reference object */
453 430
454 return_desc->reference.opcode = AML_INDEX_OP; 431 return_desc->reference.opcode = AML_INDEX_OP;
455 return_desc->reference.offset = (u32) index; 432 return_desc->reference.offset = (u32) index;
456 433
457 /* Store the reference to the Target */ 434 /* Store the reference to the Target */
458 435
459 status = acpi_ex_store (return_desc, operand[2], walk_state); 436 status = acpi_ex_store(return_desc, operand[2], walk_state);
460 437
461 /* Return the reference */ 438 /* Return the reference */
462 439
463 walk_state->result_obj = return_desc; 440 walk_state->result_obj = return_desc;
464 goto cleanup; 441 goto cleanup;
465 442
466
467 default: 443 default:
468 444
469 ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", 445 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode));
470 walk_state->opcode));
471 status = AE_AML_BAD_OPCODE; 446 status = AE_AML_BAD_OPCODE;
472 break; 447 break;
473 } 448 }
474 449
450 store_result_to_target:
475 451
476store_result_to_target: 452 if (ACPI_SUCCESS(status)) {
477
478 if (ACPI_SUCCESS (status)) {
479 /* 453 /*
480 * Store the result of the operation (which is now in return_desc) into 454 * Store the result of the operation (which is now in return_desc) into
481 * the Target descriptor. 455 * the Target descriptor.
482 */ 456 */
483 status = acpi_ex_store (return_desc, operand[2], walk_state); 457 status = acpi_ex_store(return_desc, operand[2], walk_state);
484 if (ACPI_FAILURE (status)) { 458 if (ACPI_FAILURE(status)) {
485 goto cleanup; 459 goto cleanup;
486 } 460 }
487 461
@@ -490,19 +464,17 @@ store_result_to_target:
490 } 464 }
491 } 465 }
492 466
493 467 cleanup:
494cleanup:
495 468
496 /* Delete return object on error */ 469 /* Delete return object on error */
497 470
498 if (ACPI_FAILURE (status)) { 471 if (ACPI_FAILURE(status)) {
499 acpi_ut_remove_reference (return_desc); 472 acpi_ut_remove_reference(return_desc);
500 } 473 }
501 474
502 return_ACPI_STATUS (status); 475 return_ACPI_STATUS(status);
503} 476}
504 477
505
506/******************************************************************************* 478/*******************************************************************************
507 * 479 *
508 * FUNCTION: acpi_ex_opcode_2A_0T_1R 480 * FUNCTION: acpi_ex_opcode_2A_0T_1R
@@ -515,23 +487,19 @@ cleanup:
515 * 487 *
516 ******************************************************************************/ 488 ******************************************************************************/
517 489
518acpi_status 490acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
519acpi_ex_opcode_2A_0T_1R (
520 struct acpi_walk_state *walk_state)
521{ 491{
522 union acpi_operand_object **operand = &walk_state->operands[0]; 492 union acpi_operand_object **operand = &walk_state->operands[0];
523 union acpi_operand_object *return_desc = NULL; 493 union acpi_operand_object *return_desc = NULL;
524 acpi_status status = AE_OK; 494 acpi_status status = AE_OK;
525 u8 logical_result = FALSE; 495 u8 logical_result = FALSE;
526
527
528 ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R",
529 acpi_ps_get_opcode_name (walk_state->opcode));
530 496
497 ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_1R",
498 acpi_ps_get_opcode_name(walk_state->opcode));
531 499
532 /* Create the internal return object */ 500 /* Create the internal return object */
533 501
534 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 502 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
535 if (!return_desc) { 503 if (!return_desc) {
536 status = AE_NO_MEMORY; 504 status = AE_NO_MEMORY;
537 goto cleanup; 505 goto cleanup;
@@ -542,50 +510,48 @@ acpi_ex_opcode_2A_0T_1R (
542 if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) { 510 if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) {
543 /* logical_op (Operand0, Operand1) */ 511 /* logical_op (Operand0, Operand1) */
544 512
545 status = acpi_ex_do_logical_numeric_op (walk_state->opcode, 513 status = acpi_ex_do_logical_numeric_op(walk_state->opcode,
546 operand[0]->integer.value, operand[1]->integer.value, 514 operand[0]->integer.
547 &logical_result); 515 value,
516 operand[1]->integer.
517 value, &logical_result);
548 goto store_logical_result; 518 goto store_logical_result;
549 } 519 } else if (walk_state->op_info->flags & AML_LOGICAL) {
550 else if (walk_state->op_info->flags & AML_LOGICAL) {
551 /* logical_op (Operand0, Operand1) */ 520 /* logical_op (Operand0, Operand1) */
552 521
553 status = acpi_ex_do_logical_op (walk_state->opcode, operand[0], 522 status = acpi_ex_do_logical_op(walk_state->opcode, operand[0],
554 operand[1], &logical_result); 523 operand[1], &logical_result);
555 goto store_logical_result; 524 goto store_logical_result;
556 } 525 }
557 526
558 switch (walk_state->opcode) { 527 switch (walk_state->opcode) {
559 case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */ 528 case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
560 529
561 status = acpi_ex_acquire_mutex (operand[1], operand[0], walk_state); 530 status =
531 acpi_ex_acquire_mutex(operand[1], operand[0], walk_state);
562 if (status == AE_TIME) { 532 if (status == AE_TIME) {
563 logical_result = TRUE; /* TRUE = Acquire timed out */ 533 logical_result = TRUE; /* TRUE = Acquire timed out */
564 status = AE_OK; 534 status = AE_OK;
565 } 535 }
566 break; 536 break;
567 537
538 case AML_WAIT_OP: /* Wait (event_object, Timeout) */
568 539
569 case AML_WAIT_OP: /* Wait (event_object, Timeout) */ 540 status = acpi_ex_system_wait_event(operand[1], operand[0]);
570
571 status = acpi_ex_system_wait_event (operand[1], operand[0]);
572 if (status == AE_TIME) { 541 if (status == AE_TIME) {
573 logical_result = TRUE; /* TRUE, Wait timed out */ 542 logical_result = TRUE; /* TRUE, Wait timed out */
574 status = AE_OK; 543 status = AE_OK;
575 } 544 }
576 break; 545 break;
577 546
578
579 default: 547 default:
580 548
581 ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", 549 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
582 walk_state->opcode));
583 status = AE_AML_BAD_OPCODE; 550 status = AE_AML_BAD_OPCODE;
584 goto cleanup; 551 goto cleanup;
585 } 552 }
586 553
587 554 store_logical_result:
588store_logical_result:
589 /* 555 /*
590 * Set return value to according to logical_result. logical TRUE (all ones) 556 * Set return value to according to logical_result. logical TRUE (all ones)
591 * Default is FALSE (zero) 557 * Default is FALSE (zero)
@@ -596,16 +562,13 @@ store_logical_result:
596 562
597 walk_state->result_obj = return_desc; 563 walk_state->result_obj = return_desc;
598 564
599 565 cleanup:
600cleanup:
601 566
602 /* Delete return object on error */ 567 /* Delete return object on error */
603 568
604 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
605 acpi_ut_remove_reference (return_desc); 570 acpi_ut_remove_reference(return_desc);
606 } 571 }
607 572
608 return_ACPI_STATUS (status); 573 return_ACPI_STATUS(status);
609} 574}
610
611
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 23b068adbf58..483365777670 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -42,16 +42,13 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/acparser.h> 47#include <acpi/acparser.h>
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exoparg3") 51ACPI_MODULE_NAME("exoparg3")
54
55 52
56/*! 53/*!
57 * Naming convention for AML interpreter execution routines. 54 * Naming convention for AML interpreter execution routines.
@@ -74,8 +71,6 @@
74 * The AcpiExOpcode* functions are called via the Dispatcher component with 71 * The AcpiExOpcode* functions are called via the Dispatcher component with
75 * fully resolved operands. 72 * fully resolved operands.
76!*/ 73!*/
77
78
79/******************************************************************************* 74/*******************************************************************************
80 * 75 *
81 * FUNCTION: acpi_ex_opcode_3A_0T_0R 76 * FUNCTION: acpi_ex_opcode_3A_0T_0R
@@ -87,61 +82,53 @@
87 * DESCRIPTION: Execute Triadic operator (3 operands) 82 * DESCRIPTION: Execute Triadic operator (3 operands)
88 * 83 *
89 ******************************************************************************/ 84 ******************************************************************************/
90 85acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
91acpi_status
92acpi_ex_opcode_3A_0T_0R (
93 struct acpi_walk_state *walk_state)
94{ 86{
95 union acpi_operand_object **operand = &walk_state->operands[0]; 87 union acpi_operand_object **operand = &walk_state->operands[0];
96 struct acpi_signal_fatal_info *fatal; 88 struct acpi_signal_fatal_info *fatal;
97 acpi_status status = AE_OK; 89 acpi_status status = AE_OK;
98
99
100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R",
101 acpi_ps_get_opcode_name (walk_state->opcode));
102 90
91 ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_0T_0R",
92 acpi_ps_get_opcode_name(walk_state->opcode));
103 93
104 switch (walk_state->opcode) { 94 switch (walk_state->opcode) {
105 case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */ 95 case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
106 96
107 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 97 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
108 "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", 98 "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
109 (u32) operand[0]->integer.value, 99 (u32) operand[0]->integer.value,
110 (u32) operand[1]->integer.value, 100 (u32) operand[1]->integer.value,
111 (u32) operand[2]->integer.value)); 101 (u32) operand[2]->integer.value));
112 102
113 fatal = ACPI_MEM_ALLOCATE (sizeof (struct acpi_signal_fatal_info)); 103 fatal =
104 ACPI_MEM_ALLOCATE(sizeof(struct acpi_signal_fatal_info));
114 if (fatal) { 105 if (fatal) {
115 fatal->type = (u32) operand[0]->integer.value; 106 fatal->type = (u32) operand[0]->integer.value;
116 fatal->code = (u32) operand[1]->integer.value; 107 fatal->code = (u32) operand[1]->integer.value;
117 fatal->argument = (u32) operand[2]->integer.value; 108 fatal->argument = (u32) operand[2]->integer.value;
118 } 109 }
119 110
120 /* Always signal the OS! */ 111 /* Always signal the OS! */
121 112
122 status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal); 113 status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal);
123 114
124 /* Might return while OS is shutting down, just continue */ 115 /* Might return while OS is shutting down, just continue */
125 116
126 ACPI_MEM_FREE (fatal); 117 ACPI_MEM_FREE(fatal);
127 break; 118 break;
128 119
129
130 default: 120 default:
131 121
132 ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", 122 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
133 walk_state->opcode));
134 status = AE_AML_BAD_OPCODE; 123 status = AE_AML_BAD_OPCODE;
135 goto cleanup; 124 goto cleanup;
136 } 125 }
137 126
127 cleanup:
138 128
139cleanup: 129 return_ACPI_STATUS(status);
140
141 return_ACPI_STATUS (status);
142} 130}
143 131
144
145/******************************************************************************* 132/*******************************************************************************
146 * 133 *
147 * FUNCTION: acpi_ex_opcode_3A_1T_1R 134 * FUNCTION: acpi_ex_opcode_3A_1T_1R
@@ -154,31 +141,28 @@ cleanup:
154 * 141 *
155 ******************************************************************************/ 142 ******************************************************************************/
156 143
157acpi_status 144acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
158acpi_ex_opcode_3A_1T_1R (
159 struct acpi_walk_state *walk_state)
160{ 145{
161 union acpi_operand_object **operand = &walk_state->operands[0]; 146 union acpi_operand_object **operand = &walk_state->operands[0];
162 union acpi_operand_object *return_desc = NULL; 147 union acpi_operand_object *return_desc = NULL;
163 char *buffer; 148 char *buffer = NULL;
164 acpi_status status = AE_OK; 149 acpi_status status = AE_OK;
165 acpi_integer index; 150 acpi_integer index;
166 acpi_size length; 151 acpi_size length;
167
168
169 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R",
170 acpi_ps_get_opcode_name (walk_state->opcode));
171 152
153 ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_1T_1R",
154 acpi_ps_get_opcode_name(walk_state->opcode));
172 155
173 switch (walk_state->opcode) { 156 switch (walk_state->opcode) {
174 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ 157 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
175 158
176 /* 159 /*
177 * Create the return object. The Source operand is guaranteed to be 160 * Create the return object. The Source operand is guaranteed to be
178 * either a String or a Buffer, so just use its type. 161 * either a String or a Buffer, so just use its type.
179 */ 162 */
180 return_desc = acpi_ut_create_internal_object ( 163 return_desc =
181 ACPI_GET_OBJECT_TYPE (operand[0])); 164 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
165 (operand[0]));
182 if (!return_desc) { 166 if (!return_desc) {
183 status = AE_NO_MEMORY; 167 status = AE_NO_MEMORY;
184 goto cleanup; 168 goto cleanup;
@@ -193,67 +177,92 @@ acpi_ex_opcode_3A_1T_1R (
193 * If the index is beyond the length of the String/Buffer, or if the 177 * If the index is beyond the length of the String/Buffer, or if the
194 * requested length is zero, return a zero-length String/Buffer 178 * requested length is zero, return a zero-length String/Buffer
195 */ 179 */
196 if ((index < operand[0]->string.length) && 180 if (index >= operand[0]->string.length) {
197 (length > 0)) { 181 length = 0;
198 /* Truncate request if larger than the actual String/Buffer */ 182 }
199 183
200 if ((index + length) > 184 /* Truncate request if larger than the actual String/Buffer */
201 operand[0]->string.length) { 185
202 length = (acpi_size) operand[0]->string.length - 186 else if ((index + length) > operand[0]->string.length) {
203 (acpi_size) index; 187 length = (acpi_size) operand[0]->string.length -
204 } 188 (acpi_size) index;
189 }
190
191 /* Strings always have a sub-pointer, not so for buffers */
192
193 switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
194 case ACPI_TYPE_STRING:
205 195
206 /* Allocate a new buffer for the String/Buffer */ 196 /* Always allocate a new buffer for the String */
207 197
208 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 198 buffer = ACPI_MEM_CALLOCATE((acpi_size) length + 1);
209 if (!buffer) { 199 if (!buffer) {
210 status = AE_NO_MEMORY; 200 status = AE_NO_MEMORY;
211 goto cleanup; 201 goto cleanup;
212 } 202 }
203 break;
213 204
214 /* Copy the portion requested */ 205 case ACPI_TYPE_BUFFER:
215 206
216 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, 207 /* If the requested length is zero, don't allocate a buffer */
217 length);
218 208
219 /* Set the length of the new String/Buffer */ 209 if (length > 0) {
210 /* Allocate a new buffer for the Buffer */
220 211
221 return_desc->string.pointer = buffer; 212 buffer = ACPI_MEM_CALLOCATE(length);
222 return_desc->string.length = (u32) length; 213 if (!buffer) {
214 status = AE_NO_MEMORY;
215 goto cleanup;
216 }
217 }
218 break;
219
220 default: /* Should not happen */
221
222 status = AE_AML_OPERAND_TYPE;
223 goto cleanup;
223 } 224 }
224 225
226 if (length > 0) {
227 /* Copy the portion requested */
228
229 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
230 length);
231 }
232
233 /* Set the length of the new String/Buffer */
234
235 return_desc->string.pointer = buffer;
236 return_desc->string.length = (u32) length;
237
225 /* Mark buffer initialized */ 238 /* Mark buffer initialized */
226 239
227 return_desc->buffer.flags |= AOPOBJ_DATA_VALID; 240 return_desc->buffer.flags |= AOPOBJ_DATA_VALID;
228 break; 241 break;
229 242
230
231 default: 243 default:
232 244
233 ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", 245 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
234 walk_state->opcode));
235 status = AE_AML_BAD_OPCODE; 246 status = AE_AML_BAD_OPCODE;
236 goto cleanup; 247 goto cleanup;
237 } 248 }
238 249
239 /* Store the result in the target */ 250 /* Store the result in the target */
240 251
241 status = acpi_ex_store (return_desc, operand[3], walk_state); 252 status = acpi_ex_store(return_desc, operand[3], walk_state);
242 253
243cleanup: 254 cleanup:
244 255
245 /* Delete return object on error */ 256 /* Delete return object on error */
246 257
247 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE(status) || walk_state->result_obj) {
248 acpi_ut_remove_reference (return_desc); 259 acpi_ut_remove_reference(return_desc);
249 } 260 }
250 261
251 /* Set the return object and exit */ 262 /* Set the return object and exit */
252 263
253 if (!walk_state->result_obj) { 264 else {
254 walk_state->result_obj = return_desc; 265 walk_state->result_obj = return_desc;
255 } 266 }
256 return_ACPI_STATUS (status); 267 return_ACPI_STATUS(status);
257} 268}
258
259
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c
index 17f81d42ee41..5dee77139576 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/executer/exoparg6.c
@@ -42,16 +42,13 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/acparser.h> 47#include <acpi/acparser.h>
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exoparg6") 51ACPI_MODULE_NAME("exoparg6")
54
55 52
56/*! 53/*!
57 * Naming convention for AML interpreter execution routines. 54 * Naming convention for AML interpreter execution routines.
@@ -74,15 +71,11 @@
74 * The AcpiExOpcode* functions are called via the Dispatcher component with 71 * The AcpiExOpcode* functions are called via the Dispatcher component with
75 * fully resolved operands. 72 * fully resolved operands.
76!*/ 73!*/
77
78/* Local prototypes */ 74/* Local prototypes */
79
80static u8 75static u8
81acpi_ex_do_match ( 76acpi_ex_do_match(u32 match_op,
82 u32 match_op, 77 union acpi_operand_object *package_obj,
83 union acpi_operand_object *package_obj, 78 union acpi_operand_object *match_obj);
84 union acpi_operand_object *match_obj);
85
86 79
87/******************************************************************************* 80/*******************************************************************************
88 * 81 *
@@ -101,14 +94,12 @@ acpi_ex_do_match (
101 ******************************************************************************/ 94 ******************************************************************************/
102 95
103static u8 96static u8
104acpi_ex_do_match ( 97acpi_ex_do_match(u32 match_op,
105 u32 match_op, 98 union acpi_operand_object *package_obj,
106 union acpi_operand_object *package_obj, 99 union acpi_operand_object *match_obj)
107 union acpi_operand_object *match_obj)
108{ 100{
109 u8 logical_result = TRUE; 101 u8 logical_result = TRUE;
110 acpi_status status; 102 acpi_status status;
111
112 103
113 /* 104 /*
114 * Note: Since the package_obj/match_obj ordering is opposite to that of 105 * Note: Since the package_obj/match_obj ordering is opposite to that of
@@ -133,9 +124,10 @@ acpi_ex_do_match (
133 * True if equal: (P[i] == M) 124 * True if equal: (P[i] == M)
134 * Change to: (M == P[i]) 125 * Change to: (M == P[i])
135 */ 126 */
136 status = acpi_ex_do_logical_op (AML_LEQUAL_OP, match_obj, package_obj, 127 status =
137 &logical_result); 128 acpi_ex_do_logical_op(AML_LEQUAL_OP, match_obj, package_obj,
138 if (ACPI_FAILURE (status)) { 129 &logical_result);
130 if (ACPI_FAILURE(status)) {
139 return (FALSE); 131 return (FALSE);
140 } 132 }
141 break; 133 break;
@@ -146,12 +138,13 @@ acpi_ex_do_match (
146 * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) 138 * True if less than or equal: (P[i] <= M) (P[i] not_greater than M)
147 * Change to: (M >= P[i]) (M not_less than P[i]) 139 * Change to: (M >= P[i]) (M not_less than P[i])
148 */ 140 */
149 status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj, 141 status =
150 &logical_result); 142 acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj,
151 if (ACPI_FAILURE (status)) { 143 &logical_result);
144 if (ACPI_FAILURE(status)) {
152 return (FALSE); 145 return (FALSE);
153 } 146 }
154 logical_result = (u8) !logical_result; 147 logical_result = (u8) ! logical_result;
155 break; 148 break;
156 149
157 case MATCH_MLT: 150 case MATCH_MLT:
@@ -160,9 +153,10 @@ acpi_ex_do_match (
160 * True if less than: (P[i] < M) 153 * True if less than: (P[i] < M)
161 * Change to: (M > P[i]) 154 * Change to: (M > P[i])
162 */ 155 */
163 status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj, 156 status =
164 &logical_result); 157 acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj,
165 if (ACPI_FAILURE (status)) { 158 package_obj, &logical_result);
159 if (ACPI_FAILURE(status)) {
166 return (FALSE); 160 return (FALSE);
167 } 161 }
168 break; 162 break;
@@ -173,12 +167,13 @@ acpi_ex_do_match (
173 * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) 167 * True if greater than or equal: (P[i] >= M) (P[i] not_less than M)
174 * Change to: (M <= P[i]) (M not_greater than P[i]) 168 * Change to: (M <= P[i]) (M not_greater than P[i])
175 */ 169 */
176 status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj, 170 status =
177 &logical_result); 171 acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj,
178 if (ACPI_FAILURE (status)) { 172 package_obj, &logical_result);
173 if (ACPI_FAILURE(status)) {
179 return (FALSE); 174 return (FALSE);
180 } 175 }
181 logical_result = (u8)!logical_result; 176 logical_result = (u8) ! logical_result;
182 break; 177 break;
183 178
184 case MATCH_MGT: 179 case MATCH_MGT:
@@ -187,9 +182,10 @@ acpi_ex_do_match (
187 * True if greater than: (P[i] > M) 182 * True if greater than: (P[i] > M)
188 * Change to: (M < P[i]) 183 * Change to: (M < P[i])
189 */ 184 */
190 status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj, 185 status =
191 &logical_result); 186 acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj,
192 if (ACPI_FAILURE (status)) { 187 &logical_result);
188 if (ACPI_FAILURE(status)) {
193 return (FALSE); 189 return (FALSE);
194 } 190 }
195 break; 191 break;
@@ -204,7 +200,6 @@ acpi_ex_do_match (
204 return logical_result; 200 return logical_result;
205} 201}
206 202
207
208/******************************************************************************* 203/*******************************************************************************
209 * 204 *
210 * FUNCTION: acpi_ex_opcode_6A_0T_1R 205 * FUNCTION: acpi_ex_opcode_6A_0T_1R
@@ -217,20 +212,16 @@ acpi_ex_do_match (
217 * 212 *
218 ******************************************************************************/ 213 ******************************************************************************/
219 214
220acpi_status 215acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
221acpi_ex_opcode_6A_0T_1R (
222 struct acpi_walk_state *walk_state)
223{ 216{
224 union acpi_operand_object **operand = &walk_state->operands[0]; 217 union acpi_operand_object **operand = &walk_state->operands[0];
225 union acpi_operand_object *return_desc = NULL; 218 union acpi_operand_object *return_desc = NULL;
226 acpi_status status = AE_OK; 219 acpi_status status = AE_OK;
227 acpi_integer index; 220 acpi_integer index;
228 union acpi_operand_object *this_element; 221 union acpi_operand_object *this_element;
229
230
231 ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R",
232 acpi_ps_get_opcode_name (walk_state->opcode));
233 222
223 ACPI_FUNCTION_TRACE_STR("ex_opcode_6A_0T_1R",
224 acpi_ps_get_opcode_name(walk_state->opcode));
234 225
235 switch (walk_state->opcode) { 226 switch (walk_state->opcode) {
236 case AML_MATCH_OP: 227 case AML_MATCH_OP:
@@ -242,8 +233,9 @@ acpi_ex_opcode_6A_0T_1R (
242 /* Validate both Match Term Operators (MTR, MEQ, etc.) */ 233 /* Validate both Match Term Operators (MTR, MEQ, etc.) */
243 234
244 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || 235 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
245 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { 236 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
246 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Match operator out of range\n")); 237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
238 "Match operator out of range\n"));
247 status = AE_AML_OPERAND_VALUE; 239 status = AE_AML_OPERAND_VALUE;
248 goto cleanup; 240 goto cleanup;
249 } 241 }
@@ -252,16 +244,17 @@ acpi_ex_opcode_6A_0T_1R (
252 244
253 index = operand[5]->integer.value; 245 index = operand[5]->integer.value;
254 if (index >= operand[0]->package.count) { 246 if (index >= operand[0]->package.count) {
255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 247 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
256 "Index (%X%8.8X) beyond package end (%X)\n", 248 "Index (%X%8.8X) beyond package end (%X)\n",
257 ACPI_FORMAT_UINT64 (index), operand[0]->package.count)); 249 ACPI_FORMAT_UINT64(index),
250 operand[0]->package.count));
258 status = AE_AML_PACKAGE_LIMIT; 251 status = AE_AML_PACKAGE_LIMIT;
259 goto cleanup; 252 goto cleanup;
260 } 253 }
261 254
262 /* Create an integer for the return value */ 255 /* Create an integer for the return value */
263 256
264 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 257 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
265 if (!return_desc) { 258 if (!return_desc) {
266 status = AE_NO_MEMORY; 259 status = AE_NO_MEMORY;
267 goto cleanup; 260 goto cleanup;
@@ -283,7 +276,7 @@ acpi_ex_opcode_6A_0T_1R (
283 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no 276 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no
284 * match was found. 277 * match was found.
285 */ 278 */
286 for ( ; index < operand[0]->package.count; index++) { 279 for (; index < operand[0]->package.count; index++) {
287 /* Get the current package element */ 280 /* Get the current package element */
288 281
289 this_element = operand[0]->package.elements[index]; 282 this_element = operand[0]->package.elements[index];
@@ -299,13 +292,13 @@ acpi_ex_opcode_6A_0T_1R (
299 * (proceed to next iteration of enclosing for loop) signifies a 292 * (proceed to next iteration of enclosing for loop) signifies a
300 * non-match. 293 * non-match.
301 */ 294 */
302 if (!acpi_ex_do_match ((u32) operand[1]->integer.value, 295 if (!acpi_ex_do_match((u32) operand[1]->integer.value,
303 this_element, operand[2])) { 296 this_element, operand[2])) {
304 continue; 297 continue;
305 } 298 }
306 299
307 if (!acpi_ex_do_match ((u32) operand[3]->integer.value, 300 if (!acpi_ex_do_match((u32) operand[3]->integer.value,
308 this_element, operand[4])) { 301 this_element, operand[4])) {
309 continue; 302 continue;
310 } 303 }
311 304
@@ -316,31 +309,27 @@ acpi_ex_opcode_6A_0T_1R (
316 } 309 }
317 break; 310 break;
318 311
319
320 case AML_LOAD_TABLE_OP: 312 case AML_LOAD_TABLE_OP:
321 313
322 status = acpi_ex_load_table_op (walk_state, &return_desc); 314 status = acpi_ex_load_table_op(walk_state, &return_desc);
323 break; 315 break;
324 316
325
326 default: 317 default:
327 318
328 ACPI_REPORT_ERROR (("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", 319 ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
329 walk_state->opcode));
330 status = AE_AML_BAD_OPCODE; 320 status = AE_AML_BAD_OPCODE;
331 goto cleanup; 321 goto cleanup;
332 } 322 }
333 323
334 walk_state->result_obj = return_desc; 324 walk_state->result_obj = return_desc;
335 325
336 326 cleanup:
337cleanup:
338 327
339 /* Delete return object on error */ 328 /* Delete return object on error */
340 329
341 if (ACPI_FAILURE (status)) { 330 if (ACPI_FAILURE(status)) {
342 acpi_ut_remove_reference (return_desc); 331 acpi_ut_remove_reference(return_desc);
343 } 332 }
344 333
345 return_ACPI_STATUS (status); 334 return_ACPI_STATUS(status);
346} 335}
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index c9e3c68b5549..7476c363e407 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -42,32 +42,24 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exprep") 51ACPI_MODULE_NAME("exprep")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static u32 54static u32
58acpi_ex_decode_field_access ( 55acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
59 union acpi_operand_object *obj_desc, 56 u8 field_flags, u32 * return_byte_alignment);
60 u8 field_flags,
61 u32 *return_byte_alignment);
62
63 57
64#ifdef ACPI_UNDER_DEVELOPMENT 58#ifdef ACPI_UNDER_DEVELOPMENT
65 59
66static u32 60static u32
67acpi_ex_generate_access ( 61acpi_ex_generate_access(u32 field_bit_offset,
68 u32 field_bit_offset, 62 u32 field_bit_length, u32 region_length);
69 u32 field_bit_length,
70 u32 region_length);
71 63
72/******************************************************************************* 64/*******************************************************************************
73 * 65 *
@@ -92,39 +84,36 @@ acpi_ex_generate_access (
92 ******************************************************************************/ 84 ******************************************************************************/
93 85
94static u32 86static u32
95acpi_ex_generate_access ( 87acpi_ex_generate_access(u32 field_bit_offset,
96 u32 field_bit_offset, 88 u32 field_bit_length, u32 region_length)
97 u32 field_bit_length,
98 u32 region_length)
99{ 89{
100 u32 field_byte_length; 90 u32 field_byte_length;
101 u32 field_byte_offset; 91 u32 field_byte_offset;
102 u32 field_byte_end_offset; 92 u32 field_byte_end_offset;
103 u32 access_byte_width; 93 u32 access_byte_width;
104 u32 field_start_offset; 94 u32 field_start_offset;
105 u32 field_end_offset; 95 u32 field_end_offset;
106 u32 minimum_access_width = 0xFFFFFFFF; 96 u32 minimum_access_width = 0xFFFFFFFF;
107 u32 minimum_accesses = 0xFFFFFFFF; 97 u32 minimum_accesses = 0xFFFFFFFF;
108 u32 accesses; 98 u32 accesses;
109 99
110 100 ACPI_FUNCTION_TRACE("ex_generate_access");
111 ACPI_FUNCTION_TRACE ("ex_generate_access");
112
113 101
114 /* Round Field start offset and length to "minimal" byte boundaries */ 102 /* Round Field start offset and length to "minimal" byte boundaries */
115 103
116 field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8)); 104 field_byte_offset = ACPI_DIV_8(ACPI_ROUND_DOWN(field_bit_offset, 8));
117 field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length + 105 field_byte_end_offset = ACPI_DIV_8(ACPI_ROUND_UP(field_bit_length +
118 field_bit_offset, 8)); 106 field_bit_offset, 8));
119 field_byte_length = field_byte_end_offset - field_byte_offset; 107 field_byte_length = field_byte_end_offset - field_byte_offset;
120 108
121 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 109 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
122 "Bit length %d, Bit offset %d\n", 110 "Bit length %d, Bit offset %d\n",
123 field_bit_length, field_bit_offset)); 111 field_bit_length, field_bit_offset));
124 112
125 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 113 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
126 "Byte Length %d, Byte Offset %d, End Offset %d\n", 114 "Byte Length %d, Byte Offset %d, End Offset %d\n",
127 field_byte_length, field_byte_offset, field_byte_end_offset)); 115 field_byte_length, field_byte_offset,
116 field_byte_end_offset));
128 117
129 /* 118 /*
130 * Iterative search for the maximum access width that is both aligned 119 * Iterative search for the maximum access width that is both aligned
@@ -132,7 +121,8 @@ acpi_ex_generate_access (
132 * 121 *
133 * Start at byte_acc and work upwards to qword_acc max. (1,2,4,8 bytes) 122 * Start at byte_acc and work upwards to qword_acc max. (1,2,4,8 bytes)
134 */ 123 */
135 for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) { 124 for (access_byte_width = 1; access_byte_width <= 8;
125 access_byte_width <<= 1) {
136 /* 126 /*
137 * 1) Round end offset up to next access boundary and make sure that 127 * 1) Round end offset up to next access boundary and make sure that
138 * this does not go beyond the end of the parent region. 128 * this does not go beyond the end of the parent region.
@@ -140,31 +130,37 @@ acpi_ex_generate_access (
140 * are done. (This does not optimize for the perfectly aligned 130 * are done. (This does not optimize for the perfectly aligned
141 * case yet). 131 * case yet).
142 */ 132 */
143 if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) { 133 if (ACPI_ROUND_UP(field_byte_end_offset, access_byte_width) <=
134 region_length) {
144 field_start_offset = 135 field_start_offset =
145 ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) / 136 ACPI_ROUND_DOWN(field_byte_offset,
146 access_byte_width; 137 access_byte_width) /
138 access_byte_width;
147 139
148 field_end_offset = 140 field_end_offset =
149 ACPI_ROUND_UP ((field_byte_length + field_byte_offset), 141 ACPI_ROUND_UP((field_byte_length +
150 access_byte_width) / access_byte_width; 142 field_byte_offset),
143 access_byte_width) /
144 access_byte_width;
151 145
152 accesses = field_end_offset - field_start_offset; 146 accesses = field_end_offset - field_start_offset;
153 147
154 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 148 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
155 "access_width %d end is within region\n", access_byte_width)); 149 "access_width %d end is within region\n",
150 access_byte_width));
156 151
157 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 152 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
158 "Field Start %d, Field End %d -- requires %d accesses\n", 153 "Field Start %d, Field End %d -- requires %d accesses\n",
159 field_start_offset, field_end_offset, accesses)); 154 field_start_offset, field_end_offset,
155 accesses));
160 156
161 /* Single access is optimal */ 157 /* Single access is optimal */
162 158
163 if (accesses <= 1) { 159 if (accesses <= 1) {
164 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 160 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
165 "Entire field can be accessed with one operation of size %d\n", 161 "Entire field can be accessed with one operation of size %d\n",
166 access_byte_width)); 162 access_byte_width));
167 return_VALUE (access_byte_width); 163 return_VALUE(access_byte_width);
168 } 164 }
169 165
170 /* 166 /*
@@ -172,30 +168,30 @@ acpi_ex_generate_access (
172 * try the next wider access on next iteration 168 * try the next wider access on next iteration
173 */ 169 */
174 if (accesses < minimum_accesses) { 170 if (accesses < minimum_accesses) {
175 minimum_accesses = accesses; 171 minimum_accesses = accesses;
176 minimum_access_width = access_byte_width; 172 minimum_access_width = access_byte_width;
177 } 173 }
178 } 174 } else {
179 else { 175 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
180 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 176 "access_width %d end is NOT within region\n",
181 "access_width %d end is NOT within region\n", access_byte_width)); 177 access_byte_width));
182 if (access_byte_width == 1) { 178 if (access_byte_width == 1) {
183 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 179 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
184 "Field goes beyond end-of-region!\n")); 180 "Field goes beyond end-of-region!\n"));
185 181
186 /* Field does not fit in the region at all */ 182 /* Field does not fit in the region at all */
187 183
188 return_VALUE (0); 184 return_VALUE(0);
189 } 185 }
190 186
191 /* 187 /*
192 * This width goes beyond the end-of-region, back off to 188 * This width goes beyond the end-of-region, back off to
193 * previous access 189 * previous access
194 */ 190 */
195 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 191 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
196 "Backing off to previous optimal access width of %d\n", 192 "Backing off to previous optimal access width of %d\n",
197 minimum_access_width)); 193 minimum_access_width));
198 return_VALUE (minimum_access_width); 194 return_VALUE(minimum_access_width);
199 } 195 }
200 } 196 }
201 197
@@ -203,12 +199,11 @@ acpi_ex_generate_access (
203 * Could not read/write field with one operation, 199 * Could not read/write field with one operation,
204 * just use max access width 200 * just use max access width
205 */ 201 */
206 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 202 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
207 "Cannot access field in one operation, using width 8\n")); 203 "Cannot access field in one operation, using width 8\n"));
208 return_VALUE (8); 204 return_VALUE(8);
209} 205}
210#endif /* ACPI_UNDER_DEVELOPMENT */ 206#endif /* ACPI_UNDER_DEVELOPMENT */
211
212 207
213/******************************************************************************* 208/*******************************************************************************
214 * 209 *
@@ -226,18 +221,14 @@ acpi_ex_generate_access (
226 ******************************************************************************/ 221 ******************************************************************************/
227 222
228static u32 223static u32
229acpi_ex_decode_field_access ( 224acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
230 union acpi_operand_object *obj_desc, 225 u8 field_flags, u32 * return_byte_alignment)
231 u8 field_flags,
232 u32 *return_byte_alignment)
233{ 226{
234 u32 access; 227 u32 access;
235 u32 byte_alignment; 228 u32 byte_alignment;
236 u32 bit_length; 229 u32 bit_length;
237
238
239 ACPI_FUNCTION_TRACE ("ex_decode_field_access");
240 230
231 ACPI_FUNCTION_TRACE("ex_decode_field_access");
241 232
242 access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK); 233 access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK);
243 234
@@ -246,9 +237,12 @@ acpi_ex_decode_field_access (
246 237
247#ifdef ACPI_UNDER_DEVELOPMENT 238#ifdef ACPI_UNDER_DEVELOPMENT
248 byte_alignment = 239 byte_alignment =
249 acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset, 240 acpi_ex_generate_access(obj_desc->common_field.
250 obj_desc->common_field.bit_length, 241 start_field_bit_offset,
251 0xFFFFFFFF /* Temp until we pass region_length as parameter */); 242 obj_desc->common_field.bit_length,
243 0xFFFFFFFF
244 /* Temp until we pass region_length as parameter */
245 );
252 bit_length = byte_alignment * 8; 246 bit_length = byte_alignment * 8;
253#endif 247#endif
254 248
@@ -257,36 +251,35 @@ acpi_ex_decode_field_access (
257 break; 251 break;
258 252
259 case AML_FIELD_ACCESS_BYTE: 253 case AML_FIELD_ACCESS_BYTE:
260 case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ 254 case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
261 byte_alignment = 1; 255 byte_alignment = 1;
262 bit_length = 8; 256 bit_length = 8;
263 break; 257 break;
264 258
265 case AML_FIELD_ACCESS_WORD: 259 case AML_FIELD_ACCESS_WORD:
266 byte_alignment = 2; 260 byte_alignment = 2;
267 bit_length = 16; 261 bit_length = 16;
268 break; 262 break;
269 263
270 case AML_FIELD_ACCESS_DWORD: 264 case AML_FIELD_ACCESS_DWORD:
271 byte_alignment = 4; 265 byte_alignment = 4;
272 bit_length = 32; 266 bit_length = 32;
273 break; 267 break;
274 268
275 case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ 269 case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
276 byte_alignment = 8; 270 byte_alignment = 8;
277 bit_length = 64; 271 bit_length = 64;
278 break; 272 break;
279 273
280 default: 274 default:
281 /* Invalid field access type */ 275 /* Invalid field access type */
282 276
283 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
284 "Unknown field access type %X\n", 278 "Unknown field access type %X\n", access));
285 access)); 279 return_VALUE(0);
286 return_VALUE (0);
287 } 280 }
288 281
289 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
290 /* 283 /*
291 * buffer_field access can be on any byte boundary, so the 284 * buffer_field access can be on any byte boundary, so the
292 * byte_alignment is always 1 byte -- regardless of any byte_alignment 285 * byte_alignment is always 1 byte -- regardless of any byte_alignment
@@ -296,10 +289,9 @@ acpi_ex_decode_field_access (
296 } 289 }
297 290
298 *return_byte_alignment = byte_alignment; 291 *return_byte_alignment = byte_alignment;
299 return_VALUE (bit_length); 292 return_VALUE(bit_length);
300} 293}
301 294
302
303/******************************************************************************* 295/*******************************************************************************
304 * 296 *
305 * FUNCTION: acpi_ex_prep_common_field_object 297 * FUNCTION: acpi_ex_prep_common_field_object
@@ -322,20 +314,16 @@ acpi_ex_decode_field_access (
322 ******************************************************************************/ 314 ******************************************************************************/
323 315
324acpi_status 316acpi_status
325acpi_ex_prep_common_field_object ( 317acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
326 union acpi_operand_object *obj_desc, 318 u8 field_flags,
327 u8 field_flags, 319 u8 field_attribute,
328 u8 field_attribute, 320 u32 field_bit_position, u32 field_bit_length)
329 u32 field_bit_position,
330 u32 field_bit_length)
331{ 321{
332 u32 access_bit_width; 322 u32 access_bit_width;
333 u32 byte_alignment; 323 u32 byte_alignment;
334 u32 nearest_byte_address; 324 u32 nearest_byte_address;
335
336
337 ACPI_FUNCTION_TRACE ("ex_prep_common_field_object");
338 325
326 ACPI_FUNCTION_TRACE("ex_prep_common_field_object");
339 327
340 /* 328 /*
341 * Note: the structure being initialized is the 329 * Note: the structure being initialized is the
@@ -361,16 +349,16 @@ acpi_ex_prep_common_field_object (
361 * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is 349 * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
362 * the same (equivalent) as the byte_alignment. 350 * the same (equivalent) as the byte_alignment.
363 */ 351 */
364 access_bit_width = acpi_ex_decode_field_access (obj_desc, field_flags, 352 access_bit_width = acpi_ex_decode_field_access(obj_desc, field_flags,
365 &byte_alignment); 353 &byte_alignment);
366 if (!access_bit_width) { 354 if (!access_bit_width) {
367 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 355 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
368 } 356 }
369 357
370 /* Setup width (access granularity) fields */ 358 /* Setup width (access granularity) fields */
371 359
372 obj_desc->common_field.access_byte_width = (u8) 360 obj_desc->common_field.access_byte_width = (u8)
373 ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */ 361 ACPI_DIV_8(access_bit_width); /* 1, 2, 4, 8 */
374 362
375 obj_desc->common_field.access_bit_width = (u8) access_bit_width; 363 obj_desc->common_field.access_bit_width = (u8) access_bit_width;
376 364
@@ -385,30 +373,30 @@ acpi_ex_prep_common_field_object (
385 * region or buffer. 373 * region or buffer.
386 */ 374 */
387 nearest_byte_address = 375 nearest_byte_address =
388 ACPI_ROUND_BITS_DOWN_TO_BYTES (field_bit_position); 376 ACPI_ROUND_BITS_DOWN_TO_BYTES(field_bit_position);
389 obj_desc->common_field.base_byte_offset = (u32) 377 obj_desc->common_field.base_byte_offset = (u32)
390 ACPI_ROUND_DOWN (nearest_byte_address, byte_alignment); 378 ACPI_ROUND_DOWN(nearest_byte_address, byte_alignment);
391 379
392 /* 380 /*
393 * start_field_bit_offset is the offset of the first bit of the field within 381 * start_field_bit_offset is the offset of the first bit of the field within
394 * a field datum. 382 * a field datum.
395 */ 383 */
396 obj_desc->common_field.start_field_bit_offset = (u8) 384 obj_desc->common_field.start_field_bit_offset = (u8)
397 (field_bit_position - ACPI_MUL_8 (obj_desc->common_field.base_byte_offset)); 385 (field_bit_position -
386 ACPI_MUL_8(obj_desc->common_field.base_byte_offset));
398 387
399 /* 388 /*
400 * Does the entire field fit within a single field access element? (datum) 389 * Does the entire field fit within a single field access element? (datum)
401 * (i.e., without crossing a datum boundary) 390 * (i.e., without crossing a datum boundary)
402 */ 391 */
403 if ((obj_desc->common_field.start_field_bit_offset + field_bit_length) <= 392 if ((obj_desc->common_field.start_field_bit_offset +
404 (u16) access_bit_width) { 393 field_bit_length) <= (u16) access_bit_width) {
405 obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM; 394 obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM;
406 } 395 }
407 396
408 return_ACPI_STATUS (AE_OK); 397 return_ACPI_STATUS(AE_OK);
409} 398}
410 399
411
412/******************************************************************************* 400/*******************************************************************************
413 * 401 *
414 * FUNCTION: acpi_ex_prep_field_value 402 * FUNCTION: acpi_ex_prep_field_value
@@ -422,51 +410,49 @@ acpi_ex_prep_common_field_object (
422 * 410 *
423 ******************************************************************************/ 411 ******************************************************************************/
424 412
425acpi_status 413acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
426acpi_ex_prep_field_value (
427 struct acpi_create_field_info *info)
428{ 414{
429 union acpi_operand_object *obj_desc; 415 union acpi_operand_object *obj_desc;
430 u32 type; 416 u32 type;
431 acpi_status status; 417 acpi_status status;
432
433
434 ACPI_FUNCTION_TRACE ("ex_prep_field_value");
435 418
419 ACPI_FUNCTION_TRACE("ex_prep_field_value");
436 420
437 /* Parameter validation */ 421 /* Parameter validation */
438 422
439 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { 423 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
440 if (!info->region_node) { 424 if (!info->region_node) {
441 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null region_node\n")); 425 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n"));
442 return_ACPI_STATUS (AE_AML_NO_OPERAND); 426 return_ACPI_STATUS(AE_AML_NO_OPERAND);
443 } 427 }
444 428
445 type = acpi_ns_get_type (info->region_node); 429 type = acpi_ns_get_type(info->region_node);
446 if (type != ACPI_TYPE_REGION) { 430 if (type != ACPI_TYPE_REGION) {
447 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 431 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
448 "Needed Region, found type %X (%s)\n", 432 "Needed Region, found type %X (%s)\n",
449 type, acpi_ut_get_type_name (type))); 433 type, acpi_ut_get_type_name(type)));
450 434
451 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 435 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
452 } 436 }
453 } 437 }
454 438
455 /* Allocate a new field object */ 439 /* Allocate a new field object */
456 440
457 obj_desc = acpi_ut_create_internal_object (info->field_type); 441 obj_desc = acpi_ut_create_internal_object(info->field_type);
458 if (!obj_desc) { 442 if (!obj_desc) {
459 return_ACPI_STATUS (AE_NO_MEMORY); 443 return_ACPI_STATUS(AE_NO_MEMORY);
460 } 444 }
461 445
462 /* Initialize areas of the object that are common to all fields */ 446 /* Initialize areas of the object that are common to all fields */
463 447
464 obj_desc->common_field.node = info->field_node; 448 obj_desc->common_field.node = info->field_node;
465 status = acpi_ex_prep_common_field_object (obj_desc, info->field_flags, 449 status = acpi_ex_prep_common_field_object(obj_desc, info->field_flags,
466 info->attribute, info->field_bit_position, info->field_bit_length); 450 info->attribute,
467 if (ACPI_FAILURE (status)) { 451 info->field_bit_position,
468 acpi_ut_delete_object_desc (obj_desc); 452 info->field_bit_length);
469 return_ACPI_STATUS (status); 453 if (ACPI_FAILURE(status)) {
454 acpi_ut_delete_object_desc(obj_desc);
455 return_ACPI_STATUS(status);
470 } 456 }
471 457
472 /* Initialize areas of the object that are specific to the field type */ 458 /* Initialize areas of the object that are specific to the field type */
@@ -474,71 +460,73 @@ acpi_ex_prep_field_value (
474 switch (info->field_type) { 460 switch (info->field_type) {
475 case ACPI_TYPE_LOCAL_REGION_FIELD: 461 case ACPI_TYPE_LOCAL_REGION_FIELD:
476 462
477 obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node); 463 obj_desc->field.region_obj =
464 acpi_ns_get_attached_object(info->region_node);
478 465
479 /* An additional reference for the container */ 466 /* An additional reference for the container */
480 467
481 acpi_ut_add_reference (obj_desc->field.region_obj); 468 acpi_ut_add_reference(obj_desc->field.region_obj);
482 469
483 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 470 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
484 "region_field: bit_off %X, Off %X, Gran %X, Region %p\n", 471 "region_field: bit_off %X, Off %X, Gran %X, Region %p\n",
485 obj_desc->field.start_field_bit_offset, obj_desc->field.base_byte_offset, 472 obj_desc->field.start_field_bit_offset,
486 obj_desc->field.access_byte_width, obj_desc->field.region_obj)); 473 obj_desc->field.base_byte_offset,
474 obj_desc->field.access_byte_width,
475 obj_desc->field.region_obj));
487 break; 476 break;
488 477
489
490 case ACPI_TYPE_LOCAL_BANK_FIELD: 478 case ACPI_TYPE_LOCAL_BANK_FIELD:
491 479
492 obj_desc->bank_field.value = info->bank_value; 480 obj_desc->bank_field.value = info->bank_value;
493 obj_desc->bank_field.region_obj = acpi_ns_get_attached_object ( 481 obj_desc->bank_field.region_obj =
494 info->region_node); 482 acpi_ns_get_attached_object(info->region_node);
495 obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object ( 483 obj_desc->bank_field.bank_obj =
496 info->register_node); 484 acpi_ns_get_attached_object(info->register_node);
497 485
498 /* An additional reference for the attached objects */ 486 /* An additional reference for the attached objects */
499 487
500 acpi_ut_add_reference (obj_desc->bank_field.region_obj); 488 acpi_ut_add_reference(obj_desc->bank_field.region_obj);
501 acpi_ut_add_reference (obj_desc->bank_field.bank_obj); 489 acpi_ut_add_reference(obj_desc->bank_field.bank_obj);
502 490
503 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 491 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
504 "Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n", 492 "Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n",
505 obj_desc->bank_field.start_field_bit_offset, 493 obj_desc->bank_field.start_field_bit_offset,
506 obj_desc->bank_field.base_byte_offset, 494 obj_desc->bank_field.base_byte_offset,
507 obj_desc->field.access_byte_width, 495 obj_desc->field.access_byte_width,
508 obj_desc->bank_field.region_obj, 496 obj_desc->bank_field.region_obj,
509 obj_desc->bank_field.bank_obj)); 497 obj_desc->bank_field.bank_obj));
510 break; 498 break;
511 499
512
513 case ACPI_TYPE_LOCAL_INDEX_FIELD: 500 case ACPI_TYPE_LOCAL_INDEX_FIELD:
514 501
515 obj_desc->index_field.index_obj = acpi_ns_get_attached_object ( 502 obj_desc->index_field.index_obj =
516 info->register_node); 503 acpi_ns_get_attached_object(info->register_node);
517 obj_desc->index_field.data_obj = acpi_ns_get_attached_object ( 504 obj_desc->index_field.data_obj =
518 info->data_register_node); 505 acpi_ns_get_attached_object(info->data_register_node);
519 obj_desc->index_field.value = (u32) 506 obj_desc->index_field.value = (u32)
520 (info->field_bit_position / ACPI_MUL_8 ( 507 (info->field_bit_position /
521 obj_desc->field.access_byte_width)); 508 ACPI_MUL_8(obj_desc->field.access_byte_width));
522 509
523 if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) { 510 if (!obj_desc->index_field.data_obj
524 ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); 511 || !obj_desc->index_field.index_obj) {
525 acpi_ut_delete_object_desc (obj_desc); 512 ACPI_REPORT_ERROR(("Null Index Object during field prep\n"));
526 return_ACPI_STATUS (AE_AML_INTERNAL); 513 acpi_ut_delete_object_desc(obj_desc);
514 return_ACPI_STATUS(AE_AML_INTERNAL);
527 } 515 }
528 516
529 /* An additional reference for the attached objects */ 517 /* An additional reference for the attached objects */
530 518
531 acpi_ut_add_reference (obj_desc->index_field.data_obj); 519 acpi_ut_add_reference(obj_desc->index_field.data_obj);
532 acpi_ut_add_reference (obj_desc->index_field.index_obj); 520 acpi_ut_add_reference(obj_desc->index_field.index_obj);
533 521
534 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 522 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
535 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", 523 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
536 obj_desc->index_field.start_field_bit_offset, 524 obj_desc->index_field.start_field_bit_offset,
537 obj_desc->index_field.base_byte_offset, 525 obj_desc->index_field.base_byte_offset,
538 obj_desc->index_field.value, 526 obj_desc->index_field.value,
539 obj_desc->field.access_byte_width, 527 obj_desc->field.access_byte_width,
540 obj_desc->index_field.index_obj, 528 obj_desc->index_field.index_obj,
541 obj_desc->index_field.data_obj)); 529 obj_desc->index_field.data_obj));
542 break; 530 break;
543 531
544 default: 532 default:
@@ -550,15 +538,16 @@ acpi_ex_prep_field_value (
550 * Store the constructed descriptor (obj_desc) into the parent Node, 538 * Store the constructed descriptor (obj_desc) into the parent Node,
551 * preserving the current type of that named_obj. 539 * preserving the current type of that named_obj.
552 */ 540 */
553 status = acpi_ns_attach_object (info->field_node, obj_desc, 541 status = acpi_ns_attach_object(info->field_node, obj_desc,
554 acpi_ns_get_type (info->field_node)); 542 acpi_ns_get_type(info->field_node));
555 543
556 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set named_obj %p [%4.4s], obj_desc %p\n", 544 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
557 info->field_node, acpi_ut_get_node_name (info->field_node), obj_desc)); 545 "Set named_obj %p [%4.4s], obj_desc %p\n",
546 info->field_node,
547 acpi_ut_get_node_name(info->field_node), obj_desc));
558 548
559 /* Remove local reference to the object */ 549 /* Remove local reference to the object */
560 550
561 acpi_ut_remove_reference (obj_desc); 551 acpi_ut_remove_reference(obj_desc);
562 return_ACPI_STATUS (status); 552 return_ACPI_STATUS(status);
563} 553}
564
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 723aaef4bb4a..9a2f5bea3afe 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exregion") 49ACPI_MODULE_NAME("exregion")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -68,27 +65,23 @@
68 * DESCRIPTION: Handler for the System Memory address space (Op Region) 65 * DESCRIPTION: Handler for the System Memory address space (Op Region)
69 * 66 *
70 ******************************************************************************/ 67 ******************************************************************************/
71
72acpi_status 68acpi_status
73acpi_ex_system_memory_space_handler ( 69acpi_ex_system_memory_space_handler(u32 function,
74 u32 function, 70 acpi_physical_address address,
75 acpi_physical_address address, 71 u32 bit_width,
76 u32 bit_width, 72 acpi_integer * value,
77 acpi_integer *value, 73 void *handler_context, void *region_context)
78 void *handler_context,
79 void *region_context)
80{ 74{
81 acpi_status status = AE_OK; 75 acpi_status status = AE_OK;
82 void *logical_addr_ptr = NULL; 76 void *logical_addr_ptr = NULL;
83 struct acpi_mem_space_context *mem_info = region_context; 77 struct acpi_mem_space_context *mem_info = region_context;
84 u32 length; 78 u32 length;
85 acpi_size window_size; 79 acpi_size window_size;
86#ifndef ACPI_MISALIGNED_TRANSFERS 80#ifndef ACPI_MISALIGNED_TRANSFERS
87 u32 remainder; 81 u32 remainder;
88#endif 82#endif
89 83
90 ACPI_FUNCTION_TRACE ("ex_system_memory_space_handler"); 84 ACPI_FUNCTION_TRACE("ex_system_memory_space_handler");
91
92 85
93 /* Validate and translate the bit width */ 86 /* Validate and translate the bit width */
94 87
@@ -110,9 +103,10 @@ acpi_ex_system_memory_space_handler (
110 break; 103 break;
111 104
112 default: 105 default:
113 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid system_memory width %d\n", 106 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
114 bit_width)); 107 "Invalid system_memory width %d\n",
115 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 108 bit_width));
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
116 } 110 }
117 111
118#ifndef ACPI_MISALIGNED_TRANSFERS 112#ifndef ACPI_MISALIGNED_TRANSFERS
@@ -120,9 +114,10 @@ acpi_ex_system_memory_space_handler (
120 * Hardware does not support non-aligned data transfers, we must verify 114 * Hardware does not support non-aligned data transfers, we must verify
121 * the request. 115 * the request.
122 */ 116 */
123 (void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder); 117 (void)acpi_ut_short_divide((acpi_integer) address, length, NULL,
118 &remainder);
124 if (remainder != 0) { 119 if (remainder != 0) {
125 return_ACPI_STATUS (AE_AML_ALIGNMENT); 120 return_ACPI_STATUS(AE_AML_ALIGNMENT);
126 } 121 }
127#endif 122#endif
128 123
@@ -132,9 +127,10 @@ acpi_ex_system_memory_space_handler (
132 * 2) Address beyond the current mapping? 127 * 2) Address beyond the current mapping?
133 */ 128 */
134 if ((address < mem_info->mapped_physical_address) || 129 if ((address < mem_info->mapped_physical_address) ||
135 (((acpi_integer) address + length) > 130 (((acpi_integer) address + length) > ((acpi_integer)
136 ((acpi_integer) 131 mem_info->
137 mem_info->mapped_physical_address + mem_info->mapped_length))) { 132 mapped_physical_address +
133 mem_info->mapped_length))) {
138 /* 134 /*
139 * The request cannot be resolved by the current memory mapping; 135 * The request cannot be resolved by the current memory mapping;
140 * Delete the existing mapping and create a new one. 136 * Delete the existing mapping and create a new one.
@@ -142,8 +138,8 @@ acpi_ex_system_memory_space_handler (
142 if (mem_info->mapped_length) { 138 if (mem_info->mapped_length) {
143 /* Valid mapping, delete it */ 139 /* Valid mapping, delete it */
144 140
145 acpi_os_unmap_memory (mem_info->mapped_logical_address, 141 acpi_os_unmap_memory(mem_info->mapped_logical_address,
146 mem_info->mapped_length); 142 mem_info->mapped_length);
147 } 143 }
148 144
149 /* 145 /*
@@ -151,7 +147,7 @@ acpi_ex_system_memory_space_handler (
151 * constrain the maximum mapping size to something reasonable. 147 * constrain the maximum mapping size to something reasonable.
152 */ 148 */
153 window_size = (acpi_size) 149 window_size = (acpi_size)
154 ((mem_info->address + mem_info->length) - address); 150 ((mem_info->address + mem_info->length) - address);
155 151
156 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { 152 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
157 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; 153 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
@@ -159,14 +155,16 @@ acpi_ex_system_memory_space_handler (
159 155
160 /* Create a new mapping starting at the address given */ 156 /* Create a new mapping starting at the address given */
161 157
162 status = acpi_os_map_memory (address, window_size, 158 status = acpi_os_map_memory(address, window_size,
163 (void **) &mem_info->mapped_logical_address); 159 (void **)&mem_info->
164 if (ACPI_FAILURE (status)) { 160 mapped_logical_address);
165 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 161 if (ACPI_FAILURE(status)) {
166 "Could not map memory at %8.8X%8.8X, size %X\n", 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
167 ACPI_FORMAT_UINT64 (address), (u32) window_size)); 163 "Could not map memory at %8.8X%8.8X, size %X\n",
164 ACPI_FORMAT_UINT64(address),
165 (u32) window_size));
168 mem_info->mapped_length = 0; 166 mem_info->mapped_length = 0;
169 return_ACPI_STATUS (status); 167 return_ACPI_STATUS(status);
170 } 168 }
171 169
172 /* Save the physical address and mapping size */ 170 /* Save the physical address and mapping size */
@@ -180,42 +178,41 @@ acpi_ex_system_memory_space_handler (
180 * access 178 * access
181 */ 179 */
182 logical_addr_ptr = mem_info->mapped_logical_address + 180 logical_addr_ptr = mem_info->mapped_logical_address +
183 ((acpi_integer) address - 181 ((acpi_integer) address -
184 (acpi_integer) mem_info->mapped_physical_address); 182 (acpi_integer) mem_info->mapped_physical_address);
185 183
186 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 184 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
187 "system_memory %d (%d width) Address=%8.8X%8.8X\n", 185 "system_memory %d (%d width) Address=%8.8X%8.8X\n",
188 function, bit_width, 186 function, bit_width, ACPI_FORMAT_UINT64(address)));
189 ACPI_FORMAT_UINT64 (address))); 187
190 188 /*
191 /* 189 * Perform the memory read or write
192 * Perform the memory read or write 190 *
193 * 191 * Note: For machines that do not support non-aligned transfers, the target
194 * Note: For machines that do not support non-aligned transfers, the target 192 * address was checked for alignment above. We do not attempt to break the
195 * address was checked for alignment above. We do not attempt to break the 193 * transfer up into smaller (byte-size) chunks because the AML specifically
196 * transfer up into smaller (byte-size) chunks because the AML specifically 194 * asked for a transfer width that the hardware may require.
197 * asked for a transfer width that the hardware may require. 195 */
198 */
199 switch (function) { 196 switch (function) {
200 case ACPI_READ: 197 case ACPI_READ:
201 198
202 *value = 0; 199 *value = 0;
203 switch (bit_width) { 200 switch (bit_width) {
204 case 8: 201 case 8:
205 *value = (acpi_integer) *((u8 *) logical_addr_ptr); 202 *value = (acpi_integer) * ((u8 *) logical_addr_ptr);
206 break; 203 break;
207 204
208 case 16: 205 case 16:
209 *value = (acpi_integer) *((u16 *) logical_addr_ptr); 206 *value = (acpi_integer) * ((u16 *) logical_addr_ptr);
210 break; 207 break;
211 208
212 case 32: 209 case 32:
213 *value = (acpi_integer) *((u32 *) logical_addr_ptr); 210 *value = (acpi_integer) * ((u32 *) logical_addr_ptr);
214 break; 211 break;
215 212
216#if ACPI_MACHINE_WIDTH != 16 213#if ACPI_MACHINE_WIDTH != 16
217 case 64: 214 case 64:
218 *value = (acpi_integer) *((u64 *) logical_addr_ptr); 215 *value = (acpi_integer) * ((u64 *) logical_addr_ptr);
219 break; 216 break;
220#endif 217#endif
221 default: 218 default:
@@ -228,20 +225,20 @@ acpi_ex_system_memory_space_handler (
228 225
229 switch (bit_width) { 226 switch (bit_width) {
230 case 8: 227 case 8:
231 *(u8 *) logical_addr_ptr = (u8) *value; 228 *(u8 *) logical_addr_ptr = (u8) * value;
232 break; 229 break;
233 230
234 case 16: 231 case 16:
235 *(u16 *) logical_addr_ptr = (u16) *value; 232 *(u16 *) logical_addr_ptr = (u16) * value;
236 break; 233 break;
237 234
238 case 32: 235 case 32:
239 *(u32 *) logical_addr_ptr = (u32) *value; 236 *(u32 *) logical_addr_ptr = (u32) * value;
240 break; 237 break;
241 238
242#if ACPI_MACHINE_WIDTH != 16 239#if ACPI_MACHINE_WIDTH != 16
243 case 64: 240 case 64:
244 *(u64 *) logical_addr_ptr = (u64) *value; 241 *(u64 *) logical_addr_ptr = (u64) * value;
245 break; 242 break;
246#endif 243#endif
247 244
@@ -256,10 +253,9 @@ acpi_ex_system_memory_space_handler (
256 break; 253 break;
257 } 254 }
258 255
259 return_ACPI_STATUS (status); 256 return_ACPI_STATUS(status);
260} 257}
261 258
262
263/******************************************************************************* 259/*******************************************************************************
264 * 260 *
265 * FUNCTION: acpi_ex_system_io_space_handler 261 * FUNCTION: acpi_ex_system_io_space_handler
@@ -279,39 +275,35 @@ acpi_ex_system_memory_space_handler (
279 ******************************************************************************/ 275 ******************************************************************************/
280 276
281acpi_status 277acpi_status
282acpi_ex_system_io_space_handler ( 278acpi_ex_system_io_space_handler(u32 function,
283 u32 function, 279 acpi_physical_address address,
284 acpi_physical_address address, 280 u32 bit_width,
285 u32 bit_width, 281 acpi_integer * value,
286 acpi_integer *value, 282 void *handler_context, void *region_context)
287 void *handler_context,
288 void *region_context)
289{ 283{
290 acpi_status status = AE_OK; 284 acpi_status status = AE_OK;
291 u32 value32; 285 u32 value32;
292 286
287 ACPI_FUNCTION_TRACE("ex_system_io_space_handler");
293 288
294 ACPI_FUNCTION_TRACE ("ex_system_io_space_handler"); 289 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
295 290 "system_iO %d (%d width) Address=%8.8X%8.8X\n",
296 291 function, bit_width, ACPI_FORMAT_UINT64(address)));
297 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
298 "system_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
299 ACPI_FORMAT_UINT64 (address)));
300 292
301 /* Decode the function parameter */ 293 /* Decode the function parameter */
302 294
303 switch (function) { 295 switch (function) {
304 case ACPI_READ: 296 case ACPI_READ:
305 297
306 status = acpi_os_read_port ((acpi_io_address) address, 298 status = acpi_os_read_port((acpi_io_address) address,
307 &value32, bit_width); 299 &value32, bit_width);
308 *value = value32; 300 *value = value32;
309 break; 301 break;
310 302
311 case ACPI_WRITE: 303 case ACPI_WRITE:
312 304
313 status = acpi_os_write_port ((acpi_io_address) address, 305 status = acpi_os_write_port((acpi_io_address) address,
314 (u32) *value, bit_width); 306 (u32) * value, bit_width);
315 break; 307 break;
316 308
317 default: 309 default:
@@ -319,10 +311,9 @@ acpi_ex_system_io_space_handler (
319 break; 311 break;
320 } 312 }
321 313
322 return_ACPI_STATUS (status); 314 return_ACPI_STATUS(status);
323} 315}
324 316
325
326/******************************************************************************* 317/*******************************************************************************
327 * 318 *
328 * FUNCTION: acpi_ex_pci_config_space_handler 319 * FUNCTION: acpi_ex_pci_config_space_handler
@@ -342,21 +333,17 @@ acpi_ex_system_io_space_handler (
342 ******************************************************************************/ 333 ******************************************************************************/
343 334
344acpi_status 335acpi_status
345acpi_ex_pci_config_space_handler ( 336acpi_ex_pci_config_space_handler(u32 function,
346 u32 function, 337 acpi_physical_address address,
347 acpi_physical_address address, 338 u32 bit_width,
348 u32 bit_width, 339 acpi_integer * value,
349 acpi_integer *value, 340 void *handler_context, void *region_context)
350 void *handler_context,
351 void *region_context)
352{ 341{
353 acpi_status status = AE_OK; 342 acpi_status status = AE_OK;
354 struct acpi_pci_id *pci_id; 343 struct acpi_pci_id *pci_id;
355 u16 pci_register; 344 u16 pci_register;
356
357
358 ACPI_FUNCTION_TRACE ("ex_pci_config_space_handler");
359 345
346 ACPI_FUNCTION_TRACE("ex_pci_config_space_handler");
360 347
361 /* 348 /*
362 * The arguments to acpi_os(Read|Write)pci_configuration are: 349 * The arguments to acpi_os(Read|Write)pci_configuration are:
@@ -370,26 +357,26 @@ acpi_ex_pci_config_space_handler (
370 * Value - input value for write, output address for read 357 * Value - input value for write, output address for read
371 * 358 *
372 */ 359 */
373 pci_id = (struct acpi_pci_id *) region_context; 360 pci_id = (struct acpi_pci_id *)region_context;
374 pci_register = (u16) (u32) address; 361 pci_register = (u16) (u32) address;
375 362
376 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 363 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
377 "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", 364 "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
378 function, bit_width, pci_id->segment, pci_id->bus, pci_id->device, 365 function, bit_width, pci_id->segment, pci_id->bus,
379 pci_id->function, pci_register)); 366 pci_id->device, pci_id->function, pci_register));
380 367
381 switch (function) { 368 switch (function) {
382 case ACPI_READ: 369 case ACPI_READ:
383 370
384 *value = 0; 371 *value = 0;
385 status = acpi_os_read_pci_configuration (pci_id, pci_register, 372 status = acpi_os_read_pci_configuration(pci_id, pci_register,
386 value, bit_width); 373 value, bit_width);
387 break; 374 break;
388 375
389 case ACPI_WRITE: 376 case ACPI_WRITE:
390 377
391 status = acpi_os_write_pci_configuration (pci_id, pci_register, 378 status = acpi_os_write_pci_configuration(pci_id, pci_register,
392 *value, bit_width); 379 *value, bit_width);
393 break; 380 break;
394 381
395 default: 382 default:
@@ -398,10 +385,9 @@ acpi_ex_pci_config_space_handler (
398 break; 385 break;
399 } 386 }
400 387
401 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
402} 389}
403 390
404
405/******************************************************************************* 391/*******************************************************************************
406 * 392 *
407 * FUNCTION: acpi_ex_cmos_space_handler 393 * FUNCTION: acpi_ex_cmos_space_handler
@@ -421,24 +407,19 @@ acpi_ex_pci_config_space_handler (
421 ******************************************************************************/ 407 ******************************************************************************/
422 408
423acpi_status 409acpi_status
424acpi_ex_cmos_space_handler ( 410acpi_ex_cmos_space_handler(u32 function,
425 u32 function, 411 acpi_physical_address address,
426 acpi_physical_address address, 412 u32 bit_width,
427 u32 bit_width, 413 acpi_integer * value,
428 acpi_integer *value, 414 void *handler_context, void *region_context)
429 void *handler_context,
430 void *region_context)
431{ 415{
432 acpi_status status = AE_OK; 416 acpi_status status = AE_OK;
433
434 417
435 ACPI_FUNCTION_TRACE ("ex_cmos_space_handler"); 418 ACPI_FUNCTION_TRACE("ex_cmos_space_handler");
436 419
437 420 return_ACPI_STATUS(status);
438 return_ACPI_STATUS (status);
439} 421}
440 422
441
442/******************************************************************************* 423/*******************************************************************************
443 * 424 *
444 * FUNCTION: acpi_ex_pci_bar_space_handler 425 * FUNCTION: acpi_ex_pci_bar_space_handler
@@ -458,24 +439,19 @@ acpi_ex_cmos_space_handler (
458 ******************************************************************************/ 439 ******************************************************************************/
459 440
460acpi_status 441acpi_status
461acpi_ex_pci_bar_space_handler ( 442acpi_ex_pci_bar_space_handler(u32 function,
462 u32 function, 443 acpi_physical_address address,
463 acpi_physical_address address, 444 u32 bit_width,
464 u32 bit_width, 445 acpi_integer * value,
465 acpi_integer *value, 446 void *handler_context, void *region_context)
466 void *handler_context,
467 void *region_context)
468{ 447{
469 acpi_status status = AE_OK; 448 acpi_status status = AE_OK;
470
471 449
472 ACPI_FUNCTION_TRACE ("ex_pci_bar_space_handler"); 450 ACPI_FUNCTION_TRACE("ex_pci_bar_space_handler");
473 451
474 452 return_ACPI_STATUS(status);
475 return_ACPI_STATUS (status);
476} 453}
477 454
478
479/******************************************************************************* 455/*******************************************************************************
480 * 456 *
481 * FUNCTION: acpi_ex_data_table_space_handler 457 * FUNCTION: acpi_ex_data_table_space_handler
@@ -495,24 +471,20 @@ acpi_ex_pci_bar_space_handler (
495 ******************************************************************************/ 471 ******************************************************************************/
496 472
497acpi_status 473acpi_status
498acpi_ex_data_table_space_handler ( 474acpi_ex_data_table_space_handler(u32 function,
499 u32 function, 475 acpi_physical_address address,
500 acpi_physical_address address, 476 u32 bit_width,
501 u32 bit_width, 477 acpi_integer * value,
502 acpi_integer *value, 478 void *handler_context, void *region_context)
503 void *handler_context,
504 void *region_context)
505{ 479{
506 acpi_status status = AE_OK; 480 acpi_status status = AE_OK;
507 u32 byte_width = ACPI_DIV_8 (bit_width); 481 u32 byte_width = ACPI_DIV_8(bit_width);
508 u32 i; 482 u32 i;
509 char *logical_addr_ptr; 483 char *logical_addr_ptr;
510
511 484
512 ACPI_FUNCTION_TRACE ("ex_data_table_space_handler"); 485 ACPI_FUNCTION_TRACE("ex_data_table_space_handler");
513 486
514 487 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR(address);
515 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
516 488
517 /* Perform the memory read or write */ 489 /* Perform the memory read or write */
518 490
@@ -520,17 +492,15 @@ acpi_ex_data_table_space_handler (
520 case ACPI_READ: 492 case ACPI_READ:
521 493
522 for (i = 0; i < byte_width; i++) { 494 for (i = 0; i < byte_width; i++) {
523 ((char *) value) [i] = logical_addr_ptr[i]; 495 ((char *)value)[i] = logical_addr_ptr[i];
524 } 496 }
525 break; 497 break;
526 498
527 case ACPI_WRITE: 499 case ACPI_WRITE:
528 default: 500 default:
529 501
530 return_ACPI_STATUS (AE_SUPPORT); 502 return_ACPI_STATUS(AE_SUPPORT);
531 } 503 }
532 504
533 return_ACPI_STATUS (status); 505 return_ACPI_STATUS(status);
534} 506}
535
536
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index 21d5c74fa309..ff5d8f97e8eb 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
@@ -50,10 +49,8 @@
50#include <acpi/acparser.h> 49#include <acpi/acparser.h>
51#include <acpi/amlcode.h> 50#include <acpi/amlcode.h>
52 51
53
54#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exresnte") 53ACPI_MODULE_NAME("exresnte")
56
57 54
58/******************************************************************************* 55/*******************************************************************************
59 * 56 *
@@ -80,41 +77,37 @@
80 * ACPI_TYPE_PACKAGE 77 * ACPI_TYPE_PACKAGE
81 * 78 *
82 ******************************************************************************/ 79 ******************************************************************************/
83
84acpi_status 80acpi_status
85acpi_ex_resolve_node_to_value ( 81acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
86 struct acpi_namespace_node **object_ptr, 82 struct acpi_walk_state *walk_state)
87 struct acpi_walk_state *walk_state)
88
89{ 83{
90 acpi_status status = AE_OK; 84 acpi_status status = AE_OK;
91 union acpi_operand_object *source_desc; 85 union acpi_operand_object *source_desc;
92 union acpi_operand_object *obj_desc = NULL; 86 union acpi_operand_object *obj_desc = NULL;
93 struct acpi_namespace_node *node; 87 struct acpi_namespace_node *node;
94 acpi_object_type entry_type; 88 acpi_object_type entry_type;
95
96
97 ACPI_FUNCTION_TRACE ("ex_resolve_node_to_value");
98 89
90 ACPI_FUNCTION_TRACE("ex_resolve_node_to_value");
99 91
100 /* 92 /*
101 * The stack pointer points to a struct acpi_namespace_node (Node). Get the 93 * The stack pointer points to a struct acpi_namespace_node (Node). Get the
102 * object that is attached to the Node. 94 * object that is attached to the Node.
103 */ 95 */
104 node = *object_ptr; 96 node = *object_ptr;
105 source_desc = acpi_ns_get_attached_object (node); 97 source_desc = acpi_ns_get_attached_object(node);
106 entry_type = acpi_ns_get_type ((acpi_handle) node); 98 entry_type = acpi_ns_get_type((acpi_handle) node);
107 99
108 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n", 100 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n",
109 node, source_desc, acpi_ut_get_type_name (entry_type))); 101 node, source_desc,
102 acpi_ut_get_type_name(entry_type)));
110 103
111 if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) || 104 if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) ||
112 (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { 105 (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
113 /* There is always exactly one level of indirection */ 106 /* There is always exactly one level of indirection */
114 107
115 node = ACPI_CAST_PTR (struct acpi_namespace_node, node->object); 108 node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object);
116 source_desc = acpi_ns_get_attached_object (node); 109 source_desc = acpi_ns_get_attached_object(node);
117 entry_type = acpi_ns_get_type ((acpi_handle) node); 110 entry_type = acpi_ns_get_type((acpi_handle) node);
118 *object_ptr = node; 111 *object_ptr = node;
119 } 112 }
120 113
@@ -124,14 +117,14 @@ acpi_ex_resolve_node_to_value (
124 * 2) Method locals and arguments have a pseudo-Node 117 * 2) Method locals and arguments have a pseudo-Node
125 */ 118 */
126 if (entry_type == ACPI_TYPE_DEVICE || 119 if (entry_type == ACPI_TYPE_DEVICE ||
127 (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { 120 (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) {
128 return_ACPI_STATUS (AE_OK); 121 return_ACPI_STATUS(AE_OK);
129 } 122 }
130 123
131 if (!source_desc) { 124 if (!source_desc) {
132 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n", 125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
133 node)); 126 "No object attached to node %p\n", node));
134 return_ACPI_STATUS (AE_AML_NO_OPERAND); 127 return_ACPI_STATUS(AE_AML_NO_OPERAND);
135 } 128 }
136 129
137 /* 130 /*
@@ -141,83 +134,89 @@ acpi_ex_resolve_node_to_value (
141 switch (entry_type) { 134 switch (entry_type) {
142 case ACPI_TYPE_PACKAGE: 135 case ACPI_TYPE_PACKAGE:
143 136
144 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_PACKAGE) { 137 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) {
145 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n", 138 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
146 acpi_ut_get_object_type_name (source_desc))); 139 "Object not a Package, type %s\n",
147 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 140 acpi_ut_get_object_type_name
141 (source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
148 } 143 }
149 144
150 status = acpi_ds_get_package_arguments (source_desc); 145 status = acpi_ds_get_package_arguments(source_desc);
151 if (ACPI_SUCCESS (status)) { 146 if (ACPI_SUCCESS(status)) {
152 /* Return an additional reference to the object */ 147 /* Return an additional reference to the object */
153 148
154 obj_desc = source_desc; 149 obj_desc = source_desc;
155 acpi_ut_add_reference (obj_desc); 150 acpi_ut_add_reference(obj_desc);
156 } 151 }
157 break; 152 break;
158 153
159
160 case ACPI_TYPE_BUFFER: 154 case ACPI_TYPE_BUFFER:
161 155
162 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { 156 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
163 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n", 157 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
164 acpi_ut_get_object_type_name (source_desc))); 158 "Object not a Buffer, type %s\n",
165 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 159 acpi_ut_get_object_type_name
160 (source_desc)));
161 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
166 } 162 }
167 163
168 status = acpi_ds_get_buffer_arguments (source_desc); 164 status = acpi_ds_get_buffer_arguments(source_desc);
169 if (ACPI_SUCCESS (status)) { 165 if (ACPI_SUCCESS(status)) {
170 /* Return an additional reference to the object */ 166 /* Return an additional reference to the object */
171 167
172 obj_desc = source_desc; 168 obj_desc = source_desc;
173 acpi_ut_add_reference (obj_desc); 169 acpi_ut_add_reference(obj_desc);
174 } 170 }
175 break; 171 break;
176 172
177
178 case ACPI_TYPE_STRING: 173 case ACPI_TYPE_STRING:
179 174
180 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) { 175 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) {
181 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n", 176 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
182 acpi_ut_get_object_type_name (source_desc))); 177 "Object not a String, type %s\n",
183 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 178 acpi_ut_get_object_type_name
179 (source_desc)));
180 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
184 } 181 }
185 182
186 /* Return an additional reference to the object */ 183 /* Return an additional reference to the object */
187 184
188 obj_desc = source_desc; 185 obj_desc = source_desc;
189 acpi_ut_add_reference (obj_desc); 186 acpi_ut_add_reference(obj_desc);
190 break; 187 break;
191 188
192
193 case ACPI_TYPE_INTEGER: 189 case ACPI_TYPE_INTEGER:
194 190
195 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) { 191 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) {
196 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n", 192 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
197 acpi_ut_get_object_type_name (source_desc))); 193 "Object not a Integer, type %s\n",
198 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 194 acpi_ut_get_object_type_name
195 (source_desc)));
196 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
199 } 197 }
200 198
201 /* Return an additional reference to the object */ 199 /* Return an additional reference to the object */
202 200
203 obj_desc = source_desc; 201 obj_desc = source_desc;
204 acpi_ut_add_reference (obj_desc); 202 acpi_ut_add_reference(obj_desc);
205 break; 203 break;
206 204
207
208 case ACPI_TYPE_BUFFER_FIELD: 205 case ACPI_TYPE_BUFFER_FIELD:
209 case ACPI_TYPE_LOCAL_REGION_FIELD: 206 case ACPI_TYPE_LOCAL_REGION_FIELD:
210 case ACPI_TYPE_LOCAL_BANK_FIELD: 207 case ACPI_TYPE_LOCAL_BANK_FIELD:
211 case ACPI_TYPE_LOCAL_INDEX_FIELD: 208 case ACPI_TYPE_LOCAL_INDEX_FIELD:
212 209
213 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 210 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
214 "field_read Node=%p source_desc=%p Type=%X\n", 211 "field_read Node=%p source_desc=%p Type=%X\n",
215 node, source_desc, entry_type)); 212 node, source_desc, entry_type));
216 213
217 status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc); 214 status =
215 acpi_ex_read_data_from_field(walk_state, source_desc,
216 &obj_desc);
218 break; 217 break;
219 218
220 /* For these objects, just return the object attached to the Node */ 219 /* For these objects, just return the object attached to the Node */
221 220
222 case ACPI_TYPE_MUTEX: 221 case ACPI_TYPE_MUTEX:
223 case ACPI_TYPE_METHOD: 222 case ACPI_TYPE_METHOD:
@@ -230,19 +229,18 @@ acpi_ex_resolve_node_to_value (
230 /* Return an additional reference to the object */ 229 /* Return an additional reference to the object */
231 230
232 obj_desc = source_desc; 231 obj_desc = source_desc;
233 acpi_ut_add_reference (obj_desc); 232 acpi_ut_add_reference(obj_desc);
234 break; 233 break;
235 234
236 /* TYPE_ANY is untyped, and thus there is no object associated with it */ 235 /* TYPE_ANY is untyped, and thus there is no object associated with it */
237 236
238 case ACPI_TYPE_ANY: 237 case ACPI_TYPE_ANY:
239 238
240 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
241 "Untyped entry %p, no attached object!\n", 240 "Untyped entry %p, no attached object!\n",
242 node)); 241 node));
243
244 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
245 242
243 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
246 244
247 case ACPI_TYPE_LOCAL_REFERENCE: 245 case ACPI_TYPE_LOCAL_REFERENCE:
248 246
@@ -253,39 +251,37 @@ acpi_ex_resolve_node_to_value (
253 /* Return an additional reference to the object */ 251 /* Return an additional reference to the object */
254 252
255 obj_desc = source_desc; 253 obj_desc = source_desc;
256 acpi_ut_add_reference (obj_desc); 254 acpi_ut_add_reference(obj_desc);
257 break; 255 break;
258 256
259 default: 257 default:
260 /* No named references are allowed here */ 258 /* No named references are allowed here */
261 259
262 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
263 "Unsupported Reference opcode %X (%s)\n", 261 "Unsupported Reference opcode %X (%s)\n",
264 source_desc->reference.opcode, 262 source_desc->reference.opcode,
265 acpi_ps_get_opcode_name (source_desc->reference.opcode))); 263 acpi_ps_get_opcode_name(source_desc->
264 reference.
265 opcode)));
266 266
267 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 267 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
268 } 268 }
269 break; 269 break;
270 270
271
272 default: 271 default:
273 272
274 /* Default case is for unknown types */ 273 /* Default case is for unknown types */
275 274
276 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
277 "Node %p - Unknown object type %X\n", 276 "Node %p - Unknown object type %X\n",
278 node, entry_type)); 277 node, entry_type));
279
280 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
281 278
282 } /* switch (entry_type) */ 279 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
283 280
281 } /* switch (entry_type) */
284 282
285 /* Return the object descriptor */ 283 /* Return the object descriptor */
286 284
287 *object_ptr = (void *) obj_desc; 285 *object_ptr = (void *)obj_desc;
288 return_ACPI_STATUS (status); 286 return_ACPI_STATUS(status);
289} 287}
290
291
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index 3de45672379a..97eecbd3242d 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
@@ -50,17 +49,13 @@
50#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
51#include <acpi/acparser.h> 50#include <acpi/acparser.h>
52 51
53
54#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exresolv") 53ACPI_MODULE_NAME("exresolv")
56 54
57/* Local prototypes */ 55/* Local prototypes */
58
59static acpi_status 56static acpi_status
60acpi_ex_resolve_object_to_value ( 57acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
61 union acpi_operand_object **stack_ptr, 58 struct acpi_walk_state *walk_state);
62 struct acpi_walk_state *walk_state);
63
64 59
65/******************************************************************************* 60/*******************************************************************************
66 * 61 *
@@ -78,19 +73,16 @@ acpi_ex_resolve_object_to_value (
78 ******************************************************************************/ 73 ******************************************************************************/
79 74
80acpi_status 75acpi_status
81acpi_ex_resolve_to_value ( 76acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
82 union acpi_operand_object **stack_ptr, 77 struct acpi_walk_state *walk_state)
83 struct acpi_walk_state *walk_state)
84{ 78{
85 acpi_status status; 79 acpi_status status;
86
87
88 ACPI_FUNCTION_TRACE_PTR ("ex_resolve_to_value", stack_ptr);
89 80
81 ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr);
90 82
91 if (!stack_ptr || !*stack_ptr) { 83 if (!stack_ptr || !*stack_ptr) {
92 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); 84 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n"));
93 return_ACPI_STATUS (AE_AML_NO_OPERAND); 85 return_ACPI_STATUS(AE_AML_NO_OPERAND);
94 } 86 }
95 87
96 /* 88 /*
@@ -98,15 +90,16 @@ acpi_ex_resolve_to_value (
98 * 1) A valid union acpi_operand_object, or 90 * 1) A valid union acpi_operand_object, or
99 * 2) A struct acpi_namespace_node (named_obj) 91 * 2) A struct acpi_namespace_node (named_obj)
100 */ 92 */
101 if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_OPERAND) { 93 if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_OPERAND) {
102 status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state); 94 status = acpi_ex_resolve_object_to_value(stack_ptr, walk_state);
103 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE(status)) {
104 return_ACPI_STATUS (status); 96 return_ACPI_STATUS(status);
105 } 97 }
106 98
107 if (!*stack_ptr) { 99 if (!*stack_ptr) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); 100 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
109 return_ACPI_STATUS (AE_AML_NO_OPERAND); 101 "Internal - null pointer\n"));
102 return_ACPI_STATUS(AE_AML_NO_OPERAND);
110 } 103 }
111 } 104 }
112 105
@@ -114,20 +107,20 @@ acpi_ex_resolve_to_value (
114 * Object on the stack may have changed if acpi_ex_resolve_object_to_value() 107 * Object on the stack may have changed if acpi_ex_resolve_object_to_value()
115 * was called (i.e., we can't use an _else_ here.) 108 * was called (i.e., we can't use an _else_ here.)
116 */ 109 */
117 if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) { 110 if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_NAMED) {
118 status = acpi_ex_resolve_node_to_value ( 111 status =
119 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, stack_ptr), 112 acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
120 walk_state); 113 (struct acpi_namespace_node,
121 if (ACPI_FAILURE (status)) { 114 stack_ptr), walk_state);
122 return_ACPI_STATUS (status); 115 if (ACPI_FAILURE(status)) {
116 return_ACPI_STATUS(status);
123 } 117 }
124 } 118 }
125 119
126 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr)); 120 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr));
127 return_ACPI_STATUS (AE_OK); 121 return_ACPI_STATUS(AE_OK);
128} 122}
129 123
130
131/******************************************************************************* 124/*******************************************************************************
132 * 125 *
133 * FUNCTION: acpi_ex_resolve_object_to_value 126 * FUNCTION: acpi_ex_resolve_object_to_value
@@ -143,25 +136,22 @@ acpi_ex_resolve_to_value (
143 ******************************************************************************/ 136 ******************************************************************************/
144 137
145static acpi_status 138static acpi_status
146acpi_ex_resolve_object_to_value ( 139acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
147 union acpi_operand_object **stack_ptr, 140 struct acpi_walk_state *walk_state)
148 struct acpi_walk_state *walk_state)
149{ 141{
150 acpi_status status = AE_OK; 142 acpi_status status = AE_OK;
151 union acpi_operand_object *stack_desc; 143 union acpi_operand_object *stack_desc;
152 void *temp_node; 144 void *temp_node;
153 union acpi_operand_object *obj_desc; 145 union acpi_operand_object *obj_desc;
154 u16 opcode; 146 u16 opcode;
155
156
157 ACPI_FUNCTION_TRACE ("ex_resolve_object_to_value");
158 147
148 ACPI_FUNCTION_TRACE("ex_resolve_object_to_value");
159 149
160 stack_desc = *stack_ptr; 150 stack_desc = *stack_ptr;
161 151
162 /* This is an union acpi_operand_object */ 152 /* This is an union acpi_operand_object */
163 153
164 switch (ACPI_GET_OBJECT_TYPE (stack_desc)) { 154 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) {
165 case ACPI_TYPE_LOCAL_REFERENCE: 155 case ACPI_TYPE_LOCAL_REFERENCE:
166 156
167 opcode = stack_desc->reference.opcode; 157 opcode = stack_desc->reference.opcode;
@@ -177,14 +167,13 @@ acpi_ex_resolve_object_to_value (
177 167
178 /* Delete the Reference Object */ 168 /* Delete the Reference Object */
179 169
180 acpi_ut_remove_reference (stack_desc); 170 acpi_ut_remove_reference(stack_desc);
181 171
182 /* Return the namespace node */ 172 /* Return the namespace node */
183 173
184 (*stack_ptr) = temp_node; 174 (*stack_ptr) = temp_node;
185 break; 175 break;
186 176
187
188 case AML_LOCAL_OP: 177 case AML_LOCAL_OP:
189 case AML_ARG_OP: 178 case AML_ARG_OP:
190 179
@@ -192,24 +181,28 @@ acpi_ex_resolve_object_to_value (
192 * Get the local from the method's state info 181 * Get the local from the method's state info
193 * Note: this increments the local's object reference count 182 * Note: this increments the local's object reference count
194 */ 183 */
195 status = acpi_ds_method_data_get_value (opcode, 184 status = acpi_ds_method_data_get_value(opcode,
196 stack_desc->reference.offset, walk_state, &obj_desc); 185 stack_desc->
197 if (ACPI_FAILURE (status)) { 186 reference.offset,
198 return_ACPI_STATUS (status); 187 walk_state,
188 &obj_desc);
189 if (ACPI_FAILURE(status)) {
190 return_ACPI_STATUS(status);
199 } 191 }
200 192
201 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] value_obj is %p\n", 193 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
202 stack_desc->reference.offset, obj_desc)); 194 "[Arg/Local %X] value_obj is %p\n",
195 stack_desc->reference.offset,
196 obj_desc));
203 197
204 /* 198 /*
205 * Now we can delete the original Reference Object and 199 * Now we can delete the original Reference Object and
206 * replace it with the resolved value 200 * replace it with the resolved value
207 */ 201 */
208 acpi_ut_remove_reference (stack_desc); 202 acpi_ut_remove_reference(stack_desc);
209 *stack_ptr = obj_desc; 203 *stack_ptr = obj_desc;
210 break; 204 break;
211 205
212
213 case AML_INDEX_OP: 206 case AML_INDEX_OP:
214 207
215 switch (stack_desc->reference.target_type) { 208 switch (stack_desc->reference.target_type) {
@@ -218,7 +211,6 @@ acpi_ex_resolve_object_to_value (
218 /* Just return - leave the Reference on the stack */ 211 /* Just return - leave the Reference on the stack */
219 break; 212 break;
220 213
221
222 case ACPI_TYPE_PACKAGE: 214 case ACPI_TYPE_PACKAGE:
223 215
224 obj_desc = *stack_desc->reference.where; 216 obj_desc = *stack_desc->reference.where;
@@ -228,36 +220,31 @@ acpi_ex_resolve_object_to_value (
228 * (i.e., dereference the package index) 220 * (i.e., dereference the package index)
229 * Delete the ref object, increment the returned object 221 * Delete the ref object, increment the returned object
230 */ 222 */
231 acpi_ut_remove_reference (stack_desc); 223 acpi_ut_remove_reference(stack_desc);
232 acpi_ut_add_reference (obj_desc); 224 acpi_ut_add_reference(obj_desc);
233 *stack_ptr = obj_desc; 225 *stack_ptr = obj_desc;
234 } 226 } else {
235 else {
236 /* 227 /*
237 * A NULL object descriptor means an unitialized element of 228 * A NULL object descriptor means an unitialized element of
238 * the package, can't dereference it 229 * the package, can't dereference it
239 */ 230 */
240 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 231 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
241 "Attempt to deref an Index to NULL pkg element Idx=%p\n", 232 "Attempt to deref an Index to NULL pkg element Idx=%p\n",
242 stack_desc)); 233 stack_desc));
243 status = AE_AML_UNINITIALIZED_ELEMENT; 234 status = AE_AML_UNINITIALIZED_ELEMENT;
244 } 235 }
245 break; 236 break;
246 237
247
248 default: 238 default:
249 239
250 /* Invalid reference object */ 240 /* Invalid reference object */
251 241
252 ACPI_REPORT_ERROR (( 242 ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc));
253 "During resolve, Unknown target_type %X in Index/Reference obj %p\n",
254 stack_desc->reference.target_type, stack_desc));
255 status = AE_AML_INTERNAL; 243 status = AE_AML_INTERNAL;
256 break; 244 break;
257 } 245 }
258 break; 246 break;
259 247
260
261 case AML_REF_OF_OP: 248 case AML_REF_OF_OP:
262 case AML_DEBUG_OP: 249 case AML_DEBUG_OP:
263 case AML_LOAD_OP: 250 case AML_LOAD_OP:
@@ -266,60 +253,58 @@ acpi_ex_resolve_object_to_value (
266 253
267 break; 254 break;
268 255
269 case AML_INT_NAMEPATH_OP: /* Reference to a named object */ 256 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
270 257
271 /* Get the object pointed to by the namespace node */ 258 /* Get the object pointed to by the namespace node */
272 259
273 *stack_ptr = (stack_desc->reference.node)->object; 260 *stack_ptr = (stack_desc->reference.node)->object;
274 acpi_ut_add_reference (*stack_ptr); 261 acpi_ut_add_reference(*stack_ptr);
275 acpi_ut_remove_reference (stack_desc); 262 acpi_ut_remove_reference(stack_desc);
276 break; 263 break;
277 264
278 default: 265 default:
279 266
280 ACPI_REPORT_ERROR (( 267 ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc));
281 "During resolve, Unknown Reference opcode %X (%s) in %p\n",
282 opcode, acpi_ps_get_opcode_name (opcode), stack_desc));
283 status = AE_AML_INTERNAL; 268 status = AE_AML_INTERNAL;
284 break; 269 break;
285 } 270 }
286 break; 271 break;
287 272
288
289 case ACPI_TYPE_BUFFER: 273 case ACPI_TYPE_BUFFER:
290 274
291 status = acpi_ds_get_buffer_arguments (stack_desc); 275 status = acpi_ds_get_buffer_arguments(stack_desc);
292 break; 276 break;
293 277
294
295 case ACPI_TYPE_PACKAGE: 278 case ACPI_TYPE_PACKAGE:
296 279
297 status = acpi_ds_get_package_arguments (stack_desc); 280 status = acpi_ds_get_package_arguments(stack_desc);
298 break; 281 break;
299 282
300 283 /* These cases may never happen here, but just in case.. */
301 /* These cases may never happen here, but just in case.. */
302 284
303 case ACPI_TYPE_BUFFER_FIELD: 285 case ACPI_TYPE_BUFFER_FIELD:
304 case ACPI_TYPE_LOCAL_REGION_FIELD: 286 case ACPI_TYPE_LOCAL_REGION_FIELD:
305 case ACPI_TYPE_LOCAL_BANK_FIELD: 287 case ACPI_TYPE_LOCAL_BANK_FIELD:
306 case ACPI_TYPE_LOCAL_INDEX_FIELD: 288 case ACPI_TYPE_LOCAL_INDEX_FIELD:
307 289
308 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read source_desc=%p Type=%X\n", 290 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
309 stack_desc, ACPI_GET_OBJECT_TYPE (stack_desc))); 291 "field_read source_desc=%p Type=%X\n",
292 stack_desc,
293 ACPI_GET_OBJECT_TYPE(stack_desc)));
310 294
311 status = acpi_ex_read_data_from_field (walk_state, stack_desc, &obj_desc); 295 status =
312 *stack_ptr = (void *) obj_desc; 296 acpi_ex_read_data_from_field(walk_state, stack_desc,
297 &obj_desc);
298 *stack_ptr = (void *)obj_desc;
313 break; 299 break;
314 300
315 default: 301 default:
316 break; 302 break;
317 } 303 }
318 304
319 return_ACPI_STATUS (status); 305 return_ACPI_STATUS(status);
320} 306}
321 307
322
323/******************************************************************************* 308/*******************************************************************************
324 * 309 *
325 * FUNCTION: acpi_ex_resolve_multiple 310 * FUNCTION: acpi_ex_resolve_multiple
@@ -337,42 +322,44 @@ acpi_ex_resolve_object_to_value (
337 ******************************************************************************/ 322 ******************************************************************************/
338 323
339acpi_status 324acpi_status
340acpi_ex_resolve_multiple ( 325acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
341 struct acpi_walk_state *walk_state, 326 union acpi_operand_object *operand,
342 union acpi_operand_object *operand, 327 acpi_object_type * return_type,
343 acpi_object_type *return_type, 328 union acpi_operand_object **return_desc)
344 union acpi_operand_object **return_desc)
345{ 329{
346 union acpi_operand_object *obj_desc = (void *) operand; 330 union acpi_operand_object *obj_desc = (void *)operand;
347 struct acpi_namespace_node *node; 331 struct acpi_namespace_node *node;
348 acpi_object_type type; 332 acpi_object_type type;
349 acpi_status status; 333 acpi_status status;
350
351
352 ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
353 334
335 ACPI_FUNCTION_TRACE("acpi_ex_resolve_multiple");
354 336
355 /* Operand can be either a namespace node or an operand descriptor */ 337 /* Operand can be either a namespace node or an operand descriptor */
356 338
357 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 339 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
358 case ACPI_DESC_TYPE_OPERAND: 340 case ACPI_DESC_TYPE_OPERAND:
359 type = obj_desc->common.type; 341 type = obj_desc->common.type;
360 break; 342 break;
361 343
362 case ACPI_DESC_TYPE_NAMED: 344 case ACPI_DESC_TYPE_NAMED:
363 type = ((struct acpi_namespace_node *) obj_desc)->type; 345 type = ((struct acpi_namespace_node *)obj_desc)->type;
364 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); 346 obj_desc =
347 acpi_ns_get_attached_object((struct acpi_namespace_node *)
348 obj_desc);
365 349
366 /* If we had an Alias node, use the attached object for type info */ 350 /* If we had an Alias node, use the attached object for type info */
367 351
368 if (type == ACPI_TYPE_LOCAL_ALIAS) { 352 if (type == ACPI_TYPE_LOCAL_ALIAS) {
369 type = ((struct acpi_namespace_node *) obj_desc)->type; 353 type = ((struct acpi_namespace_node *)obj_desc)->type;
370 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); 354 obj_desc =
355 acpi_ns_get_attached_object((struct
356 acpi_namespace_node *)
357 obj_desc);
371 } 358 }
372 break; 359 break;
373 360
374 default: 361 default:
375 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 362 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
376 } 363 }
377 364
378 /* If type is anything other than a reference, we are done */ 365 /* If type is anything other than a reference, we are done */
@@ -387,7 +374,7 @@ acpi_ex_resolve_multiple (
387 * of the object_type and size_of operators). This means traversing 374 * of the object_type and size_of operators). This means traversing
388 * the list of possibly many nested references. 375 * the list of possibly many nested references.
389 */ 376 */
390 while (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { 377 while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
391 switch (obj_desc->reference.opcode) { 378 switch (obj_desc->reference.opcode) {
392 case AML_REF_OF_OP: 379 case AML_REF_OF_OP:
393 380
@@ -397,31 +384,29 @@ acpi_ex_resolve_multiple (
397 384
398 /* All "References" point to a NS node */ 385 /* All "References" point to a NS node */
399 386
400 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 387 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
401 ACPI_REPORT_ERROR (( 388 ACPI_DESC_TYPE_NAMED) {
402 "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", 389 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node)));
403 node, acpi_ut_get_descriptor_name (node))); 390 return_ACPI_STATUS(AE_AML_INTERNAL);
404 return_ACPI_STATUS (AE_AML_INTERNAL);
405 } 391 }
406 392
407 /* Get the attached object */ 393 /* Get the attached object */
408 394
409 obj_desc = acpi_ns_get_attached_object (node); 395 obj_desc = acpi_ns_get_attached_object(node);
410 if (!obj_desc) { 396 if (!obj_desc) {
411 /* No object, use the NS node type */ 397 /* No object, use the NS node type */
412 398
413 type = acpi_ns_get_type (node); 399 type = acpi_ns_get_type(node);
414 goto exit; 400 goto exit;
415 } 401 }
416 402
417 /* Check for circular references */ 403 /* Check for circular references */
418 404
419 if (obj_desc == operand) { 405 if (obj_desc == operand) {
420 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 406 return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE);
421 } 407 }
422 break; 408 break;
423 409
424
425 case AML_INDEX_OP: 410 case AML_INDEX_OP:
426 411
427 /* Get the type of this reference (index into another object) */ 412 /* Get the type of this reference (index into another object) */
@@ -442,12 +427,11 @@ acpi_ex_resolve_multiple (
442 if (!obj_desc) { 427 if (!obj_desc) {
443 /* NULL package elements are allowed */ 428 /* NULL package elements are allowed */
444 429
445 type = 0; /* Uninitialized */ 430 type = 0; /* Uninitialized */
446 goto exit; 431 goto exit;
447 } 432 }
448 break; 433 break;
449 434
450
451 case AML_INT_NAMEPATH_OP: 435 case AML_INT_NAMEPATH_OP:
452 436
453 /* Dereference the reference pointer */ 437 /* Dereference the reference pointer */
@@ -456,50 +440,61 @@ acpi_ex_resolve_multiple (
456 440
457 /* All "References" point to a NS node */ 441 /* All "References" point to a NS node */
458 442
459 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 443 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
460 ACPI_REPORT_ERROR (( 444 ACPI_DESC_TYPE_NAMED) {
461 "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", 445 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node)));
462 node, acpi_ut_get_descriptor_name (node))); 446 return_ACPI_STATUS(AE_AML_INTERNAL);
463 return_ACPI_STATUS (AE_AML_INTERNAL);
464 } 447 }
465 448
466 /* Get the attached object */ 449 /* Get the attached object */
467 450
468 obj_desc = acpi_ns_get_attached_object (node); 451 obj_desc = acpi_ns_get_attached_object(node);
469 if (!obj_desc) { 452 if (!obj_desc) {
470 /* No object, use the NS node type */ 453 /* No object, use the NS node type */
471 454
472 type = acpi_ns_get_type (node); 455 type = acpi_ns_get_type(node);
473 goto exit; 456 goto exit;
474 } 457 }
475 458
476 /* Check for circular references */ 459 /* Check for circular references */
477 460
478 if (obj_desc == operand) { 461 if (obj_desc == operand) {
479 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 462 return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE);
480 } 463 }
481 break; 464 break;
482 465
483
484 case AML_LOCAL_OP: 466 case AML_LOCAL_OP:
485 case AML_ARG_OP: 467 case AML_ARG_OP:
486 468
487 if (return_desc) { 469 if (return_desc) {
488 status = acpi_ds_method_data_get_value (obj_desc->reference.opcode, 470 status =
489 obj_desc->reference.offset, walk_state, &obj_desc); 471 acpi_ds_method_data_get_value(obj_desc->
490 if (ACPI_FAILURE (status)) { 472 reference.
491 return_ACPI_STATUS (status); 473 opcode,
474 obj_desc->
475 reference.
476 offset,
477 walk_state,
478 &obj_desc);
479 if (ACPI_FAILURE(status)) {
480 return_ACPI_STATUS(status);
492 } 481 }
493 acpi_ut_remove_reference (obj_desc); 482 acpi_ut_remove_reference(obj_desc);
494 } 483 } else {
495 else { 484 status =
496 status = acpi_ds_method_data_get_node (obj_desc->reference.opcode, 485 acpi_ds_method_data_get_node(obj_desc->
497 obj_desc->reference.offset, walk_state, &node); 486 reference.
498 if (ACPI_FAILURE (status)) { 487 opcode,
499 return_ACPI_STATUS (status); 488 obj_desc->
489 reference.
490 offset,
491 walk_state,
492 &node);
493 if (ACPI_FAILURE(status)) {
494 return_ACPI_STATUS(status);
500 } 495 }
501 496
502 obj_desc = acpi_ns_get_attached_object (node); 497 obj_desc = acpi_ns_get_attached_object(node);
503 if (!obj_desc) { 498 if (!obj_desc) {
504 type = ACPI_TYPE_ANY; 499 type = ACPI_TYPE_ANY;
505 goto exit; 500 goto exit;
@@ -507,7 +502,6 @@ acpi_ex_resolve_multiple (
507 } 502 }
508 break; 503 break;
509 504
510
511 case AML_DEBUG_OP: 505 case AML_DEBUG_OP:
512 506
513 /* The Debug Object is of type "debug_object" */ 507 /* The Debug Object is of type "debug_object" */
@@ -515,13 +509,10 @@ acpi_ex_resolve_multiple (
515 type = ACPI_TYPE_DEBUG_OBJECT; 509 type = ACPI_TYPE_DEBUG_OBJECT;
516 goto exit; 510 goto exit;
517 511
518
519 default: 512 default:
520 513
521 ACPI_REPORT_ERROR (( 514 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode));
522 "acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", 515 return_ACPI_STATUS(AE_AML_INTERNAL);
523 obj_desc->reference.opcode));
524 return_ACPI_STATUS (AE_AML_INTERNAL);
525 } 516 }
526 } 517 }
527 518
@@ -529,10 +520,9 @@ acpi_ex_resolve_multiple (
529 * Now we are guaranteed to have an object that has not been created 520 * Now we are guaranteed to have an object that has not been created
530 * via the ref_of or Index operators. 521 * via the ref_of or Index operators.
531 */ 522 */
532 type = ACPI_GET_OBJECT_TYPE (obj_desc); 523 type = ACPI_GET_OBJECT_TYPE(obj_desc);
533 524
534 525 exit:
535exit:
536 /* Convert internal types to external types */ 526 /* Convert internal types to external types */
537 527
538 switch (type) { 528 switch (type) {
@@ -559,7 +549,5 @@ exit:
559 if (return_desc) { 549 if (return_desc) {
560 *return_desc = obj_desc; 550 *return_desc = obj_desc;
561 } 551 }
562 return_ACPI_STATUS (AE_OK); 552 return_ACPI_STATUS(AE_OK);
563} 553}
564
565
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index d8b470eefe7a..ff064e79ab90 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -42,24 +42,18 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acparser.h> 47#include <acpi/acparser.h>
49#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exresop") 51ACPI_MODULE_NAME("exresop")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static acpi_status 54static acpi_status
58acpi_ex_check_object_type ( 55acpi_ex_check_object_type(acpi_object_type type_needed,
59 acpi_object_type type_needed, 56 acpi_object_type this_type, void *object);
60 acpi_object_type this_type,
61 void *object);
62
63 57
64/******************************************************************************* 58/*******************************************************************************
65 * 59 *
@@ -76,13 +70,10 @@ acpi_ex_check_object_type (
76 ******************************************************************************/ 70 ******************************************************************************/
77 71
78static acpi_status 72static acpi_status
79acpi_ex_check_object_type ( 73acpi_ex_check_object_type(acpi_object_type type_needed,
80 acpi_object_type type_needed, 74 acpi_object_type this_type, void *object)
81 acpi_object_type this_type,
82 void *object)
83{ 75{
84 ACPI_FUNCTION_NAME ("ex_check_object_type"); 76 ACPI_FUNCTION_NAME("ex_check_object_type");
85
86 77
87 if (type_needed == ACPI_TYPE_ANY) { 78 if (type_needed == ACPI_TYPE_ANY) {
88 /* All types OK, so we don't perform any typechecks */ 79 /* All types OK, so we don't perform any typechecks */
@@ -97,16 +88,17 @@ acpi_ex_check_object_type (
97 * specification, a store to a constant is a noop.) 88 * specification, a store to a constant is a noop.)
98 */ 89 */
99 if ((this_type == ACPI_TYPE_INTEGER) && 90 if ((this_type == ACPI_TYPE_INTEGER) &&
100 (((union acpi_operand_object *) object)->common.flags & AOPOBJ_AML_CONSTANT)) { 91 (((union acpi_operand_object *)object)->common.
92 flags & AOPOBJ_AML_CONSTANT)) {
101 return (AE_OK); 93 return (AE_OK);
102 } 94 }
103 } 95 }
104 96
105 if (type_needed != this_type) { 97 if (type_needed != this_type) {
106 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 98 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
107 "Needed [%s], found [%s] %p\n", 99 "Needed [%s], found [%s] %p\n",
108 acpi_ut_get_type_name (type_needed), 100 acpi_ut_get_type_name(type_needed),
109 acpi_ut_get_type_name (this_type), object)); 101 acpi_ut_get_type_name(this_type), object));
110 102
111 return (AE_AML_OPERAND_TYPE); 103 return (AE_AML_OPERAND_TYPE);
112 } 104 }
@@ -114,7 +106,6 @@ acpi_ex_check_object_type (
114 return (AE_OK); 106 return (AE_OK);
115} 107}
116 108
117
118/******************************************************************************* 109/*******************************************************************************
119 * 110 *
120 * FUNCTION: acpi_ex_resolve_operands 111 * FUNCTION: acpi_ex_resolve_operands
@@ -137,41 +128,37 @@ acpi_ex_check_object_type (
137 ******************************************************************************/ 128 ******************************************************************************/
138 129
139acpi_status 130acpi_status
140acpi_ex_resolve_operands ( 131acpi_ex_resolve_operands(u16 opcode,
141 u16 opcode, 132 union acpi_operand_object ** stack_ptr,
142 union acpi_operand_object **stack_ptr, 133 struct acpi_walk_state * walk_state)
143 struct acpi_walk_state *walk_state)
144{ 134{
145 union acpi_operand_object *obj_desc; 135 union acpi_operand_object *obj_desc;
146 acpi_status status = AE_OK; 136 acpi_status status = AE_OK;
147 u8 object_type; 137 u8 object_type;
148 void *temp_node; 138 void *temp_node;
149 u32 arg_types; 139 u32 arg_types;
150 const struct acpi_opcode_info *op_info; 140 const struct acpi_opcode_info *op_info;
151 u32 this_arg_type; 141 u32 this_arg_type;
152 acpi_object_type type_needed; 142 acpi_object_type type_needed;
153 u16 target_op = 0; 143 u16 target_op = 0;
154 144
155 145 ACPI_FUNCTION_TRACE_U32("ex_resolve_operands", opcode);
156 ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode); 146
157 147 op_info = acpi_ps_get_opcode_info(opcode);
158
159 op_info = acpi_ps_get_opcode_info (opcode);
160 if (op_info->class == AML_CLASS_UNKNOWN) { 148 if (op_info->class == AML_CLASS_UNKNOWN) {
161 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 149 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
162 } 150 }
163 151
164 arg_types = op_info->runtime_args; 152 arg_types = op_info->runtime_args;
165 if (arg_types == ARGI_INVALID_OPCODE) { 153 if (arg_types == ARGI_INVALID_OPCODE) {
166 ACPI_REPORT_ERROR (("resolve_operands: %X is not a valid AML opcode\n", 154 ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode));
167 opcode));
168 155
169 return_ACPI_STATUS (AE_AML_INTERNAL); 156 return_ACPI_STATUS(AE_AML_INTERNAL);
170 } 157 }
171 158
172 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
173 "Opcode %X [%s] required_operand_types=%8.8X \n", 160 "Opcode %X [%s] required_operand_types=%8.8X \n",
174 opcode, op_info->name, arg_types)); 161 opcode, op_info->name, arg_types));
175 162
176 /* 163 /*
177 * Normal exit is with (arg_types == 0) at end of argument list. 164 * Normal exit is with (arg_types == 0) at end of argument list.
@@ -180,12 +167,11 @@ acpi_ex_resolve_operands (
180 * to) the required type; if stack underflows; or upon 167 * to) the required type; if stack underflows; or upon
181 * finding a NULL stack entry (which should not happen). 168 * finding a NULL stack entry (which should not happen).
182 */ 169 */
183 while (GET_CURRENT_ARG_TYPE (arg_types)) { 170 while (GET_CURRENT_ARG_TYPE(arg_types)) {
184 if (!stack_ptr || !*stack_ptr) { 171 if (!stack_ptr || !*stack_ptr) {
185 ACPI_REPORT_ERROR (("resolve_operands: Null stack entry at %p\n", 172 ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr));
186 stack_ptr));
187 173
188 return_ACPI_STATUS (AE_AML_INTERNAL); 174 return_ACPI_STATUS(AE_AML_INTERNAL);
189 } 175 }
190 176
191 /* Extract useful items */ 177 /* Extract useful items */
@@ -194,37 +180,37 @@ acpi_ex_resolve_operands (
194 180
195 /* Decode the descriptor type */ 181 /* Decode the descriptor type */
196 182
197 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 183 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
198 case ACPI_DESC_TYPE_NAMED: 184 case ACPI_DESC_TYPE_NAMED:
199 185
200 /* Namespace Node */ 186 /* Namespace Node */
201 187
202 object_type = ((struct acpi_namespace_node *) obj_desc)->type; 188 object_type =
189 ((struct acpi_namespace_node *)obj_desc)->type;
203 break; 190 break;
204 191
205
206 case ACPI_DESC_TYPE_OPERAND: 192 case ACPI_DESC_TYPE_OPERAND:
207 193
208 /* ACPI internal object */ 194 /* ACPI internal object */
209 195
210 object_type = ACPI_GET_OBJECT_TYPE (obj_desc); 196 object_type = ACPI_GET_OBJECT_TYPE(obj_desc);
211 197
212 /* Check for bad acpi_object_type */ 198 /* Check for bad acpi_object_type */
213 199
214 if (!acpi_ut_valid_object_type (object_type)) { 200 if (!acpi_ut_valid_object_type(object_type)) {
215 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
216 "Bad operand object type [%X]\n", 202 "Bad operand object type [%X]\n",
217 object_type)); 203 object_type));
218 204
219 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 205 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
220 } 206 }
221 207
222 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { 208 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
223 /* Decode the Reference */ 209 /* Decode the Reference */
224 210
225 op_info = acpi_ps_get_opcode_info (opcode); 211 op_info = acpi_ps_get_opcode_info(opcode);
226 if (op_info->class == AML_CLASS_UNKNOWN) { 212 if (op_info->class == AML_CLASS_UNKNOWN) {
227 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 213 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
228 } 214 }
229 215
230 switch (obj_desc->reference.opcode) { 216 switch (obj_desc->reference.opcode) {
@@ -238,51 +224,62 @@ acpi_ex_resolve_operands (
238 case AML_REF_OF_OP: 224 case AML_REF_OF_OP:
239 case AML_ARG_OP: 225 case AML_ARG_OP:
240 case AML_LOCAL_OP: 226 case AML_LOCAL_OP:
241 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ 227 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
242 case AML_INT_NAMEPATH_OP: /* Reference to a named object */ 228 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
243 229
244 ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 230 ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT
245 "Operand is a Reference, ref_opcode [%s]\n", 231 ((ACPI_DB_EXEC,
246 (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name))); 232 "Operand is a Reference, ref_opcode [%s]\n",
233 (acpi_ps_get_opcode_info
234 (obj_desc->
235 reference.
236 opcode))->
237 name)));
247 break; 238 break;
248 239
249 default: 240 default:
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 241 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
251 "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", 242 "Operand is a Reference, Unknown Reference Opcode %X [%s]\n",
252 obj_desc->reference.opcode, 243 obj_desc->reference.
253 (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name)); 244 opcode,
254 245 (acpi_ps_get_opcode_info
255 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 246 (obj_desc->reference.
247 opcode))->name));
248
249 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
256 } 250 }
257 } 251 }
258 break; 252 break;
259 253
260
261 default: 254 default:
262 255
263 /* Invalid descriptor */ 256 /* Invalid descriptor */
264 257
265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 258 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
266 "Invalid descriptor %p [%s]\n", 259 "Invalid descriptor %p [%s]\n",
267 obj_desc, acpi_ut_get_descriptor_name (obj_desc))); 260 obj_desc,
261 acpi_ut_get_descriptor_name
262 (obj_desc)));
268 263
269 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
270 } 265 }
271 266
272 /* Get one argument type, point to the next */ 267 /* Get one argument type, point to the next */
273 268
274 this_arg_type = GET_CURRENT_ARG_TYPE (arg_types); 269 this_arg_type = GET_CURRENT_ARG_TYPE(arg_types);
275 INCREMENT_ARG_LIST (arg_types); 270 INCREMENT_ARG_LIST(arg_types);
276 271
277 /* 272 /*
278 * Handle cases where the object does not need to be 273 * Handle cases where the object does not need to be
279 * resolved to a value 274 * resolved to a value
280 */ 275 */
281 switch (this_arg_type) { 276 switch (this_arg_type) {
282 case ARGI_REF_OR_STRING: /* Can be a String or Reference */ 277 case ARGI_REF_OR_STRING: /* Can be a String or Reference */
283 278
284 if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) && 279 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
285 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) { 280 ACPI_DESC_TYPE_OPERAND)
281 && (ACPI_GET_OBJECT_TYPE(obj_desc) ==
282 ACPI_TYPE_STRING)) {
286 /* 283 /*
287 * String found - the string references a named object and 284 * String found - the string references a named object and
288 * must be resolved to a node 285 * must be resolved to a node
@@ -296,39 +293,40 @@ acpi_ex_resolve_operands (
296 */ 293 */
297 /*lint -fallthrough */ 294 /*lint -fallthrough */
298 295
299 case ARGI_REFERENCE: /* References: */ 296 case ARGI_REFERENCE: /* References: */
300 case ARGI_INTEGER_REF: 297 case ARGI_INTEGER_REF:
301 case ARGI_OBJECT_REF: 298 case ARGI_OBJECT_REF:
302 case ARGI_DEVICE_REF: 299 case ARGI_DEVICE_REF:
303 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 300 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
304 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 301 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
305 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ 302 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
306 303
307 /* 304 /*
308 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 305 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
309 * A Namespace Node is OK as-is 306 * A Namespace Node is OK as-is
310 */ 307 */
311 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 308 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
309 ACPI_DESC_TYPE_NAMED) {
312 goto next_operand; 310 goto next_operand;
313 } 311 }
314 312
315 status = acpi_ex_check_object_type (ACPI_TYPE_LOCAL_REFERENCE, 313 status =
316 object_type, obj_desc); 314 acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE,
317 if (ACPI_FAILURE (status)) { 315 object_type, obj_desc);
318 return_ACPI_STATUS (status); 316 if (ACPI_FAILURE(status)) {
317 return_ACPI_STATUS(status);
319 } 318 }
320 319
321 if (obj_desc->reference.opcode == AML_NAME_OP) { 320 if (obj_desc->reference.opcode == AML_NAME_OP) {
322 /* Convert a named reference to the actual named object */ 321 /* Convert a named reference to the actual named object */
323 322
324 temp_node = obj_desc->reference.object; 323 temp_node = obj_desc->reference.object;
325 acpi_ut_remove_reference (obj_desc); 324 acpi_ut_remove_reference(obj_desc);
326 (*stack_ptr) = temp_node; 325 (*stack_ptr) = temp_node;
327 } 326 }
328 goto next_operand; 327 goto next_operand;
329 328
330 329 case ARGI_DATAREFOBJ: /* Store operator only */
331 case ARGI_DATAREFOBJ: /* Store operator only */
332 330
333 /* 331 /*
334 * We don't want to resolve index_op reference objects during 332 * We don't want to resolve index_op reference objects during
@@ -337,8 +335,10 @@ acpi_ex_resolve_operands (
337 * -- All others must be resolved below. 335 * -- All others must be resolved below.
338 */ 336 */
339 if ((opcode == AML_STORE_OP) && 337 if ((opcode == AML_STORE_OP) &&
340 (ACPI_GET_OBJECT_TYPE (*stack_ptr) == ACPI_TYPE_LOCAL_REFERENCE) && 338 (ACPI_GET_OBJECT_TYPE(*stack_ptr) ==
341 ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { 339 ACPI_TYPE_LOCAL_REFERENCE)
340 && ((*stack_ptr)->reference.opcode ==
341 AML_INDEX_OP)) {
342 goto next_operand; 342 goto next_operand;
343 } 343 }
344 break; 344 break;
@@ -351,9 +351,9 @@ acpi_ex_resolve_operands (
351 /* 351 /*
352 * Resolve this object to a value 352 * Resolve this object to a value
353 */ 353 */
354 status = acpi_ex_resolve_to_value (stack_ptr, walk_state); 354 status = acpi_ex_resolve_to_value(stack_ptr, walk_state);
355 if (ACPI_FAILURE (status)) { 355 if (ACPI_FAILURE(status)) {
356 return_ACPI_STATUS (status); 356 return_ACPI_STATUS(status);
357 } 357 }
358 358
359 /* Get the resolved object */ 359 /* Get the resolved object */
@@ -364,10 +364,10 @@ acpi_ex_resolve_operands (
364 * Check the resulting object (value) type 364 * Check the resulting object (value) type
365 */ 365 */
366 switch (this_arg_type) { 366 switch (this_arg_type) {
367 /* 367 /*
368 * For the simple cases, only one type of resolved object 368 * For the simple cases, only one type of resolved object
369 * is allowed 369 * is allowed
370 */ 370 */
371 case ARGI_MUTEX: 371 case ARGI_MUTEX:
372 372
373 /* Need an operand of type ACPI_TYPE_MUTEX */ 373 /* Need an operand of type ACPI_TYPE_MUTEX */
@@ -382,7 +382,7 @@ acpi_ex_resolve_operands (
382 type_needed = ACPI_TYPE_EVENT; 382 type_needed = ACPI_TYPE_EVENT;
383 break; 383 break;
384 384
385 case ARGI_PACKAGE: /* Package */ 385 case ARGI_PACKAGE: /* Package */
386 386
387 /* Need an operand of type ACPI_TYPE_PACKAGE */ 387 /* Need an operand of type ACPI_TYPE_PACKAGE */
388 388
@@ -403,10 +403,9 @@ acpi_ex_resolve_operands (
403 type_needed = ACPI_TYPE_LOCAL_REFERENCE; 403 type_needed = ACPI_TYPE_LOCAL_REFERENCE;
404 break; 404 break;
405 405
406 406 /*
407 /* 407 * The more complex cases allow multiple resolved object types
408 * The more complex cases allow multiple resolved object types 408 */
409 */
410 case ARGI_INTEGER: 409 case ARGI_INTEGER:
411 410
412 /* 411 /*
@@ -414,20 +413,26 @@ acpi_ex_resolve_operands (
414 * But we can implicitly convert from a STRING or BUFFER 413 * But we can implicitly convert from a STRING or BUFFER
415 * Aka - "Implicit Source Operand Conversion" 414 * Aka - "Implicit Source Operand Conversion"
416 */ 415 */
417 status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, 16); 416 status =
418 if (ACPI_FAILURE (status)) { 417 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
418 if (ACPI_FAILURE(status)) {
419 if (status == AE_TYPE) { 419 if (status == AE_TYPE) {
420 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 420 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
421 "Needed [Integer/String/Buffer], found [%s] %p\n", 421 "Needed [Integer/String/Buffer], found [%s] %p\n",
422 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 422 acpi_ut_get_object_type_name
423 (obj_desc),
424 obj_desc));
423 425
424 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 426 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
425 } 427 }
426 428
427 return_ACPI_STATUS (status); 429 return_ACPI_STATUS(status);
428 } 430 }
429 goto next_operand;
430 431
432 if (obj_desc != *stack_ptr) {
433 acpi_ut_remove_reference(obj_desc);
434 }
435 goto next_operand;
431 436
432 case ARGI_BUFFER: 437 case ARGI_BUFFER:
433 438
@@ -436,20 +441,25 @@ acpi_ex_resolve_operands (
436 * But we can implicitly convert from a STRING or INTEGER 441 * But we can implicitly convert from a STRING or INTEGER
437 * Aka - "Implicit Source Operand Conversion" 442 * Aka - "Implicit Source Operand Conversion"
438 */ 443 */
439 status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); 444 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
440 if (ACPI_FAILURE (status)) { 445 if (ACPI_FAILURE(status)) {
441 if (status == AE_TYPE) { 446 if (status == AE_TYPE) {
442 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 447 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
443 "Needed [Integer/String/Buffer], found [%s] %p\n", 448 "Needed [Integer/String/Buffer], found [%s] %p\n",
444 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 449 acpi_ut_get_object_type_name
450 (obj_desc),
451 obj_desc));
445 452
446 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 453 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
447 } 454 }
448 455
449 return_ACPI_STATUS (status); 456 return_ACPI_STATUS(status);
450 } 457 }
451 goto next_operand;
452 458
459 if (obj_desc != *stack_ptr) {
460 acpi_ut_remove_reference(obj_desc);
461 }
462 goto next_operand;
453 463
454 case ARGI_STRING: 464 case ARGI_STRING:
455 465
@@ -458,75 +468,86 @@ acpi_ex_resolve_operands (
458 * But we can implicitly convert from a BUFFER or INTEGER 468 * But we can implicitly convert from a BUFFER or INTEGER
459 * Aka - "Implicit Source Operand Conversion" 469 * Aka - "Implicit Source Operand Conversion"
460 */ 470 */
461 status = acpi_ex_convert_to_string (obj_desc, stack_ptr, 471 status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
462 ACPI_IMPLICIT_CONVERT_HEX); 472 ACPI_IMPLICIT_CONVERT_HEX);
463 if (ACPI_FAILURE (status)) { 473 if (ACPI_FAILURE(status)) {
464 if (status == AE_TYPE) { 474 if (status == AE_TYPE) {
465 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 475 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
466 "Needed [Integer/String/Buffer], found [%s] %p\n", 476 "Needed [Integer/String/Buffer], found [%s] %p\n",
467 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 477 acpi_ut_get_object_type_name
478 (obj_desc),
479 obj_desc));
468 480
469 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 481 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
470 } 482 }
471 483
472 return_ACPI_STATUS (status); 484 return_ACPI_STATUS(status);
473 } 485 }
474 goto next_operand;
475 486
487 if (obj_desc != *stack_ptr) {
488 acpi_ut_remove_reference(obj_desc);
489 }
490 goto next_operand;
476 491
477 case ARGI_COMPUTEDATA: 492 case ARGI_COMPUTEDATA:
478 493
479 /* Need an operand of type INTEGER, STRING or BUFFER */ 494 /* Need an operand of type INTEGER, STRING or BUFFER */
480 495
481 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 496 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
482 case ACPI_TYPE_INTEGER: 497 case ACPI_TYPE_INTEGER:
483 case ACPI_TYPE_STRING: 498 case ACPI_TYPE_STRING:
484 case ACPI_TYPE_BUFFER: 499 case ACPI_TYPE_BUFFER:
485 500
486 /* Valid operand */ 501 /* Valid operand */
487 break; 502 break;
488 503
489 default: 504 default:
490 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
491 "Needed [Integer/String/Buffer], found [%s] %p\n", 506 "Needed [Integer/String/Buffer], found [%s] %p\n",
492 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 507 acpi_ut_get_object_type_name
508 (obj_desc), obj_desc));
493 509
494 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 510 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
495 } 511 }
496 goto next_operand; 512 goto next_operand;
497 513
498
499 case ARGI_BUFFER_OR_STRING: 514 case ARGI_BUFFER_OR_STRING:
500 515
501 /* Need an operand of type STRING or BUFFER */ 516 /* Need an operand of type STRING or BUFFER */
502 517
503 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 518 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
504 case ACPI_TYPE_STRING: 519 case ACPI_TYPE_STRING:
505 case ACPI_TYPE_BUFFER: 520 case ACPI_TYPE_BUFFER:
506 521
507 /* Valid operand */ 522 /* Valid operand */
508 break; 523 break;
509 524
510 case ACPI_TYPE_INTEGER: 525 case ACPI_TYPE_INTEGER:
511 526
512 /* Highest priority conversion is to type Buffer */ 527 /* Highest priority conversion is to type Buffer */
513 528
514 status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); 529 status =
515 if (ACPI_FAILURE (status)) { 530 acpi_ex_convert_to_buffer(obj_desc,
516 return_ACPI_STATUS (status); 531 stack_ptr);
532 if (ACPI_FAILURE(status)) {
533 return_ACPI_STATUS(status);
534 }
535
536 if (obj_desc != *stack_ptr) {
537 acpi_ut_remove_reference(obj_desc);
517 } 538 }
518 break; 539 break;
519 540
520 default: 541 default:
521 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 542 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
522 "Needed [Integer/String/Buffer], found [%s] %p\n", 543 "Needed [Integer/String/Buffer], found [%s] %p\n",
523 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 544 acpi_ut_get_object_type_name
545 (obj_desc), obj_desc));
524 546
525 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 547 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
526 } 548 }
527 goto next_operand; 549 goto next_operand;
528 550
529
530 case ARGI_DATAOBJECT: 551 case ARGI_DATAOBJECT:
531 /* 552 /*
532 * ARGI_DATAOBJECT is only used by the size_of operator. 553 * ARGI_DATAOBJECT is only used by the size_of operator.
@@ -535,7 +556,7 @@ acpi_ex_resolve_operands (
535 * The only reference allowed here is a direct reference to 556 * The only reference allowed here is a direct reference to
536 * a namespace node. 557 * a namespace node.
537 */ 558 */
538 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 559 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
539 case ACPI_TYPE_PACKAGE: 560 case ACPI_TYPE_PACKAGE:
540 case ACPI_TYPE_STRING: 561 case ACPI_TYPE_STRING:
541 case ACPI_TYPE_BUFFER: 562 case ACPI_TYPE_BUFFER:
@@ -545,20 +566,20 @@ acpi_ex_resolve_operands (
545 break; 566 break;
546 567
547 default: 568 default:
548 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 569 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
549 "Needed [Buffer/String/Package/Reference], found [%s] %p\n", 570 "Needed [Buffer/String/Package/Reference], found [%s] %p\n",
550 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 571 acpi_ut_get_object_type_name
572 (obj_desc), obj_desc));
551 573
552 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 574 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
553 } 575 }
554 goto next_operand; 576 goto next_operand;
555 577
556
557 case ARGI_COMPLEXOBJ: 578 case ARGI_COMPLEXOBJ:
558 579
559 /* Need a buffer or package or (ACPI 2.0) String */ 580 /* Need a buffer or package or (ACPI 2.0) String */
560 581
561 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 582 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
562 case ACPI_TYPE_PACKAGE: 583 case ACPI_TYPE_PACKAGE:
563 case ACPI_TYPE_STRING: 584 case ACPI_TYPE_STRING:
564 case ACPI_TYPE_BUFFER: 585 case ACPI_TYPE_BUFFER:
@@ -567,20 +588,20 @@ acpi_ex_resolve_operands (
567 break; 588 break;
568 589
569 default: 590 default:
570 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 591 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
571 "Needed [Buffer/String/Package], found [%s] %p\n", 592 "Needed [Buffer/String/Package], found [%s] %p\n",
572 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 593 acpi_ut_get_object_type_name
594 (obj_desc), obj_desc));
573 595
574 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 596 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
575 } 597 }
576 goto next_operand; 598 goto next_operand;
577 599
578
579 case ARGI_REGION_OR_FIELD: 600 case ARGI_REGION_OR_FIELD:
580 601
581 /* Need an operand of type REGION or a FIELD in a region */ 602 /* Need an operand of type REGION or a FIELD in a region */
582 603
583 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 604 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
584 case ACPI_TYPE_REGION: 605 case ACPI_TYPE_REGION:
585 case ACPI_TYPE_LOCAL_REGION_FIELD: 606 case ACPI_TYPE_LOCAL_REGION_FIELD:
586 case ACPI_TYPE_LOCAL_BANK_FIELD: 607 case ACPI_TYPE_LOCAL_BANK_FIELD:
@@ -590,20 +611,20 @@ acpi_ex_resolve_operands (
590 break; 611 break;
591 612
592 default: 613 default:
593 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
594 "Needed [Region/region_field], found [%s] %p\n", 615 "Needed [Region/region_field], found [%s] %p\n",
595 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 616 acpi_ut_get_object_type_name
617 (obj_desc), obj_desc));
596 618
597 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 619 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
598 } 620 }
599 goto next_operand; 621 goto next_operand;
600 622
601
602 case ARGI_DATAREFOBJ: 623 case ARGI_DATAREFOBJ:
603 624
604 /* Used by the Store() operator only */ 625 /* Used by the Store() operator only */
605 626
606 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 627 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
607 case ACPI_TYPE_INTEGER: 628 case ACPI_TYPE_INTEGER:
608 case ACPI_TYPE_PACKAGE: 629 case ACPI_TYPE_PACKAGE:
609 case ACPI_TYPE_STRING: 630 case ACPI_TYPE_STRING:
@@ -635,47 +656,46 @@ acpi_ex_resolve_operands (
635 break; 656 break;
636 } 657 }
637 658
638 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 659 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
639 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", 660 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
640 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 661 acpi_ut_get_object_type_name
662 (obj_desc), obj_desc));
641 663
642 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 664 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
643 } 665 }
644 goto next_operand; 666 goto next_operand;
645 667
646
647 default: 668 default:
648 669
649 /* Unknown type */ 670 /* Unknown type */
650 671
651 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
652 "Internal - Unknown ARGI (required operand) type %X\n", 673 "Internal - Unknown ARGI (required operand) type %X\n",
653 this_arg_type)); 674 this_arg_type));
654 675
655 return_ACPI_STATUS (AE_BAD_PARAMETER); 676 return_ACPI_STATUS(AE_BAD_PARAMETER);
656 } 677 }
657 678
658 /* 679 /*
659 * Make sure that the original object was resolved to the 680 * Make sure that the original object was resolved to the
660 * required object type (Simple cases only). 681 * required object type (Simple cases only).
661 */ 682 */
662 status = acpi_ex_check_object_type (type_needed, 683 status = acpi_ex_check_object_type(type_needed,
663 ACPI_GET_OBJECT_TYPE (*stack_ptr), *stack_ptr); 684 ACPI_GET_OBJECT_TYPE
664 if (ACPI_FAILURE (status)) { 685 (*stack_ptr), *stack_ptr);
665 return_ACPI_STATUS (status); 686 if (ACPI_FAILURE(status)) {
687 return_ACPI_STATUS(status);
666 } 688 }
667 689
668next_operand: 690 next_operand:
669 /* 691 /*
670 * If more operands needed, decrement stack_ptr to point 692 * If more operands needed, decrement stack_ptr to point
671 * to next operand on stack 693 * to next operand on stack
672 */ 694 */
673 if (GET_CURRENT_ARG_TYPE (arg_types)) { 695 if (GET_CURRENT_ARG_TYPE(arg_types)) {
674 stack_ptr--; 696 stack_ptr--;
675 } 697 }
676 } 698 }
677 699
678 return_ACPI_STATUS (status); 700 return_ACPI_STATUS(status);
679} 701}
680
681
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 2725db0901b8..a7d8eea305c2 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
@@ -50,24 +49,18 @@
50#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
51#include <acpi/acparser.h> 50#include <acpi/acparser.h>
52 51
53
54#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exstore") 53ACPI_MODULE_NAME("exstore")
56 54
57/* Local prototypes */ 55/* Local prototypes */
58
59static void 56static void
60acpi_ex_do_debug_object ( 57acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
61 union acpi_operand_object *source_desc, 58 u32 level, u32 index);
62 u32 level,
63 u32 index);
64 59
65static acpi_status 60static acpi_status
66acpi_ex_store_object_to_index ( 61acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
67 union acpi_operand_object *val_desc, 62 union acpi_operand_object *dest_desc,
68 union acpi_operand_object *dest_desc, 63 struct acpi_walk_state *walk_state);
69 struct acpi_walk_state *walk_state);
70
71 64
72/******************************************************************************* 65/*******************************************************************************
73 * 66 *
@@ -84,136 +77,146 @@ acpi_ex_store_object_to_index (
84 ******************************************************************************/ 77 ******************************************************************************/
85 78
86static void 79static void
87acpi_ex_do_debug_object ( 80acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
88 union acpi_operand_object *source_desc, 81 u32 level, u32 index)
89 u32 level,
90 u32 index)
91{ 82{
92 u32 i; 83 u32 i;
93
94 84
95 ACPI_FUNCTION_TRACE_PTR ("ex_do_debug_object", source_desc); 85 ACPI_FUNCTION_TRACE_PTR("ex_do_debug_object", source_desc);
96 86
97 87 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
98 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", 88 level, " "));
99 level, " "));
100 89
101 /* Display index for package output only */ 90 /* Display index for package output only */
102 91
103 if (index > 0) { 92 if (index > 0) {
104 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 93 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
105 "(%.2u) ", index -1)); 94 "(%.2u) ", index - 1));
106 } 95 }
107 96
108 if (!source_desc) { 97 if (!source_desc) {
109 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n")); 98 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n"));
110 return_VOID; 99 return_VOID;
111 } 100 }
112 101
113 if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_OPERAND) { 102 if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
114 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ", 103 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: ",
115 acpi_ut_get_object_type_name (source_desc))); 104 acpi_ut_get_object_type_name
105 (source_desc)));
116 106
117 if (!acpi_ut_valid_internal_object (source_desc)) { 107 if (!acpi_ut_valid_internal_object(source_desc)) {
118 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 108 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
119 "%p, Invalid Internal Object!\n", source_desc)); 109 "%p, Invalid Internal Object!\n",
120 return_VOID; 110 source_desc));
111 return_VOID;
121 } 112 }
122 } 113 } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
123 else if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_NAMED) { 114 ACPI_DESC_TYPE_NAMED) {
124 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", 115 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
125 acpi_ut_get_type_name (((struct acpi_namespace_node *) source_desc)->type), 116 acpi_ut_get_type_name(((struct
126 source_desc)); 117 acpi_namespace_node
118 *)source_desc)->
119 type),
120 source_desc));
127 return_VOID; 121 return_VOID;
128 } 122 } else {
129 else {
130 return_VOID; 123 return_VOID;
131 } 124 }
132 125
133 switch (ACPI_GET_OBJECT_TYPE (source_desc)) { 126 switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
134 case ACPI_TYPE_INTEGER: 127 case ACPI_TYPE_INTEGER:
135 128
136 /* Output correct integer width */ 129 /* Output correct integer width */
137 130
138 if (acpi_gbl_integer_byte_width == 4) { 131 if (acpi_gbl_integer_byte_width == 4) {
139 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", 132 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
140 (u32) source_desc->integer.value)); 133 (u32) source_desc->integer.
141 } 134 value));
142 else { 135 } else {
143 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", 136 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
144 ACPI_FORMAT_UINT64 (source_desc->integer.value))); 137 "0x%8.8X%8.8X\n",
138 ACPI_FORMAT_UINT64(source_desc->
139 integer.
140 value)));
145 } 141 }
146 break; 142 break;
147 143
148 case ACPI_TYPE_BUFFER: 144 case ACPI_TYPE_BUFFER:
149 145
150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", 146 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
151 (u32) source_desc->buffer.length)); 147 (u32) source_desc->buffer.length));
152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer, 148 ACPI_DUMP_BUFFER(source_desc->buffer.pointer,
153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); 149 (source_desc->buffer.length <
150 32) ? source_desc->buffer.length : 32);
154 break; 151 break;
155 152
156 case ACPI_TYPE_STRING: 153 case ACPI_TYPE_STRING:
157 154
158 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", 155 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
159 source_desc->string.length, source_desc->string.pointer)); 156 source_desc->string.length,
157 source_desc->string.pointer));
160 break; 158 break;
161 159
162 case ACPI_TYPE_PACKAGE: 160 case ACPI_TYPE_PACKAGE:
163 161
164 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n", 162 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
165 source_desc->package.count)); 163 "[0x%.2X Elements]\n",
164 source_desc->package.count));
166 165
167 /* Output the entire contents of the package */ 166 /* Output the entire contents of the package */
168 167
169 for (i = 0; i < source_desc->package.count; i++) { 168 for (i = 0; i < source_desc->package.count; i++) {
170 acpi_ex_do_debug_object (source_desc->package.elements[i], 169 acpi_ex_do_debug_object(source_desc->package.
171 level+4, i+1); 170 elements[i], level + 4, i + 1);
172 } 171 }
173 break; 172 break;
174 173
175 case ACPI_TYPE_LOCAL_REFERENCE: 174 case ACPI_TYPE_LOCAL_REFERENCE:
176 175
177 if (source_desc->reference.opcode == AML_INDEX_OP) { 176 if (source_desc->reference.opcode == AML_INDEX_OP) {
178 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", 177 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
179 acpi_ps_get_opcode_name (source_desc->reference.opcode), 178 "[%s, 0x%X]\n",
180 source_desc->reference.offset)); 179 acpi_ps_get_opcode_name
180 (source_desc->reference.opcode),
181 source_desc->reference.offset));
182 } else {
183 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
184 acpi_ps_get_opcode_name
185 (source_desc->reference.opcode)));
181 } 186 }
182 else {
183 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
184 acpi_ps_get_opcode_name (source_desc->reference.opcode)));
185 }
186
187 187
188 if (source_desc->reference.object) { 188 if (source_desc->reference.object) {
189 if (ACPI_GET_DESCRIPTOR_TYPE (source_desc->reference.object) == 189 if (ACPI_GET_DESCRIPTOR_TYPE
190 ACPI_DESC_TYPE_NAMED) { 190 (source_desc->reference.object) ==
191 acpi_ex_do_debug_object (((struct acpi_namespace_node *) 191 ACPI_DESC_TYPE_NAMED) {
192 source_desc->reference.object)->object, 192 acpi_ex_do_debug_object(((struct
193 level+4, 0); 193 acpi_namespace_node *)
194 source_desc->reference.
195 object)->object,
196 level + 4, 0);
197 } else {
198 acpi_ex_do_debug_object(source_desc->reference.
199 object, level + 4, 0);
194 } 200 }
195 else { 201 } else if (source_desc->reference.node) {
196 acpi_ex_do_debug_object (source_desc->reference.object, level+4, 0); 202 acpi_ex_do_debug_object((source_desc->reference.node)->
197 } 203 object, level + 4, 0);
198 }
199 else if (source_desc->reference.node) {
200 acpi_ex_do_debug_object ((source_desc->reference.node)->object,
201 level+4, 0);
202 } 204 }
203 break; 205 break;
204 206
205 default: 207 default:
206 208
207 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n", 209 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p %s\n",
208 source_desc, acpi_ut_get_object_type_name (source_desc))); 210 source_desc,
211 acpi_ut_get_object_type_name
212 (source_desc)));
209 break; 213 break;
210 } 214 }
211 215
212 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); 216 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
213 return_VOID; 217 return_VOID;
214} 218}
215 219
216
217/******************************************************************************* 220/*******************************************************************************
218 * 221 *
219 * FUNCTION: acpi_ex_store 222 * FUNCTION: acpi_ex_store
@@ -235,42 +238,41 @@ acpi_ex_do_debug_object (
235 ******************************************************************************/ 238 ******************************************************************************/
236 239
237acpi_status 240acpi_status
238acpi_ex_store ( 241acpi_ex_store(union acpi_operand_object *source_desc,
239 union acpi_operand_object *source_desc, 242 union acpi_operand_object *dest_desc,
240 union acpi_operand_object *dest_desc, 243 struct acpi_walk_state *walk_state)
241 struct acpi_walk_state *walk_state)
242{ 244{
243 acpi_status status = AE_OK; 245 acpi_status status = AE_OK;
244 union acpi_operand_object *ref_desc = dest_desc; 246 union acpi_operand_object *ref_desc = dest_desc;
245
246
247 ACPI_FUNCTION_TRACE_PTR ("ex_store", dest_desc);
248 247
248 ACPI_FUNCTION_TRACE_PTR("ex_store", dest_desc);
249 249
250 /* Validate parameters */ 250 /* Validate parameters */
251 251
252 if (!source_desc || !dest_desc) { 252 if (!source_desc || !dest_desc) {
253 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); 253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n"));
254 return_ACPI_STATUS (AE_AML_NO_OPERAND); 254 return_ACPI_STATUS(AE_AML_NO_OPERAND);
255 } 255 }
256 256
257 /* dest_desc can be either a namespace node or an ACPI object */ 257 /* dest_desc can be either a namespace node or an ACPI object */
258 258
259 if (ACPI_GET_DESCRIPTOR_TYPE (dest_desc) == ACPI_DESC_TYPE_NAMED) { 259 if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) {
260 /* 260 /*
261 * Dest is a namespace node, 261 * Dest is a namespace node,
262 * Storing an object into a Named node. 262 * Storing an object into a Named node.
263 */ 263 */
264 status = acpi_ex_store_object_to_node (source_desc, 264 status = acpi_ex_store_object_to_node(source_desc,
265 (struct acpi_namespace_node *) dest_desc, walk_state, 265 (struct
266 ACPI_IMPLICIT_CONVERSION); 266 acpi_namespace_node *)
267 dest_desc, walk_state,
268 ACPI_IMPLICIT_CONVERSION);
267 269
268 return_ACPI_STATUS (status); 270 return_ACPI_STATUS(status);
269 } 271 }
270 272
271 /* Destination object must be a Reference or a Constant object */ 273 /* Destination object must be a Reference or a Constant object */
272 274
273 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 275 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
274 case ACPI_TYPE_LOCAL_REFERENCE: 276 case ACPI_TYPE_LOCAL_REFERENCE:
275 break; 277 break;
276 278
@@ -279,7 +281,7 @@ acpi_ex_store (
279 /* Allow stores to Constants -- a Noop as per ACPI spec */ 281 /* Allow stores to Constants -- a Noop as per ACPI spec */
280 282
281 if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) { 283 if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
282 return_ACPI_STATUS (AE_OK); 284 return_ACPI_STATUS(AE_OK);
283 } 285 }
284 286
285 /*lint -fallthrough */ 287 /*lint -fallthrough */
@@ -288,16 +290,18 @@ acpi_ex_store (
288 290
289 /* Destination is not a Reference object */ 291 /* Destination is not a Reference object */
290 292
291 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
292 "Target is not a Reference or Constant object - %s [%p]\n", 294 "Target is not a Reference or Constant object - %s [%p]\n",
293 acpi_ut_get_object_type_name (dest_desc), dest_desc)); 295 acpi_ut_get_object_type_name(dest_desc),
296 dest_desc));
294 297
295 ACPI_DUMP_STACK_ENTRY (source_desc); 298 ACPI_DUMP_STACK_ENTRY(source_desc);
296 ACPI_DUMP_STACK_ENTRY (dest_desc); 299 ACPI_DUMP_STACK_ENTRY(dest_desc);
297 ACPI_DUMP_OPERANDS (&dest_desc, ACPI_IMODE_EXECUTE, "ex_store", 300 ACPI_DUMP_OPERANDS(&dest_desc, ACPI_IMODE_EXECUTE, "ex_store",
298 2, "Target is not a Reference or Constant object"); 301 2,
302 "Target is not a Reference or Constant object");
299 303
300 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 304 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
301 } 305 }
302 306
303 /* 307 /*
@@ -314,58 +318,59 @@ acpi_ex_store (
314 318
315 /* Storing an object into a Name "container" */ 319 /* Storing an object into a Name "container" */
316 320
317 status = acpi_ex_store_object_to_node (source_desc, 321 status = acpi_ex_store_object_to_node(source_desc,
318 ref_desc->reference.object, 322 ref_desc->reference.
319 walk_state, ACPI_IMPLICIT_CONVERSION); 323 object, walk_state,
324 ACPI_IMPLICIT_CONVERSION);
320 break; 325 break;
321 326
322
323 case AML_INDEX_OP: 327 case AML_INDEX_OP:
324 328
325 /* Storing to an Index (pointer into a packager or buffer) */ 329 /* Storing to an Index (pointer into a packager or buffer) */
326 330
327 status = acpi_ex_store_object_to_index (source_desc, ref_desc, walk_state); 331 status =
332 acpi_ex_store_object_to_index(source_desc, ref_desc,
333 walk_state);
328 break; 334 break;
329 335
330
331 case AML_LOCAL_OP: 336 case AML_LOCAL_OP:
332 case AML_ARG_OP: 337 case AML_ARG_OP:
333 338
334 /* Store to a method local/arg */ 339 /* Store to a method local/arg */
335 340
336 status = acpi_ds_store_object_to_local (ref_desc->reference.opcode, 341 status =
337 ref_desc->reference.offset, source_desc, walk_state); 342 acpi_ds_store_object_to_local(ref_desc->reference.opcode,
343 ref_desc->reference.offset,
344 source_desc, walk_state);
338 break; 345 break;
339 346
340
341 case AML_DEBUG_OP: 347 case AML_DEBUG_OP:
342 348
343 /* 349 /*
344 * Storing to the Debug object causes the value stored to be 350 * Storing to the Debug object causes the value stored to be
345 * displayed and otherwise has no effect -- see ACPI Specification 351 * displayed and otherwise has no effect -- see ACPI Specification
346 */ 352 */
347 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 353 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
348 "**** Write to Debug Object: Object %p %s ****:\n\n", 354 "**** Write to Debug Object: Object %p %s ****:\n\n",
349 source_desc, acpi_ut_get_object_type_name (source_desc))); 355 source_desc,
356 acpi_ut_get_object_type_name(source_desc)));
350 357
351 acpi_ex_do_debug_object (source_desc, 0, 0); 358 acpi_ex_do_debug_object(source_desc, 0, 0);
352 break; 359 break;
353 360
354
355 default: 361 default:
356 362
357 ACPI_REPORT_ERROR (("ex_store: Unknown Reference opcode %X\n", 363 ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n",
358 ref_desc->reference.opcode)); 364 ref_desc->reference.opcode));
359 ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR); 365 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
360 366
361 status = AE_AML_INTERNAL; 367 status = AE_AML_INTERNAL;
362 break; 368 break;
363 } 369 }
364 370
365 return_ACPI_STATUS (status); 371 return_ACPI_STATUS(status);
366} 372}
367 373
368
369/******************************************************************************* 374/*******************************************************************************
370 * 375 *
371 * FUNCTION: acpi_ex_store_object_to_index 376 * FUNCTION: acpi_ex_store_object_to_index
@@ -381,20 +386,17 @@ acpi_ex_store (
381 ******************************************************************************/ 386 ******************************************************************************/
382 387
383static acpi_status 388static acpi_status
384acpi_ex_store_object_to_index ( 389acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
385 union acpi_operand_object *source_desc, 390 union acpi_operand_object *index_desc,
386 union acpi_operand_object *index_desc, 391 struct acpi_walk_state *walk_state)
387 struct acpi_walk_state *walk_state)
388{ 392{
389 acpi_status status = AE_OK; 393 acpi_status status = AE_OK;
390 union acpi_operand_object *obj_desc; 394 union acpi_operand_object *obj_desc;
391 union acpi_operand_object *new_desc; 395 union acpi_operand_object *new_desc;
392 u8 value = 0; 396 u8 value = 0;
393 u32 i; 397 u32 i;
394
395
396 ACPI_FUNCTION_TRACE ("ex_store_object_to_index");
397 398
399 ACPI_FUNCTION_TRACE("ex_store_object_to_index");
398 400
399 /* 401 /*
400 * Destination must be a reference pointer, and 402 * Destination must be a reference pointer, and
@@ -413,19 +415,20 @@ acpi_ex_store_object_to_index (
413 */ 415 */
414 obj_desc = *(index_desc->reference.where); 416 obj_desc = *(index_desc->reference.where);
415 417
416 status = acpi_ut_copy_iobject_to_iobject (source_desc, &new_desc, walk_state); 418 status =
417 if (ACPI_FAILURE (status)) { 419 acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
418 return_ACPI_STATUS (status); 420 walk_state);
421 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status);
419 } 423 }
420 424
421 if (obj_desc) { 425 if (obj_desc) {
422 /* Decrement reference count by the ref count of the parent package */ 426 /* Decrement reference count by the ref count of the parent package */
423 427
424 for (i = 0; 428 for (i = 0; i < ((union acpi_operand_object *)
425 i < ((union acpi_operand_object *) 429 index_desc->reference.object)->common.
426 index_desc->reference.object)->common.reference_count; 430 reference_count; i++) {
427 i++) { 431 acpi_ut_remove_reference(obj_desc);
428 acpi_ut_remove_reference (obj_desc);
429 } 432 }
430 } 433 }
431 434
@@ -433,16 +436,14 @@ acpi_ex_store_object_to_index (
433 436
434 /* Increment ref count by the ref count of the parent package-1 */ 437 /* Increment ref count by the ref count of the parent package-1 */
435 438
436 for (i = 1; 439 for (i = 1; i < ((union acpi_operand_object *)
437 i < ((union acpi_operand_object *) 440 index_desc->reference.object)->common.
438 index_desc->reference.object)->common.reference_count; 441 reference_count; i++) {
439 i++) { 442 acpi_ut_add_reference(new_desc);
440 acpi_ut_add_reference (new_desc);
441 } 443 }
442 444
443 break; 445 break;
444 446
445
446 case ACPI_TYPE_BUFFER_FIELD: 447 case ACPI_TYPE_BUFFER_FIELD:
447 448
448 /* 449 /*
@@ -460,16 +461,16 @@ acpi_ex_store_object_to_index (
460 * by the INDEX_OP code. 461 * by the INDEX_OP code.
461 */ 462 */
462 obj_desc = index_desc->reference.object; 463 obj_desc = index_desc->reference.object;
463 if ((ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_BUFFER) && 464 if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) &&
464 (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_STRING)) { 465 (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) {
465 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 466 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
466 } 467 }
467 468
468 /* 469 /*
469 * The assignment of the individual elements will be slightly 470 * The assignment of the individual elements will be slightly
470 * different for each source type. 471 * different for each source type.
471 */ 472 */
472 switch (ACPI_GET_OBJECT_TYPE (source_desc)) { 473 switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
473 case ACPI_TYPE_INTEGER: 474 case ACPI_TYPE_INTEGER:
474 475
475 /* Use the least-significant byte of the integer */ 476 /* Use the least-significant byte of the integer */
@@ -489,10 +490,11 @@ acpi_ex_store_object_to_index (
489 490
490 /* All other types are invalid */ 491 /* All other types are invalid */
491 492
492 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 493 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
493 "Source must be Integer/Buffer/String type, not %s\n", 494 "Source must be Integer/Buffer/String type, not %s\n",
494 acpi_ut_get_object_type_name (source_desc))); 495 acpi_ut_get_object_type_name
495 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 496 (source_desc)));
497 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
496 } 498 }
497 499
498 /* Store the source value into the target buffer byte */ 500 /* Store the source value into the target buffer byte */
@@ -500,18 +502,16 @@ acpi_ex_store_object_to_index (
500 obj_desc->buffer.pointer[index_desc->reference.offset] = value; 502 obj_desc->buffer.pointer[index_desc->reference.offset] = value;
501 break; 503 break;
502 504
503
504 default: 505 default:
505 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
506 "Target is not a Package or buffer_field\n")); 507 "Target is not a Package or buffer_field\n"));
507 status = AE_AML_OPERAND_TYPE; 508 status = AE_AML_OPERAND_TYPE;
508 break; 509 break;
509 } 510 }
510 511
511 return_ACPI_STATUS (status); 512 return_ACPI_STATUS(status);
512} 513}
513 514
514
515/******************************************************************************* 515/*******************************************************************************
516 * 516 *
517 * FUNCTION: acpi_ex_store_object_to_node 517 * FUNCTION: acpi_ex_store_object_to_node
@@ -539,42 +539,40 @@ acpi_ex_store_object_to_index (
539 ******************************************************************************/ 539 ******************************************************************************/
540 540
541acpi_status 541acpi_status
542acpi_ex_store_object_to_node ( 542acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
543 union acpi_operand_object *source_desc, 543 struct acpi_namespace_node *node,
544 struct acpi_namespace_node *node, 544 struct acpi_walk_state *walk_state,
545 struct acpi_walk_state *walk_state, 545 u8 implicit_conversion)
546 u8 implicit_conversion)
547{ 546{
548 acpi_status status = AE_OK; 547 acpi_status status = AE_OK;
549 union acpi_operand_object *target_desc; 548 union acpi_operand_object *target_desc;
550 union acpi_operand_object *new_desc; 549 union acpi_operand_object *new_desc;
551 acpi_object_type target_type; 550 acpi_object_type target_type;
552
553
554 ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc);
555 551
552 ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_node", source_desc);
556 553
557 /* Get current type of the node, and object attached to Node */ 554 /* Get current type of the node, and object attached to Node */
558 555
559 target_type = acpi_ns_get_type (node); 556 target_type = acpi_ns_get_type(node);
560 target_desc = acpi_ns_get_attached_object (node); 557 target_desc = acpi_ns_get_attached_object(node);
561 558
562 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 559 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
563 source_desc, acpi_ut_get_object_type_name (source_desc), 560 source_desc,
564 node, acpi_ut_get_type_name (target_type))); 561 acpi_ut_get_object_type_name(source_desc), node,
562 acpi_ut_get_type_name(target_type)));
565 563
566 /* 564 /*
567 * Resolve the source object to an actual value 565 * Resolve the source object to an actual value
568 * (If it is a reference object) 566 * (If it is a reference object)
569 */ 567 */
570 status = acpi_ex_resolve_object (&source_desc, target_type, walk_state); 568 status = acpi_ex_resolve_object(&source_desc, target_type, walk_state);
571 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS (status); 570 return_ACPI_STATUS(status);
573 } 571 }
574 572
575 /* If no implicit conversion, drop into the default case below */ 573 /* If no implicit conversion, drop into the default case below */
576 574
577 if (!implicit_conversion) { 575 if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) {
578 /* Force execution of default (no implicit conversion) */ 576 /* Force execution of default (no implicit conversion) */
579 577
580 target_type = ACPI_TYPE_ANY; 578 target_type = ACPI_TYPE_ANY;
@@ -590,11 +588,10 @@ acpi_ex_store_object_to_node (
590 588
591 /* For fields, copy the source data to the target field. */ 589 /* For fields, copy the source data to the target field. */
592 590
593 status = acpi_ex_write_data_to_field (source_desc, target_desc, 591 status = acpi_ex_write_data_to_field(source_desc, target_desc,
594 &walk_state->result_obj); 592 &walk_state->result_obj);
595 break; 593 break;
596 594
597
598 case ACPI_TYPE_INTEGER: 595 case ACPI_TYPE_INTEGER:
599 case ACPI_TYPE_STRING: 596 case ACPI_TYPE_STRING:
600 case ACPI_TYPE_BUFFER: 597 case ACPI_TYPE_BUFFER:
@@ -605,10 +602,11 @@ acpi_ex_store_object_to_node (
605 * 602 *
606 * Copy and/or convert the source object to a new target object 603 * Copy and/or convert the source object to a new target object
607 */ 604 */
608 status = acpi_ex_store_object_to_object (source_desc, target_desc, 605 status =
609 &new_desc, walk_state); 606 acpi_ex_store_object_to_object(source_desc, target_desc,
610 if (ACPI_FAILURE (status)) { 607 &new_desc, walk_state);
611 return_ACPI_STATUS (status); 608 if (ACPI_FAILURE(status)) {
609 return_ACPI_STATUS(status);
612 } 610 }
613 611
614 if (new_desc != target_desc) { 612 if (new_desc != target_desc) {
@@ -621,30 +619,33 @@ acpi_ex_store_object_to_node (
621 * has been performed such that the node/object type has been 619 * has been performed such that the node/object type has been
622 * changed. 620 * changed.
623 */ 621 */
624 status = acpi_ns_attach_object (node, new_desc, new_desc->common.type); 622 status =
625 623 acpi_ns_attach_object(node, new_desc,
626 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 624 new_desc->common.type);
627 "Store %s into %s via Convert/Attach\n", 625
628 acpi_ut_get_object_type_name (source_desc), 626 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
629 acpi_ut_get_object_type_name (new_desc))); 627 "Store %s into %s via Convert/Attach\n",
628 acpi_ut_get_object_type_name
629 (source_desc),
630 acpi_ut_get_object_type_name
631 (new_desc)));
630 } 632 }
631 break; 633 break;
632 634
633
634 default: 635 default:
635 636
636 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 637 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
637 "Storing %s (%p) directly into node (%p), no implicit conversion\n", 638 "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
638 acpi_ut_get_object_type_name (source_desc), source_desc, node)); 639 acpi_ut_get_object_type_name(source_desc),
640 source_desc, node));
639 641
640 /* No conversions for all other types. Just attach the source object */ 642 /* No conversions for all other types. Just attach the source object */
641 643
642 status = acpi_ns_attach_object (node, source_desc, 644 status = acpi_ns_attach_object(node, source_desc,
643 ACPI_GET_OBJECT_TYPE (source_desc)); 645 ACPI_GET_OBJECT_TYPE
646 (source_desc));
644 break; 647 break;
645 } 648 }
646 649
647 return_ACPI_STATUS (status); 650 return_ACPI_STATUS(status);
648} 651}
649
650
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index 120f30ed0bd4..382f63c14ea1 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -43,15 +43,12 @@
43 * POSSIBILITY OF SUCH DAMAGES. 43 * POSSIBILITY OF SUCH DAMAGES.
44 */ 44 */
45 45
46
47#include <acpi/acpi.h> 46#include <acpi/acpi.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exstoren") 51ACPI_MODULE_NAME("exstoren")
54
55 52
56/******************************************************************************* 53/*******************************************************************************
57 * 54 *
@@ -67,19 +64,15 @@
67 * it and return the actual object in the source_desc_ptr. 64 * it and return the actual object in the source_desc_ptr.
68 * 65 *
69 ******************************************************************************/ 66 ******************************************************************************/
70
71acpi_status 67acpi_status
72acpi_ex_resolve_object ( 68acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
73 union acpi_operand_object **source_desc_ptr, 69 acpi_object_type target_type,
74 acpi_object_type target_type, 70 struct acpi_walk_state *walk_state)
75 struct acpi_walk_state *walk_state)
76{ 71{
77 union acpi_operand_object *source_desc = *source_desc_ptr; 72 union acpi_operand_object *source_desc = *source_desc_ptr;
78 acpi_status status = AE_OK; 73 acpi_status status = AE_OK;
79
80
81 ACPI_FUNCTION_TRACE ("ex_resolve_object");
82 74
75 ACPI_FUNCTION_TRACE("ex_resolve_object");
83 76
84 /* Ensure we have a Target that can be stored to */ 77 /* Ensure we have a Target that can be stored to */
85 78
@@ -102,11 +95,14 @@ acpi_ex_resolve_object (
102 * are all essentially the same. This case handles the 95 * are all essentially the same. This case handles the
103 * "interchangeable" types Integer, String, and Buffer. 96 * "interchangeable" types Integer, String, and Buffer.
104 */ 97 */
105 if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) { 98 if (ACPI_GET_OBJECT_TYPE(source_desc) ==
99 ACPI_TYPE_LOCAL_REFERENCE) {
106 /* Resolve a reference object first */ 100 /* Resolve a reference object first */
107 101
108 status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state); 102 status =
109 if (ACPI_FAILURE (status)) { 103 acpi_ex_resolve_to_value(source_desc_ptr,
104 walk_state);
105 if (ACPI_FAILURE(status)) {
110 break; 106 break;
111 } 107 }
112 } 108 }
@@ -119,31 +115,32 @@ acpi_ex_resolve_object (
119 115
120 /* Must have a Integer, Buffer, or String */ 116 /* Must have a Integer, Buffer, or String */
121 117
122 if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) && 118 if ((ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) &&
123 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) && 119 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) &&
124 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) && 120 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) &&
125 !((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) { 121 !((ACPI_GET_OBJECT_TYPE(source_desc) ==
122 ACPI_TYPE_LOCAL_REFERENCE)
123 && (source_desc->reference.opcode == AML_LOAD_OP))) {
126 /* Conversion successful but still not a valid type */ 124 /* Conversion successful but still not a valid type */
127 125
128 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
129 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 127 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
130 acpi_ut_get_object_type_name (source_desc), 128 acpi_ut_get_object_type_name
131 acpi_ut_get_type_name (target_type))); 129 (source_desc),
130 acpi_ut_get_type_name(target_type)));
132 status = AE_AML_OPERAND_TYPE; 131 status = AE_AML_OPERAND_TYPE;
133 } 132 }
134 break; 133 break;
135 134
136
137 case ACPI_TYPE_LOCAL_ALIAS: 135 case ACPI_TYPE_LOCAL_ALIAS:
138 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 136 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
139 137
140 /* Aliases are resolved by acpi_ex_prep_operands */ 138 /* Aliases are resolved by acpi_ex_prep_operands */
141 139
142 ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); 140 ACPI_REPORT_ERROR(("Store into Alias - should never happen\n"));
143 status = AE_AML_INTERNAL; 141 status = AE_AML_INTERNAL;
144 break; 142 break;
145 143
146
147 case ACPI_TYPE_PACKAGE: 144 case ACPI_TYPE_PACKAGE:
148 default: 145 default:
149 146
@@ -154,10 +151,9 @@ acpi_ex_resolve_object (
154 break; 151 break;
155 } 152 }
156 153
157 return_ACPI_STATUS (status); 154 return_ACPI_STATUS(status);
158} 155}
159 156
160
161/******************************************************************************* 157/*******************************************************************************
162 * 158 *
163 * FUNCTION: acpi_ex_store_object_to_object 159 * FUNCTION: acpi_ex_store_object_to_object
@@ -194,18 +190,15 @@ acpi_ex_resolve_object (
194 ******************************************************************************/ 190 ******************************************************************************/
195 191
196acpi_status 192acpi_status
197acpi_ex_store_object_to_object ( 193acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
198 union acpi_operand_object *source_desc, 194 union acpi_operand_object *dest_desc,
199 union acpi_operand_object *dest_desc, 195 union acpi_operand_object **new_desc,
200 union acpi_operand_object **new_desc, 196 struct acpi_walk_state *walk_state)
201 struct acpi_walk_state *walk_state)
202{ 197{
203 union acpi_operand_object *actual_src_desc; 198 union acpi_operand_object *actual_src_desc;
204 acpi_status status = AE_OK; 199 acpi_status status = AE_OK;
205
206
207 ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_object", source_desc);
208 200
201 ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_object", source_desc);
209 202
210 actual_src_desc = source_desc; 203 actual_src_desc = source_desc;
211 if (!dest_desc) { 204 if (!dest_desc) {
@@ -214,11 +207,14 @@ acpi_ex_store_object_to_object (
214 * package element), so we can simply copy the source object 207 * package element), so we can simply copy the source object
215 * creating a new destination object 208 * creating a new destination object
216 */ 209 */
217 status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, new_desc, walk_state); 210 status =
218 return_ACPI_STATUS (status); 211 acpi_ut_copy_iobject_to_iobject(actual_src_desc, new_desc,
212 walk_state);
213 return_ACPI_STATUS(status);
219 } 214 }
220 215
221 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_GET_OBJECT_TYPE (dest_desc)) { 216 if (ACPI_GET_OBJECT_TYPE(source_desc) !=
217 ACPI_GET_OBJECT_TYPE(dest_desc)) {
222 /* 218 /*
223 * The source type does not match the type of the destination. 219 * The source type does not match the type of the destination.
224 * Perform the "implicit conversion" of the source to the current type 220 * Perform the "implicit conversion" of the source to the current type
@@ -228,10 +224,13 @@ acpi_ex_store_object_to_object (
228 * Otherwise, actual_src_desc is a temporary object to hold the 224 * Otherwise, actual_src_desc is a temporary object to hold the
229 * converted object. 225 * converted object.
230 */ 226 */
231 status = acpi_ex_convert_to_target_type (ACPI_GET_OBJECT_TYPE (dest_desc), 227 status =
232 source_desc, &actual_src_desc, walk_state); 228 acpi_ex_convert_to_target_type(ACPI_GET_OBJECT_TYPE
233 if (ACPI_FAILURE (status)) { 229 (dest_desc), source_desc,
234 return_ACPI_STATUS (status); 230 &actual_src_desc,
231 walk_state);
232 if (ACPI_FAILURE(status)) {
233 return_ACPI_STATUS(status);
235 } 234 }
236 235
237 if (source_desc == actual_src_desc) { 236 if (source_desc == actual_src_desc) {
@@ -240,7 +239,7 @@ acpi_ex_store_object_to_object (
240 * new object. 239 * new object.
241 */ 240 */
242 *new_desc = source_desc; 241 *new_desc = source_desc;
243 return_ACPI_STATUS (AE_OK); 242 return_ACPI_STATUS(AE_OK);
244 } 243 }
245 } 244 }
246 245
@@ -248,42 +247,42 @@ acpi_ex_store_object_to_object (
248 * We now have two objects of identical types, and we can perform a 247 * We now have two objects of identical types, and we can perform a
249 * copy of the *value* of the source object. 248 * copy of the *value* of the source object.
250 */ 249 */
251 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 250 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
252 case ACPI_TYPE_INTEGER: 251 case ACPI_TYPE_INTEGER:
253 252
254 dest_desc->integer.value = actual_src_desc->integer.value; 253 dest_desc->integer.value = actual_src_desc->integer.value;
255 254
256 /* Truncate value if we are executing from a 32-bit ACPI table */ 255 /* Truncate value if we are executing from a 32-bit ACPI table */
257 256
258 acpi_ex_truncate_for32bit_table (dest_desc); 257 acpi_ex_truncate_for32bit_table(dest_desc);
259 break; 258 break;
260 259
261 case ACPI_TYPE_STRING: 260 case ACPI_TYPE_STRING:
262 261
263 status = acpi_ex_store_string_to_string (actual_src_desc, dest_desc); 262 status =
263 acpi_ex_store_string_to_string(actual_src_desc, dest_desc);
264 break; 264 break;
265 265
266 case ACPI_TYPE_BUFFER: 266 case ACPI_TYPE_BUFFER:
267 267
268 /* 268 status =
269 * Note: There is different store behavior depending on the original 269 acpi_ex_store_buffer_to_buffer(actual_src_desc, dest_desc);
270 * source type
271 */
272 status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc);
273 break; 270 break;
274 271
275 case ACPI_TYPE_PACKAGE: 272 case ACPI_TYPE_PACKAGE:
276 273
277 status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc, 274 status =
278 walk_state); 275 acpi_ut_copy_iobject_to_iobject(actual_src_desc, &dest_desc,
276 walk_state);
279 break; 277 break;
280 278
281 default: 279 default:
282 /* 280 /*
283 * All other types come here. 281 * All other types come here.
284 */ 282 */
285 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", 283 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
286 acpi_ut_get_object_type_name (dest_desc))); 284 "Store into type %s not implemented\n",
285 acpi_ut_get_object_type_name(dest_desc)));
287 286
288 status = AE_NOT_IMPLEMENTED; 287 status = AE_NOT_IMPLEMENTED;
289 break; 288 break;
@@ -292,11 +291,9 @@ acpi_ex_store_object_to_object (
292 if (actual_src_desc != source_desc) { 291 if (actual_src_desc != source_desc) {
293 /* Delete the intermediate (temporary) source object */ 292 /* Delete the intermediate (temporary) source object */
294 293
295 acpi_ut_remove_reference (actual_src_desc); 294 acpi_ut_remove_reference(actual_src_desc);
296 } 295 }
297 296
298 *new_desc = dest_desc; 297 *new_desc = dest_desc;
299 return_ACPI_STATUS (status); 298 return_ACPI_STATUS(status);
300} 299}
301
302
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index 12d1527669c8..c4ff654a6697 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exstorob") 49ACPI_MODULE_NAME("exstorob")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -63,18 +60,14 @@
63 * DESCRIPTION: Copy a buffer object to another buffer object. 60 * DESCRIPTION: Copy a buffer object to another buffer object.
64 * 61 *
65 ******************************************************************************/ 62 ******************************************************************************/
66
67acpi_status 63acpi_status
68acpi_ex_store_buffer_to_buffer ( 64acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
69 union acpi_operand_object *source_desc, 65 union acpi_operand_object *target_desc)
70 union acpi_operand_object *target_desc)
71{ 66{
72 u32 length; 67 u32 length;
73 u8 *buffer; 68 u8 *buffer;
74
75
76 ACPI_FUNCTION_TRACE_PTR ("ex_store_buffer_to_buffer", source_desc);
77 69
70 ACPI_FUNCTION_TRACE_PTR("ex_store_buffer_to_buffer", source_desc);
78 71
79 /* We know that source_desc is a buffer by now */ 72 /* We know that source_desc is a buffer by now */
80 73
@@ -86,10 +79,10 @@ acpi_ex_store_buffer_to_buffer (
86 * allocate a new buffer of the proper length 79 * allocate a new buffer of the proper length
87 */ 80 */
88 if ((target_desc->buffer.length == 0) || 81 if ((target_desc->buffer.length == 0) ||
89 (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { 82 (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) {
90 target_desc->buffer.pointer = ACPI_MEM_ALLOCATE (length); 83 target_desc->buffer.pointer = ACPI_MEM_ALLOCATE(length);
91 if (!target_desc->buffer.pointer) { 84 if (!target_desc->buffer.pointer) {
92 return_ACPI_STATUS (AE_NO_MEMORY); 85 return_ACPI_STATUS(AE_NO_MEMORY);
93 } 86 }
94 87
95 target_desc->buffer.length = length; 88 target_desc->buffer.length = length;
@@ -100,8 +93,9 @@ acpi_ex_store_buffer_to_buffer (
100 if (length <= target_desc->buffer.length) { 93 if (length <= target_desc->buffer.length) {
101 /* Clear existing buffer and copy in the new one */ 94 /* Clear existing buffer and copy in the new one */
102 95
103 ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length); 96 ACPI_MEMSET(target_desc->buffer.pointer, 0,
104 ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length); 97 target_desc->buffer.length);
98 ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length);
105 99
106#ifdef ACPI_OBSOLETE_BEHAVIOR 100#ifdef ACPI_OBSOLETE_BEHAVIOR
107 /* 101 /*
@@ -124,26 +118,24 @@ acpi_ex_store_buffer_to_buffer (
124 target_desc->buffer.length = length; 118 target_desc->buffer.length = length;
125 } 119 }
126#endif 120#endif
127 } 121 } else {
128 else {
129 /* Truncate the source, copy only what will fit */ 122 /* Truncate the source, copy only what will fit */
130 123
131 ACPI_MEMCPY (target_desc->buffer.pointer, buffer, 124 ACPI_MEMCPY(target_desc->buffer.pointer, buffer,
132 target_desc->buffer.length); 125 target_desc->buffer.length);
133 126
134 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 127 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
135 "Truncating source buffer from %X to %X\n", 128 "Truncating source buffer from %X to %X\n",
136 length, target_desc->buffer.length)); 129 length, target_desc->buffer.length));
137 } 130 }
138 131
139 /* Copy flags */ 132 /* Copy flags */
140 133
141 target_desc->buffer.flags = source_desc->buffer.flags; 134 target_desc->buffer.flags = source_desc->buffer.flags;
142 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; 135 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
143 return_ACPI_STATUS (AE_OK); 136 return_ACPI_STATUS(AE_OK);
144} 137}
145 138
146
147/******************************************************************************* 139/*******************************************************************************
148 * 140 *
149 * FUNCTION: acpi_ex_store_string_to_string 141 * FUNCTION: acpi_ex_store_string_to_string
@@ -158,16 +150,13 @@ acpi_ex_store_buffer_to_buffer (
158 ******************************************************************************/ 150 ******************************************************************************/
159 151
160acpi_status 152acpi_status
161acpi_ex_store_string_to_string ( 153acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
162 union acpi_operand_object *source_desc, 154 union acpi_operand_object *target_desc)
163 union acpi_operand_object *target_desc)
164{ 155{
165 u32 length; 156 u32 length;
166 u8 *buffer; 157 u8 *buffer;
167
168
169 ACPI_FUNCTION_TRACE_PTR ("ex_store_string_to_string", source_desc);
170 158
159 ACPI_FUNCTION_TRACE_PTR("ex_store_string_to_string", source_desc);
171 160
172 /* We know that source_desc is a string by now */ 161 /* We know that source_desc is a string by now */
173 162
@@ -179,41 +168,38 @@ acpi_ex_store_string_to_string (
179 * pointer is not a static pointer (part of an ACPI table) 168 * pointer is not a static pointer (part of an ACPI table)
180 */ 169 */
181 if ((length < target_desc->string.length) && 170 if ((length < target_desc->string.length) &&
182 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { 171 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
183 /* 172 /*
184 * String will fit in existing non-static buffer. 173 * String will fit in existing non-static buffer.
185 * Clear old string and copy in the new one 174 * Clear old string and copy in the new one
186 */ 175 */
187 ACPI_MEMSET (target_desc->string.pointer, 0, 176 ACPI_MEMSET(target_desc->string.pointer, 0,
188 (acpi_size) target_desc->string.length + 1); 177 (acpi_size) target_desc->string.length + 1);
189 ACPI_MEMCPY (target_desc->string.pointer, buffer, length); 178 ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
190 } 179 } else {
191 else {
192 /* 180 /*
193 * Free the current buffer, then allocate a new buffer 181 * Free the current buffer, then allocate a new buffer
194 * large enough to hold the value 182 * large enough to hold the value
195 */ 183 */
196 if (target_desc->string.pointer && 184 if (target_desc->string.pointer &&
197 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { 185 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
198 /* Only free if not a pointer into the DSDT */ 186 /* Only free if not a pointer into the DSDT */
199 187
200 ACPI_MEM_FREE (target_desc->string.pointer); 188 ACPI_MEM_FREE(target_desc->string.pointer);
201 } 189 }
202 190
203 target_desc->string.pointer = ACPI_MEM_CALLOCATE ( 191 target_desc->string.pointer = ACPI_MEM_CALLOCATE((acpi_size)
204 (acpi_size) length + 1); 192 length + 1);
205 if (!target_desc->string.pointer) { 193 if (!target_desc->string.pointer) {
206 return_ACPI_STATUS (AE_NO_MEMORY); 194 return_ACPI_STATUS(AE_NO_MEMORY);
207 } 195 }
208 196
209 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; 197 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
210 ACPI_MEMCPY (target_desc->string.pointer, buffer, length); 198 ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
211 } 199 }
212 200
213 /* Set the new target length */ 201 /* Set the new target length */
214 202
215 target_desc->string.length = length; 203 target_desc->string.length = length;
216 return_ACPI_STATUS (AE_OK); 204 return_ACPI_STATUS(AE_OK);
217} 205}
218
219
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index cafa702108dc..8a88b841237d 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -42,14 +42,12 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/acevents.h> 47#include <acpi/acevents.h>
49 48
50#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exsystem") 50ACPI_MODULE_NAME("exsystem")
52
53 51
54/******************************************************************************* 52/*******************************************************************************
55 * 53 *
@@ -65,49 +63,42 @@
65 * interpreter is released. 63 * interpreter is released.
66 * 64 *
67 ******************************************************************************/ 65 ******************************************************************************/
68 66acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
69acpi_status
70acpi_ex_system_wait_semaphore (
71 acpi_handle semaphore,
72 u16 timeout)
73{ 67{
74 acpi_status status; 68 acpi_status status;
75 acpi_status status2; 69 acpi_status status2;
76
77 70
78 ACPI_FUNCTION_TRACE ("ex_system_wait_semaphore"); 71 ACPI_FUNCTION_TRACE("ex_system_wait_semaphore");
79 72
80 73 status = acpi_os_wait_semaphore(semaphore, 1, 0);
81 status = acpi_os_wait_semaphore (semaphore, 1, 0); 74 if (ACPI_SUCCESS(status)) {
82 if (ACPI_SUCCESS (status)) { 75 return_ACPI_STATUS(status);
83 return_ACPI_STATUS (status);
84 } 76 }
85 77
86 if (status == AE_TIME) { 78 if (status == AE_TIME) {
87 /* We must wait, so unlock the interpreter */ 79 /* We must wait, so unlock the interpreter */
88 80
89 acpi_ex_exit_interpreter (); 81 acpi_ex_exit_interpreter();
90 82
91 status = acpi_os_wait_semaphore (semaphore, 1, timeout); 83 status = acpi_os_wait_semaphore(semaphore, 1, timeout);
92 84
93 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 85 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
94 "*** Thread awake after blocking, %s\n", 86 "*** Thread awake after blocking, %s\n",
95 acpi_format_exception (status))); 87 acpi_format_exception(status)));
96 88
97 /* Reacquire the interpreter */ 89 /* Reacquire the interpreter */
98 90
99 status2 = acpi_ex_enter_interpreter (); 91 status2 = acpi_ex_enter_interpreter();
100 if (ACPI_FAILURE (status2)) { 92 if (ACPI_FAILURE(status2)) {
101 /* Report fatal error, could not acquire interpreter */ 93 /* Report fatal error, could not acquire interpreter */
102 94
103 return_ACPI_STATUS (status2); 95 return_ACPI_STATUS(status2);
104 } 96 }
105 } 97 }
106 98
107 return_ACPI_STATUS (status); 99 return_ACPI_STATUS(status);
108} 100}
109 101
110
111/******************************************************************************* 102/*******************************************************************************
112 * 103 *
113 * FUNCTION: acpi_ex_system_do_stall 104 * FUNCTION: acpi_ex_system_do_stall
@@ -125,35 +116,29 @@ acpi_ex_system_wait_semaphore (
125 * 116 *
126 ******************************************************************************/ 117 ******************************************************************************/
127 118
128acpi_status 119acpi_status acpi_ex_system_do_stall(u32 how_long)
129acpi_ex_system_do_stall (
130 u32 how_long)
131{ 120{
132 acpi_status status = AE_OK; 121 acpi_status status = AE_OK;
133
134 122
135 ACPI_FUNCTION_ENTRY (); 123 ACPI_FUNCTION_ENTRY();
136 124
137 125 if (how_long > 255) { /* 255 microseconds */
138 if (how_long > 255) /* 255 microseconds */ {
139 /* 126 /*
140 * Longer than 255 usec, this is an error 127 * Longer than 255 usec, this is an error
141 * 128 *
142 * (ACPI specifies 100 usec as max, but this gives some slack in 129 * (ACPI specifies 100 usec as max, but this gives some slack in
143 * order to support existing BIOSs) 130 * order to support existing BIOSs)
144 */ 131 */
145 ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", 132 ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n",
146 how_long)); 133 how_long));
147 status = AE_AML_OPERAND_VALUE; 134 status = AE_AML_OPERAND_VALUE;
148 } 135 } else {
149 else { 136 acpi_os_stall(how_long);
150 acpi_os_stall (how_long);
151 } 137 }
152 138
153 return (status); 139 return (status);
154} 140}
155 141
156
157/******************************************************************************* 142/*******************************************************************************
158 * 143 *
159 * FUNCTION: acpi_ex_system_do_suspend 144 * FUNCTION: acpi_ex_system_do_suspend
@@ -167,29 +152,24 @@ acpi_ex_system_do_stall (
167 * 152 *
168 ******************************************************************************/ 153 ******************************************************************************/
169 154
170acpi_status 155acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
171acpi_ex_system_do_suspend (
172 acpi_integer how_long)
173{ 156{
174 acpi_status status; 157 acpi_status status;
175
176
177 ACPI_FUNCTION_ENTRY ();
178 158
159 ACPI_FUNCTION_ENTRY();
179 160
180 /* Since this thread will sleep, we must release the interpreter */ 161 /* Since this thread will sleep, we must release the interpreter */
181 162
182 acpi_ex_exit_interpreter (); 163 acpi_ex_exit_interpreter();
183 164
184 acpi_os_sleep (how_long); 165 acpi_os_sleep(how_long);
185 166
186 /* And now we must get the interpreter again */ 167 /* And now we must get the interpreter again */
187 168
188 status = acpi_ex_enter_interpreter (); 169 status = acpi_ex_enter_interpreter();
189 return (status); 170 return (status);
190} 171}
191 172
192
193/******************************************************************************* 173/*******************************************************************************
194 * 174 *
195 * FUNCTION: acpi_ex_system_acquire_mutex 175 * FUNCTION: acpi_ex_system_acquire_mutex
@@ -206,33 +186,30 @@ acpi_ex_system_do_suspend (
206 ******************************************************************************/ 186 ******************************************************************************/
207 187
208acpi_status 188acpi_status
209acpi_ex_system_acquire_mutex ( 189acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
210 union acpi_operand_object *time_desc, 190 union acpi_operand_object * obj_desc)
211 union acpi_operand_object *obj_desc)
212{ 191{
213 acpi_status status = AE_OK; 192 acpi_status status = AE_OK;
214
215
216 ACPI_FUNCTION_TRACE_PTR ("ex_system_acquire_mutex", obj_desc);
217 193
194 ACPI_FUNCTION_TRACE_PTR("ex_system_acquire_mutex", obj_desc);
218 195
219 if (!obj_desc) { 196 if (!obj_desc) {
220 return_ACPI_STATUS (AE_BAD_PARAMETER); 197 return_ACPI_STATUS(AE_BAD_PARAMETER);
221 } 198 }
222 199
223 /* Support for the _GL_ Mutex object -- go get the global lock */ 200 /* Support for the _GL_ Mutex object -- go get the global lock */
224 201
225 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 202 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
226 status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value); 203 status =
227 return_ACPI_STATUS (status); 204 acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
205 return_ACPI_STATUS(status);
228 } 206 }
229 207
230 status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore, 208 status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore,
231 (u16) time_desc->integer.value); 209 (u16) time_desc->integer.value);
232 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
233} 211}
234 212
235
236/******************************************************************************* 213/*******************************************************************************
237 * 214 *
238 * FUNCTION: acpi_ex_system_release_mutex 215 * FUNCTION: acpi_ex_system_release_mutex
@@ -248,32 +225,27 @@ acpi_ex_system_acquire_mutex (
248 * 225 *
249 ******************************************************************************/ 226 ******************************************************************************/
250 227
251acpi_status 228acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
252acpi_ex_system_release_mutex (
253 union acpi_operand_object *obj_desc)
254{ 229{
255 acpi_status status = AE_OK; 230 acpi_status status = AE_OK;
256
257
258 ACPI_FUNCTION_TRACE ("ex_system_release_mutex");
259 231
232 ACPI_FUNCTION_TRACE("ex_system_release_mutex");
260 233
261 if (!obj_desc) { 234 if (!obj_desc) {
262 return_ACPI_STATUS (AE_BAD_PARAMETER); 235 return_ACPI_STATUS(AE_BAD_PARAMETER);
263 } 236 }
264 237
265 /* Support for the _GL_ Mutex object -- release the global lock */ 238 /* Support for the _GL_ Mutex object -- release the global lock */
266 239
267 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 240 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
268 status = acpi_ev_release_global_lock (); 241 status = acpi_ev_release_global_lock();
269 return_ACPI_STATUS (status); 242 return_ACPI_STATUS(status);
270 } 243 }
271 244
272 status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1); 245 status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1);
273 return_ACPI_STATUS (status); 246 return_ACPI_STATUS(status);
274} 247}
275 248
276
277/******************************************************************************* 249/*******************************************************************************
278 * 250 *
279 * FUNCTION: acpi_ex_system_signal_event 251 * FUNCTION: acpi_ex_system_signal_event
@@ -287,24 +259,19 @@ acpi_ex_system_release_mutex (
287 * 259 *
288 ******************************************************************************/ 260 ******************************************************************************/
289 261
290acpi_status 262acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
291acpi_ex_system_signal_event (
292 union acpi_operand_object *obj_desc)
293{ 263{
294 acpi_status status = AE_OK; 264 acpi_status status = AE_OK;
295
296
297 ACPI_FUNCTION_TRACE ("ex_system_signal_event");
298 265
266 ACPI_FUNCTION_TRACE("ex_system_signal_event");
299 267
300 if (obj_desc) { 268 if (obj_desc) {
301 status = acpi_os_signal_semaphore (obj_desc->event.semaphore, 1); 269 status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1);
302 } 270 }
303 271
304 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
305} 273}
306 274
307
308/******************************************************************************* 275/*******************************************************************************
309 * 276 *
310 * FUNCTION: acpi_ex_system_wait_event 277 * FUNCTION: acpi_ex_system_wait_event
@@ -321,25 +288,23 @@ acpi_ex_system_signal_event (
321 ******************************************************************************/ 288 ******************************************************************************/
322 289
323acpi_status 290acpi_status
324acpi_ex_system_wait_event ( 291acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
325 union acpi_operand_object *time_desc, 292 union acpi_operand_object *obj_desc)
326 union acpi_operand_object *obj_desc)
327{ 293{
328 acpi_status status = AE_OK; 294 acpi_status status = AE_OK;
329
330
331 ACPI_FUNCTION_TRACE ("ex_system_wait_event");
332 295
296 ACPI_FUNCTION_TRACE("ex_system_wait_event");
333 297
334 if (obj_desc) { 298 if (obj_desc) {
335 status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore, 299 status =
336 (u16) time_desc->integer.value); 300 acpi_ex_system_wait_semaphore(obj_desc->event.semaphore,
301 (u16) time_desc->integer.
302 value);
337 } 303 }
338 304
339 return_ACPI_STATUS (status); 305 return_ACPI_STATUS(status);
340} 306}
341 307
342
343/******************************************************************************* 308/*******************************************************************************
344 * 309 *
345 * FUNCTION: acpi_ex_system_reset_event 310 * FUNCTION: acpi_ex_system_reset_event
@@ -352,27 +317,23 @@ acpi_ex_system_wait_event (
352 * 317 *
353 ******************************************************************************/ 318 ******************************************************************************/
354 319
355acpi_status 320acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
356acpi_ex_system_reset_event (
357 union acpi_operand_object *obj_desc)
358{ 321{
359 acpi_status status = AE_OK; 322 acpi_status status = AE_OK;
360 void *temp_semaphore; 323 void *temp_semaphore;
361
362
363 ACPI_FUNCTION_ENTRY ();
364 324
325 ACPI_FUNCTION_ENTRY();
365 326
366 /* 327 /*
367 * We are going to simply delete the existing semaphore and 328 * We are going to simply delete the existing semaphore and
368 * create a new one! 329 * create a new one!
369 */ 330 */
370 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); 331 status =
371 if (ACPI_SUCCESS (status)) { 332 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
372 (void) acpi_os_delete_semaphore (obj_desc->event.semaphore); 333 if (ACPI_SUCCESS(status)) {
334 (void)acpi_os_delete_semaphore(obj_desc->event.semaphore);
373 obj_desc->event.semaphore = temp_semaphore; 335 obj_desc->event.semaphore = temp_semaphore;
374 } 336 }
375 337
376 return (status); 338 return (status);
377} 339}
378
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 5c7ec0c04177..1ee79d8c8f88 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46/* 45/*
47 * DEFINE_AML_GLOBALS is tested in amlcode.h 46 * DEFINE_AML_GLOBALS is tested in amlcode.h
48 * to determine whether certain global names should be "defined" or only 47 * to determine whether certain global names should be "defined" or only
@@ -65,15 +64,10 @@
65#include <acpi/acevents.h> 64#include <acpi/acevents.h>
66 65
67#define _COMPONENT ACPI_EXECUTER 66#define _COMPONENT ACPI_EXECUTER
68 ACPI_MODULE_NAME ("exutils") 67ACPI_MODULE_NAME("exutils")
69 68
70/* Local prototypes */ 69/* Local prototypes */
71 70static u32 acpi_ex_digits_needed(acpi_integer value, u32 base);
72static u32
73acpi_ex_digits_needed (
74 acpi_integer value,
75 u32 base);
76
77 71
78#ifndef ACPI_NO_METHOD_EXECUTION 72#ifndef ACPI_NO_METHOD_EXECUTION
79/******************************************************************************* 73/*******************************************************************************
@@ -89,24 +83,20 @@ acpi_ex_digits_needed (
89 * 83 *
90 ******************************************************************************/ 84 ******************************************************************************/
91 85
92acpi_status 86acpi_status acpi_ex_enter_interpreter(void)
93acpi_ex_enter_interpreter (
94 void)
95{ 87{
96 acpi_status status; 88 acpi_status status;
97
98 ACPI_FUNCTION_TRACE ("ex_enter_interpreter");
99 89
90 ACPI_FUNCTION_TRACE("ex_enter_interpreter");
100 91
101 status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE); 92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE);
102 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n")); 94 ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n"));
104 } 95 }
105 96
106 return_ACPI_STATUS (status); 97 return_ACPI_STATUS(status);
107} 98}
108 99
109
110/******************************************************************************* 100/*******************************************************************************
111 * 101 *
112 * FUNCTION: acpi_ex_exit_interpreter 102 * FUNCTION: acpi_ex_exit_interpreter
@@ -129,25 +119,20 @@ acpi_ex_enter_interpreter (
129 * 119 *
130 ******************************************************************************/ 120 ******************************************************************************/
131 121
132void 122void acpi_ex_exit_interpreter(void)
133acpi_ex_exit_interpreter (
134 void)
135{ 123{
136 acpi_status status; 124 acpi_status status;
137
138
139 ACPI_FUNCTION_TRACE ("ex_exit_interpreter");
140 125
126 ACPI_FUNCTION_TRACE("ex_exit_interpreter");
141 127
142 status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE); 128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE);
143 if (ACPI_FAILURE (status)) { 129 if (ACPI_FAILURE(status)) {
144 ACPI_REPORT_ERROR (("Could not release interpreter mutex\n")); 130 ACPI_REPORT_ERROR(("Could not release interpreter mutex\n"));
145 } 131 }
146 132
147 return_VOID; 133 return_VOID;
148} 134}
149 135
150
151/******************************************************************************* 136/*******************************************************************************
152 * 137 *
153 * FUNCTION: acpi_ex_truncate_for32bit_table 138 * FUNCTION: acpi_ex_truncate_for32bit_table
@@ -161,20 +146,17 @@ acpi_ex_exit_interpreter (
161 * 146 *
162 ******************************************************************************/ 147 ******************************************************************************/
163 148
164void 149void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
165acpi_ex_truncate_for32bit_table (
166 union acpi_operand_object *obj_desc)
167{ 150{
168 151
169 ACPI_FUNCTION_ENTRY (); 152 ACPI_FUNCTION_ENTRY();
170
171 153
172 /* 154 /*
173 * Object must be a valid number and we must be executing 155 * Object must be a valid number and we must be executing
174 * a control method 156 * a control method
175 */ 157 */
176 if ((!obj_desc) || 158 if ((!obj_desc) ||
177 (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER)) { 159 (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) {
178 return; 160 return;
179 } 161 }
180 162
@@ -187,7 +169,6 @@ acpi_ex_truncate_for32bit_table (
187 } 169 }
188} 170}
189 171
190
191/******************************************************************************* 172/*******************************************************************************
192 * 173 *
193 * FUNCTION: acpi_ex_acquire_global_lock 174 * FUNCTION: acpi_ex_acquire_global_lock
@@ -203,37 +184,31 @@ acpi_ex_truncate_for32bit_table (
203 * 184 *
204 ******************************************************************************/ 185 ******************************************************************************/
205 186
206u8 187u8 acpi_ex_acquire_global_lock(u32 field_flags)
207acpi_ex_acquire_global_lock (
208 u32 field_flags)
209{ 188{
210 u8 locked = FALSE; 189 u8 locked = FALSE;
211 acpi_status status; 190 acpi_status status;
212
213
214 ACPI_FUNCTION_TRACE ("ex_acquire_global_lock");
215 191
192 ACPI_FUNCTION_TRACE("ex_acquire_global_lock");
216 193
217 /* Only attempt lock if the always_lock bit is set */ 194 /* Only attempt lock if the always_lock bit is set */
218 195
219 if (field_flags & AML_FIELD_LOCK_RULE_MASK) { 196 if (field_flags & AML_FIELD_LOCK_RULE_MASK) {
220 /* We should attempt to get the lock, wait forever */ 197 /* We should attempt to get the lock, wait forever */
221 198
222 status = acpi_ev_acquire_global_lock (ACPI_WAIT_FOREVER); 199 status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER);
223 if (ACPI_SUCCESS (status)) { 200 if (ACPI_SUCCESS(status)) {
224 locked = TRUE; 201 locked = TRUE;
225 } 202 } else {
226 else { 203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
227 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204 "Could not acquire Global Lock, %s\n",
228 "Could not acquire Global Lock, %s\n", 205 acpi_format_exception(status)));
229 acpi_format_exception (status)));
230 } 206 }
231 } 207 }
232 208
233 return_VALUE (locked); 209 return_VALUE(locked);
234} 210}
235 211
236
237/******************************************************************************* 212/*******************************************************************************
238 * 213 *
239 * FUNCTION: acpi_ex_release_global_lock 214 * FUNCTION: acpi_ex_release_global_lock
@@ -247,34 +222,28 @@ acpi_ex_acquire_global_lock (
247 * 222 *
248 ******************************************************************************/ 223 ******************************************************************************/
249 224
250void 225void acpi_ex_release_global_lock(u8 locked_by_me)
251acpi_ex_release_global_lock (
252 u8 locked_by_me)
253{ 226{
254 acpi_status status; 227 acpi_status status;
255
256
257 ACPI_FUNCTION_TRACE ("ex_release_global_lock");
258 228
229 ACPI_FUNCTION_TRACE("ex_release_global_lock");
259 230
260 /* Only attempt unlock if the caller locked it */ 231 /* Only attempt unlock if the caller locked it */
261 232
262 if (locked_by_me) { 233 if (locked_by_me) {
263 /* OK, now release the lock */ 234 /* OK, now release the lock */
264 235
265 status = acpi_ev_release_global_lock (); 236 status = acpi_ev_release_global_lock();
266 if (ACPI_FAILURE (status)) { 237 if (ACPI_FAILURE(status)) {
267 /* Report the error, but there isn't much else we can do */ 238 /* Report the error, but there isn't much else we can do */
268 239
269 ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n", 240 ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status)));
270 acpi_format_exception (status)));
271 } 241 }
272 } 242 }
273 243
274 return_VOID; 244 return_VOID;
275} 245}
276 246
277
278/******************************************************************************* 247/*******************************************************************************
279 * 248 *
280 * FUNCTION: acpi_ex_digits_needed 249 * FUNCTION: acpi_ex_digits_needed
@@ -289,22 +258,17 @@ acpi_ex_release_global_lock (
289 * 258 *
290 ******************************************************************************/ 259 ******************************************************************************/
291 260
292static u32 261static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
293acpi_ex_digits_needed (
294 acpi_integer value,
295 u32 base)
296{ 262{
297 u32 num_digits; 263 u32 num_digits;
298 acpi_integer current_value; 264 acpi_integer current_value;
299
300
301 ACPI_FUNCTION_TRACE ("ex_digits_needed");
302 265
266 ACPI_FUNCTION_TRACE("ex_digits_needed");
303 267
304 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
305 269
306 if (value == 0) { 270 if (value == 0) {
307 return_VALUE (1); 271 return_VALUE(1);
308 } 272 }
309 273
310 current_value = value; 274 current_value = value;
@@ -313,14 +277,14 @@ acpi_ex_digits_needed (
313 /* Count the digits in the requested base */ 277 /* Count the digits in the requested base */
314 278
315 while (current_value) { 279 while (current_value) {
316 (void) acpi_ut_short_divide (current_value, base, &current_value, NULL); 280 (void)acpi_ut_short_divide(current_value, base, &current_value,
281 NULL);
317 num_digits++; 282 num_digits++;
318 } 283 }
319 284
320 return_VALUE (num_digits); 285 return_VALUE(num_digits);
321} 286}
322 287
323
324/******************************************************************************* 288/*******************************************************************************
325 * 289 *
326 * FUNCTION: acpi_ex_eisa_id_to_string 290 * FUNCTION: acpi_ex_eisa_id_to_string
@@ -334,32 +298,26 @@ acpi_ex_digits_needed (
334 * 298 *
335 ******************************************************************************/ 299 ******************************************************************************/
336 300
337void 301void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string)
338acpi_ex_eisa_id_to_string (
339 u32 numeric_id,
340 char *out_string)
341{ 302{
342 u32 eisa_id; 303 u32 eisa_id;
343
344
345 ACPI_FUNCTION_ENTRY ();
346 304
305 ACPI_FUNCTION_ENTRY();
347 306
348 /* Swap ID to big-endian to get contiguous bits */ 307 /* Swap ID to big-endian to get contiguous bits */
349 308
350 eisa_id = acpi_ut_dword_byte_swap (numeric_id); 309 eisa_id = acpi_ut_dword_byte_swap(numeric_id);
351 310
352 out_string[0] = (char) ('@' + (((unsigned long) eisa_id >> 26) & 0x1f)); 311 out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f));
353 out_string[1] = (char) ('@' + ((eisa_id >> 21) & 0x1f)); 312 out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f));
354 out_string[2] = (char) ('@' + ((eisa_id >> 16) & 0x1f)); 313 out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f));
355 out_string[3] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 12); 314 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12);
356 out_string[4] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 8); 315 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8);
357 out_string[5] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 4); 316 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4);
358 out_string[6] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 0); 317 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0);
359 out_string[7] = 0; 318 out_string[7] = 0;
360} 319}
361 320
362
363/******************************************************************************* 321/*******************************************************************************
364 * 322 *
365 * FUNCTION: acpi_ex_unsigned_integer_to_string 323 * FUNCTION: acpi_ex_unsigned_integer_to_string
@@ -369,30 +327,25 @@ acpi_ex_eisa_id_to_string (
369 * 327 *
370 * RETURN: None, string 328 * RETURN: None, string
371 * 329 *
372 * DESCRIPTOIN: Convert a number to string representation. Assumes string 330 * DESCRIPTION: Convert a number to string representation. Assumes string
373 * buffer is large enough to hold the string. 331 * buffer is large enough to hold the string.
374 * 332 *
375 ******************************************************************************/ 333 ******************************************************************************/
376 334
377void 335void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string)
378acpi_ex_unsigned_integer_to_string (
379 acpi_integer value,
380 char *out_string)
381{ 336{
382 u32 count; 337 u32 count;
383 u32 digits_needed; 338 u32 digits_needed;
384 u32 remainder; 339 u32 remainder;
385
386
387 ACPI_FUNCTION_ENTRY ();
388 340
341 ACPI_FUNCTION_ENTRY();
389 342
390 digits_needed = acpi_ex_digits_needed (value, 10); 343 digits_needed = acpi_ex_digits_needed(value, 10);
391 out_string[digits_needed] = 0; 344 out_string[digits_needed] = 0;
392 345
393 for (count = digits_needed; count > 0; count--) { 346 for (count = digits_needed; count > 0; count--) {
394 (void) acpi_ut_short_divide (value, 10, &value, &remainder); 347 (void)acpi_ut_short_divide(value, 10, &value, &remainder);
395 out_string[count-1] = (char) ('0' + remainder);\ 348 out_string[count - 1] = (char)('0' + remainder);
396 } 349 }
397} 350}
398 351
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 14192ee55f8f..e8165c4f162a 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -34,52 +34,45 @@
34#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
36 36
37
38#define ACPI_FAN_COMPONENT 0x00200000 37#define ACPI_FAN_COMPONENT 0x00200000
39#define ACPI_FAN_CLASS "fan" 38#define ACPI_FAN_CLASS "fan"
40#define ACPI_FAN_HID "PNP0C0B"
41#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" 39#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver"
42#define ACPI_FAN_DEVICE_NAME "Fan"
43#define ACPI_FAN_FILE_STATE "state" 40#define ACPI_FAN_FILE_STATE "state"
44#define ACPI_FAN_NOTIFY_STATUS 0x80
45 41
46#define _COMPONENT ACPI_FAN_COMPONENT 42#define _COMPONENT ACPI_FAN_COMPONENT
47ACPI_MODULE_NAME ("acpi_fan") 43ACPI_MODULE_NAME("acpi_fan")
48 44
49MODULE_AUTHOR("Paul Diefenbaugh"); 45 MODULE_AUTHOR("Paul Diefenbaugh");
50MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME); 46MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
51MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
52 48
53static int acpi_fan_add (struct acpi_device *device); 49static int acpi_fan_add(struct acpi_device *device);
54static int acpi_fan_remove (struct acpi_device *device, int type); 50static int acpi_fan_remove(struct acpi_device *device, int type);
55 51
56static struct acpi_driver acpi_fan_driver = { 52static struct acpi_driver acpi_fan_driver = {
57 .name = ACPI_FAN_DRIVER_NAME, 53 .name = ACPI_FAN_DRIVER_NAME,
58 .class = ACPI_FAN_CLASS, 54 .class = ACPI_FAN_CLASS,
59 .ids = ACPI_FAN_HID, 55 .ids = "PNP0C0B",
60 .ops = { 56 .ops = {
61 .add = acpi_fan_add, 57 .add = acpi_fan_add,
62 .remove = acpi_fan_remove, 58 .remove = acpi_fan_remove,
63 }, 59 },
64}; 60};
65 61
66struct acpi_fan { 62struct acpi_fan {
67 acpi_handle handle; 63 acpi_handle handle;
68}; 64};
69 65
70
71/* -------------------------------------------------------------------------- 66/* --------------------------------------------------------------------------
72 FS Interface (/proc) 67 FS Interface (/proc)
73 -------------------------------------------------------------------------- */ 68 -------------------------------------------------------------------------- */
74 69
75static struct proc_dir_entry *acpi_fan_dir; 70static struct proc_dir_entry *acpi_fan_dir;
76 71
77 72static int acpi_fan_read_state(struct seq_file *seq, void *offset)
78static int
79acpi_fan_read_state (struct seq_file *seq, void *offset)
80{ 73{
81 struct acpi_fan *fan = seq->private; 74 struct acpi_fan *fan = seq->private;
82 int state = 0; 75 int state = 0;
83 76
84 ACPI_FUNCTION_TRACE("acpi_fan_read_state"); 77 ACPI_FUNCTION_TRACE("acpi_fan_read_state");
85 78
@@ -88,7 +81,7 @@ acpi_fan_read_state (struct seq_file *seq, void *offset)
88 seq_printf(seq, "status: ERROR\n"); 81 seq_printf(seq, "status: ERROR\n");
89 else 82 else
90 seq_printf(seq, "status: %s\n", 83 seq_printf(seq, "status: %s\n",
91 !state?"on":"off"); 84 !state ? "on" : "off");
92 } 85 }
93 return_VALUE(0); 86 return_VALUE(0);
94} 87}
@@ -99,29 +92,26 @@ static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
99} 92}
100 93
101static ssize_t 94static ssize_t
102acpi_fan_write_state ( 95acpi_fan_write_state(struct file *file, const char __user * buffer,
103 struct file *file, 96 size_t count, loff_t * ppos)
104 const char __user *buffer,
105 size_t count,
106 loff_t *ppos)
107{ 97{
108 int result = 0; 98 int result = 0;
109 struct seq_file *m = (struct seq_file *)file->private_data; 99 struct seq_file *m = (struct seq_file *)file->private_data;
110 struct acpi_fan *fan = (struct acpi_fan *) m->private; 100 struct acpi_fan *fan = (struct acpi_fan *)m->private;
111 char state_string[12] = {'\0'}; 101 char state_string[12] = { '\0' };
112 102
113 ACPI_FUNCTION_TRACE("acpi_fan_write_state"); 103 ACPI_FUNCTION_TRACE("acpi_fan_write_state");
114 104
115 if (!fan || (count > sizeof(state_string) - 1)) 105 if (!fan || (count > sizeof(state_string) - 1))
116 return_VALUE(-EINVAL); 106 return_VALUE(-EINVAL);
117 107
118 if (copy_from_user(state_string, buffer, count)) 108 if (copy_from_user(state_string, buffer, count))
119 return_VALUE(-EFAULT); 109 return_VALUE(-EFAULT);
120 110
121 state_string[count] = '\0'; 111 state_string[count] = '\0';
122 112
123 result = acpi_bus_set_power(fan->handle, 113 result = acpi_bus_set_power(fan->handle,
124 simple_strtoul(state_string, NULL, 0)); 114 simple_strtoul(state_string, NULL, 0));
125 if (result) 115 if (result)
126 return_VALUE(result); 116 return_VALUE(result);
127 117
@@ -129,19 +119,17 @@ acpi_fan_write_state (
129} 119}
130 120
131static struct file_operations acpi_fan_state_ops = { 121static struct file_operations acpi_fan_state_ops = {
132 .open = acpi_fan_state_open_fs, 122 .open = acpi_fan_state_open_fs,
133 .read = seq_read, 123 .read = seq_read,
134 .write = acpi_fan_write_state, 124 .write = acpi_fan_write_state,
135 .llseek = seq_lseek, 125 .llseek = seq_lseek,
136 .release = single_release, 126 .release = single_release,
137 .owner = THIS_MODULE, 127 .owner = THIS_MODULE,
138}; 128};
139 129
140static int 130static int acpi_fan_add_fs(struct acpi_device *device)
141acpi_fan_add_fs (
142 struct acpi_device *device)
143{ 131{
144 struct proc_dir_entry *entry = NULL; 132 struct proc_dir_entry *entry = NULL;
145 133
146 ACPI_FUNCTION_TRACE("acpi_fan_add_fs"); 134 ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
147 135
@@ -150,7 +138,7 @@ acpi_fan_add_fs (
150 138
151 if (!acpi_device_dir(device)) { 139 if (!acpi_device_dir(device)) {
152 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 140 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
153 acpi_fan_dir); 141 acpi_fan_dir);
154 if (!acpi_device_dir(device)) 142 if (!acpi_device_dir(device))
155 return_VALUE(-ENODEV); 143 return_VALUE(-ENODEV);
156 acpi_device_dir(device)->owner = THIS_MODULE; 144 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -158,11 +146,12 @@ acpi_fan_add_fs (
158 146
159 /* 'status' [R/W] */ 147 /* 'status' [R/W] */
160 entry = create_proc_entry(ACPI_FAN_FILE_STATE, 148 entry = create_proc_entry(ACPI_FAN_FILE_STATE,
161 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 149 S_IFREG | S_IRUGO | S_IWUSR,
150 acpi_device_dir(device));
162 if (!entry) 151 if (!entry)
163 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 152 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
164 "Unable to create '%s' fs entry\n", 153 "Unable to create '%s' fs entry\n",
165 ACPI_FAN_FILE_STATE)); 154 ACPI_FAN_FILE_STATE));
166 else { 155 else {
167 entry->proc_fops = &acpi_fan_state_ops; 156 entry->proc_fops = &acpi_fan_state_ops;
168 entry->data = acpi_driver_data(device); 157 entry->data = acpi_driver_data(device);
@@ -172,16 +161,12 @@ acpi_fan_add_fs (
172 return_VALUE(0); 161 return_VALUE(0);
173} 162}
174 163
175 164static int acpi_fan_remove_fs(struct acpi_device *device)
176static int
177acpi_fan_remove_fs (
178 struct acpi_device *device)
179{ 165{
180 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); 166 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
181 167
182 if (acpi_device_dir(device)) { 168 if (acpi_device_dir(device)) {
183 remove_proc_entry(ACPI_FAN_FILE_STATE, 169 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
184 acpi_device_dir(device));
185 remove_proc_entry(acpi_device_bid(device), acpi_fan_dir); 170 remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
186 acpi_device_dir(device) = NULL; 171 acpi_device_dir(device) = NULL;
187 } 172 }
@@ -189,18 +174,15 @@ acpi_fan_remove_fs (
189 return_VALUE(0); 174 return_VALUE(0);
190} 175}
191 176
192
193/* -------------------------------------------------------------------------- 177/* --------------------------------------------------------------------------
194 Driver Interface 178 Driver Interface
195 -------------------------------------------------------------------------- */ 179 -------------------------------------------------------------------------- */
196 180
197static int 181static int acpi_fan_add(struct acpi_device *device)
198acpi_fan_add (
199 struct acpi_device *device)
200{ 182{
201 int result = 0; 183 int result = 0;
202 struct acpi_fan *fan = NULL; 184 struct acpi_fan *fan = NULL;
203 int state = 0; 185 int state = 0;
204 186
205 ACPI_FUNCTION_TRACE("acpi_fan_add"); 187 ACPI_FUNCTION_TRACE("acpi_fan_add");
206 188
@@ -213,14 +195,14 @@ acpi_fan_add (
213 memset(fan, 0, sizeof(struct acpi_fan)); 195 memset(fan, 0, sizeof(struct acpi_fan));
214 196
215 fan->handle = device->handle; 197 fan->handle = device->handle;
216 strcpy(acpi_device_name(device), ACPI_FAN_DEVICE_NAME); 198 strcpy(acpi_device_name(device), "Fan");
217 strcpy(acpi_device_class(device), ACPI_FAN_CLASS); 199 strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
218 acpi_driver_data(device) = fan; 200 acpi_driver_data(device) = fan;
219 201
220 result = acpi_bus_get_power(fan->handle, &state); 202 result = acpi_bus_get_power(fan->handle, &state);
221 if (result) { 203 if (result) {
222 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
223 "Error reading power state\n")); 205 "Error reading power state\n"));
224 goto end; 206 goto end;
225 } 207 }
226 208
@@ -229,30 +211,26 @@ acpi_fan_add (
229 goto end; 211 goto end;
230 212
231 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 213 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
232 acpi_device_name(device), acpi_device_bid(device), 214 acpi_device_name(device), acpi_device_bid(device),
233 !device->power.state?"on":"off"); 215 !device->power.state ? "on" : "off");
234 216
235end: 217 end:
236 if (result) 218 if (result)
237 kfree(fan); 219 kfree(fan);
238 220
239 return_VALUE(result); 221 return_VALUE(result);
240} 222}
241 223
242 224static int acpi_fan_remove(struct acpi_device *device, int type)
243static int
244acpi_fan_remove (
245 struct acpi_device *device,
246 int type)
247{ 225{
248 struct acpi_fan *fan = NULL; 226 struct acpi_fan *fan = NULL;
249 227
250 ACPI_FUNCTION_TRACE("acpi_fan_remove"); 228 ACPI_FUNCTION_TRACE("acpi_fan_remove");
251 229
252 if (!device || !acpi_driver_data(device)) 230 if (!device || !acpi_driver_data(device))
253 return_VALUE(-EINVAL); 231 return_VALUE(-EINVAL);
254 232
255 fan = (struct acpi_fan *) acpi_driver_data(device); 233 fan = (struct acpi_fan *)acpi_driver_data(device);
256 234
257 acpi_fan_remove_fs(device); 235 acpi_fan_remove_fs(device);
258 236
@@ -261,11 +239,9 @@ acpi_fan_remove (
261 return_VALUE(0); 239 return_VALUE(0);
262} 240}
263 241
264 242static int __init acpi_fan_init(void)
265static int __init
266acpi_fan_init (void)
267{ 243{
268 int result = 0; 244 int result = 0;
269 245
270 ACPI_FUNCTION_TRACE("acpi_fan_init"); 246 ACPI_FUNCTION_TRACE("acpi_fan_init");
271 247
@@ -283,9 +259,7 @@ acpi_fan_init (void)
283 return_VALUE(0); 259 return_VALUE(0);
284} 260}
285 261
286 262static void __exit acpi_fan_exit(void)
287static void __exit
288acpi_fan_exit (void)
289{ 263{
290 ACPI_FUNCTION_TRACE("acpi_fan_exit"); 264 ACPI_FUNCTION_TRACE("acpi_fan_exit");
291 265
@@ -296,7 +270,5 @@ acpi_fan_exit (void)
296 return_VOID; 270 return_VOID;
297} 271}
298 272
299
300module_init(acpi_fan_init); 273module_init(acpi_fan_init);
301module_exit(acpi_fan_exit); 274module_exit(acpi_fan_exit);
302
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 770cfc8b17e0..e36c5da2b31a 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -29,7 +29,8 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
29 down_write(&bus_type_sem); 29 down_write(&bus_type_sem);
30 list_add_tail(&type->list, &bus_type_list); 30 list_add_tail(&type->list, &bus_type_list);
31 up_write(&bus_type_sem); 31 up_write(&bus_type_sem);
32 printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name); 32 printk(KERN_INFO PREFIX "bus type %s registered\n",
33 type->bus->name);
33 return 0; 34 return 0;
34 } 35 }
35 return -ENODEV; 36 return -ENODEV;
@@ -45,7 +46,8 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type)
45 down_write(&bus_type_sem); 46 down_write(&bus_type_sem);
46 list_del_init(&type->list); 47 list_del_init(&type->list);
47 up_write(&bus_type_sem); 48 up_write(&bus_type_sem);
48 printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name); 49 printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n",
50 type->bus->name);
49 return 0; 51 return 0;
50 } 52 }
51 return -ENODEV; 53 return -ENODEV;
@@ -168,9 +170,6 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv)
168 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg); 170 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg);
169 if (status == AE_NOT_FOUND) { 171 if (status == AE_NOT_FOUND) {
170 /* Assume seg = 0 */ 172 /* Assume seg = 0 */
171 printk(KERN_INFO PREFIX
172 "Assume root bridge [%s] segment is 0\n",
173 (char *)buffer.pointer);
174 status = AE_OK; 173 status = AE_OK;
175 seg = 0; 174 seg = 0;
176 } 175 }
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index b51001e74eea..1bb3463d7040 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -42,13 +42,10 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47 46
48
49#define _COMPONENT ACPI_HARDWARE 47#define _COMPONENT ACPI_HARDWARE
50 ACPI_MODULE_NAME ("hwacpi") 48ACPI_MODULE_NAME("hwacpi")
51
52 49
53/****************************************************************************** 50/******************************************************************************
54 * 51 *
@@ -62,36 +59,30 @@
62 * the FADT. 59 * the FADT.
63 * 60 *
64 ******************************************************************************/ 61 ******************************************************************************/
65 62acpi_status acpi_hw_initialize(void)
66acpi_status
67acpi_hw_initialize (
68 void)
69{ 63{
70 acpi_status status; 64 acpi_status status;
71
72
73 ACPI_FUNCTION_TRACE ("hw_initialize");
74 65
66 ACPI_FUNCTION_TRACE("hw_initialize");
75 67
76 /* We must have the ACPI tables by the time we get here */ 68 /* We must have the ACPI tables by the time we get here */
77 69
78 if (!acpi_gbl_FADT) { 70 if (!acpi_gbl_FADT) {
79 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n")); 71 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n"));
80 72
81 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 73 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
82 } 74 }
83 75
84 /* Sanity check the FADT for valid values */ 76 /* Sanity check the FADT for valid values */
85 77
86 status = acpi_ut_validate_fadt (); 78 status = acpi_ut_validate_fadt();
87 if (ACPI_FAILURE (status)) { 79 if (ACPI_FAILURE(status)) {
88 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
89 } 81 }
90 82
91 return_ACPI_STATUS (AE_OK); 83 return_ACPI_STATUS(AE_OK);
92} 84}
93 85
94
95/****************************************************************************** 86/******************************************************************************
96 * 87 *
97 * FUNCTION: acpi_hw_set_mode 88 * FUNCTION: acpi_hw_set_mode
@@ -104,24 +95,21 @@ acpi_hw_initialize (
104 * 95 *
105 ******************************************************************************/ 96 ******************************************************************************/
106 97
107acpi_status 98acpi_status acpi_hw_set_mode(u32 mode)
108acpi_hw_set_mode (
109 u32 mode)
110{ 99{
111 100
112 acpi_status status; 101 acpi_status status;
113 u32 retry; 102 u32 retry;
114
115 103
116 ACPI_FUNCTION_TRACE ("hw_set_mode"); 104 ACPI_FUNCTION_TRACE("hw_set_mode");
117 105
118 /* 106 /*
119 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 107 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
120 * system does not support mode transition. 108 * system does not support mode transition.
121 */ 109 */
122 if (!acpi_gbl_FADT->smi_cmd) { 110 if (!acpi_gbl_FADT->smi_cmd) {
123 ACPI_REPORT_ERROR (("No SMI_CMD in FADT, mode transition failed.\n")); 111 ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n"));
124 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
125 } 113 }
126 114
127 /* 115 /*
@@ -132,9 +120,8 @@ acpi_hw_set_mode (
132 * transitions are not supported. 120 * transitions are not supported.
133 */ 121 */
134 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { 122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
135 ACPI_REPORT_ERROR (( 123 ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n"));
136 "No ACPI mode transition supported in this system (enable/disable both zero)\n")); 124 return_ACPI_STATUS(AE_OK);
137 return_ACPI_STATUS (AE_OK);
138 } 125 }
139 126
140 switch (mode) { 127 switch (mode) {
@@ -142,9 +129,11 @@ acpi_hw_set_mode (
142 129
143 /* BIOS should have disabled ALL fixed and GP events */ 130 /* BIOS should have disabled ALL fixed and GP events */
144 131
145 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 132 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
146 (u32) acpi_gbl_FADT->acpi_enable, 8); 133 (u32) acpi_gbl_FADT->acpi_enable,
147 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); 134 8);
135 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
136 "Attempting to enable ACPI mode\n"));
148 break; 137 break;
149 138
150 case ACPI_SYS_MODE_LEGACY: 139 case ACPI_SYS_MODE_LEGACY:
@@ -153,20 +142,21 @@ acpi_hw_set_mode (
153 * BIOS should clear all fixed status bits and restore fixed event 142 * BIOS should clear all fixed status bits and restore fixed event
154 * enable bits to default 143 * enable bits to default
155 */ 144 */
156 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 145 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
157 (u32) acpi_gbl_FADT->acpi_disable, 8); 146 (u32) acpi_gbl_FADT->acpi_disable,
158 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 147 8);
159 "Attempting to enable Legacy (non-ACPI) mode\n")); 148 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
149 "Attempting to enable Legacy (non-ACPI) mode\n"));
160 break; 150 break;
161 151
162 default: 152 default:
163 return_ACPI_STATUS (AE_BAD_PARAMETER); 153 return_ACPI_STATUS(AE_BAD_PARAMETER);
164 } 154 }
165 155
166 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
167 ACPI_REPORT_ERROR (("Could not write mode change, %s\n", 157 ACPI_REPORT_ERROR(("Could not write mode change, %s\n",
168 acpi_format_exception (status))); 158 acpi_format_exception(status)));
169 return_ACPI_STATUS (status); 159 return_ACPI_STATUS(status);
170 } 160 }
171 161
172 /* 162 /*
@@ -176,19 +166,19 @@ acpi_hw_set_mode (
176 retry = 3000; 166 retry = 3000;
177 while (retry) { 167 while (retry) {
178 if (acpi_hw_get_mode() == mode) { 168 if (acpi_hw_get_mode() == mode) {
179 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
180 mode)); 170 "Mode %X successfully enabled\n",
181 return_ACPI_STATUS (AE_OK); 171 mode));
172 return_ACPI_STATUS(AE_OK);
182 } 173 }
183 acpi_os_stall(1000); 174 acpi_os_stall(1000);
184 retry--; 175 retry--;
185 } 176 }
186 177
187 ACPI_REPORT_ERROR (("Hardware never changed modes\n")); 178 ACPI_REPORT_ERROR(("Hardware never changed modes\n"));
188 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 179 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
189} 180}
190 181
191
192/******************************************************************************* 182/*******************************************************************************
193 * 183 *
194 * FUNCTION: acpi_hw_get_mode 184 * FUNCTION: acpi_hw_get_mode
@@ -202,34 +192,30 @@ acpi_hw_set_mode (
202 * 192 *
203 ******************************************************************************/ 193 ******************************************************************************/
204 194
205u32 195u32 acpi_hw_get_mode(void)
206acpi_hw_get_mode (
207 void)
208{ 196{
209 acpi_status status; 197 acpi_status status;
210 u32 value; 198 u32 value;
211
212
213 ACPI_FUNCTION_TRACE ("hw_get_mode");
214 199
200 ACPI_FUNCTION_TRACE("hw_get_mode");
215 201
216 /* 202 /*
217 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 203 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
218 * system does not support mode transition. 204 * system does not support mode transition.
219 */ 205 */
220 if (!acpi_gbl_FADT->smi_cmd) { 206 if (!acpi_gbl_FADT->smi_cmd) {
221 return_VALUE (ACPI_SYS_MODE_ACPI); 207 return_VALUE(ACPI_SYS_MODE_ACPI);
222 } 208 }
223 209
224 status = acpi_get_register (ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 210 status =
225 if (ACPI_FAILURE (status)) { 211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
226 return_VALUE (ACPI_SYS_MODE_LEGACY); 212 if (ACPI_FAILURE(status)) {
213 return_VALUE(ACPI_SYS_MODE_LEGACY);
227 } 214 }
228 215
229 if (value) { 216 if (value) {
230 return_VALUE (ACPI_SYS_MODE_ACPI); 217 return_VALUE(ACPI_SYS_MODE_ACPI);
231 } 218 } else {
232 else { 219 return_VALUE(ACPI_SYS_MODE_LEGACY);
233 return_VALUE (ACPI_SYS_MODE_LEGACY);
234 } 220 }
235} 221}
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 8daeabb2fc7a..5c8e5dfd024e 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -46,15 +46,12 @@
46#include <acpi/acevents.h> 46#include <acpi/acevents.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwgpe") 49ACPI_MODULE_NAME("hwgpe")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52
53static acpi_status 52static acpi_status
54acpi_hw_enable_wakeup_gpe_block ( 53acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
55 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54 struct acpi_gpe_block_info *gpe_block);
56 struct acpi_gpe_block_info *gpe_block);
57
58 55
59/****************************************************************************** 56/******************************************************************************
60 * 57 *
@@ -71,15 +68,12 @@ acpi_hw_enable_wakeup_gpe_block (
71 ******************************************************************************/ 68 ******************************************************************************/
72 69
73acpi_status 70acpi_status
74acpi_hw_write_gpe_enable_reg ( 71acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info)
75 struct acpi_gpe_event_info *gpe_event_info)
76{ 72{
77 struct acpi_gpe_register_info *gpe_register_info; 73 struct acpi_gpe_register_info *gpe_register_info;
78 acpi_status status; 74 acpi_status status;
79
80
81 ACPI_FUNCTION_ENTRY ();
82 75
76 ACPI_FUNCTION_ENTRY();
83 77
84 /* Get the info block for the entire GPE register */ 78 /* Get the info block for the entire GPE register */
85 79
@@ -90,13 +84,12 @@ acpi_hw_write_gpe_enable_reg (
90 84
91 /* Write the entire GPE (runtime) enable register */ 85 /* Write the entire GPE (runtime) enable register */
92 86
93 status = acpi_hw_low_level_write (8, gpe_register_info->enable_for_run, 87 status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run,
94 &gpe_register_info->enable_address); 88 &gpe_register_info->enable_address);
95 89
96 return (status); 90 return (status);
97} 91}
98 92
99
100/****************************************************************************** 93/******************************************************************************
101 * 94 *
102 * FUNCTION: acpi_hw_clear_gpe 95 * FUNCTION: acpi_hw_clear_gpe
@@ -109,27 +102,23 @@ acpi_hw_write_gpe_enable_reg (
109 * 102 *
110 ******************************************************************************/ 103 ******************************************************************************/
111 104
112acpi_status 105acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
113acpi_hw_clear_gpe (
114 struct acpi_gpe_event_info *gpe_event_info)
115{ 106{
116 acpi_status status; 107 acpi_status status;
117
118
119 ACPI_FUNCTION_ENTRY ();
120 108
109 ACPI_FUNCTION_ENTRY();
121 110
122 /* 111 /*
123 * Write a one to the appropriate bit in the status register to 112 * Write a one to the appropriate bit in the status register to
124 * clear this GPE. 113 * clear this GPE.
125 */ 114 */
126 status = acpi_hw_low_level_write (8, gpe_event_info->register_bit, 115 status = acpi_hw_low_level_write(8, gpe_event_info->register_bit,
127 &gpe_event_info->register_info->status_address); 116 &gpe_event_info->register_info->
117 status_address);
128 118
129 return (status); 119 return (status);
130} 120}
131 121
132
133/****************************************************************************** 122/******************************************************************************
134 * 123 *
135 * FUNCTION: acpi_hw_get_gpe_status 124 * FUNCTION: acpi_hw_get_gpe_status
@@ -145,19 +134,16 @@ acpi_hw_clear_gpe (
145 134
146#ifdef ACPI_FUTURE_USAGE 135#ifdef ACPI_FUTURE_USAGE
147acpi_status 136acpi_status
148acpi_hw_get_gpe_status ( 137acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
149 struct acpi_gpe_event_info *gpe_event_info, 138 acpi_event_status * event_status)
150 acpi_event_status *event_status)
151{ 139{
152 u32 in_byte; 140 u32 in_byte;
153 u8 register_bit; 141 u8 register_bit;
154 struct acpi_gpe_register_info *gpe_register_info; 142 struct acpi_gpe_register_info *gpe_register_info;
155 acpi_status status; 143 acpi_status status;
156 acpi_event_status local_event_status = 0; 144 acpi_event_status local_event_status = 0;
157
158
159 ACPI_FUNCTION_ENTRY ();
160 145
146 ACPI_FUNCTION_ENTRY();
161 147
162 if (!event_status) { 148 if (!event_status) {
163 return (AE_BAD_PARAMETER); 149 return (AE_BAD_PARAMETER);
@@ -185,8 +171,10 @@ acpi_hw_get_gpe_status (
185 171
186 /* GPE currently active (status bit == 1)? */ 172 /* GPE currently active (status bit == 1)? */
187 173
188 status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address); 174 status =
189 if (ACPI_FAILURE (status)) { 175 acpi_hw_low_level_read(8, &in_byte,
176 &gpe_register_info->status_address);
177 if (ACPI_FAILURE(status)) {
190 goto unlock_and_exit; 178 goto unlock_and_exit;
191 } 179 }
192 180
@@ -198,12 +186,10 @@ acpi_hw_get_gpe_status (
198 186
199 (*event_status) = local_event_status; 187 (*event_status) = local_event_status;
200 188
201 189 unlock_and_exit:
202unlock_and_exit:
203 return (status); 190 return (status);
204} 191}
205#endif /* ACPI_FUTURE_USAGE */ 192#endif /* ACPI_FUTURE_USAGE */
206
207 193
208/****************************************************************************** 194/******************************************************************************
209 * 195 *
@@ -219,22 +205,21 @@ unlock_and_exit:
219 ******************************************************************************/ 205 ******************************************************************************/
220 206
221acpi_status 207acpi_status
222acpi_hw_disable_gpe_block ( 208acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
223 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 209 struct acpi_gpe_block_info * gpe_block)
224 struct acpi_gpe_block_info *gpe_block)
225{ 210{
226 u32 i; 211 u32 i;
227 acpi_status status; 212 acpi_status status;
228
229 213
230 /* Examine each GPE Register within the block */ 214 /* Examine each GPE Register within the block */
231 215
232 for (i = 0; i < gpe_block->register_count; i++) { 216 for (i = 0; i < gpe_block->register_count; i++) {
233 /* Disable all GPEs in this register */ 217 /* Disable all GPEs in this register */
234 218
235 status = acpi_hw_low_level_write (8, 0x00, 219 status = acpi_hw_low_level_write(8, 0x00,
236 &gpe_block->register_info[i].enable_address); 220 &gpe_block->register_info[i].
237 if (ACPI_FAILURE (status)) { 221 enable_address);
222 if (ACPI_FAILURE(status)) {
238 return (status); 223 return (status);
239 } 224 }
240 } 225 }
@@ -242,7 +227,6 @@ acpi_hw_disable_gpe_block (
242 return (AE_OK); 227 return (AE_OK);
243} 228}
244 229
245
246/****************************************************************************** 230/******************************************************************************
247 * 231 *
248 * FUNCTION: acpi_hw_clear_gpe_block 232 * FUNCTION: acpi_hw_clear_gpe_block
@@ -257,22 +241,21 @@ acpi_hw_disable_gpe_block (
257 ******************************************************************************/ 241 ******************************************************************************/
258 242
259acpi_status 243acpi_status
260acpi_hw_clear_gpe_block ( 244acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
261 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 245 struct acpi_gpe_block_info * gpe_block)
262 struct acpi_gpe_block_info *gpe_block)
263{ 246{
264 u32 i; 247 u32 i;
265 acpi_status status; 248 acpi_status status;
266
267 249
268 /* Examine each GPE Register within the block */ 250 /* Examine each GPE Register within the block */
269 251
270 for (i = 0; i < gpe_block->register_count; i++) { 252 for (i = 0; i < gpe_block->register_count; i++) {
271 /* Clear status on all GPEs in this register */ 253 /* Clear status on all GPEs in this register */
272 254
273 status = acpi_hw_low_level_write (8, 0xFF, 255 status = acpi_hw_low_level_write(8, 0xFF,
274 &gpe_block->register_info[i].status_address); 256 &gpe_block->register_info[i].
275 if (ACPI_FAILURE (status)) { 257 status_address);
258 if (ACPI_FAILURE(status)) {
276 return (status); 259 return (status);
277 } 260 }
278 } 261 }
@@ -280,7 +263,6 @@ acpi_hw_clear_gpe_block (
280 return (AE_OK); 263 return (AE_OK);
281} 264}
282 265
283
284/****************************************************************************** 266/******************************************************************************
285 * 267 *
286 * FUNCTION: acpi_hw_enable_runtime_gpe_block 268 * FUNCTION: acpi_hw_enable_runtime_gpe_block
@@ -296,13 +278,11 @@ acpi_hw_clear_gpe_block (
296 ******************************************************************************/ 278 ******************************************************************************/
297 279
298acpi_status 280acpi_status
299acpi_hw_enable_runtime_gpe_block ( 281acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
300 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 282 struct acpi_gpe_block_info * gpe_block)
301 struct acpi_gpe_block_info *gpe_block)
302{ 283{
303 u32 i; 284 u32 i;
304 acpi_status status; 285 acpi_status status;
305
306 286
307 /* NOTE: assumes that all GPEs are currently disabled */ 287 /* NOTE: assumes that all GPEs are currently disabled */
308 288
@@ -315,9 +295,13 @@ acpi_hw_enable_runtime_gpe_block (
315 295
316 /* Enable all "runtime" GPEs in this register */ 296 /* Enable all "runtime" GPEs in this register */
317 297
318 status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_run, 298 status =
319 &gpe_block->register_info[i].enable_address); 299 acpi_hw_low_level_write(8,
320 if (ACPI_FAILURE (status)) { 300 gpe_block->register_info[i].
301 enable_for_run,
302 &gpe_block->register_info[i].
303 enable_address);
304 if (ACPI_FAILURE(status)) {
321 return (status); 305 return (status);
322 } 306 }
323 } 307 }
@@ -325,7 +309,6 @@ acpi_hw_enable_runtime_gpe_block (
325 return (AE_OK); 309 return (AE_OK);
326} 310}
327 311
328
329/****************************************************************************** 312/******************************************************************************
330 * 313 *
331 * FUNCTION: acpi_hw_enable_wakeup_gpe_block 314 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
@@ -341,13 +324,11 @@ acpi_hw_enable_runtime_gpe_block (
341 ******************************************************************************/ 324 ******************************************************************************/
342 325
343static acpi_status 326static acpi_status
344acpi_hw_enable_wakeup_gpe_block ( 327acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
345 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 328 struct acpi_gpe_block_info *gpe_block)
346 struct acpi_gpe_block_info *gpe_block)
347{ 329{
348 u32 i; 330 u32 i;
349 acpi_status status; 331 acpi_status status;
350
351 332
352 /* Examine each GPE Register within the block */ 333 /* Examine each GPE Register within the block */
353 334
@@ -358,10 +339,12 @@ acpi_hw_enable_wakeup_gpe_block (
358 339
359 /* Enable all "wake" GPEs in this register */ 340 /* Enable all "wake" GPEs in this register */
360 341
361 status = acpi_hw_low_level_write (8, 342 status = acpi_hw_low_level_write(8,
362 gpe_block->register_info[i].enable_for_wake, 343 gpe_block->register_info[i].
363 &gpe_block->register_info[i].enable_address); 344 enable_for_wake,
364 if (ACPI_FAILURE (status)) { 345 &gpe_block->register_info[i].
346 enable_address);
347 if (ACPI_FAILURE(status)) {
365 return (status); 348 return (status);
366 } 349 }
367 } 350 }
@@ -369,12 +352,11 @@ acpi_hw_enable_wakeup_gpe_block (
369 return (AE_OK); 352 return (AE_OK);
370} 353}
371 354
372
373/****************************************************************************** 355/******************************************************************************
374 * 356 *
375 * FUNCTION: acpi_hw_disable_all_gpes 357 * FUNCTION: acpi_hw_disable_all_gpes
376 * 358 *
377 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 359 * PARAMETERS: None
378 * 360 *
379 * RETURN: Status 361 * RETURN: Status
380 * 362 *
@@ -382,27 +364,22 @@ acpi_hw_enable_wakeup_gpe_block (
382 * 364 *
383 ******************************************************************************/ 365 ******************************************************************************/
384 366
385acpi_status 367acpi_status acpi_hw_disable_all_gpes(void)
386acpi_hw_disable_all_gpes (
387 u32 flags)
388{ 368{
389 acpi_status status; 369 acpi_status status;
390
391 370
392 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); 371 ACPI_FUNCTION_TRACE("hw_disable_all_gpes");
393 372
394 373 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
395 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags); 374 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
396 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags); 375 return_ACPI_STATUS(status);
397 return_ACPI_STATUS (status);
398} 376}
399 377
400
401/****************************************************************************** 378/******************************************************************************
402 * 379 *
403 * FUNCTION: acpi_hw_enable_all_runtime_gpes 380 * FUNCTION: acpi_hw_enable_all_runtime_gpes
404 * 381 *
405 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 382 * PARAMETERS: None
406 * 383 *
407 * RETURN: Status 384 * RETURN: Status
408 * 385 *
@@ -410,26 +387,21 @@ acpi_hw_disable_all_gpes (
410 * 387 *
411 ******************************************************************************/ 388 ******************************************************************************/
412 389
413acpi_status 390acpi_status acpi_hw_enable_all_runtime_gpes(void)
414acpi_hw_enable_all_runtime_gpes (
415 u32 flags)
416{ 391{
417 acpi_status status; 392 acpi_status status;
418
419 393
420 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); 394 ACPI_FUNCTION_TRACE("hw_enable_all_runtime_gpes");
421 395
422 396 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block);
423 status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags); 397 return_ACPI_STATUS(status);
424 return_ACPI_STATUS (status);
425} 398}
426 399
427
428/****************************************************************************** 400/******************************************************************************
429 * 401 *
430 * FUNCTION: acpi_hw_enable_all_wakeup_gpes 402 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
431 * 403 *
432 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 404 * PARAMETERS: None
433 * 405 *
434 * RETURN: Status 406 * RETURN: Status
435 * 407 *
@@ -437,17 +409,12 @@ acpi_hw_enable_all_runtime_gpes (
437 * 409 *
438 ******************************************************************************/ 410 ******************************************************************************/
439 411
440acpi_status 412acpi_status acpi_hw_enable_all_wakeup_gpes(void)
441acpi_hw_enable_all_wakeup_gpes (
442 u32 flags)
443{ 413{
444 acpi_status status; 414 acpi_status status;
445
446 415
447 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); 416 ACPI_FUNCTION_TRACE("hw_enable_all_wakeup_gpes");
448 417
449 418 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block);
450 status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags); 419 return_ACPI_STATUS(status);
451 return_ACPI_STATUS (status);
452} 420}
453
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 6d9e4eb84836..536a7aea80c9 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -50,8 +50,7 @@
50#include <acpi/acevents.h> 50#include <acpi/acevents.h>
51 51
52#define _COMPONENT ACPI_HARDWARE 52#define _COMPONENT ACPI_HARDWARE
53 ACPI_MODULE_NAME ("hwregs") 53ACPI_MODULE_NAME("hwregs")
54
55 54
56/******************************************************************************* 55/*******************************************************************************
57 * 56 *
@@ -65,57 +64,52 @@
65 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 64 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
66 * 65 *
67 ******************************************************************************/ 66 ******************************************************************************/
68 67acpi_status acpi_hw_clear_acpi_status(u32 flags)
69acpi_status
70acpi_hw_clear_acpi_status (
71 u32 flags)
72{ 68{
73 acpi_status status; 69 acpi_status status;
74
75 70
76 ACPI_FUNCTION_TRACE ("hw_clear_acpi_status"); 71 ACPI_FUNCTION_TRACE("hw_clear_acpi_status");
77 72
78 73 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n",
79 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", 74 ACPI_BITMASK_ALL_FIXED_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS, 75 (u16) acpi_gbl_FADT->xpm1a_evt_blk.address));
81 (u16) acpi_gbl_FADT->xpm1a_evt_blk.address));
82 76
83 if (flags & ACPI_MTX_LOCK) { 77 if (flags & ACPI_MTX_LOCK) {
84 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 78 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
85 if (ACPI_FAILURE (status)) { 79 if (ACPI_FAILURE(status)) {
86 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
87 } 81 }
88 } 82 }
89 83
90 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 84 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
91 ACPI_REGISTER_PM1_STATUS, 85 ACPI_REGISTER_PM1_STATUS,
92 ACPI_BITMASK_ALL_FIXED_STATUS); 86 ACPI_BITMASK_ALL_FIXED_STATUS);
93 if (ACPI_FAILURE (status)) { 87 if (ACPI_FAILURE(status)) {
94 goto unlock_and_exit; 88 goto unlock_and_exit;
95 } 89 }
96 90
97 /* Clear the fixed events */ 91 /* Clear the fixed events */
98 92
99 if (acpi_gbl_FADT->xpm1b_evt_blk.address) { 93 if (acpi_gbl_FADT->xpm1b_evt_blk.address) {
100 status = acpi_hw_low_level_write (16, ACPI_BITMASK_ALL_FIXED_STATUS, 94 status =
101 &acpi_gbl_FADT->xpm1b_evt_blk); 95 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
102 if (ACPI_FAILURE (status)) { 96 &acpi_gbl_FADT->xpm1b_evt_blk);
97 if (ACPI_FAILURE(status)) {
103 goto unlock_and_exit; 98 goto unlock_and_exit;
104 } 99 }
105 } 100 }
106 101
107 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 102 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
108 103
109 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, ACPI_ISR); 104 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
110 105
111unlock_and_exit: 106 unlock_and_exit:
112 if (flags & ACPI_MTX_LOCK) { 107 if (flags & ACPI_MTX_LOCK) {
113 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 108 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
114 } 109 }
115 return_ACPI_STATUS (status); 110 return_ACPI_STATUS(status);
116} 111}
117 112
118
119/******************************************************************************* 113/*******************************************************************************
120 * 114 *
121 * FUNCTION: acpi_get_sleep_type_data 115 * FUNCTION: acpi_get_sleep_type_data
@@ -132,53 +126,48 @@ unlock_and_exit:
132 ******************************************************************************/ 126 ******************************************************************************/
133 127
134acpi_status 128acpi_status
135acpi_get_sleep_type_data ( 129acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
136 u8 sleep_state,
137 u8 *sleep_type_a,
138 u8 *sleep_type_b)
139{ 130{
140 acpi_status status = AE_OK; 131 acpi_status status = AE_OK;
141 struct acpi_parameter_info info; 132 struct acpi_parameter_info info;
142 char *sleep_state_name; 133 char *sleep_state_name;
143
144
145 ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
146 134
135 ACPI_FUNCTION_TRACE("acpi_get_sleep_type_data");
147 136
148 /* Validate parameters */ 137 /* Validate parameters */
149 138
150 if ((sleep_state > ACPI_S_STATES_MAX) || 139 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
151 !sleep_type_a || !sleep_type_b) { 140 return_ACPI_STATUS(AE_BAD_PARAMETER);
152 return_ACPI_STATUS (AE_BAD_PARAMETER);
153 } 141 }
154 142
155 /* Evaluate the namespace object containing the values for this state */ 143 /* Evaluate the namespace object containing the values for this state */
156 144
157 info.parameters = NULL; 145 info.parameters = NULL;
158 info.return_object = NULL; 146 info.return_object = NULL;
159 sleep_state_name = (char *) acpi_gbl_sleep_state_names[sleep_state]; 147 sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state];
160 148
161 status = acpi_ns_evaluate_by_name (sleep_state_name, &info); 149 status = acpi_ns_evaluate_by_name(sleep_state_name, &info);
162 if (ACPI_FAILURE (status)) { 150 if (ACPI_FAILURE(status)) {
163 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 151 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
164 "%s while evaluating sleep_state [%s]\n", 152 "%s while evaluating sleep_state [%s]\n",
165 acpi_format_exception (status), sleep_state_name)); 153 acpi_format_exception(status),
154 sleep_state_name));
166 155
167 return_ACPI_STATUS (status); 156 return_ACPI_STATUS(status);
168 } 157 }
169 158
170 /* Must have a return object */ 159 /* Must have a return object */
171 160
172 if (!info.return_object) { 161 if (!info.return_object) {
173 ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n", 162 ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n",
174 sleep_state_name)); 163 sleep_state_name));
175 status = AE_NOT_EXIST; 164 status = AE_NOT_EXIST;
176 } 165 }
177 166
178 /* It must be of type Package */ 167 /* It must be of type Package */
179 168
180 else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) { 169 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) {
181 ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n")); 170 ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n"));
182 status = AE_AML_OPERAND_TYPE; 171 status = AE_AML_OPERAND_TYPE;
183 } 172 }
184 173
@@ -190,45 +179,41 @@ acpi_get_sleep_type_data (
190 * one per sleep type (A/B). 179 * one per sleep type (A/B).
191 */ 180 */
192 else if (info.return_object->package.count < 2) { 181 else if (info.return_object->package.count < 2) {
193 ACPI_REPORT_ERROR (( 182 ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n"));
194 "Sleep State return package does not have at least two elements\n"));
195 status = AE_AML_NO_OPERAND; 183 status = AE_AML_NO_OPERAND;
196 } 184 }
197 185
198 /* The first two elements must both be of type Integer */ 186 /* The first two elements must both be of type Integer */
199 187
200 else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0]) 188 else if ((ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[0])
201 != ACPI_TYPE_INTEGER) || 189 != ACPI_TYPE_INTEGER) ||
202 (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1]) 190 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1])
203 != ACPI_TYPE_INTEGER)) { 191 != ACPI_TYPE_INTEGER)) {
204 ACPI_REPORT_ERROR (( 192 ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1])));
205 "Sleep State return package elements are not both Integers (%s, %s)\n",
206 acpi_ut_get_object_type_name (info.return_object->package.elements[0]),
207 acpi_ut_get_object_type_name (info.return_object->package.elements[1])));
208 status = AE_AML_OPERAND_TYPE; 193 status = AE_AML_OPERAND_TYPE;
209 } 194 } else {
210 else {
211 /* Valid _Sx_ package size, type, and value */ 195 /* Valid _Sx_ package size, type, and value */
212 196
213 *sleep_type_a = (u8) 197 *sleep_type_a = (u8)
214 (info.return_object->package.elements[0])->integer.value; 198 (info.return_object->package.elements[0])->integer.value;
215 *sleep_type_b = (u8) 199 *sleep_type_b = (u8)
216 (info.return_object->package.elements[1])->integer.value; 200 (info.return_object->package.elements[1])->integer.value;
217 } 201 }
218 202
219 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE(status)) {
220 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
221 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", 205 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
222 acpi_format_exception (status), 206 acpi_format_exception(status),
223 sleep_state_name, info.return_object, 207 sleep_state_name, info.return_object,
224 acpi_ut_get_object_type_name (info.return_object))); 208 acpi_ut_get_object_type_name(info.
209 return_object)));
225 } 210 }
226 211
227 acpi_ut_remove_reference (info.return_object); 212 acpi_ut_remove_reference(info.return_object);
228 return_ACPI_STATUS (status); 213 return_ACPI_STATUS(status);
229} 214}
230EXPORT_SYMBOL(acpi_get_sleep_type_data);
231 215
216EXPORT_SYMBOL(acpi_get_sleep_type_data);
232 217
233/******************************************************************************* 218/*******************************************************************************
234 * 219 *
@@ -242,22 +227,20 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
242 * 227 *
243 ******************************************************************************/ 228 ******************************************************************************/
244 229
245struct acpi_bit_register_info * 230struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
246acpi_hw_get_bit_register_info (
247 u32 register_id)
248{ 231{
249 ACPI_FUNCTION_NAME ("hw_get_bit_register_info"); 232 ACPI_FUNCTION_NAME("hw_get_bit_register_info");
250
251 233
252 if (register_id > ACPI_BITREG_MAX) { 234 if (register_id > ACPI_BITREG_MAX) {
253 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid bit_register ID: %X\n", register_id)); 235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
236 "Invalid bit_register ID: %X\n",
237 register_id));
254 return (NULL); 238 return (NULL);
255 } 239 }
256 240
257 return (&acpi_gbl_bit_register_info[register_id]); 241 return (&acpi_gbl_bit_register_info[register_id]);
258} 242}
259 243
260
261/******************************************************************************* 244/*******************************************************************************
262 * 245 *
263 * FUNCTION: acpi_get_register 246 * FUNCTION: acpi_get_register
@@ -273,59 +256,56 @@ acpi_hw_get_bit_register_info (
273 * 256 *
274 ******************************************************************************/ 257 ******************************************************************************/
275 258
276acpi_status 259acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags)
277acpi_get_register (
278 u32 register_id,
279 u32 *return_value,
280 u32 flags)
281{ 260{
282 u32 register_value = 0; 261 u32 register_value = 0;
283 struct acpi_bit_register_info *bit_reg_info; 262 struct acpi_bit_register_info *bit_reg_info;
284 acpi_status status; 263 acpi_status status;
285
286
287 ACPI_FUNCTION_TRACE ("acpi_get_register");
288 264
265 ACPI_FUNCTION_TRACE("acpi_get_register");
289 266
290 /* Get the info structure corresponding to the requested ACPI Register */ 267 /* Get the info structure corresponding to the requested ACPI Register */
291 268
292 bit_reg_info = acpi_hw_get_bit_register_info (register_id); 269 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
293 if (!bit_reg_info) { 270 if (!bit_reg_info) {
294 return_ACPI_STATUS (AE_BAD_PARAMETER); 271 return_ACPI_STATUS(AE_BAD_PARAMETER);
295 } 272 }
296 273
297 if (flags & ACPI_MTX_LOCK) { 274 if (flags & ACPI_MTX_LOCK) {
298 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 275 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
299 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE(status)) {
300 return_ACPI_STATUS (status); 277 return_ACPI_STATUS(status);
301 } 278 }
302 } 279 }
303 280
304 /* Read from the register */ 281 /* Read from the register */
305 282
306 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 283 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
307 bit_reg_info->parent_register, &register_value); 284 bit_reg_info->parent_register,
285 &register_value);
308 286
309 if (flags & ACPI_MTX_LOCK) { 287 if (flags & ACPI_MTX_LOCK) {
310 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 288 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
311 } 289 }
312 290
313 if (ACPI_SUCCESS (status)) { 291 if (ACPI_SUCCESS(status)) {
314 /* Normalize the value that was read */ 292 /* Normalize the value that was read */
315 293
316 register_value = ((register_value & bit_reg_info->access_bit_mask) 294 register_value =
317 >> bit_reg_info->bit_position); 295 ((register_value & bit_reg_info->access_bit_mask)
296 >> bit_reg_info->bit_position);
318 297
319 *return_value = register_value; 298 *return_value = register_value;
320 299
321 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", 300 ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n",
322 register_value, bit_reg_info->parent_register)); 301 register_value,
302 bit_reg_info->parent_register));
323 } 303 }
324 304
325 return_ACPI_STATUS (status); 305 return_ACPI_STATUS(status);
326} 306}
327EXPORT_SYMBOL(acpi_get_register);
328 307
308EXPORT_SYMBOL(acpi_get_register);
329 309
330/******************************************************************************* 310/*******************************************************************************
331 * 311 *
@@ -342,40 +322,36 @@ EXPORT_SYMBOL(acpi_get_register);
342 * 322 *
343 ******************************************************************************/ 323 ******************************************************************************/
344 324
345acpi_status 325acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
346acpi_set_register (
347 u32 register_id,
348 u32 value,
349 u32 flags)
350{ 326{
351 u32 register_value = 0; 327 u32 register_value = 0;
352 struct acpi_bit_register_info *bit_reg_info; 328 struct acpi_bit_register_info *bit_reg_info;
353 acpi_status status; 329 acpi_status status;
354
355
356 ACPI_FUNCTION_TRACE_U32 ("acpi_set_register", register_id);
357 330
331 ACPI_FUNCTION_TRACE_U32("acpi_set_register", register_id);
358 332
359 /* Get the info structure corresponding to the requested ACPI Register */ 333 /* Get the info structure corresponding to the requested ACPI Register */
360 334
361 bit_reg_info = acpi_hw_get_bit_register_info (register_id); 335 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
362 if (!bit_reg_info) { 336 if (!bit_reg_info) {
363 ACPI_REPORT_ERROR (("Bad ACPI HW register_id: %X\n", register_id)); 337 ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n",
364 return_ACPI_STATUS (AE_BAD_PARAMETER); 338 register_id));
339 return_ACPI_STATUS(AE_BAD_PARAMETER);
365 } 340 }
366 341
367 if (flags & ACPI_MTX_LOCK) { 342 if (flags & ACPI_MTX_LOCK) {
368 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 343 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
369 if (ACPI_FAILURE (status)) { 344 if (ACPI_FAILURE(status)) {
370 return_ACPI_STATUS (status); 345 return_ACPI_STATUS(status);
371 } 346 }
372 } 347 }
373 348
374 /* Always do a register read first so we can insert the new bits */ 349 /* Always do a register read first so we can insert the new bits */
375 350
376 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 351 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
377 bit_reg_info->parent_register, &register_value); 352 bit_reg_info->parent_register,
378 if (ACPI_FAILURE (status)) { 353 &register_value);
354 if (ACPI_FAILURE(status)) {
379 goto unlock_and_exit; 355 goto unlock_and_exit;
380 } 356 }
381 357
@@ -395,26 +371,30 @@ acpi_set_register (
395 * information is the single bit we're interested in, all others should 371 * information is the single bit we're interested in, all others should
396 * be written as 0 so they will be left unchanged. 372 * be written as 0 so they will be left unchanged.
397 */ 373 */
398 value = ACPI_REGISTER_PREPARE_BITS (value, 374 value = ACPI_REGISTER_PREPARE_BITS(value,
399 bit_reg_info->bit_position, bit_reg_info->access_bit_mask); 375 bit_reg_info->bit_position,
376 bit_reg_info->
377 access_bit_mask);
400 if (value) { 378 if (value) {
401 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 379 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
402 ACPI_REGISTER_PM1_STATUS, (u16) value); 380 ACPI_REGISTER_PM1_STATUS,
381 (u16) value);
403 register_value = 0; 382 register_value = 0;
404 } 383 }
405 break; 384 break;
406 385
407
408 case ACPI_REGISTER_PM1_ENABLE: 386 case ACPI_REGISTER_PM1_ENABLE:
409 387
410 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 388 ACPI_REGISTER_INSERT_VALUE(register_value,
411 bit_reg_info->access_bit_mask, value); 389 bit_reg_info->bit_position,
390 bit_reg_info->access_bit_mask,
391 value);
412 392
413 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 393 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
414 ACPI_REGISTER_PM1_ENABLE, (u16) register_value); 394 ACPI_REGISTER_PM1_ENABLE,
395 (u16) register_value);
415 break; 396 break;
416 397
417
418 case ACPI_REGISTER_PM1_CONTROL: 398 case ACPI_REGISTER_PM1_CONTROL:
419 399
420 /* 400 /*
@@ -422,65 +402,73 @@ acpi_set_register (
422 * Note that at this level, the fact that there are actually TWO 402 * Note that at this level, the fact that there are actually TWO
423 * registers (A and B - and B may not exist) is abstracted. 403 * registers (A and B - and B may not exist) is abstracted.
424 */ 404 */
425 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", register_value)); 405 ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n",
406 register_value));
426 407
427 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 408 ACPI_REGISTER_INSERT_VALUE(register_value,
428 bit_reg_info->access_bit_mask, value); 409 bit_reg_info->bit_position,
410 bit_reg_info->access_bit_mask,
411 value);
429 412
430 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 413 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
431 ACPI_REGISTER_PM1_CONTROL, (u16) register_value); 414 ACPI_REGISTER_PM1_CONTROL,
415 (u16) register_value);
432 break; 416 break;
433 417
434
435 case ACPI_REGISTER_PM2_CONTROL: 418 case ACPI_REGISTER_PM2_CONTROL:
436 419
437 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 420 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
438 ACPI_REGISTER_PM2_CONTROL, &register_value); 421 ACPI_REGISTER_PM2_CONTROL,
439 if (ACPI_FAILURE (status)) { 422 &register_value);
423 if (ACPI_FAILURE(status)) {
440 goto unlock_and_exit; 424 goto unlock_and_exit;
441 } 425 }
442 426
443 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", 427 ACPI_DEBUG_PRINT((ACPI_DB_IO,
444 register_value, 428 "PM2 control: Read %X from %8.8X%8.8X\n",
445 ACPI_FORMAT_UINT64 ( 429 register_value,
446 acpi_gbl_FADT->xpm2_cnt_blk.address))); 430 ACPI_FORMAT_UINT64(acpi_gbl_FADT->
447 431 xpm2_cnt_blk.address)));
448 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 432
449 bit_reg_info->access_bit_mask, value); 433 ACPI_REGISTER_INSERT_VALUE(register_value,
450 434 bit_reg_info->bit_position,
451 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", 435 bit_reg_info->access_bit_mask,
452 register_value, 436 value);
453 ACPI_FORMAT_UINT64 ( 437
454 acpi_gbl_FADT->xpm2_cnt_blk.address))); 438 ACPI_DEBUG_PRINT((ACPI_DB_IO,
455 439 "About to write %4.4X to %8.8X%8.8X\n",
456 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 440 register_value,
457 ACPI_REGISTER_PM2_CONTROL, (u8) (register_value)); 441 ACPI_FORMAT_UINT64(acpi_gbl_FADT->
442 xpm2_cnt_blk.address)));
443
444 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
445 ACPI_REGISTER_PM2_CONTROL,
446 (u8) (register_value));
458 break; 447 break;
459 448
460
461 default: 449 default:
462 break; 450 break;
463 } 451 }
464 452
465 453 unlock_and_exit:
466unlock_and_exit:
467 454
468 if (flags & ACPI_MTX_LOCK) { 455 if (flags & ACPI_MTX_LOCK) {
469 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 456 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
470 } 457 }
471 458
472 /* Normalize the value that was read */ 459 /* Normalize the value that was read */
473 460
474 ACPI_DEBUG_EXEC (register_value = 461 ACPI_DEBUG_EXEC(register_value =
475 ((register_value & bit_reg_info->access_bit_mask) >> 462 ((register_value & bit_reg_info->access_bit_mask) >>
476 bit_reg_info->bit_position)); 463 bit_reg_info->bit_position));
477 464
478 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", 465 ACPI_DEBUG_PRINT((ACPI_DB_IO,
479 value, register_value, bit_reg_info->parent_register)); 466 "Set bits: %8.8X actual %8.8X register %X\n", value,
480 return_ACPI_STATUS (status); 467 register_value, bit_reg_info->parent_register));
468 return_ACPI_STATUS(status);
481} 469}
482EXPORT_SYMBOL(acpi_set_register);
483 470
471EXPORT_SYMBOL(acpi_set_register);
484 472
485/****************************************************************************** 473/******************************************************************************
486 * 474 *
@@ -498,103 +486,107 @@ EXPORT_SYMBOL(acpi_set_register);
498 ******************************************************************************/ 486 ******************************************************************************/
499 487
500acpi_status 488acpi_status
501acpi_hw_register_read ( 489acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
502 u8 use_lock,
503 u32 register_id,
504 u32 *return_value)
505{ 490{
506 u32 value1 = 0; 491 u32 value1 = 0;
507 u32 value2 = 0; 492 u32 value2 = 0;
508 acpi_status status; 493 acpi_status status;
509
510
511 ACPI_FUNCTION_TRACE ("hw_register_read");
512 494
495 ACPI_FUNCTION_TRACE("hw_register_read");
513 496
514 if (ACPI_MTX_LOCK == use_lock) { 497 if (ACPI_MTX_LOCK == use_lock) {
515 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 498 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
516 if (ACPI_FAILURE (status)) { 499 if (ACPI_FAILURE(status)) {
517 return_ACPI_STATUS (status); 500 return_ACPI_STATUS(status);
518 } 501 }
519 } 502 }
520 503
521 switch (register_id) { 504 switch (register_id) {
522 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 505 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
523 506
524 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_evt_blk); 507 status =
525 if (ACPI_FAILURE (status)) { 508 acpi_hw_low_level_read(16, &value1,
509 &acpi_gbl_FADT->xpm1a_evt_blk);
510 if (ACPI_FAILURE(status)) {
526 goto unlock_and_exit; 511 goto unlock_and_exit;
527 } 512 }
528 513
529 /* PM1B is optional */ 514 /* PM1B is optional */
530 515
531 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_evt_blk); 516 status =
517 acpi_hw_low_level_read(16, &value2,
518 &acpi_gbl_FADT->xpm1b_evt_blk);
532 value1 |= value2; 519 value1 |= value2;
533 break; 520 break;
534 521
522 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
535 523
536 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 524 status =
537 525 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
538 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_xpm1a_enable); 526 if (ACPI_FAILURE(status)) {
539 if (ACPI_FAILURE (status)) {
540 goto unlock_and_exit; 527 goto unlock_and_exit;
541 } 528 }
542 529
543 /* PM1B is optional */ 530 /* PM1B is optional */
544 531
545 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_xpm1b_enable); 532 status =
533 acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
546 value1 |= value2; 534 value1 |= value2;
547 break; 535 break;
548 536
537 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
549 538
550 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 539 status =
551 540 acpi_hw_low_level_read(16, &value1,
552 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_cnt_blk); 541 &acpi_gbl_FADT->xpm1a_cnt_blk);
553 if (ACPI_FAILURE (status)) { 542 if (ACPI_FAILURE(status)) {
554 goto unlock_and_exit; 543 goto unlock_and_exit;
555 } 544 }
556 545
557 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_cnt_blk); 546 status =
547 acpi_hw_low_level_read(16, &value2,
548 &acpi_gbl_FADT->xpm1b_cnt_blk);
558 value1 |= value2; 549 value1 |= value2;
559 break; 550 break;
560 551
552 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
561 553
562 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 554 status =
563 555 acpi_hw_low_level_read(8, &value1,
564 status = acpi_hw_low_level_read (8, &value1, &acpi_gbl_FADT->xpm2_cnt_blk); 556 &acpi_gbl_FADT->xpm2_cnt_blk);
565 break; 557 break;
566 558
559 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
567 560
568 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 561 status =
569 562 acpi_hw_low_level_read(32, &value1,
570 status = acpi_hw_low_level_read (32, &value1, &acpi_gbl_FADT->xpm_tmr_blk); 563 &acpi_gbl_FADT->xpm_tmr_blk);
571 break; 564 break;
572 565
573 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 566 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
574 567
575 status = acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value1, 8); 568 status = acpi_os_read_port(acpi_gbl_FADT->smi_cmd, &value1, 8);
576 break; 569 break;
577 570
578 default: 571 default:
579 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", 572 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n",
580 register_id)); 573 register_id));
581 status = AE_BAD_PARAMETER; 574 status = AE_BAD_PARAMETER;
582 break; 575 break;
583 } 576 }
584 577
585unlock_and_exit: 578 unlock_and_exit:
586 if (ACPI_MTX_LOCK == use_lock) { 579 if (ACPI_MTX_LOCK == use_lock) {
587 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 580 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
588 } 581 }
589 582
590 if (ACPI_SUCCESS (status)) { 583 if (ACPI_SUCCESS(status)) {
591 *return_value = value1; 584 *return_value = value1;
592 } 585 }
593 586
594 return_ACPI_STATUS (status); 587 return_ACPI_STATUS(status);
595} 588}
596 589
597
598/****************************************************************************** 590/******************************************************************************
599 * 591 *
600 * FUNCTION: acpi_hw_register_write 592 * FUNCTION: acpi_hw_register_write
@@ -610,109 +602,112 @@ unlock_and_exit:
610 * 602 *
611 ******************************************************************************/ 603 ******************************************************************************/
612 604
613acpi_status 605acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
614acpi_hw_register_write (
615 u8 use_lock,
616 u32 register_id,
617 u32 value)
618{ 606{
619 acpi_status status; 607 acpi_status status;
620
621
622 ACPI_FUNCTION_TRACE ("hw_register_write");
623 608
609 ACPI_FUNCTION_TRACE("hw_register_write");
624 610
625 if (ACPI_MTX_LOCK == use_lock) { 611 if (ACPI_MTX_LOCK == use_lock) {
626 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 612 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
627 if (ACPI_FAILURE (status)) { 613 if (ACPI_FAILURE(status)) {
628 return_ACPI_STATUS (status); 614 return_ACPI_STATUS(status);
629 } 615 }
630 } 616 }
631 617
632 switch (register_id) { 618 switch (register_id) {
633 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 619 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
634 620
635 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_evt_blk); 621 status =
636 if (ACPI_FAILURE (status)) { 622 acpi_hw_low_level_write(16, value,
623 &acpi_gbl_FADT->xpm1a_evt_blk);
624 if (ACPI_FAILURE(status)) {
637 goto unlock_and_exit; 625 goto unlock_and_exit;
638 } 626 }
639 627
640 /* PM1B is optional */ 628 /* PM1B is optional */
641 629
642 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_evt_blk); 630 status =
631 acpi_hw_low_level_write(16, value,
632 &acpi_gbl_FADT->xpm1b_evt_blk);
643 break; 633 break;
644 634
635 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
645 636
646 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ 637 status =
647 638 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
648 status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1a_enable); 639 if (ACPI_FAILURE(status)) {
649 if (ACPI_FAILURE (status)) {
650 goto unlock_and_exit; 640 goto unlock_and_exit;
651 } 641 }
652 642
653 /* PM1B is optional */ 643 /* PM1B is optional */
654 644
655 status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1b_enable); 645 status =
646 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
656 break; 647 break;
657 648
649 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
658 650
659 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 651 status =
660 652 acpi_hw_low_level_write(16, value,
661 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); 653 &acpi_gbl_FADT->xpm1a_cnt_blk);
662 if (ACPI_FAILURE (status)) { 654 if (ACPI_FAILURE(status)) {
663 goto unlock_and_exit; 655 goto unlock_and_exit;
664 } 656 }
665 657
666 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); 658 status =
659 acpi_hw_low_level_write(16, value,
660 &acpi_gbl_FADT->xpm1b_cnt_blk);
667 break; 661 break;
668 662
663 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
669 664
670 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 665 status =
671 666 acpi_hw_low_level_write(16, value,
672 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); 667 &acpi_gbl_FADT->xpm1a_cnt_blk);
673 break; 668 break;
674 669
670 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
675 671
676 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 672 status =
677 673 acpi_hw_low_level_write(16, value,
678 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); 674 &acpi_gbl_FADT->xpm1b_cnt_blk);
679 break; 675 break;
680 676
677 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
681 678
682 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 679 status =
683 680 acpi_hw_low_level_write(8, value,
684 status = acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->xpm2_cnt_blk); 681 &acpi_gbl_FADT->xpm2_cnt_blk);
685 break; 682 break;
686 683
684 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
687 685
688 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 686 status =
689 687 acpi_hw_low_level_write(32, value,
690 status = acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->xpm_tmr_blk); 688 &acpi_gbl_FADT->xpm_tmr_blk);
691 break; 689 break;
692 690
693 691 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
694 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
695 692
696 /* SMI_CMD is currently always in IO space */ 693 /* SMI_CMD is currently always in IO space */
697 694
698 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8); 695 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, value, 8);
699 break; 696 break;
700 697
701
702 default: 698 default:
703 status = AE_BAD_PARAMETER; 699 status = AE_BAD_PARAMETER;
704 break; 700 break;
705 } 701 }
706 702
707unlock_and_exit: 703 unlock_and_exit:
708 if (ACPI_MTX_LOCK == use_lock) { 704 if (ACPI_MTX_LOCK == use_lock) {
709 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 705 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
710 } 706 }
711 707
712 return_ACPI_STATUS (status); 708 return_ACPI_STATUS(status);
713} 709}
714 710
715
716/****************************************************************************** 711/******************************************************************************
717 * 712 *
718 * FUNCTION: acpi_hw_low_level_read 713 * FUNCTION: acpi_hw_low_level_read
@@ -728,17 +723,12 @@ unlock_and_exit:
728 ******************************************************************************/ 723 ******************************************************************************/
729 724
730acpi_status 725acpi_status
731acpi_hw_low_level_read ( 726acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
732 u32 width,
733 u32 *value,
734 struct acpi_generic_address *reg)
735{ 727{
736 u64 address; 728 u64 address;
737 acpi_status status; 729 acpi_status status;
738
739
740 ACPI_FUNCTION_NAME ("hw_low_level_read");
741 730
731 ACPI_FUNCTION_NAME("hw_low_level_read");
742 732
743 /* 733 /*
744 * Must have a valid pointer to a GAS structure, and 734 * Must have a valid pointer to a GAS structure, and
@@ -751,7 +741,7 @@ acpi_hw_low_level_read (
751 741
752 /* Get a local copy of the address. Handles possible alignment issues */ 742 /* Get a local copy of the address. Handles possible alignment issues */
753 743
754 ACPI_MOVE_64_TO_64 (&address, &reg->address); 744 ACPI_MOVE_64_TO_64(&address, &reg->address);
755 if (!address) { 745 if (!address) {
756 return (AE_OK); 746 return (AE_OK);
757 } 747 }
@@ -764,35 +754,32 @@ acpi_hw_low_level_read (
764 switch (reg->address_space_id) { 754 switch (reg->address_space_id) {
765 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 755 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
766 756
767 status = acpi_os_read_memory ( 757 status = acpi_os_read_memory((acpi_physical_address) address,
768 (acpi_physical_address) address, 758 value, width);
769 value, width);
770 break; 759 break;
771 760
772
773 case ACPI_ADR_SPACE_SYSTEM_IO: 761 case ACPI_ADR_SPACE_SYSTEM_IO:
774 762
775 status = acpi_os_read_port ((acpi_io_address) address, 763 status = acpi_os_read_port((acpi_io_address) address,
776 value, width); 764 value, width);
777 break; 765 break;
778 766
779
780 default: 767 default:
781 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 768 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
782 "Unsupported address space: %X\n", reg->address_space_id)); 769 "Unsupported address space: %X\n",
770 reg->address_space_id));
783 return (AE_BAD_PARAMETER); 771 return (AE_BAD_PARAMETER);
784 } 772 }
785 773
786 ACPI_DEBUG_PRINT ((ACPI_DB_IO, 774 ACPI_DEBUG_PRINT((ACPI_DB_IO,
787 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 775 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
788 *value, width, 776 *value, width,
789 ACPI_FORMAT_UINT64 (address), 777 ACPI_FORMAT_UINT64(address),
790 acpi_ut_get_region_name (reg->address_space_id))); 778 acpi_ut_get_region_name(reg->address_space_id)));
791 779
792 return (status); 780 return (status);
793} 781}
794 782
795
796/****************************************************************************** 783/******************************************************************************
797 * 784 *
798 * FUNCTION: acpi_hw_low_level_write 785 * FUNCTION: acpi_hw_low_level_write
@@ -808,17 +795,12 @@ acpi_hw_low_level_read (
808 ******************************************************************************/ 795 ******************************************************************************/
809 796
810acpi_status 797acpi_status
811acpi_hw_low_level_write ( 798acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
812 u32 width,
813 u32 value,
814 struct acpi_generic_address *reg)
815{ 799{
816 u64 address; 800 u64 address;
817 acpi_status status; 801 acpi_status status;
818
819
820 ACPI_FUNCTION_NAME ("hw_low_level_write");
821 802
803 ACPI_FUNCTION_NAME("hw_low_level_write");
822 804
823 /* 805 /*
824 * Must have a valid pointer to a GAS structure, and 806 * Must have a valid pointer to a GAS structure, and
@@ -831,7 +813,7 @@ acpi_hw_low_level_write (
831 813
832 /* Get a local copy of the address. Handles possible alignment issues */ 814 /* Get a local copy of the address. Handles possible alignment issues */
833 815
834 ACPI_MOVE_64_TO_64 (&address, &reg->address); 816 ACPI_MOVE_64_TO_64(&address, &reg->address);
835 if (!address) { 817 if (!address) {
836 return (AE_OK); 818 return (AE_OK);
837 } 819 }
@@ -843,30 +825,28 @@ acpi_hw_low_level_write (
843 switch (reg->address_space_id) { 825 switch (reg->address_space_id) {
844 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 826 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
845 827
846 status = acpi_os_write_memory ( 828 status = acpi_os_write_memory((acpi_physical_address) address,
847 (acpi_physical_address) address, 829 value, width);
848 value, width);
849 break; 830 break;
850 831
851
852 case ACPI_ADR_SPACE_SYSTEM_IO: 832 case ACPI_ADR_SPACE_SYSTEM_IO:
853 833
854 status = acpi_os_write_port ((acpi_io_address) address, 834 status = acpi_os_write_port((acpi_io_address) address,
855 value, width); 835 value, width);
856 break; 836 break;
857 837
858
859 default: 838 default:
860 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
861 "Unsupported address space: %X\n", reg->address_space_id)); 840 "Unsupported address space: %X\n",
841 reg->address_space_id));
862 return (AE_BAD_PARAMETER); 842 return (AE_BAD_PARAMETER);
863 } 843 }
864 844
865 ACPI_DEBUG_PRINT ((ACPI_DB_IO, 845 ACPI_DEBUG_PRINT((ACPI_DB_IO,
866 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 846 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
867 value, width, 847 value, width,
868 ACPI_FORMAT_UINT64 (address), 848 ACPI_FORMAT_UINT64(address),
869 acpi_ut_get_region_name (reg->address_space_id))); 849 acpi_ut_get_region_name(reg->address_space_id)));
870 850
871 return (status); 851 return (status);
872} 852}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 415d342aeab5..34519069050c 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -46,8 +46,7 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwsleep") 49ACPI_MODULE_NAME("hwsleep")
50
51 50
52/******************************************************************************* 51/*******************************************************************************
53 * 52 *
@@ -61,30 +60,25 @@
61 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
62 * 61 *
63 ******************************************************************************/ 62 ******************************************************************************/
64
65acpi_status 63acpi_status
66acpi_set_firmware_waking_vector ( 64acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
67 acpi_physical_address physical_address)
68{ 65{
69 66
70 ACPI_FUNCTION_TRACE ("acpi_set_firmware_waking_vector"); 67 ACPI_FUNCTION_TRACE("acpi_set_firmware_waking_vector");
71
72 68
73 /* Set the vector */ 69 /* Set the vector */
74 70
75 if (acpi_gbl_common_fACS.vector_width == 32) { 71 if (acpi_gbl_common_fACS.vector_width == 32) {
76 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)) 72 *(ACPI_CAST_PTR
77 = (u32) physical_address; 73 (u32, acpi_gbl_common_fACS.firmware_waking_vector))
78 } 74 = (u32) physical_address;
79 else { 75 } else {
80 *acpi_gbl_common_fACS.firmware_waking_vector 76 *acpi_gbl_common_fACS.firmware_waking_vector = physical_address;
81 = physical_address;
82 } 77 }
83 78
84 return_ACPI_STATUS (AE_OK); 79 return_ACPI_STATUS(AE_OK);
85} 80}
86 81
87
88/******************************************************************************* 82/*******************************************************************************
89 * 83 *
90 * FUNCTION: acpi_get_firmware_waking_vector 84 * FUNCTION: acpi_get_firmware_waking_vector
@@ -101,33 +95,31 @@ acpi_set_firmware_waking_vector (
101 95
102#ifdef ACPI_FUTURE_USAGE 96#ifdef ACPI_FUTURE_USAGE
103acpi_status 97acpi_status
104acpi_get_firmware_waking_vector ( 98acpi_get_firmware_waking_vector(acpi_physical_address * physical_address)
105 acpi_physical_address *physical_address)
106{ 99{
107 100
108 ACPI_FUNCTION_TRACE ("acpi_get_firmware_waking_vector"); 101 ACPI_FUNCTION_TRACE("acpi_get_firmware_waking_vector");
109
110 102
111 if (!physical_address) { 103 if (!physical_address) {
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 105 }
114 106
115 /* Get the vector */ 107 /* Get the vector */
116 108
117 if (acpi_gbl_common_fACS.vector_width == 32) { 109 if (acpi_gbl_common_fACS.vector_width == 32) {
118 *physical_address = (acpi_physical_address) 110 *physical_address = (acpi_physical_address)
119 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)); 111 *
120 } 112 (ACPI_CAST_PTR
121 else { 113 (u32, acpi_gbl_common_fACS.firmware_waking_vector));
114 } else {
122 *physical_address = 115 *physical_address =
123 *acpi_gbl_common_fACS.firmware_waking_vector; 116 *acpi_gbl_common_fACS.firmware_waking_vector;
124 } 117 }
125 118
126 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
127} 120}
128#endif 121#endif
129 122
130
131/******************************************************************************* 123/*******************************************************************************
132 * 124 *
133 * FUNCTION: acpi_enter_sleep_state_prep 125 * FUNCTION: acpi_enter_sleep_state_prep
@@ -143,25 +135,22 @@ acpi_get_firmware_waking_vector (
143 * 135 *
144 ******************************************************************************/ 136 ******************************************************************************/
145 137
146acpi_status 138acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
147acpi_enter_sleep_state_prep (
148 u8 sleep_state)
149{ 139{
150 acpi_status status; 140 acpi_status status;
151 struct acpi_object_list arg_list; 141 struct acpi_object_list arg_list;
152 union acpi_object arg; 142 union acpi_object arg;
153
154
155 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_prep");
156 143
144 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_prep");
157 145
158 /* 146 /*
159 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. 147 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
160 */ 148 */
161 status = acpi_get_sleep_type_data (sleep_state, 149 status = acpi_get_sleep_type_data(sleep_state,
162 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 150 &acpi_gbl_sleep_type_a,
163 if (ACPI_FAILURE (status)) { 151 &acpi_gbl_sleep_type_b);
164 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
165 } 154 }
166 155
167 /* Setup parameter object */ 156 /* Setup parameter object */
@@ -174,14 +163,14 @@ acpi_enter_sleep_state_prep (
174 163
175 /* Run the _PTS and _GTS methods */ 164 /* Run the _PTS and _GTS methods */
176 165
177 status = acpi_evaluate_object (NULL, METHOD_NAME__PTS, &arg_list, NULL); 166 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
178 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 167 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
179 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
180 } 169 }
181 170
182 status = acpi_evaluate_object (NULL, METHOD_NAME__GTS, &arg_list, NULL); 171 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
183 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 172 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
184 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
185 } 174 }
186 175
187 /* Setup the argument to _SST */ 176 /* Setup the argument to _SST */
@@ -202,22 +191,21 @@ acpi_enter_sleep_state_prep (
202 break; 191 break;
203 192
204 default: 193 default:
205 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 194 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
206 break; 195 break;
207 } 196 }
208 197
209 /* Set the system indicators to show the desired sleep state. */ 198 /* Set the system indicators to show the desired sleep state. */
210 199
211 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
212 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
213 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 202 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
214 acpi_format_exception (status))); 203 acpi_format_exception(status)));
215 } 204 }
216 205
217 return_ACPI_STATUS (AE_OK); 206 return_ACPI_STATUS(AE_OK);
218} 207}
219 208
220
221/******************************************************************************* 209/*******************************************************************************
222 * 210 *
223 * FUNCTION: acpi_enter_sleep_state 211 * FUNCTION: acpi_enter_sleep_state
@@ -231,80 +219,82 @@ acpi_enter_sleep_state_prep (
231 * 219 *
232 ******************************************************************************/ 220 ******************************************************************************/
233 221
234acpi_status asmlinkage 222acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
235acpi_enter_sleep_state (
236 u8 sleep_state)
237{ 223{
238 u32 PM1Acontrol; 224 u32 PM1Acontrol;
239 u32 PM1Bcontrol; 225 u32 PM1Bcontrol;
240 struct acpi_bit_register_info *sleep_type_reg_info; 226 struct acpi_bit_register_info *sleep_type_reg_info;
241 struct acpi_bit_register_info *sleep_enable_reg_info; 227 struct acpi_bit_register_info *sleep_enable_reg_info;
242 u32 in_value; 228 u32 in_value;
243 acpi_status status; 229 acpi_status status;
244
245
246 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state");
247 230
231 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state");
248 232
249 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
250 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
251 ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n", 235 ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n",
252 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 236 acpi_gbl_sleep_type_a,
253 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 237 acpi_gbl_sleep_type_b));
238 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
254 } 239 }
255 240
256 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 241 sleep_type_reg_info =
257 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 242 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
243 sleep_enable_reg_info =
244 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
258 245
259 /* Clear wake status */ 246 /* Clear wake status */
260 247
261 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 248 status =
262 if (ACPI_FAILURE (status)) { 249 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
263 return_ACPI_STATUS (status); 250 if (ACPI_FAILURE(status)) {
251 return_ACPI_STATUS(status);
264 } 252 }
265 253
266 /* Clear all fixed and general purpose status bits */ 254 /* Clear all fixed and general purpose status bits */
267 255
268 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 256 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
269 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
270 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
271 } 259 }
272 260
273 /* 261 /*
274 * 1) Disable/Clear all GPEs 262 * 1) Disable/Clear all GPEs
275 * 2) Enable all wakeup GPEs 263 * 2) Enable all wakeup GPEs
276 */ 264 */
277 status = acpi_hw_disable_all_gpes (ACPI_ISR); 265 status = acpi_hw_disable_all_gpes();
278 if (ACPI_FAILURE (status)) { 266 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 267 return_ACPI_STATUS(status);
280 } 268 }
281 acpi_gbl_system_awake_and_running = FALSE; 269 acpi_gbl_system_awake_and_running = FALSE;
282 270
283 status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); 271 status = acpi_hw_enable_all_wakeup_gpes();
284 if (ACPI_FAILURE (status)) { 272 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS (status); 273 return_ACPI_STATUS(status);
286 } 274 }
287 275
288 /* Get current value of PM1A control */ 276 /* Get current value of PM1A control */
289 277
290 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 278 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
291 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 279 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
292 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
293 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
294 } 282 }
295 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 283 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
296 "Entering sleep state [S%d]\n", sleep_state)); 284 "Entering sleep state [S%d]\n", sleep_state));
297 285
298 /* Clear SLP_EN and SLP_TYP fields */ 286 /* Clear SLP_EN and SLP_TYP fields */
299 287
300 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 288 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
301 sleep_enable_reg_info->access_bit_mask); 289 sleep_enable_reg_info->access_bit_mask);
302 PM1Bcontrol = PM1Acontrol; 290 PM1Bcontrol = PM1Acontrol;
303 291
304 /* Insert SLP_TYP bits */ 292 /* Insert SLP_TYP bits */
305 293
306 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 294 PM1Acontrol |=
307 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 295 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
296 PM1Bcontrol |=
297 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
308 298
309 /* 299 /*
310 * We split the writes of SLP_TYP and SLP_EN to workaround 300 * We split the writes of SLP_TYP and SLP_EN to workaround
@@ -313,16 +303,18 @@ acpi_enter_sleep_state (
313 303
314 /* Write #1: fill in SLP_TYP data */ 304 /* Write #1: fill in SLP_TYP data */
315 305
316 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 306 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
317 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 307 ACPI_REGISTER_PM1A_CONTROL,
318 if (ACPI_FAILURE (status)) { 308 PM1Acontrol);
319 return_ACPI_STATUS (status); 309 if (ACPI_FAILURE(status)) {
310 return_ACPI_STATUS(status);
320 } 311 }
321 312
322 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 313 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
323 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 314 ACPI_REGISTER_PM1B_CONTROL,
324 if (ACPI_FAILURE (status)) { 315 PM1Bcontrol);
325 return_ACPI_STATUS (status); 316 if (ACPI_FAILURE(status)) {
317 return_ACPI_STATUS(status);
326 } 318 }
327 319
328 /* Insert SLP_ENABLE bit */ 320 /* Insert SLP_ENABLE bit */
@@ -332,18 +324,20 @@ acpi_enter_sleep_state (
332 324
333 /* Write #2: SLP_TYP + SLP_EN */ 325 /* Write #2: SLP_TYP + SLP_EN */
334 326
335 ACPI_FLUSH_CPU_CACHE (); 327 ACPI_FLUSH_CPU_CACHE();
336 328
337 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 329 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
338 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 330 ACPI_REGISTER_PM1A_CONTROL,
339 if (ACPI_FAILURE (status)) { 331 PM1Acontrol);
340 return_ACPI_STATUS (status); 332 if (ACPI_FAILURE(status)) {
333 return_ACPI_STATUS(status);
341 } 334 }
342 335
343 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 336 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
344 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 337 ACPI_REGISTER_PM1B_CONTROL,
345 if (ACPI_FAILURE (status)) { 338 PM1Bcontrol);
346 return_ACPI_STATUS (status); 339 if (ACPI_FAILURE(status)) {
340 return_ACPI_STATUS(status);
347 } 341 }
348 342
349 if (sleep_state > ACPI_STATE_S3) { 343 if (sleep_state > ACPI_STATE_S3) {
@@ -358,33 +352,34 @@ acpi_enter_sleep_state (
358 * still read the right value. Ideally, this block would go 352 * still read the right value. Ideally, this block would go
359 * away entirely. 353 * away entirely.
360 */ 354 */
361 acpi_os_stall (10000000); 355 acpi_os_stall(10000000);
362 356
363 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 357 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
364 ACPI_REGISTER_PM1_CONTROL, 358 ACPI_REGISTER_PM1_CONTROL,
365 sleep_enable_reg_info->access_bit_mask); 359 sleep_enable_reg_info->
366 if (ACPI_FAILURE (status)) { 360 access_bit_mask);
367 return_ACPI_STATUS (status); 361 if (ACPI_FAILURE(status)) {
362 return_ACPI_STATUS(status);
368 } 363 }
369 } 364 }
370 365
371 /* Wait until we enter sleep state */ 366 /* Wait until we enter sleep state */
372 367
373 do { 368 do {
374 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 369 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
375 ACPI_MTX_DO_NOT_LOCK); 370 ACPI_MTX_DO_NOT_LOCK);
376 if (ACPI_FAILURE (status)) { 371 if (ACPI_FAILURE(status)) {
377 return_ACPI_STATUS (status); 372 return_ACPI_STATUS(status);
378 } 373 }
379 374
380 /* Spin until we wake */ 375 /* Spin until we wake */
381 376
382 } while (!in_value); 377 } while (!in_value);
383 378
384 return_ACPI_STATUS (AE_OK); 379 return_ACPI_STATUS(AE_OK);
385} 380}
386EXPORT_SYMBOL(acpi_enter_sleep_state);
387 381
382EXPORT_SYMBOL(acpi_enter_sleep_state);
388 383
389/******************************************************************************* 384/*******************************************************************************
390 * 385 *
@@ -399,60 +394,57 @@ EXPORT_SYMBOL(acpi_enter_sleep_state);
399 * 394 *
400 ******************************************************************************/ 395 ******************************************************************************/
401 396
402acpi_status asmlinkage 397acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
403acpi_enter_sleep_state_s4bios (
404 void)
405{ 398{
406 u32 in_value; 399 u32 in_value;
407 acpi_status status; 400 acpi_status status;
408
409 401
410 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_s4bios"); 402 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_s4bios");
411 403
412 404 status =
413 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 405 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
414 if (ACPI_FAILURE (status)) { 406 if (ACPI_FAILURE(status)) {
415 return_ACPI_STATUS (status); 407 return_ACPI_STATUS(status);
416 } 408 }
417 409
418 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 410 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
419 if (ACPI_FAILURE (status)) { 411 if (ACPI_FAILURE(status)) {
420 return_ACPI_STATUS (status); 412 return_ACPI_STATUS(status);
421 } 413 }
422 414
423 /* 415 /*
424 * 1) Disable/Clear all GPEs 416 * 1) Disable/Clear all GPEs
425 * 2) Enable all wakeup GPEs 417 * 2) Enable all wakeup GPEs
426 */ 418 */
427 status = acpi_hw_disable_all_gpes (ACPI_ISR); 419 status = acpi_hw_disable_all_gpes();
428 if (ACPI_FAILURE (status)) { 420 if (ACPI_FAILURE(status)) {
429 return_ACPI_STATUS (status); 421 return_ACPI_STATUS(status);
430 } 422 }
431 acpi_gbl_system_awake_and_running = FALSE; 423 acpi_gbl_system_awake_and_running = FALSE;
432 424
433 status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); 425 status = acpi_hw_enable_all_wakeup_gpes();
434 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
435 return_ACPI_STATUS (status); 427 return_ACPI_STATUS(status);
436 } 428 }
437 429
438 ACPI_FLUSH_CPU_CACHE (); 430 ACPI_FLUSH_CPU_CACHE();
439 431
440 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 432 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
441 (u32) acpi_gbl_FADT->S4bios_req, 8); 433 (u32) acpi_gbl_FADT->S4bios_req, 8);
442 434
443 do { 435 do {
444 acpi_os_stall(1000); 436 acpi_os_stall(1000);
445 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 437 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
446 ACPI_MTX_DO_NOT_LOCK); 438 ACPI_MTX_DO_NOT_LOCK);
447 if (ACPI_FAILURE (status)) { 439 if (ACPI_FAILURE(status)) {
448 return_ACPI_STATUS (status); 440 return_ACPI_STATUS(status);
449 } 441 }
450 } while (!in_value); 442 } while (!in_value);
451 443
452 return_ACPI_STATUS (AE_OK); 444 return_ACPI_STATUS(AE_OK);
453} 445}
454EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
455 446
447EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
456 448
457/******************************************************************************* 449/*******************************************************************************
458 * 450 *
@@ -467,55 +459,62 @@ EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
467 * 459 *
468 ******************************************************************************/ 460 ******************************************************************************/
469 461
470acpi_status 462acpi_status acpi_leave_sleep_state(u8 sleep_state)
471acpi_leave_sleep_state (
472 u8 sleep_state)
473{ 463{
474 struct acpi_object_list arg_list; 464 struct acpi_object_list arg_list;
475 union acpi_object arg; 465 union acpi_object arg;
476 acpi_status status; 466 acpi_status status;
477 struct acpi_bit_register_info *sleep_type_reg_info; 467 struct acpi_bit_register_info *sleep_type_reg_info;
478 struct acpi_bit_register_info *sleep_enable_reg_info; 468 struct acpi_bit_register_info *sleep_enable_reg_info;
479 u32 PM1Acontrol; 469 u32 PM1Acontrol;
480 u32 PM1Bcontrol; 470 u32 PM1Bcontrol;
481
482
483 ACPI_FUNCTION_TRACE ("acpi_leave_sleep_state");
484 471
472 ACPI_FUNCTION_TRACE("acpi_leave_sleep_state");
485 473
486 /* 474 /*
487 * Set SLP_TYPE and SLP_EN to state S0. 475 * Set SLP_TYPE and SLP_EN to state S0.
488 * This is unclear from the ACPI Spec, but it is required 476 * This is unclear from the ACPI Spec, but it is required
489 * by some machines. 477 * by some machines.
490 */ 478 */
491 status = acpi_get_sleep_type_data (ACPI_STATE_S0, 479 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
492 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 480 &acpi_gbl_sleep_type_a,
493 if (ACPI_SUCCESS (status)) { 481 &acpi_gbl_sleep_type_b);
494 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 482 if (ACPI_SUCCESS(status)) {
495 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 483 sleep_type_reg_info =
484 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
485 sleep_enable_reg_info =
486 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
496 487
497 /* Get current value of PM1A control */ 488 /* Get current value of PM1A control */
498 489
499 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 490 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
500 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 491 ACPI_REGISTER_PM1_CONTROL,
501 if (ACPI_SUCCESS (status)) { 492 &PM1Acontrol);
493 if (ACPI_SUCCESS(status)) {
502 /* Clear SLP_EN and SLP_TYP fields */ 494 /* Clear SLP_EN and SLP_TYP fields */
503 495
504 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 496 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
505 sleep_enable_reg_info->access_bit_mask); 497 sleep_enable_reg_info->
498 access_bit_mask);
506 PM1Bcontrol = PM1Acontrol; 499 PM1Bcontrol = PM1Acontrol;
507 500
508 /* Insert SLP_TYP bits */ 501 /* Insert SLP_TYP bits */
509 502
510 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 503 PM1Acontrol |=
511 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 504 (acpi_gbl_sleep_type_a << sleep_type_reg_info->
505 bit_position);
506 PM1Bcontrol |=
507 (acpi_gbl_sleep_type_b << sleep_type_reg_info->
508 bit_position);
512 509
513 /* Just ignore any errors */ 510 /* Just ignore any errors */
514 511
515 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 512 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 513 ACPI_REGISTER_PM1A_CONTROL,
517 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 514 PM1Acontrol);
518 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 515 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1B_CONTROL,
517 PM1Bcontrol);
519 } 518 }
520 } 519 }
521 520
@@ -532,23 +531,23 @@ acpi_leave_sleep_state (
532 /* Ignore any errors from these methods */ 531 /* Ignore any errors from these methods */
533 532
534 arg.integer.value = ACPI_SST_WAKING; 533 arg.integer.value = ACPI_SST_WAKING;
535 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 534 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
536 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 535 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
537 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 536 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
538 acpi_format_exception (status))); 537 acpi_format_exception(status)));
539 } 538 }
540 539
541 arg.integer.value = sleep_state; 540 arg.integer.value = sleep_state;
542 status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL); 541 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
543 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 542 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
544 ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", 543 ACPI_REPORT_ERROR(("Method _BFS failed, %s\n",
545 acpi_format_exception (status))); 544 acpi_format_exception(status)));
546 } 545 }
547 546
548 status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL); 547 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
549 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 548 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
550 ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", 549 ACPI_REPORT_ERROR(("Method _WAK failed, %s\n",
551 acpi_format_exception (status))); 550 acpi_format_exception(status)));
552 } 551 }
553 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 552 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
554 553
@@ -557,33 +556,35 @@ acpi_leave_sleep_state (
557 * 1) Disable/Clear all GPEs 556 * 1) Disable/Clear all GPEs
558 * 2) Enable all runtime GPEs 557 * 2) Enable all runtime GPEs
559 */ 558 */
560 status = acpi_hw_disable_all_gpes (ACPI_NOT_ISR); 559 status = acpi_hw_disable_all_gpes();
561 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
562 return_ACPI_STATUS (status); 561 return_ACPI_STATUS(status);
563 } 562 }
564 acpi_gbl_system_awake_and_running = TRUE; 563 acpi_gbl_system_awake_and_running = TRUE;
565 564
566 status = acpi_hw_enable_all_runtime_gpes (ACPI_NOT_ISR); 565 status = acpi_hw_enable_all_runtime_gpes();
567 if (ACPI_FAILURE (status)) { 566 if (ACPI_FAILURE(status)) {
568 return_ACPI_STATUS (status); 567 return_ACPI_STATUS(status);
569 } 568 }
570 569
571 /* Enable power button */ 570 /* Enable power button */
572 571
573 (void) acpi_set_register( 572 (void)
574 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id, 573 acpi_set_register(acpi_gbl_fixed_event_info
575 1, ACPI_MTX_DO_NOT_LOCK); 574 [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1,
575 ACPI_MTX_DO_NOT_LOCK);
576 576
577 (void) acpi_set_register( 577 (void)
578 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id, 578 acpi_set_register(acpi_gbl_fixed_event_info
579 1, ACPI_MTX_DO_NOT_LOCK); 579 [ACPI_EVENT_POWER_BUTTON].status_register_id, 1,
580 ACPI_MTX_DO_NOT_LOCK);
580 581
581 arg.integer.value = ACPI_SST_WORKING; 582 arg.integer.value = ACPI_SST_WORKING;
582 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 583 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
583 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 584 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
584 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 585 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
585 acpi_format_exception (status))); 586 acpi_format_exception(status)));
586 } 587 }
587 588
588 return_ACPI_STATUS (status); 589 return_ACPI_STATUS(status);
589} 590}
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index 49d7b395322e..aff6dc141784 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -46,8 +46,7 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwtimer") 49ACPI_MODULE_NAME("hwtimer")
50
51 50
52/****************************************************************************** 51/******************************************************************************
53 * 52 *
@@ -60,29 +59,23 @@
60 * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). 59 * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
61 * 60 *
62 ******************************************************************************/ 61 ******************************************************************************/
63 62acpi_status acpi_get_timer_resolution(u32 * resolution)
64acpi_status
65acpi_get_timer_resolution (
66 u32 *resolution)
67{ 63{
68 ACPI_FUNCTION_TRACE ("acpi_get_timer_resolution"); 64 ACPI_FUNCTION_TRACE("acpi_get_timer_resolution");
69
70 65
71 if (!resolution) { 66 if (!resolution) {
72 return_ACPI_STATUS (AE_BAD_PARAMETER); 67 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 } 68 }
74 69
75 if (0 == acpi_gbl_FADT->tmr_val_ext) { 70 if (0 == acpi_gbl_FADT->tmr_val_ext) {
76 *resolution = 24; 71 *resolution = 24;
77 } 72 } else {
78 else {
79 *resolution = 32; 73 *resolution = 32;
80 } 74 }
81 75
82 return_ACPI_STATUS (AE_OK); 76 return_ACPI_STATUS(AE_OK);
83} 77}
84 78
85
86/****************************************************************************** 79/******************************************************************************
87 * 80 *
88 * FUNCTION: acpi_get_timer 81 * FUNCTION: acpi_get_timer
@@ -95,26 +88,22 @@ acpi_get_timer_resolution (
95 * 88 *
96 ******************************************************************************/ 89 ******************************************************************************/
97 90
98acpi_status 91acpi_status acpi_get_timer(u32 * ticks)
99acpi_get_timer (
100 u32 *ticks)
101{ 92{
102 acpi_status status; 93 acpi_status status;
103
104
105 ACPI_FUNCTION_TRACE ("acpi_get_timer");
106 94
95 ACPI_FUNCTION_TRACE("acpi_get_timer");
107 96
108 if (!ticks) { 97 if (!ticks) {
109 return_ACPI_STATUS (AE_BAD_PARAMETER); 98 return_ACPI_STATUS(AE_BAD_PARAMETER);
110 } 99 }
111 100
112 status = acpi_hw_low_level_read (32, ticks, &acpi_gbl_FADT->xpm_tmr_blk); 101 status = acpi_hw_low_level_read(32, ticks, &acpi_gbl_FADT->xpm_tmr_blk);
113 102
114 return_ACPI_STATUS (status); 103 return_ACPI_STATUS(status);
115} 104}
116EXPORT_SYMBOL(acpi_get_timer);
117 105
106EXPORT_SYMBOL(acpi_get_timer);
118 107
119/****************************************************************************** 108/******************************************************************************
120 * 109 *
@@ -146,21 +135,16 @@ EXPORT_SYMBOL(acpi_get_timer);
146 ******************************************************************************/ 135 ******************************************************************************/
147 136
148acpi_status 137acpi_status
149acpi_get_timer_duration ( 138acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
150 u32 start_ticks,
151 u32 end_ticks,
152 u32 *time_elapsed)
153{ 139{
154 acpi_status status; 140 acpi_status status;
155 u32 delta_ticks; 141 u32 delta_ticks;
156 acpi_integer quotient; 142 acpi_integer quotient;
157
158
159 ACPI_FUNCTION_TRACE ("acpi_get_timer_duration");
160 143
144 ACPI_FUNCTION_TRACE("acpi_get_timer_duration");
161 145
162 if (!time_elapsed) { 146 if (!time_elapsed) {
163 return_ACPI_STATUS (AE_BAD_PARAMETER); 147 return_ACPI_STATUS(AE_BAD_PARAMETER);
164 } 148 }
165 149
166 /* 150 /*
@@ -169,22 +153,22 @@ acpi_get_timer_duration (
169 */ 153 */
170 if (start_ticks < end_ticks) { 154 if (start_ticks < end_ticks) {
171 delta_ticks = end_ticks - start_ticks; 155 delta_ticks = end_ticks - start_ticks;
172 } 156 } else if (start_ticks > end_ticks) {
173 else if (start_ticks > end_ticks) {
174 if (0 == acpi_gbl_FADT->tmr_val_ext) { 157 if (0 == acpi_gbl_FADT->tmr_val_ext) {
175 /* 24-bit Timer */ 158 /* 24-bit Timer */
176 159
177 delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF); 160 delta_ticks =
178 } 161 (((0x00FFFFFF - start_ticks) +
179 else { 162 end_ticks) & 0x00FFFFFF);
163 } else {
180 /* 32-bit Timer */ 164 /* 32-bit Timer */
181 165
182 delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks; 166 delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
183 } 167 }
184 } 168 } else { /* start_ticks == end_ticks */
185 else /* start_ticks == end_ticks */ { 169
186 *time_elapsed = 0; 170 *time_elapsed = 0;
187 return_ACPI_STATUS (AE_OK); 171 return_ACPI_STATUS(AE_OK);
188 } 172 }
189 173
190 /* 174 /*
@@ -192,12 +176,11 @@ acpi_get_timer_duration (
192 * 176 *
193 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; 177 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
194 */ 178 */
195 status = acpi_ut_short_divide (((u64) delta_ticks) * 1000000, 179 status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000,
196 PM_TIMER_FREQUENCY, &quotient, NULL); 180 PM_TIMER_FREQUENCY, &quotient, NULL);
197 181
198 *time_elapsed = (u32) quotient; 182 *time_elapsed = (u32) quotient;
199 return_ACPI_STATUS (status); 183 return_ACPI_STATUS(status);
200} 184}
201 185
202EXPORT_SYMBOL(acpi_get_timer_duration); 186EXPORT_SYMBOL(acpi_get_timer_duration);
203
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index 1f76a40badec..2e2e4051dfa7 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -62,7 +62,7 @@
62#define _COMPONENT ACPI_HOTKEY_COMPONENT 62#define _COMPONENT ACPI_HOTKEY_COMPONENT
63ACPI_MODULE_NAME("acpi_hotkey") 63ACPI_MODULE_NAME("acpi_hotkey")
64 64
65MODULE_AUTHOR("luming.yu@intel.com"); 65 MODULE_AUTHOR("luming.yu@intel.com");
66MODULE_DESCRIPTION(ACPI_HOTK_NAME); 66MODULE_DESCRIPTION(ACPI_HOTK_NAME);
67MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
68 68
@@ -180,8 +180,8 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset);
180static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset); 180static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset);
181static int hotkey_polling_open_fs(struct inode *inode, struct file *file); 181static int hotkey_polling_open_fs(struct inode *inode, struct file *file);
182static union acpi_hotkey *get_hotkey_by_event(struct 182static union acpi_hotkey *get_hotkey_by_event(struct
183 acpi_hotkey_list 183 acpi_hotkey_list
184 *hotkey_list, int event); 184 *hotkey_list, int event);
185 185
186/* event based config */ 186/* event based config */
187static struct file_operations hotkey_config_fops = { 187static struct file_operations hotkey_config_fops = {
@@ -246,7 +246,7 @@ static int hotkey_info_open_fs(struct inode *inode, struct file *file)
246static char *format_result(union acpi_object *object) 246static char *format_result(union acpi_object *object)
247{ 247{
248 char *buf = NULL; 248 char *buf = NULL;
249 249
250 buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL); 250 buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL);
251 if (buf) 251 if (buf)
252 memset(buf, 0, RESULT_STR_LEN); 252 memset(buf, 0, RESULT_STR_LEN);
@@ -256,7 +256,7 @@ static char *format_result(union acpi_object *object)
256 /* Now, just support integer type */ 256 /* Now, just support integer type */
257 if (object->type == ACPI_TYPE_INTEGER) 257 if (object->type == ACPI_TYPE_INTEGER)
258 sprintf(buf, "%d\n", (u32) object->integer.value); 258 sprintf(buf, "%d\n", (u32) object->integer.value);
259do_fail: 259 do_fail:
260 return (buf); 260 return (buf);
261} 261}
262 262
@@ -268,9 +268,9 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
268 268
269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); 269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
270 270
271 if (poll_hotkey->poll_result){ 271 if (poll_hotkey->poll_result) {
272 buf = format_result(poll_hotkey->poll_result); 272 buf = format_result(poll_hotkey->poll_result);
273 if(buf) 273 if (buf)
274 seq_printf(seq, "%s", buf); 274 seq_printf(seq, "%s", buf);
275 kfree(buf); 275 kfree(buf);
276 } 276 }
@@ -299,7 +299,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
299 union acpi_hotkey *key = 299 union acpi_hotkey *key =
300 container_of(entries, union acpi_hotkey, entries); 300 container_of(entries, union acpi_hotkey, entries);
301 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT 301 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
302 && key->event_hotkey.external_hotkey_num == event){ 302 && key->event_hotkey.external_hotkey_num == event) {
303 val = key->link.hotkey_standard_num; 303 val = key->link.hotkey_standard_num;
304 break; 304 break;
305 } 305 }
@@ -343,7 +343,7 @@ static int auto_hotkey_remove(struct acpi_device *device, int type)
343static int create_polling_proc(union acpi_hotkey *device) 343static int create_polling_proc(union acpi_hotkey *device)
344{ 344{
345 struct proc_dir_entry *proc; 345 struct proc_dir_entry *proc;
346 char proc_name[80]; 346 char proc_name[80];
347 mode_t mode; 347 mode_t mode;
348 348
349 ACPI_FUNCTION_TRACE("create_polling_proc"); 349 ACPI_FUNCTION_TRACE("create_polling_proc");
@@ -351,8 +351,8 @@ static int create_polling_proc(union acpi_hotkey *device)
351 351
352 sprintf(proc_name, "%d", device->link.hotkey_standard_num); 352 sprintf(proc_name, "%d", device->link.hotkey_standard_num);
353 /* 353 /*
354 strcat(proc_name, device->poll_hotkey.poll_method); 354 strcat(proc_name, device->poll_hotkey.poll_method);
355 */ 355 */
356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); 356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
357 357
358 if (!proc) { 358 if (!proc) {
@@ -415,50 +415,50 @@ static int hotkey_remove(union acpi_hotkey *device)
415 return_VALUE(0); 415 return_VALUE(0);
416} 416}
417 417
418static int hotkey_update(union acpi_hotkey *key) 418static int hotkey_update(union acpi_hotkey *key)
419{ 419{
420 struct list_head *entries; 420 struct list_head *entries;
421 421
422 ACPI_FUNCTION_TRACE("hotkey_update"); 422 ACPI_FUNCTION_TRACE("hotkey_update");
423 423
424 list_for_each(entries, global_hotkey_list.entries) { 424 list_for_each(entries, global_hotkey_list.entries) {
425 union acpi_hotkey *tmp= 425 union acpi_hotkey *tmp =
426 container_of(entries, union acpi_hotkey, entries); 426 container_of(entries, union acpi_hotkey, entries);
427 if (tmp->link.hotkey_standard_num == 427 if (tmp->link.hotkey_standard_num ==
428 key->link.hotkey_standard_num) { 428 key->link.hotkey_standard_num) {
429 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 429 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
430 free_hotkey_buffer(tmp); 430 free_hotkey_buffer(tmp);
431 tmp->event_hotkey.bus_handle = 431 tmp->event_hotkey.bus_handle =
432 key->event_hotkey.bus_handle; 432 key->event_hotkey.bus_handle;
433 tmp->event_hotkey.external_hotkey_num = 433 tmp->event_hotkey.external_hotkey_num =
434 key->event_hotkey.external_hotkey_num; 434 key->event_hotkey.external_hotkey_num;
435 tmp->event_hotkey.action_handle = 435 tmp->event_hotkey.action_handle =
436 key->event_hotkey.action_handle; 436 key->event_hotkey.action_handle;
437 tmp->event_hotkey.action_method = 437 tmp->event_hotkey.action_method =
438 key->event_hotkey.action_method; 438 key->event_hotkey.action_method;
439 kfree(key); 439 kfree(key);
440 } else { 440 } else {
441 /* 441 /*
442 char proc_name[80]; 442 char proc_name[80];
443 443
444 sprintf(proc_name, "%d", tmp->link.hotkey_standard_num); 444 sprintf(proc_name, "%d", tmp->link.hotkey_standard_num);
445 strcat(proc_name, tmp->poll_hotkey.poll_method); 445 strcat(proc_name, tmp->poll_hotkey.poll_method);
446 remove_proc_entry(proc_name,hotkey_proc_dir); 446 remove_proc_entry(proc_name,hotkey_proc_dir);
447 */ 447 */
448 free_poll_hotkey_buffer(tmp); 448 free_poll_hotkey_buffer(tmp);
449 tmp->poll_hotkey.poll_handle = 449 tmp->poll_hotkey.poll_handle =
450 key->poll_hotkey.poll_handle; 450 key->poll_hotkey.poll_handle;
451 tmp->poll_hotkey.poll_method = 451 tmp->poll_hotkey.poll_method =
452 key->poll_hotkey.poll_method; 452 key->poll_hotkey.poll_method;
453 tmp->poll_hotkey.action_handle = 453 tmp->poll_hotkey.action_handle =
454 key->poll_hotkey.action_handle; 454 key->poll_hotkey.action_handle;
455 tmp->poll_hotkey.action_method = 455 tmp->poll_hotkey.action_method =
456 key->poll_hotkey.action_method; 456 key->poll_hotkey.action_method;
457 tmp->poll_hotkey.poll_result = 457 tmp->poll_hotkey.poll_result =
458 key->poll_hotkey.poll_result; 458 key->poll_hotkey.poll_result;
459 /* 459 /*
460 create_polling_proc(tmp); 460 create_polling_proc(tmp);
461 */ 461 */
462 kfree(key); 462 kfree(key);
463 } 463 }
464 return_VALUE(0); 464 return_VALUE(0);
@@ -483,27 +483,25 @@ static void free_hotkey_device(union acpi_hotkey *key)
483 acpi_hotkey_notify_handler); 483 acpi_hotkey_notify_handler);
484 free_hotkey_buffer(key); 484 free_hotkey_buffer(key);
485 } else { 485 } else {
486 char proc_name[80]; 486 char proc_name[80];
487 487
488 sprintf(proc_name, "%d", key->link.hotkey_standard_num); 488 sprintf(proc_name, "%d", key->link.hotkey_standard_num);
489 /* 489 /*
490 strcat(proc_name, key->poll_hotkey.poll_method); 490 strcat(proc_name, key->poll_hotkey.poll_method);
491 */ 491 */
492 remove_proc_entry(proc_name,hotkey_proc_dir); 492 remove_proc_entry(proc_name, hotkey_proc_dir);
493 free_poll_hotkey_buffer(key); 493 free_poll_hotkey_buffer(key);
494 } 494 }
495 kfree(key); 495 kfree(key);
496 return_VOID; 496 return_VOID;
497} 497}
498 498
499static void 499static void free_hotkey_buffer(union acpi_hotkey *key)
500free_hotkey_buffer(union acpi_hotkey *key)
501{ 500{
502 kfree(key->event_hotkey.action_method); 501 kfree(key->event_hotkey.action_method);
503} 502}
504 503
505static void 504static void free_poll_hotkey_buffer(union acpi_hotkey *key)
506free_poll_hotkey_buffer(union acpi_hotkey *key)
507{ 505{
508 kfree(key->poll_hotkey.action_method); 506 kfree(key->poll_hotkey.action_method);
509 kfree(key->poll_hotkey.poll_method); 507 kfree(key->poll_hotkey.poll_method);
@@ -513,15 +511,15 @@ static int
513init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, 511init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
514 char *method, int std_num, int external_num) 512 char *method, int std_num, int external_num)
515{ 513{
516 acpi_handle tmp_handle; 514 acpi_handle tmp_handle;
517 acpi_status status = AE_OK; 515 acpi_status status = AE_OK;
518 516
519 ACPI_FUNCTION_TRACE("init_hotkey_device"); 517 ACPI_FUNCTION_TRACE("init_hotkey_device");
520 518
521 if(std_num < 0 || IS_POLL(std_num) || !key ) 519 if (std_num < 0 || IS_POLL(std_num) || !key)
522 goto do_fail; 520 goto do_fail;
523 521
524 if(!bus_str || !action_str || !method) 522 if (!bus_str || !action_str || !method)
525 goto do_fail; 523 goto do_fail;
526 524
527 key->link.hotkey_type = ACPI_HOTKEY_EVENT; 525 key->link.hotkey_type = ACPI_HOTKEY_EVENT;
@@ -529,19 +527,22 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
529 key->event_hotkey.flag = 0; 527 key->event_hotkey.flag = 0;
530 key->event_hotkey.action_method = method; 528 key->event_hotkey.action_method = method;
531 529
532 status = acpi_get_handle(NULL,bus_str, &(key->event_hotkey.bus_handle)); 530 status =
533 if(ACPI_FAILURE(status)) 531 acpi_get_handle(NULL, bus_str, &(key->event_hotkey.bus_handle));
532 if (ACPI_FAILURE(status))
534 goto do_fail; 533 goto do_fail;
535 key->event_hotkey.external_hotkey_num = external_num; 534 key->event_hotkey.external_hotkey_num = external_num;
536 status = acpi_get_handle(NULL,action_str, &(key->event_hotkey.action_handle)); 535 status =
537 if(ACPI_FAILURE(status)) 536 acpi_get_handle(NULL, action_str,
537 &(key->event_hotkey.action_handle));
538 if (ACPI_FAILURE(status))
538 goto do_fail; 539 goto do_fail;
539 status = acpi_get_handle(key->event_hotkey.action_handle, 540 status = acpi_get_handle(key->event_hotkey.action_handle,
540 method, &tmp_handle); 541 method, &tmp_handle);
541 if (ACPI_FAILURE(status)) 542 if (ACPI_FAILURE(status))
542 goto do_fail; 543 goto do_fail;
543 return_VALUE(AE_OK); 544 return_VALUE(AE_OK);
544do_fail: 545 do_fail:
545 return_VALUE(-ENODEV); 546 return_VALUE(-ENODEV);
546} 547}
547 548
@@ -552,14 +553,14 @@ init_poll_hotkey_device(union acpi_hotkey *key,
552 char *action_str, char *action_method, int std_num) 553 char *action_str, char *action_method, int std_num)
553{ 554{
554 acpi_status status = AE_OK; 555 acpi_status status = AE_OK;
555 acpi_handle tmp_handle; 556 acpi_handle tmp_handle;
556 557
557 ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); 558 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
558 559
559 if(std_num < 0 || IS_EVENT(std_num) || !key) 560 if (std_num < 0 || IS_EVENT(std_num) || !key)
560 goto do_fail; 561 goto do_fail;
561 562
562 if(!poll_str || !poll_method || !action_str || !action_method) 563 if (!poll_str || !poll_method || !action_str || !action_method)
563 goto do_fail; 564 goto do_fail;
564 565
565 key->link.hotkey_type = ACPI_HOTKEY_POLLING; 566 key->link.hotkey_type = ACPI_HOTKEY_POLLING;
@@ -568,30 +569,32 @@ init_poll_hotkey_device(union acpi_hotkey *key,
568 key->poll_hotkey.poll_method = poll_method; 569 key->poll_hotkey.poll_method = poll_method;
569 key->poll_hotkey.action_method = action_method; 570 key->poll_hotkey.action_method = action_method;
570 571
571 status = acpi_get_handle(NULL,poll_str, &(key->poll_hotkey.poll_handle)); 572 status =
572 if(ACPI_FAILURE(status)) 573 acpi_get_handle(NULL, poll_str, &(key->poll_hotkey.poll_handle));
574 if (ACPI_FAILURE(status))
573 goto do_fail; 575 goto do_fail;
574 status = acpi_get_handle(key->poll_hotkey.poll_handle, 576 status = acpi_get_handle(key->poll_hotkey.poll_handle,
575 poll_method, &tmp_handle); 577 poll_method, &tmp_handle);
576 if (ACPI_FAILURE(status)) 578 if (ACPI_FAILURE(status))
577 goto do_fail; 579 goto do_fail;
578 status = acpi_get_handle(NULL,action_str, &(key->poll_hotkey.action_handle)); 580 status =
581 acpi_get_handle(NULL, action_str,
582 &(key->poll_hotkey.action_handle));
579 if (ACPI_FAILURE(status)) 583 if (ACPI_FAILURE(status))
580 goto do_fail; 584 goto do_fail;
581 status = acpi_get_handle(key->poll_hotkey.action_handle, 585 status = acpi_get_handle(key->poll_hotkey.action_handle,
582 action_method, &tmp_handle); 586 action_method, &tmp_handle);
583 if (ACPI_FAILURE(status)) 587 if (ACPI_FAILURE(status))
584 goto do_fail; 588 goto do_fail;
585 key->poll_hotkey.poll_result = 589 key->poll_hotkey.poll_result =
586 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 590 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
587 if(!key->poll_hotkey.poll_result) 591 if (!key->poll_hotkey.poll_result)
588 goto do_fail; 592 goto do_fail;
589 return_VALUE(AE_OK); 593 return_VALUE(AE_OK);
590do_fail: 594 do_fail:
591 return_VALUE(-ENODEV); 595 return_VALUE(-ENODEV);
592} 596}
593 597
594
595static int hotkey_open_config(struct inode *inode, struct file *file) 598static int hotkey_open_config(struct inode *inode, struct file *file)
596{ 599{
597 ACPI_FUNCTION_TRACE("hotkey_open_config"); 600 ACPI_FUNCTION_TRACE("hotkey_open_config");
@@ -679,8 +682,9 @@ get_parms(char *config_record,
679 682
680 sscanf(config_record, "%d", cmd); 683 sscanf(config_record, "%d", cmd);
681 684
682 if(*cmd == 1){ 685 if (*cmd == 1) {
683 if(sscanf(config_record, "%d:%d", cmd, internal_event_num)!=2) 686 if (sscanf(config_record, "%d:%d", cmd, internal_event_num) !=
687 2)
684 goto do_fail; 688 goto do_fail;
685 else 689 else
686 return (6); 690 return (6);
@@ -694,8 +698,8 @@ get_parms(char *config_record,
694 goto do_fail; 698 goto do_fail;
695 699
696 count = tmp1 - tmp; 700 count = tmp1 - tmp;
697 *bus_handle = (char *) kmalloc(count+1, GFP_KERNEL); 701 *bus_handle = (char *)kmalloc(count + 1, GFP_KERNEL);
698 if(!*bus_handle) 702 if (!*bus_handle)
699 goto do_fail; 703 goto do_fail;
700 strncpy(*bus_handle, tmp, count); 704 strncpy(*bus_handle, tmp, count);
701 *(*bus_handle + count) = 0; 705 *(*bus_handle + count) = 0;
@@ -706,8 +710,8 @@ get_parms(char *config_record,
706 if (!tmp1) 710 if (!tmp1)
707 goto do_fail; 711 goto do_fail;
708 count = tmp1 - tmp; 712 count = tmp1 - tmp;
709 *bus_method = (char *) kmalloc(count+1, GFP_KERNEL); 713 *bus_method = (char *)kmalloc(count + 1, GFP_KERNEL);
710 if(!*bus_method) 714 if (!*bus_method)
711 goto do_fail; 715 goto do_fail;
712 strncpy(*bus_method, tmp, count); 716 strncpy(*bus_method, tmp, count);
713 *(*bus_method + count) = 0; 717 *(*bus_method + count) = 0;
@@ -718,7 +722,7 @@ get_parms(char *config_record,
718 if (!tmp1) 722 if (!tmp1)
719 goto do_fail; 723 goto do_fail;
720 count = tmp1 - tmp; 724 count = tmp1 - tmp;
721 *action_handle = (char *) kmalloc(count+1, GFP_KERNEL); 725 *action_handle = (char *)kmalloc(count + 1, GFP_KERNEL);
722 strncpy(*action_handle, tmp, count); 726 strncpy(*action_handle, tmp, count);
723 *(*action_handle + count) = 0; 727 *(*action_handle + count) = 0;
724 728
@@ -728,17 +732,18 @@ get_parms(char *config_record,
728 if (!tmp1) 732 if (!tmp1)
729 goto do_fail; 733 goto do_fail;
730 count = tmp1 - tmp; 734 count = tmp1 - tmp;
731 *method = (char *) kmalloc(count+1, GFP_KERNEL); 735 *method = (char *)kmalloc(count + 1, GFP_KERNEL);
732 if(!*method) 736 if (!*method)
733 goto do_fail; 737 goto do_fail;
734 strncpy(*method, tmp, count); 738 strncpy(*method, tmp, count);
735 *(*method + count) = 0; 739 *(*method + count) = 0;
736 740
737 if(sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num)<=0) 741 if (sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num) <=
742 0)
738 goto do_fail; 743 goto do_fail;
739 744
740 return_VALUE(6); 745 return_VALUE(6);
741do_fail: 746 do_fail:
742 return_VALUE(-1); 747 return_VALUE(-1);
743} 748}
744 749
@@ -758,8 +763,8 @@ static ssize_t hotkey_write_config(struct file *file,
758 763
759 ACPI_FUNCTION_TRACE(("hotkey_write_config")); 764 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
760 765
761 config_record = (char *) kmalloc(count+1, GFP_KERNEL); 766 config_record = (char *)kmalloc(count + 1, GFP_KERNEL);
762 if(!config_record) 767 if (!config_record)
763 return_VALUE(-ENOMEM); 768 return_VALUE(-ENOMEM);
764 769
765 if (copy_from_user(config_record, buffer, count)) { 770 if (copy_from_user(config_record, buffer, count)) {
@@ -777,10 +782,10 @@ static ssize_t hotkey_write_config(struct file *file,
777 &method, &internal_event_num, &external_event_num); 782 &method, &internal_event_num, &external_event_num);
778 783
779 kfree(config_record); 784 kfree(config_record);
780 if(IS_OTHERS(internal_event_num)) 785 if (IS_OTHERS(internal_event_num))
781 goto do_fail; 786 goto do_fail;
782 if (ret != 6) { 787 if (ret != 6) {
783do_fail: 788 do_fail:
784 kfree(bus_handle); 789 kfree(bus_handle);
785 kfree(bus_method); 790 kfree(bus_method);
786 kfree(action_handle); 791 kfree(action_handle);
@@ -791,14 +796,14 @@ do_fail:
791 } 796 }
792 797
793 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 798 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
794 if(!key) 799 if (!key)
795 goto do_fail; 800 goto do_fail;
796 memset(key, 0, sizeof(union acpi_hotkey)); 801 memset(key, 0, sizeof(union acpi_hotkey));
797 if(cmd == 1) { 802 if (cmd == 1) {
798 union acpi_hotkey *tmp = NULL; 803 union acpi_hotkey *tmp = NULL;
799 tmp = get_hotkey_by_event(&global_hotkey_list, 804 tmp = get_hotkey_by_event(&global_hotkey_list,
800 internal_event_num); 805 internal_event_num);
801 if(!tmp) 806 if (!tmp)
802 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); 807 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key"));
803 else 808 else
804 memcpy(key, tmp, sizeof(union acpi_hotkey)); 809 memcpy(key, tmp, sizeof(union acpi_hotkey));
@@ -807,15 +812,16 @@ do_fail:
807 if (IS_EVENT(internal_event_num)) { 812 if (IS_EVENT(internal_event_num)) {
808 kfree(bus_method); 813 kfree(bus_method);
809 ret = init_hotkey_device(key, bus_handle, action_handle, method, 814 ret = init_hotkey_device(key, bus_handle, action_handle, method,
810 internal_event_num, external_event_num); 815 internal_event_num,
816 external_event_num);
811 } else 817 } else
812 ret = init_poll_hotkey_device(key, bus_handle, bus_method, 818 ret = init_poll_hotkey_device(key, bus_handle, bus_method,
813 action_handle, method, 819 action_handle, method,
814 internal_event_num); 820 internal_event_num);
815 if (ret) { 821 if (ret) {
816 kfree(bus_handle); 822 kfree(bus_handle);
817 kfree(action_handle); 823 kfree(action_handle);
818 if(IS_EVENT(internal_event_num)) 824 if (IS_EVENT(internal_event_num))
819 free_hotkey_buffer(key); 825 free_hotkey_buffer(key);
820 else 826 else
821 free_poll_hotkey_buffer(key); 827 free_poll_hotkey_buffer(key);
@@ -824,13 +830,14 @@ do_fail:
824 return_VALUE(-EINVAL); 830 return_VALUE(-EINVAL);
825 } 831 }
826 832
827cont_cmd: 833 cont_cmd:
828 kfree(bus_handle); 834 kfree(bus_handle);
829 kfree(action_handle); 835 kfree(action_handle);
830 836
831 switch (cmd) { 837 switch (cmd) {
832 case 0: 838 case 0:
833 if(get_hotkey_by_event(&global_hotkey_list,key->link.hotkey_standard_num)) 839 if (get_hotkey_by_event
840 (&global_hotkey_list, key->link.hotkey_standard_num))
834 goto fail_out; 841 goto fail_out;
835 else 842 else
836 hotkey_add(key); 843 hotkey_add(key);
@@ -839,7 +846,7 @@ cont_cmd:
839 hotkey_remove(key); 846 hotkey_remove(key);
840 break; 847 break;
841 case 2: 848 case 2:
842 if(hotkey_update(key)) 849 if (hotkey_update(key))
843 goto fail_out; 850 goto fail_out;
844 break; 851 break;
845 default: 852 default:
@@ -847,8 +854,8 @@ cont_cmd:
847 break; 854 break;
848 } 855 }
849 return_VALUE(count); 856 return_VALUE(count);
850fail_out: 857 fail_out:
851 if(IS_EVENT(internal_event_num)) 858 if (IS_EVENT(internal_event_num))
852 free_hotkey_buffer(key); 859 free_hotkey_buffer(key);
853 else 860 else
854 free_poll_hotkey_buffer(key); 861 free_poll_hotkey_buffer(key);
@@ -882,7 +889,8 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
882 return_VALUE(status == AE_OK); 889 return_VALUE(status == AE_OK);
883} 890}
884 891
885static int read_acpi_int(acpi_handle handle, const char *method, union acpi_object *val) 892static int read_acpi_int(acpi_handle handle, const char *method,
893 union acpi_object *val)
886{ 894{
887 struct acpi_buffer output; 895 struct acpi_buffer output;
888 union acpi_object out_obj; 896 union acpi_object out_obj;
@@ -893,7 +901,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, union acpi_obje
893 output.pointer = &out_obj; 901 output.pointer = &out_obj;
894 902
895 status = acpi_evaluate_object(handle, (char *)method, NULL, &output); 903 status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
896 if(val){ 904 if (val) {
897 val->integer.value = out_obj.integer.value; 905 val->integer.value = out_obj.integer.value;
898 val->type = out_obj.type; 906 val->type = out_obj.type;
899 } else 907 } else
@@ -903,8 +911,8 @@ static int read_acpi_int(acpi_handle handle, const char *method, union acpi_obje
903} 911}
904 912
905static union acpi_hotkey *get_hotkey_by_event(struct 913static union acpi_hotkey *get_hotkey_by_event(struct
906 acpi_hotkey_list 914 acpi_hotkey_list
907 *hotkey_list, int event) 915 *hotkey_list, int event)
908{ 916{
909 struct list_head *entries; 917 struct list_head *entries;
910 918
@@ -912,10 +920,10 @@ static union acpi_hotkey *get_hotkey_by_event(struct
912 union acpi_hotkey *key = 920 union acpi_hotkey *key =
913 container_of(entries, union acpi_hotkey, entries); 921 container_of(entries, union acpi_hotkey, entries);
914 if (key->link.hotkey_standard_num == event) { 922 if (key->link.hotkey_standard_num == event) {
915 return(key); 923 return (key);
916 } 924 }
917 } 925 }
918 return(NULL); 926 return (NULL);
919} 927}
920 928
921/* 929/*
@@ -932,15 +940,15 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
932{ 940{
933 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 941 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
934 char *arg; 942 char *arg;
935 int event,method_type,type, value; 943 int event, method_type, type, value;
936 union acpi_hotkey *key; 944 union acpi_hotkey *key;
937 945
938 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); 946 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
939 947
940 arg = (char *) kmalloc(count+1, GFP_KERNEL); 948 arg = (char *)kmalloc(count + 1, GFP_KERNEL);
941 if(!arg) 949 if (!arg)
942 return_VALUE(-ENOMEM); 950 return_VALUE(-ENOMEM);
943 arg[count]=0; 951 arg[count] = 0;
944 952
945 if (copy_from_user(arg, buffer, count)) { 953 if (copy_from_user(arg, buffer, count)) {
946 kfree(arg); 954 kfree(arg);
@@ -948,7 +956,8 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
948 return_VALUE(-EINVAL); 956 return_VALUE(-EINVAL);
949 } 957 }
950 958
951 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) { 959 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) !=
960 4) {
952 kfree(arg); 961 kfree(arg);
953 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); 962 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3"));
954 return_VALUE(-EINVAL); 963 return_VALUE(-EINVAL);
@@ -956,19 +965,21 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
956 kfree(arg); 965 kfree(arg);
957 if (type == ACPI_TYPE_INTEGER) { 966 if (type == ACPI_TYPE_INTEGER) {
958 key = get_hotkey_by_event(hotkey_list, event); 967 key = get_hotkey_by_event(hotkey_list, event);
959 if(!key) 968 if (!key)
960 goto do_fail; 969 goto do_fail;
961 if (IS_EVENT(event)) 970 if (IS_EVENT(event))
962 write_acpi_int(key->event_hotkey.action_handle, 971 write_acpi_int(key->event_hotkey.action_handle,
963 key->event_hotkey.action_method, value, NULL); 972 key->event_hotkey.action_method, value,
973 NULL);
964 else if (IS_POLL(event)) { 974 else if (IS_POLL(event)) {
965 if ( method_type == POLL_METHOD ) 975 if (method_type == POLL_METHOD)
966 read_acpi_int(key->poll_hotkey.poll_handle, 976 read_acpi_int(key->poll_hotkey.poll_handle,
967 key->poll_hotkey.poll_method, 977 key->poll_hotkey.poll_method,
968 key->poll_hotkey.poll_result); 978 key->poll_hotkey.poll_result);
969 else if ( method_type == ACTION_METHOD ) 979 else if (method_type == ACTION_METHOD)
970 write_acpi_int(key->poll_hotkey.action_handle, 980 write_acpi_int(key->poll_hotkey.action_handle,
971 key->poll_hotkey.action_method, value, NULL); 981 key->poll_hotkey.action_method,
982 value, NULL);
972 else 983 else
973 goto do_fail; 984 goto do_fail;
974 985
@@ -978,7 +989,7 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
978 return_VALUE(-EINVAL); 989 return_VALUE(-EINVAL);
979 } 990 }
980 return_VALUE(count); 991 return_VALUE(count);
981do_fail: 992 do_fail:
982 return_VALUE(-EINVAL); 993 return_VALUE(-EINVAL);
983 994
984} 995}
@@ -1074,15 +1085,15 @@ static int __init hotkey_init(void)
1074 1085
1075 return (0); 1086 return (0);
1076 1087
1077do_fail5: 1088 do_fail5:
1078 remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir); 1089 remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir);
1079do_fail4: 1090 do_fail4:
1080 remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir); 1091 remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir);
1081do_fail3: 1092 do_fail3:
1082 remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir); 1093 remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir);
1083do_fail2: 1094 do_fail2:
1084 remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir); 1095 remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir);
1085do_fail1: 1096 do_fail1:
1086 remove_proc_entry(HOTKEY_PROC, acpi_root_dir); 1097 remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
1087 return (-ENODEV); 1098 return (-ENODEV);
1088} 1099}
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index ad85e10001f4..5cc090326ddc 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -2,7 +2,7 @@
2 * ibm_acpi.c - IBM ThinkPad ACPI Extras 2 * ibm_acpi.c - IBM ThinkPad ACPI Extras
3 * 3 *
4 * 4 *
5 * Copyright (C) 2004 Borislav Deianov 5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -17,38 +17,62 @@
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * 20 */
21
22#define IBM_VERSION "0.12a"
23
24/*
21 * Changelog: 25 * Changelog:
22 * 26 *
23 * 2004-08-09 0.1 initial release, support for X series 27 * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels
24 * 2004-08-14 0.2 support for T series, X20 28 * 2005-03-17 0.11 support for 600e, 770x
25 * bluetooth enable/disable 29 * thanks to Jamie Lentin <lentinj@dial.pipex.com>
26 * hotkey events disabled by default 30 * support for 770e, G41
27 * removed fan control, currently useless 31 * G40 and G41 don't have a thinklight
28 * 2004-08-17 0.3 support for R40 32 * temperatures no longer experimental
29 * lcd off, brightness control 33 * experimental brightness control
30 * thinklight on/off 34 * experimental volume control
31 * 2004-09-16 0.4 support for module parameters 35 * experimental fan enable/disable
32 * hotkey mask can be prefixed by 0x 36 * 2005-01-16 0.10 fix module loading on R30, R31
33 * video output switching 37 * 2005-01-16 0.9 support for 570, R30, R31
34 * video expansion control 38 * ultrabay support on A22p, A3x
35 * ultrabay eject support 39 * limit arg for cmos, led, beep, drop experimental status
36 * removed lcd brightness/on/off control, didn't work 40 * more capable led control on A21e, A22p, T20-22, X20
41 * experimental temperatures and fan speed
42 * experimental embedded controller register dump
43 * mark more functions as __init, drop incorrect __exit
44 * use MODULE_VERSION
45 * thanks to Henrik Brix Andersen <brix@gentoo.org>
46 * fix parameter passing on module loading
47 * thanks to Rusty Russell <rusty@rustcorp.com.au>
48 * thanks to Jim Radford <radford@blackbean.org>
49 * 2004-11-08 0.8 fix init error case, don't return from a macro
50 * thanks to Chris Wright <chrisw@osdl.org>
51 * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20
52 * fix led control on A21e
53 * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device
37 * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20 54 * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20
38 * proc file format changed 55 * proc file format changed
39 * video_switch command 56 * video_switch command
40 * experimental cmos control 57 * experimental cmos control
41 * experimental led control 58 * experimental led control
42 * experimental acpi sounds 59 * experimental acpi sounds
43 * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device 60 * 2004-09-16 0.4 support for module parameters
44 * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20 61 * hotkey mask can be prefixed by 0x
45 * fix LED control on A21e 62 * video output switching
46 * 2004-11-08 0.8 fix init error case, don't return from a macro 63 * video expansion control
47 * thanks to Chris Wright <chrisw@osdl.org> 64 * ultrabay eject support
65 * removed lcd brightness/on/off control, didn't work
66 * 2004-08-17 0.3 support for R40
67 * lcd off, brightness control
68 * thinklight on/off
69 * 2004-08-14 0.2 support for T series, X20
70 * bluetooth enable/disable
71 * hotkey events disabled by default
72 * removed fan control, currently useless
73 * 2004-08-09 0.1 initial release, support for X series
48 */ 74 */
49 75
50#define IBM_VERSION "0.8"
51
52#include <linux/kernel.h> 76#include <linux/kernel.h>
53#include <linux/module.h> 77#include <linux/module.h>
54#include <linux/init.h> 78#include <linux/init.h>
@@ -64,6 +88,11 @@
64#define IBM_FILE "ibm_acpi" 88#define IBM_FILE "ibm_acpi"
65#define IBM_URL "http://ibm-acpi.sf.net/" 89#define IBM_URL "http://ibm-acpi.sf.net/"
66 90
91MODULE_AUTHOR("Borislav Deianov");
92MODULE_DESCRIPTION(IBM_DESC);
93MODULE_VERSION(IBM_VERSION);
94MODULE_LICENSE("GPL");
95
67#define IBM_DIR IBM_NAME 96#define IBM_DIR IBM_NAME
68 97
69#define IBM_LOG IBM_FILE ": " 98#define IBM_LOG IBM_FILE ": "
@@ -84,54 +113,122 @@ static acpi_handle root_handle = NULL;
84#define IBM_HANDLE(object, parent, paths...) \ 113#define IBM_HANDLE(object, parent, paths...) \
85 static acpi_handle object##_handle; \ 114 static acpi_handle object##_handle; \
86 static acpi_handle *object##_parent = &parent##_handle; \ 115 static acpi_handle *object##_parent = &parent##_handle; \
116 static char *object##_path; \
87 static char *object##_paths[] = { paths } 117 static char *object##_paths[] = { paths }
88 118
89IBM_HANDLE(ec, root, 119/*
90 "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ 120 * The following models are supported to various degrees:
91 "\\_SB.PCI0.LPC.EC", /* all others */ 121 *
92); 122 * 570, 600e, 600x, 770e, 770x
93 123 * A20m, A21e, A21m, A21p, A22p, A30, A30p, A31, A31p
94IBM_HANDLE(vid, root, 124 * G40, G41
95 "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ 125 * R30, R31, R32, R40, R40e, R50, R50e, R50p, R51
96 "\\_SB.PCI0.AGP.VID", /* all others */ 126 * T20, T21, T22, T23, T30, T40, T40p, T41, T41p, T42, T42p, T43
97); 127 * X20, X21, X22, X23, X24, X30, X31, X40
98 128 *
99IBM_HANDLE(cmos, root, 129 * The following models have no supported features:
100 "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ 130 *
101 "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ 131 * 240, 240x, i1400
102 "\\CMS", /* R40, R40e */ 132 *
103); /* A21e, A22p, T20, T21, X20 */ 133 * Still missing DSDTs for the following models:
104 134 *
105IBM_HANDLE(dock, root, 135 * A20p, A22e, A22m
106 "\\_SB.GDCK", /* X30, X31, X40 */ 136 * R52
107 "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ 137 * S31
108 "\\_SB.PCI0.PCI1.DOCK", /* all others */ 138 * T43p
109); /* A21e, G40, R32, R40, R40e */ 139 */
110 140
111IBM_HANDLE(bay, root, 141IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */
112 "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ 142 "\\_SB.PCI.ISA.EC", /* 570 */
113IBM_HANDLE(bayej, root, 143 "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */
114 "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ 144 "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */
115 145 "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */
116IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ 146 "\\_SB.PCI0.ICH3.EC0", /* R31 */
117IBM_HANDLE(hkey, ec, "HKEY"); /* all */ 147 "\\_SB.PCI0.LPC.EC", /* all others */
118IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ 148 );
119IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ 149
120IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ 150IBM_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */
121IBM_HANDLE(beep, ec, "BEEP"); /* all models */ 151 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
152 "\\_SB.PCI0.VID0", /* 770e */
153 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
154 "\\_SB.PCI0.AGP.VID", /* all others */
155 ); /* R30, R31 */
156
157IBM_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */
158
159IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
160 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
161 "\\CMS", /* R40, R40e */
162 ); /* all others */
163
164IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
165 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
166 "\\_SB.PCI0.PCI1.DOCK", /* all others */
167 "\\_SB.PCI.ISA.SLCE", /* 570 */
168 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
169
170IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
171 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
172 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
173 ); /* A21e, R30, R31 */
174
175IBM_HANDLE(bay_ej, bay, "_EJ3", /* 600e/x, A2xm/p, A3x */
176 "_EJ0", /* all others */
177 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
178
179IBM_HANDLE(bay2, root, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
180 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
181 ); /* all others */
182
183IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */
184 "_EJ0", /* 770x */
185 ); /* all others */
186
187/* don't list other alternatives as we install a notify handler on the 570 */
188IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
189
190IBM_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
191 "^HKEY", /* R30, R31 */
192 "HKEY", /* all others */
193 ); /* 570 */
194
195IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
196IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
197
198IBM_HANDLE(led, ec, "SLED", /* 570 */
199 "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
200 "LED", /* all others */
201 ); /* R30, R31 */
202
203IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */
204IBM_HANDLE(ecrd, ec, "ECRD"); /* 570 */
205IBM_HANDLE(ecwr, ec, "ECWR"); /* 570 */
206IBM_HANDLE(fans, ec, "FANS"); /* X31, X40 */
207
208IBM_HANDLE(gfan, ec, "GFAN", /* 570 */
209 "\\FSPD", /* 600e/x, 770e, 770x */
210 ); /* all others */
211
212IBM_HANDLE(sfan, ec, "SFAN", /* 570 */
213 "JFNS", /* 770x-JL */
214 ); /* all others */
215
216#define IBM_HKEY_HID "IBM0068"
217#define IBM_PCI_HID "PNP0A03"
122 218
123struct ibm_struct { 219struct ibm_struct {
124 char *name; 220 char *name;
221 char param[32];
125 222
126 char *hid; 223 char *hid;
127 struct acpi_driver *driver; 224 struct acpi_driver *driver;
128
129 int (*init) (struct ibm_struct *);
130 int (*read) (struct ibm_struct *, char *);
131 int (*write) (struct ibm_struct *, char *);
132 void (*exit) (struct ibm_struct *);
133 225
134 void (*notify) (struct ibm_struct *, u32); 226 int (*init) (void);
227 int (*read) (char *);
228 int (*write) (char *);
229 void (*exit) (void);
230
231 void (*notify) (struct ibm_struct *, u32);
135 acpi_handle *handle; 232 acpi_handle *handle;
136 int type; 233 int type;
137 struct acpi_device *device; 234 struct acpi_device *device;
@@ -141,17 +238,6 @@ struct ibm_struct {
141 int init_called; 238 int init_called;
142 int notify_installed; 239 int notify_installed;
143 240
144 int supported;
145 union {
146 struct {
147 int status;
148 int mask;
149 } hotkey;
150 struct {
151 int autoswitch;
152 } video;
153 } state;
154
155 int experimental; 241 int experimental;
156}; 242};
157 243
@@ -165,15 +251,15 @@ static int acpi_evalf(acpi_handle handle,
165 void *res, char *method, char *fmt, ...) 251 void *res, char *method, char *fmt, ...)
166{ 252{
167 char *fmt0 = fmt; 253 char *fmt0 = fmt;
168 struct acpi_object_list params; 254 struct acpi_object_list params;
169 union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; 255 union acpi_object in_objs[IBM_MAX_ACPI_ARGS];
170 struct acpi_buffer result; 256 struct acpi_buffer result, *resultp;
171 union acpi_object out_obj; 257 union acpi_object out_obj;
172 acpi_status status; 258 acpi_status status;
173 va_list ap; 259 va_list ap;
174 char res_type; 260 char res_type;
175 int success; 261 int success;
176 int quiet; 262 int quiet;
177 263
178 if (!*fmt) { 264 if (!*fmt) {
179 printk(IBM_ERR "acpi_evalf() called with empty format\n"); 265 printk(IBM_ERR "acpi_evalf() called with empty format\n");
@@ -199,7 +285,7 @@ static int acpi_evalf(acpi_handle handle,
199 in_objs[params.count].integer.value = va_arg(ap, int); 285 in_objs[params.count].integer.value = va_arg(ap, int);
200 in_objs[params.count++].type = ACPI_TYPE_INTEGER; 286 in_objs[params.count++].type = ACPI_TYPE_INTEGER;
201 break; 287 break;
202 /* add more types as needed */ 288 /* add more types as needed */
203 default: 289 default:
204 printk(IBM_ERR "acpi_evalf() called " 290 printk(IBM_ERR "acpi_evalf() called "
205 "with invalid format character '%c'\n", c); 291 "with invalid format character '%c'\n", c);
@@ -208,21 +294,25 @@ static int acpi_evalf(acpi_handle handle,
208 } 294 }
209 va_end(ap); 295 va_end(ap);
210 296
211 result.length = sizeof(out_obj); 297 if (res_type != 'v') {
212 result.pointer = &out_obj; 298 result.length = sizeof(out_obj);
299 result.pointer = &out_obj;
300 resultp = &result;
301 } else
302 resultp = NULL;
213 303
214 status = acpi_evaluate_object(handle, method, &params, &result); 304 status = acpi_evaluate_object(handle, method, &params, resultp);
215 305
216 switch (res_type) { 306 switch (res_type) {
217 case 'd': /* int */ 307 case 'd': /* int */
218 if (res) 308 if (res)
219 *(int *)res = out_obj.integer.value; 309 *(int *)res = out_obj.integer.value;
220 success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; 310 success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER;
221 break; 311 break;
222 case 'v': /* void */ 312 case 'v': /* void */
223 success = status == AE_OK; 313 success = status == AE_OK;
224 break; 314 break;
225 /* add more types as needed */ 315 /* add more types as needed */
226 default: 316 default:
227 printk(IBM_ERR "acpi_evalf() called " 317 printk(IBM_ERR "acpi_evalf() called "
228 "with invalid format character '%c'\n", res_type); 318 "with invalid format character '%c'\n", res_type);
@@ -262,7 +352,7 @@ static char *next_cmd(char **cmds)
262 return start; 352 return start;
263} 353}
264 354
265static int driver_init(struct ibm_struct *ibm) 355static int driver_init(void)
266{ 356{
267 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); 357 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
268 printk(IBM_INFO "%s\n", IBM_URL); 358 printk(IBM_INFO "%s\n", IBM_URL);
@@ -270,7 +360,7 @@ static int driver_init(struct ibm_struct *ibm)
270 return 0; 360 return 0;
271} 361}
272 362
273static int driver_read(struct ibm_struct *ibm, char *p) 363static int driver_read(char *p)
274{ 364{
275 int len = 0; 365 int len = 0;
276 366
@@ -280,67 +370,74 @@ static int driver_read(struct ibm_struct *ibm, char *p)
280 return len; 370 return len;
281} 371}
282 372
283static int hotkey_get(struct ibm_struct *ibm, int *status, int *mask) 373static int hotkey_supported;
374static int hotkey_mask_supported;
375static int hotkey_orig_status;
376static int hotkey_orig_mask;
377
378static int hotkey_get(int *status, int *mask)
284{ 379{
285 if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) 380 if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
286 return -EIO; 381 return 0;
287 if (ibm->supported) { 382
288 if (!acpi_evalf(hkey_handle, mask, "DHKN", "qd")) 383 if (hotkey_mask_supported)
289 return -EIO; 384 if (!acpi_evalf(hkey_handle, mask, "DHKN", "d"))
290 } else { 385 return 0;
291 *mask = ibm->state.hotkey.mask; 386
292 } 387 return 1;
293 return 0;
294} 388}
295 389
296static int hotkey_set(struct ibm_struct *ibm, int status, int mask) 390static int hotkey_set(int status, int mask)
297{ 391{
298 int i; 392 int i;
299 393
300 if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status)) 394 if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
301 return -EIO;
302
303 if (!ibm->supported)
304 return 0; 395 return 0;
305 396
306 for (i=0; i<32; i++) { 397 if (hotkey_mask_supported)
307 int bit = ((1 << i) & mask) != 0; 398 for (i = 0; i < 32; i++) {
308 if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit)) 399 int bit = ((1 << i) & mask) != 0;
309 return -EIO; 400 if (!acpi_evalf(hkey_handle,
310 } 401 NULL, "MHKM", "vdd", i + 1, bit))
402 return 0;
403 }
311 404
312 return 0; 405 return 1;
313} 406}
314 407
315static int hotkey_init(struct ibm_struct *ibm) 408static int hotkey_init(void)
316{ 409{
317 int ret; 410 /* hotkey not supported on 570 */
411 hotkey_supported = hkey_handle != NULL;
318 412
319 ibm->supported = 1; 413 if (hotkey_supported) {
320 ret = hotkey_get(ibm, 414 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
321 &ibm->state.hotkey.status, 415 A30, R30, R31, T20-22, X20-21, X22-24 */
322 &ibm->state.hotkey.mask); 416 hotkey_mask_supported =
323 if (ret < 0) { 417 acpi_evalf(hkey_handle, NULL, "DHKN", "qv");
324 /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ 418
325 ibm->supported = 0; 419 if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
326 ret = hotkey_get(ibm, 420 return -ENODEV;
327 &ibm->state.hotkey.status,
328 &ibm->state.hotkey.mask);
329 } 421 }
330 422
331 return ret; 423 return 0;
332} 424}
333 425
334static int hotkey_read(struct ibm_struct *ibm, char *p) 426static int hotkey_read(char *p)
335{ 427{
336 int status, mask; 428 int status, mask;
337 int len = 0; 429 int len = 0;
338 430
339 if (hotkey_get(ibm, &status, &mask) < 0) 431 if (!hotkey_supported) {
432 len += sprintf(p + len, "status:\t\tnot supported\n");
433 return len;
434 }
435
436 if (!hotkey_get(&status, &mask))
340 return -EIO; 437 return -EIO;
341 438
342 len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); 439 len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
343 if (ibm->supported) { 440 if (hotkey_mask_supported) {
344 len += sprintf(p + len, "mask:\t\t0x%04x\n", mask); 441 len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
345 len += sprintf(p + len, 442 len += sprintf(p + len,
346 "commands:\tenable, disable, reset, <mask>\n"); 443 "commands:\tenable, disable, reset, <mask>\n");
@@ -352,23 +449,26 @@ static int hotkey_read(struct ibm_struct *ibm, char *p)
352 return len; 449 return len;
353} 450}
354 451
355static int hotkey_write(struct ibm_struct *ibm, char *buf) 452static int hotkey_write(char *buf)
356{ 453{
357 int status, mask; 454 int status, mask;
358 char *cmd; 455 char *cmd;
359 int do_cmd = 0; 456 int do_cmd = 0;
360 457
361 if (hotkey_get(ibm, &status, &mask) < 0) 458 if (!hotkey_supported)
362 return -ENODEV; 459 return -ENODEV;
363 460
461 if (!hotkey_get(&status, &mask))
462 return -EIO;
463
364 while ((cmd = next_cmd(&buf))) { 464 while ((cmd = next_cmd(&buf))) {
365 if (strlencmp(cmd, "enable") == 0) { 465 if (strlencmp(cmd, "enable") == 0) {
366 status = 1; 466 status = 1;
367 } else if (strlencmp(cmd, "disable") == 0) { 467 } else if (strlencmp(cmd, "disable") == 0) {
368 status = 0; 468 status = 0;
369 } else if (strlencmp(cmd, "reset") == 0) { 469 } else if (strlencmp(cmd, "reset") == 0) {
370 status = ibm->state.hotkey.status; 470 status = hotkey_orig_status;
371 mask = ibm->state.hotkey.mask; 471 mask = hotkey_orig_mask;
372 } else if (sscanf(cmd, "0x%x", &mask) == 1) { 472 } else if (sscanf(cmd, "0x%x", &mask) == 1) {
373 /* mask set */ 473 /* mask set */
374 } else if (sscanf(cmd, "%x", &mask) == 1) { 474 } else if (sscanf(cmd, "%x", &mask) == 1) {
@@ -378,15 +478,16 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf)
378 do_cmd = 1; 478 do_cmd = 1;
379 } 479 }
380 480
381 if (do_cmd && hotkey_set(ibm, status, mask) < 0) 481 if (do_cmd && !hotkey_set(status, mask))
382 return -EIO; 482 return -EIO;
383 483
384 return 0; 484 return 0;
385} 485}
386 486
387static void hotkey_exit(struct ibm_struct *ibm) 487static void hotkey_exit(void)
388{ 488{
389 hotkey_set(ibm, ibm->state.hotkey.status, ibm->state.hotkey.mask); 489 if (hotkey_supported)
490 hotkey_set(hotkey_orig_status, hotkey_orig_mask);
390} 491}
391 492
392static void hotkey_notify(struct ibm_struct *ibm, u32 event) 493static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -398,33 +499,38 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
398 else { 499 else {
399 printk(IBM_ERR "unknown hotkey event %d\n", event); 500 printk(IBM_ERR "unknown hotkey event %d\n", event);
400 acpi_bus_generate_event(ibm->device, event, 0); 501 acpi_bus_generate_event(ibm->device, event, 0);
401 } 502 }
402} 503}
403 504
404static int bluetooth_init(struct ibm_struct *ibm) 505static int bluetooth_supported;
506
507static int bluetooth_init(void)
405{ 508{
406 /* bluetooth not supported on A21e, G40, T20, T21, X20 */ 509 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
407 ibm->supported = acpi_evalf(hkey_handle, NULL, "GBDC", "qv"); 510 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
511 bluetooth_supported = hkey_handle &&
512 acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
408 513
409 return 0; 514 return 0;
410} 515}
411 516
412static int bluetooth_status(struct ibm_struct *ibm) 517static int bluetooth_status(void)
413{ 518{
414 int status; 519 int status;
415 520
416 if (!ibm->supported || !acpi_evalf(hkey_handle, &status, "GBDC", "d")) 521 if (!bluetooth_supported ||
522 !acpi_evalf(hkey_handle, &status, "GBDC", "d"))
417 status = 0; 523 status = 0;
418 524
419 return status; 525 return status;
420} 526}
421 527
422static int bluetooth_read(struct ibm_struct *ibm, char *p) 528static int bluetooth_read(char *p)
423{ 529{
424 int len = 0; 530 int len = 0;
425 int status = bluetooth_status(ibm); 531 int status = bluetooth_status();
426 532
427 if (!ibm->supported) 533 if (!bluetooth_supported)
428 len += sprintf(p + len, "status:\t\tnot supported\n"); 534 len += sprintf(p + len, "status:\t\tnot supported\n");
429 else if (!(status & 1)) 535 else if (!(status & 1))
430 len += sprintf(p + len, "status:\t\tnot installed\n"); 536 len += sprintf(p + len, "status:\t\tnot installed\n");
@@ -436,14 +542,14 @@ static int bluetooth_read(struct ibm_struct *ibm, char *p)
436 return len; 542 return len;
437} 543}
438 544
439static int bluetooth_write(struct ibm_struct *ibm, char *buf) 545static int bluetooth_write(char *buf)
440{ 546{
441 int status = bluetooth_status(ibm); 547 int status = bluetooth_status();
442 char *cmd; 548 char *cmd;
443 int do_cmd = 0; 549 int do_cmd = 0;
444 550
445 if (!ibm->supported) 551 if (!bluetooth_supported)
446 return -EINVAL; 552 return -ENODEV;
447 553
448 while ((cmd = next_cmd(&buf))) { 554 while ((cmd = next_cmd(&buf))) {
449 if (strlencmp(cmd, "enable") == 0) { 555 if (strlencmp(cmd, "enable") == 0) {
@@ -456,64 +562,166 @@ static int bluetooth_write(struct ibm_struct *ibm, char *buf)
456 } 562 }
457 563
458 if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) 564 if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
459 return -EIO; 565 return -EIO;
460 566
461 return 0; 567 return 0;
462} 568}
463 569
464static int video_init(struct ibm_struct *ibm) 570static int video_supported;
571static int video_orig_autosw;
572
573#define VIDEO_570 1
574#define VIDEO_770 2
575#define VIDEO_NEW 3
576
577static int video_init(void)
465{ 578{
466 if (!acpi_evalf(vid_handle, 579 int ivga;
467 &ibm->state.video.autoswitch, "^VDEE", "d")) 580
468 return -ENODEV; 581 if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga)
582 /* G41, assume IVGA doesn't change */
583 vid_handle = vid2_handle;
584
585 if (!vid_handle)
586 /* video switching not supported on R30, R31 */
587 video_supported = 0;
588 else if (acpi_evalf(vid_handle, &video_orig_autosw, "SWIT", "qd"))
589 /* 570 */
590 video_supported = VIDEO_570;
591 else if (acpi_evalf(vid_handle, &video_orig_autosw, "^VADL", "qd"))
592 /* 600e/x, 770e, 770x */
593 video_supported = VIDEO_770;
594 else
595 /* all others */
596 video_supported = VIDEO_NEW;
469 597
470 return 0; 598 return 0;
471} 599}
472 600
473static int video_status(struct ibm_struct *ibm) 601static int video_status(void)
474{ 602{
475 int status = 0; 603 int status = 0;
476 int i; 604 int i;
477 605
478 acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1); 606 if (video_supported == VIDEO_570) {
479 if (acpi_evalf(NULL, &i, "\\VCDC", "d")) 607 if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87))
480 status |= 0x02 * i; 608 status = i & 3;
609 } else if (video_supported == VIDEO_770) {
610 if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
611 status |= 0x01 * i;
612 if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
613 status |= 0x02 * i;
614 } else if (video_supported == VIDEO_NEW) {
615 acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1);
616 if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
617 status |= 0x02 * i;
618
619 acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0);
620 if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
621 status |= 0x01 * i;
622 if (acpi_evalf(NULL, &i, "\\VCDD", "d"))
623 status |= 0x08 * i;
624 }
625
626 return status;
627}
481 628
482 acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0); 629static int video_autosw(void)
483 if (acpi_evalf(NULL, &i, "\\VCDL", "d")) 630{
484 status |= 0x01 * i; 631 int autosw = 0;
485 if (acpi_evalf(NULL, &i, "\\VCDD", "d"))
486 status |= 0x08 * i;
487 632
488 if (acpi_evalf(vid_handle, &i, "^VDEE", "d")) 633 if (video_supported == VIDEO_570)
489 status |= 0x10 * (i & 1); 634 acpi_evalf(vid_handle, &autosw, "SWIT", "d");
635 else if (video_supported == VIDEO_770 || video_supported == VIDEO_NEW)
636 acpi_evalf(vid_handle, &autosw, "^VDEE", "d");
490 637
491 return status; 638 return autosw & 1;
492} 639}
493 640
494static int video_read(struct ibm_struct *ibm, char *p) 641static int video_read(char *p)
495{ 642{
496 int status = video_status(ibm); 643 int status = video_status();
644 int autosw = video_autosw();
497 int len = 0; 645 int len = 0;
498 646
647 if (!video_supported) {
648 len += sprintf(p + len, "status:\t\tnot supported\n");
649 return len;
650 }
651
652 len += sprintf(p + len, "status:\t\tsupported\n");
499 len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0)); 653 len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0));
500 len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1)); 654 len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1));
501 len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); 655 if (video_supported == VIDEO_NEW)
502 len += sprintf(p + len, "auto:\t\t%s\n", enabled(status, 4)); 656 len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3));
503 len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable, " 657 len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0));
504 "crt_enable, crt_disable\n"); 658 len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n");
505 len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable, " 659 len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n");
506 "auto_enable, auto_disable\n"); 660 if (video_supported == VIDEO_NEW)
661 len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n");
662 len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n");
507 len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n"); 663 len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n");
508 664
509 return len; 665 return len;
510} 666}
511 667
512static int video_write(struct ibm_struct *ibm, char *buf) 668static int video_switch(void)
669{
670 int autosw = video_autosw();
671 int ret;
672
673 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
674 return -EIO;
675 ret = video_supported == VIDEO_570 ?
676 acpi_evalf(ec_handle, NULL, "_Q16", "v") :
677 acpi_evalf(vid_handle, NULL, "VSWT", "v");
678 acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw);
679
680 return ret;
681}
682
683static int video_expand(void)
684{
685 if (video_supported == VIDEO_570)
686 return acpi_evalf(ec_handle, NULL, "_Q17", "v");
687 else if (video_supported == VIDEO_770)
688 return acpi_evalf(vid_handle, NULL, "VEXP", "v");
689 else
690 return acpi_evalf(NULL, NULL, "\\VEXP", "v");
691}
692
693static int video_switch2(int status)
694{
695 int ret;
696
697 if (video_supported == VIDEO_570) {
698 ret = acpi_evalf(NULL, NULL,
699 "\\_SB.PHS2", "vdd", 0x8b, status | 0x80);
700 } else if (video_supported == VIDEO_770) {
701 int autosw = video_autosw();
702 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
703 return -EIO;
704
705 ret = acpi_evalf(vid_handle, NULL,
706 "ASWT", "vdd", status * 0x100, 0);
707
708 acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw);
709 } else {
710 ret = acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80) &&
711 acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1);
712 }
713
714 return ret;
715}
716
717static int video_write(char *buf)
513{ 718{
514 char *cmd; 719 char *cmd;
515 int enable, disable, status; 720 int enable, disable, status;
516 721
722 if (!video_supported)
723 return -ENODEV;
724
517 enable = disable = 0; 725 enable = disable = 0;
518 726
519 while ((cmd = next_cmd(&buf))) { 727 while ((cmd = next_cmd(&buf))) {
@@ -525,9 +733,11 @@ static int video_write(struct ibm_struct *ibm, char *buf)
525 enable |= 0x02; 733 enable |= 0x02;
526 } else if (strlencmp(cmd, "crt_disable") == 0) { 734 } else if (strlencmp(cmd, "crt_disable") == 0) {
527 disable |= 0x02; 735 disable |= 0x02;
528 } else if (strlencmp(cmd, "dvi_enable") == 0) { 736 } else if (video_supported == VIDEO_NEW &&
737 strlencmp(cmd, "dvi_enable") == 0) {
529 enable |= 0x08; 738 enable |= 0x08;
530 } else if (strlencmp(cmd, "dvi_disable") == 0) { 739 } else if (video_supported == VIDEO_NEW &&
740 strlencmp(cmd, "dvi_disable") == 0) {
531 disable |= 0x08; 741 disable |= 0x08;
532 } else if (strlencmp(cmd, "auto_enable") == 0) { 742 } else if (strlencmp(cmd, "auto_enable") == 0) {
533 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) 743 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
@@ -536,71 +746,75 @@ static int video_write(struct ibm_struct *ibm, char *buf)
536 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 0)) 746 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 0))
537 return -EIO; 747 return -EIO;
538 } else if (strlencmp(cmd, "video_switch") == 0) { 748 } else if (strlencmp(cmd, "video_switch") == 0) {
539 int autoswitch; 749 if (!video_switch())
540 if (!acpi_evalf(vid_handle, &autoswitch, "^VDEE", "d"))
541 return -EIO;
542 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
543 return -EIO;
544 if (!acpi_evalf(vid_handle, NULL, "VSWT", "v"))
545 return -EIO;
546 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd",
547 autoswitch))
548 return -EIO; 750 return -EIO;
549 } else if (strlencmp(cmd, "expand_toggle") == 0) { 751 } else if (strlencmp(cmd, "expand_toggle") == 0) {
550 if (!acpi_evalf(NULL, NULL, "\\VEXP", "v")) 752 if (!video_expand())
551 return -EIO; 753 return -EIO;
552 } else 754 } else
553 return -EINVAL; 755 return -EINVAL;
554 } 756 }
555 757
556 if (enable || disable) { 758 if (enable || disable) {
557 status = (video_status(ibm) & 0x0f & ~disable) | enable; 759 status = (video_status() & 0x0f & ~disable) | enable;
558 if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80)) 760 if (!video_switch2(status))
559 return -EIO;
560 if (!acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1))
561 return -EIO; 761 return -EIO;
562 } 762 }
563 763
564 return 0; 764 return 0;
565} 765}
566 766
567static void video_exit(struct ibm_struct *ibm) 767static void video_exit(void)
568{ 768{
569 acpi_evalf(vid_handle, NULL, "_DOS", "vd", 769 acpi_evalf(vid_handle, NULL, "_DOS", "vd", video_orig_autosw);
570 ibm->state.video.autoswitch);
571} 770}
572 771
573static int light_init(struct ibm_struct *ibm) 772static int light_supported;
773static int light_status_supported;
774
775static int light_init(void)
574{ 776{
575 /* kblt not supported on G40, R32, X20 */ 777 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
576 ibm->supported = acpi_evalf(ec_handle, NULL, "KBLT", "qv"); 778 light_supported = (cmos_handle || lght_handle) && !ledb_handle;
779
780 if (light_supported)
781 /* light status not supported on
782 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
783 light_status_supported = acpi_evalf(ec_handle, NULL,
784 "KBLT", "qv");
577 785
578 return 0; 786 return 0;
579} 787}
580 788
581static int light_read(struct ibm_struct *ibm, char *p) 789static int light_read(char *p)
582{ 790{
583 int len = 0; 791 int len = 0;
584 int status = 0; 792 int status = 0;
585 793
586 if (ibm->supported) { 794 if (!light_supported) {
795 len += sprintf(p + len, "status:\t\tnot supported\n");
796 } else if (!light_status_supported) {
797 len += sprintf(p + len, "status:\t\tunknown\n");
798 len += sprintf(p + len, "commands:\ton, off\n");
799 } else {
587 if (!acpi_evalf(ec_handle, &status, "KBLT", "d")) 800 if (!acpi_evalf(ec_handle, &status, "KBLT", "d"))
588 return -EIO; 801 return -EIO;
589 len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0)); 802 len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0));
590 } else 803 len += sprintf(p + len, "commands:\ton, off\n");
591 len += sprintf(p + len, "status:\t\tunknown\n"); 804 }
592
593 len += sprintf(p + len, "commands:\ton, off\n");
594 805
595 return len; 806 return len;
596} 807}
597 808
598static int light_write(struct ibm_struct *ibm, char *buf) 809static int light_write(char *buf)
599{ 810{
600 int cmos_cmd, lght_cmd; 811 int cmos_cmd, lght_cmd;
601 char *cmd; 812 char *cmd;
602 int success; 813 int success;
603 814
815 if (!light_supported)
816 return -ENODEV;
817
604 while ((cmd = next_cmd(&buf))) { 818 while ((cmd = next_cmd(&buf))) {
605 if (strlencmp(cmd, "on") == 0) { 819 if (strlencmp(cmd, "on") == 0) {
606 cmos_cmd = 0x0c; 820 cmos_cmd = 0x0c;
@@ -610,10 +824,10 @@ static int light_write(struct ibm_struct *ibm, char *buf)
610 lght_cmd = 0; 824 lght_cmd = 0;
611 } else 825 } else
612 return -EINVAL; 826 return -EINVAL;
613 827
614 success = cmos_handle ? 828 success = cmos_handle ?
615 acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : 829 acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) :
616 acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); 830 acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd);
617 if (!success) 831 if (!success)
618 return -EIO; 832 return -EIO;
619 } 833 }
@@ -633,7 +847,7 @@ static int _sta(acpi_handle handle)
633 847
634#define dock_docked() (_sta(dock_handle) & 1) 848#define dock_docked() (_sta(dock_handle) & 1)
635 849
636static int dock_read(struct ibm_struct *ibm, char *p) 850static int dock_read(char *p)
637{ 851{
638 int len = 0; 852 int len = 0;
639 int docked = dock_docked(); 853 int docked = dock_docked();
@@ -650,18 +864,17 @@ static int dock_read(struct ibm_struct *ibm, char *p)
650 return len; 864 return len;
651} 865}
652 866
653static int dock_write(struct ibm_struct *ibm, char *buf) 867static int dock_write(char *buf)
654{ 868{
655 char *cmd; 869 char *cmd;
656 870
657 if (!dock_docked()) 871 if (!dock_docked())
658 return -EINVAL; 872 return -ENODEV;
659 873
660 while ((cmd = next_cmd(&buf))) { 874 while ((cmd = next_cmd(&buf))) {
661 if (strlencmp(cmd, "undock") == 0) { 875 if (strlencmp(cmd, "undock") == 0) {
662 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0)) 876 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0) ||
663 return -EIO; 877 !acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1))
664 if (!acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1))
665 return -EIO; 878 return -EIO;
666 } else if (strlencmp(cmd, "dock") == 0) { 879 } else if (strlencmp(cmd, "dock") == 0) {
667 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 1)) 880 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 1))
@@ -671,90 +884,131 @@ static int dock_write(struct ibm_struct *ibm, char *buf)
671 } 884 }
672 885
673 return 0; 886 return 0;
674} 887}
675 888
676static void dock_notify(struct ibm_struct *ibm, u32 event) 889static void dock_notify(struct ibm_struct *ibm, u32 event)
677{ 890{
678 int docked = dock_docked(); 891 int docked = dock_docked();
679 892 int pci = ibm->hid && strstr(ibm->hid, IBM_PCI_HID);
680 if (event == 3 && docked) 893
681 acpi_bus_generate_event(ibm->device, event, 1); /* button */ 894 if (event == 1 && !pci) /* 570 */
895 acpi_bus_generate_event(ibm->device, event, 1); /* button */
896 else if (event == 1 && pci) /* 570 */
897 acpi_bus_generate_event(ibm->device, event, 3); /* dock */
898 else if (event == 3 && docked)
899 acpi_bus_generate_event(ibm->device, event, 1); /* button */
682 else if (event == 3 && !docked) 900 else if (event == 3 && !docked)
683 acpi_bus_generate_event(ibm->device, event, 2); /* undock */ 901 acpi_bus_generate_event(ibm->device, event, 2); /* undock */
684 else if (event == 0 && docked) 902 else if (event == 0 && docked)
685 acpi_bus_generate_event(ibm->device, event, 3); /* dock */ 903 acpi_bus_generate_event(ibm->device, event, 3); /* dock */
686 else { 904 else {
687 printk(IBM_ERR "unknown dock event %d, status %d\n", 905 printk(IBM_ERR "unknown dock event %d, status %d\n",
688 event, _sta(dock_handle)); 906 event, _sta(dock_handle));
689 acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ 907 acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
690 } 908 }
691} 909}
692 910
693#define bay_occupied() (_sta(bay_handle) & 1) 911static int bay_status_supported;
912static int bay_status2_supported;
913static int bay_eject_supported;
914static int bay_eject2_supported;
694 915
695static int bay_init(struct ibm_struct *ibm) 916static int bay_init(void)
696{ 917{
697 /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ 918 bay_status_supported = bay_handle &&
698 ibm->supported = bay_handle && bayej_handle && 919 acpi_evalf(bay_handle, NULL, "_STA", "qv");
699 acpi_evalf(bay_handle, NULL, "_STA", "qv"); 920 bay_status2_supported = bay2_handle &&
921 acpi_evalf(bay2_handle, NULL, "_STA", "qv");
922
923 bay_eject_supported = bay_handle && bay_ej_handle &&
924 (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental);
925 bay_eject2_supported = bay2_handle && bay2_ej_handle &&
926 (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
700 927
701 return 0; 928 return 0;
702} 929}
703 930
704static int bay_read(struct ibm_struct *ibm, char *p) 931#define bay_occupied(b) (_sta(b##_handle) & 1)
932
933static int bay_read(char *p)
705{ 934{
706 int len = 0; 935 int len = 0;
707 int occupied = bay_occupied(); 936 int occupied = bay_occupied(bay);
708 937 int occupied2 = bay_occupied(bay2);
709 if (!ibm->supported) 938 int eject, eject2;
710 len += sprintf(p + len, "status:\t\tnot supported\n"); 939
711 else if (!occupied) 940 len += sprintf(p + len, "status:\t\t%s\n", bay_status_supported ?
712 len += sprintf(p + len, "status:\t\tunoccupied\n"); 941 (occupied ? "occupied" : "unoccupied") :
713 else { 942 "not supported");
714 len += sprintf(p + len, "status:\t\toccupied\n"); 943 if (bay_status2_supported)
944 len += sprintf(p + len, "status2:\t%s\n", occupied2 ?
945 "occupied" : "unoccupied");
946
947 eject = bay_eject_supported && occupied;
948 eject2 = bay_eject2_supported && occupied2;
949
950 if (eject && eject2)
951 len += sprintf(p + len, "commands:\teject, eject2\n");
952 else if (eject)
715 len += sprintf(p + len, "commands:\teject\n"); 953 len += sprintf(p + len, "commands:\teject\n");
716 } 954 else if (eject2)
955 len += sprintf(p + len, "commands:\teject2\n");
717 956
718 return len; 957 return len;
719} 958}
720 959
721static int bay_write(struct ibm_struct *ibm, char *buf) 960static int bay_write(char *buf)
722{ 961{
723 char *cmd; 962 char *cmd;
724 963
964 if (!bay_eject_supported && !bay_eject2_supported)
965 return -ENODEV;
966
725 while ((cmd = next_cmd(&buf))) { 967 while ((cmd = next_cmd(&buf))) {
726 if (strlencmp(cmd, "eject") == 0) { 968 if (bay_eject_supported && strlencmp(cmd, "eject") == 0) {
727 if (!ibm->supported || 969 if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1))
728 !acpi_evalf(bay_handle, NULL, "_EJ0", "vd", 1)) 970 return -EIO;
971 } else if (bay_eject2_supported &&
972 strlencmp(cmd, "eject2") == 0) {
973 if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1))
729 return -EIO; 974 return -EIO;
730 } else 975 } else
731 return -EINVAL; 976 return -EINVAL;
732 } 977 }
733 978
734 return 0; 979 return 0;
735} 980}
736 981
737static void bay_notify(struct ibm_struct *ibm, u32 event) 982static void bay_notify(struct ibm_struct *ibm, u32 event)
738{ 983{
739 acpi_bus_generate_event(ibm->device, event, 0); 984 acpi_bus_generate_event(ibm->device, event, 0);
740} 985}
741 986
742static int cmos_read(struct ibm_struct *ibm, char *p) 987static int cmos_read(char *p)
743{ 988{
744 int len = 0; 989 int len = 0;
745 990
746 /* cmos not supported on A21e, A22p, T20, T21, X20 */ 991 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
992 R30, R31, T20-22, X20-21 */
747 if (!cmos_handle) 993 if (!cmos_handle)
748 len += sprintf(p + len, "status:\t\tnot supported\n"); 994 len += sprintf(p + len, "status:\t\tnot supported\n");
749 else { 995 else {
750 len += sprintf(p + len, "status:\t\tsupported\n"); 996 len += sprintf(p + len, "status:\t\tsupported\n");
751 len += sprintf(p + len, "commands:\t<int>\n"); 997 len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-21)\n");
752 } 998 }
753 999
754 return len; 1000 return len;
755} 1001}
756 1002
757static int cmos_write(struct ibm_struct *ibm, char *buf) 1003static int cmos_eval(int cmos_cmd)
1004{
1005 if (cmos_handle)
1006 return acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd);
1007 else
1008 return 1;
1009}
1010
1011static int cmos_write(char *buf)
758{ 1012{
759 char *cmd; 1013 char *cmd;
760 int cmos_cmd; 1014 int cmos_cmd;
@@ -763,183 +1017,644 @@ static int cmos_write(struct ibm_struct *ibm, char *buf)
763 return -EINVAL; 1017 return -EINVAL;
764 1018
765 while ((cmd = next_cmd(&buf))) { 1019 while ((cmd = next_cmd(&buf))) {
766 if (sscanf(cmd, "%u", &cmos_cmd) == 1) { 1020 if (sscanf(cmd, "%u", &cmos_cmd) == 1 &&
1021 cmos_cmd >= 0 && cmos_cmd <= 21) {
767 /* cmos_cmd set */ 1022 /* cmos_cmd set */
768 } else 1023 } else
769 return -EINVAL; 1024 return -EINVAL;
770 1025
771 if (!acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd)) 1026 if (!cmos_eval(cmos_cmd))
772 return -EIO; 1027 return -EIO;
773 } 1028 }
774 1029
775 return 0; 1030 return 0;
776} 1031}
777 1032
778static int led_read(struct ibm_struct *ibm, char *p) 1033static int led_supported;
1034
1035#define LED_570 1
1036#define LED_OLD 2
1037#define LED_NEW 3
1038
1039static int led_init(void)
1040{
1041 if (!led_handle)
1042 /* led not supported on R30, R31 */
1043 led_supported = 0;
1044 else if (strlencmp(led_path, "SLED") == 0)
1045 /* 570 */
1046 led_supported = LED_570;
1047 else if (strlencmp(led_path, "SYSL") == 0)
1048 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1049 led_supported = LED_OLD;
1050 else
1051 /* all others */
1052 led_supported = LED_NEW;
1053
1054 return 0;
1055}
1056
1057#define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
1058
1059static int led_read(char *p)
779{ 1060{
780 int len = 0; 1061 int len = 0;
781 1062
1063 if (!led_supported) {
1064 len += sprintf(p + len, "status:\t\tnot supported\n");
1065 return len;
1066 }
1067 len += sprintf(p + len, "status:\t\tsupported\n");
1068
1069 if (led_supported == LED_570) {
1070 /* 570 */
1071 int i, status;
1072 for (i = 0; i < 8; i++) {
1073 if (!acpi_evalf(ec_handle,
1074 &status, "GLED", "dd", 1 << i))
1075 return -EIO;
1076 len += sprintf(p + len, "%d:\t\t%s\n",
1077 i, led_status(status));
1078 }
1079 }
1080
782 len += sprintf(p + len, "commands:\t" 1081 len += sprintf(p + len, "commands:\t"
783 "<int> on, <int> off, <int> blink\n"); 1082 "<led> on, <led> off, <led> blink (<led> is 0-7)\n");
784 1083
785 return len; 1084 return len;
786} 1085}
787 1086
788static int led_write(struct ibm_struct *ibm, char *buf) 1087/* off, on, blink */
1088static const int led_sled_arg1[] = { 0, 1, 3 };
1089static const int led_exp_hlbl[] = { 0, 0, 1 }; /* led# * */
1090static const int led_exp_hlcl[] = { 0, 1, 1 }; /* led# * */
1091static const int led_led_arg1[] = { 0, 0x80, 0xc0 };
1092
1093#define EC_HLCL 0x0c
1094#define EC_HLBL 0x0d
1095#define EC_HLMS 0x0e
1096
1097static int led_write(char *buf)
789{ 1098{
790 char *cmd; 1099 char *cmd;
791 unsigned int led; 1100 int led, ind, ret;
792 int led_cmd, sysl_cmd, bled_a, bled_b; 1101
1102 if (!led_supported)
1103 return -ENODEV;
793 1104
794 while ((cmd = next_cmd(&buf))) { 1105 while ((cmd = next_cmd(&buf))) {
795 if (sscanf(cmd, "%u", &led) != 1) 1106 if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 7)
796 return -EINVAL; 1107 return -EINVAL;
797 1108
798 if (strstr(cmd, "blink")) { 1109 if (strstr(cmd, "off")) {
799 led_cmd = 0xc0; 1110 ind = 0;
800 sysl_cmd = 2;
801 bled_a = 2;
802 bled_b = 1;
803 } else if (strstr(cmd, "on")) { 1111 } else if (strstr(cmd, "on")) {
804 led_cmd = 0x80; 1112 ind = 1;
805 sysl_cmd = 1; 1113 } else if (strstr(cmd, "blink")) {
806 bled_a = 2; 1114 ind = 2;
807 bled_b = 0;
808 } else if (strstr(cmd, "off")) {
809 led_cmd = sysl_cmd = bled_a = bled_b = 0;
810 } else 1115 } else
811 return -EINVAL; 1116 return -EINVAL;
812 1117
813 if (led_handle) { 1118 if (led_supported == LED_570) {
1119 /* 570 */
1120 led = 1 << led;
814 if (!acpi_evalf(led_handle, NULL, NULL, "vdd", 1121 if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
815 led, led_cmd)) 1122 led, led_sled_arg1[ind]))
816 return -EIO; 1123 return -EIO;
817 } else if (led < 2) { 1124 } else if (led_supported == LED_OLD) {
818 if (acpi_evalf(sysl_handle, NULL, NULL, "vdd", 1125 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
819 led, sysl_cmd)) 1126 led = 1 << led;
1127 ret = ec_write(EC_HLMS, led);
1128 if (ret >= 0)
1129 ret =
1130 ec_write(EC_HLBL, led * led_exp_hlbl[ind]);
1131 if (ret >= 0)
1132 ret =
1133 ec_write(EC_HLCL, led * led_exp_hlcl[ind]);
1134 if (ret < 0)
1135 return ret;
1136 } else {
1137 /* all others */
1138 if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
1139 led, led_led_arg1[ind]))
820 return -EIO; 1140 return -EIO;
821 } else if (led == 2 && bled_handle) { 1141 }
822 if (acpi_evalf(bled_handle, NULL, NULL, "vdd", 1142 }
823 bled_a, bled_b)) 1143
1144 return 0;
1145}
1146
1147static int beep_read(char *p)
1148{
1149 int len = 0;
1150
1151 if (!beep_handle)
1152 len += sprintf(p + len, "status:\t\tnot supported\n");
1153 else {
1154 len += sprintf(p + len, "status:\t\tsupported\n");
1155 len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-17)\n");
1156 }
1157
1158 return len;
1159}
1160
1161static int beep_write(char *buf)
1162{
1163 char *cmd;
1164 int beep_cmd;
1165
1166 if (!beep_handle)
1167 return -ENODEV;
1168
1169 while ((cmd = next_cmd(&buf))) {
1170 if (sscanf(cmd, "%u", &beep_cmd) == 1 &&
1171 beep_cmd >= 0 && beep_cmd <= 17) {
1172 /* beep_cmd set */
1173 } else
1174 return -EINVAL;
1175 if (!acpi_evalf(beep_handle, NULL, NULL, "vdd", beep_cmd, 0))
1176 return -EIO;
1177 }
1178
1179 return 0;
1180}
1181
1182static int acpi_ec_read(int i, u8 * p)
1183{
1184 int v;
1185
1186 if (ecrd_handle) {
1187 if (!acpi_evalf(ecrd_handle, &v, NULL, "dd", i))
1188 return 0;
1189 *p = v;
1190 } else {
1191 if (ec_read(i, p) < 0)
1192 return 0;
1193 }
1194
1195 return 1;
1196}
1197
1198static int acpi_ec_write(int i, u8 v)
1199{
1200 if (ecwr_handle) {
1201 if (!acpi_evalf(ecwr_handle, NULL, NULL, "vdd", i, v))
1202 return 0;
1203 } else {
1204 if (ec_write(i, v) < 0)
1205 return 0;
1206 }
1207
1208 return 1;
1209}
1210
1211static int thermal_tmp_supported;
1212static int thermal_updt_supported;
1213
1214static int thermal_init(void)
1215{
1216 /* temperatures not supported on 570, G4x, R30, R31, R32 */
1217 thermal_tmp_supported = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
1218
1219 /* 600e/x, 770e, 770x */
1220 thermal_updt_supported = acpi_evalf(ec_handle, NULL, "UPDT", "qv");
1221
1222 return 0;
1223}
1224
1225static int thermal_read(char *p)
1226{
1227 int len = 0;
1228
1229 if (!thermal_tmp_supported)
1230 len += sprintf(p + len, "temperatures:\tnot supported\n");
1231 else {
1232 int i, t;
1233 char tmpi[] = "TMPi";
1234 s8 tmp[8];
1235
1236 if (thermal_updt_supported)
1237 if (!acpi_evalf(ec_handle, NULL, "UPDT", "v"))
1238 return -EIO;
1239
1240 for (i = 0; i < 8; i++) {
1241 tmpi[3] = '0' + i;
1242 if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
1243 return -EIO;
1244 if (thermal_updt_supported)
1245 tmp[i] = (t - 2732 + 5) / 10;
1246 else
1247 tmp[i] = t;
1248 }
1249
1250 len += sprintf(p + len,
1251 "temperatures:\t%d %d %d %d %d %d %d %d\n",
1252 tmp[0], tmp[1], tmp[2], tmp[3],
1253 tmp[4], tmp[5], tmp[6], tmp[7]);
1254 }
1255
1256 return len;
1257}
1258
1259static u8 ecdump_regs[256];
1260
1261static int ecdump_read(char *p)
1262{
1263 int len = 0;
1264 int i, j;
1265 u8 v;
1266
1267 len += sprintf(p + len, "EC "
1268 " +00 +01 +02 +03 +04 +05 +06 +07"
1269 " +08 +09 +0a +0b +0c +0d +0e +0f\n");
1270 for (i = 0; i < 256; i += 16) {
1271 len += sprintf(p + len, "EC 0x%02x:", i);
1272 for (j = 0; j < 16; j++) {
1273 if (!acpi_ec_read(i + j, &v))
1274 break;
1275 if (v != ecdump_regs[i + j])
1276 len += sprintf(p + len, " *%02x", v);
1277 else
1278 len += sprintf(p + len, " %02x", v);
1279 ecdump_regs[i + j] = v;
1280 }
1281 len += sprintf(p + len, "\n");
1282 if (j != 16)
1283 break;
1284 }
1285
1286 /* These are way too dangerous to advertise openly... */
1287#if 0
1288 len += sprintf(p + len, "commands:\t0x<offset> 0x<value>"
1289 " (<offset> is 00-ff, <value> is 00-ff)\n");
1290 len += sprintf(p + len, "commands:\t0x<offset> <value> "
1291 " (<offset> is 00-ff, <value> is 0-255)\n");
1292#endif
1293 return len;
1294}
1295
1296static int ecdump_write(char *buf)
1297{
1298 char *cmd;
1299 int i, v;
1300
1301 while ((cmd = next_cmd(&buf))) {
1302 if (sscanf(cmd, "0x%x 0x%x", &i, &v) == 2) {
1303 /* i and v set */
1304 } else if (sscanf(cmd, "0x%x %u", &i, &v) == 2) {
1305 /* i and v set */
1306 } else
1307 return -EINVAL;
1308 if (i >= 0 && i < 256 && v >= 0 && v < 256) {
1309 if (!acpi_ec_write(i, v))
824 return -EIO; 1310 return -EIO;
825 } else 1311 } else
826 return -EINVAL; 1312 return -EINVAL;
827 } 1313 }
828 1314
829 return 0; 1315 return 0;
830} 1316}
831 1317
832static int beep_read(struct ibm_struct *ibm, char *p) 1318static int brightness_offset = 0x31;
1319
1320static int brightness_read(char *p)
833{ 1321{
834 int len = 0; 1322 int len = 0;
1323 u8 level;
835 1324
836 len += sprintf(p + len, "commands:\t<int>\n"); 1325 if (!acpi_ec_read(brightness_offset, &level)) {
1326 len += sprintf(p + len, "level:\t\tunreadable\n");
1327 } else {
1328 len += sprintf(p + len, "level:\t\t%d\n", level & 0x7);
1329 len += sprintf(p + len, "commands:\tup, down\n");
1330 len += sprintf(p + len, "commands:\tlevel <level>"
1331 " (<level> is 0-7)\n");
1332 }
837 1333
838 return len; 1334 return len;
839} 1335}
840 1336
841static int beep_write(struct ibm_struct *ibm, char *buf) 1337#define BRIGHTNESS_UP 4
1338#define BRIGHTNESS_DOWN 5
1339
1340static int brightness_write(char *buf)
842{ 1341{
1342 int cmos_cmd, inc, i;
1343 u8 level;
1344 int new_level;
843 char *cmd; 1345 char *cmd;
844 int beep_cmd;
845 1346
846 while ((cmd = next_cmd(&buf))) { 1347 while ((cmd = next_cmd(&buf))) {
847 if (sscanf(cmd, "%u", &beep_cmd) == 1) { 1348 if (!acpi_ec_read(brightness_offset, &level))
848 /* beep_cmd set */ 1349 return -EIO;
1350 level &= 7;
1351
1352 if (strlencmp(cmd, "up") == 0) {
1353 new_level = level == 7 ? 7 : level + 1;
1354 } else if (strlencmp(cmd, "down") == 0) {
1355 new_level = level == 0 ? 0 : level - 1;
1356 } else if (sscanf(cmd, "level %d", &new_level) == 1 &&
1357 new_level >= 0 && new_level <= 7) {
1358 /* new_level set */
1359 } else
1360 return -EINVAL;
1361
1362 cmos_cmd = new_level > level ? BRIGHTNESS_UP : BRIGHTNESS_DOWN;
1363 inc = new_level > level ? 1 : -1;
1364 for (i = level; i != new_level; i += inc) {
1365 if (!cmos_eval(cmos_cmd))
1366 return -EIO;
1367 if (!acpi_ec_write(brightness_offset, i + inc))
1368 return -EIO;
1369 }
1370 }
1371
1372 return 0;
1373}
1374
1375static int volume_offset = 0x30;
1376
1377static int volume_read(char *p)
1378{
1379 int len = 0;
1380 u8 level;
1381
1382 if (!acpi_ec_read(volume_offset, &level)) {
1383 len += sprintf(p + len, "level:\t\tunreadable\n");
1384 } else {
1385 len += sprintf(p + len, "level:\t\t%d\n", level & 0xf);
1386 len += sprintf(p + len, "mute:\t\t%s\n", onoff(level, 6));
1387 len += sprintf(p + len, "commands:\tup, down, mute\n");
1388 len += sprintf(p + len, "commands:\tlevel <level>"
1389 " (<level> is 0-15)\n");
1390 }
1391
1392 return len;
1393}
1394
1395#define VOLUME_DOWN 0
1396#define VOLUME_UP 1
1397#define VOLUME_MUTE 2
1398
1399static int volume_write(char *buf)
1400{
1401 int cmos_cmd, inc, i;
1402 u8 level, mute;
1403 int new_level, new_mute;
1404 char *cmd;
1405
1406 while ((cmd = next_cmd(&buf))) {
1407 if (!acpi_ec_read(volume_offset, &level))
1408 return -EIO;
1409 new_mute = mute = level & 0x40;
1410 new_level = level = level & 0xf;
1411
1412 if (strlencmp(cmd, "up") == 0) {
1413 if (mute)
1414 new_mute = 0;
1415 else
1416 new_level = level == 15 ? 15 : level + 1;
1417 } else if (strlencmp(cmd, "down") == 0) {
1418 if (mute)
1419 new_mute = 0;
1420 else
1421 new_level = level == 0 ? 0 : level - 1;
1422 } else if (sscanf(cmd, "level %d", &new_level) == 1 &&
1423 new_level >= 0 && new_level <= 15) {
1424 /* new_level set */
1425 } else if (strlencmp(cmd, "mute") == 0) {
1426 new_mute = 0x40;
849 } else 1427 } else
850 return -EINVAL; 1428 return -EINVAL;
851 1429
852 if (!acpi_evalf(beep_handle, NULL, NULL, "vd", beep_cmd)) 1430 if (new_level != level) { /* mute doesn't change */
1431 cmos_cmd = new_level > level ? VOLUME_UP : VOLUME_DOWN;
1432 inc = new_level > level ? 1 : -1;
1433
1434 if (mute && (!cmos_eval(cmos_cmd) ||
1435 !acpi_ec_write(volume_offset, level)))
1436 return -EIO;
1437
1438 for (i = level; i != new_level; i += inc)
1439 if (!cmos_eval(cmos_cmd) ||
1440 !acpi_ec_write(volume_offset, i + inc))
1441 return -EIO;
1442
1443 if (mute && (!cmos_eval(VOLUME_MUTE) ||
1444 !acpi_ec_write(volume_offset,
1445 new_level + mute)))
1446 return -EIO;
1447 }
1448
1449 if (new_mute != mute) { /* level doesn't change */
1450 cmos_cmd = new_mute ? VOLUME_MUTE : VOLUME_UP;
1451
1452 if (!cmos_eval(cmos_cmd) ||
1453 !acpi_ec_write(volume_offset, level + new_mute))
1454 return -EIO;
1455 }
1456 }
1457
1458 return 0;
1459}
1460
1461static int fan_status_offset = 0x2f;
1462static int fan_rpm_offset = 0x84;
1463
1464static int fan_read(char *p)
1465{
1466 int len = 0;
1467 int s;
1468 u8 lo, hi, status;
1469
1470 if (gfan_handle) {
1471 /* 570, 600e/x, 770e, 770x */
1472 if (!acpi_evalf(gfan_handle, &s, NULL, "d"))
853 return -EIO; 1473 return -EIO;
1474
1475 len += sprintf(p + len, "level:\t\t%d\n", s);
1476 } else {
1477 /* all except 570, 600e/x, 770e, 770x */
1478 if (!acpi_ec_read(fan_status_offset, &status))
1479 len += sprintf(p + len, "status:\t\tunreadable\n");
1480 else
1481 len += sprintf(p + len, "status:\t\t%s\n",
1482 enabled(status, 7));
1483
1484 if (!acpi_ec_read(fan_rpm_offset, &lo) ||
1485 !acpi_ec_read(fan_rpm_offset + 1, &hi))
1486 len += sprintf(p + len, "speed:\t\tunreadable\n");
1487 else
1488 len += sprintf(p + len, "speed:\t\t%d\n",
1489 (hi << 8) + lo);
1490 }
1491
1492 if (sfan_handle)
1493 /* 570, 770x-JL */
1494 len += sprintf(p + len, "commands:\tlevel <level>"
1495 " (<level> is 0-7)\n");
1496 if (!gfan_handle)
1497 /* all except 570, 600e/x, 770e, 770x */
1498 len += sprintf(p + len, "commands:\tenable, disable\n");
1499 if (fans_handle)
1500 /* X31, X40 */
1501 len += sprintf(p + len, "commands:\tspeed <speed>"
1502 " (<speed> is 0-65535)\n");
1503
1504 return len;
1505}
1506
1507static int fan_write(char *buf)
1508{
1509 char *cmd;
1510 int level, speed;
1511
1512 while ((cmd = next_cmd(&buf))) {
1513 if (sfan_handle &&
1514 sscanf(cmd, "level %d", &level) == 1 &&
1515 level >= 0 && level <= 7) {
1516 /* 570, 770x-JL */
1517 if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level))
1518 return -EIO;
1519 } else if (!gfan_handle && strlencmp(cmd, "enable") == 0) {
1520 /* all except 570, 600e/x, 770e, 770x */
1521 if (!acpi_ec_write(fan_status_offset, 0x80))
1522 return -EIO;
1523 } else if (!gfan_handle && strlencmp(cmd, "disable") == 0) {
1524 /* all except 570, 600e/x, 770e, 770x */
1525 if (!acpi_ec_write(fan_status_offset, 0x00))
1526 return -EIO;
1527 } else if (fans_handle &&
1528 sscanf(cmd, "speed %d", &speed) == 1 &&
1529 speed >= 0 && speed <= 65535) {
1530 /* X31, X40 */
1531 if (!acpi_evalf(fans_handle, NULL, NULL, "vddd",
1532 speed, speed, speed))
1533 return -EIO;
1534 } else
1535 return -EINVAL;
854 } 1536 }
855 1537
856 return 0; 1538 return 0;
857} 1539}
858 1540
859static struct ibm_struct ibms[] = { 1541static struct ibm_struct ibms[] = {
860 { 1542 {
861 .name = "driver", 1543 .name = "driver",
862 .init = driver_init, 1544 .init = driver_init,
863 .read = driver_read, 1545 .read = driver_read,
864 }, 1546 },
1547 {
1548 .name = "hotkey",
1549 .hid = IBM_HKEY_HID,
1550 .init = hotkey_init,
1551 .read = hotkey_read,
1552 .write = hotkey_write,
1553 .exit = hotkey_exit,
1554 .notify = hotkey_notify,
1555 .handle = &hkey_handle,
1556 .type = ACPI_DEVICE_NOTIFY,
1557 },
1558 {
1559 .name = "bluetooth",
1560 .init = bluetooth_init,
1561 .read = bluetooth_read,
1562 .write = bluetooth_write,
1563 },
1564 {
1565 .name = "video",
1566 .init = video_init,
1567 .read = video_read,
1568 .write = video_write,
1569 .exit = video_exit,
1570 },
865 { 1571 {
866 .name = "hotkey", 1572 .name = "light",
867 .hid = "IBM0068", 1573 .init = light_init,
868 .init = hotkey_init, 1574 .read = light_read,
869 .read = hotkey_read, 1575 .write = light_write,
870 .write = hotkey_write, 1576 },
871 .exit = hotkey_exit,
872 .notify = hotkey_notify,
873 .handle = &hkey_handle,
874 .type = ACPI_DEVICE_NOTIFY,
875 },
876 { 1577 {
877 .name = "bluetooth", 1578 .name = "dock",
878 .init = bluetooth_init, 1579 .read = dock_read,
879 .read = bluetooth_read, 1580 .write = dock_write,
880 .write = bluetooth_write, 1581 .notify = dock_notify,
881 }, 1582 .handle = &dock_handle,
1583 .type = ACPI_SYSTEM_NOTIFY,
1584 },
882 { 1585 {
883 .name = "video", 1586 .name = "dock",
884 .init = video_init, 1587 .hid = IBM_PCI_HID,
885 .read = video_read, 1588 .notify = dock_notify,
886 .write = video_write, 1589 .handle = &pci_handle,
887 .exit = video_exit, 1590 .type = ACPI_SYSTEM_NOTIFY,
888 }, 1591 },
889 { 1592 {
890 .name = "light", 1593 .name = "bay",
891 .init = light_init, 1594 .init = bay_init,
892 .read = light_read, 1595 .read = bay_read,
893 .write = light_write, 1596 .write = bay_write,
894 }, 1597 .notify = bay_notify,
1598 .handle = &bay_handle,
1599 .type = ACPI_SYSTEM_NOTIFY,
1600 },
895 { 1601 {
896 .name = "dock", 1602 .name = "cmos",
897 .read = dock_read, 1603 .read = cmos_read,
898 .write = dock_write, 1604 .write = cmos_write,
899 .notify = dock_notify, 1605 },
900 .handle = &dock_handle,
901 .type = ACPI_SYSTEM_NOTIFY,
902 },
903 { 1606 {
904 .name = "bay", 1607 .name = "led",
905 .init = bay_init, 1608 .init = led_init,
906 .read = bay_read, 1609 .read = led_read,
907 .write = bay_write, 1610 .write = led_write,
908 .notify = bay_notify, 1611 },
909 .handle = &bay_handle,
910 .type = ACPI_SYSTEM_NOTIFY,
911 },
912 { 1612 {
913 .name = "cmos", 1613 .name = "beep",
914 .read = cmos_read, 1614 .read = beep_read,
915 .write = cmos_write, 1615 .write = beep_write,
916 .experimental = 1, 1616 },
917 },
918 { 1617 {
919 .name = "led", 1618 .name = "thermal",
920 .read = led_read, 1619 .init = thermal_init,
921 .write = led_write, 1620 .read = thermal_read,
922 .experimental = 1, 1621 },
923 },
924 { 1622 {
925 .name = "beep", 1623 .name = "ecdump",
926 .read = beep_read, 1624 .read = ecdump_read,
927 .write = beep_write, 1625 .write = ecdump_write,
928 .experimental = 1, 1626 .experimental = 1,
929 }, 1627 },
1628 {
1629 .name = "brightness",
1630 .read = brightness_read,
1631 .write = brightness_write,
1632 .experimental = 1,
1633 },
1634 {
1635 .name = "volume",
1636 .read = volume_read,
1637 .write = volume_write,
1638 .experimental = 1,
1639 },
1640 {
1641 .name = "fan",
1642 .read = fan_read,
1643 .write = fan_write,
1644 .experimental = 1,
1645 },
930}; 1646};
931#define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0]))
932 1647
933static int dispatch_read(char *page, char **start, off_t off, int count, 1648static int dispatch_read(char *page, char **start, off_t off, int count,
934 int *eof, void *data) 1649 int *eof, void *data)
935{ 1650{
936 struct ibm_struct *ibm = (struct ibm_struct *)data; 1651 struct ibm_struct *ibm = (struct ibm_struct *)data;
937 int len; 1652 int len;
938 1653
939 if (!ibm || !ibm->read) 1654 if (!ibm || !ibm->read)
940 return -EINVAL; 1655 return -EINVAL;
941 1656
942 len = ibm->read(ibm, page); 1657 len = ibm->read(page);
943 if (len < 0) 1658 if (len < 0)
944 return len; 1659 return len;
945 1660
@@ -955,7 +1670,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count,
955 return len; 1670 return len;
956} 1671}
957 1672
958static int dispatch_write(struct file *file, const char __user *userbuf, 1673static int dispatch_write(struct file *file, const char __user * userbuf,
959 unsigned long count, void *data) 1674 unsigned long count, void *data)
960{ 1675{
961 struct ibm_struct *ibm = (struct ibm_struct *)data; 1676 struct ibm_struct *ibm = (struct ibm_struct *)data;
@@ -969,20 +1684,20 @@ static int dispatch_write(struct file *file, const char __user *userbuf,
969 if (!kernbuf) 1684 if (!kernbuf)
970 return -ENOMEM; 1685 return -ENOMEM;
971 1686
972 if (copy_from_user(kernbuf, userbuf, count)) { 1687 if (copy_from_user(kernbuf, userbuf, count)) {
973 kfree(kernbuf); 1688 kfree(kernbuf);
974 return -EFAULT; 1689 return -EFAULT;
975 } 1690 }
976 1691
977 kernbuf[count] = 0; 1692 kernbuf[count] = 0;
978 strcat(kernbuf, ","); 1693 strcat(kernbuf, ",");
979 ret = ibm->write(ibm, kernbuf); 1694 ret = ibm->write(kernbuf);
980 if (ret == 0) 1695 if (ret == 0)
981 ret = count; 1696 ret = count;
982 1697
983 kfree(kernbuf); 1698 kfree(kernbuf);
984 1699
985 return ret; 1700 return ret;
986} 1701}
987 1702
988static void dispatch_notify(acpi_handle handle, u32 event, void *data) 1703static void dispatch_notify(acpi_handle handle, u32 event, void *data)
@@ -995,7 +1710,7 @@ static void dispatch_notify(acpi_handle handle, u32 event, void *data)
995 ibm->notify(ibm, event); 1710 ibm->notify(ibm, event);
996} 1711}
997 1712
998static int setup_notify(struct ibm_struct *ibm) 1713static int __init setup_notify(struct ibm_struct *ibm)
999{ 1714{
1000 acpi_status status; 1715 acpi_status status;
1001 int ret; 1716 int ret;
@@ -1020,17 +1735,15 @@ static int setup_notify(struct ibm_struct *ibm)
1020 return -ENODEV; 1735 return -ENODEV;
1021 } 1736 }
1022 1737
1023 ibm->notify_installed = 1;
1024
1025 return 0; 1738 return 0;
1026} 1739}
1027 1740
1028static int ibmacpi_device_add(struct acpi_device *device) 1741static int __init ibm_device_add(struct acpi_device *device)
1029{ 1742{
1030 return 0; 1743 return 0;
1031} 1744}
1032 1745
1033static int register_driver(struct ibm_struct *ibm) 1746static int __init register_driver(struct ibm_struct *ibm)
1034{ 1747{
1035 int ret; 1748 int ret;
1036 1749
@@ -1043,7 +1756,7 @@ static int register_driver(struct ibm_struct *ibm)
1043 memset(ibm->driver, 0, sizeof(struct acpi_driver)); 1756 memset(ibm->driver, 0, sizeof(struct acpi_driver));
1044 sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name); 1757 sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name);
1045 ibm->driver->ids = ibm->hid; 1758 ibm->driver->ids = ibm->hid;
1046 ibm->driver->ops.add = &ibmacpi_device_add; 1759 ibm->driver->ops.add = &ibm_device_add;
1047 1760
1048 ret = acpi_bus_register_driver(ibm->driver); 1761 ret = acpi_bus_register_driver(ibm->driver);
1049 if (ret < 0) { 1762 if (ret < 0) {
@@ -1055,7 +1768,7 @@ static int register_driver(struct ibm_struct *ibm)
1055 return ret; 1768 return ret;
1056} 1769}
1057 1770
1058static int ibm_init(struct ibm_struct *ibm) 1771static int __init ibm_init(struct ibm_struct *ibm)
1059{ 1772{
1060 int ret; 1773 int ret;
1061 struct proc_dir_entry *entry; 1774 struct proc_dir_entry *entry;
@@ -1071,31 +1784,34 @@ static int ibm_init(struct ibm_struct *ibm)
1071 } 1784 }
1072 1785
1073 if (ibm->init) { 1786 if (ibm->init) {
1074 ret = ibm->init(ibm); 1787 ret = ibm->init();
1075 if (ret != 0) 1788 if (ret != 0)
1076 return ret; 1789 return ret;
1077 ibm->init_called = 1; 1790 ibm->init_called = 1;
1078 } 1791 }
1079 1792
1080 entry = create_proc_entry(ibm->name, S_IFREG | S_IRUGO | S_IWUSR, 1793 if (ibm->read) {
1081 proc_dir); 1794 entry = create_proc_entry(ibm->name,
1082 if (!entry) { 1795 S_IFREG | S_IRUGO | S_IWUSR,
1083 printk(IBM_ERR "unable to create proc entry %s\n", ibm->name); 1796 proc_dir);
1084 return -ENODEV; 1797 if (!entry) {
1085 } 1798 printk(IBM_ERR "unable to create proc entry %s\n",
1086 entry->owner = THIS_MODULE; 1799 ibm->name);
1087 ibm->proc_created = 1; 1800 return -ENODEV;
1088 1801 }
1089 entry->data = ibm; 1802 entry->owner = THIS_MODULE;
1090 if (ibm->read) 1803 entry->data = ibm;
1091 entry->read_proc = &dispatch_read; 1804 entry->read_proc = &dispatch_read;
1092 if (ibm->write) 1805 if (ibm->write)
1093 entry->write_proc = &dispatch_write; 1806 entry->write_proc = &dispatch_write;
1807 ibm->proc_created = 1;
1808 }
1094 1809
1095 if (ibm->notify) { 1810 if (ibm->notify) {
1096 ret = setup_notify(ibm); 1811 ret = setup_notify(ibm);
1097 if (ret < 0) 1812 if (ret < 0)
1098 return ret; 1813 return ret;
1814 ibm->notify_installed = 1;
1099 } 1815 }
1100 1816
1101 return 0; 1817 return 0;
@@ -1111,7 +1827,7 @@ static void ibm_exit(struct ibm_struct *ibm)
1111 remove_proc_entry(ibm->name, proc_dir); 1827 remove_proc_entry(ibm->name, proc_dir);
1112 1828
1113 if (ibm->init_called && ibm->exit) 1829 if (ibm->init_called && ibm->exit)
1114 ibm->exit(ibm); 1830 ibm->exit();
1115 1831
1116 if (ibm->driver_registered) { 1832 if (ibm->driver_registered) {
1117 acpi_bus_unregister_driver(ibm->driver); 1833 acpi_bus_unregister_driver(ibm->driver);
@@ -1119,60 +1835,66 @@ static void ibm_exit(struct ibm_struct *ibm)
1119 } 1835 }
1120} 1836}
1121 1837
1122static int ibm_handle_init(char *name, 1838static void __init ibm_handle_init(char *name,
1123 acpi_handle *handle, acpi_handle parent, 1839 acpi_handle * handle, acpi_handle parent,
1124 char **paths, int num_paths, int required) 1840 char **paths, int num_paths, char **path)
1125{ 1841{
1126 int i; 1842 int i;
1127 acpi_status status; 1843 acpi_status status;
1128 1844
1129 for (i=0; i<num_paths; i++) { 1845 for (i = 0; i < num_paths; i++) {
1130 status = acpi_get_handle(parent, paths[i], handle); 1846 status = acpi_get_handle(parent, paths[i], handle);
1131 if (ACPI_SUCCESS(status)) 1847 if (ACPI_SUCCESS(status)) {
1132 return 0; 1848 *path = paths[i];
1133 } 1849 return;
1134 1850 }
1135 *handle = NULL;
1136
1137 if (required) {
1138 printk(IBM_ERR "%s object not found\n", name);
1139 return -1;
1140 } 1851 }
1141 1852
1142 return 0; 1853 *handle = NULL;
1143} 1854}
1144 1855
1145#define IBM_HANDLE_INIT(object, required) \ 1856#define IBM_HANDLE_INIT(object) \
1146 ibm_handle_init(#object, &object##_handle, *object##_parent, \ 1857 ibm_handle_init(#object, &object##_handle, *object##_parent, \
1147 object##_paths, sizeof(object##_paths)/sizeof(char*), required) 1858 object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
1148
1149 1859
1150static int set_ibm_param(const char *val, struct kernel_param *kp) 1860static int set_ibm_param(const char *val, struct kernel_param *kp)
1151{ 1861{
1152 unsigned int i; 1862 unsigned int i;
1153 char arg_with_comma[32];
1154
1155 if (strlen(val) > 30)
1156 return -ENOSPC;
1157 1863
1158 strcpy(arg_with_comma, val); 1864 for (i = 0; i < ARRAY_SIZE(ibms); i++)
1159 strcat(arg_with_comma, ","); 1865 if (strcmp(ibms[i].name, kp->name) == 0 && ibms[i].write) {
1866 if (strlen(val) > sizeof(ibms[i].param) - 2)
1867 return -ENOSPC;
1868 strcpy(ibms[i].param, val);
1869 strcat(ibms[i].param, ",");
1870 return 0;
1871 }
1160 1872
1161 for (i=0; i<NUM_IBMS; i++)
1162 if (strcmp(ibms[i].name, kp->name) == 0)
1163 return ibms[i].write(&ibms[i], arg_with_comma);
1164 BUG();
1165 return -EINVAL; 1873 return -EINVAL;
1166} 1874}
1167 1875
1168#define IBM_PARAM(feature) \ 1876#define IBM_PARAM(feature) \
1169 module_param_call(feature, set_ibm_param, NULL, NULL, 0) 1877 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
1170 1878
1879IBM_PARAM(hotkey);
1880IBM_PARAM(bluetooth);
1881IBM_PARAM(video);
1882IBM_PARAM(light);
1883IBM_PARAM(dock);
1884IBM_PARAM(bay);
1885IBM_PARAM(cmos);
1886IBM_PARAM(led);
1887IBM_PARAM(beep);
1888IBM_PARAM(ecdump);
1889IBM_PARAM(brightness);
1890IBM_PARAM(volume);
1891IBM_PARAM(fan);
1892
1171static void acpi_ibm_exit(void) 1893static void acpi_ibm_exit(void)
1172{ 1894{
1173 int i; 1895 int i;
1174 1896
1175 for (i=NUM_IBMS-1; i>=0; i--) 1897 for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--)
1176 ibm_exit(&ibms[i]); 1898 ibm_exit(&ibms[i]);
1177 1899
1178 remove_proc_entry(IBM_DIR, acpi_root_dir); 1900 remove_proc_entry(IBM_DIR, acpi_root_dir);
@@ -1185,30 +1907,40 @@ static int __init acpi_ibm_init(void)
1185 if (acpi_disabled) 1907 if (acpi_disabled)
1186 return -ENODEV; 1908 return -ENODEV;
1187 1909
1188 if (!acpi_specific_hotkey_enabled){ 1910 if (!acpi_specific_hotkey_enabled) {
1189 printk(IBM_ERR "Using generic hotkey driver\n"); 1911 printk(IBM_ERR "using generic hotkey driver\n");
1190 return -ENODEV;
1191 }
1192 /* these handles are required */
1193 if (IBM_HANDLE_INIT(ec, 1) < 0 ||
1194 IBM_HANDLE_INIT(hkey, 1) < 0 ||
1195 IBM_HANDLE_INIT(vid, 1) < 0 ||
1196 IBM_HANDLE_INIT(beep, 1) < 0)
1197 return -ENODEV; 1912 return -ENODEV;
1913 }
1198 1914
1199 /* these handles have alternatives */ 1915 /* ec is required because many other handles are relative to it */
1200 IBM_HANDLE_INIT(lght, 0); 1916 IBM_HANDLE_INIT(ec);
1201 if (IBM_HANDLE_INIT(cmos, !lght_handle) < 0) 1917 if (!ec_handle) {
1202 return -ENODEV; 1918 printk(IBM_ERR "ec object not found\n");
1203 IBM_HANDLE_INIT(sysl, 0);
1204 if (IBM_HANDLE_INIT(led, !sysl_handle) < 0)
1205 return -ENODEV; 1919 return -ENODEV;
1920 }
1206 1921
1207 /* these handles are not required */ 1922 /* these handles are not required */
1208 IBM_HANDLE_INIT(dock, 0); 1923 IBM_HANDLE_INIT(vid);
1209 IBM_HANDLE_INIT(bay, 0); 1924 IBM_HANDLE_INIT(vid2);
1210 IBM_HANDLE_INIT(bayej, 0); 1925 IBM_HANDLE_INIT(ledb);
1211 IBM_HANDLE_INIT(bled, 0); 1926 IBM_HANDLE_INIT(led);
1927 IBM_HANDLE_INIT(hkey);
1928 IBM_HANDLE_INIT(lght);
1929 IBM_HANDLE_INIT(cmos);
1930 IBM_HANDLE_INIT(dock);
1931 IBM_HANDLE_INIT(pci);
1932 IBM_HANDLE_INIT(bay);
1933 if (bay_handle)
1934 IBM_HANDLE_INIT(bay_ej);
1935 IBM_HANDLE_INIT(bay2);
1936 if (bay2_handle)
1937 IBM_HANDLE_INIT(bay2_ej);
1938 IBM_HANDLE_INIT(beep);
1939 IBM_HANDLE_INIT(ecrd);
1940 IBM_HANDLE_INIT(ecwr);
1941 IBM_HANDLE_INIT(fans);
1942 IBM_HANDLE_INIT(gfan);
1943 IBM_HANDLE_INIT(sfan);
1212 1944
1213 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); 1945 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
1214 if (!proc_dir) { 1946 if (!proc_dir) {
@@ -1216,9 +1948,11 @@ static int __init acpi_ibm_init(void)
1216 return -ENODEV; 1948 return -ENODEV;
1217 } 1949 }
1218 proc_dir->owner = THIS_MODULE; 1950 proc_dir->owner = THIS_MODULE;
1219 1951
1220 for (i=0; i<NUM_IBMS; i++) { 1952 for (i = 0; i < ARRAY_SIZE(ibms); i++) {
1221 ret = ibm_init(&ibms[i]); 1953 ret = ibm_init(&ibms[i]);
1954 if (ret >= 0 && *ibms[i].param)
1955 ret = ibms[i].write(ibms[i].param);
1222 if (ret < 0) { 1956 if (ret < 0) {
1223 acpi_ibm_exit(); 1957 acpi_ibm_exit();
1224 return ret; 1958 return ret;
@@ -1230,17 +1964,3 @@ static int __init acpi_ibm_init(void)
1230 1964
1231module_init(acpi_ibm_init); 1965module_init(acpi_ibm_init);
1232module_exit(acpi_ibm_exit); 1966module_exit(acpi_ibm_exit);
1233
1234MODULE_AUTHOR("Borislav Deianov");
1235MODULE_DESCRIPTION(IBM_DESC);
1236MODULE_LICENSE("GPL");
1237
1238IBM_PARAM(hotkey);
1239IBM_PARAM(bluetooth);
1240IBM_PARAM(video);
1241IBM_PARAM(light);
1242IBM_PARAM(dock);
1243IBM_PARAM(bay);
1244IBM_PARAM(cmos);
1245IBM_PARAM(led);
1246IBM_PARAM(beep);
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index 61ea70742d49..e928e8c2c6ec 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -30,12 +30,11 @@
30#include <acpi/acpi_drivers.h> 30#include <acpi/acpi_drivers.h>
31 31
32#define _COMPONENT ACPI_SYSTEM_COMPONENT 32#define _COMPONENT ACPI_SYSTEM_COMPONENT
33ACPI_MODULE_NAME ("acpi_motherboard") 33ACPI_MODULE_NAME("acpi_motherboard")
34 34
35/* Dell use PNP0C01 instead of PNP0C02 */ 35/* Dell use PNP0C01 instead of PNP0C02 */
36#define ACPI_MB_HID1 "PNP0C01" 36#define ACPI_MB_HID1 "PNP0C01"
37#define ACPI_MB_HID2 "PNP0C02" 37#define ACPI_MB_HID2 "PNP0C02"
38
39/** 38/**
40 * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved 39 * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved
41 * Doesn't care about the failure of 'request_region', since other may reserve 40 * Doesn't care about the failure of 'request_region', since other may reserve
@@ -44,15 +43,12 @@ ACPI_MODULE_NAME ("acpi_motherboard")
44#define IS_RESERVED_ADDR(base, len) \ 43#define IS_RESERVED_ADDR(base, len) \
45 (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \ 44 (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \
46 && ((base) + (len) > PCIBIOS_MIN_IO)) 45 && ((base) + (len) > PCIBIOS_MIN_IO))
47
48/* 46/*
49 * Clearing the flag (IORESOURCE_BUSY) allows drivers to use 47 * Clearing the flag (IORESOURCE_BUSY) allows drivers to use
50 * the io ports if they really know they can use it, while 48 * the io ports if they really know they can use it, while
51 * still preventing hotplug PCI devices from using it. 49 * still preventing hotplug PCI devices from using it.
52 */ 50 */
53 51static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
54static acpi_status
55acpi_reserve_io_ranges (struct acpi_resource *res, void *data)
56{ 52{
57 struct resource *requested_res = NULL; 53 struct resource *requested_res = NULL;
58 54
@@ -63,22 +59,32 @@ acpi_reserve_io_ranges (struct acpi_resource *res, void *data)
63 59
64 if (io_res->min_base_address != io_res->max_base_address) 60 if (io_res->min_base_address != io_res->max_base_address)
65 return_VALUE(AE_OK); 61 return_VALUE(AE_OK);
66 if (IS_RESERVED_ADDR(io_res->min_base_address, io_res->range_length)) { 62 if (IS_RESERVED_ADDR
67 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", 63 (io_res->min_base_address, io_res->range_length)) {
68 io_res->min_base_address, 64 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
69 io_res->min_base_address + io_res->range_length)); 65 "Motherboard resources 0x%08x - 0x%08x\n",
70 requested_res = request_region(io_res->min_base_address, 66 io_res->min_base_address,
71 io_res->range_length, "motherboard"); 67 io_res->min_base_address +
68 io_res->range_length));
69 requested_res =
70 request_region(io_res->min_base_address,
71 io_res->range_length, "motherboard");
72 } 72 }
73 } else if (res->id == ACPI_RSTYPE_FIXED_IO) { 73 } else if (res->id == ACPI_RSTYPE_FIXED_IO) {
74 struct acpi_resource_fixed_io *fixed_io_res = &res->data.fixed_io; 74 struct acpi_resource_fixed_io *fixed_io_res =
75 75 &res->data.fixed_io;
76 if (IS_RESERVED_ADDR(fixed_io_res->base_address, fixed_io_res->range_length)) { 76
77 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", 77 if (IS_RESERVED_ADDR
78 fixed_io_res->base_address, 78 (fixed_io_res->base_address, fixed_io_res->range_length)) {
79 fixed_io_res->base_address + fixed_io_res->range_length)); 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
80 requested_res = request_region(fixed_io_res->base_address, 80 "Motherboard resources 0x%08x - 0x%08x\n",
81 fixed_io_res->range_length, "motherboard"); 81 fixed_io_res->base_address,
82 fixed_io_res->base_address +
83 fixed_io_res->range_length));
84 requested_res =
85 request_region(fixed_io_res->base_address,
86 fixed_io_res->range_length,
87 "motherboard");
82 } 88 }
83 } else { 89 } else {
84 /* Memory mapped IO? */ 90 /* Memory mapped IO? */
@@ -89,72 +95,70 @@ acpi_reserve_io_ranges (struct acpi_resource *res, void *data)
89 return_VALUE(AE_OK); 95 return_VALUE(AE_OK);
90} 96}
91 97
92static int acpi_motherboard_add (struct acpi_device *device) 98static int acpi_motherboard_add(struct acpi_device *device)
93{ 99{
94 if (!device) 100 if (!device)
95 return -EINVAL; 101 return -EINVAL;
96 acpi_walk_resources(device->handle, METHOD_NAME__CRS, 102 acpi_walk_resources(device->handle, METHOD_NAME__CRS,
97 acpi_reserve_io_ranges, NULL); 103 acpi_reserve_io_ranges, NULL);
98 104
99 return 0; 105 return 0;
100} 106}
101 107
102static struct acpi_driver acpi_motherboard_driver1 = { 108static struct acpi_driver acpi_motherboard_driver1 = {
103 .name = "motherboard", 109 .name = "motherboard",
104 .class = "", 110 .class = "",
105 .ids = ACPI_MB_HID1, 111 .ids = ACPI_MB_HID1,
106 .ops = { 112 .ops = {
107 .add = acpi_motherboard_add, 113 .add = acpi_motherboard_add,
108 }, 114 },
109}; 115};
110 116
111static struct acpi_driver acpi_motherboard_driver2 = { 117static struct acpi_driver acpi_motherboard_driver2 = {
112 .name = "motherboard", 118 .name = "motherboard",
113 .class = "", 119 .class = "",
114 .ids = ACPI_MB_HID2, 120 .ids = ACPI_MB_HID2,
115 .ops = { 121 .ops = {
116 .add = acpi_motherboard_add, 122 .add = acpi_motherboard_add,
117 }, 123 },
118}; 124};
119 125
120static void __init 126static void __init acpi_reserve_resources(void)
121acpi_reserve_resources (void)
122{ 127{
123 if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) 128 if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
124 request_region(acpi_gbl_FADT->xpm1a_evt_blk.address, 129 request_region(acpi_gbl_FADT->xpm1a_evt_blk.address,
125 acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK"); 130 acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK");
126 131
127 if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) 132 if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
128 request_region(acpi_gbl_FADT->xpm1b_evt_blk.address, 133 request_region(acpi_gbl_FADT->xpm1b_evt_blk.address,
129 acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK"); 134 acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK");
130 135
131 if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) 136 if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
132 request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address, 137 request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address,
133 acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK"); 138 acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK");
134 139
135 if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) 140 if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
136 request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address, 141 request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address,
137 acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK"); 142 acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK");
138 143
139 if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len == 4) 144 if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len == 4)
140 request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 145 request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4, "PM_TMR");
141 4, "PM_TMR");
142 146
143 if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len) 147 if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len)
144 request_region(acpi_gbl_FADT->xpm2_cnt_blk.address, 148 request_region(acpi_gbl_FADT->xpm2_cnt_blk.address,
145 acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK"); 149 acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK");
146 150
147 /* Length of GPE blocks must be a non-negative multiple of 2 */ 151 /* Length of GPE blocks must be a non-negative multiple of 2 */
148 152
149 if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len && 153 if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len &&
150 !(acpi_gbl_FADT->gpe0_blk_len & 0x1)) 154 !(acpi_gbl_FADT->gpe0_blk_len & 0x1))
151 request_region(acpi_gbl_FADT->xgpe0_blk.address, 155 request_region(acpi_gbl_FADT->xgpe0_blk.address,
152 acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK"); 156 acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK");
153 157
154 if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len && 158 if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len &&
155 !(acpi_gbl_FADT->gpe1_blk_len & 0x1)) 159 !(acpi_gbl_FADT->gpe1_blk_len & 0x1))
156 request_region(acpi_gbl_FADT->xgpe1_blk.address, 160 request_region(acpi_gbl_FADT->xgpe1_blk.address,
157 acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK"); 161 acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK");
158} 162}
159 163
160static int __init acpi_motherboard_init(void) 164static int __init acpi_motherboard_init(void)
@@ -166,7 +170,7 @@ static int __init acpi_motherboard_init(void)
166 * This module must run after scan.c 170 * This module must run after scan.c
167 */ 171 */
168 if (!acpi_disabled) 172 if (!acpi_disabled)
169 acpi_reserve_resources (); 173 acpi_reserve_resources();
170 return 0; 174 return 0;
171} 175}
172 176
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index ece7a9dedd5c..edfbe34600f5 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -41,16 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
49 48
50
51#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsaccess") 50ACPI_MODULE_NAME("nsaccess")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -65,24 +62,19 @@
65 * MUTEX: Locks namespace for entire execution 62 * MUTEX: Locks namespace for entire execution
66 * 63 *
67 ******************************************************************************/ 64 ******************************************************************************/
68 65acpi_status acpi_ns_root_initialize(void)
69acpi_status
70acpi_ns_root_initialize (
71 void)
72{ 66{
73 acpi_status status; 67 acpi_status status;
74 const struct acpi_predefined_names *init_val = NULL; 68 const struct acpi_predefined_names *init_val = NULL;
75 struct acpi_namespace_node *new_node; 69 struct acpi_namespace_node *new_node;
76 union acpi_operand_object *obj_desc; 70 union acpi_operand_object *obj_desc;
77 acpi_string val = NULL; 71 acpi_string val = NULL;
78
79
80 ACPI_FUNCTION_TRACE ("ns_root_initialize");
81 72
73 ACPI_FUNCTION_TRACE("ns_root_initialize");
82 74
83 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 75 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
84 if (ACPI_FAILURE (status)) { 76 if (ACPI_FAILURE(status)) {
85 return_ACPI_STATUS (status); 77 return_ACPI_STATUS(status);
86 } 78 }
87 79
88 /* 80 /*
@@ -102,24 +94,26 @@ acpi_ns_root_initialize (
102 94
103 /* Enter the pre-defined names in the name table */ 95 /* Enter the pre-defined names in the name table */
104 96
105 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 97 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
106 "Entering predefined entries into namespace\n")); 98 "Entering predefined entries into namespace\n"));
107 99
108 for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { 100 for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
109 /* _OSI is optional for now, will be permanent later */ 101 /* _OSI is optional for now, will be permanent later */
110 102
111 if (!ACPI_STRCMP (init_val->name, "_OSI") && !acpi_gbl_create_osi_method) { 103 if (!ACPI_STRCMP(init_val->name, "_OSI")
104 && !acpi_gbl_create_osi_method) {
112 continue; 105 continue;
113 } 106 }
114 107
115 status = acpi_ns_lookup (NULL, init_val->name, init_val->type, 108 status = acpi_ns_lookup(NULL, init_val->name, init_val->type,
116 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 109 ACPI_IMODE_LOAD_PASS2,
117 NULL, &new_node); 110 ACPI_NS_NO_UPSEARCH, NULL, &new_node);
118 111
119 if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ { 112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
120 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
121 "Could not create predefined name %s, %s\n", 114 "Could not create predefined name %s, %s\n",
122 init_val->name, acpi_format_exception (status))); 115 init_val->name,
116 acpi_format_exception(status)));
123 } 117 }
124 118
125 /* 119 /*
@@ -128,11 +122,11 @@ acpi_ns_root_initialize (
128 * initial value, create the initial value. 122 * initial value, create the initial value.
129 */ 123 */
130 if (init_val->val) { 124 if (init_val->val) {
131 status = acpi_os_predefined_override (init_val, &val); 125 status = acpi_os_predefined_override(init_val, &val);
132 if (ACPI_FAILURE (status)) { 126 if (ACPI_FAILURE(status)) {
133 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
134 "Could not override predefined %s\n", 128 "Could not override predefined %s\n",
135 init_val->name)); 129 init_val->name));
136 } 130 }
137 131
138 if (!val) { 132 if (!val) {
@@ -143,7 +137,8 @@ acpi_ns_root_initialize (
143 * Entry requests an initial value, allocate a 137 * Entry requests an initial value, allocate a
144 * descriptor for it. 138 * descriptor for it.
145 */ 139 */
146 obj_desc = acpi_ut_create_internal_object (init_val->type); 140 obj_desc =
141 acpi_ut_create_internal_object(init_val->type);
147 if (!obj_desc) { 142 if (!obj_desc) {
148 status = AE_NO_MEMORY; 143 status = AE_NO_MEMORY;
149 goto unlock_and_exit; 144 goto unlock_and_exit;
@@ -156,55 +151,62 @@ acpi_ns_root_initialize (
156 */ 151 */
157 switch (init_val->type) { 152 switch (init_val->type) {
158 case ACPI_TYPE_METHOD: 153 case ACPI_TYPE_METHOD:
159 obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); 154 obj_desc->method.param_count =
155 (u8) ACPI_TO_INTEGER(val);
160 obj_desc->common.flags |= AOPOBJ_DATA_VALID; 156 obj_desc->common.flags |= AOPOBJ_DATA_VALID;
161 157
162#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) 158#if defined (ACPI_ASL_COMPILER)
163 159
164 /* 160 /* save the parameter count for the i_aSL compiler */
165 * i_aSL Compiler cheats by putting parameter count 161
166 * in the owner_iD 162 new_node->value = obj_desc->method.param_count;
167 */
168 new_node->owner_id = obj_desc->method.param_count;
169#else 163#else
170 /* Mark this as a very SPECIAL method */ 164 /* Mark this as a very SPECIAL method */
171 165
172 obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY; 166 obj_desc->method.method_flags =
173 obj_desc->method.implementation = acpi_ut_osi_implementation; 167 AML_METHOD_INTERNAL_ONLY;
168
169#ifndef ACPI_DUMP_APP
170 obj_desc->method.implementation =
171 acpi_ut_osi_implementation;
172#endif
174#endif 173#endif
175 break; 174 break;
176 175
177 case ACPI_TYPE_INTEGER: 176 case ACPI_TYPE_INTEGER:
178 177
179 obj_desc->integer.value = ACPI_TO_INTEGER (val); 178 obj_desc->integer.value = ACPI_TO_INTEGER(val);
180 break; 179 break;
181 180
182
183 case ACPI_TYPE_STRING: 181 case ACPI_TYPE_STRING:
184 182
185 /* 183 /*
186 * Build an object around the static string 184 * Build an object around the static string
187 */ 185 */
188 obj_desc->string.length = (u32) ACPI_STRLEN (val); 186 obj_desc->string.length =
187 (u32) ACPI_STRLEN(val);
189 obj_desc->string.pointer = val; 188 obj_desc->string.pointer = val;
190 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 189 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
191 break; 190 break;
192 191
193
194 case ACPI_TYPE_MUTEX: 192 case ACPI_TYPE_MUTEX:
195 193
196 obj_desc->mutex.node = new_node; 194 obj_desc->mutex.node = new_node;
197 obj_desc->mutex.sync_level = (u8) (ACPI_TO_INTEGER (val) - 1); 195 obj_desc->mutex.sync_level =
196 (u8) (ACPI_TO_INTEGER(val) - 1);
198 197
199 if (ACPI_STRCMP (init_val->name, "_GL_") == 0) { 198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
200 /* 199 /*
201 * Create a counting semaphore for the 200 * Create a counting semaphore for the
202 * global lock 201 * global lock
203 */ 202 */
204 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 203 status =
205 1, &obj_desc->mutex.semaphore); 204 acpi_os_create_semaphore
206 if (ACPI_FAILURE (status)) { 205 (ACPI_NO_UNIT_LIMIT, 1,
207 acpi_ut_remove_reference (obj_desc); 206 &obj_desc->mutex.semaphore);
207 if (ACPI_FAILURE(status)) {
208 acpi_ut_remove_reference
209 (obj_desc);
208 goto unlock_and_exit; 210 goto unlock_and_exit;
209 } 211 }
210 212
@@ -212,56 +214,58 @@ acpi_ns_root_initialize (
212 * We just created the mutex for the 214 * We just created the mutex for the
213 * global lock, save it 215 * global lock, save it
214 */ 216 */
215 acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; 217 acpi_gbl_global_lock_semaphore =
216 } 218 obj_desc->mutex.semaphore;
217 else { 219 } else {
218 /* Create a mutex */ 220 /* Create a mutex */
219 221
220 status = acpi_os_create_semaphore (1, 1, 222 status = acpi_os_create_semaphore(1, 1,
221 &obj_desc->mutex.semaphore); 223 &obj_desc->
222 if (ACPI_FAILURE (status)) { 224 mutex.
223 acpi_ut_remove_reference (obj_desc); 225 semaphore);
226 if (ACPI_FAILURE(status)) {
227 acpi_ut_remove_reference
228 (obj_desc);
224 goto unlock_and_exit; 229 goto unlock_and_exit;
225 } 230 }
226 } 231 }
227 break; 232 break;
228 233
229
230 default: 234 default:
231 235
232 ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", 236 ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type));
233 init_val->type)); 237 acpi_ut_remove_reference(obj_desc);
234 acpi_ut_remove_reference (obj_desc);
235 obj_desc = NULL; 238 obj_desc = NULL;
236 continue; 239 continue;
237 } 240 }
238 241
239 /* Store pointer to value descriptor in the Node */ 242 /* Store pointer to value descriptor in the Node */
240 243
241 status = acpi_ns_attach_object (new_node, obj_desc, 244 status = acpi_ns_attach_object(new_node, obj_desc,
242 ACPI_GET_OBJECT_TYPE (obj_desc)); 245 ACPI_GET_OBJECT_TYPE
246 (obj_desc));
243 247
244 /* Remove local reference to the object */ 248 /* Remove local reference to the object */
245 249
246 acpi_ut_remove_reference (obj_desc); 250 acpi_ut_remove_reference(obj_desc);
247 } 251 }
248 } 252 }
249 253
250 254 unlock_and_exit:
251unlock_and_exit: 255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
252 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
253 256
254 /* Save a handle to "_GPE", it is always present */ 257 /* Save a handle to "_GPE", it is always present */
255 258
256 if (ACPI_SUCCESS (status)) { 259 if (ACPI_SUCCESS(status)) {
257 status = acpi_ns_get_node_by_path ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, 260 status =
258 &acpi_gbl_fadt_gpe_device); 261 acpi_ns_get_node_by_path("\\_GPE", NULL,
262 ACPI_NS_NO_UPSEARCH,
263 &acpi_gbl_fadt_gpe_device);
259 } 264 }
260 265
261 return_ACPI_STATUS (status); 266 return_ACPI_STATUS(status);
262} 267}
263 268
264
265/******************************************************************************* 269/*******************************************************************************
266 * 270 *
267 * FUNCTION: acpi_ns_lookup 271 * FUNCTION: acpi_ns_lookup
@@ -286,62 +290,57 @@ unlock_and_exit:
286 ******************************************************************************/ 290 ******************************************************************************/
287 291
288acpi_status 292acpi_status
289acpi_ns_lookup ( 293acpi_ns_lookup(union acpi_generic_state *scope_info,
290 union acpi_generic_state *scope_info, 294 char *pathname,
291 char *pathname, 295 acpi_object_type type,
292 acpi_object_type type, 296 acpi_interpreter_mode interpreter_mode,
293 acpi_interpreter_mode interpreter_mode, 297 u32 flags,
294 u32 flags, 298 struct acpi_walk_state *walk_state,
295 struct acpi_walk_state *walk_state, 299 struct acpi_namespace_node **return_node)
296 struct acpi_namespace_node **return_node)
297{ 300{
298 acpi_status status; 301 acpi_status status;
299 char *path = pathname; 302 char *path = pathname;
300 struct acpi_namespace_node *prefix_node; 303 struct acpi_namespace_node *prefix_node;
301 struct acpi_namespace_node *current_node = NULL; 304 struct acpi_namespace_node *current_node = NULL;
302 struct acpi_namespace_node *this_node = NULL; 305 struct acpi_namespace_node *this_node = NULL;
303 u32 num_segments; 306 u32 num_segments;
304 u32 num_carats; 307 u32 num_carats;
305 acpi_name simple_name; 308 acpi_name simple_name;
306 acpi_object_type type_to_check_for; 309 acpi_object_type type_to_check_for;
307 acpi_object_type this_search_type; 310 acpi_object_type this_search_type;
308 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; 311 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
309 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | 312 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND |
310 ACPI_NS_SEARCH_PARENT); 313 ACPI_NS_SEARCH_PARENT);
311 314
312 315 ACPI_FUNCTION_TRACE("ns_lookup");
313 ACPI_FUNCTION_TRACE ("ns_lookup");
314
315 316
316 if (!return_node) { 317 if (!return_node) {
317 return_ACPI_STATUS (AE_BAD_PARAMETER); 318 return_ACPI_STATUS(AE_BAD_PARAMETER);
318 } 319 }
319 320
320 acpi_gbl_ns_lookup_count++; 321 acpi_gbl_ns_lookup_count++;
321 *return_node = ACPI_ENTRY_NOT_FOUND; 322 *return_node = ACPI_ENTRY_NOT_FOUND;
322 323
323 if (!acpi_gbl_root_node) { 324 if (!acpi_gbl_root_node) {
324 return_ACPI_STATUS (AE_NO_NAMESPACE); 325 return_ACPI_STATUS(AE_NO_NAMESPACE);
325 } 326 }
326 327
327 /* 328 /*
328 * Get the prefix scope. 329 * Get the prefix scope.
329 * A null scope means use the root scope 330 * A null scope means use the root scope
330 */ 331 */
331 if ((!scope_info) || 332 if ((!scope_info) || (!scope_info->scope.node)) {
332 (!scope_info->scope.node)) { 333 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
333 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 334 "Null scope prefix, using root node (%p)\n",
334 "Null scope prefix, using root node (%p)\n", 335 acpi_gbl_root_node));
335 acpi_gbl_root_node));
336 336
337 prefix_node = acpi_gbl_root_node; 337 prefix_node = acpi_gbl_root_node;
338 } 338 } else {
339 else {
340 prefix_node = scope_info->scope.node; 339 prefix_node = scope_info->scope.node;
341 if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) { 340 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
342 ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n", 341 ACPI_DESC_TYPE_NAMED) {
343 prefix_node, acpi_ut_get_descriptor_name (prefix_node))); 342 ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node)));
344 return_ACPI_STATUS (AE_AML_INTERNAL); 343 return_ACPI_STATUS(AE_AML_INTERNAL);
345 } 344 }
346 345
347 /* 346 /*
@@ -349,9 +348,9 @@ acpi_ns_lookup (
349 * Device/Method, etc.) It could be a Package or other object node. 348 * Device/Method, etc.) It could be a Package or other object node.
350 * Backup up the tree to find the containing scope node. 349 * Backup up the tree to find the containing scope node.
351 */ 350 */
352 while (!acpi_ns_opens_scope (prefix_node->type) && 351 while (!acpi_ns_opens_scope(prefix_node->type) &&
353 prefix_node->type != ACPI_TYPE_ANY) { 352 prefix_node->type != ACPI_TYPE_ANY) {
354 prefix_node = acpi_ns_get_parent_node (prefix_node); 353 prefix_node = acpi_ns_get_parent_node(prefix_node);
355 } 354 }
356 } 355 }
357 356
@@ -366,13 +365,13 @@ acpi_ns_lookup (
366 /* A Null name_path is allowed and refers to the root */ 365 /* A Null name_path is allowed and refers to the root */
367 366
368 num_segments = 0; 367 num_segments = 0;
369 this_node = acpi_gbl_root_node; 368 this_node = acpi_gbl_root_node;
370 path = ""; 369 path = "";
371 370
372 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 371 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
373 "Null Pathname (Zero segments), Flags=%X\n", flags)); 372 "Null Pathname (Zero segments), Flags=%X\n",
374 } 373 flags));
375 else { 374 } else {
376 /* 375 /*
377 * Name pointer is valid (and must be in internal name format) 376 * Name pointer is valid (and must be in internal name format)
378 * 377 *
@@ -396,15 +395,16 @@ acpi_ns_lookup (
396 395
397 path++; 396 path++;
398 397
399 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 398 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
400 "Path is absolute from root [%p]\n", this_node)); 399 "Path is absolute from root [%p]\n",
401 } 400 this_node));
402 else { 401 } else {
403 /* Pathname is relative to current scope, start there */ 402 /* Pathname is relative to current scope, start there */
404 403
405 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 404 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
406 "Searching relative to prefix scope [%4.4s] (%p)\n", 405 "Searching relative to prefix scope [%4.4s] (%p)\n",
407 acpi_ut_get_node_name (prefix_node), prefix_node)); 406 acpi_ut_get_node_name(prefix_node),
407 prefix_node));
408 408
409 /* 409 /*
410 * Handle multiple Parent Prefixes (carat) by just getting 410 * Handle multiple Parent Prefixes (carat) by just getting
@@ -425,20 +425,20 @@ acpi_ns_lookup (
425 /* Backup to the parent node */ 425 /* Backup to the parent node */
426 426
427 num_carats++; 427 num_carats++;
428 this_node = acpi_ns_get_parent_node (this_node); 428 this_node = acpi_ns_get_parent_node(this_node);
429 if (!this_node) { 429 if (!this_node) {
430 /* Current scope has no parent scope */ 430 /* Current scope has no parent scope */
431 431
432 ACPI_REPORT_ERROR ( 432 ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
433 ("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); 433 return_ACPI_STATUS(AE_NOT_FOUND);
434 return_ACPI_STATUS (AE_NOT_FOUND);
435 } 434 }
436 } 435 }
437 436
438 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) { 437 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
439 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 438 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
440 "Search scope is [%4.4s], path has %d carat(s)\n", 439 "Search scope is [%4.4s], path has %d carat(s)\n",
441 acpi_ut_get_node_name (this_node), num_carats)); 440 acpi_ut_get_node_name
441 (this_node), num_carats));
442 } 442 }
443 } 443 }
444 444
@@ -464,9 +464,9 @@ acpi_ns_lookup (
464 num_segments = 0; 464 num_segments = 0;
465 type = this_node->type; 465 type = this_node->type;
466 466
467 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 467 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
468 "Prefix-only Pathname (Zero name segments), Flags=%X\n", 468 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
469 flags)); 469 flags));
470 break; 470 break;
471 471
472 case AML_DUAL_NAME_PREFIX: 472 case AML_DUAL_NAME_PREFIX:
@@ -480,8 +480,9 @@ acpi_ns_lookup (
480 num_segments = 2; 480 num_segments = 2;
481 path++; 481 path++;
482 482
483 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 483 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
484 "Dual Pathname (2 segments, Flags=%X)\n", flags)); 484 "Dual Pathname (2 segments, Flags=%X)\n",
485 flags));
485 break; 486 break;
486 487
487 case AML_MULTI_NAME_PREFIX_OP: 488 case AML_MULTI_NAME_PREFIX_OP:
@@ -493,12 +494,12 @@ acpi_ns_lookup (
493 /* Extract segment count, point to first name segment */ 494 /* Extract segment count, point to first name segment */
494 495
495 path++; 496 path++;
496 num_segments = (u32) (u8) *path; 497 num_segments = (u32) (u8) * path;
497 path++; 498 path++;
498 499
499 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
500 "Multi Pathname (%d Segments, Flags=%X) \n", 501 "Multi Pathname (%d Segments, Flags=%X) \n",
501 num_segments, flags)); 502 num_segments, flags));
502 break; 503 break;
503 504
504 default: 505 default:
@@ -508,15 +509,15 @@ acpi_ns_lookup (
508 */ 509 */
509 num_segments = 1; 510 num_segments = 1;
510 511
511 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 512 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
512 "Simple Pathname (1 segment, Flags=%X)\n", flags)); 513 "Simple Pathname (1 segment, Flags=%X)\n",
514 flags));
513 break; 515 break;
514 } 516 }
515 517
516 ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, path)); 518 ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
517 } 519 }
518 520
519
520 /* 521 /*
521 * Search namespace for each segment of the name. Loop through and 522 * Search namespace for each segment of the name. Loop through and
522 * verify (or add to the namespace) each name segment. 523 * verify (or add to the namespace) each name segment.
@@ -540,7 +541,7 @@ acpi_ns_lookup (
540 * requested it AND we have a single, non-fully-qualified name_seg 541 * requested it AND we have a single, non-fully-qualified name_seg
541 */ 542 */
542 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) && 543 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
543 (flags & ACPI_NS_SEARCH_PARENT)) { 544 (flags & ACPI_NS_SEARCH_PARENT)) {
544 local_flags |= ACPI_NS_SEARCH_PARENT; 545 local_flags |= ACPI_NS_SEARCH_PARENT;
545 } 546 }
546 547
@@ -553,24 +554,28 @@ acpi_ns_lookup (
553 554
554 /* Extract one ACPI name from the front of the pathname */ 555 /* Extract one ACPI name from the front of the pathname */
555 556
556 ACPI_MOVE_32_TO_32 (&simple_name, path); 557 ACPI_MOVE_32_TO_32(&simple_name, path);
557 558
558 /* Try to find the single (4 character) ACPI name */ 559 /* Try to find the single (4 character) ACPI name */
559 560
560 status = acpi_ns_search_and_enter (simple_name, walk_state, current_node, 561 status =
561 interpreter_mode, this_search_type, local_flags, &this_node); 562 acpi_ns_search_and_enter(simple_name, walk_state,
562 if (ACPI_FAILURE (status)) { 563 current_node, interpreter_mode,
564 this_search_type, local_flags,
565 &this_node);
566 if (ACPI_FAILURE(status)) {
563 if (status == AE_NOT_FOUND) { 567 if (status == AE_NOT_FOUND) {
564 /* Name not found in ACPI namespace */ 568 /* Name not found in ACPI namespace */
565 569
566 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 570 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
567 "Name [%4.4s] not found in scope [%4.4s] %p\n", 571 "Name [%4.4s] not found in scope [%4.4s] %p\n",
568 (char *) &simple_name, (char *) &current_node->name, 572 (char *)&simple_name,
569 current_node)); 573 (char *)&current_node->name,
574 current_node));
570 } 575 }
571 576
572 *return_node = this_node; 577 *return_node = this_node;
573 return_ACPI_STATUS (status); 578 return_ACPI_STATUS(status);
574 } 579 }
575 580
576 /* 581 /*
@@ -586,19 +591,16 @@ acpi_ns_lookup (
586 * 591 *
587 * Then we have a type mismatch. Just warn and ignore it. 592 * Then we have a type mismatch. Just warn and ignore it.
588 */ 593 */
589 if ((num_segments == 0) && 594 if ((num_segments == 0) &&
590 (type_to_check_for != ACPI_TYPE_ANY) && 595 (type_to_check_for != ACPI_TYPE_ANY) &&
591 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) && 596 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
592 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 597 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
593 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && 598 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) &&
594 (this_node->type != ACPI_TYPE_ANY) && 599 (this_node->type != ACPI_TYPE_ANY) &&
595 (this_node->type != type_to_check_for)) { 600 (this_node->type != type_to_check_for)) {
596 /* Complain about a type mismatch */ 601 /* Complain about a type mismatch */
597 602
598 ACPI_REPORT_WARNING ( 603 ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for)));
599 ("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n",
600 (char *) &simple_name, acpi_ut_get_type_name (this_node->type),
601 acpi_ut_get_type_name (type_to_check_for)));
602 } 604 }
603 605
604 /* 606 /*
@@ -624,15 +626,16 @@ acpi_ns_lookup (
624 * If entry is a type which opens a scope, push the new scope on the 626 * If entry is a type which opens a scope, push the new scope on the
625 * scope stack. 627 * scope stack.
626 */ 628 */
627 if (acpi_ns_opens_scope (type)) { 629 if (acpi_ns_opens_scope(type)) {
628 status = acpi_ds_scope_stack_push (this_node, type, walk_state); 630 status =
629 if (ACPI_FAILURE (status)) { 631 acpi_ds_scope_stack_push(this_node, type,
630 return_ACPI_STATUS (status); 632 walk_state);
633 if (ACPI_FAILURE(status)) {
634 return_ACPI_STATUS(status);
631 } 635 }
632 } 636 }
633 } 637 }
634 638
635 *return_node = this_node; 639 *return_node = this_node;
636 return_ACPI_STATUS (AE_OK); 640 return_ACPI_STATUS(AE_OK);
637} 641}
638
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 5653a19d7172..cc7a85f8cfe6 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -41,20 +41,14 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nsalloc") 48ACPI_MODULE_NAME("nsalloc")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53 51static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
54static void
55acpi_ns_remove_reference (
56 struct acpi_namespace_node *node);
57
58 52
59/******************************************************************************* 53/*******************************************************************************
60 * 54 *
@@ -68,31 +62,26 @@ acpi_ns_remove_reference (
68 * 62 *
69 ******************************************************************************/ 63 ******************************************************************************/
70 64
71struct acpi_namespace_node * 65struct acpi_namespace_node *acpi_ns_create_node(u32 name)
72acpi_ns_create_node (
73 u32 name)
74{ 66{
75 struct acpi_namespace_node *node; 67 struct acpi_namespace_node *node;
76
77 68
78 ACPI_FUNCTION_TRACE ("ns_create_node"); 69 ACPI_FUNCTION_TRACE("ns_create_node");
79 70
80 71 node = ACPI_MEM_CALLOCATE(sizeof(struct acpi_namespace_node));
81 node = ACPI_MEM_CALLOCATE (sizeof (struct acpi_namespace_node));
82 if (!node) { 72 if (!node) {
83 return_PTR (NULL); 73 return_PTR(NULL);
84 } 74 }
85 75
86 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); 76 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
87 77
88 node->name.integer = name; 78 node->name.integer = name;
89 node->reference_count = 1; 79 node->reference_count = 1;
90 ACPI_SET_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED); 80 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
91 81
92 return_PTR (node); 82 return_PTR(node);
93} 83}
94 84
95
96/******************************************************************************* 85/*******************************************************************************
97 * 86 *
98 * FUNCTION: acpi_ns_delete_node 87 * FUNCTION: acpi_ns_delete_node
@@ -105,19 +94,15 @@ acpi_ns_create_node (
105 * 94 *
106 ******************************************************************************/ 95 ******************************************************************************/
107 96
108void 97void acpi_ns_delete_node(struct acpi_namespace_node *node)
109acpi_ns_delete_node (
110 struct acpi_namespace_node *node)
111{ 98{
112 struct acpi_namespace_node *parent_node; 99 struct acpi_namespace_node *parent_node;
113 struct acpi_namespace_node *prev_node; 100 struct acpi_namespace_node *prev_node;
114 struct acpi_namespace_node *next_node; 101 struct acpi_namespace_node *next_node;
115
116 102
117 ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node); 103 ACPI_FUNCTION_TRACE_PTR("ns_delete_node", node);
118 104
119 105 parent_node = acpi_ns_get_parent_node(node);
120 parent_node = acpi_ns_get_parent_node (node);
121 106
122 prev_node = NULL; 107 prev_node = NULL;
123 next_node = parent_node->child; 108 next_node = parent_node->child;
@@ -136,32 +121,29 @@ acpi_ns_delete_node (
136 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { 121 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
137 prev_node->flags |= ANOBJ_END_OF_PEER_LIST; 122 prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
138 } 123 }
139 } 124 } else {
140 else {
141 /* Node is first child (has no previous peer) */ 125 /* Node is first child (has no previous peer) */
142 126
143 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { 127 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
144 /* No peers at all */ 128 /* No peers at all */
145 129
146 parent_node->child = NULL; 130 parent_node->child = NULL;
147 } 131 } else { /* Link peer list to parent */
148 else { /* Link peer list to parent */
149 132
150 parent_node->child = next_node->peer; 133 parent_node->child = next_node->peer;
151 } 134 }
152 } 135 }
153 136
154 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 137 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
155 138
156 /* 139 /*
157 * Detach an object if there is one then delete the node 140 * Detach an object if there is one then delete the node
158 */ 141 */
159 acpi_ns_detach_object (node); 142 acpi_ns_detach_object(node);
160 ACPI_MEM_FREE (node); 143 ACPI_MEM_FREE(node);
161 return_VOID; 144 return_VOID;
162} 145}
163 146
164
165/******************************************************************************* 147/*******************************************************************************
166 * 148 *
167 * FUNCTION: acpi_ns_install_node 149 * FUNCTION: acpi_ns_install_node
@@ -176,30 +158,20 @@ acpi_ns_delete_node (
176 * DESCRIPTION: Initialize a new namespace node and install it amongst 158 * DESCRIPTION: Initialize a new namespace node and install it amongst
177 * its peers. 159 * its peers.
178 * 160 *
179 * Note: Current namespace lookup is linear search. However, the 161 * Note: Current namespace lookup is linear search. This appears
180 * nodes are linked in alphabetical order to 1) put all reserved 162 * to be sufficient as namespace searches consume only a small
181 * names (start with underscore) first, and to 2) make a readable 163 * fraction of the execution time of the ACPI subsystem.
182 * namespace dump.
183 * 164 *
184 ******************************************************************************/ 165 ******************************************************************************/
185 166
186void 167void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
187acpi_ns_install_node ( 168 struct acpi_namespace_node *node, /* New Child */
188 struct acpi_walk_state *walk_state, 169 acpi_object_type type)
189 struct acpi_namespace_node *parent_node, /* Parent */
190 struct acpi_namespace_node *node, /* New Child*/
191 acpi_object_type type)
192{ 170{
193 u16 owner_id = 0; 171 acpi_owner_id owner_id = 0;
194 struct acpi_namespace_node *child_node; 172 struct acpi_namespace_node *child_node;
195#ifdef ACPI_ALPHABETIC_NAMESPACE
196
197 struct acpi_namespace_node *previous_child_node;
198#endif
199
200
201 ACPI_FUNCTION_TRACE ("ns_install_node");
202 173
174 ACPI_FUNCTION_TRACE("ns_install_node");
203 175
204 /* 176 /*
205 * Get the owner ID from the Walk state 177 * Get the owner ID from the Walk state
@@ -217,59 +189,7 @@ acpi_ns_install_node (
217 parent_node->child = node; 189 parent_node->child = node;
218 node->flags |= ANOBJ_END_OF_PEER_LIST; 190 node->flags |= ANOBJ_END_OF_PEER_LIST;
219 node->peer = parent_node; 191 node->peer = parent_node;
220 } 192 } else {
221 else {
222#ifdef ACPI_ALPHABETIC_NAMESPACE
223 /*
224 * Walk the list whilst searching for the correct
225 * alphabetic placement.
226 */
227 previous_child_node = NULL;
228 while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node),
229 acpi_ut_get_node_name (node)) < 0) {
230 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
231 /* Last peer; Clear end-of-list flag */
232
233 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
234
235 /* This node is the new peer to the child node */
236
237 child_node->peer = node;
238
239 /* This node is the new end-of-list */
240
241 node->flags |= ANOBJ_END_OF_PEER_LIST;
242 node->peer = parent_node;
243 break;
244 }
245
246 /* Get next peer */
247
248 previous_child_node = child_node;
249 child_node = child_node->peer;
250 }
251
252 /* Did the node get inserted at the end-of-list? */
253
254 if (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
255 /*
256 * Loop above terminated without reaching the end-of-list.
257 * Insert the new node at the current location
258 */
259 if (previous_child_node) {
260 /* Insert node alphabetically */
261
262 node->peer = child_node;
263 previous_child_node->peer = node;
264 }
265 else {
266 /* Insert node alphabetically at start of list */
267
268 node->peer = child_node;
269 parent_node->child = node;
270 }
271 }
272#else
273 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { 193 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
274 child_node = child_node->peer; 194 child_node = child_node->peer;
275 } 195 }
@@ -279,9 +199,8 @@ acpi_ns_install_node (
279 /* Clear end-of-list flag */ 199 /* Clear end-of-list flag */
280 200
281 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; 201 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
282 node->flags |= ANOBJ_END_OF_PEER_LIST; 202 node->flags |= ANOBJ_END_OF_PEER_LIST;
283 node->peer = parent_node; 203 node->peer = parent_node;
284#endif
285 } 204 }
286 205
287 /* Init the new entry */ 206 /* Init the new entry */
@@ -289,24 +208,25 @@ acpi_ns_install_node (
289 node->owner_id = owner_id; 208 node->owner_id = owner_id;
290 node->type = (u8) type; 209 node->type = (u8) type;
291 210
292 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 211 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
293 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", 212 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
294 acpi_ut_get_node_name (node), acpi_ut_get_type_name (node->type), node, owner_id, 213 acpi_ut_get_node_name(node),
295 acpi_ut_get_node_name (parent_node), acpi_ut_get_type_name (parent_node->type), 214 acpi_ut_get_type_name(node->type), node, owner_id,
296 parent_node)); 215 acpi_ut_get_node_name(parent_node),
216 acpi_ut_get_type_name(parent_node->type),
217 parent_node));
297 218
298 /* 219 /*
299 * Increment the reference count(s) of all parents up to 220 * Increment the reference count(s) of all parents up to
300 * the root! 221 * the root!
301 */ 222 */
302 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 223 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
303 node->reference_count++; 224 node->reference_count++;
304 } 225 }
305 226
306 return_VOID; 227 return_VOID;
307} 228}
308 229
309
310/******************************************************************************* 230/*******************************************************************************
311 * 231 *
312 * FUNCTION: acpi_ns_delete_children 232 * FUNCTION: acpi_ns_delete_children
@@ -320,18 +240,14 @@ acpi_ns_install_node (
320 * 240 *
321 ******************************************************************************/ 241 ******************************************************************************/
322 242
323void 243void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
324acpi_ns_delete_children (
325 struct acpi_namespace_node *parent_node)
326{ 244{
327 struct acpi_namespace_node *child_node; 245 struct acpi_namespace_node *child_node;
328 struct acpi_namespace_node *next_node; 246 struct acpi_namespace_node *next_node;
329 struct acpi_namespace_node *node; 247 struct acpi_namespace_node *node;
330 u8 flags; 248 u8 flags;
331
332
333 ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node);
334 249
250 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
335 251
336 if (!parent_node) { 252 if (!parent_node) {
337 return_VOID; 253 return_VOID;
@@ -350,48 +266,48 @@ acpi_ns_delete_children (
350 do { 266 do {
351 /* Get the things we need */ 267 /* Get the things we need */
352 268
353 next_node = child_node->peer; 269 next_node = child_node->peer;
354 flags = child_node->flags; 270 flags = child_node->flags;
355 271
356 /* Grandchildren should have all been deleted already */ 272 /* Grandchildren should have all been deleted already */
357 273
358 if (child_node->child) { 274 if (child_node->child) {
359 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", 275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
360 parent_node, child_node)); 276 "Found a grandchild! P=%p C=%p\n",
277 parent_node, child_node));
361 } 278 }
362 279
363 /* Now we can free this child object */ 280 /* Now we can free this child object */
364 281
365 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 282 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
366 283
367 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", 284 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
368 child_node, acpi_gbl_current_node_count)); 285 "Object %p, Remaining %X\n", child_node,
286 acpi_gbl_current_node_count));
369 287
370 /* 288 /*
371 * Detach an object if there is one, then free the child node 289 * Detach an object if there is one, then free the child node
372 */ 290 */
373 acpi_ns_detach_object (child_node); 291 acpi_ns_detach_object(child_node);
374 292
375 /* 293 /*
376 * Decrement the reference count(s) of all parents up to 294 * Decrement the reference count(s) of all parents up to
377 * the root! (counts were incremented when the node was created) 295 * the root! (counts were incremented when the node was created)
378 */ 296 */
379 node = child_node; 297 node = child_node;
380 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 298 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
381 node->reference_count--; 299 node->reference_count--;
382 } 300 }
383 301
384 /* There should be only one reference remaining on this node */ 302 /* There should be only one reference remaining on this node */
385 303
386 if (child_node->reference_count != 1) { 304 if (child_node->reference_count != 1) {
387 ACPI_REPORT_WARNING (( 305 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node));
388 "Existing references (%d) on node being deleted (%p)\n",
389 child_node->reference_count, child_node));
390 } 306 }
391 307
392 /* Now we can delete the node */ 308 /* Now we can delete the node */
393 309
394 ACPI_MEM_FREE (child_node); 310 ACPI_MEM_FREE(child_node);
395 311
396 /* And move on to the next child in the list */ 312 /* And move on to the next child in the list */
397 313
@@ -399,7 +315,6 @@ acpi_ns_delete_children (
399 315
400 } while (!(flags & ANOBJ_END_OF_PEER_LIST)); 316 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
401 317
402
403 /* Clear the parent's child pointer */ 318 /* Clear the parent's child pointer */
404 319
405 parent_node->child = NULL; 320 parent_node->child = NULL;
@@ -407,7 +322,6 @@ acpi_ns_delete_children (
407 return_VOID; 322 return_VOID;
408} 323}
409 324
410
411/******************************************************************************* 325/*******************************************************************************
412 * 326 *
413 * FUNCTION: acpi_ns_delete_namespace_subtree 327 * FUNCTION: acpi_ns_delete_namespace_subtree
@@ -421,16 +335,12 @@ acpi_ns_delete_children (
421 * 335 *
422 ******************************************************************************/ 336 ******************************************************************************/
423 337
424void 338void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
425acpi_ns_delete_namespace_subtree (
426 struct acpi_namespace_node *parent_node)
427{ 339{
428 struct acpi_namespace_node *child_node = NULL; 340 struct acpi_namespace_node *child_node = NULL;
429 u32 level = 1; 341 u32 level = 1;
430
431
432 ACPI_FUNCTION_TRACE ("ns_delete_namespace_subtree");
433 342
343 ACPI_FUNCTION_TRACE("ns_delete_namespace_subtree");
434 344
435 if (!parent_node) { 345 if (!parent_node) {
436 return_VOID; 346 return_VOID;
@@ -443,16 +353,17 @@ acpi_ns_delete_namespace_subtree (
443 while (level > 0) { 353 while (level > 0) {
444 /* Get the next node in this scope (NULL if none) */ 354 /* Get the next node in this scope (NULL if none) */
445 355
446 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, 356 child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
447 child_node); 357 child_node);
448 if (child_node) { 358 if (child_node) {
449 /* Found a child node - detach any attached object */ 359 /* Found a child node - detach any attached object */
450 360
451 acpi_ns_detach_object (child_node); 361 acpi_ns_detach_object(child_node);
452 362
453 /* Check if this node has any children */ 363 /* Check if this node has any children */
454 364
455 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 365 if (acpi_ns_get_next_node
366 (ACPI_TYPE_ANY, child_node, NULL)) {
456 /* 367 /*
457 * There is at least one child of this node, 368 * There is at least one child of this node,
458 * visit the node 369 * visit the node
@@ -461,8 +372,7 @@ acpi_ns_delete_namespace_subtree (
461 parent_node = child_node; 372 parent_node = child_node;
462 child_node = NULL; 373 child_node = NULL;
463 } 374 }
464 } 375 } else {
465 else {
466 /* 376 /*
467 * No more children of this parent node. 377 * No more children of this parent node.
468 * Move up to the grandparent. 378 * Move up to the grandparent.
@@ -473,7 +383,7 @@ acpi_ns_delete_namespace_subtree (
473 * Now delete all of the children of this parent 383 * Now delete all of the children of this parent
474 * all at the same time. 384 * all at the same time.
475 */ 385 */
476 acpi_ns_delete_children (parent_node); 386 acpi_ns_delete_children(parent_node);
477 387
478 /* New "last child" is this parent node */ 388 /* New "last child" is this parent node */
479 389
@@ -481,14 +391,13 @@ acpi_ns_delete_namespace_subtree (
481 391
482 /* Move up the tree to the grandparent */ 392 /* Move up the tree to the grandparent */
483 393
484 parent_node = acpi_ns_get_parent_node (parent_node); 394 parent_node = acpi_ns_get_parent_node(parent_node);
485 } 395 }
486 } 396 }
487 397
488 return_VOID; 398 return_VOID;
489} 399}
490 400
491
492/******************************************************************************* 401/*******************************************************************************
493 * 402 *
494 * FUNCTION: acpi_ns_remove_reference 403 * FUNCTION: acpi_ns_remove_reference
@@ -504,16 +413,12 @@ acpi_ns_delete_namespace_subtree (
504 * 413 *
505 ******************************************************************************/ 414 ******************************************************************************/
506 415
507static void 416static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
508acpi_ns_remove_reference (
509 struct acpi_namespace_node *node)
510{ 417{
511 struct acpi_namespace_node *parent_node; 418 struct acpi_namespace_node *parent_node;
512 struct acpi_namespace_node *this_node; 419 struct acpi_namespace_node *this_node;
513
514
515 ACPI_FUNCTION_ENTRY ();
516 420
421 ACPI_FUNCTION_ENTRY();
517 422
518 /* 423 /*
519 * Decrement the reference count(s) of this node and all 424 * Decrement the reference count(s) of this node and all
@@ -523,7 +428,7 @@ acpi_ns_remove_reference (
523 while (this_node) { 428 while (this_node) {
524 /* Prepare to move up to parent */ 429 /* Prepare to move up to parent */
525 430
526 parent_node = acpi_ns_get_parent_node (this_node); 431 parent_node = acpi_ns_get_parent_node(this_node);
527 432
528 /* Decrement the reference count on this node */ 433 /* Decrement the reference count on this node */
529 434
@@ -534,15 +439,14 @@ acpi_ns_remove_reference (
534 if (!this_node->reference_count) { 439 if (!this_node->reference_count) {
535 /* Delete all children and delete the node */ 440 /* Delete all children and delete the node */
536 441
537 acpi_ns_delete_children (this_node); 442 acpi_ns_delete_children(this_node);
538 acpi_ns_delete_node (this_node); 443 acpi_ns_delete_node(this_node);
539 } 444 }
540 445
541 this_node = parent_node; 446 this_node = parent_node;
542 } 447 }
543} 448}
544 449
545
546/******************************************************************************* 450/*******************************************************************************
547 * 451 *
548 * FUNCTION: acpi_ns_delete_namespace_by_owner 452 * FUNCTION: acpi_ns_delete_namespace_by_owner
@@ -557,23 +461,23 @@ acpi_ns_remove_reference (
557 * 461 *
558 ******************************************************************************/ 462 ******************************************************************************/
559 463
560void 464void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
561acpi_ns_delete_namespace_by_owner (
562 u16 owner_id)
563{ 465{
564 struct acpi_namespace_node *child_node; 466 struct acpi_namespace_node *child_node;
565 struct acpi_namespace_node *deletion_node; 467 struct acpi_namespace_node *deletion_node;
566 u32 level; 468 u32 level;
567 struct acpi_namespace_node *parent_node; 469 struct acpi_namespace_node *parent_node;
568
569 470
570 ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); 471 ACPI_FUNCTION_TRACE_U32("ns_delete_namespace_by_owner", owner_id);
571 472
473 if (owner_id == 0) {
474 return_VOID;
475 }
572 476
573 parent_node = acpi_gbl_root_node; 477 parent_node = acpi_gbl_root_node;
574 child_node = NULL; 478 child_node = NULL;
575 deletion_node = NULL; 479 deletion_node = NULL;
576 level = 1; 480 level = 1;
577 481
578 /* 482 /*
579 * Traverse the tree of nodes until we bubble back up 483 * Traverse the tree of nodes until we bubble back up
@@ -584,10 +488,12 @@ acpi_ns_delete_namespace_by_owner (
584 * Get the next child of this parent node. When child_node is NULL, 488 * Get the next child of this parent node. When child_node is NULL,
585 * the first child of the parent is returned 489 * the first child of the parent is returned
586 */ 490 */
587 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); 491 child_node =
492 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
493 child_node);
588 494
589 if (deletion_node) { 495 if (deletion_node) {
590 acpi_ns_remove_reference (deletion_node); 496 acpi_ns_remove_reference(deletion_node);
591 deletion_node = NULL; 497 deletion_node = NULL;
592 } 498 }
593 499
@@ -595,12 +501,13 @@ acpi_ns_delete_namespace_by_owner (
595 if (child_node->owner_id == owner_id) { 501 if (child_node->owner_id == owner_id) {
596 /* Found a matching child node - detach any attached object */ 502 /* Found a matching child node - detach any attached object */
597 503
598 acpi_ns_detach_object (child_node); 504 acpi_ns_detach_object(child_node);
599 } 505 }
600 506
601 /* Check if this node has any children */ 507 /* Check if this node has any children */
602 508
603 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 509 if (acpi_ns_get_next_node
510 (ACPI_TYPE_ANY, child_node, NULL)) {
604 /* 511 /*
605 * There is at least one child of this node, 512 * There is at least one child of this node,
606 * visit the node 513 * visit the node
@@ -608,12 +515,10 @@ acpi_ns_delete_namespace_by_owner (
608 level++; 515 level++;
609 parent_node = child_node; 516 parent_node = child_node;
610 child_node = NULL; 517 child_node = NULL;
611 } 518 } else if (child_node->owner_id == owner_id) {
612 else if (child_node->owner_id == owner_id) {
613 deletion_node = child_node; 519 deletion_node = child_node;
614 } 520 }
615 } 521 } else {
616 else {
617 /* 522 /*
618 * No more children of this parent node. 523 * No more children of this parent node.
619 * Move up to the grandparent. 524 * Move up to the grandparent.
@@ -631,62 +536,9 @@ acpi_ns_delete_namespace_by_owner (
631 536
632 /* Move up the tree to the grandparent */ 537 /* Move up the tree to the grandparent */
633 538
634 parent_node = acpi_ns_get_parent_node (parent_node); 539 parent_node = acpi_ns_get_parent_node(parent_node);
635 } 540 }
636 } 541 }
637 542
638 return_VOID; 543 return_VOID;
639} 544}
640
641
642#ifdef ACPI_ALPHABETIC_NAMESPACE
643/*******************************************************************************
644 *
645 * FUNCTION: acpi_ns_compare_names
646 *
647 * PARAMETERS: Name1 - First name to compare
648 * Name2 - Second name to compare
649 *
650 * RETURN: value from strncmp
651 *
652 * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
653 * underscore are forced to be alphabetically first.
654 *
655 ******************************************************************************/
656
657int
658acpi_ns_compare_names (
659 char *name1,
660 char *name2)
661{
662 char reversed_name1[ACPI_NAME_SIZE];
663 char reversed_name2[ACPI_NAME_SIZE];
664 u32 i;
665 u32 j;
666
667
668 /*
669 * Replace all instances of "underscore" with a value that is smaller so
670 * that all names that are prefixed with underscore(s) are alphabetically
671 * first.
672 *
673 * Reverse the name bytewise so we can just do a 32-bit compare instead
674 * of a strncmp.
675 */
676 for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
677 reversed_name1[j] = name1[i];
678 if (name1[i] == '_') {
679 reversed_name1[j] = '*';
680 }
681
682 reversed_name2[j] = name2[i];
683 if (name2[i] == '_') {
684 reversed_name2[j] = '*';
685 }
686 }
687
688 return (*(int *) reversed_name1 - *(int *) reversed_name2);
689}
690#endif
691
692
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 6c2aef0e0dd4..9faf1d5c86ed 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -41,31 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump") 49ACPI_MODULE_NAME("nsdump")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55#ifdef ACPI_OBSOLETE_FUNCTIONS 52#ifdef ACPI_OBSOLETE_FUNCTIONS
56void 53void acpi_ns_dump_root_devices(void);
57acpi_ns_dump_root_devices (
58 void);
59 54
60static acpi_status 55static acpi_status
61acpi_ns_dump_one_device ( 56acpi_ns_dump_one_device(acpi_handle obj_handle,
62 acpi_handle obj_handle, 57 u32 level, void *context, void **return_value);
63 u32 level,
64 void *context,
65 void **return_value);
66#endif 58#endif
67 59
68
69#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 60#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
70/******************************************************************************* 61/*******************************************************************************
71 * 62 *
@@ -80,36 +71,38 @@ acpi_ns_dump_one_device (
80 * 71 *
81 ******************************************************************************/ 72 ******************************************************************************/
82 73
83void 74void acpi_ns_print_pathname(u32 num_segments, char *pathname)
84acpi_ns_print_pathname (
85 u32 num_segments,
86 char *pathname)
87{ 75{
88 ACPI_FUNCTION_NAME ("ns_print_pathname"); 76 acpi_native_uint i;
89 77
78 ACPI_FUNCTION_NAME("ns_print_pathname");
90 79
91 if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) { 80 if (!(acpi_dbg_level & ACPI_LV_NAMES)
81 || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
92 return; 82 return;
93 } 83 }
94 84
95 /* Print the entire name */ 85 /* Print the entire name */
96 86
97 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); 87 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
98 88
99 while (num_segments) { 89 while (num_segments) {
100 acpi_os_printf ("%4.4s", pathname); 90 for (i = 0; i < 4; i++) {
101 pathname += ACPI_NAME_SIZE; 91 ACPI_IS_PRINT(pathname[i]) ?
92 acpi_os_printf("%c", pathname[i]) :
93 acpi_os_printf("?");
94 }
102 95
96 pathname += ACPI_NAME_SIZE;
103 num_segments--; 97 num_segments--;
104 if (num_segments) { 98 if (num_segments) {
105 acpi_os_printf ("."); 99 acpi_os_printf(".");
106 } 100 }
107 } 101 }
108 102
109 acpi_os_printf ("]\n"); 103 acpi_os_printf("]\n");
110} 104}
111 105
112
113/******************************************************************************* 106/*******************************************************************************
114 * 107 *
115 * FUNCTION: acpi_ns_dump_pathname 108 * FUNCTION: acpi_ns_dump_pathname
@@ -127,15 +120,10 @@ acpi_ns_print_pathname (
127 ******************************************************************************/ 120 ******************************************************************************/
128 121
129void 122void
130acpi_ns_dump_pathname ( 123acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
131 acpi_handle handle,
132 char *msg,
133 u32 level,
134 u32 component)
135{ 124{
136 125
137 ACPI_FUNCTION_TRACE ("ns_dump_pathname"); 126 ACPI_FUNCTION_TRACE("ns_dump_pathname");
138
139 127
140 /* Do this only if the requested debug level and component are enabled */ 128 /* Do this only if the requested debug level and component are enabled */
141 129
@@ -145,12 +133,11 @@ acpi_ns_dump_pathname (
145 133
146 /* Convert handle to a full pathname and print it (with supplied message) */ 134 /* Convert handle to a full pathname and print it (with supplied message) */
147 135
148 acpi_ns_print_node_pathname (handle, msg); 136 acpi_ns_print_node_pathname(handle, msg);
149 acpi_os_printf ("\n"); 137 acpi_os_printf("\n");
150 return_VOID; 138 return_VOID;
151} 139}
152 140
153
154/******************************************************************************* 141/*******************************************************************************
155 * 142 *
156 * FUNCTION: acpi_ns_dump_one_object 143 * FUNCTION: acpi_ns_dump_one_object
@@ -168,24 +155,19 @@ acpi_ns_dump_pathname (
168 ******************************************************************************/ 155 ******************************************************************************/
169 156
170acpi_status 157acpi_status
171acpi_ns_dump_one_object ( 158acpi_ns_dump_one_object(acpi_handle obj_handle,
172 acpi_handle obj_handle, 159 u32 level, void *context, void **return_value)
173 u32 level,
174 void *context,
175 void **return_value)
176{ 160{
177 struct acpi_walk_info *info = (struct acpi_walk_info *) context; 161 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
178 struct acpi_namespace_node *this_node; 162 struct acpi_namespace_node *this_node;
179 union acpi_operand_object *obj_desc = NULL; 163 union acpi_operand_object *obj_desc = NULL;
180 acpi_object_type obj_type; 164 acpi_object_type obj_type;
181 acpi_object_type type; 165 acpi_object_type type;
182 u32 bytes_to_dump; 166 u32 bytes_to_dump;
183 u32 dbg_level; 167 u32 dbg_level;
184 u32 i; 168 u32 i;
185
186
187 ACPI_FUNCTION_NAME ("ns_dump_one_object");
188 169
170 ACPI_FUNCTION_NAME("ns_dump_one_object");
189 171
190 /* Is output enabled? */ 172 /* Is output enabled? */
191 173
@@ -194,193 +176,215 @@ acpi_ns_dump_one_object (
194 } 176 }
195 177
196 if (!obj_handle) { 178 if (!obj_handle) {
197 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
198 return (AE_OK); 180 return (AE_OK);
199 } 181 }
200 182
201 this_node = acpi_ns_map_handle_to_node (obj_handle); 183 this_node = acpi_ns_map_handle_to_node(obj_handle);
202 type = this_node->type; 184 type = this_node->type;
203 185
204 /* Check if the owner matches */ 186 /* Check if the owner matches */
205 187
206 if ((info->owner_id != ACPI_UINT32_MAX) && 188 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
207 (info->owner_id != this_node->owner_id)) { 189 (info->owner_id != this_node->owner_id)) {
208 return (AE_OK); 190 return (AE_OK);
209 } 191 }
210 192
211 /* Indent the object according to the level */ 193 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
194 /* Indent the object according to the level */
212 195
213 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); 196 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
214 197
215 /* Check the node type and name */ 198 /* Check the node type and name */
216 199
217 if (type > ACPI_TYPE_LOCAL_MAX) { 200 if (type > ACPI_TYPE_LOCAL_MAX) {
218 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); 201 ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type));
219 } 202 }
203
204 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
205 ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n",
206 this_node->name.integer));
207 }
220 208
221 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { 209 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
222 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
223 this_node->name.integer));
224 } 210 }
225 211
226 /* 212 /*
227 * Now we can print out the pertinent information 213 * Now we can print out the pertinent information
228 */ 214 */
229 acpi_os_printf ("%4.4s %-12s %p ", 215 acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node);
230 acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node);
231 216
232 dbg_level = acpi_dbg_level; 217 dbg_level = acpi_dbg_level;
233 acpi_dbg_level = 0; 218 acpi_dbg_level = 0;
234 obj_desc = acpi_ns_get_attached_object (this_node); 219 obj_desc = acpi_ns_get_attached_object(this_node);
235 acpi_dbg_level = dbg_level; 220 acpi_dbg_level = dbg_level;
236 221
237 switch (info->display_type) { 222 switch (info->display_type & ACPI_DISPLAY_MASK) {
238 case ACPI_DISPLAY_SUMMARY: 223 case ACPI_DISPLAY_SUMMARY:
239 224
240 if (!obj_desc) { 225 if (!obj_desc) {
241 /* No attached object, we are done */ 226 /* No attached object, we are done */
242 227
243 acpi_os_printf ("\n"); 228 acpi_os_printf("\n");
244 return (AE_OK); 229 return (AE_OK);
245 } 230 }
246 231
247 switch (type) { 232 switch (type) {
248 case ACPI_TYPE_PROCESSOR: 233 case ACPI_TYPE_PROCESSOR:
249 234
250 acpi_os_printf ("ID %X Len %.4X Addr %p\n", 235 acpi_os_printf("ID %X Len %.4X Addr %p\n",
251 obj_desc->processor.proc_id, obj_desc->processor.length, 236 obj_desc->processor.proc_id,
252 (char *) obj_desc->processor.address); 237 obj_desc->processor.length,
238 (char *)obj_desc->processor.address);
253 break; 239 break;
254 240
255
256 case ACPI_TYPE_DEVICE: 241 case ACPI_TYPE_DEVICE:
257 242
258 acpi_os_printf ("Notify Object: %p\n", obj_desc); 243 acpi_os_printf("Notify Object: %p\n", obj_desc);
259 break; 244 break;
260 245
261
262 case ACPI_TYPE_METHOD: 246 case ACPI_TYPE_METHOD:
263 247
264 acpi_os_printf ("Args %X Len %.4X Aml %p\n", 248 acpi_os_printf("Args %X Len %.4X Aml %p\n",
265 (u32) obj_desc->method.param_count, 249 (u32) obj_desc->method.param_count,
266 obj_desc->method.aml_length, obj_desc->method.aml_start); 250 obj_desc->method.aml_length,
251 obj_desc->method.aml_start);
267 break; 252 break;
268 253
269
270 case ACPI_TYPE_INTEGER: 254 case ACPI_TYPE_INTEGER:
271 255
272 acpi_os_printf ("= %8.8X%8.8X\n", 256 acpi_os_printf("= %8.8X%8.8X\n",
273 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 257 ACPI_FORMAT_UINT64(obj_desc->integer.
258 value));
274 break; 259 break;
275 260
276
277 case ACPI_TYPE_PACKAGE: 261 case ACPI_TYPE_PACKAGE:
278 262
279 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 263 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
280 acpi_os_printf ("Elements %.2X\n", 264 acpi_os_printf("Elements %.2X\n",
281 obj_desc->package.count); 265 obj_desc->package.count);
282 } 266 } else {
283 else { 267 acpi_os_printf("[Length not yet evaluated]\n");
284 acpi_os_printf ("[Length not yet evaluated]\n");
285 } 268 }
286 break; 269 break;
287 270
288
289 case ACPI_TYPE_BUFFER: 271 case ACPI_TYPE_BUFFER:
290 272
291 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 273 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
292 acpi_os_printf ("Len %.2X", 274 acpi_os_printf("Len %.2X",
293 obj_desc->buffer.length); 275 obj_desc->buffer.length);
294 276
295 /* Dump some of the buffer */ 277 /* Dump some of the buffer */
296 278
297 if (obj_desc->buffer.length > 0) { 279 if (obj_desc->buffer.length > 0) {
298 acpi_os_printf (" ="); 280 acpi_os_printf(" =");
299 for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) { 281 for (i = 0;
300 acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]); 282 (i < obj_desc->buffer.length
283 && i < 12); i++) {
284 acpi_os_printf(" %.2hX",
285 obj_desc->buffer.
286 pointer[i]);
301 } 287 }
302 } 288 }
303 acpi_os_printf ("\n"); 289 acpi_os_printf("\n");
304 } 290 } else {
305 else { 291 acpi_os_printf("[Length not yet evaluated]\n");
306 acpi_os_printf ("[Length not yet evaluated]\n");
307 } 292 }
308 break; 293 break;
309 294
310
311 case ACPI_TYPE_STRING: 295 case ACPI_TYPE_STRING:
312 296
313 acpi_os_printf ("Len %.2X ", obj_desc->string.length); 297 acpi_os_printf("Len %.2X ", obj_desc->string.length);
314 acpi_ut_print_string (obj_desc->string.pointer, 32); 298 acpi_ut_print_string(obj_desc->string.pointer, 32);
315 acpi_os_printf ("\n"); 299 acpi_os_printf("\n");
316 break; 300 break;
317 301
318
319 case ACPI_TYPE_REGION: 302 case ACPI_TYPE_REGION:
320 303
321 acpi_os_printf ("[%s]", 304 acpi_os_printf("[%s]",
322 acpi_ut_get_region_name (obj_desc->region.space_id)); 305 acpi_ut_get_region_name(obj_desc->region.
306 space_id));
323 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 307 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
324 acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n", 308 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
325 ACPI_FORMAT_UINT64 (obj_desc->region.address), 309 ACPI_FORMAT_UINT64(obj_desc->
326 obj_desc->region.length); 310 region.
327 } 311 address),
328 else { 312 obj_desc->region.length);
329 acpi_os_printf (" [Address/Length not yet evaluated]\n"); 313 } else {
314 acpi_os_printf
315 (" [Address/Length not yet evaluated]\n");
330 } 316 }
331 break; 317 break;
332 318
333
334 case ACPI_TYPE_LOCAL_REFERENCE: 319 case ACPI_TYPE_LOCAL_REFERENCE:
335 320
336 acpi_os_printf ("[%s]\n", 321 acpi_os_printf("[%s]\n",
337 acpi_ps_get_opcode_name (obj_desc->reference.opcode)); 322 acpi_ps_get_opcode_name(obj_desc->
323 reference.
324 opcode));
338 break; 325 break;
339 326
340
341 case ACPI_TYPE_BUFFER_FIELD: 327 case ACPI_TYPE_BUFFER_FIELD:
342 328
343 if (obj_desc->buffer_field.buffer_obj && 329 if (obj_desc->buffer_field.buffer_obj &&
344 obj_desc->buffer_field.buffer_obj->buffer.node) { 330 obj_desc->buffer_field.buffer_obj->buffer.node) {
345 acpi_os_printf ("Buf [%4.4s]", 331 acpi_os_printf("Buf [%4.4s]",
346 acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node)); 332 acpi_ut_get_node_name(obj_desc->
333 buffer_field.
334 buffer_obj->
335 buffer.
336 node));
347 } 337 }
348 break; 338 break;
349 339
350
351 case ACPI_TYPE_LOCAL_REGION_FIELD: 340 case ACPI_TYPE_LOCAL_REGION_FIELD:
352 341
353 acpi_os_printf ("Rgn [%4.4s]", 342 acpi_os_printf("Rgn [%4.4s]",
354 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node)); 343 acpi_ut_get_node_name(obj_desc->
344 common_field.
345 region_obj->region.
346 node));
355 break; 347 break;
356 348
357
358 case ACPI_TYPE_LOCAL_BANK_FIELD: 349 case ACPI_TYPE_LOCAL_BANK_FIELD:
359 350
360 acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]", 351 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
361 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node), 352 acpi_ut_get_node_name(obj_desc->
362 acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node)); 353 common_field.
354 region_obj->region.
355 node),
356 acpi_ut_get_node_name(obj_desc->
357 bank_field.
358 bank_obj->
359 common_field.
360 node));
363 break; 361 break;
364 362
365
366 case ACPI_TYPE_LOCAL_INDEX_FIELD: 363 case ACPI_TYPE_LOCAL_INDEX_FIELD:
367 364
368 acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]", 365 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
369 acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node), 366 acpi_ut_get_node_name(obj_desc->
370 acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node)); 367 index_field.
368 index_obj->
369 common_field.node),
370 acpi_ut_get_node_name(obj_desc->
371 index_field.
372 data_obj->
373 common_field.
374 node));
371 break; 375 break;
372 376
373
374 case ACPI_TYPE_LOCAL_ALIAS: 377 case ACPI_TYPE_LOCAL_ALIAS:
375 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 378 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
376 379
377 acpi_os_printf ("Target %4.4s (%p)\n", 380 acpi_os_printf("Target %4.4s (%p)\n",
378 acpi_ut_get_node_name (obj_desc), obj_desc); 381 acpi_ut_get_node_name(obj_desc),
382 obj_desc);
379 break; 383 break;
380 384
381 default: 385 default:
382 386
383 acpi_os_printf ("Object %p\n", obj_desc); 387 acpi_os_printf("Object %p\n", obj_desc);
384 break; 388 break;
385 } 389 }
386 390
@@ -392,11 +396,15 @@ acpi_ns_dump_one_object (
392 case ACPI_TYPE_LOCAL_BANK_FIELD: 396 case ACPI_TYPE_LOCAL_BANK_FIELD:
393 case ACPI_TYPE_LOCAL_INDEX_FIELD: 397 case ACPI_TYPE_LOCAL_INDEX_FIELD:
394 398
395 acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n", 399 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
396 (obj_desc->common_field.base_byte_offset * 8) 400 (obj_desc->common_field.
397 + obj_desc->common_field.start_field_bit_offset, 401 base_byte_offset * 8)
398 obj_desc->common_field.bit_length, 402 +
399 obj_desc->common_field.access_byte_width); 403 obj_desc->common_field.
404 start_field_bit_offset,
405 obj_desc->common_field.bit_length,
406 obj_desc->common_field.
407 access_byte_width);
400 break; 408 break;
401 409
402 default: 410 default:
@@ -404,56 +412,55 @@ acpi_ns_dump_one_object (
404 } 412 }
405 break; 413 break;
406 414
407
408 case ACPI_DISPLAY_OBJECTS: 415 case ACPI_DISPLAY_OBJECTS:
409 416
410 acpi_os_printf ("O:%p", obj_desc); 417 acpi_os_printf("O:%p", obj_desc);
411 if (!obj_desc) { 418 if (!obj_desc) {
412 /* No attached object, we are done */ 419 /* No attached object, we are done */
413 420
414 acpi_os_printf ("\n"); 421 acpi_os_printf("\n");
415 return (AE_OK); 422 return (AE_OK);
416 } 423 }
417 424
418 acpi_os_printf ("(R%d)", obj_desc->common.reference_count); 425 acpi_os_printf("(R%d)", obj_desc->common.reference_count);
419 426
420 switch (type) { 427 switch (type) {
421 case ACPI_TYPE_METHOD: 428 case ACPI_TYPE_METHOD:
422 429
423 /* Name is a Method and its AML offset/length are set */ 430 /* Name is a Method and its AML offset/length are set */
424 431
425 acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start, 432 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
426 obj_desc->method.aml_length); 433 obj_desc->method.aml_length);
427 break; 434 break;
428 435
429 case ACPI_TYPE_INTEGER: 436 case ACPI_TYPE_INTEGER:
430 437
431 acpi_os_printf (" I:%8.8X8.8%X\n", 438 acpi_os_printf(" I:%8.8X8.8%X\n",
432 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 439 ACPI_FORMAT_UINT64(obj_desc->integer.
440 value));
433 break; 441 break;
434 442
435 case ACPI_TYPE_STRING: 443 case ACPI_TYPE_STRING:
436 444
437 acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer, 445 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
438 obj_desc->string.length); 446 obj_desc->string.length);
439 break; 447 break;
440 448
441 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
442 450
443 acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer, 451 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
444 obj_desc->buffer.length); 452 obj_desc->buffer.length);
445 break; 453 break;
446 454
447 default: 455 default:
448 456
449 acpi_os_printf ("\n"); 457 acpi_os_printf("\n");
450 break; 458 break;
451 } 459 }
452 break; 460 break;
453 461
454
455 default: 462 default:
456 acpi_os_printf ("\n"); 463 acpi_os_printf("\n");
457 break; 464 break;
458 } 465 }
459 466
@@ -463,61 +470,58 @@ acpi_ns_dump_one_object (
463 return (AE_OK); 470 return (AE_OK);
464 } 471 }
465 472
466
467 /* If there is an attached object, display it */ 473 /* If there is an attached object, display it */
468 474
469 dbg_level = acpi_dbg_level; 475 dbg_level = acpi_dbg_level;
470 acpi_dbg_level = 0; 476 acpi_dbg_level = 0;
471 obj_desc = acpi_ns_get_attached_object (this_node); 477 obj_desc = acpi_ns_get_attached_object(this_node);
472 acpi_dbg_level = dbg_level; 478 acpi_dbg_level = dbg_level;
473 479
474 /* Dump attached objects */ 480 /* Dump attached objects */
475 481
476 while (obj_desc) { 482 while (obj_desc) {
477 obj_type = ACPI_TYPE_INVALID; 483 obj_type = ACPI_TYPE_INVALID;
478 acpi_os_printf (" Attached Object %p: ", obj_desc); 484 acpi_os_printf("Attached Object %p: ", obj_desc);
479 485
480 /* Decode the type of attached object and dump the contents */ 486 /* Decode the type of attached object and dump the contents */
481 487
482 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 488 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
483 case ACPI_DESC_TYPE_NAMED: 489 case ACPI_DESC_TYPE_NAMED:
484 490
485 acpi_os_printf ("(Ptr to Node)\n"); 491 acpi_os_printf("(Ptr to Node)\n");
486 bytes_to_dump = sizeof (struct acpi_namespace_node); 492 bytes_to_dump = sizeof(struct acpi_namespace_node);
493 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
487 break; 494 break;
488 495
489
490 case ACPI_DESC_TYPE_OPERAND: 496 case ACPI_DESC_TYPE_OPERAND:
491 497
492 obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); 498 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
493 499
494 if (obj_type > ACPI_TYPE_LOCAL_MAX) { 500 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
495 acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", 501 acpi_os_printf
496 obj_type); 502 ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
503 obj_type);
497 bytes_to_dump = 32; 504 bytes_to_dump = 32;
505 } else {
506 acpi_os_printf
507 ("(Ptr to ACPI Object type %X [%s])\n",
508 obj_type, acpi_ut_get_type_name(obj_type));
509 bytes_to_dump =
510 sizeof(union acpi_operand_object);
498 } 511 }
499 else {
500 acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n",
501 acpi_ut_get_type_name (obj_type), obj_type);
502 bytes_to_dump = sizeof (union acpi_operand_object);
503 }
504 break;
505 512
513 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
514 break;
506 515
507 default: 516 default:
508 517
509 acpi_os_printf (
510 "(String or Buffer ptr - not an object descriptor) [%s]\n",
511 acpi_ut_get_descriptor_name (obj_desc));
512 bytes_to_dump = 16;
513 break; 518 break;
514 } 519 }
515 520
516 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
517
518 /* If value is NOT an internal object, we are done */ 521 /* If value is NOT an internal object, we are done */
519 522
520 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 523 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
524 ACPI_DESC_TYPE_OPERAND) {
521 goto cleanup; 525 goto cleanup;
522 } 526 }
523 527
@@ -525,51 +529,56 @@ acpi_ns_dump_one_object (
525 * Valid object, get the pointer to next level, if any 529 * Valid object, get the pointer to next level, if any
526 */ 530 */
527 switch (obj_type) { 531 switch (obj_type) {
528 case ACPI_TYPE_STRING:
529 obj_desc = (void *) obj_desc->string.pointer;
530 break;
531
532 case ACPI_TYPE_BUFFER: 532 case ACPI_TYPE_BUFFER:
533 obj_desc = (void *) obj_desc->buffer.pointer; 533 case ACPI_TYPE_STRING:
534 break; 534 /*
535 * NOTE: takes advantage of common fields between string/buffer
536 */
537 bytes_to_dump = obj_desc->string.length;
538 obj_desc = (void *)obj_desc->string.pointer;
539 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
540 obj_desc, bytes_to_dump);
541 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
542 goto cleanup;
535 543
536 case ACPI_TYPE_BUFFER_FIELD: 544 case ACPI_TYPE_BUFFER_FIELD:
537 obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; 545 obj_desc =
546 (union acpi_operand_object *)obj_desc->buffer_field.
547 buffer_obj;
538 break; 548 break;
539 549
540 case ACPI_TYPE_PACKAGE: 550 case ACPI_TYPE_PACKAGE:
541 obj_desc = (void *) obj_desc->package.elements; 551 obj_desc = (void *)obj_desc->package.elements;
542 break; 552 break;
543 553
544 case ACPI_TYPE_METHOD: 554 case ACPI_TYPE_METHOD:
545 obj_desc = (void *) obj_desc->method.aml_start; 555 obj_desc = (void *)obj_desc->method.aml_start;
546 break; 556 break;
547 557
548 case ACPI_TYPE_LOCAL_REGION_FIELD: 558 case ACPI_TYPE_LOCAL_REGION_FIELD:
549 obj_desc = (void *) obj_desc->field.region_obj; 559 obj_desc = (void *)obj_desc->field.region_obj;
550 break; 560 break;
551 561
552 case ACPI_TYPE_LOCAL_BANK_FIELD: 562 case ACPI_TYPE_LOCAL_BANK_FIELD:
553 obj_desc = (void *) obj_desc->bank_field.region_obj; 563 obj_desc = (void *)obj_desc->bank_field.region_obj;
554 break; 564 break;
555 565
556 case ACPI_TYPE_LOCAL_INDEX_FIELD: 566 case ACPI_TYPE_LOCAL_INDEX_FIELD:
557 obj_desc = (void *) obj_desc->index_field.index_obj; 567 obj_desc = (void *)obj_desc->index_field.index_obj;
558 break; 568 break;
559 569
560 default: 570 default:
561 goto cleanup; 571 goto cleanup;
562 } 572 }
563 573
564 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ 574 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
565 } 575 }
566 576
567cleanup: 577 cleanup:
568 acpi_os_printf ("\n"); 578 acpi_os_printf("\n");
569 return (AE_OK); 579 return (AE_OK);
570} 580}
571 581
572
573#ifdef ACPI_FUTURE_USAGE 582#ifdef ACPI_FUTURE_USAGE
574/******************************************************************************* 583/*******************************************************************************
575 * 584 *
@@ -591,29 +600,25 @@ cleanup:
591 ******************************************************************************/ 600 ******************************************************************************/
592 601
593void 602void
594acpi_ns_dump_objects ( 603acpi_ns_dump_objects(acpi_object_type type,
595 acpi_object_type type, 604 u8 display_type,
596 u8 display_type, 605 u32 max_depth,
597 u32 max_depth, 606 acpi_owner_id owner_id, acpi_handle start_handle)
598 u32 owner_id,
599 acpi_handle start_handle)
600{ 607{
601 struct acpi_walk_info info; 608 struct acpi_walk_info info;
602
603
604 ACPI_FUNCTION_ENTRY ();
605 609
610 ACPI_FUNCTION_ENTRY();
606 611
607 info.debug_level = ACPI_LV_TABLES; 612 info.debug_level = ACPI_LV_TABLES;
608 info.owner_id = owner_id; 613 info.owner_id = owner_id;
609 info.display_type = display_type; 614 info.display_type = display_type;
610 615
611 (void) acpi_ns_walk_namespace (type, start_handle, max_depth, 616 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
612 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, 617 ACPI_NS_WALK_NO_UNLOCK,
613 (void *) &info, NULL); 618 acpi_ns_dump_one_object, (void *)&info,
619 NULL);
614} 620}
615#endif /* ACPI_FUTURE_USAGE */ 621#endif /* ACPI_FUTURE_USAGE */
616
617 622
618/******************************************************************************* 623/*******************************************************************************
619 * 624 *
@@ -628,26 +633,20 @@ acpi_ns_dump_objects (
628 * 633 *
629 ******************************************************************************/ 634 ******************************************************************************/
630 635
631void 636void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
632acpi_ns_dump_entry (
633 acpi_handle handle,
634 u32 debug_level)
635{ 637{
636 struct acpi_walk_info info; 638 struct acpi_walk_info info;
637
638
639 ACPI_FUNCTION_ENTRY ();
640 639
640 ACPI_FUNCTION_ENTRY();
641 641
642 info.debug_level = debug_level; 642 info.debug_level = debug_level;
643 info.owner_id = ACPI_UINT32_MAX; 643 info.owner_id = ACPI_OWNER_ID_MAX;
644 info.display_type = ACPI_DISPLAY_SUMMARY; 644 info.display_type = ACPI_DISPLAY_SUMMARY;
645 645
646 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); 646 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
647} 647}
648 648
649 649#ifdef ACPI_ASL_COMPILER
650#ifdef _ACPI_ASL_COMPILER
651/******************************************************************************* 650/*******************************************************************************
652 * 651 *
653 * FUNCTION: acpi_ns_dump_tables 652 * FUNCTION: acpi_ns_dump_tables
@@ -663,23 +662,19 @@ acpi_ns_dump_entry (
663 * 662 *
664 ******************************************************************************/ 663 ******************************************************************************/
665 664
666void 665void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
667acpi_ns_dump_tables (
668 acpi_handle search_base,
669 u32 max_depth)
670{ 666{
671 acpi_handle search_handle = search_base; 667 acpi_handle search_handle = search_base;
672
673
674 ACPI_FUNCTION_TRACE ("ns_dump_tables");
675 668
669 ACPI_FUNCTION_TRACE("ns_dump_tables");
676 670
677 if (!acpi_gbl_root_node) { 671 if (!acpi_gbl_root_node) {
678 /* 672 /*
679 * If the name space has not been initialized, 673 * If the name space has not been initialized,
680 * there is nothing to dump. 674 * there is nothing to dump.
681 */ 675 */
682 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); 676 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
677 "namespace not initialized!\n"));
683 return_VOID; 678 return_VOID;
684 } 679 }
685 680
@@ -687,12 +682,12 @@ acpi_ns_dump_tables (
687 /* Entire namespace */ 682 /* Entire namespace */
688 683
689 search_handle = acpi_gbl_root_node; 684 search_handle = acpi_gbl_root_node;
690 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); 685 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
691 } 686 }
692 687
693 acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, 688 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
694 ACPI_UINT32_MAX, search_handle); 689 ACPI_OWNER_ID_MAX, search_handle);
695 return_VOID; 690 return_VOID;
696} 691}
697#endif /* _ACPI_ASL_COMPILER */ 692#endif /* _ACPI_ASL_COMPILER */
698#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ 693#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index 27c4f7cd2a43..55de883943d6 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -41,20 +41,15 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46 45
47
48/* TBD: This entire module is apparently obsolete and should be removed */ 46/* TBD: This entire module is apparently obsolete and should be removed */
49 47
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdumpdv") 49ACPI_MODULE_NAME("nsdumpdv")
52
53#ifdef ACPI_OBSOLETE_FUNCTIONS 50#ifdef ACPI_OBSOLETE_FUNCTIONS
54#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
55
56#include <acpi/acnamesp.h> 52#include <acpi/acnamesp.h>
57
58/******************************************************************************* 53/*******************************************************************************
59 * 54 *
60 * FUNCTION: acpi_ns_dump_one_device 55 * FUNCTION: acpi_ns_dump_one_device
@@ -70,44 +65,39 @@
70 * This procedure is a user_function called by acpi_ns_walk_namespace. 65 * This procedure is a user_function called by acpi_ns_walk_namespace.
71 * 66 *
72 ******************************************************************************/ 67 ******************************************************************************/
73
74static acpi_status 68static acpi_status
75acpi_ns_dump_one_device ( 69acpi_ns_dump_one_device(acpi_handle obj_handle,
76 acpi_handle obj_handle, 70 u32 level, void *context, void **return_value)
77 u32 level,
78 void *context,
79 void **return_value)
80{ 71{
81 struct acpi_buffer buffer; 72 struct acpi_buffer buffer;
82 struct acpi_device_info *info; 73 struct acpi_device_info *info;
83 acpi_status status; 74 acpi_status status;
84 u32 i; 75 u32 i;
85
86 76
87 ACPI_FUNCTION_NAME ("ns_dump_one_device"); 77 ACPI_FUNCTION_NAME("ns_dump_one_device");
88 78
89 79 status =
90 status = acpi_ns_dump_one_object (obj_handle, level, context, return_value); 80 acpi_ns_dump_one_object(obj_handle, level, context, return_value);
91 81
92 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 82 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
93 status = acpi_get_object_info (obj_handle, &buffer); 83 status = acpi_get_object_info(obj_handle, &buffer);
94 if (ACPI_SUCCESS (status)) { 84 if (ACPI_SUCCESS(status)) {
95 info = buffer.pointer; 85 info = buffer.pointer;
96 for (i = 0; i < level; i++) { 86 for (i = 0; i < level; i++) {
97 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); 87 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " "));
98 } 88 }
99 89
100 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, 90 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES,
101 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 91 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
102 info->hardware_id.value, ACPI_FORMAT_UINT64 (info->address), 92 info->hardware_id.value,
103 info->current_status)); 93 ACPI_FORMAT_UINT64(info->address),
104 ACPI_MEM_FREE (info); 94 info->current_status));
95 ACPI_MEM_FREE(info);
105 } 96 }
106 97
107 return (status); 98 return (status);
108} 99}
109 100
110
111/******************************************************************************* 101/*******************************************************************************
112 * 102 *
113 * FUNCTION: acpi_ns_dump_root_devices 103 * FUNCTION: acpi_ns_dump_root_devices
@@ -120,16 +110,12 @@ acpi_ns_dump_one_device (
120 * 110 *
121 ******************************************************************************/ 111 ******************************************************************************/
122 112
123void 113void acpi_ns_dump_root_devices(void)
124acpi_ns_dump_root_devices (
125 void)
126{ 114{
127 acpi_handle sys_bus_handle; 115 acpi_handle sys_bus_handle;
128 acpi_status status; 116 acpi_status status;
129
130
131 ACPI_FUNCTION_NAME ("ns_dump_root_devices");
132 117
118 ACPI_FUNCTION_NAME("ns_dump_root_devices");
133 119
134 /* Only dump the table if tracing is enabled */ 120 /* Only dump the table if tracing is enabled */
135 121
@@ -138,19 +124,17 @@ acpi_ns_dump_root_devices (
138 } 124 }
139 125
140 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle); 126 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
141 if (ACPI_FAILURE (status)) { 127 if (ACPI_FAILURE(status)) {
142 return; 128 return;
143 } 129 }
144 130
145 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 131 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
146 "Display of all devices in the namespace:\n")); 132 "Display of all devices in the namespace:\n"));
147 133
148 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, 134 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle,
149 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, 135 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
150 acpi_ns_dump_one_device, NULL, NULL); 136 acpi_ns_dump_one_device, NULL, NULL);
151} 137}
152 138
153#endif 139#endif
154#endif 140#endif
155
156
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 1ae89a1c8826..0191c7d92824 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -42,26 +42,19 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50 49
51
52#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nseval") 51ACPI_MODULE_NAME("nseval")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static acpi_status 54static acpi_status
58acpi_ns_execute_control_method ( 55acpi_ns_execute_control_method(struct acpi_parameter_info *info);
59 struct acpi_parameter_info *info);
60
61static acpi_status
62acpi_ns_get_object_value (
63 struct acpi_parameter_info *info);
64 56
57static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info);
65 58
66/******************************************************************************* 59/*******************************************************************************
67 * 60 *
@@ -85,48 +78,44 @@ acpi_ns_get_object_value (
85 ******************************************************************************/ 78 ******************************************************************************/
86 79
87acpi_status 80acpi_status
88acpi_ns_evaluate_relative ( 81acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info)
89 char *pathname,
90 struct acpi_parameter_info *info)
91{ 82{
92 acpi_status status; 83 acpi_status status;
93 struct acpi_namespace_node *node = NULL; 84 struct acpi_namespace_node *node = NULL;
94 union acpi_generic_state *scope_info; 85 union acpi_generic_state *scope_info;
95 char *internal_path = NULL; 86 char *internal_path = NULL;
96
97
98 ACPI_FUNCTION_TRACE ("ns_evaluate_relative");
99 87
88 ACPI_FUNCTION_TRACE("ns_evaluate_relative");
100 89
101 /* 90 /*
102 * Must have a valid object handle 91 * Must have a valid object handle
103 */ 92 */
104 if (!info || !info->node) { 93 if (!info || !info->node) {
105 return_ACPI_STATUS (AE_BAD_PARAMETER); 94 return_ACPI_STATUS(AE_BAD_PARAMETER);
106 } 95 }
107 96
108 /* Build an internal name string for the method */ 97 /* Build an internal name string for the method */
109 98
110 status = acpi_ns_internalize_name (pathname, &internal_path); 99 status = acpi_ns_internalize_name(pathname, &internal_path);
111 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
113 } 102 }
114 103
115 scope_info = acpi_ut_create_generic_state (); 104 scope_info = acpi_ut_create_generic_state();
116 if (!scope_info) { 105 if (!scope_info) {
117 goto cleanup1; 106 goto cleanup1;
118 } 107 }
119 108
120 /* Get the prefix handle and Node */ 109 /* Get the prefix handle and Node */
121 110
122 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 111 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE(status)) {
124 goto cleanup; 113 goto cleanup;
125 } 114 }
126 115
127 info->node = acpi_ns_map_handle_to_node (info->node); 116 info->node = acpi_ns_map_handle_to_node(info->node);
128 if (!info->node) { 117 if (!info->node) {
129 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 118 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
130 status = AE_BAD_PARAMETER; 119 status = AE_BAD_PARAMETER;
131 goto cleanup; 120 goto cleanup;
132 } 121 }
@@ -134,39 +123,38 @@ acpi_ns_evaluate_relative (
134 /* Lookup the name in the namespace */ 123 /* Lookup the name in the namespace */
135 124
136 scope_info->scope.node = info->node; 125 scope_info->scope.node = info->node;
137 status = acpi_ns_lookup (scope_info, internal_path, ACPI_TYPE_ANY, 126 status = acpi_ns_lookup(scope_info, internal_path, ACPI_TYPE_ANY,
138 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 127 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
139 &node); 128 &node);
140 129
141 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 130 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
142 131
143 if (ACPI_FAILURE (status)) { 132 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", 133 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object [%s] not found [%s]\n",
145 pathname, acpi_format_exception (status))); 134 pathname, acpi_format_exception(status)));
146 goto cleanup; 135 goto cleanup;
147 } 136 }
148 137
149 /* 138 /*
150 * Now that we have a handle to the object, we can attempt to evaluate it. 139 * Now that we have a handle to the object, we can attempt to evaluate it.
151 */ 140 */
152 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 141 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
153 pathname, node, acpi_ns_get_attached_object (node))); 142 pathname, node, acpi_ns_get_attached_object(node)));
154 143
155 info->node = node; 144 info->node = node;
156 status = acpi_ns_evaluate_by_handle (info); 145 status = acpi_ns_evaluate_by_handle(info);
157 146
158 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
159 pathname)); 148 "*** Completed eval of object %s ***\n", pathname));
160 149
161cleanup: 150 cleanup:
162 acpi_ut_delete_generic_state (scope_info); 151 acpi_ut_delete_generic_state(scope_info);
163 152
164cleanup1: 153 cleanup1:
165 ACPI_MEM_FREE (internal_path); 154 ACPI_MEM_FREE(internal_path);
166 return_ACPI_STATUS (status); 155 return_ACPI_STATUS(status);
167} 156}
168 157
169
170/******************************************************************************* 158/*******************************************************************************
171 * 159 *
172 * FUNCTION: acpi_ns_evaluate_by_name 160 * FUNCTION: acpi_ns_evaluate_by_name
@@ -189,68 +177,63 @@ cleanup1:
189 ******************************************************************************/ 177 ******************************************************************************/
190 178
191acpi_status 179acpi_status
192acpi_ns_evaluate_by_name ( 180acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info)
193 char *pathname,
194 struct acpi_parameter_info *info)
195{ 181{
196 acpi_status status; 182 acpi_status status;
197 char *internal_path = NULL; 183 char *internal_path = NULL;
198
199
200 ACPI_FUNCTION_TRACE ("ns_evaluate_by_name");
201 184
185 ACPI_FUNCTION_TRACE("ns_evaluate_by_name");
202 186
203 /* Build an internal name string for the method */ 187 /* Build an internal name string for the method */
204 188
205 status = acpi_ns_internalize_name (pathname, &internal_path); 189 status = acpi_ns_internalize_name(pathname, &internal_path);
206 if (ACPI_FAILURE (status)) { 190 if (ACPI_FAILURE(status)) {
207 return_ACPI_STATUS (status); 191 return_ACPI_STATUS(status);
208 } 192 }
209 193
210 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 194 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
211 if (ACPI_FAILURE (status)) { 195 if (ACPI_FAILURE(status)) {
212 goto cleanup; 196 goto cleanup;
213 } 197 }
214 198
215 /* Lookup the name in the namespace */ 199 /* Lookup the name in the namespace */
216 200
217 status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, 201 status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY,
218 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 202 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
219 &info->node); 203 &info->node);
220 204
221 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 205 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
222 206
223 if (ACPI_FAILURE (status)) { 207 if (ACPI_FAILURE(status)) {
224 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 208 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
225 "Object at [%s] was not found, status=%.4X\n", 209 "Object at [%s] was not found, status=%.4X\n",
226 pathname, status)); 210 pathname, status));
227 goto cleanup; 211 goto cleanup;
228 } 212 }
229 213
230 /* 214 /*
231 * Now that we have a handle to the object, we can attempt to evaluate it. 215 * Now that we have a handle to the object, we can attempt to evaluate it.
232 */ 216 */
233 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 217 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
234 pathname, info->node, acpi_ns_get_attached_object (info->node))); 218 pathname, info->node,
235 219 acpi_ns_get_attached_object(info->node)));
236 status = acpi_ns_evaluate_by_handle (info);
237 220
238 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 221 status = acpi_ns_evaluate_by_handle(info);
239 pathname));
240 222
223 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
224 "*** Completed eval of object %s ***\n", pathname));
241 225
242cleanup: 226 cleanup:
243 227
244 /* Cleanup */ 228 /* Cleanup */
245 229
246 if (internal_path) { 230 if (internal_path) {
247 ACPI_MEM_FREE (internal_path); 231 ACPI_MEM_FREE(internal_path);
248 } 232 }
249 233
250 return_ACPI_STATUS (status); 234 return_ACPI_STATUS(status);
251} 235}
252 236
253
254/******************************************************************************* 237/*******************************************************************************
255 * 238 *
256 * FUNCTION: acpi_ns_evaluate_by_handle 239 * FUNCTION: acpi_ns_evaluate_by_handle
@@ -275,26 +258,22 @@ cleanup:
275 * 258 *
276 ******************************************************************************/ 259 ******************************************************************************/
277 260
278acpi_status 261acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info)
279acpi_ns_evaluate_by_handle (
280 struct acpi_parameter_info *info)
281{ 262{
282 acpi_status status; 263 acpi_status status;
283
284
285 ACPI_FUNCTION_TRACE ("ns_evaluate_by_handle");
286 264
265 ACPI_FUNCTION_TRACE("ns_evaluate_by_handle");
287 266
288 /* Check if namespace has been initialized */ 267 /* Check if namespace has been initialized */
289 268
290 if (!acpi_gbl_root_node) { 269 if (!acpi_gbl_root_node) {
291 return_ACPI_STATUS (AE_NO_NAMESPACE); 270 return_ACPI_STATUS(AE_NO_NAMESPACE);
292 } 271 }
293 272
294 /* Parameter Validation */ 273 /* Parameter Validation */
295 274
296 if (!info) { 275 if (!info) {
297 return_ACPI_STATUS (AE_BAD_PARAMETER); 276 return_ACPI_STATUS(AE_BAD_PARAMETER);
298 } 277 }
299 278
300 /* Initialize the return value to an invalid object */ 279 /* Initialize the return value to an invalid object */
@@ -303,23 +282,25 @@ acpi_ns_evaluate_by_handle (
303 282
304 /* Get the prefix handle and Node */ 283 /* Get the prefix handle and Node */
305 284
306 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 285 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
307 if (ACPI_FAILURE (status)) { 286 if (ACPI_FAILURE(status)) {
308 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
309 } 288 }
310 289
311 info->node = acpi_ns_map_handle_to_node (info->node); 290 info->node = acpi_ns_map_handle_to_node(info->node);
312 if (!info->node) { 291 if (!info->node) {
313 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 292 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
314 return_ACPI_STATUS (AE_BAD_PARAMETER); 293 return_ACPI_STATUS(AE_BAD_PARAMETER);
315 } 294 }
316 295
317 /* 296 /*
318 * For a method alias, we must grab the actual method node so that proper 297 * For a method alias, we must grab the actual method node so that proper
319 * scoping context will be established before execution. 298 * scoping context will be established before execution.
320 */ 299 */
321 if (acpi_ns_get_type (info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { 300 if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
322 info->node = ACPI_CAST_PTR (struct acpi_namespace_node, info->node->object); 301 info->node =
302 ACPI_CAST_PTR(struct acpi_namespace_node,
303 info->node->object);
323 } 304 }
324 305
325 /* 306 /*
@@ -329,17 +310,16 @@ acpi_ns_evaluate_by_handle (
329 * 310 *
330 * In both cases, the namespace is unlocked by the acpi_ns* procedure 311 * In both cases, the namespace is unlocked by the acpi_ns* procedure
331 */ 312 */
332 if (acpi_ns_get_type (info->node) == ACPI_TYPE_METHOD) { 313 if (acpi_ns_get_type(info->node) == ACPI_TYPE_METHOD) {
333 /* 314 /*
334 * Case 1) We have an actual control method to execute 315 * Case 1) We have an actual control method to execute
335 */ 316 */
336 status = acpi_ns_execute_control_method (info); 317 status = acpi_ns_execute_control_method(info);
337 } 318 } else {
338 else {
339 /* 319 /*
340 * Case 2) Object is NOT a method, just return its current value 320 * Case 2) Object is NOT a method, just return its current value
341 */ 321 */
342 status = acpi_ns_get_object_value (info); 322 status = acpi_ns_get_object_value(info);
343 } 323 }
344 324
345 /* 325 /*
@@ -355,16 +335,16 @@ acpi_ns_evaluate_by_handle (
355 * Namespace was unlocked by the handling acpi_ns* function, so we 335 * Namespace was unlocked by the handling acpi_ns* function, so we
356 * just return 336 * just return
357 */ 337 */
358 return_ACPI_STATUS (status); 338 return_ACPI_STATUS(status);
359} 339}
360 340
361
362/******************************************************************************* 341/*******************************************************************************
363 * 342 *
364 * FUNCTION: acpi_ns_execute_control_method 343 * FUNCTION: acpi_ns_execute_control_method
365 * 344 *
366 * PARAMETERS: Info - Method info block, contains: 345 * PARAMETERS: Info - Method info block, contains:
367 * Node - Method Node to execute 346 * Node - Method Node to execute
347 * obj_desc - Method object
368 * Parameters - List of parameters to pass to the method, 348 * Parameters - List of parameters to pass to the method,
369 * terminated by NULL. Params itself may be 349 * terminated by NULL. Params itself may be
370 * NULL if no parameters are being passed. 350 * NULL if no parameters are being passed.
@@ -383,31 +363,29 @@ acpi_ns_evaluate_by_handle (
383 ******************************************************************************/ 363 ******************************************************************************/
384 364
385static acpi_status 365static acpi_status
386acpi_ns_execute_control_method ( 366acpi_ns_execute_control_method(struct acpi_parameter_info *info)
387 struct acpi_parameter_info *info)
388{ 367{
389 acpi_status status; 368 acpi_status status;
390 union acpi_operand_object *obj_desc;
391
392
393 ACPI_FUNCTION_TRACE ("ns_execute_control_method");
394 369
370 ACPI_FUNCTION_TRACE("ns_execute_control_method");
395 371
396 /* Verify that there is a method associated with this object */ 372 /* Verify that there is a method associated with this object */
397 373
398 obj_desc = acpi_ns_get_attached_object (info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
399 if (!obj_desc) { 375 if (!info->obj_desc) {
400 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); 376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
377 "No attached method object\n"));
401 378
402 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
403 return_ACPI_STATUS (AE_NULL_OBJECT); 380 return_ACPI_STATUS(AE_NULL_OBJECT);
404 } 381 }
405 382
406 ACPI_DUMP_PATHNAME (info->node, "Execute Method:", 383 ACPI_DUMP_PATHNAME(info->node, "Execute Method:",
407 ACPI_LV_INFO, _COMPONENT); 384 ACPI_LV_INFO, _COMPONENT);
408 385
409 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", 386 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
410 obj_desc->method.aml_start + 1, obj_desc->method.aml_length - 1)); 387 info->obj_desc->method.aml_start + 1,
388 info->obj_desc->method.aml_length - 1));
411 389
412 /* 390 /*
413 * Unlock the namespace before execution. This allows namespace access 391 * Unlock the namespace before execution. This allows namespace access
@@ -416,27 +394,26 @@ acpi_ns_execute_control_method (
416 * interpreter locks to ensure that no thread is using the portion of the 394 * interpreter locks to ensure that no thread is using the portion of the
417 * namespace that is being deleted. 395 * namespace that is being deleted.
418 */ 396 */
419 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 397 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
420 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
421 return_ACPI_STATUS (status); 399 return_ACPI_STATUS(status);
422 } 400 }
423 401
424 /* 402 /*
425 * Execute the method via the interpreter. The interpreter is locked 403 * Execute the method via the interpreter. The interpreter is locked
426 * here before calling into the AML parser 404 * here before calling into the AML parser
427 */ 405 */
428 status = acpi_ex_enter_interpreter (); 406 status = acpi_ex_enter_interpreter();
429 if (ACPI_FAILURE (status)) { 407 if (ACPI_FAILURE(status)) {
430 return_ACPI_STATUS (status); 408 return_ACPI_STATUS(status);
431 } 409 }
432 410
433 status = acpi_psx_execute (info); 411 status = acpi_ps_execute_method(info);
434 acpi_ex_exit_interpreter (); 412 acpi_ex_exit_interpreter();
435 413
436 return_ACPI_STATUS (status); 414 return_ACPI_STATUS(status);
437} 415}
438 416
439
440/******************************************************************************* 417/*******************************************************************************
441 * 418 *
442 * FUNCTION: acpi_ns_get_object_value 419 * FUNCTION: acpi_ns_get_object_value
@@ -454,16 +431,12 @@ acpi_ns_execute_control_method (
454 * 431 *
455 ******************************************************************************/ 432 ******************************************************************************/
456 433
457static acpi_status 434static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info)
458acpi_ns_get_object_value (
459 struct acpi_parameter_info *info)
460{ 435{
461 acpi_status status = AE_OK; 436 acpi_status status = AE_OK;
462 struct acpi_namespace_node *resolved_node = info->node; 437 struct acpi_namespace_node *resolved_node = info->node;
463
464
465 ACPI_FUNCTION_TRACE ("ns_get_object_value");
466 438
439 ACPI_FUNCTION_TRACE("ns_get_object_value");
467 440
468 /* 441 /*
469 * Objects require additional resolution steps (e.g., the Node may be a 442 * Objects require additional resolution steps (e.g., the Node may be a
@@ -486,32 +459,33 @@ acpi_ns_get_object_value (
486 * 459 *
487 * We must release the namespace lock before entering the intepreter. 460 * We must release the namespace lock before entering the intepreter.
488 */ 461 */
489 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 462 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
490 if (ACPI_FAILURE (status)) { 463 if (ACPI_FAILURE(status)) {
491 return_ACPI_STATUS (status); 464 return_ACPI_STATUS(status);
492 } 465 }
493 466
494 status = acpi_ex_enter_interpreter (); 467 status = acpi_ex_enter_interpreter();
495 if (ACPI_SUCCESS (status)) { 468 if (ACPI_SUCCESS(status)) {
496 status = acpi_ex_resolve_node_to_value (&resolved_node, NULL); 469 status = acpi_ex_resolve_node_to_value(&resolved_node, NULL);
497 /* 470 /*
498 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed 471 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed
499 * in resolved_node. 472 * in resolved_node.
500 */ 473 */
501 acpi_ex_exit_interpreter (); 474 acpi_ex_exit_interpreter();
502 475
503 if (ACPI_SUCCESS (status)) { 476 if (ACPI_SUCCESS(status)) {
504 status = AE_CTRL_RETURN_VALUE; 477 status = AE_CTRL_RETURN_VALUE;
505 info->return_object = ACPI_CAST_PTR 478 info->return_object = ACPI_CAST_PTR
506 (union acpi_operand_object, resolved_node); 479 (union acpi_operand_object, resolved_node);
507 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 480 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
508 info->return_object, 481 "Returning object %p [%s]\n",
509 acpi_ut_get_object_type_name (info->return_object))); 482 info->return_object,
483 acpi_ut_get_object_type_name(info->
484 return_object)));
510 } 485 }
511 } 486 }
512 487
513 /* Namespace is unlocked */ 488 /* Namespace is unlocked */
514 489
515 return_ACPI_STATUS (status); 490 return_ACPI_STATUS(status);
516} 491}
517
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 362802ae29a2..0a08d2f04a06 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -41,31 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsinit") 50ACPI_MODULE_NAME("nsinit")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static acpi_status 53static acpi_status
56acpi_ns_init_one_object ( 54acpi_ns_init_one_object(acpi_handle obj_handle,
57 acpi_handle obj_handle, 55 u32 level, void *context, void **return_value);
58 u32 level,
59 void *context,
60 void **return_value);
61 56
62static acpi_status 57static acpi_status
63acpi_ns_init_one_device ( 58acpi_ns_init_one_device(acpi_handle obj_handle,
64 acpi_handle obj_handle, 59 u32 nesting_level, void *context, void **return_value);
65 u32 nesting_level,
66 void *context,
67 void **return_value);
68
69 60
70/******************************************************************************* 61/*******************************************************************************
71 * 62 *
@@ -80,52 +71,48 @@ acpi_ns_init_one_device (
80 * 71 *
81 ******************************************************************************/ 72 ******************************************************************************/
82 73
83acpi_status 74acpi_status acpi_ns_initialize_objects(void)
84acpi_ns_initialize_objects (
85 void)
86{ 75{
87 acpi_status status; 76 acpi_status status;
88 struct acpi_init_walk_info info; 77 struct acpi_init_walk_info info;
89
90 78
91 ACPI_FUNCTION_TRACE ("ns_initialize_objects"); 79 ACPI_FUNCTION_TRACE("ns_initialize_objects");
92 80
93 81 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
94 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 82 "**** Starting initialization of namespace objects ****\n"));
95 "**** Starting initialization of namespace objects ****\n")); 83 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
96 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 84 "Completing Region/Field/Buffer/Package initialization:"));
97 "Completing Region/Field/Buffer/Package initialization:"));
98 85
99 /* Set all init info to zero */ 86 /* Set all init info to zero */
100 87
101 ACPI_MEMSET (&info, 0, sizeof (struct acpi_init_walk_info)); 88 ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
102 89
103 /* Walk entire namespace from the supplied root */ 90 /* Walk entire namespace from the supplied root */
104 91
105 status = acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 92 status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
106 ACPI_UINT32_MAX, acpi_ns_init_one_object, 93 ACPI_UINT32_MAX, acpi_ns_init_one_object,
107 &info, NULL); 94 &info, NULL);
108 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE(status)) {
109 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 96 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
110 acpi_format_exception (status))); 97 acpi_format_exception(status)));
111 } 98 }
112 99
113 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 100 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
114 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", 101 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n",
115 info.op_region_init, info.op_region_count, 102 info.op_region_init, info.op_region_count,
116 info.field_init, info.field_count, 103 info.field_init, info.field_count,
117 info.buffer_init, info.buffer_count, 104 info.buffer_init, info.buffer_count,
118 info.package_init, info.package_count, info.object_count)); 105 info.package_init, info.package_count,
106 info.object_count));
119 107
120 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 108 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
121 "%hd Control Methods found\n", info.method_count)); 109 "%hd Control Methods found\n", info.method_count));
122 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 110 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
123 "%hd Op Regions found\n", info.op_region_count)); 111 "%hd Op Regions found\n", info.op_region_count));
124 112
125 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
126} 114}
127 115
128
129/******************************************************************************* 116/*******************************************************************************
130 * 117 *
131 * FUNCTION: acpi_ns_initialize_devices 118 * FUNCTION: acpi_ns_initialize_devices
@@ -142,16 +129,12 @@ acpi_ns_initialize_objects (
142 * 129 *
143 ******************************************************************************/ 130 ******************************************************************************/
144 131
145acpi_status 132acpi_status acpi_ns_initialize_devices(void)
146acpi_ns_initialize_devices (
147 void)
148{ 133{
149 acpi_status status; 134 acpi_status status;
150 struct acpi_device_walk_info info; 135 struct acpi_device_walk_info info;
151
152
153 ACPI_FUNCTION_TRACE ("ns_initialize_devices");
154 136
137 ACPI_FUNCTION_TRACE("ns_initialize_devices");
155 138
156 /* Init counters */ 139 /* Init counters */
157 140
@@ -159,34 +142,34 @@ acpi_ns_initialize_devices (
159 info.num_STA = 0; 142 info.num_STA = 0;
160 info.num_INI = 0; 143 info.num_INI = 0;
161 144
162 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 145 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
163 "Executing all Device _STA and_INI methods:")); 146 "Executing all Device _STA and_INI methods:"));
164 147
165 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 148 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
166 if (ACPI_FAILURE (status)) { 149 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS (status); 150 return_ACPI_STATUS(status);
168 } 151 }
169 152
170 /* Walk namespace for all objects */ 153 /* Walk namespace for all objects */
171 154
172 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 155 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
173 ACPI_UINT32_MAX, TRUE, acpi_ns_init_one_device, &info, NULL); 156 ACPI_UINT32_MAX, TRUE,
157 acpi_ns_init_one_device, &info, NULL);
174 158
175 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 159 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
176 160
177 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
178 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
179 acpi_format_exception (status))); 163 acpi_format_exception(status)));
180 } 164 }
181 165
182 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 166 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
183 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", 167 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n",
184 info.device_count, info.num_STA, info.num_INI)); 168 info.device_count, info.num_STA, info.num_INI));
185 169
186 return_ACPI_STATUS (status); 170 return_ACPI_STATUS(status);
187} 171}
188 172
189
190/******************************************************************************* 173/*******************************************************************************
191 * 174 *
192 * FUNCTION: acpi_ns_init_one_object 175 * FUNCTION: acpi_ns_init_one_object
@@ -208,28 +191,25 @@ acpi_ns_initialize_devices (
208 ******************************************************************************/ 191 ******************************************************************************/
209 192
210static acpi_status 193static acpi_status
211acpi_ns_init_one_object ( 194acpi_ns_init_one_object(acpi_handle obj_handle,
212 acpi_handle obj_handle, 195 u32 level, void *context, void **return_value)
213 u32 level,
214 void *context,
215 void **return_value)
216{ 196{
217 acpi_object_type type; 197 acpi_object_type type;
218 acpi_status status; 198 acpi_status status;
219 struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; 199 struct acpi_init_walk_info *info =
220 struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; 200 (struct acpi_init_walk_info *)context;
221 union acpi_operand_object *obj_desc; 201 struct acpi_namespace_node *node =
222 202 (struct acpi_namespace_node *)obj_handle;
223 203 union acpi_operand_object *obj_desc;
224 ACPI_FUNCTION_NAME ("ns_init_one_object");
225 204
205 ACPI_FUNCTION_NAME("ns_init_one_object");
226 206
227 info->object_count++; 207 info->object_count++;
228 208
229 /* And even then, we are only interested in a few object types */ 209 /* And even then, we are only interested in a few object types */
230 210
231 type = acpi_ns_get_type (obj_handle); 211 type = acpi_ns_get_type(obj_handle);
232 obj_desc = acpi_ns_get_attached_object (node); 212 obj_desc = acpi_ns_get_attached_object(node);
233 if (!obj_desc) { 213 if (!obj_desc) {
234 return (AE_OK); 214 return (AE_OK);
235 } 215 }
@@ -269,8 +249,8 @@ acpi_ns_init_one_object (
269 /* 249 /*
270 * Must lock the interpreter before executing AML code 250 * Must lock the interpreter before executing AML code
271 */ 251 */
272 status = acpi_ex_enter_interpreter (); 252 status = acpi_ex_enter_interpreter();
273 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
274 return (status); 254 return (status);
275 } 255 }
276 256
@@ -282,25 +262,25 @@ acpi_ns_init_one_object (
282 case ACPI_TYPE_REGION: 262 case ACPI_TYPE_REGION:
283 263
284 info->op_region_init++; 264 info->op_region_init++;
285 status = acpi_ds_get_region_arguments (obj_desc); 265 status = acpi_ds_get_region_arguments(obj_desc);
286 break; 266 break;
287 267
288 case ACPI_TYPE_BUFFER_FIELD: 268 case ACPI_TYPE_BUFFER_FIELD:
289 269
290 info->field_init++; 270 info->field_init++;
291 status = acpi_ds_get_buffer_field_arguments (obj_desc); 271 status = acpi_ds_get_buffer_field_arguments(obj_desc);
292 break; 272 break;
293 273
294 case ACPI_TYPE_BUFFER: 274 case ACPI_TYPE_BUFFER:
295 275
296 info->buffer_init++; 276 info->buffer_init++;
297 status = acpi_ds_get_buffer_arguments (obj_desc); 277 status = acpi_ds_get_buffer_arguments(obj_desc);
298 break; 278 break;
299 279
300 case ACPI_TYPE_PACKAGE: 280 case ACPI_TYPE_PACKAGE:
301 281
302 info->package_init++; 282 info->package_init++;
303 status = acpi_ds_get_package_arguments (obj_desc); 283 status = acpi_ds_get_package_arguments(obj_desc);
304 break; 284 break;
305 285
306 default: 286 default:
@@ -308,12 +288,13 @@ acpi_ns_init_one_object (
308 break; 288 break;
309 } 289 }
310 290
311 if (ACPI_FAILURE (status)) { 291 if (ACPI_FAILURE(status)) {
312 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n")); 292 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n"));
313 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
314 "Could not execute arguments for [%4.4s] (%s), %s\n", 294 "Could not execute arguments for [%4.4s] (%s), %s\n",
315 acpi_ut_get_node_name (node), acpi_ut_get_type_name (type), 295 acpi_ut_get_node_name(node),
316 acpi_format_exception (status))); 296 acpi_ut_get_type_name(type),
297 acpi_format_exception(status)));
317 } 298 }
318 299
319 /* 300 /*
@@ -321,18 +302,17 @@ acpi_ns_init_one_object (
321 * pathname 302 * pathname
322 */ 303 */
323 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 304 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
324 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 305 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
325 } 306 }
326 307
327 /* 308 /*
328 * We ignore errors from above, and always return OK, since we don't want 309 * We ignore errors from above, and always return OK, since we don't want
329 * to abort the walk on any single error. 310 * to abort the walk on any single error.
330 */ 311 */
331 acpi_ex_exit_interpreter (); 312 acpi_ex_exit_interpreter();
332 return (AE_OK); 313 return (AE_OK);
333} 314}
334 315
335
336/******************************************************************************* 316/*******************************************************************************
337 * 317 *
338 * FUNCTION: acpi_ns_init_one_device 318 * FUNCTION: acpi_ns_init_one_device
@@ -348,41 +328,37 @@ acpi_ns_init_one_object (
348 ******************************************************************************/ 328 ******************************************************************************/
349 329
350static acpi_status 330static acpi_status
351acpi_ns_init_one_device ( 331acpi_ns_init_one_device(acpi_handle obj_handle,
352 acpi_handle obj_handle, 332 u32 nesting_level, void *context, void **return_value)
353 u32 nesting_level,
354 void *context,
355 void **return_value)
356{ 333{
357 struct acpi_device_walk_info *info = (struct acpi_device_walk_info *) context; 334 struct acpi_device_walk_info *info =
358 struct acpi_parameter_info pinfo; 335 (struct acpi_device_walk_info *)context;
359 u32 flags; 336 struct acpi_parameter_info pinfo;
360 acpi_status status; 337 u32 flags;
361 338 acpi_status status;
362
363 ACPI_FUNCTION_TRACE ("ns_init_one_device");
364 339
340 ACPI_FUNCTION_TRACE("ns_init_one_device");
365 341
366 pinfo.parameters = NULL; 342 pinfo.parameters = NULL;
367 pinfo.parameter_type = ACPI_PARAM_ARGS; 343 pinfo.parameter_type = ACPI_PARAM_ARGS;
368 344
369 pinfo.node = acpi_ns_map_handle_to_node (obj_handle); 345 pinfo.node = acpi_ns_map_handle_to_node(obj_handle);
370 if (!pinfo.node) { 346 if (!pinfo.node) {
371 return_ACPI_STATUS (AE_BAD_PARAMETER); 347 return_ACPI_STATUS(AE_BAD_PARAMETER);
372 } 348 }
373 349
374 /* 350 /*
375 * We will run _STA/_INI on Devices, Processors and thermal_zones only 351 * We will run _STA/_INI on Devices, Processors and thermal_zones only
376 */ 352 */
377 if ((pinfo.node->type != ACPI_TYPE_DEVICE) && 353 if ((pinfo.node->type != ACPI_TYPE_DEVICE) &&
378 (pinfo.node->type != ACPI_TYPE_PROCESSOR) && 354 (pinfo.node->type != ACPI_TYPE_PROCESSOR) &&
379 (pinfo.node->type != ACPI_TYPE_THERMAL)) { 355 (pinfo.node->type != ACPI_TYPE_THERMAL)) {
380 return_ACPI_STATUS (AE_OK); 356 return_ACPI_STATUS(AE_OK);
381 } 357 }
382 358
383 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && 359 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
384 (!(acpi_dbg_level & ACPI_LV_INFO))) { 360 (!(acpi_dbg_level & ACPI_LV_INFO))) {
385 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 361 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
386 } 362 }
387 363
388 info->device_count++; 364 info->device_count++;
@@ -390,20 +366,20 @@ acpi_ns_init_one_device (
390 /* 366 /*
391 * Run _STA to determine if we can run _INI on the device. 367 * Run _STA to determine if we can run _INI on the device.
392 */ 368 */
393 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 369 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
394 pinfo.node, METHOD_NAME__STA)); 370 pinfo.node,
395 status = acpi_ut_execute_STA (pinfo.node, &flags); 371 METHOD_NAME__STA));
372 status = acpi_ut_execute_STA(pinfo.node, &flags);
396 373
397 if (ACPI_FAILURE (status)) { 374 if (ACPI_FAILURE(status)) {
398 if (pinfo.node->type == ACPI_TYPE_DEVICE) { 375 if (pinfo.node->type == ACPI_TYPE_DEVICE) {
399 /* Ignore error and move on to next device */ 376 /* Ignore error and move on to next device */
400 377
401 return_ACPI_STATUS (AE_OK); 378 return_ACPI_STATUS(AE_OK);
402 } 379 }
403 380
404 /* _STA is not required for Processor or thermal_zone objects */ 381 /* _STA is not required for Processor or thermal_zone objects */
405 } 382 } else {
406 else {
407 info->num_STA++; 383 info->num_STA++;
408 384
409 if (!(flags & 0x01)) { 385 if (!(flags & 0x01)) {
@@ -416,32 +392,34 @@ acpi_ns_init_one_device (
416 /* 392 /*
417 * The device is present. Run _INI. 393 * The device is present. Run _INI.
418 */ 394 */
419 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 395 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
420 pinfo.node, METHOD_NAME__INI)); 396 pinfo.node,
421 status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo); 397 METHOD_NAME__INI));
422 if (ACPI_FAILURE (status)) { 398 status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo);
399 if (ACPI_FAILURE(status)) {
423 /* No _INI (AE_NOT_FOUND) means device requires no initialization */ 400 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
424 401
425 if (status != AE_NOT_FOUND) { 402 if (status != AE_NOT_FOUND) {
426 /* Ignore error and move on to next device */ 403 /* Ignore error and move on to next device */
427 404
428#ifdef ACPI_DEBUG_OUTPUT 405#ifdef ACPI_DEBUG_OUTPUT
429 char *scope_name = acpi_ns_get_external_pathname (pinfo.node); 406 char *scope_name =
407 acpi_ns_get_external_pathname(pinfo.node);
430 408
431 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", 409 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n",
432 scope_name, acpi_format_exception (status))); 410 scope_name,
411 acpi_format_exception(status)));
433 412
434 ACPI_MEM_FREE (scope_name); 413 ACPI_MEM_FREE(scope_name);
435#endif 414#endif
436 } 415 }
437 416
438 status = AE_OK; 417 status = AE_OK;
439 } 418 } else {
440 else {
441 /* Delete any return object (especially if implicit_return is enabled) */ 419 /* Delete any return object (especially if implicit_return is enabled) */
442 420
443 if (pinfo.return_object) { 421 if (pinfo.return_object) {
444 acpi_ut_remove_reference (pinfo.return_object); 422 acpi_ut_remove_reference(pinfo.return_object);
445 } 423 }
446 424
447 /* Count of successful INIs */ 425 /* Count of successful INIs */
@@ -452,8 +430,9 @@ acpi_ns_init_one_device (
452 if (acpi_gbl_init_handler) { 430 if (acpi_gbl_init_handler) {
453 /* External initialization handler is present, call it */ 431 /* External initialization handler is present, call it */
454 432
455 status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI); 433 status =
434 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI);
456 } 435 }
457 436
458 return_ACPI_STATUS (status); 437 return_ACPI_STATUS(status);
459} 438}
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index 34e497016601..c28849de465a 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -41,32 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsload") 49ACPI_MODULE_NAME("nsload")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54 52static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type);
55static acpi_status
56acpi_ns_load_table_by_type (
57 acpi_table_type table_type);
58 53
59#ifdef ACPI_FUTURE_IMPLEMENTATION 54#ifdef ACPI_FUTURE_IMPLEMENTATION
60acpi_status 55acpi_status acpi_ns_unload_namespace(acpi_handle handle);
61acpi_ns_unload_namespace (
62 acpi_handle handle);
63 56
64static acpi_status 57static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
65acpi_ns_delete_subtree (
66 acpi_handle start_handle);
67#endif 58#endif
68 59
69
70#ifndef ACPI_NO_METHOD_EXECUTION 60#ifndef ACPI_NO_METHOD_EXECUTION
71/******************************************************************************* 61/*******************************************************************************
72 * 62 *
@@ -82,40 +72,39 @@ acpi_ns_delete_subtree (
82 ******************************************************************************/ 72 ******************************************************************************/
83 73
84acpi_status 74acpi_status
85acpi_ns_load_table ( 75acpi_ns_load_table(struct acpi_table_desc *table_desc,
86 struct acpi_table_desc *table_desc, 76 struct acpi_namespace_node *node)
87 struct acpi_namespace_node *node)
88{ 77{
89 acpi_status status; 78 acpi_status status;
90
91
92 ACPI_FUNCTION_TRACE ("ns_load_table");
93 79
80 ACPI_FUNCTION_TRACE("ns_load_table");
94 81
95 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */ 82 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
96 83
97 if (!(acpi_gbl_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) { 84 if (!
85 (acpi_gbl_table_data[table_desc->type].
86 flags & ACPI_TABLE_EXECUTABLE)) {
98 /* Just ignore this table */ 87 /* Just ignore this table */
99 88
100 return_ACPI_STATUS (AE_OK); 89 return_ACPI_STATUS(AE_OK);
101 } 90 }
102 91
103 /* Check validity of the AML start and length */ 92 /* Check validity of the AML start and length */
104 93
105 if (!table_desc->aml_start) { 94 if (!table_desc->aml_start) {
106 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n")); 95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n"));
107 return_ACPI_STATUS (AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
108 } 97 }
109 98
110 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", 99 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AML block at %p\n",
111 table_desc->aml_start)); 100 table_desc->aml_start));
112 101
113 /* Ignore table if there is no AML contained within */ 102 /* Ignore table if there is no AML contained within */
114 103
115 if (!table_desc->aml_length) { 104 if (!table_desc->aml_length) {
116 ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", 105 ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n",
117 table_desc->pointer->signature)); 106 table_desc->pointer->signature));
118 return_ACPI_STATUS (AE_OK); 107 return_ACPI_STATUS(AE_OK);
119 } 108 }
120 109
121 /* 110 /*
@@ -127,19 +116,19 @@ acpi_ns_load_table (
127 * to another control method, we can't continue parsing 116 * to another control method, we can't continue parsing
128 * because we don't know how many arguments to parse next! 117 * because we don't know how many arguments to parse next!
129 */ 118 */
130 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 119 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
131 "**** Loading table into namespace ****\n")); 120 "**** Loading table into namespace ****\n"));
132 121
133 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 122 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
134 if (ACPI_FAILURE (status)) { 123 if (ACPI_FAILURE(status)) {
135 return_ACPI_STATUS (status); 124 return_ACPI_STATUS(status);
136 } 125 }
137 126
138 status = acpi_ns_parse_table (table_desc, node->child); 127 status = acpi_ns_parse_table(table_desc, node->child);
139 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 128 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
140 129
141 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
142 return_ACPI_STATUS (status); 131 return_ACPI_STATUS(status);
143 } 132 }
144 133
145 /* 134 /*
@@ -148,18 +137,17 @@ acpi_ns_load_table (
148 * just-in-time parsing, we delete the control method 137 * just-in-time parsing, we delete the control method
149 * parse trees. 138 * parse trees.
150 */ 139 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 140 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "**** Begin Table Method Parsing and Object Initialization ****\n")); 141 "**** Begin Table Method Parsing and Object Initialization ****\n"));
153 142
154 status = acpi_ds_initialize_objects (table_desc, node); 143 status = acpi_ds_initialize_objects(table_desc, node);
155 144
156 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 145 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
157 "**** Completed Table Method Parsing and Object Initialization ****\n")); 146 "**** Completed Table Method Parsing and Object Initialization ****\n"));
158 147
159 return_ACPI_STATUS (status); 148 return_ACPI_STATUS(status);
160} 149}
161 150
162
163/******************************************************************************* 151/*******************************************************************************
164 * 152 *
165 * FUNCTION: acpi_ns_load_table_by_type 153 * FUNCTION: acpi_ns_load_table_by_type
@@ -174,21 +162,17 @@ acpi_ns_load_table (
174 * 162 *
175 ******************************************************************************/ 163 ******************************************************************************/
176 164
177static acpi_status 165static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type)
178acpi_ns_load_table_by_type (
179 acpi_table_type table_type)
180{ 166{
181 u32 i; 167 u32 i;
182 acpi_status status; 168 acpi_status status;
183 struct acpi_table_desc *table_desc; 169 struct acpi_table_desc *table_desc;
184
185 170
186 ACPI_FUNCTION_TRACE ("ns_load_table_by_type"); 171 ACPI_FUNCTION_TRACE("ns_load_table_by_type");
187 172
188 173 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
189 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 174 if (ACPI_FAILURE(status)) {
190 if (ACPI_FAILURE (status)) { 175 return_ACPI_STATUS(status);
191 return_ACPI_STATUS (status);
192 } 176 }
193 177
194 /* 178 /*
@@ -198,7 +182,7 @@ acpi_ns_load_table_by_type (
198 switch (table_type) { 182 switch (table_type) {
199 case ACPI_TABLE_DSDT: 183 case ACPI_TABLE_DSDT:
200 184
201 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n")); 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace load: DSDT\n"));
202 186
203 table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next; 187 table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next;
204 188
@@ -210,57 +194,33 @@ acpi_ns_load_table_by_type (
210 194
211 /* Now load the single DSDT */ 195 /* Now load the single DSDT */
212 196
213 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); 197 status = acpi_ns_load_table(table_desc, acpi_gbl_root_node);
214 if (ACPI_SUCCESS (status)) { 198 if (ACPI_SUCCESS(status)) {
215 table_desc->loaded_into_namespace = TRUE; 199 table_desc->loaded_into_namespace = TRUE;
216 } 200 }
217 break; 201 break;
218 202
219
220 case ACPI_TABLE_SSDT: 203 case ACPI_TABLE_SSDT:
204 case ACPI_TABLE_PSDT:
221 205
222 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n", 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
223 acpi_gbl_table_lists[ACPI_TABLE_SSDT].count)); 207 "Namespace load: %d SSDT or PSDTs\n",
208 acpi_gbl_table_lists[table_type].count));
224 209
225 /* 210 /*
226 * Traverse list of SSDT tables 211 * Traverse list of SSDT or PSDT tables
227 */ 212 */
228 table_desc = acpi_gbl_table_lists[ACPI_TABLE_SSDT].next; 213 table_desc = acpi_gbl_table_lists[table_type].next;
229 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_SSDT].count; i++) { 214 for (i = 0; i < acpi_gbl_table_lists[table_type].count; i++) {
230 /* 215 /*
231 * Only attempt to load table if it is not 216 * Only attempt to load table into namespace if it is not
232 * already loaded! 217 * already loaded!
233 */ 218 */
234 if (!table_desc->loaded_into_namespace) { 219 if (!table_desc->loaded_into_namespace) {
235 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); 220 status =
236 if (ACPI_FAILURE (status)) { 221 acpi_ns_load_table(table_desc,
237 break; 222 acpi_gbl_root_node);
238 } 223 if (ACPI_FAILURE(status)) {
239
240 table_desc->loaded_into_namespace = TRUE;
241 }
242
243 table_desc = table_desc->next;
244 }
245 break;
246
247
248 case ACPI_TABLE_PSDT:
249
250 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
251 acpi_gbl_table_lists[ACPI_TABLE_PSDT].count));
252
253 /*
254 * Traverse list of PSDT tables
255 */
256 table_desc = acpi_gbl_table_lists[ACPI_TABLE_PSDT].next;
257
258 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_PSDT].count; i++) {
259 /* Only attempt to load table if it is not already loaded! */
260
261 if (!table_desc->loaded_into_namespace) {
262 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
263 if (ACPI_FAILURE (status)) {
264 break; 224 break;
265 } 225 }
266 226
@@ -271,19 +231,16 @@ acpi_ns_load_table_by_type (
271 } 231 }
272 break; 232 break;
273 233
274
275 default: 234 default:
276 status = AE_SUPPORT; 235 status = AE_SUPPORT;
277 break; 236 break;
278 } 237 }
279 238
280 239 unlock_and_exit:
281unlock_and_exit: 240 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
282 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 241 return_ACPI_STATUS(status);
283 return_ACPI_STATUS (status);
284} 242}
285 243
286
287/******************************************************************************* 244/*******************************************************************************
288 * 245 *
289 * FUNCTION: acpi_load_namespace 246 * FUNCTION: acpi_load_namespace
@@ -297,45 +254,40 @@ unlock_and_exit:
297 * 254 *
298 ******************************************************************************/ 255 ******************************************************************************/
299 256
300acpi_status 257acpi_status acpi_ns_load_namespace(void)
301acpi_ns_load_namespace (
302 void)
303{ 258{
304 acpi_status status; 259 acpi_status status;
305
306
307 ACPI_FUNCTION_TRACE ("acpi_load_name_space");
308 260
261 ACPI_FUNCTION_TRACE("acpi_load_name_space");
309 262
310 /* There must be at least a DSDT installed */ 263 /* There must be at least a DSDT installed */
311 264
312 if (acpi_gbl_DSDT == NULL) { 265 if (acpi_gbl_DSDT == NULL) {
313 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n")); 266 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n"));
314 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 267 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
315 } 268 }
316 269
317 /* 270 /*
318 * Load the namespace. The DSDT is required, 271 * Load the namespace. The DSDT is required,
319 * but the SSDT and PSDT tables are optional. 272 * but the SSDT and PSDT tables are optional.
320 */ 273 */
321 status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT); 274 status = acpi_ns_load_table_by_type(ACPI_TABLE_DSDT);
322 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
323 return_ACPI_STATUS (status); 276 return_ACPI_STATUS(status);
324 } 277 }
325 278
326 /* Ignore exceptions from these */ 279 /* Ignore exceptions from these */
327 280
328 (void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT); 281 (void)acpi_ns_load_table_by_type(ACPI_TABLE_SSDT);
329 (void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT); 282 (void)acpi_ns_load_table_by_type(ACPI_TABLE_PSDT);
330 283
331 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 284 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
332 "ACPI Namespace successfully loaded at root %p\n", 285 "ACPI Namespace successfully loaded at root %p\n",
333 acpi_gbl_root_node)); 286 acpi_gbl_root_node));
334 287
335 return_ACPI_STATUS (status); 288 return_ACPI_STATUS(status);
336} 289}
337 290
338
339#ifdef ACPI_FUTURE_IMPLEMENTATION 291#ifdef ACPI_FUTURE_IMPLEMENTATION
340/******************************************************************************* 292/*******************************************************************************
341 * 293 *
@@ -353,24 +305,20 @@ acpi_ns_load_namespace (
353 * 305 *
354 ******************************************************************************/ 306 ******************************************************************************/
355 307
356static acpi_status 308static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
357acpi_ns_delete_subtree (
358 acpi_handle start_handle)
359{ 309{
360 acpi_status status; 310 acpi_status status;
361 acpi_handle child_handle; 311 acpi_handle child_handle;
362 acpi_handle parent_handle; 312 acpi_handle parent_handle;
363 acpi_handle next_child_handle; 313 acpi_handle next_child_handle;
364 acpi_handle dummy; 314 acpi_handle dummy;
365 u32 level; 315 u32 level;
366
367
368 ACPI_FUNCTION_TRACE ("ns_delete_subtree");
369 316
317 ACPI_FUNCTION_TRACE("ns_delete_subtree");
370 318
371 parent_handle = start_handle; 319 parent_handle = start_handle;
372 child_handle = NULL; 320 child_handle = NULL;
373 level = 1; 321 level = 1;
374 322
375 /* 323 /*
376 * Traverse the tree of objects until we bubble back up 324 * Traverse the tree of objects until we bubble back up
@@ -379,18 +327,19 @@ acpi_ns_delete_subtree (
379 while (level > 0) { 327 while (level > 0) {
380 /* Attempt to get the next object in this scope */ 328 /* Attempt to get the next object in this scope */
381 329
382 status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle, 330 status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle,
383 child_handle, &next_child_handle); 331 child_handle, &next_child_handle);
384 332
385 child_handle = next_child_handle; 333 child_handle = next_child_handle;
386 334
387 /* Did we get a new object? */ 335 /* Did we get a new object? */
388 336
389 if (ACPI_SUCCESS (status)) { 337 if (ACPI_SUCCESS(status)) {
390 /* Check if this object has any children */ 338 /* Check if this object has any children */
391 339
392 if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, 340 if (ACPI_SUCCESS
393 NULL, &dummy))) { 341 (acpi_get_next_object
342 (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) {
394 /* 343 /*
395 * There is at least one child of this object, 344 * There is at least one child of this object,
396 * visit the object 345 * visit the object
@@ -399,8 +348,7 @@ acpi_ns_delete_subtree (
399 parent_handle = child_handle; 348 parent_handle = child_handle;
400 child_handle = NULL; 349 child_handle = NULL;
401 } 350 }
402 } 351 } else {
403 else {
404 /* 352 /*
405 * No more children in this object, go back up to 353 * No more children in this object, go back up to
406 * the object's parent 354 * the object's parent
@@ -409,24 +357,23 @@ acpi_ns_delete_subtree (
409 357
410 /* Delete all children now */ 358 /* Delete all children now */
411 359
412 acpi_ns_delete_children (child_handle); 360 acpi_ns_delete_children(child_handle);
413 361
414 child_handle = parent_handle; 362 child_handle = parent_handle;
415 status = acpi_get_parent (parent_handle, &parent_handle); 363 status = acpi_get_parent(parent_handle, &parent_handle);
416 if (ACPI_FAILURE (status)) { 364 if (ACPI_FAILURE(status)) {
417 return_ACPI_STATUS (status); 365 return_ACPI_STATUS(status);
418 } 366 }
419 } 367 }
420 } 368 }
421 369
422 /* Now delete the starting object, and we are done */ 370 /* Now delete the starting object, and we are done */
423 371
424 acpi_ns_delete_node (child_handle); 372 acpi_ns_delete_node(child_handle);
425 373
426 return_ACPI_STATUS (AE_OK); 374 return_ACPI_STATUS(AE_OK);
427} 375}
428 376
429
430/******************************************************************************* 377/*******************************************************************************
431 * 378 *
432 * FUNCTION: acpi_ns_unload_name_space 379 * FUNCTION: acpi_ns_unload_name_space
@@ -441,32 +388,27 @@ acpi_ns_delete_subtree (
441 * 388 *
442 ******************************************************************************/ 389 ******************************************************************************/
443 390
444acpi_status 391acpi_status acpi_ns_unload_namespace(acpi_handle handle)
445acpi_ns_unload_namespace (
446 acpi_handle handle)
447{ 392{
448 acpi_status status; 393 acpi_status status;
449
450
451 ACPI_FUNCTION_TRACE ("ns_unload_name_space");
452 394
395 ACPI_FUNCTION_TRACE("ns_unload_name_space");
453 396
454 /* Parameter validation */ 397 /* Parameter validation */
455 398
456 if (!acpi_gbl_root_node) { 399 if (!acpi_gbl_root_node) {
457 return_ACPI_STATUS (AE_NO_NAMESPACE); 400 return_ACPI_STATUS(AE_NO_NAMESPACE);
458 } 401 }
459 402
460 if (!handle) { 403 if (!handle) {
461 return_ACPI_STATUS (AE_BAD_PARAMETER); 404 return_ACPI_STATUS(AE_BAD_PARAMETER);
462 } 405 }
463 406
464 /* This function does the real work */ 407 /* This function does the real work */
465 408
466 status = acpi_ns_delete_subtree (handle); 409 status = acpi_ns_delete_subtree(handle);
467 410
468 return_ACPI_STATUS (status); 411 return_ACPI_STATUS(status);
469} 412}
470#endif 413#endif
471#endif 414#endif
472
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d8ce7e39795f..d5e8dea61c27 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -41,23 +41,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsnames") 49ACPI_MODULE_NAME("nsnames")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static void 52static void
56acpi_ns_build_external_path ( 53acpi_ns_build_external_path(struct acpi_namespace_node *node,
57 struct acpi_namespace_node *node, 54 acpi_size size, char *name_buffer);
58 acpi_size size,
59 char *name_buffer);
60
61 55
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
@@ -75,17 +69,13 @@ acpi_ns_build_external_path (
75 ******************************************************************************/ 69 ******************************************************************************/
76 70
77static void 71static void
78acpi_ns_build_external_path ( 72acpi_ns_build_external_path(struct acpi_namespace_node *node,
79 struct acpi_namespace_node *node, 73 acpi_size size, char *name_buffer)
80 acpi_size size,
81 char *name_buffer)
82{ 74{
83 acpi_size index; 75 acpi_size index;
84 struct acpi_namespace_node *parent_node; 76 struct acpi_namespace_node *parent_node;
85
86
87 ACPI_FUNCTION_NAME ("ns_build_external_path");
88 77
78 ACPI_FUNCTION_NAME("ns_build_external_path");
89 79
90 /* Special case for root */ 80 /* Special case for root */
91 81
@@ -106,8 +96,8 @@ acpi_ns_build_external_path (
106 96
107 /* Put the name into the buffer */ 97 /* Put the name into the buffer */
108 98
109 ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name); 99 ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name);
110 parent_node = acpi_ns_get_parent_node (parent_node); 100 parent_node = acpi_ns_get_parent_node(parent_node);
111 101
112 /* Prefix name with the path separator */ 102 /* Prefix name with the path separator */
113 103
@@ -120,15 +110,14 @@ acpi_ns_build_external_path (
120 name_buffer[index] = AML_ROOT_PREFIX; 110 name_buffer[index] = AML_ROOT_PREFIX;
121 111
122 if (index != 0) { 112 if (index != 0) {
123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
124 "Could not construct pathname; index=%X, size=%X, Path=%s\n", 114 "Could not construct pathname; index=%X, size=%X, Path=%s\n",
125 (u32) index, (u32) size, &name_buffer[size])); 115 (u32) index, (u32) size, &name_buffer[size]));
126 } 116 }
127 117
128 return; 118 return;
129} 119}
130 120
131
132#ifdef ACPI_DEBUG_OUTPUT 121#ifdef ACPI_DEBUG_OUTPUT
133/******************************************************************************* 122/*******************************************************************************
134 * 123 *
@@ -144,37 +133,32 @@ acpi_ns_build_external_path (
144 * 133 *
145 ******************************************************************************/ 134 ******************************************************************************/
146 135
147char * 136char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
148acpi_ns_get_external_pathname (
149 struct acpi_namespace_node *node)
150{ 137{
151 char *name_buffer; 138 char *name_buffer;
152 acpi_size size; 139 acpi_size size;
153
154
155 ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node);
156 140
141 ACPI_FUNCTION_TRACE_PTR("ns_get_external_pathname", node);
157 142
158 /* Calculate required buffer size based on depth below root */ 143 /* Calculate required buffer size based on depth below root */
159 144
160 size = acpi_ns_get_pathname_length (node); 145 size = acpi_ns_get_pathname_length(node);
161 146
162 /* Allocate a buffer to be returned to caller */ 147 /* Allocate a buffer to be returned to caller */
163 148
164 name_buffer = ACPI_MEM_CALLOCATE (size); 149 name_buffer = ACPI_MEM_CALLOCATE(size);
165 if (!name_buffer) { 150 if (!name_buffer) {
166 ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n")); 151 ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n"));
167 return_PTR (NULL); 152 return_PTR(NULL);
168 } 153 }
169 154
170 /* Build the path in the allocated buffer */ 155 /* Build the path in the allocated buffer */
171 156
172 acpi_ns_build_external_path (node, size, name_buffer); 157 acpi_ns_build_external_path(node, size, name_buffer);
173 return_PTR (name_buffer); 158 return_PTR(name_buffer);
174} 159}
175#endif 160#endif
176 161
177
178/******************************************************************************* 162/*******************************************************************************
179 * 163 *
180 * FUNCTION: acpi_ns_get_pathname_length 164 * FUNCTION: acpi_ns_get_pathname_length
@@ -187,16 +171,12 @@ acpi_ns_get_external_pathname (
187 * 171 *
188 ******************************************************************************/ 172 ******************************************************************************/
189 173
190acpi_size 174acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
191acpi_ns_get_pathname_length (
192 struct acpi_namespace_node *node)
193{ 175{
194 acpi_size size; 176 acpi_size size;
195 struct acpi_namespace_node *next_node; 177 struct acpi_namespace_node *next_node;
196
197
198 ACPI_FUNCTION_ENTRY ();
199 178
179 ACPI_FUNCTION_ENTRY();
200 180
201 /* 181 /*
202 * Compute length of pathname as 5 * number of name segments. 182 * Compute length of pathname as 5 * number of name segments.
@@ -207,17 +187,16 @@ acpi_ns_get_pathname_length (
207 187
208 while (next_node && (next_node != acpi_gbl_root_node)) { 188 while (next_node && (next_node != acpi_gbl_root_node)) {
209 size += ACPI_PATH_SEGMENT_LENGTH; 189 size += ACPI_PATH_SEGMENT_LENGTH;
210 next_node = acpi_ns_get_parent_node (next_node); 190 next_node = acpi_ns_get_parent_node(next_node);
211 } 191 }
212 192
213 if (!size) { 193 if (!size) {
214 size = 1; /* Root node case */ 194 size = 1; /* Root node case */
215 } 195 }
216 196
217 return (size + 1); /* +1 for null string terminator */ 197 return (size + 1); /* +1 for null string terminator */
218} 198}
219 199
220
221/******************************************************************************* 200/*******************************************************************************
222 * 201 *
223 * FUNCTION: acpi_ns_handle_to_pathname 202 * FUNCTION: acpi_ns_handle_to_pathname
@@ -233,41 +212,36 @@ acpi_ns_get_pathname_length (
233 ******************************************************************************/ 212 ******************************************************************************/
234 213
235acpi_status 214acpi_status
236acpi_ns_handle_to_pathname ( 215acpi_ns_handle_to_pathname(acpi_handle target_handle,
237 acpi_handle target_handle, 216 struct acpi_buffer * buffer)
238 struct acpi_buffer *buffer)
239{ 217{
240 acpi_status status; 218 acpi_status status;
241 struct acpi_namespace_node *node; 219 struct acpi_namespace_node *node;
242 acpi_size required_size; 220 acpi_size required_size;
243 221
222 ACPI_FUNCTION_TRACE_PTR("ns_handle_to_pathname", target_handle);
244 223
245 ACPI_FUNCTION_TRACE_PTR ("ns_handle_to_pathname", target_handle); 224 node = acpi_ns_map_handle_to_node(target_handle);
246
247
248 node = acpi_ns_map_handle_to_node (target_handle);
249 if (!node) { 225 if (!node) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 226 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 227 }
252 228
253 /* Determine size required for the caller buffer */ 229 /* Determine size required for the caller buffer */
254 230
255 required_size = acpi_ns_get_pathname_length (node); 231 required_size = acpi_ns_get_pathname_length(node);
256 232
257 /* Validate/Allocate/Clear caller buffer */ 233 /* Validate/Allocate/Clear caller buffer */
258 234
259 status = acpi_ut_initialize_buffer (buffer, required_size); 235 status = acpi_ut_initialize_buffer(buffer, required_size);
260 if (ACPI_FAILURE (status)) { 236 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS (status); 237 return_ACPI_STATUS(status);
262 } 238 }
263 239
264 /* Build the path in the caller buffer */ 240 /* Build the path in the caller buffer */
265 241
266 acpi_ns_build_external_path (node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
267 243
268 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n",
269 (char *) buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
270 return_ACPI_STATUS (AE_OK); 246 return_ACPI_STATUS(AE_OK);
271} 247}
272
273
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 27258c1ca4f1..fc9be946ebed 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsobject") 49ACPI_MODULE_NAME("nsobject")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -71,20 +68,15 @@
71 * MUTEX: Assumes namespace is locked 68 * MUTEX: Assumes namespace is locked
72 * 69 *
73 ******************************************************************************/ 70 ******************************************************************************/
74
75acpi_status 71acpi_status
76acpi_ns_attach_object ( 72acpi_ns_attach_object(struct acpi_namespace_node *node,
77 struct acpi_namespace_node *node, 73 union acpi_operand_object *object, acpi_object_type type)
78 union acpi_operand_object *object,
79 acpi_object_type type)
80{ 74{
81 union acpi_operand_object *obj_desc; 75 union acpi_operand_object *obj_desc;
82 union acpi_operand_object *last_obj_desc; 76 union acpi_operand_object *last_obj_desc;
83 acpi_object_type object_type = ACPI_TYPE_ANY; 77 acpi_object_type object_type = ACPI_TYPE_ANY;
84
85
86 ACPI_FUNCTION_TRACE ("ns_attach_object");
87 78
79 ACPI_FUNCTION_TRACE("ns_attach_object");
88 80
89 /* 81 /*
90 * Parameter validation 82 * Parameter validation
@@ -92,40 +84,39 @@ acpi_ns_attach_object (
92 if (!node) { 84 if (!node) {
93 /* Invalid handle */ 85 /* Invalid handle */
94 86
95 ACPI_REPORT_ERROR (("ns_attach_object: Null named_obj handle\n")); 87 ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n"));
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 if (!object && (ACPI_TYPE_ANY != type)) { 91 if (!object && (ACPI_TYPE_ANY != type)) {
100 /* Null object */ 92 /* Null object */
101 93
102 ACPI_REPORT_ERROR (( 94 ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
103 "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 95 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 return_ACPI_STATUS (AE_BAD_PARAMETER);
105 } 96 }
106 97
107 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 98 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
108 /* Not a name handle */ 99 /* Not a name handle */
109 100
110 ACPI_REPORT_ERROR (("ns_attach_object: Invalid handle %p [%s]\n", 101 ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n",
111 node, acpi_ut_get_descriptor_name (node))); 102 node, acpi_ut_get_descriptor_name(node)));
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 103 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 104 }
114 105
115 /* Check if this object is already attached */ 106 /* Check if this object is already attached */
116 107
117 if (node->object == object) { 108 if (node->object == object) {
118 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 109 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
119 "Obj %p already installed in name_obj %p\n", 110 "Obj %p already installed in name_obj %p\n",
120 object, node)); 111 object, node));
121 112
122 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
123 } 114 }
124 115
125 /* If null object, we will just install it */ 116 /* If null object, we will just install it */
126 117
127 if (!object) { 118 if (!object) {
128 obj_desc = NULL; 119 obj_desc = NULL;
129 object_type = ACPI_TYPE_ANY; 120 object_type = ACPI_TYPE_ANY;
130 } 121 }
131 122
@@ -133,14 +124,14 @@ acpi_ns_attach_object (
133 * If the source object is a namespace Node with an attached object, 124 * If the source object is a namespace Node with an attached object,
134 * we will use that (attached) object 125 * we will use that (attached) object
135 */ 126 */
136 else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) && 127 else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) &&
137 ((struct acpi_namespace_node *) object)->object) { 128 ((struct acpi_namespace_node *)object)->object) {
138 /* 129 /*
139 * Value passed is a name handle and that name has a 130 * Value passed is a name handle and that name has a
140 * non-null value. Use that name's value and type. 131 * non-null value. Use that name's value and type.
141 */ 132 */
142 obj_desc = ((struct acpi_namespace_node *) object)->object; 133 obj_desc = ((struct acpi_namespace_node *)object)->object;
143 object_type = ((struct acpi_namespace_node *) object)->type; 134 object_type = ((struct acpi_namespace_node *)object)->type;
144 } 135 }
145 136
146 /* 137 /*
@@ -148,20 +139,20 @@ acpi_ns_attach_object (
148 * it first 139 * it first
149 */ 140 */
150 else { 141 else {
151 obj_desc = (union acpi_operand_object *) object; 142 obj_desc = (union acpi_operand_object *)object;
152 143
153 /* Use the given type */ 144 /* Use the given type */
154 145
155 object_type = type; 146 object_type = type;
156 } 147 }
157 148
158 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", 149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
159 obj_desc, node, acpi_ut_get_node_name (node))); 150 obj_desc, node, acpi_ut_get_node_name(node)));
160 151
161 /* Detach an existing attached object if present */ 152 /* Detach an existing attached object if present */
162 153
163 if (node->object) { 154 if (node->object) {
164 acpi_ns_detach_object (node); 155 acpi_ns_detach_object(node);
165 } 156 }
166 157
167 if (obj_desc) { 158 if (obj_desc) {
@@ -169,7 +160,7 @@ acpi_ns_attach_object (
169 * Must increment the new value's reference count 160 * Must increment the new value's reference count
170 * (if it is an internal object) 161 * (if it is an internal object)
171 */ 162 */
172 acpi_ut_add_reference (obj_desc); 163 acpi_ut_add_reference(obj_desc);
173 164
174 /* 165 /*
175 * Handle objects with multiple descriptors - walk 166 * Handle objects with multiple descriptors - walk
@@ -185,13 +176,12 @@ acpi_ns_attach_object (
185 last_obj_desc->common.next_object = node->object; 176 last_obj_desc->common.next_object = node->object;
186 } 177 }
187 178
188 node->type = (u8) object_type; 179 node->type = (u8) object_type;
189 node->object = obj_desc; 180 node->object = obj_desc;
190 181
191 return_ACPI_STATUS (AE_OK); 182 return_ACPI_STATUS(AE_OK);
192} 183}
193 184
194
195/******************************************************************************* 185/*******************************************************************************
196 * 186 *
197 * FUNCTION: acpi_ns_detach_object 187 * FUNCTION: acpi_ns_detach_object
@@ -206,30 +196,27 @@ acpi_ns_attach_object (
206 * 196 *
207 ******************************************************************************/ 197 ******************************************************************************/
208 198
209void 199void acpi_ns_detach_object(struct acpi_namespace_node *node)
210acpi_ns_detach_object (
211 struct acpi_namespace_node *node)
212{ 200{
213 union acpi_operand_object *obj_desc; 201 union acpi_operand_object *obj_desc;
214
215
216 ACPI_FUNCTION_TRACE ("ns_detach_object");
217 202
203 ACPI_FUNCTION_TRACE("ns_detach_object");
218 204
219 obj_desc = node->object; 205 obj_desc = node->object;
220 206
221 if (!obj_desc || 207 if (!obj_desc ||
222 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) { 208 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
223 return_VOID; 209 return_VOID;
224 } 210 }
225 211
226 /* Clear the entry in all cases */ 212 /* Clear the entry in all cases */
227 213
228 node->object = NULL; 214 node->object = NULL;
229 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) { 215 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
230 node->object = obj_desc->common.next_object; 216 node->object = obj_desc->common.next_object;
231 if (node->object && 217 if (node->object &&
232 (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) { 218 (ACPI_GET_OBJECT_TYPE(node->object) !=
219 ACPI_TYPE_LOCAL_DATA)) {
233 node->object = node->object->common.next_object; 220 node->object = node->object->common.next_object;
234 } 221 }
235 } 222 }
@@ -238,16 +225,15 @@ acpi_ns_detach_object (
238 225
239 node->type = ACPI_TYPE_ANY; 226 node->type = ACPI_TYPE_ANY;
240 227
241 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", 228 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
242 node, acpi_ut_get_node_name (node), obj_desc)); 229 node, acpi_ut_get_node_name(node), obj_desc));
243 230
244 /* Remove one reference on the object (and all subobjects) */ 231 /* Remove one reference on the object (and all subobjects) */
245 232
246 acpi_ut_remove_reference (obj_desc); 233 acpi_ut_remove_reference(obj_desc);
247 return_VOID; 234 return_VOID;
248} 235}
249 236
250
251/******************************************************************************* 237/*******************************************************************************
252 * 238 *
253 * FUNCTION: acpi_ns_get_attached_object 239 * FUNCTION: acpi_ns_get_attached_object
@@ -261,29 +247,28 @@ acpi_ns_detach_object (
261 * 247 *
262 ******************************************************************************/ 248 ******************************************************************************/
263 249
264union acpi_operand_object * 250union acpi_operand_object *acpi_ns_get_attached_object(struct
265acpi_ns_get_attached_object ( 251 acpi_namespace_node
266 struct acpi_namespace_node *node) 252 *node)
267{ 253{
268 ACPI_FUNCTION_TRACE_PTR ("ns_get_attached_object", node); 254 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node);
269
270 255
271 if (!node) { 256 if (!node) {
272 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n")); 257 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n"));
273 return_PTR (NULL); 258 return_PTR(NULL);
274 } 259 }
275 260
276 if (!node->object || 261 if (!node->object ||
277 ((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_OPERAND) && 262 ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
278 (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED)) || 263 && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
279 (ACPI_GET_OBJECT_TYPE (node->object) == ACPI_TYPE_LOCAL_DATA)) { 264 ACPI_DESC_TYPE_NAMED))
280 return_PTR (NULL); 265 || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) {
266 return_PTR(NULL);
281 } 267 }
282 268
283 return_PTR (node->object); 269 return_PTR(node->object);
284} 270}
285 271
286
287/******************************************************************************* 272/*******************************************************************************
288 * 273 *
289 * FUNCTION: acpi_ns_get_secondary_object 274 * FUNCTION: acpi_ns_get_secondary_object
@@ -297,24 +282,23 @@ acpi_ns_get_attached_object (
297 * 282 *
298 ******************************************************************************/ 283 ******************************************************************************/
299 284
300union acpi_operand_object * 285union acpi_operand_object *acpi_ns_get_secondary_object(union
301acpi_ns_get_secondary_object ( 286 acpi_operand_object
302 union acpi_operand_object *obj_desc) 287 *obj_desc)
303{ 288{
304 ACPI_FUNCTION_TRACE_PTR ("ns_get_secondary_object", obj_desc); 289 ACPI_FUNCTION_TRACE_PTR("ns_get_secondary_object", obj_desc);
305 290
306 291 if ((!obj_desc) ||
307 if ((!obj_desc) || 292 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
308 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) || 293 (!obj_desc->common.next_object) ||
309 (!obj_desc->common.next_object) || 294 (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) ==
310 (ACPI_GET_OBJECT_TYPE (obj_desc->common.next_object) == ACPI_TYPE_LOCAL_DATA)) { 295 ACPI_TYPE_LOCAL_DATA)) {
311 return_PTR (NULL); 296 return_PTR(NULL);
312 } 297 }
313 298
314 return_PTR (obj_desc->common.next_object); 299 return_PTR(obj_desc->common.next_object);
315} 300}
316 301
317
318/******************************************************************************* 302/*******************************************************************************
319 * 303 *
320 * FUNCTION: acpi_ns_attach_data 304 * FUNCTION: acpi_ns_attach_data
@@ -330,23 +314,20 @@ acpi_ns_get_secondary_object (
330 ******************************************************************************/ 314 ******************************************************************************/
331 315
332acpi_status 316acpi_status
333acpi_ns_attach_data ( 317acpi_ns_attach_data(struct acpi_namespace_node *node,
334 struct acpi_namespace_node *node, 318 acpi_object_handler handler, void *data)
335 acpi_object_handler handler,
336 void *data)
337{ 319{
338 union acpi_operand_object *prev_obj_desc; 320 union acpi_operand_object *prev_obj_desc;
339 union acpi_operand_object *obj_desc; 321 union acpi_operand_object *obj_desc;
340 union acpi_operand_object *data_desc; 322 union acpi_operand_object *data_desc;
341
342 323
343 /* We only allow one attachment per handler */ 324 /* We only allow one attachment per handler */
344 325
345 prev_obj_desc = NULL; 326 prev_obj_desc = NULL;
346 obj_desc = node->object; 327 obj_desc = node->object;
347 while (obj_desc) { 328 while (obj_desc) {
348 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 329 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
349 (obj_desc->data.handler == handler)) { 330 (obj_desc->data.handler == handler)) {
350 return (AE_ALREADY_EXISTS); 331 return (AE_ALREADY_EXISTS);
351 } 332 }
352 333
@@ -356,7 +337,7 @@ acpi_ns_attach_data (
356 337
357 /* Create an internal object for the data */ 338 /* Create an internal object for the data */
358 339
359 data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA); 340 data_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_DATA);
360 if (!data_desc) { 341 if (!data_desc) {
361 return (AE_NO_MEMORY); 342 return (AE_NO_MEMORY);
362 } 343 }
@@ -368,15 +349,13 @@ acpi_ns_attach_data (
368 349
369 if (prev_obj_desc) { 350 if (prev_obj_desc) {
370 prev_obj_desc->common.next_object = data_desc; 351 prev_obj_desc->common.next_object = data_desc;
371 } 352 } else {
372 else {
373 node->object = data_desc; 353 node->object = data_desc;
374 } 354 }
375 355
376 return (AE_OK); 356 return (AE_OK);
377} 357}
378 358
379
380/******************************************************************************* 359/*******************************************************************************
381 * 360 *
382 * FUNCTION: acpi_ns_detach_data 361 * FUNCTION: acpi_ns_detach_data
@@ -392,27 +371,25 @@ acpi_ns_attach_data (
392 ******************************************************************************/ 371 ******************************************************************************/
393 372
394acpi_status 373acpi_status
395acpi_ns_detach_data ( 374acpi_ns_detach_data(struct acpi_namespace_node * node,
396 struct acpi_namespace_node *node, 375 acpi_object_handler handler)
397 acpi_object_handler handler)
398{ 376{
399 union acpi_operand_object *obj_desc; 377 union acpi_operand_object *obj_desc;
400 union acpi_operand_object *prev_obj_desc; 378 union acpi_operand_object *prev_obj_desc;
401
402 379
403 prev_obj_desc = NULL; 380 prev_obj_desc = NULL;
404 obj_desc = node->object; 381 obj_desc = node->object;
405 while (obj_desc) { 382 while (obj_desc) {
406 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 383 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
407 (obj_desc->data.handler == handler)) { 384 (obj_desc->data.handler == handler)) {
408 if (prev_obj_desc) { 385 if (prev_obj_desc) {
409 prev_obj_desc->common.next_object = obj_desc->common.next_object; 386 prev_obj_desc->common.next_object =
410 } 387 obj_desc->common.next_object;
411 else { 388 } else {
412 node->object = obj_desc->common.next_object; 389 node->object = obj_desc->common.next_object;
413 } 390 }
414 391
415 acpi_ut_remove_reference (obj_desc); 392 acpi_ut_remove_reference(obj_desc);
416 return (AE_OK); 393 return (AE_OK);
417 } 394 }
418 395
@@ -423,7 +400,6 @@ acpi_ns_detach_data (
423 return (AE_NOT_FOUND); 400 return (AE_NOT_FOUND);
424} 401}
425 402
426
427/******************************************************************************* 403/*******************************************************************************
428 * 404 *
429 * FUNCTION: acpi_ns_get_attached_data 405 * FUNCTION: acpi_ns_get_attached_data
@@ -440,18 +416,15 @@ acpi_ns_detach_data (
440 ******************************************************************************/ 416 ******************************************************************************/
441 417
442acpi_status 418acpi_status
443acpi_ns_get_attached_data ( 419acpi_ns_get_attached_data(struct acpi_namespace_node * node,
444 struct acpi_namespace_node *node, 420 acpi_object_handler handler, void **data)
445 acpi_object_handler handler,
446 void **data)
447{ 421{
448 union acpi_operand_object *obj_desc; 422 union acpi_operand_object *obj_desc;
449
450 423
451 obj_desc = node->object; 424 obj_desc = node->object;
452 while (obj_desc) { 425 while (obj_desc) {
453 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 426 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
454 (obj_desc->data.handler == handler)) { 427 (obj_desc->data.handler == handler)) {
455 *data = obj_desc->data.pointer; 428 *data = obj_desc->data.pointer;
456 return (AE_OK); 429 return (AE_OK);
457 } 430 }
@@ -461,5 +434,3 @@ acpi_ns_get_attached_data (
461 434
462 return (AE_NOT_FOUND); 435 return (AE_NOT_FOUND);
463} 436}
464
465
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
index a0e13e8d3764..433442a9ec74 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/namespace/nsparse.c
@@ -41,16 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
49 48
50
51#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsparse") 50ACPI_MODULE_NAME("nsparse")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -64,54 +61,50 @@
64 * DESCRIPTION: Perform one complete parse of an ACPI/AML table. 61 * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
65 * 62 *
66 ******************************************************************************/ 63 ******************************************************************************/
67
68acpi_status 64acpi_status
69acpi_ns_one_complete_parse ( 65acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc * table_desc)
70 u32 pass_number,
71 struct acpi_table_desc *table_desc)
72{ 66{
73 union acpi_parse_object *parse_root; 67 union acpi_parse_object *parse_root;
74 acpi_status status; 68 acpi_status status;
75 struct acpi_walk_state *walk_state; 69 struct acpi_walk_state *walk_state;
76
77
78 ACPI_FUNCTION_TRACE ("ns_one_complete_parse");
79 70
71 ACPI_FUNCTION_TRACE("ns_one_complete_parse");
80 72
81 /* Create and init a Root Node */ 73 /* Create and init a Root Node */
82 74
83 parse_root = acpi_ps_create_scope_op (); 75 parse_root = acpi_ps_create_scope_op();
84 if (!parse_root) { 76 if (!parse_root) {
85 return_ACPI_STATUS (AE_NO_MEMORY); 77 return_ACPI_STATUS(AE_NO_MEMORY);
86 } 78 }
87 79
88 /* Create and initialize a new walk state */ 80 /* Create and initialize a new walk state */
89 81
90 walk_state = acpi_ds_create_walk_state (table_desc->table_id, 82 walk_state = acpi_ds_create_walk_state(table_desc->owner_id,
91 NULL, NULL, NULL); 83 NULL, NULL, NULL);
92 if (!walk_state) { 84 if (!walk_state) {
93 acpi_ps_free_op (parse_root); 85 acpi_ps_free_op(parse_root);
94 return_ACPI_STATUS (AE_NO_MEMORY); 86 return_ACPI_STATUS(AE_NO_MEMORY);
95 } 87 }
96 88
97 status = acpi_ds_init_aml_walk (walk_state, parse_root, NULL, 89 status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
98 table_desc->aml_start, table_desc->aml_length, 90 table_desc->aml_start,
99 NULL, pass_number); 91 table_desc->aml_length, NULL,
100 if (ACPI_FAILURE (status)) { 92 pass_number);
101 acpi_ds_delete_walk_state (walk_state); 93 if (ACPI_FAILURE(status)) {
102 return_ACPI_STATUS (status); 94 acpi_ds_delete_walk_state(walk_state);
95 return_ACPI_STATUS(status);
103 } 96 }
104 97
105 /* Parse the AML */ 98 /* Parse the AML */
106 99
107 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", pass_number)); 100 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n",
108 status = acpi_ps_parse_aml (walk_state); 101 pass_number));
102 status = acpi_ps_parse_aml(walk_state);
109 103
110 acpi_ps_delete_parse_tree (parse_root); 104 acpi_ps_delete_parse_tree(parse_root);
111 return_ACPI_STATUS (status); 105 return_ACPI_STATUS(status);
112} 106}
113 107
114
115/******************************************************************************* 108/*******************************************************************************
116 * 109 *
117 * FUNCTION: acpi_ns_parse_table 110 * FUNCTION: acpi_ns_parse_table
@@ -126,15 +119,12 @@ acpi_ns_one_complete_parse (
126 ******************************************************************************/ 119 ******************************************************************************/
127 120
128acpi_status 121acpi_status
129acpi_ns_parse_table ( 122acpi_ns_parse_table(struct acpi_table_desc *table_desc,
130 struct acpi_table_desc *table_desc, 123 struct acpi_namespace_node *start_node)
131 struct acpi_namespace_node *start_node)
132{ 124{
133 acpi_status status; 125 acpi_status status;
134
135
136 ACPI_FUNCTION_TRACE ("ns_parse_table");
137 126
127 ACPI_FUNCTION_TRACE("ns_parse_table");
138 128
139 /* 129 /*
140 * AML Parse, pass 1 130 * AML Parse, pass 1
@@ -146,9 +136,10 @@ acpi_ns_parse_table (
146 * to service the entire parse. The second pass of the parse then 136 * to service the entire parse. The second pass of the parse then
147 * performs another complete parse of the AML.. 137 * performs another complete parse of the AML..
148 */ 138 */
149 status = acpi_ns_one_complete_parse (1, table_desc); 139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
150 if (ACPI_FAILURE (status)) { 140 status = acpi_ns_one_complete_parse(1, table_desc);
151 return_ACPI_STATUS (status); 141 if (ACPI_FAILURE(status)) {
142 return_ACPI_STATUS(status);
152 } 143 }
153 144
154 /* 145 /*
@@ -160,12 +151,11 @@ acpi_ns_parse_table (
160 * overhead of this is compensated for by the fact that the 151 * overhead of this is compensated for by the fact that the
161 * parse objects are all cached. 152 * parse objects are all cached.
162 */ 153 */
163 status = acpi_ns_one_complete_parse (2, table_desc); 154 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
164 if (ACPI_FAILURE (status)) { 155 status = acpi_ns_one_complete_parse(2, table_desc);
165 return_ACPI_STATUS (status); 156 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status);
166 } 158 }
167 159
168 return_ACPI_STATUS (status); 160 return_ACPI_STATUS(status);
169} 161}
170
171
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index af8aaa9cc4f3..50a3ca5470ed 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -41,23 +41,18 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nssearch") 48ACPI_MODULE_NAME("nssearch")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_ns_search_parent_tree ( 52acpi_ns_search_parent_tree(u32 target_name,
56 u32 target_name, 53 struct acpi_namespace_node *node,
57 struct acpi_namespace_node *node, 54 acpi_object_type type,
58 acpi_object_type type, 55 struct acpi_namespace_node **return_node);
59 struct acpi_namespace_node **return_node);
60
61 56
62/******************************************************************************* 57/*******************************************************************************
63 * 58 *
@@ -87,30 +82,28 @@ acpi_ns_search_parent_tree (
87 ******************************************************************************/ 82 ******************************************************************************/
88 83
89acpi_status 84acpi_status
90acpi_ns_search_node ( 85acpi_ns_search_node(u32 target_name,
91 u32 target_name, 86 struct acpi_namespace_node *node,
92 struct acpi_namespace_node *node, 87 acpi_object_type type,
93 acpi_object_type type, 88 struct acpi_namespace_node **return_node)
94 struct acpi_namespace_node **return_node)
95{ 89{
96 struct acpi_namespace_node *next_node; 90 struct acpi_namespace_node *next_node;
97
98
99 ACPI_FUNCTION_TRACE ("ns_search_node");
100 91
92 ACPI_FUNCTION_TRACE("ns_search_node");
101 93
102#ifdef ACPI_DEBUG_OUTPUT 94#ifdef ACPI_DEBUG_OUTPUT
103 if (ACPI_LV_NAMES & acpi_dbg_level) { 95 if (ACPI_LV_NAMES & acpi_dbg_level) {
104 char *scope_name; 96 char *scope_name;
105 97
106 scope_name = acpi_ns_get_external_pathname (node); 98 scope_name = acpi_ns_get_external_pathname(node);
107 if (scope_name) { 99 if (scope_name) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
109 "Searching %s (%p) For [%4.4s] (%s)\n", 101 "Searching %s (%p) For [%4.4s] (%s)\n",
110 scope_name, node, (char *) &target_name, 102 scope_name, node,
111 acpi_ut_get_type_name (type))); 103 (char *)&target_name,
104 acpi_ut_get_type_name(type)));
112 105
113 ACPI_MEM_FREE (scope_name); 106 ACPI_MEM_FREE(scope_name);
114 } 107 }
115 } 108 }
116#endif 109#endif
@@ -126,20 +119,26 @@ acpi_ns_search_node (
126 if (next_node->name.integer == target_name) { 119 if (next_node->name.integer == target_name) {
127 /* Resolve a control method alias if any */ 120 /* Resolve a control method alias if any */
128 121
129 if (acpi_ns_get_type (next_node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { 122 if (acpi_ns_get_type(next_node) ==
130 next_node = ACPI_CAST_PTR (struct acpi_namespace_node, next_node->object); 123 ACPI_TYPE_LOCAL_METHOD_ALIAS) {
124 next_node =
125 ACPI_CAST_PTR(struct acpi_namespace_node,
126 next_node->object);
131 } 127 }
132 128
133 /* 129 /*
134 * Found matching entry. 130 * Found matching entry.
135 */ 131 */
136 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
137 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
138 (char *) &target_name, acpi_ut_get_type_name (next_node->type), 134 (char *)&target_name,
139 next_node, acpi_ut_get_node_name (node), node)); 135 acpi_ut_get_type_name(next_node->
136 type),
137 next_node,
138 acpi_ut_get_node_name(node), node));
140 139
141 *return_node = next_node; 140 *return_node = next_node;
142 return_ACPI_STATUS (AE_OK); 141 return_ACPI_STATUS(AE_OK);
143 } 142 }
144 143
145 /* 144 /*
@@ -159,15 +158,14 @@ acpi_ns_search_node (
159 158
160 /* Searched entire namespace level, not found */ 159 /* Searched entire namespace level, not found */
161 160
162 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
163 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
164 (char *) &target_name, acpi_ut_get_type_name (type), 163 (char *)&target_name, acpi_ut_get_type_name(type),
165 acpi_ut_get_node_name (node), node, node->child)); 164 acpi_ut_get_node_name(node), node, node->child));
166 165
167 return_ACPI_STATUS (AE_NOT_FOUND); 166 return_ACPI_STATUS(AE_NOT_FOUND);
168} 167}
169 168
170
171/******************************************************************************* 169/*******************************************************************************
172 * 170 *
173 * FUNCTION: acpi_ns_search_parent_tree 171 * FUNCTION: acpi_ns_search_parent_tree
@@ -194,43 +192,42 @@ acpi_ns_search_node (
194 ******************************************************************************/ 192 ******************************************************************************/
195 193
196static acpi_status 194static acpi_status
197acpi_ns_search_parent_tree ( 195acpi_ns_search_parent_tree(u32 target_name,
198 u32 target_name, 196 struct acpi_namespace_node *node,
199 struct acpi_namespace_node *node, 197 acpi_object_type type,
200 acpi_object_type type, 198 struct acpi_namespace_node **return_node)
201 struct acpi_namespace_node **return_node)
202{ 199{
203 acpi_status status; 200 acpi_status status;
204 struct acpi_namespace_node *parent_node; 201 struct acpi_namespace_node *parent_node;
205 202
203 ACPI_FUNCTION_TRACE("ns_search_parent_tree");
206 204
207 ACPI_FUNCTION_TRACE ("ns_search_parent_tree"); 205 parent_node = acpi_ns_get_parent_node(node);
208
209
210 parent_node = acpi_ns_get_parent_node (node);
211 206
212 /* 207 /*
213 * If there is no parent (i.e., we are at the root) or type is "local", 208 * If there is no parent (i.e., we are at the root) or type is "local",
214 * we won't be searching the parent tree. 209 * we won't be searching the parent tree.
215 */ 210 */
216 if (!parent_node) { 211 if (!parent_node) {
217 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 212 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
218 (char *) &target_name)); 213 (char *)&target_name));
219 return_ACPI_STATUS (AE_NOT_FOUND); 214 return_ACPI_STATUS(AE_NOT_FOUND);
220 } 215 }
221 216
222 if (acpi_ns_local (type)) { 217 if (acpi_ns_local(type)) {
223 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 218 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
224 "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 219 "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
225 (char *) &target_name, acpi_ut_get_type_name (type))); 220 (char *)&target_name,
226 return_ACPI_STATUS (AE_NOT_FOUND); 221 acpi_ut_get_type_name(type)));
222 return_ACPI_STATUS(AE_NOT_FOUND);
227 } 223 }
228 224
229 /* Search the parent tree */ 225 /* Search the parent tree */
230 226
231 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 227 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
232 "Searching parent [%4.4s] for [%4.4s]\n", 228 "Searching parent [%4.4s] for [%4.4s]\n",
233 acpi_ut_get_node_name (parent_node), (char *) &target_name)); 229 acpi_ut_get_node_name(parent_node),
230 (char *)&target_name));
234 231
235 /* 232 /*
236 * Search parents until target is found or we have backed up to the root 233 * Search parents until target is found or we have backed up to the root
@@ -241,25 +238,24 @@ acpi_ns_search_parent_tree (
241 * object type at this point, we only care about the existence of 238 * object type at this point, we only care about the existence of
242 * the actual name we are searching for. Typechecking comes later. 239 * the actual name we are searching for. Typechecking comes later.
243 */ 240 */
244 status = acpi_ns_search_node (target_name, parent_node, 241 status = acpi_ns_search_node(target_name, parent_node,
245 ACPI_TYPE_ANY, return_node); 242 ACPI_TYPE_ANY, return_node);
246 if (ACPI_SUCCESS (status)) { 243 if (ACPI_SUCCESS(status)) {
247 return_ACPI_STATUS (status); 244 return_ACPI_STATUS(status);
248 } 245 }
249 246
250 /* 247 /*
251 * Not found here, go up another level 248 * Not found here, go up another level
252 * (until we reach the root) 249 * (until we reach the root)
253 */ 250 */
254 parent_node = acpi_ns_get_parent_node (parent_node); 251 parent_node = acpi_ns_get_parent_node(parent_node);
255 } 252 }
256 253
257 /* Not found in parent tree */ 254 /* Not found in parent tree */
258 255
259 return_ACPI_STATUS (AE_NOT_FOUND); 256 return_ACPI_STATUS(AE_NOT_FOUND);
260} 257}
261 258
262
263/******************************************************************************* 259/*******************************************************************************
264 * 260 *
265 * FUNCTION: acpi_ns_search_and_enter 261 * FUNCTION: acpi_ns_search_and_enter
@@ -286,52 +282,46 @@ acpi_ns_search_parent_tree (
286 ******************************************************************************/ 282 ******************************************************************************/
287 283
288acpi_status 284acpi_status
289acpi_ns_search_and_enter ( 285acpi_ns_search_and_enter(u32 target_name,
290 u32 target_name, 286 struct acpi_walk_state *walk_state,
291 struct acpi_walk_state *walk_state, 287 struct acpi_namespace_node *node,
292 struct acpi_namespace_node *node, 288 acpi_interpreter_mode interpreter_mode,
293 acpi_interpreter_mode interpreter_mode, 289 acpi_object_type type,
294 acpi_object_type type, 290 u32 flags, struct acpi_namespace_node **return_node)
295 u32 flags,
296 struct acpi_namespace_node **return_node)
297{ 291{
298 acpi_status status; 292 acpi_status status;
299 struct acpi_namespace_node *new_node; 293 struct acpi_namespace_node *new_node;
300
301
302 ACPI_FUNCTION_TRACE ("ns_search_and_enter");
303 294
295 ACPI_FUNCTION_TRACE("ns_search_and_enter");
304 296
305 /* Parameter validation */ 297 /* Parameter validation */
306 298
307 if (!node || !target_name || !return_node) { 299 if (!node || !target_name || !return_node) {
308 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 300 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
309 "Null param: Node %p Name %X return_node %p\n", 301 "Null param: Node %p Name %X return_node %p\n",
310 node, target_name, return_node)); 302 node, target_name, return_node));
311 303
312 ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n")); 304 ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n"));
313 return_ACPI_STATUS (AE_BAD_PARAMETER); 305 return_ACPI_STATUS(AE_BAD_PARAMETER);
314 } 306 }
315 307
316 /* Name must consist of printable characters */ 308 /* Name must consist of printable characters */
317 309
318 if (!acpi_ut_valid_acpi_name (target_name)) { 310 if (!acpi_ut_valid_acpi_name(target_name)) {
319 ACPI_REPORT_ERROR (("ns_search_and_enter: Bad character in ACPI Name: %X\n", 311 ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name));
320 target_name)); 312 return_ACPI_STATUS(AE_BAD_CHARACTER);
321 return_ACPI_STATUS (AE_BAD_CHARACTER);
322 } 313 }
323 314
324 /* Try to find the name in the namespace level specified by the caller */ 315 /* Try to find the name in the namespace level specified by the caller */
325 316
326 *return_node = ACPI_ENTRY_NOT_FOUND; 317 *return_node = ACPI_ENTRY_NOT_FOUND;
327 status = acpi_ns_search_node (target_name, node, type, return_node); 318 status = acpi_ns_search_node(target_name, node, type, return_node);
328 if (status != AE_NOT_FOUND) { 319 if (status != AE_NOT_FOUND) {
329 /* 320 /*
330 * If we found it AND the request specifies that a find is an error, 321 * If we found it AND the request specifies that a find is an error,
331 * return the error 322 * return the error
332 */ 323 */
333 if ((status == AE_OK) && 324 if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
334 (flags & ACPI_NS_ERROR_IF_FOUND)) {
335 status = AE_ALREADY_EXISTS; 325 status = AE_ALREADY_EXISTS;
336 } 326 }
337 327
@@ -339,7 +329,7 @@ acpi_ns_search_and_enter (
339 * Either found it or there was an error 329 * Either found it or there was an error
340 * -- finished either way 330 * -- finished either way
341 */ 331 */
342 return_ACPI_STATUS (status); 332 return_ACPI_STATUS(status);
343 } 333 }
344 334
345 /* 335 /*
@@ -351,14 +341,16 @@ acpi_ns_search_and_enter (
351 * and during the execution phase. 341 * and during the execution phase.
352 */ 342 */
353 if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) && 343 if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
354 (flags & ACPI_NS_SEARCH_PARENT)) { 344 (flags & ACPI_NS_SEARCH_PARENT)) {
355 /* 345 /*
356 * Not found at this level - search parent tree according to the 346 * Not found at this level - search parent tree according to the
357 * ACPI specification 347 * ACPI specification
358 */ 348 */
359 status = acpi_ns_search_parent_tree (target_name, node, type, return_node); 349 status =
360 if (ACPI_SUCCESS (status)) { 350 acpi_ns_search_parent_tree(target_name, node, type,
361 return_ACPI_STATUS (status); 351 return_node);
352 if (ACPI_SUCCESS(status)) {
353 return_ACPI_STATUS(status);
362 } 354 }
363 } 355 }
364 356
@@ -366,25 +358,24 @@ acpi_ns_search_and_enter (
366 * In execute mode, just search, never add names. Exit now. 358 * In execute mode, just search, never add names. Exit now.
367 */ 359 */
368 if (interpreter_mode == ACPI_IMODE_EXECUTE) { 360 if (interpreter_mode == ACPI_IMODE_EXECUTE) {
369 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
370 "%4.4s Not found in %p [Not adding]\n", 362 "%4.4s Not found in %p [Not adding]\n",
371 (char *) &target_name, node)); 363 (char *)&target_name, node));
372 364
373 return_ACPI_STATUS (AE_NOT_FOUND); 365 return_ACPI_STATUS(AE_NOT_FOUND);
374 } 366 }
375 367
376 /* Create the new named object */ 368 /* Create the new named object */
377 369
378 new_node = acpi_ns_create_node (target_name); 370 new_node = acpi_ns_create_node(target_name);
379 if (!new_node) { 371 if (!new_node) {
380 return_ACPI_STATUS (AE_NO_MEMORY); 372 return_ACPI_STATUS(AE_NO_MEMORY);
381 } 373 }
382 374
383 /* Install the new object into the parent's list of children */ 375 /* Install the new object into the parent's list of children */
384 376
385 acpi_ns_install_node (walk_state, node, new_node, type); 377 acpi_ns_install_node(walk_state, node, new_node, type);
386 *return_node = new_node; 378 *return_node = new_node;
387 379
388 return_ACPI_STATUS (AE_OK); 380 return_ACPI_STATUS(AE_OK);
389} 381}
390
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index c53b82e94ce3..ebec036423c9 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -42,28 +42,21 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49#include <acpi/actables.h> 48#include <acpi/actables.h>
50 49
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsutils") 51ACPI_MODULE_NAME("nsutils")
53 52
54/* Local prototypes */ 53/* Local prototypes */
55 54static u8 acpi_ns_valid_path_separator(char sep);
56static u8
57acpi_ns_valid_path_separator (
58 char sep);
59 55
60#ifdef ACPI_OBSOLETE_FUNCTIONS 56#ifdef ACPI_OBSOLETE_FUNCTIONS
61acpi_name 57acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
62acpi_ns_find_parent_name (
63 struct acpi_namespace_node *node_to_search);
64#endif 58#endif
65 59
66
67/******************************************************************************* 60/*******************************************************************************
68 * 61 *
69 * FUNCTION: acpi_ns_report_error 62 * FUNCTION: acpi_ns_report_error
@@ -81,51 +74,45 @@ acpi_ns_find_parent_name (
81 ******************************************************************************/ 74 ******************************************************************************/
82 75
83void 76void
84acpi_ns_report_error ( 77acpi_ns_report_error(char *module_name,
85 char *module_name, 78 u32 line_number,
86 u32 line_number, 79 u32 component_id,
87 u32 component_id, 80 char *internal_name, acpi_status lookup_status)
88 char *internal_name,
89 acpi_status lookup_status)
90{ 81{
91 acpi_status status; 82 acpi_status status;
92 char *name = NULL; 83 char *name = NULL;
93
94 84
95 acpi_os_printf ("%8s-%04d: *** Error: Looking up ", 85 acpi_os_printf("%8s-%04d: *** Error: Looking up ",
96 module_name, line_number); 86 module_name, line_number);
97 87
98 if (lookup_status == AE_BAD_CHARACTER) { 88 if (lookup_status == AE_BAD_CHARACTER) {
99 /* There is a non-ascii character in the name */ 89 /* There is a non-ascii character in the name */
100 90
101 acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n", 91 acpi_os_printf("[0x%4.4X] (NON-ASCII)\n",
102 *(ACPI_CAST_PTR (u32, internal_name))); 92 *(ACPI_CAST_PTR(u32, internal_name)));
103 } 93 } else {
104 else {
105 /* Convert path to external format */ 94 /* Convert path to external format */
106 95
107 status = acpi_ns_externalize_name (ACPI_UINT32_MAX, 96 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
108 internal_name, NULL, &name); 97 internal_name, NULL, &name);
109 98
110 /* Print target name */ 99 /* Print target name */
111 100
112 if (ACPI_SUCCESS (status)) { 101 if (ACPI_SUCCESS(status)) {
113 acpi_os_printf ("[%s]", name); 102 acpi_os_printf("[%s]", name);
114 } 103 } else {
115 else { 104 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
116 acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]");
117 } 105 }
118 106
119 if (name) { 107 if (name) {
120 ACPI_MEM_FREE (name); 108 ACPI_MEM_FREE(name);
121 } 109 }
122 } 110 }
123 111
124 acpi_os_printf (" in namespace, %s\n", 112 acpi_os_printf(" in namespace, %s\n",
125 acpi_format_exception (lookup_status)); 113 acpi_format_exception(lookup_status));
126} 114}
127 115
128
129/******************************************************************************* 116/*******************************************************************************
130 * 117 *
131 * FUNCTION: acpi_ns_report_method_error 118 * FUNCTION: acpi_ns_report_method_error
@@ -145,34 +132,31 @@ acpi_ns_report_error (
145 ******************************************************************************/ 132 ******************************************************************************/
146 133
147void 134void
148acpi_ns_report_method_error ( 135acpi_ns_report_method_error(char *module_name,
149 char *module_name, 136 u32 line_number,
150 u32 line_number, 137 u32 component_id,
151 u32 component_id, 138 char *message,
152 char *message, 139 struct acpi_namespace_node *prefix_node,
153 struct acpi_namespace_node *prefix_node, 140 char *path, acpi_status method_status)
154 char *path,
155 acpi_status method_status)
156{ 141{
157 acpi_status status; 142 acpi_status status;
158 struct acpi_namespace_node *node = prefix_node; 143 struct acpi_namespace_node *node = prefix_node;
159
160 144
161 if (path) { 145 if (path) {
162 status = acpi_ns_get_node_by_path (path, prefix_node, 146 status = acpi_ns_get_node_by_path(path, prefix_node,
163 ACPI_NS_NO_UPSEARCH, &node); 147 ACPI_NS_NO_UPSEARCH, &node);
164 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
165 acpi_os_printf ("report_method_error: Could not get node\n"); 149 acpi_os_printf
150 ("report_method_error: Could not get node\n");
166 return; 151 return;
167 } 152 }
168 } 153 }
169 154
170 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 155 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
171 acpi_ns_print_node_pathname (node, message); 156 acpi_ns_print_node_pathname(node, message);
172 acpi_os_printf (", %s\n", acpi_format_exception (method_status)); 157 acpi_os_printf(", %s\n", acpi_format_exception(method_status));
173} 158}
174 159
175
176/******************************************************************************* 160/*******************************************************************************
177 * 161 *
178 * FUNCTION: acpi_ns_print_node_pathname 162 * FUNCTION: acpi_ns_print_node_pathname
@@ -186,16 +170,13 @@ acpi_ns_report_method_error (
186 ******************************************************************************/ 170 ******************************************************************************/
187 171
188void 172void
189acpi_ns_print_node_pathname ( 173acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *message)
190 struct acpi_namespace_node *node,
191 char *message)
192{ 174{
193 struct acpi_buffer buffer; 175 struct acpi_buffer buffer;
194 acpi_status status; 176 acpi_status status;
195
196 177
197 if (!node) { 178 if (!node) {
198 acpi_os_printf ("[NULL NAME]"); 179 acpi_os_printf("[NULL NAME]");
199 return; 180 return;
200 } 181 }
201 182
@@ -203,18 +184,17 @@ acpi_ns_print_node_pathname (
203 184
204 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 185 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
205 186
206 status = acpi_ns_handle_to_pathname (node, &buffer); 187 status = acpi_ns_handle_to_pathname(node, &buffer);
207 if (ACPI_SUCCESS (status)) { 188 if (ACPI_SUCCESS(status)) {
208 if (message) { 189 if (message) {
209 acpi_os_printf ("%s ", message); 190 acpi_os_printf("%s ", message);
210 } 191 }
211 192
212 acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node); 193 acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
213 ACPI_MEM_FREE (buffer.pointer); 194 ACPI_MEM_FREE(buffer.pointer);
214 } 195 }
215} 196}
216 197
217
218/******************************************************************************* 198/*******************************************************************************
219 * 199 *
220 * FUNCTION: acpi_ns_valid_root_prefix 200 * FUNCTION: acpi_ns_valid_root_prefix
@@ -227,15 +207,12 @@ acpi_ns_print_node_pathname (
227 * 207 *
228 ******************************************************************************/ 208 ******************************************************************************/
229 209
230u8 210u8 acpi_ns_valid_root_prefix(char prefix)
231acpi_ns_valid_root_prefix (
232 char prefix)
233{ 211{
234 212
235 return ((u8) (prefix == '\\')); 213 return ((u8) (prefix == '\\'));
236} 214}
237 215
238
239/******************************************************************************* 216/*******************************************************************************
240 * 217 *
241 * FUNCTION: acpi_ns_valid_path_separator 218 * FUNCTION: acpi_ns_valid_path_separator
@@ -248,15 +225,12 @@ acpi_ns_valid_root_prefix (
248 * 225 *
249 ******************************************************************************/ 226 ******************************************************************************/
250 227
251static u8 228static u8 acpi_ns_valid_path_separator(char sep)
252acpi_ns_valid_path_separator (
253 char sep)
254{ 229{
255 230
256 return ((u8) (sep == '.')); 231 return ((u8) (sep == '.'));
257} 232}
258 233
259
260/******************************************************************************* 234/*******************************************************************************
261 * 235 *
262 * FUNCTION: acpi_ns_get_type 236 * FUNCTION: acpi_ns_get_type
@@ -269,22 +243,18 @@ acpi_ns_valid_path_separator (
269 * 243 *
270 ******************************************************************************/ 244 ******************************************************************************/
271 245
272acpi_object_type 246acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
273acpi_ns_get_type (
274 struct acpi_namespace_node *node)
275{ 247{
276 ACPI_FUNCTION_TRACE ("ns_get_type"); 248 ACPI_FUNCTION_TRACE("ns_get_type");
277
278 249
279 if (!node) { 250 if (!node) {
280 ACPI_REPORT_WARNING (("ns_get_type: Null Node input pointer\n")); 251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n"));
281 return_VALUE (ACPI_TYPE_ANY); 252 return_VALUE(ACPI_TYPE_ANY);
282 } 253 }
283 254
284 return_VALUE ((acpi_object_type) node->type); 255 return_VALUE((acpi_object_type) node->type);
285} 256}
286 257
287
288/******************************************************************************* 258/*******************************************************************************
289 * 259 *
290 * FUNCTION: acpi_ns_local 260 * FUNCTION: acpi_ns_local
@@ -298,24 +268,20 @@ acpi_ns_get_type (
298 * 268 *
299 ******************************************************************************/ 269 ******************************************************************************/
300 270
301u32 271u32 acpi_ns_local(acpi_object_type type)
302acpi_ns_local (
303 acpi_object_type type)
304{ 272{
305 ACPI_FUNCTION_TRACE ("ns_local"); 273 ACPI_FUNCTION_TRACE("ns_local");
306
307 274
308 if (!acpi_ut_valid_object_type (type)) { 275 if (!acpi_ut_valid_object_type(type)) {
309 /* Type code out of range */ 276 /* Type code out of range */
310 277
311 ACPI_REPORT_WARNING (("ns_local: Invalid Object Type\n")); 278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n"));
312 return_VALUE (ACPI_NS_NORMAL); 279 return_VALUE(ACPI_NS_NORMAL);
313 } 280 }
314 281
315 return_VALUE ((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 282 return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
316} 283}
317 284
318
319/******************************************************************************* 285/*******************************************************************************
320 * 286 *
321 * FUNCTION: acpi_ns_get_internal_name_length 287 * FUNCTION: acpi_ns_get_internal_name_length
@@ -330,16 +296,12 @@ acpi_ns_local (
330 * 296 *
331 ******************************************************************************/ 297 ******************************************************************************/
332 298
333void 299void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
334acpi_ns_get_internal_name_length (
335 struct acpi_namestring_info *info)
336{ 300{
337 char *next_external_char; 301 char *next_external_char;
338 u32 i; 302 u32 i;
339
340
341 ACPI_FUNCTION_ENTRY ();
342 303
304 ACPI_FUNCTION_ENTRY();
343 305
344 next_external_char = info->external_name; 306 next_external_char = info->external_name;
345 info->num_carats = 0; 307 info->num_carats = 0;
@@ -353,11 +315,10 @@ acpi_ns_get_internal_name_length (
353 * 315 *
354 * strlen() + 1 covers the first name_seg, which has no path separator 316 * strlen() + 1 covers the first name_seg, which has no path separator
355 */ 317 */
356 if (acpi_ns_valid_root_prefix (next_external_char[0])) { 318 if (acpi_ns_valid_root_prefix(next_external_char[0])) {
357 info->fully_qualified = TRUE; 319 info->fully_qualified = TRUE;
358 next_external_char++; 320 next_external_char++;
359 } 321 } else {
360 else {
361 /* 322 /*
362 * Handle Carat prefixes 323 * Handle Carat prefixes
363 */ 324 */
@@ -375,19 +336,18 @@ acpi_ns_get_internal_name_length (
375 if (*next_external_char) { 336 if (*next_external_char) {
376 info->num_segments = 1; 337 info->num_segments = 1;
377 for (i = 0; next_external_char[i]; i++) { 338 for (i = 0; next_external_char[i]; i++) {
378 if (acpi_ns_valid_path_separator (next_external_char[i])) { 339 if (acpi_ns_valid_path_separator(next_external_char[i])) {
379 info->num_segments++; 340 info->num_segments++;
380 } 341 }
381 } 342 }
382 } 343 }
383 344
384 info->length = (ACPI_NAME_SIZE * info->num_segments) + 345 info->length = (ACPI_NAME_SIZE * info->num_segments) +
385 4 + info->num_carats; 346 4 + info->num_carats;
386 347
387 info->next_external_char = next_external_char; 348 info->next_external_char = next_external_char;
388} 349}
389 350
390
391/******************************************************************************* 351/*******************************************************************************
392 * 352 *
393 * FUNCTION: acpi_ns_build_internal_name 353 * FUNCTION: acpi_ns_build_internal_name
@@ -401,19 +361,15 @@ acpi_ns_get_internal_name_length (
401 * 361 *
402 ******************************************************************************/ 362 ******************************************************************************/
403 363
404acpi_status 364acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
405acpi_ns_build_internal_name (
406 struct acpi_namestring_info *info)
407{ 365{
408 u32 num_segments = info->num_segments; 366 u32 num_segments = info->num_segments;
409 char *internal_name = info->internal_name; 367 char *internal_name = info->internal_name;
410 char *external_name = info->next_external_char; 368 char *external_name = info->next_external_char;
411 char *result = NULL; 369 char *result = NULL;
412 acpi_native_uint i; 370 acpi_native_uint i;
413
414
415 ACPI_FUNCTION_TRACE ("ns_build_internal_name");
416 371
372 ACPI_FUNCTION_TRACE("ns_build_internal_name");
417 373
418 /* Setup the correct prefixes, counts, and pointers */ 374 /* Setup the correct prefixes, counts, and pointers */
419 375
@@ -422,18 +378,15 @@ acpi_ns_build_internal_name (
422 378
423 if (num_segments <= 1) { 379 if (num_segments <= 1) {
424 result = &internal_name[1]; 380 result = &internal_name[1];
425 } 381 } else if (num_segments == 2) {
426 else if (num_segments == 2) {
427 internal_name[1] = AML_DUAL_NAME_PREFIX; 382 internal_name[1] = AML_DUAL_NAME_PREFIX;
428 result = &internal_name[2]; 383 result = &internal_name[2];
429 } 384 } else {
430 else {
431 internal_name[1] = AML_MULTI_NAME_PREFIX_OP; 385 internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
432 internal_name[2] = (char) num_segments; 386 internal_name[2] = (char)num_segments;
433 result = &internal_name[3]; 387 result = &internal_name[3];
434 } 388 }
435 } 389 } else {
436 else {
437 /* 390 /*
438 * Not fully qualified. 391 * Not fully qualified.
439 * Handle Carats first, then append the name segments 392 * Handle Carats first, then append the name segments
@@ -447,15 +400,14 @@ acpi_ns_build_internal_name (
447 400
448 if (num_segments <= 1) { 401 if (num_segments <= 1) {
449 result = &internal_name[i]; 402 result = &internal_name[i];
450 } 403 } else if (num_segments == 2) {
451 else if (num_segments == 2) {
452 internal_name[i] = AML_DUAL_NAME_PREFIX; 404 internal_name[i] = AML_DUAL_NAME_PREFIX;
453 result = &internal_name[(acpi_native_uint) (i+1)]; 405 result = &internal_name[(acpi_native_uint) (i + 1)];
454 } 406 } else {
455 else {
456 internal_name[i] = AML_MULTI_NAME_PREFIX_OP; 407 internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
457 internal_name[(acpi_native_uint) (i+1)] = (char) num_segments; 408 internal_name[(acpi_native_uint) (i + 1)] =
458 result = &internal_name[(acpi_native_uint) (i+2)]; 409 (char)num_segments;
410 result = &internal_name[(acpi_native_uint) (i + 2)];
459 } 411 }
460 } 412 }
461 413
@@ -463,25 +415,25 @@ acpi_ns_build_internal_name (
463 415
464 for (; num_segments; num_segments--) { 416 for (; num_segments; num_segments--) {
465 for (i = 0; i < ACPI_NAME_SIZE; i++) { 417 for (i = 0; i < ACPI_NAME_SIZE; i++) {
466 if (acpi_ns_valid_path_separator (*external_name) || 418 if (acpi_ns_valid_path_separator(*external_name) ||
467 (*external_name == 0)) { 419 (*external_name == 0)) {
468 /* Pad the segment with underscore(s) if segment is short */ 420 /* Pad the segment with underscore(s) if segment is short */
469 421
470 result[i] = '_'; 422 result[i] = '_';
471 } 423 } else {
472 else {
473 /* Convert the character to uppercase and save it */ 424 /* Convert the character to uppercase and save it */
474 425
475 result[i] = (char) ACPI_TOUPPER ((int) *external_name); 426 result[i] =
427 (char)ACPI_TOUPPER((int)*external_name);
476 external_name++; 428 external_name++;
477 } 429 }
478 } 430 }
479 431
480 /* Now we must have a path separator, or the pathname is bad */ 432 /* Now we must have a path separator, or the pathname is bad */
481 433
482 if (!acpi_ns_valid_path_separator (*external_name) && 434 if (!acpi_ns_valid_path_separator(*external_name) &&
483 (*external_name != 0)) { 435 (*external_name != 0)) {
484 return_ACPI_STATUS (AE_BAD_PARAMETER); 436 return_ACPI_STATUS(AE_BAD_PARAMETER);
485 } 437 }
486 438
487 /* Move on the next segment */ 439 /* Move on the next segment */
@@ -495,18 +447,17 @@ acpi_ns_build_internal_name (
495 *result = 0; 447 *result = 0;
496 448
497 if (info->fully_qualified) { 449 if (info->fully_qualified) {
498 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", 450 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
499 internal_name, internal_name)); 451 "Returning [%p] (abs) \"\\%s\"\n",
500 } 452 internal_name, internal_name));
501 else { 453 } else {
502 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", 454 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
503 internal_name, internal_name)); 455 internal_name, internal_name));
504 } 456 }
505 457
506 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS(AE_OK);
507} 459}
508 460
509
510/******************************************************************************* 461/*******************************************************************************
511 * 462 *
512 * FUNCTION: acpi_ns_internalize_name 463 * FUNCTION: acpi_ns_internalize_name
@@ -522,51 +473,43 @@ acpi_ns_build_internal_name (
522 * 473 *
523 *******************************************************************************/ 474 *******************************************************************************/
524 475
525acpi_status 476acpi_status acpi_ns_internalize_name(char *external_name, char **converted_name)
526acpi_ns_internalize_name (
527 char *external_name,
528 char **converted_name)
529{ 477{
530 char *internal_name; 478 char *internal_name;
531 struct acpi_namestring_info info; 479 struct acpi_namestring_info info;
532 acpi_status status; 480 acpi_status status;
533
534
535 ACPI_FUNCTION_TRACE ("ns_internalize_name");
536 481
482 ACPI_FUNCTION_TRACE("ns_internalize_name");
537 483
538 if ((!external_name) || 484 if ((!external_name) || (*external_name == 0) || (!converted_name)) {
539 (*external_name == 0) || 485 return_ACPI_STATUS(AE_BAD_PARAMETER);
540 (!converted_name)) {
541 return_ACPI_STATUS (AE_BAD_PARAMETER);
542 } 486 }
543 487
544 /* Get the length of the new internal name */ 488 /* Get the length of the new internal name */
545 489
546 info.external_name = external_name; 490 info.external_name = external_name;
547 acpi_ns_get_internal_name_length (&info); 491 acpi_ns_get_internal_name_length(&info);
548 492
549 /* We need a segment to store the internal name */ 493 /* We need a segment to store the internal name */
550 494
551 internal_name = ACPI_MEM_CALLOCATE (info.length); 495 internal_name = ACPI_MEM_CALLOCATE(info.length);
552 if (!internal_name) { 496 if (!internal_name) {
553 return_ACPI_STATUS (AE_NO_MEMORY); 497 return_ACPI_STATUS(AE_NO_MEMORY);
554 } 498 }
555 499
556 /* Build the name */ 500 /* Build the name */
557 501
558 info.internal_name = internal_name; 502 info.internal_name = internal_name;
559 status = acpi_ns_build_internal_name (&info); 503 status = acpi_ns_build_internal_name(&info);
560 if (ACPI_FAILURE (status)) { 504 if (ACPI_FAILURE(status)) {
561 ACPI_MEM_FREE (internal_name); 505 ACPI_MEM_FREE(internal_name);
562 return_ACPI_STATUS (status); 506 return_ACPI_STATUS(status);
563 } 507 }
564 508
565 *converted_name = internal_name; 509 *converted_name = internal_name;
566 return_ACPI_STATUS (AE_OK); 510 return_ACPI_STATUS(AE_OK);
567} 511}
568 512
569
570/******************************************************************************* 513/*******************************************************************************
571 * 514 *
572 * FUNCTION: acpi_ns_externalize_name 515 * FUNCTION: acpi_ns_externalize_name
@@ -585,27 +528,21 @@ acpi_ns_internalize_name (
585 ******************************************************************************/ 528 ******************************************************************************/
586 529
587acpi_status 530acpi_status
588acpi_ns_externalize_name ( 531acpi_ns_externalize_name(u32 internal_name_length,
589 u32 internal_name_length, 532 char *internal_name,
590 char *internal_name, 533 u32 * converted_name_length, char **converted_name)
591 u32 *converted_name_length,
592 char **converted_name)
593{ 534{
594 acpi_native_uint names_index = 0; 535 acpi_native_uint names_index = 0;
595 acpi_native_uint num_segments = 0; 536 acpi_native_uint num_segments = 0;
596 acpi_native_uint required_length; 537 acpi_native_uint required_length;
597 acpi_native_uint prefix_length = 0; 538 acpi_native_uint prefix_length = 0;
598 acpi_native_uint i = 0; 539 acpi_native_uint i = 0;
599 acpi_native_uint j = 0; 540 acpi_native_uint j = 0;
600
601 541
602 ACPI_FUNCTION_TRACE ("ns_externalize_name"); 542 ACPI_FUNCTION_TRACE("ns_externalize_name");
603 543
604 544 if (!internal_name_length || !internal_name || !converted_name) {
605 if (!internal_name_length || 545 return_ACPI_STATUS(AE_BAD_PARAMETER);
606 !internal_name ||
607 !converted_name) {
608 return_ACPI_STATUS (AE_BAD_PARAMETER);
609 } 546 }
610 547
611 /* 548 /*
@@ -620,8 +557,7 @@ acpi_ns_externalize_name (
620 for (i = 0; i < internal_name_length; i++) { 557 for (i = 0; i < internal_name_length; i++) {
621 if (internal_name[i] == '^') { 558 if (internal_name[i] == '^') {
622 prefix_length = i + 1; 559 prefix_length = i + 1;
623 } 560 } else {
624 else {
625 break; 561 break;
626 } 562 }
627 } 563 }
@@ -648,7 +584,8 @@ acpi_ns_externalize_name (
648 584
649 names_index = prefix_length + 2; 585 names_index = prefix_length + 2;
650 num_segments = (acpi_native_uint) (u8) 586 num_segments = (acpi_native_uint) (u8)
651 internal_name[(acpi_native_uint) (prefix_length + 1)]; 587 internal_name[(acpi_native_uint)
588 (prefix_length + 1)];
652 break; 589 break;
653 590
654 case AML_DUAL_NAME_PREFIX: 591 case AML_DUAL_NAME_PREFIX:
@@ -683,23 +620,23 @@ acpi_ns_externalize_name (
683 * punctuation ('.') between object names, plus the NULL terminator. 620 * punctuation ('.') between object names, plus the NULL terminator.
684 */ 621 */
685 required_length = prefix_length + (4 * num_segments) + 622 required_length = prefix_length + (4 * num_segments) +
686 ((num_segments > 0) ? (num_segments - 1) : 0) + 1; 623 ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
687 624
688 /* 625 /*
689 * Check to see if we're still in bounds. If not, there's a problem 626 * Check to see if we're still in bounds. If not, there's a problem
690 * with internal_name (invalid format). 627 * with internal_name (invalid format).
691 */ 628 */
692 if (required_length > internal_name_length) { 629 if (required_length > internal_name_length) {
693 ACPI_REPORT_ERROR (("ns_externalize_name: Invalid internal name\n")); 630 ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n"));
694 return_ACPI_STATUS (AE_BAD_PATHNAME); 631 return_ACPI_STATUS(AE_BAD_PATHNAME);
695 } 632 }
696 633
697 /* 634 /*
698 * Build converted_name 635 * Build converted_name
699 */ 636 */
700 *converted_name = ACPI_MEM_CALLOCATE (required_length); 637 *converted_name = ACPI_MEM_CALLOCATE(required_length);
701 if (!(*converted_name)) { 638 if (!(*converted_name)) {
702 return_ACPI_STATUS (AE_NO_MEMORY); 639 return_ACPI_STATUS(AE_NO_MEMORY);
703 } 640 }
704 641
705 j = 0; 642 j = 0;
@@ -725,10 +662,9 @@ acpi_ns_externalize_name (
725 *converted_name_length = (u32) required_length; 662 *converted_name_length = (u32) required_length;
726 } 663 }
727 664
728 return_ACPI_STATUS (AE_OK); 665 return_ACPI_STATUS(AE_OK);
729} 666}
730 667
731
732/******************************************************************************* 668/*******************************************************************************
733 * 669 *
734 * FUNCTION: acpi_ns_map_handle_to_node 670 * FUNCTION: acpi_ns_map_handle_to_node
@@ -745,13 +681,10 @@ acpi_ns_externalize_name (
745 * 681 *
746 ******************************************************************************/ 682 ******************************************************************************/
747 683
748struct acpi_namespace_node * 684struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
749acpi_ns_map_handle_to_node (
750 acpi_handle handle)
751{ 685{
752 686
753 ACPI_FUNCTION_ENTRY (); 687 ACPI_FUNCTION_ENTRY();
754
755 688
756 /* 689 /*
757 * Simple implementation. 690 * Simple implementation.
@@ -766,14 +699,13 @@ acpi_ns_map_handle_to_node (
766 699
767 /* We can at least attempt to verify the handle */ 700 /* We can at least attempt to verify the handle */
768 701
769 if (ACPI_GET_DESCRIPTOR_TYPE (handle) != ACPI_DESC_TYPE_NAMED) { 702 if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
770 return (NULL); 703 return (NULL);
771 } 704 }
772 705
773 return ((struct acpi_namespace_node *) handle); 706 return ((struct acpi_namespace_node *)handle);
774} 707}
775 708
776
777/******************************************************************************* 709/*******************************************************************************
778 * 710 *
779 * FUNCTION: acpi_ns_convert_entry_to_handle 711 * FUNCTION: acpi_ns_convert_entry_to_handle
@@ -786,18 +718,14 @@ acpi_ns_map_handle_to_node (
786 * 718 *
787 ******************************************************************************/ 719 ******************************************************************************/
788 720
789acpi_handle 721acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
790acpi_ns_convert_entry_to_handle (
791 struct acpi_namespace_node *node)
792{ 722{
793 723
794
795 /* 724 /*
796 * Simple implementation for now; 725 * Simple implementation for now;
797 */ 726 */
798 return ((acpi_handle) node); 727 return ((acpi_handle) node);
799 728
800
801/* Example future implementation --------------------- 729/* Example future implementation ---------------------
802 730
803 if (!Node) 731 if (!Node)
@@ -810,12 +738,10 @@ acpi_ns_convert_entry_to_handle (
810 return (ACPI_ROOT_OBJECT); 738 return (ACPI_ROOT_OBJECT);
811 } 739 }
812 740
813
814 return ((acpi_handle) Node); 741 return ((acpi_handle) Node);
815------------------------------------------------------*/ 742------------------------------------------------------*/
816} 743}
817 744
818
819/******************************************************************************* 745/*******************************************************************************
820 * 746 *
821 * FUNCTION: acpi_ns_terminate 747 * FUNCTION: acpi_ns_terminate
@@ -828,42 +754,37 @@ acpi_ns_convert_entry_to_handle (
828 * 754 *
829 ******************************************************************************/ 755 ******************************************************************************/
830 756
831void 757void acpi_ns_terminate(void)
832acpi_ns_terminate (
833 void)
834{ 758{
835 union acpi_operand_object *obj_desc; 759 union acpi_operand_object *obj_desc;
836
837
838 ACPI_FUNCTION_TRACE ("ns_terminate");
839 760
761 ACPI_FUNCTION_TRACE("ns_terminate");
840 762
841 /* 763 /*
842 * 1) Free the entire namespace -- all nodes and objects 764 * 1) Free the entire namespace -- all nodes and objects
843 * 765 *
844 * Delete all object descriptors attached to namepsace nodes 766 * Delete all object descriptors attached to namepsace nodes
845 */ 767 */
846 acpi_ns_delete_namespace_subtree (acpi_gbl_root_node); 768 acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
847 769
848 /* Detach any objects attached to the root */ 770 /* Detach any objects attached to the root */
849 771
850 obj_desc = acpi_ns_get_attached_object (acpi_gbl_root_node); 772 obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
851 if (obj_desc) { 773 if (obj_desc) {
852 acpi_ns_detach_object (acpi_gbl_root_node); 774 acpi_ns_detach_object(acpi_gbl_root_node);
853 } 775 }
854 776
855 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); 777 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
856 778
857 /* 779 /*
858 * 2) Now we can delete the ACPI tables 780 * 2) Now we can delete the ACPI tables
859 */ 781 */
860 acpi_tb_delete_all_tables (); 782 acpi_tb_delete_all_tables();
861 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); 783 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
862 784
863 return_VOID; 785 return_VOID;
864} 786}
865 787
866
867/******************************************************************************* 788/*******************************************************************************
868 * 789 *
869 * FUNCTION: acpi_ns_opens_scope 790 * FUNCTION: acpi_ns_opens_scope
@@ -875,24 +796,21 @@ acpi_ns_terminate (
875 * 796 *
876 ******************************************************************************/ 797 ******************************************************************************/
877 798
878u32 799u32 acpi_ns_opens_scope(acpi_object_type type)
879acpi_ns_opens_scope (
880 acpi_object_type type)
881{ 800{
882 ACPI_FUNCTION_TRACE_STR ("ns_opens_scope", acpi_ut_get_type_name (type)); 801 ACPI_FUNCTION_TRACE_STR("ns_opens_scope", acpi_ut_get_type_name(type));
883
884 802
885 if (!acpi_ut_valid_object_type (type)) { 803 if (!acpi_ut_valid_object_type(type)) {
886 /* type code out of range */ 804 /* type code out of range */
887 805
888 ACPI_REPORT_WARNING (("ns_opens_scope: Invalid Object Type %X\n", type)); 806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n",
889 return_VALUE (ACPI_NS_NORMAL); 807 type));
808 return_VALUE(ACPI_NS_NORMAL);
890 } 809 }
891 810
892 return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 811 return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
893} 812}
894 813
895
896/******************************************************************************* 814/*******************************************************************************
897 * 815 *
898 * FUNCTION: acpi_ns_get_node_by_path 816 * FUNCTION: acpi_ns_get_node_by_path
@@ -916,33 +834,29 @@ acpi_ns_opens_scope (
916 ******************************************************************************/ 834 ******************************************************************************/
917 835
918acpi_status 836acpi_status
919acpi_ns_get_node_by_path ( 837acpi_ns_get_node_by_path(char *pathname,
920 char *pathname, 838 struct acpi_namespace_node *start_node,
921 struct acpi_namespace_node *start_node, 839 u32 flags, struct acpi_namespace_node **return_node)
922 u32 flags,
923 struct acpi_namespace_node **return_node)
924{ 840{
925 union acpi_generic_state scope_info; 841 union acpi_generic_state scope_info;
926 acpi_status status; 842 acpi_status status;
927 char *internal_path = NULL; 843 char *internal_path = NULL;
928
929
930 ACPI_FUNCTION_TRACE_PTR ("ns_get_node_by_path", pathname);
931 844
845 ACPI_FUNCTION_TRACE_PTR("ns_get_node_by_path", pathname);
932 846
933 if (pathname) { 847 if (pathname) {
934 /* Convert path to internal representation */ 848 /* Convert path to internal representation */
935 849
936 status = acpi_ns_internalize_name (pathname, &internal_path); 850 status = acpi_ns_internalize_name(pathname, &internal_path);
937 if (ACPI_FAILURE (status)) { 851 if (ACPI_FAILURE(status)) {
938 return_ACPI_STATUS (status); 852 return_ACPI_STATUS(status);
939 } 853 }
940 } 854 }
941 855
942 /* Must lock namespace during lookup */ 856 /* Must lock namespace during lookup */
943 857
944 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 858 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
945 if (ACPI_FAILURE (status)) { 859 if (ACPI_FAILURE(status)) {
946 goto cleanup; 860 goto cleanup;
947 } 861 }
948 862
@@ -952,25 +866,25 @@ acpi_ns_get_node_by_path (
952 866
953 /* Lookup the name in the namespace */ 867 /* Lookup the name in the namespace */
954 868
955 status = acpi_ns_lookup (&scope_info, internal_path, 869 status = acpi_ns_lookup(&scope_info, internal_path,
956 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 870 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
957 (flags | ACPI_NS_DONT_OPEN_SCOPE), 871 (flags | ACPI_NS_DONT_OPEN_SCOPE),
958 NULL, return_node); 872 NULL, return_node);
959 if (ACPI_FAILURE (status)) { 873 if (ACPI_FAILURE(status)) {
960 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", 874 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n",
961 internal_path, acpi_format_exception (status))); 875 internal_path,
876 acpi_format_exception(status)));
962 } 877 }
963 878
964 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 879 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
965 880
966cleanup: 881 cleanup:
967 if (internal_path) { 882 if (internal_path) {
968 ACPI_MEM_FREE (internal_path); 883 ACPI_MEM_FREE(internal_path);
969 } 884 }
970 return_ACPI_STATUS (status); 885 return_ACPI_STATUS(status);
971} 886}
972 887
973
974/******************************************************************************* 888/*******************************************************************************
975 * 889 *
976 * FUNCTION: acpi_ns_get_parent_node 890 * FUNCTION: acpi_ns_get_parent_node
@@ -983,12 +897,10 @@ cleanup:
983 * 897 *
984 ******************************************************************************/ 898 ******************************************************************************/
985 899
986struct acpi_namespace_node * 900struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
987acpi_ns_get_parent_node ( 901 *node)
988 struct acpi_namespace_node *node)
989{ 902{
990 ACPI_FUNCTION_ENTRY (); 903 ACPI_FUNCTION_ENTRY();
991
992 904
993 if (!node) { 905 if (!node) {
994 return (NULL); 906 return (NULL);
@@ -1006,7 +918,6 @@ acpi_ns_get_parent_node (
1006 return (node->peer); 918 return (node->peer);
1007} 919}
1008 920
1009
1010/******************************************************************************* 921/*******************************************************************************
1011 * 922 *
1012 * FUNCTION: acpi_ns_get_next_valid_node 923 * FUNCTION: acpi_ns_get_next_valid_node
@@ -1021,9 +932,9 @@ acpi_ns_get_parent_node (
1021 * 932 *
1022 ******************************************************************************/ 933 ******************************************************************************/
1023 934
1024struct acpi_namespace_node * 935struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
1025acpi_ns_get_next_valid_node ( 936 acpi_namespace_node
1026 struct acpi_namespace_node *node) 937 *node)
1027{ 938{
1028 939
1029 /* If we are at the end of this peer list, return NULL */ 940 /* If we are at the end of this peer list, return NULL */
@@ -1037,7 +948,6 @@ acpi_ns_get_next_valid_node (
1037 return (node->peer); 948 return (node->peer);
1038} 949}
1039 950
1040
1041#ifdef ACPI_OBSOLETE_FUNCTIONS 951#ifdef ACPI_OBSOLETE_FUNCTIONS
1042/******************************************************************************* 952/*******************************************************************************
1043 * 953 *
@@ -1053,38 +963,36 @@ acpi_ns_get_next_valid_node (
1053 * 963 *
1054 ******************************************************************************/ 964 ******************************************************************************/
1055 965
1056acpi_name 966acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node)
1057acpi_ns_find_parent_name (
1058 struct acpi_namespace_node *child_node)
1059{ 967{
1060 struct acpi_namespace_node *parent_node; 968 struct acpi_namespace_node *parent_node;
1061
1062
1063 ACPI_FUNCTION_TRACE ("ns_find_parent_name");
1064 969
970 ACPI_FUNCTION_TRACE("ns_find_parent_name");
1065 971
1066 if (child_node) { 972 if (child_node) {
1067 /* Valid entry. Get the parent Node */ 973 /* Valid entry. Get the parent Node */
1068 974
1069 parent_node = acpi_ns_get_parent_node (child_node); 975 parent_node = acpi_ns_get_parent_node(child_node);
1070 if (parent_node) { 976 if (parent_node) {
1071 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 977 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1072 "Parent of %p [%4.4s] is %p [%4.4s]\n", 978 "Parent of %p [%4.4s] is %p [%4.4s]\n",
1073 child_node, acpi_ut_get_node_name (child_node), 979 child_node,
1074 parent_node, acpi_ut_get_node_name (parent_node))); 980 acpi_ut_get_node_name(child_node),
981 parent_node,
982 acpi_ut_get_node_name(parent_node)));
1075 983
1076 if (parent_node->name.integer) { 984 if (parent_node->name.integer) {
1077 return_VALUE ((acpi_name) parent_node->name.integer); 985 return_VALUE((acpi_name) parent_node->name.
986 integer);
1078 } 987 }
1079 } 988 }
1080 989
1081 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 990 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1082 "Unable to find parent of %p (%4.4s)\n", 991 "Unable to find parent of %p (%4.4s)\n",
1083 child_node, acpi_ut_get_node_name (child_node))); 992 child_node,
993 acpi_ut_get_node_name(child_node)));
1084 } 994 }
1085 995
1086 return_VALUE (ACPI_UNKNOWN_NAME); 996 return_VALUE(ACPI_UNKNOWN_NAME);
1087} 997}
1088#endif 998#endif
1089
1090
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index f9a7277dca6e..5f164c0df33b 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nswalk") 48ACPI_MODULE_NAME("nswalk")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -68,18 +65,15 @@
68 * within Scope is returned. 65 * within Scope is returned.
69 * 66 *
70 ******************************************************************************/ 67 ******************************************************************************/
71 68struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type,
72struct acpi_namespace_node * 69 struct acpi_namespace_node
73acpi_ns_get_next_node ( 70 *parent_node,
74 acpi_object_type type, 71 struct acpi_namespace_node
75 struct acpi_namespace_node *parent_node, 72 *child_node)
76 struct acpi_namespace_node *child_node)
77{ 73{
78 struct acpi_namespace_node *next_node = NULL; 74 struct acpi_namespace_node *next_node = NULL;
79
80
81 ACPI_FUNCTION_ENTRY ();
82 75
76 ACPI_FUNCTION_ENTRY();
83 77
84 if (!child_node) { 78 if (!child_node) {
85 /* It's really the parent's _scope_ that we want */ 79 /* It's really the parent's _scope_ that we want */
@@ -92,7 +86,7 @@ acpi_ns_get_next_node (
92 else { 86 else {
93 /* Start search at the NEXT node */ 87 /* Start search at the NEXT node */
94 88
95 next_node = acpi_ns_get_next_valid_node (child_node); 89 next_node = acpi_ns_get_next_valid_node(child_node);
96 } 90 }
97 91
98 /* If any type is OK, we are done */ 92 /* If any type is OK, we are done */
@@ -114,7 +108,7 @@ acpi_ns_get_next_node (
114 108
115 /* Otherwise, move on to the next node */ 109 /* Otherwise, move on to the next node */
116 110
117 next_node = acpi_ns_get_next_valid_node (next_node); 111 next_node = acpi_ns_get_next_valid_node(next_node);
118 } 112 }
119 113
120 /* Not found */ 114 /* Not found */
@@ -122,7 +116,6 @@ acpi_ns_get_next_node (
122 return (NULL); 116 return (NULL);
123} 117}
124 118
125
126/******************************************************************************* 119/*******************************************************************************
127 * 120 *
128 * FUNCTION: acpi_ns_walk_namespace 121 * FUNCTION: acpi_ns_walk_namespace
@@ -154,25 +147,21 @@ acpi_ns_get_next_node (
154 ******************************************************************************/ 147 ******************************************************************************/
155 148
156acpi_status 149acpi_status
157acpi_ns_walk_namespace ( 150acpi_ns_walk_namespace(acpi_object_type type,
158 acpi_object_type type, 151 acpi_handle start_node,
159 acpi_handle start_node, 152 u32 max_depth,
160 u32 max_depth, 153 u8 unlock_before_callback,
161 u8 unlock_before_callback, 154 acpi_walk_callback user_function,
162 acpi_walk_callback user_function, 155 void *context, void **return_value)
163 void *context,
164 void **return_value)
165{ 156{
166 acpi_status status; 157 acpi_status status;
167 acpi_status mutex_status; 158 acpi_status mutex_status;
168 struct acpi_namespace_node *child_node; 159 struct acpi_namespace_node *child_node;
169 struct acpi_namespace_node *parent_node; 160 struct acpi_namespace_node *parent_node;
170 acpi_object_type child_type; 161 acpi_object_type child_type;
171 u32 level; 162 u32 level;
172
173
174 ACPI_FUNCTION_TRACE ("ns_walk_namespace");
175 163
164 ACPI_FUNCTION_TRACE("ns_walk_namespace");
176 165
177 /* Special case for the namespace Root Node */ 166 /* Special case for the namespace Root Node */
178 167
@@ -183,9 +172,9 @@ acpi_ns_walk_namespace (
183 /* Null child means "get first node" */ 172 /* Null child means "get first node" */
184 173
185 parent_node = start_node; 174 parent_node = start_node;
186 child_node = NULL; 175 child_node = NULL;
187 child_type = ACPI_TYPE_ANY; 176 child_type = ACPI_TYPE_ANY;
188 level = 1; 177 level = 1;
189 178
190 /* 179 /*
191 * Traverse the tree of nodes until we bubble back up to where we 180 * Traverse the tree of nodes until we bubble back up to where we
@@ -196,7 +185,9 @@ acpi_ns_walk_namespace (
196 /* Get the next node in this scope. Null if not found */ 185 /* Get the next node in this scope. Null if not found */
197 186
198 status = AE_OK; 187 status = AE_OK;
199 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); 188 child_node =
189 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
190 child_node);
200 if (child_node) { 191 if (child_node) {
201 /* 192 /*
202 * Found node, Get the type if we are not 193 * Found node, Get the type if we are not
@@ -212,19 +203,25 @@ acpi_ns_walk_namespace (
212 * callback function 203 * callback function
213 */ 204 */
214 if (unlock_before_callback) { 205 if (unlock_before_callback) {
215 mutex_status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 206 mutex_status =
216 if (ACPI_FAILURE (mutex_status)) { 207 acpi_ut_release_mutex
217 return_ACPI_STATUS (mutex_status); 208 (ACPI_MTX_NAMESPACE);
209 if (ACPI_FAILURE(mutex_status)) {
210 return_ACPI_STATUS
211 (mutex_status);
218 } 212 }
219 } 213 }
220 214
221 status = user_function (child_node, level, 215 status = user_function(child_node, level,
222 context, return_value); 216 context, return_value);
223 217
224 if (unlock_before_callback) { 218 if (unlock_before_callback) {
225 mutex_status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 219 mutex_status =
226 if (ACPI_FAILURE (mutex_status)) { 220 acpi_ut_acquire_mutex
227 return_ACPI_STATUS (mutex_status); 221 (ACPI_MTX_NAMESPACE);
222 if (ACPI_FAILURE(mutex_status)) {
223 return_ACPI_STATUS
224 (mutex_status);
228 } 225 }
229 } 226 }
230 227
@@ -239,13 +236,13 @@ acpi_ns_walk_namespace (
239 236
240 /* Exit now, with OK status */ 237 /* Exit now, with OK status */
241 238
242 return_ACPI_STATUS (AE_OK); 239 return_ACPI_STATUS(AE_OK);
243 240
244 default: 241 default:
245 242
246 /* All others are valid exceptions */ 243 /* All others are valid exceptions */
247 244
248 return_ACPI_STATUS (status); 245 return_ACPI_STATUS(status);
249 } 246 }
250 } 247 }
251 248
@@ -258,7 +255,8 @@ acpi_ns_walk_namespace (
258 * maximum depth has been reached. 255 * maximum depth has been reached.
259 */ 256 */
260 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { 257 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
261 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 258 if (acpi_ns_get_next_node
259 (ACPI_TYPE_ANY, child_node, NULL)) {
262 /* 260 /*
263 * There is at least one child of this 261 * There is at least one child of this
264 * node, visit the onde 262 * node, visit the onde
@@ -268,8 +266,7 @@ acpi_ns_walk_namespace (
268 child_node = NULL; 266 child_node = NULL;
269 } 267 }
270 } 268 }
271 } 269 } else {
272 else {
273 /* 270 /*
274 * No more children of this node (acpi_ns_get_next_node 271 * No more children of this node (acpi_ns_get_next_node
275 * failed), go back upwards in the namespace tree to 272 * failed), go back upwards in the namespace tree to
@@ -277,13 +274,11 @@ acpi_ns_walk_namespace (
277 */ 274 */
278 level--; 275 level--;
279 child_node = parent_node; 276 child_node = parent_node;
280 parent_node = acpi_ns_get_parent_node (parent_node); 277 parent_node = acpi_ns_get_parent_node(parent_node);
281 } 278 }
282 } 279 }
283 280
284 /* Complete walk, not terminated by user function */ 281 /* Complete walk, not terminated by user function */
285 282
286 return_ACPI_STATUS (AE_OK); 283 return_ACPI_STATUS(AE_OK);
287} 284}
288
289
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index 12ea202257fa..c07b046659ff 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -48,10 +48,8 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
50 50
51
52#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nsxfeval") 52ACPI_MODULE_NAME("nsxfeval")
54
55 53
56/******************************************************************************* 54/*******************************************************************************
57 * 55 *
@@ -73,27 +71,23 @@
73 * be valid (non-null) 71 * be valid (non-null)
74 * 72 *
75 ******************************************************************************/ 73 ******************************************************************************/
76
77#ifdef ACPI_FUTURE_USAGE 74#ifdef ACPI_FUTURE_USAGE
78acpi_status 75acpi_status
79acpi_evaluate_object_typed ( 76acpi_evaluate_object_typed(acpi_handle handle,
80 acpi_handle handle, 77 acpi_string pathname,
81 acpi_string pathname, 78 struct acpi_object_list *external_params,
82 struct acpi_object_list *external_params, 79 struct acpi_buffer *return_buffer,
83 struct acpi_buffer *return_buffer, 80 acpi_object_type return_type)
84 acpi_object_type return_type)
85{ 81{
86 acpi_status status; 82 acpi_status status;
87 u8 must_free = FALSE; 83 u8 must_free = FALSE;
88
89
90 ACPI_FUNCTION_TRACE ("acpi_evaluate_object_typed");
91 84
85 ACPI_FUNCTION_TRACE("acpi_evaluate_object_typed");
92 86
93 /* Return buffer must be valid */ 87 /* Return buffer must be valid */
94 88
95 if (!return_buffer) { 89 if (!return_buffer) {
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 90 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 91 }
98 92
99 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { 93 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
@@ -102,51 +96,52 @@ acpi_evaluate_object_typed (
102 96
103 /* Evaluate the object */ 97 /* Evaluate the object */
104 98
105 status = acpi_evaluate_object (handle, pathname, external_params, return_buffer); 99 status =
106 if (ACPI_FAILURE (status)) { 100 acpi_evaluate_object(handle, pathname, external_params,
107 return_ACPI_STATUS (status); 101 return_buffer);
102 if (ACPI_FAILURE(status)) {
103 return_ACPI_STATUS(status);
108 } 104 }
109 105
110 /* Type ANY means "don't care" */ 106 /* Type ANY means "don't care" */
111 107
112 if (return_type == ACPI_TYPE_ANY) { 108 if (return_type == ACPI_TYPE_ANY) {
113 return_ACPI_STATUS (AE_OK); 109 return_ACPI_STATUS(AE_OK);
114 } 110 }
115 111
116 if (return_buffer->length == 0) { 112 if (return_buffer->length == 0) {
117 /* Error because caller specifically asked for a return value */ 113 /* Error because caller specifically asked for a return value */
118 114
119 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n"));
120 "No return value\n"));
121 116
122 return_ACPI_STATUS (AE_NULL_OBJECT); 117 return_ACPI_STATUS(AE_NULL_OBJECT);
123 } 118 }
124 119
125 /* Examine the object type returned from evaluate_object */ 120 /* Examine the object type returned from evaluate_object */
126 121
127 if (((union acpi_object *) return_buffer->pointer)->type == return_type) { 122 if (((union acpi_object *)return_buffer->pointer)->type == return_type) {
128 return_ACPI_STATUS (AE_OK); 123 return_ACPI_STATUS(AE_OK);
129 } 124 }
130 125
131 /* Return object type does not match requested type */ 126 /* Return object type does not match requested type */
132 127
133 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 128 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
134 "Incorrect return type [%s] requested [%s]\n", 129 "Incorrect return type [%s] requested [%s]\n",
135 acpi_ut_get_type_name (((union acpi_object *) return_buffer->pointer)->type), 130 acpi_ut_get_type_name(((union acpi_object *)
136 acpi_ut_get_type_name (return_type))); 131 return_buffer->pointer)->type),
132 acpi_ut_get_type_name(return_type)));
137 133
138 if (must_free) { 134 if (must_free) {
139 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 135 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
140 136
141 acpi_os_free (return_buffer->pointer); 137 acpi_os_free(return_buffer->pointer);
142 return_buffer->pointer = NULL; 138 return_buffer->pointer = NULL;
143 } 139 }
144 140
145 return_buffer->length = 0; 141 return_buffer->length = 0;
146 return_ACPI_STATUS (AE_TYPE); 142 return_ACPI_STATUS(AE_TYPE);
147} 143}
148#endif /* ACPI_FUTURE_USAGE */ 144#endif /* ACPI_FUTURE_USAGE */
149
150 145
151/******************************************************************************* 146/*******************************************************************************
152 * 147 *
@@ -169,21 +164,18 @@ acpi_evaluate_object_typed (
169 ******************************************************************************/ 164 ******************************************************************************/
170 165
171acpi_status 166acpi_status
172acpi_evaluate_object ( 167acpi_evaluate_object(acpi_handle handle,
173 acpi_handle handle, 168 acpi_string pathname,
174 acpi_string pathname, 169 struct acpi_object_list *external_params,
175 struct acpi_object_list *external_params, 170 struct acpi_buffer *return_buffer)
176 struct acpi_buffer *return_buffer)
177{ 171{
178 acpi_status status; 172 acpi_status status;
179 acpi_status status2; 173 acpi_status status2;
180 struct acpi_parameter_info info; 174 struct acpi_parameter_info info;
181 acpi_size buffer_space_needed; 175 acpi_size buffer_space_needed;
182 u32 i; 176 u32 i;
183
184
185 ACPI_FUNCTION_TRACE ("acpi_evaluate_object");
186 177
178 ACPI_FUNCTION_TRACE("acpi_evaluate_object");
187 179
188 info.node = handle; 180 info.node = handle;
189 info.parameters = NULL; 181 info.parameters = NULL;
@@ -200,11 +192,11 @@ acpi_evaluate_object (
200 * Allocate a new parameter block for the internal objects 192 * Allocate a new parameter block for the internal objects
201 * Add 1 to count to allow for null terminated internal list 193 * Add 1 to count to allow for null terminated internal list
202 */ 194 */
203 info.parameters = ACPI_MEM_CALLOCATE ( 195 info.parameters = ACPI_MEM_CALLOCATE(((acpi_size)
204 ((acpi_size) external_params->count + 1) * 196 external_params->count +
205 sizeof (void *)); 197 1) * sizeof(void *));
206 if (!info.parameters) { 198 if (!info.parameters) {
207 return_ACPI_STATUS (AE_NO_MEMORY); 199 return_ACPI_STATUS(AE_NO_MEMORY);
208 } 200 }
209 201
210 /* 202 /*
@@ -212,48 +204,47 @@ acpi_evaluate_object (
212 * internal object 204 * internal object
213 */ 205 */
214 for (i = 0; i < external_params->count; i++) { 206 for (i = 0; i < external_params->count; i++) {
215 status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i], 207 status =
216 &info.parameters[i]); 208 acpi_ut_copy_eobject_to_iobject(&external_params->
217 if (ACPI_FAILURE (status)) { 209 pointer[i],
218 acpi_ut_delete_internal_object_list (info.parameters); 210 &info.
219 return_ACPI_STATUS (status); 211 parameters[i]);
212 if (ACPI_FAILURE(status)) {
213 acpi_ut_delete_internal_object_list(info.
214 parameters);
215 return_ACPI_STATUS(status);
220 } 216 }
221 } 217 }
222 info.parameters[external_params->count] = NULL; 218 info.parameters[external_params->count] = NULL;
223 } 219 }
224 220
225
226 /* 221 /*
227 * Three major cases: 222 * Three major cases:
228 * 1) Fully qualified pathname 223 * 1) Fully qualified pathname
229 * 2) No handle, not fully qualified pathname (error) 224 * 2) No handle, not fully qualified pathname (error)
230 * 3) Valid handle 225 * 3) Valid handle
231 */ 226 */
232 if ((pathname) && 227 if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) {
233 (acpi_ns_valid_root_prefix (pathname[0]))) {
234 /* 228 /*
235 * The path is fully qualified, just evaluate by name 229 * The path is fully qualified, just evaluate by name
236 */ 230 */
237 status = acpi_ns_evaluate_by_name (pathname, &info); 231 status = acpi_ns_evaluate_by_name(pathname, &info);
238 } 232 } else if (!handle) {
239 else if (!handle) {
240 /* 233 /*
241 * A handle is optional iff a fully qualified pathname 234 * A handle is optional iff a fully qualified pathname
242 * is specified. Since we've already handled fully 235 * is specified. Since we've already handled fully
243 * qualified names above, this is an error 236 * qualified names above, this is an error
244 */ 237 */
245 if (!pathname) { 238 if (!pathname) {
246 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
247 "Both Handle and Pathname are NULL\n")); 240 "Both Handle and Pathname are NULL\n"));
248 } 241 } else {
249 else { 242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 243 "Handle is NULL and Pathname is relative\n"));
251 "Handle is NULL and Pathname is relative\n"));
252 } 244 }
253 245
254 status = AE_BAD_PARAMETER; 246 status = AE_BAD_PARAMETER;
255 } 247 } else {
256 else {
257 /* 248 /*
258 * We get here if we have a handle -- and if we have a 249 * We get here if we have a handle -- and if we have a
259 * pathname it is relative. The handle will be validated 250 * pathname it is relative. The handle will be validated
@@ -264,17 +255,15 @@ acpi_evaluate_object (
264 * The null pathname case means the handle is for 255 * The null pathname case means the handle is for
265 * the actual object to be evaluated 256 * the actual object to be evaluated
266 */ 257 */
267 status = acpi_ns_evaluate_by_handle (&info); 258 status = acpi_ns_evaluate_by_handle(&info);
268 } 259 } else {
269 else { 260 /*
270 /* 261 * Both a Handle and a relative Pathname
271 * Both a Handle and a relative Pathname 262 */
272 */ 263 status = acpi_ns_evaluate_relative(pathname, &info);
273 status = acpi_ns_evaluate_relative (pathname, &info);
274 } 264 }
275 } 265 }
276 266
277
278 /* 267 /*
279 * If we are expecting a return value, and all went well above, 268 * If we are expecting a return value, and all went well above,
280 * copy the return value to an external object. 269 * copy the return value to an external object.
@@ -282,9 +271,9 @@ acpi_evaluate_object (
282 if (return_buffer) { 271 if (return_buffer) {
283 if (!info.return_object) { 272 if (!info.return_object) {
284 return_buffer->length = 0; 273 return_buffer->length = 0;
285 } 274 } else {
286 else { 275 if (ACPI_GET_DESCRIPTOR_TYPE(info.return_object) ==
287 if (ACPI_GET_DESCRIPTOR_TYPE (info.return_object) == ACPI_DESC_TYPE_NAMED) { 276 ACPI_DESC_TYPE_NAMED) {
288 /* 277 /*
289 * If we received a NS Node as a return object, this means that 278 * If we received a NS Node as a return object, this means that
290 * the object we are evaluating has nothing interesting to 279 * the object we are evaluating has nothing interesting to
@@ -294,37 +283,43 @@ acpi_evaluate_object (
294 * support for various types at a later date if necessary. 283 * support for various types at a later date if necessary.
295 */ 284 */
296 status = AE_TYPE; 285 status = AE_TYPE;
297 info.return_object = NULL; /* No need to delete a NS Node */ 286 info.return_object = NULL; /* No need to delete a NS Node */
298 return_buffer->length = 0; 287 return_buffer->length = 0;
299 } 288 }
300 289
301 if (ACPI_SUCCESS (status)) { 290 if (ACPI_SUCCESS(status)) {
302 /* 291 /*
303 * Find out how large a buffer is needed 292 * Find out how large a buffer is needed
304 * to contain the returned object 293 * to contain the returned object
305 */ 294 */
306 status = acpi_ut_get_object_size (info.return_object, 295 status =
307 &buffer_space_needed); 296 acpi_ut_get_object_size(info.return_object,
308 if (ACPI_SUCCESS (status)) { 297 &buffer_space_needed);
298 if (ACPI_SUCCESS(status)) {
309 /* Validate/Allocate/Clear caller buffer */ 299 /* Validate/Allocate/Clear caller buffer */
310 300
311 status = acpi_ut_initialize_buffer (return_buffer, 301 status =
312 buffer_space_needed); 302 acpi_ut_initialize_buffer
313 if (ACPI_FAILURE (status)) { 303 (return_buffer,
304 buffer_space_needed);
305 if (ACPI_FAILURE(status)) {
314 /* 306 /*
315 * Caller's buffer is too small or a new one can't be allocated 307 * Caller's buffer is too small or a new one can't be allocated
316 */ 308 */
317 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 309 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
318 "Needed buffer size %X, %s\n", 310 "Needed buffer size %X, %s\n",
319 (u32) buffer_space_needed, 311 (u32)
320 acpi_format_exception (status))); 312 buffer_space_needed,
321 } 313 acpi_format_exception
322 else { 314 (status)));
315 } else {
323 /* 316 /*
324 * We have enough space for the object, build it 317 * We have enough space for the object, build it
325 */ 318 */
326 status = acpi_ut_copy_iobject_to_eobject (info.return_object, 319 status =
327 return_buffer); 320 acpi_ut_copy_iobject_to_eobject
321 (info.return_object,
322 return_buffer);
328 } 323 }
329 } 324 }
330 } 325 }
@@ -336,14 +331,14 @@ acpi_evaluate_object (
336 * Delete the internal return object. NOTE: Interpreter 331 * Delete the internal return object. NOTE: Interpreter
337 * must be locked to avoid race condition. 332 * must be locked to avoid race condition.
338 */ 333 */
339 status2 = acpi_ex_enter_interpreter (); 334 status2 = acpi_ex_enter_interpreter();
340 if (ACPI_SUCCESS (status2)) { 335 if (ACPI_SUCCESS(status2)) {
341 /* 336 /*
342 * Delete the internal return object. (Or at least 337 * Delete the internal return object. (Or at least
343 * decrement the reference count by one) 338 * decrement the reference count by one)
344 */ 339 */
345 acpi_ut_remove_reference (info.return_object); 340 acpi_ut_remove_reference(info.return_object);
346 acpi_ex_exit_interpreter (); 341 acpi_ex_exit_interpreter();
347 } 342 }
348 } 343 }
349 344
@@ -353,13 +348,13 @@ acpi_evaluate_object (
353 if (info.parameters) { 348 if (info.parameters) {
354 /* Free the allocated parameter block */ 349 /* Free the allocated parameter block */
355 350
356 acpi_ut_delete_internal_object_list (info.parameters); 351 acpi_ut_delete_internal_object_list(info.parameters);
357 } 352 }
358 353
359 return_ACPI_STATUS (status); 354 return_ACPI_STATUS(status);
360} 355}
361EXPORT_SYMBOL(acpi_evaluate_object);
362 356
357EXPORT_SYMBOL(acpi_evaluate_object);
363 358
364/******************************************************************************* 359/*******************************************************************************
365 * 360 *
@@ -392,26 +387,20 @@ EXPORT_SYMBOL(acpi_evaluate_object);
392 ******************************************************************************/ 387 ******************************************************************************/
393 388
394acpi_status 389acpi_status
395acpi_walk_namespace ( 390acpi_walk_namespace(acpi_object_type type,
396 acpi_object_type type, 391 acpi_handle start_object,
397 acpi_handle start_object, 392 u32 max_depth,
398 u32 max_depth, 393 acpi_walk_callback user_function,
399 acpi_walk_callback user_function, 394 void *context, void **return_value)
400 void *context,
401 void **return_value)
402{ 395{
403 acpi_status status; 396 acpi_status status;
404
405
406 ACPI_FUNCTION_TRACE ("acpi_walk_namespace");
407 397
398 ACPI_FUNCTION_TRACE("acpi_walk_namespace");
408 399
409 /* Parameter validation */ 400 /* Parameter validation */
410 401
411 if ((type > ACPI_TYPE_EXTERNAL_MAX) || 402 if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) {
412 (!max_depth) || 403 return_ACPI_STATUS(AE_BAD_PARAMETER);
413 (!user_function)) {
414 return_ACPI_STATUS (AE_BAD_PARAMETER);
415 } 404 }
416 405
417 /* 406 /*
@@ -420,20 +409,20 @@ acpi_walk_namespace (
420 * to the user function - since this function 409 * to the user function - since this function
421 * must be allowed to make Acpi calls itself. 410 * must be allowed to make Acpi calls itself.
422 */ 411 */
423 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 412 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
424 if (ACPI_FAILURE (status)) { 413 if (ACPI_FAILURE(status)) {
425 return_ACPI_STATUS (status); 414 return_ACPI_STATUS(status);
426 } 415 }
427 416
428 status = acpi_ns_walk_namespace (type, start_object, max_depth, 417 status = acpi_ns_walk_namespace(type, start_object, max_depth,
429 ACPI_NS_WALK_UNLOCK, 418 ACPI_NS_WALK_UNLOCK,
430 user_function, context, return_value); 419 user_function, context, return_value);
431 420
432 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 421 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
433 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
434} 423}
435EXPORT_SYMBOL(acpi_walk_namespace);
436 424
425EXPORT_SYMBOL(acpi_walk_namespace);
437 426
438/******************************************************************************* 427/*******************************************************************************
439 * 428 *
@@ -450,29 +439,26 @@ EXPORT_SYMBOL(acpi_walk_namespace);
450 ******************************************************************************/ 439 ******************************************************************************/
451 440
452static acpi_status 441static acpi_status
453acpi_ns_get_device_callback ( 442acpi_ns_get_device_callback(acpi_handle obj_handle,
454 acpi_handle obj_handle, 443 u32 nesting_level,
455 u32 nesting_level, 444 void *context, void **return_value)
456 void *context,
457 void **return_value)
458{ 445{
459 struct acpi_get_devices_info *info = context; 446 struct acpi_get_devices_info *info = context;
460 acpi_status status; 447 acpi_status status;
461 struct acpi_namespace_node *node; 448 struct acpi_namespace_node *node;
462 u32 flags; 449 u32 flags;
463 struct acpi_device_id hid; 450 struct acpi_device_id hid;
464 struct acpi_compatible_id_list *cid; 451 struct acpi_compatible_id_list *cid;
465 acpi_native_uint i; 452 acpi_native_uint i;
466
467 453
468 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 454 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
469 if (ACPI_FAILURE (status)) { 455 if (ACPI_FAILURE(status)) {
470 return (status); 456 return (status);
471 } 457 }
472 458
473 node = acpi_ns_map_handle_to_node (obj_handle); 459 node = acpi_ns_map_handle_to_node(obj_handle);
474 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 460 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
475 if (ACPI_FAILURE (status)) { 461 if (ACPI_FAILURE(status)) {
476 return (status); 462 return (status);
477 } 463 }
478 464
@@ -482,8 +468,8 @@ acpi_ns_get_device_callback (
482 468
483 /* Run _STA to determine if device is present */ 469 /* Run _STA to determine if device is present */
484 470
485 status = acpi_ut_execute_STA (node, &flags); 471 status = acpi_ut_execute_STA(node, &flags);
486 if (ACPI_FAILURE (status)) { 472 if (ACPI_FAILURE(status)) {
487 return (AE_CTRL_DEPTH); 473 return (AE_CTRL_DEPTH);
488 } 474 }
489 475
@@ -496,44 +482,43 @@ acpi_ns_get_device_callback (
496 /* Filter based on device HID & CID */ 482 /* Filter based on device HID & CID */
497 483
498 if (info->hid != NULL) { 484 if (info->hid != NULL) {
499 status = acpi_ut_execute_HID (node, &hid); 485 status = acpi_ut_execute_HID(node, &hid);
500 if (status == AE_NOT_FOUND) { 486 if (status == AE_NOT_FOUND) {
501 return (AE_OK); 487 return (AE_OK);
502 } 488 } else if (ACPI_FAILURE(status)) {
503 else if (ACPI_FAILURE (status)) {
504 return (AE_CTRL_DEPTH); 489 return (AE_CTRL_DEPTH);
505 } 490 }
506 491
507 if (ACPI_STRNCMP (hid.value, info->hid, sizeof (hid.value)) != 0) { 492 if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) {
508 /* Get the list of Compatible IDs */ 493 /* Get the list of Compatible IDs */
509 494
510 status = acpi_ut_execute_CID (node, &cid); 495 status = acpi_ut_execute_CID(node, &cid);
511 if (status == AE_NOT_FOUND) { 496 if (status == AE_NOT_FOUND) {
512 return (AE_OK); 497 return (AE_OK);
513 } 498 } else if (ACPI_FAILURE(status)) {
514 else if (ACPI_FAILURE (status)) {
515 return (AE_CTRL_DEPTH); 499 return (AE_CTRL_DEPTH);
516 } 500 }
517 501
518 /* Walk the CID list */ 502 /* Walk the CID list */
519 503
520 for (i = 0; i < cid->count; i++) { 504 for (i = 0; i < cid->count; i++) {
521 if (ACPI_STRNCMP (cid->id[i].value, info->hid, 505 if (ACPI_STRNCMP(cid->id[i].value, info->hid,
522 sizeof (struct acpi_compatible_id)) != 0) { 506 sizeof(struct
523 ACPI_MEM_FREE (cid); 507 acpi_compatible_id)) !=
508 0) {
509 ACPI_MEM_FREE(cid);
524 return (AE_OK); 510 return (AE_OK);
525 } 511 }
526 } 512 }
527 ACPI_MEM_FREE (cid); 513 ACPI_MEM_FREE(cid);
528 } 514 }
529 } 515 }
530 516
531 status = info->user_function (obj_handle, nesting_level, info->context, 517 status = info->user_function(obj_handle, nesting_level, info->context,
532 return_value); 518 return_value);
533 return (status); 519 return (status);
534} 520}
535 521
536
537/******************************************************************************* 522/*******************************************************************************
538 * 523 *
539 * FUNCTION: acpi_get_devices 524 * FUNCTION: acpi_get_devices
@@ -560,32 +545,28 @@ acpi_ns_get_device_callback (
560 ******************************************************************************/ 545 ******************************************************************************/
561 546
562acpi_status 547acpi_status
563acpi_get_devices ( 548acpi_get_devices(char *HID,
564 char *HID, 549 acpi_walk_callback user_function,
565 acpi_walk_callback user_function, 550 void *context, void **return_value)
566 void *context,
567 void **return_value)
568{ 551{
569 acpi_status status; 552 acpi_status status;
570 struct acpi_get_devices_info info; 553 struct acpi_get_devices_info info;
571
572
573 ACPI_FUNCTION_TRACE ("acpi_get_devices");
574 554
555 ACPI_FUNCTION_TRACE("acpi_get_devices");
575 556
576 /* Parameter validation */ 557 /* Parameter validation */
577 558
578 if (!user_function) { 559 if (!user_function) {
579 return_ACPI_STATUS (AE_BAD_PARAMETER); 560 return_ACPI_STATUS(AE_BAD_PARAMETER);
580 } 561 }
581 562
582 /* 563 /*
583 * We're going to call their callback from OUR callback, so we need 564 * We're going to call their callback from OUR callback, so we need
584 * to know what it is, and their context parameter. 565 * to know what it is, and their context parameter.
585 */ 566 */
586 info.context = context; 567 info.context = context;
587 info.user_function = user_function; 568 info.user_function = user_function;
588 info.hid = HID; 569 info.hid = HID;
589 570
590 /* 571 /*
591 * Lock the namespace around the walk. 572 * Lock the namespace around the walk.
@@ -593,22 +574,22 @@ acpi_get_devices (
593 * to the user function - since this function 574 * to the user function - since this function
594 * must be allowed to make Acpi calls itself. 575 * must be allowed to make Acpi calls itself.
595 */ 576 */
596 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 577 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
597 if (ACPI_FAILURE (status)) { 578 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS (status); 579 return_ACPI_STATUS(status);
599 } 580 }
600 581
601 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, 582 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE,
602 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 583 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
603 ACPI_NS_WALK_UNLOCK, 584 ACPI_NS_WALK_UNLOCK,
604 acpi_ns_get_device_callback, &info, 585 acpi_ns_get_device_callback, &info,
605 return_value); 586 return_value);
606 587
607 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 588 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
608 return_ACPI_STATUS (status); 589 return_ACPI_STATUS(status);
609} 590}
610EXPORT_SYMBOL(acpi_get_devices);
611 591
592EXPORT_SYMBOL(acpi_get_devices);
612 593
613/******************************************************************************* 594/*******************************************************************************
614 * 595 *
@@ -625,44 +606,38 @@ EXPORT_SYMBOL(acpi_get_devices);
625 ******************************************************************************/ 606 ******************************************************************************/
626 607
627acpi_status 608acpi_status
628acpi_attach_data ( 609acpi_attach_data(acpi_handle obj_handle,
629 acpi_handle obj_handle, 610 acpi_object_handler handler, void *data)
630 acpi_object_handler handler,
631 void *data)
632{ 611{
633 struct acpi_namespace_node *node; 612 struct acpi_namespace_node *node;
634 acpi_status status; 613 acpi_status status;
635
636 614
637 /* Parameter validation */ 615 /* Parameter validation */
638 616
639 if (!obj_handle || 617 if (!obj_handle || !handler || !data) {
640 !handler ||
641 !data) {
642 return (AE_BAD_PARAMETER); 618 return (AE_BAD_PARAMETER);
643 } 619 }
644 620
645 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 621 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
646 if (ACPI_FAILURE (status)) { 622 if (ACPI_FAILURE(status)) {
647 return (status); 623 return (status);
648 } 624 }
649 625
650 /* Convert and validate the handle */ 626 /* Convert and validate the handle */
651 627
652 node = acpi_ns_map_handle_to_node (obj_handle); 628 node = acpi_ns_map_handle_to_node(obj_handle);
653 if (!node) { 629 if (!node) {
654 status = AE_BAD_PARAMETER; 630 status = AE_BAD_PARAMETER;
655 goto unlock_and_exit; 631 goto unlock_and_exit;
656 } 632 }
657 633
658 status = acpi_ns_attach_data (node, handler, data); 634 status = acpi_ns_attach_data(node, handler, data);
659 635
660unlock_and_exit: 636 unlock_and_exit:
661 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 637 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
662 return (status); 638 return (status);
663} 639}
664 640
665
666/******************************************************************************* 641/*******************************************************************************
667 * 642 *
668 * FUNCTION: acpi_detach_data 643 * FUNCTION: acpi_detach_data
@@ -677,42 +652,37 @@ unlock_and_exit:
677 ******************************************************************************/ 652 ******************************************************************************/
678 653
679acpi_status 654acpi_status
680acpi_detach_data ( 655acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
681 acpi_handle obj_handle,
682 acpi_object_handler handler)
683{ 656{
684 struct acpi_namespace_node *node; 657 struct acpi_namespace_node *node;
685 acpi_status status; 658 acpi_status status;
686
687 659
688 /* Parameter validation */ 660 /* Parameter validation */
689 661
690 if (!obj_handle || 662 if (!obj_handle || !handler) {
691 !handler) {
692 return (AE_BAD_PARAMETER); 663 return (AE_BAD_PARAMETER);
693 } 664 }
694 665
695 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
696 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
697 return (status); 668 return (status);
698 } 669 }
699 670
700 /* Convert and validate the handle */ 671 /* Convert and validate the handle */
701 672
702 node = acpi_ns_map_handle_to_node (obj_handle); 673 node = acpi_ns_map_handle_to_node(obj_handle);
703 if (!node) { 674 if (!node) {
704 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
705 goto unlock_and_exit; 676 goto unlock_and_exit;
706 } 677 }
707 678
708 status = acpi_ns_detach_data (node, handler); 679 status = acpi_ns_detach_data(node, handler);
709 680
710unlock_and_exit: 681 unlock_and_exit:
711 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 682 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
712 return (status); 683 return (status);
713} 684}
714 685
715
716/******************************************************************************* 686/*******************************************************************************
717 * 687 *
718 * FUNCTION: acpi_get_data 688 * FUNCTION: acpi_get_data
@@ -728,41 +698,33 @@ unlock_and_exit:
728 ******************************************************************************/ 698 ******************************************************************************/
729 699
730acpi_status 700acpi_status
731acpi_get_data ( 701acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
732 acpi_handle obj_handle,
733 acpi_object_handler handler,
734 void **data)
735{ 702{
736 struct acpi_namespace_node *node; 703 struct acpi_namespace_node *node;
737 acpi_status status; 704 acpi_status status;
738
739 705
740 /* Parameter validation */ 706 /* Parameter validation */
741 707
742 if (!obj_handle || 708 if (!obj_handle || !handler || !data) {
743 !handler ||
744 !data) {
745 return (AE_BAD_PARAMETER); 709 return (AE_BAD_PARAMETER);
746 } 710 }
747 711
748 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 712 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
749 if (ACPI_FAILURE (status)) { 713 if (ACPI_FAILURE(status)) {
750 return (status); 714 return (status);
751 } 715 }
752 716
753 /* Convert and validate the handle */ 717 /* Convert and validate the handle */
754 718
755 node = acpi_ns_map_handle_to_node (obj_handle); 719 node = acpi_ns_map_handle_to_node(obj_handle);
756 if (!node) { 720 if (!node) {
757 status = AE_BAD_PARAMETER; 721 status = AE_BAD_PARAMETER;
758 goto unlock_and_exit; 722 goto unlock_and_exit;
759 } 723 }
760 724
761 status = acpi_ns_get_attached_data (node, handler, data); 725 status = acpi_ns_get_attached_data(node, handler, data);
762 726
763unlock_and_exit: 727 unlock_and_exit:
764 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 728 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
765 return (status); 729 return (status);
766} 730}
767
768
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 8d097914c49a..6b5f8d4481d1 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -47,10 +47,8 @@
47#include <acpi/acpi.h> 47#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsxfname") 51ACPI_MODULE_NAME("nsxfname")
53
54 52
55/****************************************************************************** 53/******************************************************************************
56 * 54 *
@@ -69,20 +67,15 @@
69 * namespace handle. 67 * namespace handle.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_get_handle ( 71acpi_get_handle(acpi_handle parent,
75 acpi_handle parent, 72 acpi_string pathname, acpi_handle * ret_handle)
76 acpi_string pathname,
77 acpi_handle *ret_handle)
78{ 73{
79 acpi_status status; 74 acpi_status status;
80 struct acpi_namespace_node *node = NULL; 75 struct acpi_namespace_node *node = NULL;
81 struct acpi_namespace_node *prefix_node = NULL; 76 struct acpi_namespace_node *prefix_node = NULL;
82
83
84 ACPI_FUNCTION_ENTRY ();
85 77
78 ACPI_FUNCTION_ENTRY();
86 79
87 /* Parameter Validation */ 80 /* Parameter Validation */
88 81
@@ -93,45 +86,47 @@ acpi_get_handle (
93 /* Convert a parent handle to a prefix node */ 86 /* Convert a parent handle to a prefix node */
94 87
95 if (parent) { 88 if (parent) {
96 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 89 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
97 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE(status)) {
98 return (status); 91 return (status);
99 } 92 }
100 93
101 prefix_node = acpi_ns_map_handle_to_node (parent); 94 prefix_node = acpi_ns_map_handle_to_node(parent);
102 if (!prefix_node) { 95 if (!prefix_node) {
103 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 96 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
104 return (AE_BAD_PARAMETER); 97 return (AE_BAD_PARAMETER);
105 } 98 }
106 99
107 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 100 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
108 if (ACPI_FAILURE (status)) { 101 if (ACPI_FAILURE(status)) {
109 return (status); 102 return (status);
110 } 103 }
111 } 104 }
112 105
113 /* Special case for root, since we can't search for it */ 106 /* Special case for root, since we can't search for it */
114 107
115 if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) { 108 if (ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH) == 0) {
116 *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node); 109 *ret_handle =
110 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
117 return (AE_OK); 111 return (AE_OK);
118 } 112 }
119 113
120 /* 114 /*
121 * Find the Node and convert to a handle 115 * Find the Node and convert to a handle
122 */ 116 */
123 status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH, 117 status =
124 &node); 118 acpi_ns_get_node_by_path(pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
119 &node);
125 120
126 *ret_handle = NULL; 121 *ret_handle = NULL;
127 if (ACPI_SUCCESS (status)) { 122 if (ACPI_SUCCESS(status)) {
128 *ret_handle = acpi_ns_convert_entry_to_handle (node); 123 *ret_handle = acpi_ns_convert_entry_to_handle(node);
129 } 124 }
130 125
131 return (status); 126 return (status);
132} 127}
133EXPORT_SYMBOL(acpi_get_handle);
134 128
129EXPORT_SYMBOL(acpi_get_handle);
135 130
136/****************************************************************************** 131/******************************************************************************
137 * 132 *
@@ -150,14 +145,10 @@ EXPORT_SYMBOL(acpi_get_handle);
150 ******************************************************************************/ 145 ******************************************************************************/
151 146
152acpi_status 147acpi_status
153acpi_get_name ( 148acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
154 acpi_handle handle,
155 u32 name_type,
156 struct acpi_buffer *buffer)
157{ 149{
158 acpi_status status; 150 acpi_status status;
159 struct acpi_namespace_node *node; 151 struct acpi_namespace_node *node;
160
161 152
162 /* Parameter validation */ 153 /* Parameter validation */
163 154
@@ -165,15 +156,15 @@ acpi_get_name (
165 return (AE_BAD_PARAMETER); 156 return (AE_BAD_PARAMETER);
166 } 157 }
167 158
168 status = acpi_ut_validate_buffer (buffer); 159 status = acpi_ut_validate_buffer(buffer);
169 if (ACPI_FAILURE (status)) { 160 if (ACPI_FAILURE(status)) {
170 return (status); 161 return (status);
171 } 162 }
172 163
173 if (name_type == ACPI_FULL_PATHNAME) { 164 if (name_type == ACPI_FULL_PATHNAME) {
174 /* Get the full pathname (From the namespace root) */ 165 /* Get the full pathname (From the namespace root) */
175 166
176 status = acpi_ns_handle_to_pathname (handle, buffer); 167 status = acpi_ns_handle_to_pathname(handle, buffer);
177 return (status); 168 return (status);
178 } 169 }
179 170
@@ -181,12 +172,12 @@ acpi_get_name (
181 * Wants the single segment ACPI name. 172 * Wants the single segment ACPI name.
182 * Validate handle and convert to a namespace Node 173 * Validate handle and convert to a namespace Node
183 */ 174 */
184 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 175 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
185 if (ACPI_FAILURE (status)) { 176 if (ACPI_FAILURE(status)) {
186 return (status); 177 return (status);
187 } 178 }
188 179
189 node = acpi_ns_map_handle_to_node (handle); 180 node = acpi_ns_map_handle_to_node(handle);
190 if (!node) { 181 if (!node) {
191 status = AE_BAD_PARAMETER; 182 status = AE_BAD_PARAMETER;
192 goto unlock_and_exit; 183 goto unlock_and_exit;
@@ -194,26 +185,25 @@ acpi_get_name (
194 185
195 /* Validate/Allocate/Clear caller buffer */ 186 /* Validate/Allocate/Clear caller buffer */
196 187
197 status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH); 188 status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
198 if (ACPI_FAILURE (status)) { 189 if (ACPI_FAILURE(status)) {
199 goto unlock_and_exit; 190 goto unlock_and_exit;
200 } 191 }
201 192
202 /* Just copy the ACPI name from the Node and zero terminate it */ 193 /* Just copy the ACPI name from the Node and zero terminate it */
203 194
204 ACPI_STRNCPY (buffer->pointer, acpi_ut_get_node_name (node), 195 ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
205 ACPI_NAME_SIZE); 196 ACPI_NAME_SIZE);
206 ((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0; 197 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
207 status = AE_OK; 198 status = AE_OK;
208 199
200 unlock_and_exit:
209 201
210unlock_and_exit: 202 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
211
212 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
213 return (status); 203 return (status);
214} 204}
215EXPORT_SYMBOL(acpi_get_name);
216 205
206EXPORT_SYMBOL(acpi_get_name);
217 207
218/****************************************************************************** 208/******************************************************************************
219 * 209 *
@@ -231,17 +221,14 @@ EXPORT_SYMBOL(acpi_get_name);
231 ******************************************************************************/ 221 ******************************************************************************/
232 222
233acpi_status 223acpi_status
234acpi_get_object_info ( 224acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
235 acpi_handle handle,
236 struct acpi_buffer *buffer)
237{ 225{
238 acpi_status status; 226 acpi_status status;
239 struct acpi_namespace_node *node; 227 struct acpi_namespace_node *node;
240 struct acpi_device_info *info; 228 struct acpi_device_info *info;
241 struct acpi_device_info *return_info; 229 struct acpi_device_info *return_info;
242 struct acpi_compatible_id_list *cid_list = NULL; 230 struct acpi_compatible_id_list *cid_list = NULL;
243 acpi_size size; 231 acpi_size size;
244
245 232
246 /* Parameter validation */ 233 /* Parameter validation */
247 234
@@ -249,37 +236,37 @@ acpi_get_object_info (
249 return (AE_BAD_PARAMETER); 236 return (AE_BAD_PARAMETER);
250 } 237 }
251 238
252 status = acpi_ut_validate_buffer (buffer); 239 status = acpi_ut_validate_buffer(buffer);
253 if (ACPI_FAILURE (status)) { 240 if (ACPI_FAILURE(status)) {
254 return (status); 241 return (status);
255 } 242 }
256 243
257 info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_device_info)); 244 info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_device_info));
258 if (!info) { 245 if (!info) {
259 return (AE_NO_MEMORY); 246 return (AE_NO_MEMORY);
260 } 247 }
261 248
262 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 249 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
263 if (ACPI_FAILURE (status)) { 250 if (ACPI_FAILURE(status)) {
264 goto cleanup; 251 goto cleanup;
265 } 252 }
266 253
267 node = acpi_ns_map_handle_to_node (handle); 254 node = acpi_ns_map_handle_to_node(handle);
268 if (!node) { 255 if (!node) {
269 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 256 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
270 goto cleanup; 257 goto cleanup;
271 } 258 }
272 259
273 /* Init return structure */ 260 /* Init return structure */
274 261
275 size = sizeof (struct acpi_device_info); 262 size = sizeof(struct acpi_device_info);
276 263
277 info->type = node->type; 264 info->type = node->type;
278 info->name = node->name.integer; 265 info->name = node->name.integer;
279 info->valid = 0; 266 info->valid = 0;
280 267
281 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 268 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
282 if (ACPI_FAILURE (status)) { 269 if (ACPI_FAILURE(status)) {
283 goto cleanup; 270 goto cleanup;
284 } 271 }
285 272
@@ -297,73 +284,73 @@ acpi_get_object_info (
297 284
298 /* Execute the Device._HID method */ 285 /* Execute the Device._HID method */
299 286
300 status = acpi_ut_execute_HID (node, &info->hardware_id); 287 status = acpi_ut_execute_HID(node, &info->hardware_id);
301 if (ACPI_SUCCESS (status)) { 288 if (ACPI_SUCCESS(status)) {
302 info->valid |= ACPI_VALID_HID; 289 info->valid |= ACPI_VALID_HID;
303 } 290 }
304 291
305 /* Execute the Device._UID method */ 292 /* Execute the Device._UID method */
306 293
307 status = acpi_ut_execute_UID (node, &info->unique_id); 294 status = acpi_ut_execute_UID(node, &info->unique_id);
308 if (ACPI_SUCCESS (status)) { 295 if (ACPI_SUCCESS(status)) {
309 info->valid |= ACPI_VALID_UID; 296 info->valid |= ACPI_VALID_UID;
310 } 297 }
311 298
312 /* Execute the Device._CID method */ 299 /* Execute the Device._CID method */
313 300
314 status = acpi_ut_execute_CID (node, &cid_list); 301 status = acpi_ut_execute_CID(node, &cid_list);
315 if (ACPI_SUCCESS (status)) { 302 if (ACPI_SUCCESS(status)) {
316 size += ((acpi_size) cid_list->count - 1) * 303 size += ((acpi_size) cid_list->count - 1) *
317 sizeof (struct acpi_compatible_id); 304 sizeof(struct acpi_compatible_id);
318 info->valid |= ACPI_VALID_CID; 305 info->valid |= ACPI_VALID_CID;
319 } 306 }
320 307
321 /* Execute the Device._STA method */ 308 /* Execute the Device._STA method */
322 309
323 status = acpi_ut_execute_STA (node, &info->current_status); 310 status = acpi_ut_execute_STA(node, &info->current_status);
324 if (ACPI_SUCCESS (status)) { 311 if (ACPI_SUCCESS(status)) {
325 info->valid |= ACPI_VALID_STA; 312 info->valid |= ACPI_VALID_STA;
326 } 313 }
327 314
328 /* Execute the Device._ADR method */ 315 /* Execute the Device._ADR method */
329 316
330 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node, 317 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
331 &info->address); 318 &info->address);
332 if (ACPI_SUCCESS (status)) { 319 if (ACPI_SUCCESS(status)) {
333 info->valid |= ACPI_VALID_ADR; 320 info->valid |= ACPI_VALID_ADR;
334 } 321 }
335 322
336 /* Execute the Device._sx_d methods */ 323 /* Execute the Device._sx_d methods */
337 324
338 status = acpi_ut_execute_sxds (node, info->highest_dstates); 325 status = acpi_ut_execute_sxds(node, info->highest_dstates);
339 if (ACPI_SUCCESS (status)) { 326 if (ACPI_SUCCESS(status)) {
340 info->valid |= ACPI_VALID_SXDS; 327 info->valid |= ACPI_VALID_SXDS;
341 } 328 }
342 } 329 }
343 330
344 /* Validate/Allocate/Clear caller buffer */ 331 /* Validate/Allocate/Clear caller buffer */
345 332
346 status = acpi_ut_initialize_buffer (buffer, size); 333 status = acpi_ut_initialize_buffer(buffer, size);
347 if (ACPI_FAILURE (status)) { 334 if (ACPI_FAILURE(status)) {
348 goto cleanup; 335 goto cleanup;
349 } 336 }
350 337
351 /* Populate the return buffer */ 338 /* Populate the return buffer */
352 339
353 return_info = buffer->pointer; 340 return_info = buffer->pointer;
354 ACPI_MEMCPY (return_info, info, sizeof (struct acpi_device_info)); 341 ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info));
355 342
356 if (cid_list) { 343 if (cid_list) {
357 ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size); 344 ACPI_MEMCPY(&return_info->compatibility_id, cid_list,
345 cid_list->size);
358 } 346 }
359 347
360 348 cleanup:
361cleanup: 349 ACPI_MEM_FREE(info);
362 ACPI_MEM_FREE (info);
363 if (cid_list) { 350 if (cid_list) {
364 ACPI_MEM_FREE (cid_list); 351 ACPI_MEM_FREE(cid_list);
365 } 352 }
366 return (status); 353 return (status);
367} 354}
368EXPORT_SYMBOL(acpi_get_object_info);
369 355
356EXPORT_SYMBOL(acpi_get_object_info);
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 363e1f6cfb18..0856d42e6909 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -47,9 +47,8 @@
47#include <acpi/acpi.h> 47#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsxfobj") 51ACPI_MODULE_NAME("nsxfobj")
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -63,15 +62,10 @@
63 * DESCRIPTION: This routine returns the type associatd with a particular handle 62 * DESCRIPTION: This routine returns the type associatd with a particular handle
64 * 63 *
65 ******************************************************************************/ 64 ******************************************************************************/
66 65acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
67acpi_status
68acpi_get_type (
69 acpi_handle handle,
70 acpi_object_type *ret_type)
71{ 66{
72 struct acpi_namespace_node *node; 67 struct acpi_namespace_node *node;
73 acpi_status status; 68 acpi_status status;
74
75 69
76 /* Parameter Validation */ 70 /* Parameter Validation */
77 71
@@ -88,27 +82,26 @@ acpi_get_type (
88 return (AE_OK); 82 return (AE_OK);
89 } 83 }
90 84
91 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 85 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
92 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
93 return (status); 87 return (status);
94 } 88 }
95 89
96 /* Convert and validate the handle */ 90 /* Convert and validate the handle */
97 91
98 node = acpi_ns_map_handle_to_node (handle); 92 node = acpi_ns_map_handle_to_node(handle);
99 if (!node) { 93 if (!node) {
100 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 94 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
101 return (AE_BAD_PARAMETER); 95 return (AE_BAD_PARAMETER);
102 } 96 }
103 97
104 *ret_type = node->type; 98 *ret_type = node->type;
105 99
106 100 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
107 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
108 return (status); 101 return (status);
109} 102}
110EXPORT_SYMBOL(acpi_get_type);
111 103
104EXPORT_SYMBOL(acpi_get_type);
112 105
113/******************************************************************************* 106/*******************************************************************************
114 * 107 *
@@ -124,14 +117,10 @@ EXPORT_SYMBOL(acpi_get_type);
124 * 117 *
125 ******************************************************************************/ 118 ******************************************************************************/
126 119
127acpi_status 120acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
128acpi_get_parent (
129 acpi_handle handle,
130 acpi_handle *ret_handle)
131{ 121{
132 struct acpi_namespace_node *node; 122 struct acpi_namespace_node *node;
133 acpi_status status; 123 acpi_status status;
134
135 124
136 if (!ret_handle) { 125 if (!ret_handle) {
137 return (AE_BAD_PARAMETER); 126 return (AE_BAD_PARAMETER);
@@ -143,14 +132,14 @@ acpi_get_parent (
143 return (AE_NULL_ENTRY); 132 return (AE_NULL_ENTRY);
144 } 133 }
145 134
146 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 135 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
147 if (ACPI_FAILURE (status)) { 136 if (ACPI_FAILURE(status)) {
148 return (status); 137 return (status);
149 } 138 }
150 139
151 /* Convert and validate the handle */ 140 /* Convert and validate the handle */
152 141
153 node = acpi_ns_map_handle_to_node (handle); 142 node = acpi_ns_map_handle_to_node(handle);
154 if (!node) { 143 if (!node) {
155 status = AE_BAD_PARAMETER; 144 status = AE_BAD_PARAMETER;
156 goto unlock_and_exit; 145 goto unlock_and_exit;
@@ -159,22 +148,21 @@ acpi_get_parent (
159 /* Get the parent entry */ 148 /* Get the parent entry */
160 149
161 *ret_handle = 150 *ret_handle =
162 acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node)); 151 acpi_ns_convert_entry_to_handle(acpi_ns_get_parent_node(node));
163 152
164 /* Return exception if parent is null */ 153 /* Return exception if parent is null */
165 154
166 if (!acpi_ns_get_parent_node (node)) { 155 if (!acpi_ns_get_parent_node(node)) {
167 status = AE_NULL_ENTRY; 156 status = AE_NULL_ENTRY;
168 } 157 }
169 158
159 unlock_and_exit:
170 160
171unlock_and_exit: 161 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
172
173 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
174 return (status); 162 return (status);
175} 163}
176EXPORT_SYMBOL(acpi_get_parent);
177 164
165EXPORT_SYMBOL(acpi_get_parent);
178 166
179/******************************************************************************* 167/*******************************************************************************
180 * 168 *
@@ -195,17 +183,14 @@ EXPORT_SYMBOL(acpi_get_parent);
195 ******************************************************************************/ 183 ******************************************************************************/
196 184
197acpi_status 185acpi_status
198acpi_get_next_object ( 186acpi_get_next_object(acpi_object_type type,
199 acpi_object_type type, 187 acpi_handle parent,
200 acpi_handle parent, 188 acpi_handle child, acpi_handle * ret_handle)
201 acpi_handle child,
202 acpi_handle *ret_handle)
203{ 189{
204 acpi_status status; 190 acpi_status status;
205 struct acpi_namespace_node *node; 191 struct acpi_namespace_node *node;
206 struct acpi_namespace_node *parent_node = NULL; 192 struct acpi_namespace_node *parent_node = NULL;
207 struct acpi_namespace_node *child_node = NULL; 193 struct acpi_namespace_node *child_node = NULL;
208
209 194
210 /* Parameter validation */ 195 /* Parameter validation */
211 196
@@ -213,8 +198,8 @@ acpi_get_next_object (
213 return (AE_BAD_PARAMETER); 198 return (AE_BAD_PARAMETER);
214 } 199 }
215 200
216 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 201 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
217 if (ACPI_FAILURE (status)) { 202 if (ACPI_FAILURE(status)) {
218 return (status); 203 return (status);
219 } 204 }
220 205
@@ -223,17 +208,16 @@ acpi_get_next_object (
223 if (!child) { 208 if (!child) {
224 /* Start search at the beginning of the specified scope */ 209 /* Start search at the beginning of the specified scope */
225 210
226 parent_node = acpi_ns_map_handle_to_node (parent); 211 parent_node = acpi_ns_map_handle_to_node(parent);
227 if (!parent_node) { 212 if (!parent_node) {
228 status = AE_BAD_PARAMETER; 213 status = AE_BAD_PARAMETER;
229 goto unlock_and_exit; 214 goto unlock_and_exit;
230 } 215 }
231 } 216 } else {
232 else {
233 /* Non-null handle, ignore the parent */ 217 /* Non-null handle, ignore the parent */
234 /* Convert and validate the handle */ 218 /* Convert and validate the handle */
235 219
236 child_node = acpi_ns_map_handle_to_node (child); 220 child_node = acpi_ns_map_handle_to_node(child);
237 if (!child_node) { 221 if (!child_node) {
238 status = AE_BAD_PARAMETER; 222 status = AE_BAD_PARAMETER;
239 goto unlock_and_exit; 223 goto unlock_and_exit;
@@ -242,20 +226,19 @@ acpi_get_next_object (
242 226
243 /* Internal function does the real work */ 227 /* Internal function does the real work */
244 228
245 node = acpi_ns_get_next_node (type, parent_node, child_node); 229 node = acpi_ns_get_next_node(type, parent_node, child_node);
246 if (!node) { 230 if (!node) {
247 status = AE_NOT_FOUND; 231 status = AE_NOT_FOUND;
248 goto unlock_and_exit; 232 goto unlock_and_exit;
249 } 233 }
250 234
251 if (ret_handle) { 235 if (ret_handle) {
252 *ret_handle = acpi_ns_convert_entry_to_handle (node); 236 *ret_handle = acpi_ns_convert_entry_to_handle(node);
253 } 237 }
254 238
239 unlock_and_exit:
255 240
256unlock_and_exit: 241 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
257
258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
259 return (status); 242 return (status);
260} 243}
261 244
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index a82834b32752..64b98e82feb7 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -34,16 +34,18 @@
34 34
35#define ACPI_NUMA 0x80000000 35#define ACPI_NUMA 0x80000000
36#define _COMPONENT ACPI_NUMA 36#define _COMPONENT ACPI_NUMA
37 ACPI_MODULE_NAME ("numa") 37ACPI_MODULE_NAME("numa")
38 38
39extern int __init acpi_table_parse_madt_family (enum acpi_table_id id, unsigned long madt_size, int entry_id, acpi_madt_entry_handler handler, unsigned int max_entries); 39extern int __init acpi_table_parse_madt_family(enum acpi_table_id id,
40 unsigned long madt_size,
41 int entry_id,
42 acpi_madt_entry_handler handler,
43 unsigned int max_entries);
40 44
41void __init 45void __init acpi_table_print_srat_entry(acpi_table_entry_header * header)
42acpi_table_print_srat_entry (
43 acpi_table_entry_header *header)
44{ 46{
45 47
46 ACPI_FUNCTION_NAME ("acpi_table_print_srat_entry"); 48 ACPI_FUNCTION_NAME("acpi_table_print_srat_entry");
47 49
48 if (!header) 50 if (!header)
49 return; 51 return;
@@ -52,48 +54,55 @@ acpi_table_print_srat_entry (
52 54
53 case ACPI_SRAT_PROCESSOR_AFFINITY: 55 case ACPI_SRAT_PROCESSOR_AFFINITY:
54#ifdef ACPI_DEBUG_OUTPUT 56#ifdef ACPI_DEBUG_OUTPUT
55 { 57 {
56 struct acpi_table_processor_affinity *p = 58 struct acpi_table_processor_affinity *p =
57 (struct acpi_table_processor_affinity*) header; 59 (struct acpi_table_processor_affinity *)header;
58 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n", 60 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
59 p->apic_id, p->lsapic_eid, p->proximity_domain, 61 "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
60 p->flags.enabled?"enabled":"disabled")); 62 p->apic_id, p->lsapic_eid,
61 } 63 p->proximity_domain,
62#endif /* ACPI_DEBUG_OUTPUT */ 64 p->flags.
65 enabled ? "enabled" : "disabled"));
66 }
67#endif /* ACPI_DEBUG_OUTPUT */
63 break; 68 break;
64 69
65 case ACPI_SRAT_MEMORY_AFFINITY: 70 case ACPI_SRAT_MEMORY_AFFINITY:
66#ifdef ACPI_DEBUG_OUTPUT 71#ifdef ACPI_DEBUG_OUTPUT
67 { 72 {
68 struct acpi_table_memory_affinity *p = 73 struct acpi_table_memory_affinity *p =
69 (struct acpi_table_memory_affinity*) header; 74 (struct acpi_table_memory_affinity *)header;
70 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n", 75 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
71 p->base_addr_hi, p->base_addr_lo, p->length_hi, p->length_lo, 76 "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n",
72 p->memory_type, p->proximity_domain, 77 p->base_addr_hi, p->base_addr_lo,
73 p->flags.enabled ? "enabled" : "disabled", 78 p->length_hi, p->length_lo,
74 p->flags.hot_pluggable ? " hot-pluggable" : "")); 79 p->memory_type, p->proximity_domain,
75 } 80 p->flags.
76#endif /* ACPI_DEBUG_OUTPUT */ 81 enabled ? "enabled" : "disabled",
82 p->flags.
83 hot_pluggable ? " hot-pluggable" :
84 ""));
85 }
86#endif /* ACPI_DEBUG_OUTPUT */
77 break; 87 break;
78 88
79 default: 89 default:
80 printk(KERN_WARNING PREFIX "Found unsupported SRAT entry (type = 0x%x)\n", 90 printk(KERN_WARNING PREFIX
81 header->type); 91 "Found unsupported SRAT entry (type = 0x%x)\n",
92 header->type);
82 break; 93 break;
83 } 94 }
84} 95}
85 96
86 97static int __init acpi_parse_slit(unsigned long phys_addr, unsigned long size)
87static int __init
88acpi_parse_slit (unsigned long phys_addr, unsigned long size)
89{ 98{
90 struct acpi_table_slit *slit; 99 struct acpi_table_slit *slit;
91 u32 localities; 100 u32 localities;
92 101
93 if (!phys_addr || !size) 102 if (!phys_addr || !size)
94 return -EINVAL; 103 return -EINVAL;
95 104
96 slit = (struct acpi_table_slit *) __va(phys_addr); 105 slit = (struct acpi_table_slit *)__va(phys_addr);
97 106
98 /* downcast just for %llu vs %lu for i386/ia64 */ 107 /* downcast just for %llu vs %lu for i386/ia64 */
99 localities = (u32) slit->localities; 108 localities = (u32) slit->localities;
@@ -103,15 +112,13 @@ acpi_parse_slit (unsigned long phys_addr, unsigned long size)
103 return 0; 112 return 0;
104} 113}
105 114
106
107static int __init 115static int __init
108acpi_parse_processor_affinity ( 116acpi_parse_processor_affinity(acpi_table_entry_header * header,
109 acpi_table_entry_header *header, 117 const unsigned long end)
110 const unsigned long end)
111{ 118{
112 struct acpi_table_processor_affinity *processor_affinity; 119 struct acpi_table_processor_affinity *processor_affinity;
113 120
114 processor_affinity = (struct acpi_table_processor_affinity*) header; 121 processor_affinity = (struct acpi_table_processor_affinity *)header;
115 if (!processor_affinity) 122 if (!processor_affinity)
116 return -EINVAL; 123 return -EINVAL;
117 124
@@ -123,15 +130,13 @@ acpi_parse_processor_affinity (
123 return 0; 130 return 0;
124} 131}
125 132
126
127static int __init 133static int __init
128acpi_parse_memory_affinity ( 134acpi_parse_memory_affinity(acpi_table_entry_header * header,
129 acpi_table_entry_header *header, 135 const unsigned long end)
130 const unsigned long end)
131{ 136{
132 struct acpi_table_memory_affinity *memory_affinity; 137 struct acpi_table_memory_affinity *memory_affinity;
133 138
134 memory_affinity = (struct acpi_table_memory_affinity*) header; 139 memory_affinity = (struct acpi_table_memory_affinity *)header;
135 if (!memory_affinity) 140 if (!memory_affinity)
136 return -EINVAL; 141 return -EINVAL;
137 142
@@ -143,36 +148,30 @@ acpi_parse_memory_affinity (
143 return 0; 148 return 0;
144} 149}
145 150
146 151static int __init acpi_parse_srat(unsigned long phys_addr, unsigned long size)
147static int __init
148acpi_parse_srat (unsigned long phys_addr, unsigned long size)
149{ 152{
150 struct acpi_table_srat *srat; 153 struct acpi_table_srat *srat;
151 154
152 if (!phys_addr || !size) 155 if (!phys_addr || !size)
153 return -EINVAL; 156 return -EINVAL;
154 157
155 srat = (struct acpi_table_srat *) __va(phys_addr); 158 srat = (struct acpi_table_srat *)__va(phys_addr);
156 159
157 return 0; 160 return 0;
158} 161}
159 162
160
161int __init 163int __init
162acpi_table_parse_srat ( 164acpi_table_parse_srat(enum acpi_srat_entry_id id,
163 enum acpi_srat_entry_id id, 165 acpi_madt_entry_handler handler, unsigned int max_entries)
164 acpi_madt_entry_handler handler,
165 unsigned int max_entries)
166{ 166{
167 return acpi_table_parse_madt_family(ACPI_SRAT, sizeof(struct acpi_table_srat), 167 return acpi_table_parse_madt_family(ACPI_SRAT,
168 id, handler, max_entries); 168 sizeof(struct acpi_table_srat), id,
169 handler, max_entries);
169} 170}
170 171
171 172int __init acpi_numa_init(void)
172int __init
173acpi_numa_init(void)
174{ 173{
175 int result; 174 int result;
176 175
177 /* SRAT: Static Resource Affinity Table */ 176 /* SRAT: Static Resource Affinity Table */
178 result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat); 177 result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat);
@@ -181,9 +180,7 @@ acpi_numa_init(void)
181 result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY, 180 result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
182 acpi_parse_processor_affinity, 181 acpi_parse_processor_affinity,
183 NR_CPUS); 182 NR_CPUS);
184 result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, 183 result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); // IA64 specific
185 acpi_parse_memory_affinity,
186 NR_NODE_MEMBLKS); // IA64 specific
187 } 184 }
188 185
189 /* SLIT: System Locality Information Table */ 186 /* SLIT: System Locality Information Table */
@@ -193,8 +190,7 @@ acpi_numa_init(void)
193 return 0; 190 return 0;
194} 191}
195 192
196int 193int acpi_get_pxm(acpi_handle h)
197acpi_get_pxm(acpi_handle h)
198{ 194{
199 unsigned long pxm; 195 unsigned long pxm;
200 acpi_status status; 196 acpi_status status;
@@ -207,7 +203,8 @@ acpi_get_pxm(acpi_handle h)
207 if (ACPI_SUCCESS(status)) 203 if (ACPI_SUCCESS(status))
208 return (int)pxm; 204 return (int)pxm;
209 status = acpi_get_parent(handle, &phandle); 205 status = acpi_get_parent(handle, &phandle);
210 } while(ACPI_SUCCESS(status)); 206 } while (ACPI_SUCCESS(status));
211 return -1; 207 return -1;
212} 208}
209
213EXPORT_SYMBOL(acpi_get_pxm); 210EXPORT_SYMBOL(acpi_get_pxm);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0d11d6e6abd6..d528c750a380 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -45,16 +45,12 @@
45 45
46#include <linux/efi.h> 46#include <linux/efi.h>
47 47
48
49#define _COMPONENT ACPI_OS_SERVICES 48#define _COMPONENT ACPI_OS_SERVICES
50ACPI_MODULE_NAME ("osl") 49ACPI_MODULE_NAME("osl")
51
52#define PREFIX "ACPI: " 50#define PREFIX "ACPI: "
53 51struct acpi_os_dpc {
54struct acpi_os_dpc 52 acpi_osd_exec_callback function;
55{ 53 void *context;
56 acpi_osd_exec_callback function;
57 void *context;
58}; 54};
59 55
60#ifdef CONFIG_ACPI_CUSTOM_DSDT 56#ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -69,7 +65,7 @@ int acpi_in_debugger;
69EXPORT_SYMBOL(acpi_in_debugger); 65EXPORT_SYMBOL(acpi_in_debugger);
70 66
71extern char line_buf[80]; 67extern char line_buf[80];
72#endif /*ENABLE_DEBUGGER*/ 68#endif /*ENABLE_DEBUGGER */
73 69
74int acpi_specific_hotkey_enabled = TRUE; 70int acpi_specific_hotkey_enabled = TRUE;
75EXPORT_SYMBOL(acpi_specific_hotkey_enabled); 71EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
@@ -79,33 +75,29 @@ static acpi_osd_handler acpi_irq_handler;
79static void *acpi_irq_context; 75static void *acpi_irq_context;
80static struct workqueue_struct *kacpid_wq; 76static struct workqueue_struct *kacpid_wq;
81 77
82acpi_status 78acpi_status acpi_os_initialize(void)
83acpi_os_initialize(void)
84{ 79{
85 return AE_OK; 80 return AE_OK;
86} 81}
87 82
88acpi_status 83acpi_status acpi_os_initialize1(void)
89acpi_os_initialize1(void)
90{ 84{
91 /* 85 /*
92 * Initialize PCI configuration space access, as we'll need to access 86 * Initialize PCI configuration space access, as we'll need to access
93 * it while walking the namespace (bus 0 and root bridges w/ _BBNs). 87 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
94 */ 88 */
95#ifdef CONFIG_ACPI_PCI
96 if (!raw_pci_ops) { 89 if (!raw_pci_ops) {
97 printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); 90 printk(KERN_ERR PREFIX
91 "Access to PCI configuration space unavailable\n");
98 return AE_NULL_ENTRY; 92 return AE_NULL_ENTRY;
99 } 93 }
100#endif
101 kacpid_wq = create_singlethread_workqueue("kacpid"); 94 kacpid_wq = create_singlethread_workqueue("kacpid");
102 BUG_ON(!kacpid_wq); 95 BUG_ON(!kacpid_wq);
103 96
104 return AE_OK; 97 return AE_OK;
105} 98}
106 99
107acpi_status 100acpi_status acpi_os_terminate(void)
108acpi_os_terminate(void)
109{ 101{
110 if (acpi_irq_handler) { 102 if (acpi_irq_handler) {
111 acpi_os_remove_interrupt_handler(acpi_irq_irq, 103 acpi_os_remove_interrupt_handler(acpi_irq_irq,
@@ -117,21 +109,20 @@ acpi_os_terminate(void)
117 return AE_OK; 109 return AE_OK;
118} 110}
119 111
120void 112void acpi_os_printf(const char *fmt, ...)
121acpi_os_printf(const char *fmt,...)
122{ 113{
123 va_list args; 114 va_list args;
124 va_start(args, fmt); 115 va_start(args, fmt);
125 acpi_os_vprintf(fmt, args); 116 acpi_os_vprintf(fmt, args);
126 va_end(args); 117 va_end(args);
127} 118}
119
128EXPORT_SYMBOL(acpi_os_printf); 120EXPORT_SYMBOL(acpi_os_printf);
129 121
130void 122void acpi_os_vprintf(const char *fmt, va_list args)
131acpi_os_vprintf(const char *fmt, va_list args)
132{ 123{
133 static char buffer[512]; 124 static char buffer[512];
134 125
135 vsprintf(buffer, fmt, args); 126 vsprintf(buffer, fmt, args);
136 127
137#ifdef ENABLE_DEBUGGER 128#ifdef ENABLE_DEBUGGER
@@ -146,8 +137,7 @@ acpi_os_vprintf(const char *fmt, va_list args)
146} 137}
147 138
148extern int acpi_in_resume; 139extern int acpi_in_resume;
149void * 140void *acpi_os_allocate(acpi_size size)
150acpi_os_allocate(acpi_size size)
151{ 141{
152 if (acpi_in_resume) 142 if (acpi_in_resume)
153 return kmalloc(size, GFP_ATOMIC); 143 return kmalloc(size, GFP_ATOMIC);
@@ -155,31 +145,32 @@ acpi_os_allocate(acpi_size size)
155 return kmalloc(size, GFP_KERNEL); 145 return kmalloc(size, GFP_KERNEL);
156} 146}
157 147
158void 148void acpi_os_free(void *ptr)
159acpi_os_free(void *ptr)
160{ 149{
161 kfree(ptr); 150 kfree(ptr);
162} 151}
152
163EXPORT_SYMBOL(acpi_os_free); 153EXPORT_SYMBOL(acpi_os_free);
164 154
165acpi_status 155acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
166acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
167{ 156{
168 if (efi_enabled) { 157 if (efi_enabled) {
169 addr->pointer_type = ACPI_PHYSICAL_POINTER; 158 addr->pointer_type = ACPI_PHYSICAL_POINTER;
170 if (efi.acpi20) 159 if (efi.acpi20)
171 addr->pointer.physical = 160 addr->pointer.physical =
172 (acpi_physical_address) virt_to_phys(efi.acpi20); 161 (acpi_physical_address) virt_to_phys(efi.acpi20);
173 else if (efi.acpi) 162 else if (efi.acpi)
174 addr->pointer.physical = 163 addr->pointer.physical =
175 (acpi_physical_address) virt_to_phys(efi.acpi); 164 (acpi_physical_address) virt_to_phys(efi.acpi);
176 else { 165 else {
177 printk(KERN_ERR PREFIX "System description tables not found\n"); 166 printk(KERN_ERR PREFIX
167 "System description tables not found\n");
178 return AE_NOT_FOUND; 168 return AE_NOT_FOUND;
179 } 169 }
180 } else { 170 } else {
181 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) { 171 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
182 printk(KERN_ERR PREFIX "System description tables not found\n"); 172 printk(KERN_ERR PREFIX
173 "System description tables not found\n");
183 return AE_NOT_FOUND; 174 return AE_NOT_FOUND;
184 } 175 }
185 } 176 }
@@ -188,11 +179,12 @@ acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
188} 179}
189 180
190acpi_status 181acpi_status
191acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **virt) 182acpi_os_map_memory(acpi_physical_address phys, acpi_size size,
183 void __iomem ** virt)
192{ 184{
193 if (efi_enabled) { 185 if (efi_enabled) {
194 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { 186 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) {
195 *virt = (void __iomem *) phys_to_virt(phys); 187 *virt = (void __iomem *)phys_to_virt(phys);
196 } else { 188 } else {
197 *virt = ioremap(phys, size); 189 *virt = ioremap(phys, size);
198 } 190 }
@@ -202,9 +194,9 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi
202 return AE_BAD_PARAMETER; 194 return AE_BAD_PARAMETER;
203 } 195 }
204 /* 196 /*
205 * ioremap checks to ensure this is in reserved space 197 * ioremap checks to ensure this is in reserved space
206 */ 198 */
207 *virt = ioremap((unsigned long) phys, size); 199 *virt = ioremap((unsigned long)phys, size);
208 } 200 }
209 201
210 if (!*virt) 202 if (!*virt)
@@ -213,17 +205,16 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi
213 return AE_OK; 205 return AE_OK;
214} 206}
215 207
216void 208void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
217acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
218{ 209{
219 iounmap(virt); 210 iounmap(virt);
220} 211}
221 212
222#ifdef ACPI_FUTURE_USAGE 213#ifdef ACPI_FUTURE_USAGE
223acpi_status 214acpi_status
224acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) 215acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
225{ 216{
226 if(!phys || !virt) 217 if (!phys || !virt)
227 return AE_BAD_PARAMETER; 218 return AE_BAD_PARAMETER;
228 219
229 *phys = virt_to_phys(virt); 220 *phys = virt_to_phys(virt);
@@ -237,16 +228,16 @@ acpi_os_get_physical_address(void *virt, acpi_physical_address *phys)
237static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; 228static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
238 229
239acpi_status 230acpi_status
240acpi_os_predefined_override (const struct acpi_predefined_names *init_val, 231acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
241 acpi_string *new_val) 232 acpi_string * new_val)
242{ 233{
243 if (!init_val || !new_val) 234 if (!init_val || !new_val)
244 return AE_BAD_PARAMETER; 235 return AE_BAD_PARAMETER;
245 236
246 *new_val = NULL; 237 *new_val = NULL;
247 if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { 238 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
248 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", 239 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
249 acpi_os_name); 240 acpi_os_name);
250 *new_val = acpi_os_name; 241 *new_val = acpi_os_name;
251 } 242 }
252 243
@@ -254,15 +245,15 @@ acpi_os_predefined_override (const struct acpi_predefined_names *init_val,
254} 245}
255 246
256acpi_status 247acpi_status
257acpi_os_table_override (struct acpi_table_header *existing_table, 248acpi_os_table_override(struct acpi_table_header * existing_table,
258 struct acpi_table_header **new_table) 249 struct acpi_table_header ** new_table)
259{ 250{
260 if (!existing_table || !new_table) 251 if (!existing_table || !new_table)
261 return AE_BAD_PARAMETER; 252 return AE_BAD_PARAMETER;
262 253
263#ifdef CONFIG_ACPI_CUSTOM_DSDT 254#ifdef CONFIG_ACPI_CUSTOM_DSDT
264 if (strncmp(existing_table->signature, "DSDT", 4) == 0) 255 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
265 *new_table = (struct acpi_table_header*)AmlCode; 256 *new_table = (struct acpi_table_header *)AmlCode;
266 else 257 else
267 *new_table = NULL; 258 *new_table = NULL;
268#else 259#else
@@ -271,14 +262,14 @@ acpi_os_table_override (struct acpi_table_header *existing_table,
271 return AE_OK; 262 return AE_OK;
272} 263}
273 264
274static irqreturn_t 265static irqreturn_t acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
275acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
276{ 266{
277 return (*acpi_irq_handler)(acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; 267 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
278} 268}
279 269
280acpi_status 270acpi_status
281acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *context) 271acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
272 void *context)
282{ 273{
283 unsigned int irq; 274 unsigned int irq;
284 275
@@ -305,8 +296,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *conte
305 return AE_OK; 296 return AE_OK;
306} 297}
307 298
308acpi_status 299acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
309acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
310{ 300{
311 if (irq) { 301 if (irq) {
312 free_irq(irq, acpi_irq); 302 free_irq(irq, acpi_irq);
@@ -321,16 +311,15 @@ acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
321 * Running in interpreter thread context, safe to sleep 311 * Running in interpreter thread context, safe to sleep
322 */ 312 */
323 313
324void 314void acpi_os_sleep(acpi_integer ms)
325acpi_os_sleep(acpi_integer ms)
326{ 315{
327 current->state = TASK_INTERRUPTIBLE; 316 current->state = TASK_INTERRUPTIBLE;
328 schedule_timeout(((signed long) ms * HZ) / 1000); 317 schedule_timeout(((signed long)ms * HZ) / 1000);
329} 318}
319
330EXPORT_SYMBOL(acpi_os_sleep); 320EXPORT_SYMBOL(acpi_os_sleep);
331 321
332void 322void acpi_os_stall(u32 us)
333acpi_os_stall(u32 us)
334{ 323{
335 while (us) { 324 while (us) {
336 u32 delay = 1000; 325 u32 delay = 1000;
@@ -342,6 +331,7 @@ acpi_os_stall(u32 us)
342 us -= delay; 331 us -= delay;
343 } 332 }
344} 333}
334
345EXPORT_SYMBOL(acpi_os_stall); 335EXPORT_SYMBOL(acpi_os_stall);
346 336
347/* 337/*
@@ -349,8 +339,7 @@ EXPORT_SYMBOL(acpi_os_stall);
349 * Returns 64-bit free-running, monotonically increasing timer 339 * Returns 64-bit free-running, monotonically increasing timer
350 * with 100ns granularity 340 * with 100ns granularity
351 */ 341 */
352u64 342u64 acpi_os_get_timer(void)
353acpi_os_get_timer (void)
354{ 343{
355 static u64 t; 344 static u64 t;
356 345
@@ -367,27 +356,22 @@ acpi_os_get_timer (void)
367 return ++t; 356 return ++t;
368} 357}
369 358
370acpi_status 359acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
371acpi_os_read_port(
372 acpi_io_address port,
373 u32 *value,
374 u32 width)
375{ 360{
376 u32 dummy; 361 u32 dummy;
377 362
378 if (!value) 363 if (!value)
379 value = &dummy; 364 value = &dummy;
380 365
381 switch (width) 366 switch (width) {
382 {
383 case 8: 367 case 8:
384 *(u8*) value = inb(port); 368 *(u8 *) value = inb(port);
385 break; 369 break;
386 case 16: 370 case 16:
387 *(u16*) value = inw(port); 371 *(u16 *) value = inw(port);
388 break; 372 break;
389 case 32: 373 case 32:
390 *(u32*) value = inl(port); 374 *(u32 *) value = inl(port);
391 break; 375 break;
392 default: 376 default:
393 BUG(); 377 BUG();
@@ -395,16 +379,12 @@ acpi_os_read_port(
395 379
396 return AE_OK; 380 return AE_OK;
397} 381}
382
398EXPORT_SYMBOL(acpi_os_read_port); 383EXPORT_SYMBOL(acpi_os_read_port);
399 384
400acpi_status 385acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
401acpi_os_write_port(
402 acpi_io_address port,
403 u32 value,
404 u32 width)
405{ 386{
406 switch (width) 387 switch (width) {
407 {
408 case 8: 388 case 8:
409 outb(value, port); 389 outb(value, port);
410 break; 390 break;
@@ -420,40 +400,38 @@ acpi_os_write_port(
420 400
421 return AE_OK; 401 return AE_OK;
422} 402}
403
423EXPORT_SYMBOL(acpi_os_write_port); 404EXPORT_SYMBOL(acpi_os_write_port);
424 405
425acpi_status 406acpi_status
426acpi_os_read_memory( 407acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
427 acpi_physical_address phys_addr,
428 u32 *value,
429 u32 width)
430{ 408{
431 u32 dummy; 409 u32 dummy;
432 void __iomem *virt_addr; 410 void __iomem *virt_addr;
433 int iomem = 0; 411 int iomem = 0;
434 412
435 if (efi_enabled) { 413 if (efi_enabled) {
436 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { 414 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
437 /* HACK ALERT! We can use readb/w/l on real memory too.. */ 415 /* HACK ALERT! We can use readb/w/l on real memory too.. */
438 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 416 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
439 } else { 417 } else {
440 iomem = 1; 418 iomem = 1;
441 virt_addr = ioremap(phys_addr, width); 419 virt_addr = ioremap(phys_addr, width);
442 } 420 }
443 } else 421 } else
444 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 422 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
445 if (!value) 423 if (!value)
446 value = &dummy; 424 value = &dummy;
447 425
448 switch (width) { 426 switch (width) {
449 case 8: 427 case 8:
450 *(u8*) value = readb(virt_addr); 428 *(u8 *) value = readb(virt_addr);
451 break; 429 break;
452 case 16: 430 case 16:
453 *(u16*) value = readw(virt_addr); 431 *(u16 *) value = readw(virt_addr);
454 break; 432 break;
455 case 32: 433 case 32:
456 *(u32*) value = readl(virt_addr); 434 *(u32 *) value = readl(virt_addr);
457 break; 435 break;
458 default: 436 default:
459 BUG(); 437 BUG();
@@ -468,24 +446,21 @@ acpi_os_read_memory(
468} 446}
469 447
470acpi_status 448acpi_status
471acpi_os_write_memory( 449acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
472 acpi_physical_address phys_addr,
473 u32 value,
474 u32 width)
475{ 450{
476 void __iomem *virt_addr; 451 void __iomem *virt_addr;
477 int iomem = 0; 452 int iomem = 0;
478 453
479 if (efi_enabled) { 454 if (efi_enabled) {
480 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { 455 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
481 /* HACK ALERT! We can use writeb/w/l on real memory too */ 456 /* HACK ALERT! We can use writeb/w/l on real memory too */
482 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 457 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
483 } else { 458 } else {
484 iomem = 1; 459 iomem = 1;
485 virt_addr = ioremap(phys_addr, width); 460 virt_addr = ioremap(phys_addr, width);
486 } 461 }
487 } else 462 } else
488 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 463 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
489 464
490 switch (width) { 465 switch (width) {
491 case 8: 466 case 8:
@@ -507,10 +482,9 @@ acpi_os_write_memory(
507 return AE_OK; 482 return AE_OK;
508} 483}
509 484
510#ifdef CONFIG_ACPI_PCI
511
512acpi_status 485acpi_status
513acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value, u32 width) 486acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
487 void *value, u32 width)
514{ 488{
515 int result, size; 489 int result, size;
516 490
@@ -534,15 +508,17 @@ acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value
534 BUG_ON(!raw_pci_ops); 508 BUG_ON(!raw_pci_ops);
535 509
536 result = raw_pci_ops->read(pci_id->segment, pci_id->bus, 510 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
537 PCI_DEVFN(pci_id->device, pci_id->function), 511 PCI_DEVFN(pci_id->device, pci_id->function),
538 reg, size, value); 512 reg, size, value);
539 513
540 return (result ? AE_ERROR : AE_OK); 514 return (result ? AE_ERROR : AE_OK);
541} 515}
516
542EXPORT_SYMBOL(acpi_os_read_pci_configuration); 517EXPORT_SYMBOL(acpi_os_read_pci_configuration);
543 518
544acpi_status 519acpi_status
545acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integer value, u32 width) 520acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
521 acpi_integer value, u32 width)
546{ 522{
547 int result, size; 523 int result, size;
548 524
@@ -563,56 +539,62 @@ acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integ
563 BUG_ON(!raw_pci_ops); 539 BUG_ON(!raw_pci_ops);
564 540
565 result = raw_pci_ops->write(pci_id->segment, pci_id->bus, 541 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
566 PCI_DEVFN(pci_id->device, pci_id->function), 542 PCI_DEVFN(pci_id->device, pci_id->function),
567 reg, size, value); 543 reg, size, value);
568 544
569 return (result ? AE_ERROR : AE_OK); 545 return (result ? AE_ERROR : AE_OK);
570} 546}
571 547
572/* TODO: Change code to take advantage of driver model more */ 548/* TODO: Change code to take advantage of driver model more */
573static void 549static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
574acpi_os_derive_pci_id_2 ( 550 acpi_handle chandle, /* current node */
575 acpi_handle rhandle, /* upper bound */ 551 struct acpi_pci_id **id,
576 acpi_handle chandle, /* current node */ 552 int *is_bridge, u8 * bus_number)
577 struct acpi_pci_id **id,
578 int *is_bridge,
579 u8 *bus_number)
580{ 553{
581 acpi_handle handle; 554 acpi_handle handle;
582 struct acpi_pci_id *pci_id = *id; 555 struct acpi_pci_id *pci_id = *id;
583 acpi_status status; 556 acpi_status status;
584 unsigned long temp; 557 unsigned long temp;
585 acpi_object_type type; 558 acpi_object_type type;
586 u8 tu8; 559 u8 tu8;
587 560
588 acpi_get_parent(chandle, &handle); 561 acpi_get_parent(chandle, &handle);
589 if (handle != rhandle) { 562 if (handle != rhandle) {
590 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, bus_number); 563 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
564 bus_number);
591 565
592 status = acpi_get_type(handle, &type); 566 status = acpi_get_type(handle, &type);
593 if ( (ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE) ) 567 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
594 return; 568 return;
595 569
596 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &temp); 570 status =
571 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
572 &temp);
597 if (ACPI_SUCCESS(status)) { 573 if (ACPI_SUCCESS(status)) {
598 pci_id->device = ACPI_HIWORD (ACPI_LODWORD (temp)); 574 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
599 pci_id->function = ACPI_LOWORD (ACPI_LODWORD (temp)); 575 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
600 576
601 if (*is_bridge) 577 if (*is_bridge)
602 pci_id->bus = *bus_number; 578 pci_id->bus = *bus_number;
603 579
604 /* any nicer way to get bus number of bridge ? */ 580 /* any nicer way to get bus number of bridge ? */
605 status = acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, 8); 581 status =
606 if (ACPI_SUCCESS(status) && 582 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
607 ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { 583 8);
608 status = acpi_os_read_pci_configuration(pci_id, 0x18, &tu8, 8); 584 if (ACPI_SUCCESS(status)
585 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
586 status =
587 acpi_os_read_pci_configuration(pci_id, 0x18,
588 &tu8, 8);
609 if (!ACPI_SUCCESS(status)) { 589 if (!ACPI_SUCCESS(status)) {
610 /* Certainly broken... FIX ME */ 590 /* Certainly broken... FIX ME */
611 return; 591 return;
612 } 592 }
613 *is_bridge = 1; 593 *is_bridge = 1;
614 pci_id->bus = tu8; 594 pci_id->bus = tu8;
615 status = acpi_os_read_pci_configuration(pci_id, 0x19, &tu8, 8); 595 status =
596 acpi_os_read_pci_configuration(pci_id, 0x19,
597 &tu8, 8);
616 if (ACPI_SUCCESS(status)) { 598 if (ACPI_SUCCESS(status)) {
617 *bus_number = tu8; 599 *bus_number = tu8;
618 } 600 }
@@ -622,11 +604,9 @@ acpi_os_derive_pci_id_2 (
622 } 604 }
623} 605}
624 606
625void 607void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
626acpi_os_derive_pci_id ( 608 acpi_handle chandle, /* current node */
627 acpi_handle rhandle, /* upper bound */ 609 struct acpi_pci_id **id)
628 acpi_handle chandle, /* current node */
629 struct acpi_pci_id **id)
630{ 610{
631 int is_bridge = 1; 611 int is_bridge = 1;
632 u8 bus_number = (*id)->bus; 612 u8 bus_number = (*id)->bus;
@@ -634,49 +614,15 @@ acpi_os_derive_pci_id (
634 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); 614 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
635} 615}
636 616
637#else /*!CONFIG_ACPI_PCI*/ 617static void acpi_os_execute_deferred(void *context)
638
639acpi_status
640acpi_os_write_pci_configuration (
641 struct acpi_pci_id *pci_id,
642 u32 reg,
643 acpi_integer value,
644 u32 width)
645{
646 return AE_SUPPORT;
647}
648
649acpi_status
650acpi_os_read_pci_configuration (
651 struct acpi_pci_id *pci_id,
652 u32 reg,
653 void *value,
654 u32 width)
655{
656 return AE_SUPPORT;
657}
658
659void
660acpi_os_derive_pci_id (
661 acpi_handle rhandle, /* upper bound */
662 acpi_handle chandle, /* current node */
663 struct acpi_pci_id **id)
664{
665}
666
667#endif /*CONFIG_ACPI_PCI*/
668
669static void
670acpi_os_execute_deferred (
671 void *context)
672{ 618{
673 struct acpi_os_dpc *dpc = NULL; 619 struct acpi_os_dpc *dpc = NULL;
674 620
675 ACPI_FUNCTION_TRACE ("os_execute_deferred"); 621 ACPI_FUNCTION_TRACE("os_execute_deferred");
676 622
677 dpc = (struct acpi_os_dpc *) context; 623 dpc = (struct acpi_os_dpc *)context;
678 if (!dpc) { 624 if (!dpc) {
679 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
680 return_VOID; 626 return_VOID;
681 } 627 }
682 628
@@ -688,21 +634,21 @@ acpi_os_execute_deferred (
688} 634}
689 635
690acpi_status 636acpi_status
691acpi_os_queue_for_execution( 637acpi_os_queue_for_execution(u32 priority,
692 u32 priority, 638 acpi_osd_exec_callback function, void *context)
693 acpi_osd_exec_callback function,
694 void *context)
695{ 639{
696 acpi_status status = AE_OK; 640 acpi_status status = AE_OK;
697 struct acpi_os_dpc *dpc; 641 struct acpi_os_dpc *dpc;
698 struct work_struct *task; 642 struct work_struct *task;
699 643
700 ACPI_FUNCTION_TRACE ("os_queue_for_execution"); 644 ACPI_FUNCTION_TRACE("os_queue_for_execution");
701 645
702 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); 646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
647 "Scheduling function [%p(%p)] for deferred execution.\n",
648 function, context));
703 649
704 if (!function) 650 if (!function)
705 return_ACPI_STATUS (AE_BAD_PARAMETER); 651 return_ACPI_STATUS(AE_BAD_PARAMETER);
706 652
707 /* 653 /*
708 * Allocate/initialize DPC structure. Note that this memory will be 654 * Allocate/initialize DPC structure. Note that this memory will be
@@ -715,146 +661,94 @@ acpi_os_queue_for_execution(
715 * from the same memory. 661 * from the same memory.
716 */ 662 */
717 663
718 dpc = kmalloc(sizeof(struct acpi_os_dpc)+sizeof(struct work_struct), GFP_ATOMIC); 664 dpc =
665 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
666 GFP_ATOMIC);
719 if (!dpc) 667 if (!dpc)
720 return_ACPI_STATUS (AE_NO_MEMORY); 668 return_ACPI_STATUS(AE_NO_MEMORY);
721 669
722 dpc->function = function; 670 dpc->function = function;
723 dpc->context = context; 671 dpc->context = context;
724 672
725 task = (void *)(dpc+1); 673 task = (void *)(dpc + 1);
726 INIT_WORK(task, acpi_os_execute_deferred, (void*)dpc); 674 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
727 675
728 if (!queue_work(kacpid_wq, task)) { 676 if (!queue_work(kacpid_wq, task)) {
729 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to queue_work() failed.\n")); 677 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
678 "Call to queue_work() failed.\n"));
730 kfree(dpc); 679 kfree(dpc);
731 status = AE_ERROR; 680 status = AE_ERROR;
732 } 681 }
733 682
734 return_ACPI_STATUS (status); 683 return_ACPI_STATUS(status);
735} 684}
685
736EXPORT_SYMBOL(acpi_os_queue_for_execution); 686EXPORT_SYMBOL(acpi_os_queue_for_execution);
737 687
738void 688void acpi_os_wait_events_complete(void *context)
739acpi_os_wait_events_complete(
740 void *context)
741{ 689{
742 flush_workqueue(kacpid_wq); 690 flush_workqueue(kacpid_wq);
743} 691}
692
744EXPORT_SYMBOL(acpi_os_wait_events_complete); 693EXPORT_SYMBOL(acpi_os_wait_events_complete);
745 694
746/* 695/*
747 * Allocate the memory for a spinlock and initialize it. 696 * Allocate the memory for a spinlock and initialize it.
748 */ 697 */
749acpi_status 698acpi_status acpi_os_create_lock(acpi_handle * out_handle)
750acpi_os_create_lock (
751 acpi_handle *out_handle)
752{ 699{
753 spinlock_t *lock_ptr; 700 spinlock_t *lock_ptr;
754 701
755 ACPI_FUNCTION_TRACE ("os_create_lock"); 702 ACPI_FUNCTION_TRACE("os_create_lock");
756 703
757 lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); 704 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
758 705
759 spin_lock_init(lock_ptr); 706 spin_lock_init(lock_ptr);
760 707
761 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); 708 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
762 709
763 *out_handle = lock_ptr; 710 *out_handle = lock_ptr;
764 711
765 return_ACPI_STATUS (AE_OK); 712 return_ACPI_STATUS(AE_OK);
766} 713}
767 714
768
769/* 715/*
770 * Deallocate the memory for a spinlock. 716 * Deallocate the memory for a spinlock.
771 */ 717 */
772void 718void acpi_os_delete_lock(acpi_handle handle)
773acpi_os_delete_lock (
774 acpi_handle handle)
775{ 719{
776 ACPI_FUNCTION_TRACE ("os_create_lock"); 720 ACPI_FUNCTION_TRACE("os_create_lock");
777 721
778 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); 722 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
779 723
780 acpi_os_free(handle); 724 acpi_os_free(handle);
781 725
782 return_VOID; 726 return_VOID;
783} 727}
784 728
785/*
786 * Acquire a spinlock.
787 *
788 * handle is a pointer to the spinlock_t.
789 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
790 * that indicates whether we are at interrupt level.
791 */
792void
793acpi_os_acquire_lock (
794 acpi_handle handle,
795 u32 flags)
796{
797 ACPI_FUNCTION_TRACE ("os_acquire_lock");
798
799 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle,
800 ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
801
802 if (flags & ACPI_NOT_ISR)
803 ACPI_DISABLE_IRQS();
804
805 spin_lock((spinlock_t *)handle);
806
807 return_VOID;
808}
809
810
811/*
812 * Release a spinlock. See above.
813 */
814void
815acpi_os_release_lock (
816 acpi_handle handle,
817 u32 flags)
818{
819 ACPI_FUNCTION_TRACE ("os_release_lock");
820
821 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle,
822 ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
823
824 spin_unlock((spinlock_t *)handle);
825
826 if (flags & ACPI_NOT_ISR)
827 ACPI_ENABLE_IRQS();
828
829 return_VOID;
830}
831
832
833acpi_status 729acpi_status
834acpi_os_create_semaphore( 730acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
835 u32 max_units,
836 u32 initial_units,
837 acpi_handle *handle)
838{ 731{
839 struct semaphore *sem = NULL; 732 struct semaphore *sem = NULL;
840 733
841 ACPI_FUNCTION_TRACE ("os_create_semaphore"); 734 ACPI_FUNCTION_TRACE("os_create_semaphore");
842 735
843 sem = acpi_os_allocate(sizeof(struct semaphore)); 736 sem = acpi_os_allocate(sizeof(struct semaphore));
844 if (!sem) 737 if (!sem)
845 return_ACPI_STATUS (AE_NO_MEMORY); 738 return_ACPI_STATUS(AE_NO_MEMORY);
846 memset(sem, 0, sizeof(struct semaphore)); 739 memset(sem, 0, sizeof(struct semaphore));
847 740
848 sema_init(sem, initial_units); 741 sema_init(sem, initial_units);
849 742
850 *handle = (acpi_handle*)sem; 743 *handle = (acpi_handle *) sem;
851 744
852 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); 745 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
746 *handle, initial_units));
853 747
854 return_ACPI_STATUS (AE_OK); 748 return_ACPI_STATUS(AE_OK);
855} 749}
856EXPORT_SYMBOL(acpi_os_create_semaphore);
857 750
751EXPORT_SYMBOL(acpi_os_create_semaphore);
858 752
859/* 753/*
860 * TODO: A better way to delete semaphores? Linux doesn't have a 754 * TODO: A better way to delete semaphores? Linux doesn't have a
@@ -863,25 +757,24 @@ EXPORT_SYMBOL(acpi_os_create_semaphore);
863 * we at least check for blocked threads and signal/cancel them? 757 * we at least check for blocked threads and signal/cancel them?
864 */ 758 */
865 759
866acpi_status 760acpi_status acpi_os_delete_semaphore(acpi_handle handle)
867acpi_os_delete_semaphore(
868 acpi_handle handle)
869{ 761{
870 struct semaphore *sem = (struct semaphore*) handle; 762 struct semaphore *sem = (struct semaphore *)handle;
871 763
872 ACPI_FUNCTION_TRACE ("os_delete_semaphore"); 764 ACPI_FUNCTION_TRACE("os_delete_semaphore");
873 765
874 if (!sem) 766 if (!sem)
875 return_ACPI_STATUS (AE_BAD_PARAMETER); 767 return_ACPI_STATUS(AE_BAD_PARAMETER);
876 768
877 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); 769 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
878 770
879 acpi_os_free(sem); sem = NULL; 771 acpi_os_free(sem);
772 sem = NULL;
880 773
881 return_ACPI_STATUS (AE_OK); 774 return_ACPI_STATUS(AE_OK);
882} 775}
883EXPORT_SYMBOL(acpi_os_delete_semaphore);
884 776
777EXPORT_SYMBOL(acpi_os_delete_semaphore);
885 778
886/* 779/*
887 * TODO: The kernel doesn't have a 'down_timeout' function -- had to 780 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
@@ -892,31 +785,27 @@ EXPORT_SYMBOL(acpi_os_delete_semaphore);
892 * 785 *
893 * TODO: Support for units > 1? 786 * TODO: Support for units > 1?
894 */ 787 */
895acpi_status 788acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
896acpi_os_wait_semaphore(
897 acpi_handle handle,
898 u32 units,
899 u16 timeout)
900{ 789{
901 acpi_status status = AE_OK; 790 acpi_status status = AE_OK;
902 struct semaphore *sem = (struct semaphore*)handle; 791 struct semaphore *sem = (struct semaphore *)handle;
903 int ret = 0; 792 int ret = 0;
904 793
905 ACPI_FUNCTION_TRACE ("os_wait_semaphore"); 794 ACPI_FUNCTION_TRACE("os_wait_semaphore");
906 795
907 if (!sem || (units < 1)) 796 if (!sem || (units < 1))
908 return_ACPI_STATUS (AE_BAD_PARAMETER); 797 return_ACPI_STATUS(AE_BAD_PARAMETER);
909 798
910 if (units > 1) 799 if (units > 1)
911 return_ACPI_STATUS (AE_SUPPORT); 800 return_ACPI_STATUS(AE_SUPPORT);
912 801
913 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); 802 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
803 handle, units, timeout));
914 804
915 if (in_atomic()) 805 if (in_atomic())
916 timeout = 0; 806 timeout = 0;
917 807
918 switch (timeout) 808 switch (timeout) {
919 {
920 /* 809 /*
921 * No Wait: 810 * No Wait:
922 * -------- 811 * --------
@@ -924,8 +813,8 @@ acpi_os_wait_semaphore(
924 * acquire the semaphore if available otherwise return AE_TIME 813 * acquire the semaphore if available otherwise return AE_TIME
925 * (a.k.a. 'would block'). 814 * (a.k.a. 'would block').
926 */ 815 */
927 case 0: 816 case 0:
928 if(down_trylock(sem)) 817 if (down_trylock(sem))
929 status = AE_TIME; 818 status = AE_TIME;
930 break; 819 break;
931 820
@@ -933,7 +822,7 @@ acpi_os_wait_semaphore(
933 * Wait Indefinitely: 822 * Wait Indefinitely:
934 * ------------------ 823 * ------------------
935 */ 824 */
936 case ACPI_WAIT_FOREVER: 825 case ACPI_WAIT_FOREVER:
937 down(sem); 826 down(sem);
938 break; 827 break;
939 828
@@ -941,11 +830,11 @@ acpi_os_wait_semaphore(
941 * Wait w/ Timeout: 830 * Wait w/ Timeout:
942 * ---------------- 831 * ----------------
943 */ 832 */
944 default: 833 default:
945 // TODO: A better timeout algorithm? 834 // TODO: A better timeout algorithm?
946 { 835 {
947 int i = 0; 836 int i = 0;
948 static const int quantum_ms = 1000/HZ; 837 static const int quantum_ms = 1000 / HZ;
949 838
950 ret = down_trylock(sem); 839 ret = down_trylock(sem);
951 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 840 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
@@ -953,7 +842,7 @@ acpi_os_wait_semaphore(
953 schedule_timeout(1); 842 schedule_timeout(1);
954 ret = down_trylock(sem); 843 ret = down_trylock(sem);
955 } 844 }
956 845
957 if (ret != 0) 846 if (ret != 0)
958 status = AE_TIME; 847 status = AE_TIME;
959 } 848 }
@@ -961,47 +850,48 @@ acpi_os_wait_semaphore(
961 } 850 }
962 851
963 if (ACPI_FAILURE(status)) { 852 if (ACPI_FAILURE(status)) {
964 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failed to acquire semaphore[%p|%d|%d], %s\n", 853 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
965 handle, units, timeout, acpi_format_exception(status))); 854 "Failed to acquire semaphore[%p|%d|%d], %s\n",
966 } 855 handle, units, timeout,
967 else { 856 acpi_format_exception(status)));
968 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout)); 857 } else {
858 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
859 "Acquired semaphore[%p|%d|%d]\n", handle,
860 units, timeout));
969 } 861 }
970 862
971 return_ACPI_STATUS (status); 863 return_ACPI_STATUS(status);
972} 864}
973EXPORT_SYMBOL(acpi_os_wait_semaphore);
974 865
866EXPORT_SYMBOL(acpi_os_wait_semaphore);
975 867
976/* 868/*
977 * TODO: Support for units > 1? 869 * TODO: Support for units > 1?
978 */ 870 */
979acpi_status 871acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
980acpi_os_signal_semaphore(
981 acpi_handle handle,
982 u32 units)
983{ 872{
984 struct semaphore *sem = (struct semaphore *) handle; 873 struct semaphore *sem = (struct semaphore *)handle;
985 874
986 ACPI_FUNCTION_TRACE ("os_signal_semaphore"); 875 ACPI_FUNCTION_TRACE("os_signal_semaphore");
987 876
988 if (!sem || (units < 1)) 877 if (!sem || (units < 1))
989 return_ACPI_STATUS (AE_BAD_PARAMETER); 878 return_ACPI_STATUS(AE_BAD_PARAMETER);
990 879
991 if (units > 1) 880 if (units > 1)
992 return_ACPI_STATUS (AE_SUPPORT); 881 return_ACPI_STATUS(AE_SUPPORT);
993 882
994 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); 883 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
884 units));
995 885
996 up(sem); 886 up(sem);
997 887
998 return_ACPI_STATUS (AE_OK); 888 return_ACPI_STATUS(AE_OK);
999} 889}
890
1000EXPORT_SYMBOL(acpi_os_signal_semaphore); 891EXPORT_SYMBOL(acpi_os_signal_semaphore);
1001 892
1002#ifdef ACPI_FUTURE_USAGE 893#ifdef ACPI_FUTURE_USAGE
1003u32 894u32 acpi_os_get_line(char *buffer)
1004acpi_os_get_line(char *buffer)
1005{ 895{
1006 896
1007#ifdef ENABLE_DEBUGGER 897#ifdef ENABLE_DEBUGGER
@@ -1018,22 +908,21 @@ acpi_os_get_line(char *buffer)
1018 908
1019 return 0; 909 return 0;
1020} 910}
1021#endif /* ACPI_FUTURE_USAGE */ 911#endif /* ACPI_FUTURE_USAGE */
1022 912
1023/* Assumes no unreadable holes inbetween */ 913/* Assumes no unreadable holes inbetween */
1024u8 914u8 acpi_os_readable(void *ptr, acpi_size len)
1025acpi_os_readable(void *ptr, acpi_size len)
1026{ 915{
1027#if defined(__i386__) || defined(__x86_64__) 916#if defined(__i386__) || defined(__x86_64__)
1028 char tmp; 917 char tmp;
1029 return !__get_user(tmp, (char __user *)ptr) && !__get_user(tmp, (char __user *)ptr + len - 1); 918 return !__get_user(tmp, (char __user *)ptr)
919 && !__get_user(tmp, (char __user *)ptr + len - 1);
1030#endif 920#endif
1031 return 1; 921 return 1;
1032} 922}
1033 923
1034#ifdef ACPI_FUTURE_USAGE 924#ifdef ACPI_FUTURE_USAGE
1035u8 925u8 acpi_os_writable(void *ptr, acpi_size len)
1036acpi_os_writable(void *ptr, acpi_size len)
1037{ 926{
1038 /* could do dummy write (racy) or a kernel page table lookup. 927 /* could do dummy write (racy) or a kernel page table lookup.
1039 The later may be difficult at early boot when kmap doesn't work yet. */ 928 The later may be difficult at early boot when kmap doesn't work yet. */
@@ -1041,8 +930,7 @@ acpi_os_writable(void *ptr, acpi_size len)
1041} 930}
1042#endif 931#endif
1043 932
1044u32 933u32 acpi_os_get_thread_id(void)
1045acpi_os_get_thread_id (void)
1046{ 934{
1047 if (!in_atomic()) 935 if (!in_atomic())
1048 return current->pid; 936 return current->pid;
@@ -1050,13 +938,9 @@ acpi_os_get_thread_id (void)
1050 return 0; 938 return 0;
1051} 939}
1052 940
1053acpi_status 941acpi_status acpi_os_signal(u32 function, void *info)
1054acpi_os_signal (
1055 u32 function,
1056 void *info)
1057{ 942{
1058 switch (function) 943 switch (function) {
1059 {
1060 case ACPI_SIGNAL_FATAL: 944 case ACPI_SIGNAL_FATAL:
1061 printk(KERN_ERR PREFIX "Fatal opcode executed\n"); 945 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
1062 break; 946 break;
@@ -1076,13 +960,13 @@ acpi_os_signal (
1076 960
1077 return AE_OK; 961 return AE_OK;
1078} 962}
963
1079EXPORT_SYMBOL(acpi_os_signal); 964EXPORT_SYMBOL(acpi_os_signal);
1080 965
1081static int __init 966static int __init acpi_os_name_setup(char *str)
1082acpi_os_name_setup(char *str)
1083{ 967{
1084 char *p = acpi_os_name; 968 char *p = acpi_os_name;
1085 int count = ACPI_MAX_OVERRIDE_LEN-1; 969 int count = ACPI_MAX_OVERRIDE_LEN - 1;
1086 970
1087 if (!str || !*str) 971 if (!str || !*str)
1088 return 0; 972 return 0;
@@ -1098,7 +982,7 @@ acpi_os_name_setup(char *str)
1098 *p = 0; 982 *p = 0;
1099 983
1100 return 1; 984 return 1;
1101 985
1102} 986}
1103 987
1104__setup("acpi_os_name=", acpi_os_name_setup); 988__setup("acpi_os_name=", acpi_os_name_setup);
@@ -1108,16 +992,15 @@ __setup("acpi_os_name=", acpi_os_name_setup);
1108 * empty string disables _OSI 992 * empty string disables _OSI
1109 * TBD additional string adds to _OSI 993 * TBD additional string adds to _OSI
1110 */ 994 */
1111static int __init 995static int __init acpi_osi_setup(char *str)
1112acpi_osi_setup(char *str)
1113{ 996{
1114 if (str == NULL || *str == '\0') { 997 if (str == NULL || *str == '\0') {
1115 printk(KERN_INFO PREFIX "_OSI method disabled\n"); 998 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1116 acpi_gbl_create_osi_method = FALSE; 999 acpi_gbl_create_osi_method = FALSE;
1117 } else 1000 } else {
1118 {
1119 /* TBD */ 1001 /* TBD */
1120 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", str); 1002 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
1003 str);
1121 } 1004 }
1122 1005
1123 return 1; 1006 return 1;
@@ -1126,8 +1009,7 @@ acpi_osi_setup(char *str)
1126__setup("acpi_osi=", acpi_osi_setup); 1009__setup("acpi_osi=", acpi_osi_setup);
1127 1010
1128/* enable serialization to combat AE_ALREADY_EXISTS errors */ 1011/* enable serialization to combat AE_ALREADY_EXISTS errors */
1129static int __init 1012static int __init acpi_serialize_setup(char *str)
1130acpi_serialize_setup(char *str)
1131{ 1013{
1132 printk(KERN_INFO PREFIX "serialize enabled\n"); 1014 printk(KERN_INFO PREFIX "serialize enabled\n");
1133 1015
@@ -1147,8 +1029,7 @@ __setup("acpi_serialize", acpi_serialize_setup);
1147 * Run-time events on the same GPE this flag is available 1029 * Run-time events on the same GPE this flag is available
1148 * to tell Linux to keep the wake-time GPEs enabled at run-time. 1030 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1149 */ 1031 */
1150static int __init 1032static int __init acpi_wake_gpes_always_on_setup(char *str)
1151acpi_wake_gpes_always_on_setup(char *str)
1152{ 1033{
1153 printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); 1034 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1154 1035
@@ -1159,8 +1040,7 @@ acpi_wake_gpes_always_on_setup(char *str)
1159 1040
1160__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); 1041__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1161 1042
1162int __init 1043static int __init acpi_hotkey_setup(char *str)
1163acpi_hotkey_setup(char *str)
1164{ 1044{
1165 acpi_specific_hotkey_enabled = FALSE; 1045 acpi_specific_hotkey_enabled = FALSE;
1166 return 1; 1046 return 1;
@@ -1174,5 +1054,132 @@ __setup("acpi_generic_hotkey", acpi_hotkey_setup);
1174 */ 1054 */
1175unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; 1055unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1176 1056
1177
1178EXPORT_SYMBOL(max_cstate); 1057EXPORT_SYMBOL(max_cstate);
1058
1059/*
1060 * Acquire a spinlock.
1061 *
1062 * handle is a pointer to the spinlock_t.
1063 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1064 * that indicates whether we are at interrupt level.
1065 */
1066
1067unsigned long acpi_os_acquire_lock(acpi_handle handle)
1068{
1069 unsigned long flags;
1070 spin_lock_irqsave((spinlock_t *) handle, flags);
1071 return flags;
1072}
1073
1074/*
1075 * Release a spinlock. See above.
1076 */
1077
1078void acpi_os_release_lock(acpi_handle handle, unsigned long flags)
1079{
1080 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1081}
1082
1083#ifndef ACPI_USE_LOCAL_CACHE
1084
1085/*******************************************************************************
1086 *
1087 * FUNCTION: acpi_os_create_cache
1088 *
1089 * PARAMETERS: CacheName - Ascii name for the cache
1090 * ObjectSize - Size of each cached object
1091 * MaxDepth - Maximum depth of the cache (in objects)
1092 * ReturnCache - Where the new cache object is returned
1093 *
1094 * RETURN: Status
1095 *
1096 * DESCRIPTION: Create a cache object
1097 *
1098 ******************************************************************************/
1099
1100acpi_status
1101acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1102{
1103 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1104 return AE_OK;
1105}
1106
1107/*******************************************************************************
1108 *
1109 * FUNCTION: acpi_os_purge_cache
1110 *
1111 * PARAMETERS: Cache - Handle to cache object
1112 *
1113 * RETURN: Status
1114 *
1115 * DESCRIPTION: Free all objects within the requested cache.
1116 *
1117 ******************************************************************************/
1118
1119acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1120{
1121 (void)kmem_cache_shrink(cache);
1122 return (AE_OK);
1123}
1124
1125/*******************************************************************************
1126 *
1127 * FUNCTION: acpi_os_delete_cache
1128 *
1129 * PARAMETERS: Cache - Handle to cache object
1130 *
1131 * RETURN: Status
1132 *
1133 * DESCRIPTION: Free all objects within the requested cache and delete the
1134 * cache object.
1135 *
1136 ******************************************************************************/
1137
1138acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1139{
1140 (void)kmem_cache_destroy(cache);
1141 return (AE_OK);
1142}
1143
1144/*******************************************************************************
1145 *
1146 * FUNCTION: acpi_os_release_object
1147 *
1148 * PARAMETERS: Cache - Handle to cache object
1149 * Object - The object to be released
1150 *
1151 * RETURN: None
1152 *
1153 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1154 * the object is deleted.
1155 *
1156 ******************************************************************************/
1157
1158acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1159{
1160 kmem_cache_free(cache, object);
1161 return (AE_OK);
1162}
1163
1164/*******************************************************************************
1165 *
1166 * FUNCTION: acpi_os_acquire_object
1167 *
1168 * PARAMETERS: Cache - Handle to cache object
1169 * ReturnObject - Where the object is returned
1170 *
1171 * RETURN: Status
1172 *
1173 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
1174 * the object is allocated.
1175 *
1176 ******************************************************************************/
1177
1178void *acpi_os_acquire_object(acpi_cache_t * cache)
1179{
1180 void *object = kmem_cache_alloc(cache, GFP_KERNEL);
1181 WARN_ON(!object);
1182 return object;
1183}
1184
1185#endif
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
index bbdd286c660d..db24ee09cf11 100644
--- a/drivers/acpi/parser/Makefile
+++ b/drivers/acpi/parser/Makefile
@@ -2,7 +2,7 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := psargs.o psparse.o pstree.o pswalk.o \ 5obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \
6 psopcode.o psscope.o psutils.o psxface.o 6 psopcode.o psscope.o psutils.o psxface.o
7 7
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index b7ac68cc9e1c..5858188f94a6 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -41,25 +41,20 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psargs") 50ACPI_MODULE_NAME("psargs")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static u32 53static u32
56acpi_ps_get_next_package_length ( 54acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state);
57 struct acpi_parse_state *parser_state);
58
59static union acpi_parse_object *
60acpi_ps_get_next_field (
61 struct acpi_parse_state *parser_state);
62 55
56static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
57 *parser_state);
63 58
64/******************************************************************************* 59/*******************************************************************************
65 * 60 *
@@ -75,49 +70,43 @@ acpi_ps_get_next_field (
75 ******************************************************************************/ 70 ******************************************************************************/
76 71
77static u32 72static u32
78acpi_ps_get_next_package_length ( 73acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
79 struct acpi_parse_state *parser_state)
80{ 74{
81 u32 encoded_length; 75 u32 encoded_length;
82 u32 length = 0; 76 u32 length = 0;
83 77
78 ACPI_FUNCTION_TRACE("ps_get_next_package_length");
84 79
85 ACPI_FUNCTION_TRACE ("ps_get_next_package_length"); 80 encoded_length = (u32) ACPI_GET8(parser_state->aml);
86
87
88 encoded_length = (u32) ACPI_GET8 (parser_state->aml);
89 parser_state->aml++; 81 parser_state->aml++;
90 82
91 switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ { 83 switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */
92 case 0: /* 1-byte encoding (bits 0-5) */ 84 case 0: /* 1-byte encoding (bits 0-5) */
93 85
94 length = (encoded_length & 0x3F); 86 length = (encoded_length & 0x3F);
95 break; 87 break;
96 88
89 case 1: /* 2-byte encoding (next byte + bits 0-3) */
97 90
98 case 1: /* 2-byte encoding (next byte + bits 0-3) */ 91 length = ((ACPI_GET8(parser_state->aml) << 04) |
99 92 (encoded_length & 0x0F));
100 length = ((ACPI_GET8 (parser_state->aml) << 04) |
101 (encoded_length & 0x0F));
102 parser_state->aml++; 93 parser_state->aml++;
103 break; 94 break;
104 95
96 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
105 97
106 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ 98 length = ((ACPI_GET8(parser_state->aml + 1) << 12) |
107 99 (ACPI_GET8(parser_state->aml) << 04) |
108 length = ((ACPI_GET8 (parser_state->aml + 1) << 12) | 100 (encoded_length & 0x0F));
109 (ACPI_GET8 (parser_state->aml) << 04) |
110 (encoded_length & 0x0F));
111 parser_state->aml += 2; 101 parser_state->aml += 2;
112 break; 102 break;
113 103
104 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
114 105
115 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ 106 length = ((ACPI_GET8(parser_state->aml + 2) << 20) |
116 107 (ACPI_GET8(parser_state->aml + 1) << 12) |
117 length = ((ACPI_GET8 (parser_state->aml + 2) << 20) | 108 (ACPI_GET8(parser_state->aml) << 04) |
118 (ACPI_GET8 (parser_state->aml + 1) << 12) | 109 (encoded_length & 0x0F));
119 (ACPI_GET8 (parser_state->aml) << 04) |
120 (encoded_length & 0x0F));
121 parser_state->aml += 3; 110 parser_state->aml += 3;
122 break; 111 break;
123 112
@@ -127,10 +116,9 @@ acpi_ps_get_next_package_length (
127 break; 116 break;
128 } 117 }
129 118
130 return_VALUE (length); 119 return_VALUE(length);
131} 120}
132 121
133
134/******************************************************************************* 122/*******************************************************************************
135 * 123 *
136 * FUNCTION: acpi_ps_get_next_package_end 124 * FUNCTION: acpi_ps_get_next_package_end
@@ -144,25 +132,21 @@ acpi_ps_get_next_package_length (
144 * 132 *
145 ******************************************************************************/ 133 ******************************************************************************/
146 134
147u8 * 135u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
148acpi_ps_get_next_package_end (
149 struct acpi_parse_state *parser_state)
150{ 136{
151 u8 *start = parser_state->aml; 137 u8 *start = parser_state->aml;
152 acpi_native_uint length; 138 acpi_native_uint length;
153
154
155 ACPI_FUNCTION_TRACE ("ps_get_next_package_end");
156 139
140 ACPI_FUNCTION_TRACE("ps_get_next_package_end");
157 141
158 /* Function below changes parser_state->Aml */ 142 /* Function below changes parser_state->Aml */
159 143
160 length = (acpi_native_uint) acpi_ps_get_next_package_length (parser_state); 144 length =
145 (acpi_native_uint) acpi_ps_get_next_package_length(parser_state);
161 146
162 return_PTR (start + length); /* end of package */ 147 return_PTR(start + length); /* end of package */
163} 148}
164 149
165
166/******************************************************************************* 150/*******************************************************************************
167 * 151 *
168 * FUNCTION: acpi_ps_get_next_namestring 152 * FUNCTION: acpi_ps_get_next_namestring
@@ -178,20 +162,16 @@ acpi_ps_get_next_package_end (
178 * 162 *
179 ******************************************************************************/ 163 ******************************************************************************/
180 164
181char * 165char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
182acpi_ps_get_next_namestring (
183 struct acpi_parse_state *parser_state)
184{ 166{
185 u8 *start = parser_state->aml; 167 u8 *start = parser_state->aml;
186 u8 *end = parser_state->aml; 168 u8 *end = parser_state->aml;
187
188
189 ACPI_FUNCTION_TRACE ("ps_get_next_namestring");
190 169
170 ACPI_FUNCTION_TRACE("ps_get_next_namestring");
191 171
192 /* Handle multiple prefix characters */ 172 /* Handle multiple prefix characters */
193 173
194 while (acpi_ps_is_prefix_char (ACPI_GET8 (end))) { 174 while (acpi_ps_is_prefix_char(ACPI_GET8(end))) {
195 /* Include prefix '\\' or '^' */ 175 /* Include prefix '\\' or '^' */
196 176
197 end++; 177 end++;
@@ -199,7 +179,7 @@ acpi_ps_get_next_namestring (
199 179
200 /* Decode the path */ 180 /* Decode the path */
201 181
202 switch (ACPI_GET8 (end)) { 182 switch (ACPI_GET8(end)) {
203 case 0: 183 case 0:
204 184
205 /* null_name */ 185 /* null_name */
@@ -221,7 +201,7 @@ acpi_ps_get_next_namestring (
221 201
222 /* Multiple name segments, 4 chars each */ 202 /* Multiple name segments, 4 chars each */
223 203
224 end += 2 + ((acpi_size) ACPI_GET8 (end + 1) * ACPI_NAME_SIZE); 204 end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE);
225 break; 205 break;
226 206
227 default: 207 default:
@@ -232,11 +212,10 @@ acpi_ps_get_next_namestring (
232 break; 212 break;
233 } 213 }
234 214
235 parser_state->aml = (u8*) end; 215 parser_state->aml = (u8 *) end;
236 return_PTR ((char *) start); 216 return_PTR((char *)start);
237} 217}
238 218
239
240/******************************************************************************* 219/*******************************************************************************
241 * 220 *
242 * FUNCTION: acpi_ps_get_next_namepath 221 * FUNCTION: acpi_ps_get_next_namepath
@@ -259,24 +238,20 @@ acpi_ps_get_next_namestring (
259 ******************************************************************************/ 238 ******************************************************************************/
260 239
261acpi_status 240acpi_status
262acpi_ps_get_next_namepath ( 241acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
263 struct acpi_walk_state *walk_state, 242 struct acpi_parse_state *parser_state,
264 struct acpi_parse_state *parser_state, 243 union acpi_parse_object *arg, u8 method_call)
265 union acpi_parse_object *arg,
266 u8 method_call)
267{ 244{
268 char *path; 245 char *path;
269 union acpi_parse_object *name_op; 246 union acpi_parse_object *name_op;
270 acpi_status status = AE_OK; 247 acpi_status status = AE_OK;
271 union acpi_operand_object *method_desc; 248 union acpi_operand_object *method_desc;
272 struct acpi_namespace_node *node; 249 struct acpi_namespace_node *node;
273 union acpi_generic_state scope_info; 250 union acpi_generic_state scope_info;
274 251
252 ACPI_FUNCTION_TRACE("ps_get_next_namepath");
275 253
276 ACPI_FUNCTION_TRACE ("ps_get_next_namepath"); 254 path = acpi_ps_get_next_namestring(parser_state);
277
278
279 path = acpi_ps_get_next_namestring (parser_state);
280 255
281 /* Null path case is allowed */ 256 /* Null path case is allowed */
282 257
@@ -296,49 +271,50 @@ acpi_ps_get_next_namepath (
296 * parent tree, but don't open a new scope -- we just want to lookup the 271 * parent tree, but don't open a new scope -- we just want to lookup the
297 * object (MUST BE mode EXECUTE to perform upsearch) 272 * object (MUST BE mode EXECUTE to perform upsearch)
298 */ 273 */
299 status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, 274 status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY,
300 ACPI_IMODE_EXECUTE, 275 ACPI_IMODE_EXECUTE,
301 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 276 ACPI_NS_SEARCH_PARENT |
302 NULL, &node); 277 ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
303 if (ACPI_SUCCESS (status) && method_call) { 278 if (ACPI_SUCCESS(status) && method_call) {
304 if (node->type == ACPI_TYPE_METHOD) { 279 if (node->type == ACPI_TYPE_METHOD) {
305 /* This name is actually a control method invocation */ 280 /* This name is actually a control method invocation */
306 281
307 method_desc = acpi_ns_get_attached_object (node); 282 method_desc = acpi_ns_get_attached_object(node);
308 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 283 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
309 "Control Method - %p Desc %p Path=%p\n", 284 "Control Method - %p Desc %p Path=%p\n",
310 node, method_desc, path)); 285 node, method_desc, path));
311 286
312 name_op = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP); 287 name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
313 if (!name_op) { 288 if (!name_op) {
314 return_ACPI_STATUS (AE_NO_MEMORY); 289 return_ACPI_STATUS(AE_NO_MEMORY);
315 } 290 }
316 291
317 /* Change arg into a METHOD CALL and attach name to it */ 292 /* Change arg into a METHOD CALL and attach name to it */
318 293
319 acpi_ps_init_op (arg, AML_INT_METHODCALL_OP); 294 acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
320 name_op->common.value.name = path; 295 name_op->common.value.name = path;
321 296
322 /* Point METHODCALL/NAME to the METHOD Node */ 297 /* Point METHODCALL/NAME to the METHOD Node */
323 298
324 name_op->common.node = node; 299 name_op->common.node = node;
325 acpi_ps_append_arg (arg, name_op); 300 acpi_ps_append_arg(arg, name_op);
326 301
327 if (!method_desc) { 302 if (!method_desc) {
328 ACPI_REPORT_ERROR (( 303 ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node));
329 "ps_get_next_namepath: Control Method %p has no attached object\n", 304 return_ACPI_STATUS(AE_AML_INTERNAL);
330 node));
331 return_ACPI_STATUS (AE_AML_INTERNAL);
332 } 305 }
333 306
334 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 307 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
335 "Control Method - %p Args %X\n", 308 "Control Method - %p Args %X\n",
336 node, method_desc->method.param_count)); 309 node,
310 method_desc->method.
311 param_count));
337 312
338 /* Get the number of arguments to expect */ 313 /* Get the number of arguments to expect */
339 314
340 walk_state->arg_count = method_desc->method.param_count; 315 walk_state->arg_count =
341 return_ACPI_STATUS (AE_OK); 316 method_desc->method.param_count;
317 return_ACPI_STATUS(AE_OK);
342 } 318 }
343 319
344 /* 320 /*
@@ -348,25 +324,26 @@ acpi_ps_get_next_namepath (
348 */ 324 */
349 } 325 }
350 326
351 if (ACPI_FAILURE (status)) { 327 if (ACPI_FAILURE(status)) {
352 /* 328 /*
353 * 1) Any error other than NOT_FOUND is always severe 329 * 1) Any error other than NOT_FOUND is always severe
354 * 2) NOT_FOUND is only important if we are executing a method. 330 * 2) NOT_FOUND is only important if we are executing a method.
355 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. 331 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok.
356 */ 332 */
357 if ((((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) && 333 if ((((walk_state->
358 (status == AE_NOT_FOUND) && 334 parse_flags & ACPI_PARSE_MODE_MASK) ==
359 (walk_state->op->common.aml_opcode != AML_COND_REF_OF_OP)) || 335 ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND)
360 336 && (walk_state->op->common.aml_opcode !=
361 (status != AE_NOT_FOUND)) { 337 AML_COND_REF_OF_OP))
362 ACPI_REPORT_NSERROR (path, status); 338 || (status != AE_NOT_FOUND)) {
363 339 ACPI_REPORT_NSERROR(path, status);
364 acpi_os_printf ("search_node %p start_node %p return_node %p\n", 340
365 scope_info.scope.node, parser_state->start_node, node); 341 acpi_os_printf
366 342 ("search_node %p start_node %p return_node %p\n",
367 343 scope_info.scope.node,
368 } 344 parser_state->start_node, node);
369 else { 345
346 } else {
370 /* 347 /*
371 * We got a NOT_FOUND during table load or we encountered 348 * We got a NOT_FOUND during table load or we encountered
372 * a cond_ref_of(x) where the target does not exist. 349 * a cond_ref_of(x) where the target does not exist.
@@ -381,13 +358,12 @@ acpi_ps_get_next_namepath (
381 * Regardless of success/failure above, 358 * Regardless of success/failure above,
382 * Just initialize the Op with the pathname. 359 * Just initialize the Op with the pathname.
383 */ 360 */
384 acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP); 361 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
385 arg->common.value.name = path; 362 arg->common.value.name = path;
386 363
387 return_ACPI_STATUS (status); 364 return_ACPI_STATUS(status);
388} 365}
389 366
390
391/******************************************************************************* 367/*******************************************************************************
392 * 368 *
393 * FUNCTION: acpi_ps_get_next_simple_arg 369 * FUNCTION: acpi_ps_get_next_simple_arg
@@ -403,87 +379,81 @@ acpi_ps_get_next_namepath (
403 ******************************************************************************/ 379 ******************************************************************************/
404 380
405void 381void
406acpi_ps_get_next_simple_arg ( 382acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
407 struct acpi_parse_state *parser_state, 383 u32 arg_type, union acpi_parse_object *arg)
408 u32 arg_type,
409 union acpi_parse_object *arg)
410{ 384{
411 385
412 ACPI_FUNCTION_TRACE_U32 ("ps_get_next_simple_arg", arg_type); 386 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type);
413
414 387
415 switch (arg_type) { 388 switch (arg_type) {
416 case ARGP_BYTEDATA: 389 case ARGP_BYTEDATA:
417 390
418 acpi_ps_init_op (arg, AML_BYTE_OP); 391 acpi_ps_init_op(arg, AML_BYTE_OP);
419 arg->common.value.integer = (u32) ACPI_GET8 (parser_state->aml); 392 arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml);
420 parser_state->aml++; 393 parser_state->aml++;
421 break; 394 break;
422 395
423
424 case ARGP_WORDDATA: 396 case ARGP_WORDDATA:
425 397
426 acpi_ps_init_op (arg, AML_WORD_OP); 398 acpi_ps_init_op(arg, AML_WORD_OP);
427 399
428 /* Get 2 bytes from the AML stream */ 400 /* Get 2 bytes from the AML stream */
429 401
430 ACPI_MOVE_16_TO_32 (&arg->common.value.integer, parser_state->aml); 402 ACPI_MOVE_16_TO_32(&arg->common.value.integer,
403 parser_state->aml);
431 parser_state->aml += 2; 404 parser_state->aml += 2;
432 break; 405 break;
433 406
434
435 case ARGP_DWORDDATA: 407 case ARGP_DWORDDATA:
436 408
437 acpi_ps_init_op (arg, AML_DWORD_OP); 409 acpi_ps_init_op(arg, AML_DWORD_OP);
438 410
439 /* Get 4 bytes from the AML stream */ 411 /* Get 4 bytes from the AML stream */
440 412
441 ACPI_MOVE_32_TO_32 (&arg->common.value.integer, parser_state->aml); 413 ACPI_MOVE_32_TO_32(&arg->common.value.integer,
414 parser_state->aml);
442 parser_state->aml += 4; 415 parser_state->aml += 4;
443 break; 416 break;
444 417
445
446 case ARGP_QWORDDATA: 418 case ARGP_QWORDDATA:
447 419
448 acpi_ps_init_op (arg, AML_QWORD_OP); 420 acpi_ps_init_op(arg, AML_QWORD_OP);
449 421
450 /* Get 8 bytes from the AML stream */ 422 /* Get 8 bytes from the AML stream */
451 423
452 ACPI_MOVE_64_TO_64 (&arg->common.value.integer, parser_state->aml); 424 ACPI_MOVE_64_TO_64(&arg->common.value.integer,
425 parser_state->aml);
453 parser_state->aml += 8; 426 parser_state->aml += 8;
454 break; 427 break;
455 428
456
457 case ARGP_CHARLIST: 429 case ARGP_CHARLIST:
458 430
459 acpi_ps_init_op (arg, AML_STRING_OP); 431 acpi_ps_init_op(arg, AML_STRING_OP);
460 arg->common.value.string = (char *) parser_state->aml; 432 arg->common.value.string = (char *)parser_state->aml;
461 433
462 while (ACPI_GET8 (parser_state->aml) != '\0') { 434 while (ACPI_GET8(parser_state->aml) != '\0') {
463 parser_state->aml++; 435 parser_state->aml++;
464 } 436 }
465 parser_state->aml++; 437 parser_state->aml++;
466 break; 438 break;
467 439
468
469 case ARGP_NAME: 440 case ARGP_NAME:
470 case ARGP_NAMESTRING: 441 case ARGP_NAMESTRING:
471 442
472 acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP); 443 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
473 arg->common.value.name = acpi_ps_get_next_namestring (parser_state); 444 arg->common.value.name =
445 acpi_ps_get_next_namestring(parser_state);
474 break; 446 break;
475 447
476
477 default: 448 default:
478 449
479 ACPI_REPORT_ERROR (("Invalid arg_type %X\n", arg_type)); 450 ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type));
480 break; 451 break;
481 } 452 }
482 453
483 return_VOID; 454 return_VOID;
484} 455}
485 456
486
487/******************************************************************************* 457/*******************************************************************************
488 * 458 *
489 * FUNCTION: acpi_ps_get_next_field 459 * FUNCTION: acpi_ps_get_next_field
@@ -496,24 +466,21 @@ acpi_ps_get_next_simple_arg (
496 * 466 *
497 ******************************************************************************/ 467 ******************************************************************************/
498 468
499static union acpi_parse_object * 469static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
500acpi_ps_get_next_field ( 470 *parser_state)
501 struct acpi_parse_state *parser_state)
502{ 471{
503 u32 aml_offset = (u32) 472 u32 aml_offset = (u32)
504 ACPI_PTR_DIFF (parser_state->aml, 473 ACPI_PTR_DIFF(parser_state->aml,
505 parser_state->aml_start); 474 parser_state->aml_start);
506 union acpi_parse_object *field; 475 union acpi_parse_object *field;
507 u16 opcode; 476 u16 opcode;
508 u32 name; 477 u32 name;
509
510
511 ACPI_FUNCTION_TRACE ("ps_get_next_field");
512 478
479 ACPI_FUNCTION_TRACE("ps_get_next_field");
513 480
514 /* Determine field type */ 481 /* Determine field type */
515 482
516 switch (ACPI_GET8 (parser_state->aml)) { 483 switch (ACPI_GET8(parser_state->aml)) {
517 default: 484 default:
518 485
519 opcode = AML_INT_NAMEDFIELD_OP; 486 opcode = AML_INT_NAMEDFIELD_OP;
@@ -534,9 +501,9 @@ acpi_ps_get_next_field (
534 501
535 /* Allocate a new field op */ 502 /* Allocate a new field op */
536 503
537 field = acpi_ps_alloc_op (opcode); 504 field = acpi_ps_alloc_op(opcode);
538 if (!field) { 505 if (!field) {
539 return_PTR (NULL); 506 return_PTR(NULL);
540 } 507 }
541 508
542 field->common.aml_offset = aml_offset; 509 field->common.aml_offset = aml_offset;
@@ -548,33 +515,34 @@ acpi_ps_get_next_field (
548 515
549 /* Get the 4-character name */ 516 /* Get the 4-character name */
550 517
551 ACPI_MOVE_32_TO_32 (&name, parser_state->aml); 518 ACPI_MOVE_32_TO_32(&name, parser_state->aml);
552 acpi_ps_set_name (field, name); 519 acpi_ps_set_name(field, name);
553 parser_state->aml += ACPI_NAME_SIZE; 520 parser_state->aml += ACPI_NAME_SIZE;
554 521
555 /* Get the length which is encoded as a package length */ 522 /* Get the length which is encoded as a package length */
556 523
557 field->common.value.size = acpi_ps_get_next_package_length (parser_state); 524 field->common.value.size =
525 acpi_ps_get_next_package_length(parser_state);
558 break; 526 break;
559 527
560
561 case AML_INT_RESERVEDFIELD_OP: 528 case AML_INT_RESERVEDFIELD_OP:
562 529
563 /* Get the length which is encoded as a package length */ 530 /* Get the length which is encoded as a package length */
564 531
565 field->common.value.size = acpi_ps_get_next_package_length (parser_state); 532 field->common.value.size =
533 acpi_ps_get_next_package_length(parser_state);
566 break; 534 break;
567 535
568
569 case AML_INT_ACCESSFIELD_OP: 536 case AML_INT_ACCESSFIELD_OP:
570 537
571 /* 538 /*
572 * Get access_type and access_attrib and merge into the field Op 539 * Get access_type and access_attrib and merge into the field Op
573 * access_type is first operand, access_attribute is second 540 * access_type is first operand, access_attribute is second
574 */ 541 */
575 field->common.value.integer = (ACPI_GET8 (parser_state->aml) << 8); 542 field->common.value.integer =
543 (ACPI_GET8(parser_state->aml) << 8);
576 parser_state->aml++; 544 parser_state->aml++;
577 field->common.value.integer |= ACPI_GET8 (parser_state->aml); 545 field->common.value.integer |= ACPI_GET8(parser_state->aml);
578 parser_state->aml++; 546 parser_state->aml++;
579 break; 547 break;
580 548
@@ -584,10 +552,9 @@ acpi_ps_get_next_field (
584 break; 552 break;
585 } 553 }
586 554
587 return_PTR (field); 555 return_PTR(field);
588} 556}
589 557
590
591/******************************************************************************* 558/*******************************************************************************
592 * 559 *
593 * FUNCTION: acpi_ps_get_next_arg 560 * FUNCTION: acpi_ps_get_next_arg
@@ -605,21 +572,17 @@ acpi_ps_get_next_field (
605 ******************************************************************************/ 572 ******************************************************************************/
606 573
607acpi_status 574acpi_status
608acpi_ps_get_next_arg ( 575acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
609 struct acpi_walk_state *walk_state, 576 struct acpi_parse_state *parser_state,
610 struct acpi_parse_state *parser_state, 577 u32 arg_type, union acpi_parse_object **return_arg)
611 u32 arg_type,
612 union acpi_parse_object **return_arg)
613{ 578{
614 union acpi_parse_object *arg = NULL; 579 union acpi_parse_object *arg = NULL;
615 union acpi_parse_object *prev = NULL; 580 union acpi_parse_object *prev = NULL;
616 union acpi_parse_object *field; 581 union acpi_parse_object *field;
617 u32 subop; 582 u32 subop;
618 acpi_status status = AE_OK; 583 acpi_status status = AE_OK;
619
620
621 ACPI_FUNCTION_TRACE_PTR ("ps_get_next_arg", parser_state);
622 584
585 ACPI_FUNCTION_TRACE_PTR("ps_get_next_arg", parser_state);
623 586
624 switch (arg_type) { 587 switch (arg_type) {
625 case ARGP_BYTEDATA: 588 case ARGP_BYTEDATA:
@@ -631,37 +594,35 @@ acpi_ps_get_next_arg (
631 594
632 /* Constants, strings, and namestrings are all the same size */ 595 /* Constants, strings, and namestrings are all the same size */
633 596
634 arg = acpi_ps_alloc_op (AML_BYTE_OP); 597 arg = acpi_ps_alloc_op(AML_BYTE_OP);
635 if (!arg) { 598 if (!arg) {
636 return_ACPI_STATUS (AE_NO_MEMORY); 599 return_ACPI_STATUS(AE_NO_MEMORY);
637 } 600 }
638 acpi_ps_get_next_simple_arg (parser_state, arg_type, arg); 601 acpi_ps_get_next_simple_arg(parser_state, arg_type, arg);
639 break; 602 break;
640 603
641
642 case ARGP_PKGLENGTH: 604 case ARGP_PKGLENGTH:
643 605
644 /* Package length, nothing returned */ 606 /* Package length, nothing returned */
645 607
646 parser_state->pkg_end = acpi_ps_get_next_package_end (parser_state); 608 parser_state->pkg_end =
609 acpi_ps_get_next_package_end(parser_state);
647 break; 610 break;
648 611
649
650 case ARGP_FIELDLIST: 612 case ARGP_FIELDLIST:
651 613
652 if (parser_state->aml < parser_state->pkg_end) { 614 if (parser_state->aml < parser_state->pkg_end) {
653 /* Non-empty list */ 615 /* Non-empty list */
654 616
655 while (parser_state->aml < parser_state->pkg_end) { 617 while (parser_state->aml < parser_state->pkg_end) {
656 field = acpi_ps_get_next_field (parser_state); 618 field = acpi_ps_get_next_field(parser_state);
657 if (!field) { 619 if (!field) {
658 return_ACPI_STATUS (AE_NO_MEMORY); 620 return_ACPI_STATUS(AE_NO_MEMORY);
659 } 621 }
660 622
661 if (prev) { 623 if (prev) {
662 prev->common.next = field; 624 prev->common.next = field;
663 } 625 } else {
664 else {
665 arg = field; 626 arg = field;
666 } 627 }
667 prev = field; 628 prev = field;
@@ -673,21 +634,21 @@ acpi_ps_get_next_arg (
673 } 634 }
674 break; 635 break;
675 636
676
677 case ARGP_BYTELIST: 637 case ARGP_BYTELIST:
678 638
679 if (parser_state->aml < parser_state->pkg_end) { 639 if (parser_state->aml < parser_state->pkg_end) {
680 /* Non-empty list */ 640 /* Non-empty list */
681 641
682 arg = acpi_ps_alloc_op (AML_INT_BYTELIST_OP); 642 arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP);
683 if (!arg) { 643 if (!arg) {
684 return_ACPI_STATUS (AE_NO_MEMORY); 644 return_ACPI_STATUS(AE_NO_MEMORY);
685 } 645 }
686 646
687 /* Fill in bytelist data */ 647 /* Fill in bytelist data */
688 648
689 arg->common.value.size = (u32) 649 arg->common.value.size = (u32)
690 ACPI_PTR_DIFF (parser_state->pkg_end, parser_state->aml); 650 ACPI_PTR_DIFF(parser_state->pkg_end,
651 parser_state->aml);
691 arg->named.data = parser_state->aml; 652 arg->named.data = parser_state->aml;
692 653
693 /* Skip to End of byte data */ 654 /* Skip to End of byte data */
@@ -696,32 +657,31 @@ acpi_ps_get_next_arg (
696 } 657 }
697 break; 658 break;
698 659
699
700 case ARGP_TARGET: 660 case ARGP_TARGET:
701 case ARGP_SUPERNAME: 661 case ARGP_SUPERNAME:
702 case ARGP_SIMPLENAME: 662 case ARGP_SIMPLENAME:
703 663
704 subop = acpi_ps_peek_opcode (parser_state); 664 subop = acpi_ps_peek_opcode(parser_state);
705 if (subop == 0 || 665 if (subop == 0 ||
706 acpi_ps_is_leading_char (subop) || 666 acpi_ps_is_leading_char(subop) ||
707 acpi_ps_is_prefix_char (subop)) { 667 acpi_ps_is_prefix_char(subop)) {
708 /* null_name or name_string */ 668 /* null_name or name_string */
709 669
710 arg = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP); 670 arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
711 if (!arg) { 671 if (!arg) {
712 return_ACPI_STATUS (AE_NO_MEMORY); 672 return_ACPI_STATUS(AE_NO_MEMORY);
713 } 673 }
714 674
715 status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0); 675 status =
716 } 676 acpi_ps_get_next_namepath(walk_state, parser_state,
717 else { 677 arg, 0);
678 } else {
718 /* Single complex argument, nothing returned */ 679 /* Single complex argument, nothing returned */
719 680
720 walk_state->arg_count = 1; 681 walk_state->arg_count = 1;
721 } 682 }
722 break; 683 break;
723 684
724
725 case ARGP_DATAOBJ: 685 case ARGP_DATAOBJ:
726 case ARGP_TERMARG: 686 case ARGP_TERMARG:
727 687
@@ -730,7 +690,6 @@ acpi_ps_get_next_arg (
730 walk_state->arg_count = 1; 690 walk_state->arg_count = 1;
731 break; 691 break;
732 692
733
734 case ARGP_DATAOBJLIST: 693 case ARGP_DATAOBJLIST:
735 case ARGP_TERMLIST: 694 case ARGP_TERMLIST:
736 case ARGP_OBJLIST: 695 case ARGP_OBJLIST:
@@ -742,14 +701,13 @@ acpi_ps_get_next_arg (
742 } 701 }
743 break; 702 break;
744 703
745
746 default: 704 default:
747 705
748 ACPI_REPORT_ERROR (("Invalid arg_type: %X\n", arg_type)); 706 ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type));
749 status = AE_AML_OPERAND_TYPE; 707 status = AE_AML_OPERAND_TYPE;
750 break; 708 break;
751 } 709 }
752 710
753 *return_arg = arg; 711 *return_arg = arg;
754 return_ACPI_STATUS (status); 712 return_ACPI_STATUS(status);
755} 713}
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
new file mode 100644
index 000000000000..088d33999d90
--- /dev/null
+++ b/drivers/acpi/parser/psloop.c
@@ -0,0 +1,874 @@
1/******************************************************************************
2 *
3 * Module Name: psloop - Main AML parse loop
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44/*
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
47 * generated parser to tightly constrain stack and dynamic memory
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
50 * templates in aml_op_info[]
51 */
52
53#include <acpi/acpi.h>
54#include <acpi/acparser.h>
55#include <acpi/acdispat.h>
56#include <acpi/amlcode.h>
57
58#define _COMPONENT ACPI_PARSER
59ACPI_MODULE_NAME("psloop")
60
61static u32 acpi_gbl_depth = 0;
62
63/*******************************************************************************
64 *
65 * FUNCTION: acpi_ps_parse_loop
66 *
67 * PARAMETERS: walk_state - Current state
68 *
69 * RETURN: Status
70 *
71 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
72 * a tree of ops.
73 *
74 ******************************************************************************/
75
76acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
77{
78 acpi_status status = AE_OK;
79 acpi_status status2;
80 union acpi_parse_object *op = NULL; /* current op */
81 union acpi_parse_object *arg = NULL;
82 union acpi_parse_object *pre_op = NULL;
83 struct acpi_parse_state *parser_state;
84 u8 *aml_op_start = NULL;
85
86 ACPI_FUNCTION_TRACE_PTR("ps_parse_loop", walk_state);
87
88 if (walk_state->descending_callback == NULL) {
89 return_ACPI_STATUS(AE_BAD_PARAMETER);
90 }
91
92 parser_state = &walk_state->parser_state;
93 walk_state->arg_types = 0;
94
95#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
96
97 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
98 /* We are restarting a preempted control method */
99
100 if (acpi_ps_has_completed_scope(parser_state)) {
101 /*
102 * We must check if a predicate to an IF or WHILE statement
103 * was just completed
104 */
105 if ((parser_state->scope->parse_scope.op) &&
106 ((parser_state->scope->parse_scope.op->common.
107 aml_opcode == AML_IF_OP)
108 || (parser_state->scope->parse_scope.op->common.
109 aml_opcode == AML_WHILE_OP))
110 && (walk_state->control_state)
111 && (walk_state->control_state->common.state ==
112 ACPI_CONTROL_PREDICATE_EXECUTING)) {
113 /*
114 * A predicate was just completed, get the value of the
115 * predicate and branch based on that value
116 */
117 walk_state->op = NULL;
118 status =
119 acpi_ds_get_predicate_value(walk_state,
120 ACPI_TO_POINTER
121 (TRUE));
122 if (ACPI_FAILURE(status)
123 && ((status & AE_CODE_MASK) !=
124 AE_CODE_CONTROL)) {
125 if (status == AE_AML_NO_RETURN_VALUE) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
127 "Invoked method did not return a value, %s\n",
128 acpi_format_exception
129 (status)));
130
131 }
132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
133 "get_predicate Failed, %s\n",
134 acpi_format_exception
135 (status)));
136 return_ACPI_STATUS(status);
137 }
138
139 status =
140 acpi_ps_next_parse_state(walk_state, op,
141 status);
142 }
143
144 acpi_ps_pop_scope(parser_state, &op,
145 &walk_state->arg_types,
146 &walk_state->arg_count);
147 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
148 "Popped scope, Op=%p\n", op));
149 } else if (walk_state->prev_op) {
150 /* We were in the middle of an op */
151
152 op = walk_state->prev_op;
153 walk_state->arg_types = walk_state->prev_arg_types;
154 }
155 }
156#endif
157
158 /* Iterative parsing loop, while there is more AML to process: */
159
160 while ((parser_state->aml < parser_state->aml_end) || (op)) {
161 aml_op_start = parser_state->aml;
162 if (!op) {
163 /* Get the next opcode from the AML stream */
164
165 walk_state->aml_offset =
166 (u32) ACPI_PTR_DIFF(parser_state->aml,
167 parser_state->aml_start);
168 walk_state->opcode = acpi_ps_peek_opcode(parser_state);
169
170 /*
171 * First cut to determine what we have found:
172 * 1) A valid AML opcode
173 * 2) A name string
174 * 3) An unknown/invalid opcode
175 */
176 walk_state->op_info =
177 acpi_ps_get_opcode_info(walk_state->opcode);
178 switch (walk_state->op_info->class) {
179 case AML_CLASS_ASCII:
180 case AML_CLASS_PREFIX:
181 /*
182 * Starts with a valid prefix or ASCII char, this is a name
183 * string. Convert the bare name string to a namepath.
184 */
185 walk_state->opcode = AML_INT_NAMEPATH_OP;
186 walk_state->arg_types = ARGP_NAMESTRING;
187 break;
188
189 case AML_CLASS_UNKNOWN:
190
191 /* The opcode is unrecognized. Just skip unknown opcodes */
192
193 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
194 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
195 walk_state->opcode,
196 parser_state->aml,
197 walk_state->aml_offset));
198
199 ACPI_DUMP_BUFFER(parser_state->aml, 128);
200
201 /* Assume one-byte bad opcode */
202
203 parser_state->aml++;
204 continue;
205
206 default:
207
208 /* Found opcode info, this is a normal opcode */
209
210 parser_state->aml +=
211 acpi_ps_get_opcode_size(walk_state->opcode);
212 walk_state->arg_types =
213 walk_state->op_info->parse_args;
214 break;
215 }
216
217 /* Create Op structure and append to parent's argument list */
218
219 if (walk_state->op_info->flags & AML_NAMED) {
220 /* Allocate a new pre_op if necessary */
221
222 if (!pre_op) {
223 pre_op =
224 acpi_ps_alloc_op(walk_state->
225 opcode);
226 if (!pre_op) {
227 status = AE_NO_MEMORY;
228 goto close_this_op;
229 }
230 }
231
232 pre_op->common.value.arg = NULL;
233 pre_op->common.aml_opcode = walk_state->opcode;
234
235 /*
236 * Get and append arguments until we find the node that contains
237 * the name (the type ARGP_NAME).
238 */
239 while (GET_CURRENT_ARG_TYPE
240 (walk_state->arg_types)
241 &&
242 (GET_CURRENT_ARG_TYPE
243 (walk_state->arg_types) != ARGP_NAME)) {
244 status =
245 acpi_ps_get_next_arg(walk_state,
246 parser_state,
247 GET_CURRENT_ARG_TYPE
248 (walk_state->
249 arg_types),
250 &arg);
251 if (ACPI_FAILURE(status)) {
252 goto close_this_op;
253 }
254
255 acpi_ps_append_arg(pre_op, arg);
256 INCREMENT_ARG_LIST(walk_state->
257 arg_types);
258 }
259
260 /*
261 * Make sure that we found a NAME and didn't run out of
262 * arguments
263 */
264 if (!GET_CURRENT_ARG_TYPE
265 (walk_state->arg_types)) {
266 status = AE_AML_NO_OPERAND;
267 goto close_this_op;
268 }
269
270 /* We know that this arg is a name, move to next arg */
271
272 INCREMENT_ARG_LIST(walk_state->arg_types);
273
274 /*
275 * Find the object. This will either insert the object into
276 * the namespace or simply look it up
277 */
278 walk_state->op = NULL;
279
280 status =
281 walk_state->descending_callback(walk_state,
282 &op);
283 if (ACPI_FAILURE(status)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
285 "During name lookup/catalog, %s\n",
286 acpi_format_exception
287 (status)));
288 goto close_this_op;
289 }
290
291 if (!op) {
292 continue;
293 }
294
295 status =
296 acpi_ps_next_parse_state(walk_state, op,
297 status);
298 if (status == AE_CTRL_PENDING) {
299 status = AE_OK;
300 goto close_this_op;
301 }
302
303 if (ACPI_FAILURE(status)) {
304 goto close_this_op;
305 }
306
307 acpi_ps_append_arg(op,
308 pre_op->common.value.arg);
309 acpi_gbl_depth++;
310
311 if (op->common.aml_opcode == AML_REGION_OP) {
312 /*
313 * Defer final parsing of an operation_region body,
314 * because we don't have enough info in the first pass
315 * to parse it correctly (i.e., there may be method
316 * calls within the term_arg elements of the body.)
317 *
318 * However, we must continue parsing because
319 * the opregion is not a standalone package --
320 * we don't know where the end is at this point.
321 *
322 * (Length is unknown until parse of the body complete)
323 */
324 op->named.data = aml_op_start;
325 op->named.length = 0;
326 }
327 } else {
328 /* Not a named opcode, just allocate Op and append to parent */
329
330 walk_state->op_info =
331 acpi_ps_get_opcode_info(walk_state->opcode);
332 op = acpi_ps_alloc_op(walk_state->opcode);
333 if (!op) {
334 status = AE_NO_MEMORY;
335 goto close_this_op;
336 }
337
338 if (walk_state->op_info->flags & AML_CREATE) {
339 /*
340 * Backup to beginning of create_xXXfield declaration
341 * body_length is unknown until we parse the body
342 */
343 op->named.data = aml_op_start;
344 op->named.length = 0;
345 }
346
347 acpi_ps_append_arg(acpi_ps_get_parent_scope
348 (parser_state), op);
349
350 if ((walk_state->descending_callback != NULL)) {
351 /*
352 * Find the object. This will either insert the object into
353 * the namespace or simply look it up
354 */
355 walk_state->op = op;
356
357 status =
358 walk_state->
359 descending_callback(walk_state,
360 &op);
361 status =
362 acpi_ps_next_parse_state(walk_state,
363 op,
364 status);
365 if (status == AE_CTRL_PENDING) {
366 status = AE_OK;
367 goto close_this_op;
368 }
369
370 if (ACPI_FAILURE(status)) {
371 goto close_this_op;
372 }
373 }
374 }
375
376 op->common.aml_offset = walk_state->aml_offset;
377
378 if (walk_state->op_info) {
379 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
380 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
381 (u32) op->common.aml_opcode,
382 walk_state->op_info->name, op,
383 parser_state->aml,
384 op->common.aml_offset));
385 }
386 }
387
388 /*
389 * Start arg_count at zero because we don't know if there are
390 * any args yet
391 */
392 walk_state->arg_count = 0;
393
394 /* Are there any arguments that must be processed? */
395
396 if (walk_state->arg_types) {
397 /* Get arguments */
398
399 switch (op->common.aml_opcode) {
400 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
401 case AML_WORD_OP: /* AML_WORDDATA_ARG */
402 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
403 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
404 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
405
406 /* Fill in constant or string argument directly */
407
408 acpi_ps_get_next_simple_arg(parser_state,
409 GET_CURRENT_ARG_TYPE
410 (walk_state->
411 arg_types), op);
412 break;
413
414 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
415
416 status =
417 acpi_ps_get_next_namepath(walk_state,
418 parser_state, op,
419 1);
420 if (ACPI_FAILURE(status)) {
421 goto close_this_op;
422 }
423
424 walk_state->arg_types = 0;
425 break;
426
427 default:
428 /*
429 * Op is not a constant or string, append each argument
430 * to the Op
431 */
432 while (GET_CURRENT_ARG_TYPE
433 (walk_state->arg_types)
434 && !walk_state->arg_count) {
435 walk_state->aml_offset = (u32)
436 ACPI_PTR_DIFF(parser_state->aml,
437 parser_state->
438 aml_start);
439
440 status =
441 acpi_ps_get_next_arg(walk_state,
442 parser_state,
443 GET_CURRENT_ARG_TYPE
444 (walk_state->
445 arg_types),
446 &arg);
447 if (ACPI_FAILURE(status)) {
448 goto close_this_op;
449 }
450
451 if (arg) {
452 arg->common.aml_offset =
453 walk_state->aml_offset;
454 acpi_ps_append_arg(op, arg);
455 }
456 INCREMENT_ARG_LIST(walk_state->
457 arg_types);
458 }
459
460 /* Special processing for certain opcodes */
461
462 /* TBD (remove): Temporary mechanism to disable this code if needed */
463
464#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
465
466 if ((walk_state->pass_number <=
467 ACPI_IMODE_LOAD_PASS1)
468 &&
469 ((walk_state->
470 parse_flags & ACPI_PARSE_DISASSEMBLE) ==
471 0)) {
472 /*
473 * We want to skip If/Else/While constructs during Pass1
474 * because we want to actually conditionally execute the
475 * code during Pass2.
476 *
477 * Except for disassembly, where we always want to
478 * walk the If/Else/While packages
479 */
480 switch (op->common.aml_opcode) {
481 case AML_IF_OP:
482 case AML_ELSE_OP:
483 case AML_WHILE_OP:
484
485 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
486 "Pass1: Skipping an If/Else/While body\n"));
487
488 /* Skip body of if/else/while in pass 1 */
489
490 parser_state->aml =
491 parser_state->pkg_end;
492 walk_state->arg_count = 0;
493 break;
494
495 default:
496 break;
497 }
498 }
499#endif
500 switch (op->common.aml_opcode) {
501 case AML_METHOD_OP:
502
503 /*
504 * Skip parsing of control method
505 * because we don't have enough info in the first pass
506 * to parse it correctly.
507 *
508 * Save the length and address of the body
509 */
510 op->named.data = parser_state->aml;
511 op->named.length =
512 (u32) (parser_state->pkg_end -
513 parser_state->aml);
514
515 /* Skip body of method */
516
517 parser_state->aml =
518 parser_state->pkg_end;
519 walk_state->arg_count = 0;
520 break;
521
522 case AML_BUFFER_OP:
523 case AML_PACKAGE_OP:
524 case AML_VAR_PACKAGE_OP:
525
526 if ((op->common.parent) &&
527 (op->common.parent->common.
528 aml_opcode == AML_NAME_OP)
529 && (walk_state->pass_number <=
530 ACPI_IMODE_LOAD_PASS2)) {
531 /*
532 * Skip parsing of Buffers and Packages
533 * because we don't have enough info in the first pass
534 * to parse them correctly.
535 */
536 op->named.data = aml_op_start;
537 op->named.length =
538 (u32) (parser_state->
539 pkg_end -
540 aml_op_start);
541
542 /* Skip body */
543
544 parser_state->aml =
545 parser_state->pkg_end;
546 walk_state->arg_count = 0;
547 }
548 break;
549
550 case AML_WHILE_OP:
551
552 if (walk_state->control_state) {
553 walk_state->control_state->
554 control.package_end =
555 parser_state->pkg_end;
556 }
557 break;
558
559 default:
560
561 /* No action for all other opcodes */
562 break;
563 }
564 break;
565 }
566 }
567
568 /* Check for arguments that need to be processed */
569
570 if (walk_state->arg_count) {
571 /*
572 * There are arguments (complex ones), push Op and
573 * prepare for argument
574 */
575 status = acpi_ps_push_scope(parser_state, op,
576 walk_state->arg_types,
577 walk_state->arg_count);
578 if (ACPI_FAILURE(status)) {
579 goto close_this_op;
580 }
581 op = NULL;
582 continue;
583 }
584
585 /*
586 * All arguments have been processed -- Op is complete,
587 * prepare for next
588 */
589 walk_state->op_info =
590 acpi_ps_get_opcode_info(op->common.aml_opcode);
591 if (walk_state->op_info->flags & AML_NAMED) {
592 if (acpi_gbl_depth) {
593 acpi_gbl_depth--;
594 }
595
596 if (op->common.aml_opcode == AML_REGION_OP) {
597 /*
598 * Skip parsing of control method or opregion body,
599 * because we don't have enough info in the first pass
600 * to parse them correctly.
601 *
602 * Completed parsing an op_region declaration, we now
603 * know the length.
604 */
605 op->named.length =
606 (u32) (parser_state->aml - op->named.data);
607 }
608 }
609
610 if (walk_state->op_info->flags & AML_CREATE) {
611 /*
612 * Backup to beginning of create_xXXfield declaration (1 for
613 * Opcode)
614 *
615 * body_length is unknown until we parse the body
616 */
617 op->named.length =
618 (u32) (parser_state->aml - op->named.data);
619 }
620
621 /* This op complete, notify the dispatcher */
622
623 if (walk_state->ascending_callback != NULL) {
624 walk_state->op = op;
625 walk_state->opcode = op->common.aml_opcode;
626
627 status = walk_state->ascending_callback(walk_state);
628 status =
629 acpi_ps_next_parse_state(walk_state, op, status);
630 if (status == AE_CTRL_PENDING) {
631 status = AE_OK;
632 goto close_this_op;
633 }
634 }
635
636 close_this_op:
637 /*
638 * Finished one argument of the containing scope
639 */
640 parser_state->scope->parse_scope.arg_count--;
641
642 /* Finished with pre_op */
643
644 if (pre_op) {
645 acpi_ps_free_op(pre_op);
646 pre_op = NULL;
647 }
648
649 /* Close this Op (will result in parse subtree deletion) */
650
651 status2 = acpi_ps_complete_this_op(walk_state, op);
652 if (ACPI_FAILURE(status2)) {
653 return_ACPI_STATUS(status2);
654 }
655 op = NULL;
656
657 switch (status) {
658 case AE_OK:
659 break;
660
661 case AE_CTRL_TRANSFER:
662
663 /* We are about to transfer to a called method. */
664
665 walk_state->prev_op = op;
666 walk_state->prev_arg_types = walk_state->arg_types;
667 return_ACPI_STATUS(status);
668
669 case AE_CTRL_END:
670
671 acpi_ps_pop_scope(parser_state, &op,
672 &walk_state->arg_types,
673 &walk_state->arg_count);
674
675 if (op) {
676 walk_state->op = op;
677 walk_state->op_info =
678 acpi_ps_get_opcode_info(op->common.
679 aml_opcode);
680 walk_state->opcode = op->common.aml_opcode;
681
682 status =
683 walk_state->ascending_callback(walk_state);
684 status =
685 acpi_ps_next_parse_state(walk_state, op,
686 status);
687
688 status2 =
689 acpi_ps_complete_this_op(walk_state, op);
690 if (ACPI_FAILURE(status2)) {
691 return_ACPI_STATUS(status2);
692 }
693 op = NULL;
694 }
695 status = AE_OK;
696 break;
697
698 case AE_CTRL_BREAK:
699 case AE_CTRL_CONTINUE:
700
701 /* Pop off scopes until we find the While */
702
703 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
704 acpi_ps_pop_scope(parser_state, &op,
705 &walk_state->arg_types,
706 &walk_state->arg_count);
707 }
708
709 /* Close this iteration of the While loop */
710
711 walk_state->op = op;
712 walk_state->op_info =
713 acpi_ps_get_opcode_info(op->common.aml_opcode);
714 walk_state->opcode = op->common.aml_opcode;
715
716 status = walk_state->ascending_callback(walk_state);
717 status =
718 acpi_ps_next_parse_state(walk_state, op, status);
719
720 status2 = acpi_ps_complete_this_op(walk_state, op);
721 if (ACPI_FAILURE(status2)) {
722 return_ACPI_STATUS(status2);
723 }
724 op = NULL;
725
726 status = AE_OK;
727 break;
728
729 case AE_CTRL_TERMINATE:
730
731 status = AE_OK;
732
733 /* Clean up */
734 do {
735 if (op) {
736 status2 =
737 acpi_ps_complete_this_op(walk_state,
738 op);
739 if (ACPI_FAILURE(status2)) {
740 return_ACPI_STATUS(status2);
741 }
742 }
743 acpi_ps_pop_scope(parser_state, &op,
744 &walk_state->arg_types,
745 &walk_state->arg_count);
746
747 } while (op);
748
749 return_ACPI_STATUS(status);
750
751 default: /* All other non-AE_OK status */
752
753 do {
754 if (op) {
755 status2 =
756 acpi_ps_complete_this_op(walk_state,
757 op);
758 if (ACPI_FAILURE(status2)) {
759 return_ACPI_STATUS(status2);
760 }
761 }
762 acpi_ps_pop_scope(parser_state, &op,
763 &walk_state->arg_types,
764 &walk_state->arg_count);
765
766 } while (op);
767
768 /*
769 * TBD: Cleanup parse ops on error
770 */
771#if 0
772 if (op == NULL) {
773 acpi_ps_pop_scope(parser_state, &op,
774 &walk_state->arg_types,
775 &walk_state->arg_count);
776 }
777#endif
778 walk_state->prev_op = op;
779 walk_state->prev_arg_types = walk_state->arg_types;
780 return_ACPI_STATUS(status);
781 }
782
783 /* This scope complete? */
784
785 if (acpi_ps_has_completed_scope(parser_state)) {
786 acpi_ps_pop_scope(parser_state, &op,
787 &walk_state->arg_types,
788 &walk_state->arg_count);
789 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
790 "Popped scope, Op=%p\n", op));
791 } else {
792 op = NULL;
793 }
794
795 } /* while parser_state->Aml */
796
797 /*
798 * Complete the last Op (if not completed), and clear the scope stack.
799 * It is easily possible to end an AML "package" with an unbounded number
800 * of open scopes (such as when several ASL blocks are closed with
801 * sequential closing braces). We want to terminate each one cleanly.
802 */
803 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
804 op));
805 do {
806 if (op) {
807 if (walk_state->ascending_callback != NULL) {
808 walk_state->op = op;
809 walk_state->op_info =
810 acpi_ps_get_opcode_info(op->common.
811 aml_opcode);
812 walk_state->opcode = op->common.aml_opcode;
813
814 status =
815 walk_state->ascending_callback(walk_state);
816 status =
817 acpi_ps_next_parse_state(walk_state, op,
818 status);
819 if (status == AE_CTRL_PENDING) {
820 status = AE_OK;
821 goto close_this_op;
822 }
823
824 if (status == AE_CTRL_TERMINATE) {
825 status = AE_OK;
826
827 /* Clean up */
828 do {
829 if (op) {
830 status2 =
831 acpi_ps_complete_this_op
832 (walk_state, op);
833 if (ACPI_FAILURE
834 (status2)) {
835 return_ACPI_STATUS
836 (status2);
837 }
838 }
839
840 acpi_ps_pop_scope(parser_state,
841 &op,
842 &walk_state->
843 arg_types,
844 &walk_state->
845 arg_count);
846
847 } while (op);
848
849 return_ACPI_STATUS(status);
850 }
851
852 else if (ACPI_FAILURE(status)) {
853 /* First error is most important */
854
855 (void)
856 acpi_ps_complete_this_op(walk_state,
857 op);
858 return_ACPI_STATUS(status);
859 }
860 }
861
862 status2 = acpi_ps_complete_this_op(walk_state, op);
863 if (ACPI_FAILURE(status2)) {
864 return_ACPI_STATUS(status2);
865 }
866 }
867
868 acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types,
869 &walk_state->arg_count);
870
871 } while (op);
872
873 return_ACPI_STATUS(status);
874}
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 5744673568c0..229ae86afe8b 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -41,16 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/acopcode.h> 46#include <acpi/acopcode.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49 48
50
51#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
52 ACPI_MODULE_NAME ("psopcode") 50ACPI_MODULE_NAME("psopcode")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -62,7 +59,6 @@
62 * the operand type. 59 * the operand type.
63 * 60 *
64 ******************************************************************************/ 61 ******************************************************************************/
65
66/* 62/*
67 * Summary of opcode types/flags 63 * Summary of opcode types/flags
68 * 64 *
@@ -180,156 +176,468 @@
180 AML_CREATE_QWORD_FIELD_OP 176 AML_CREATE_QWORD_FIELD_OP
181 177
182 ******************************************************************************/ 178 ******************************************************************************/
183
184
185/* 179/*
186 * Master Opcode information table. A summary of everything we know about each 180 * Master Opcode information table. A summary of everything we know about each
187 * opcode, all in one place. 181 * opcode, all in one place.
188 */ 182 */
189const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = 183const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
190{
191/*! [Begin] no source code translation */ 184/*! [Begin] no source code translation */
192/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ 185/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */
193 186
194/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), 187/* 00 */ ACPI_OP("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER,
195/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), 188 AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
196/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 189/* 01 */ ACPI_OP("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER,
197/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 190 AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
198/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), 191/* 02 */ ACPI_OP("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP,
199/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), 192 ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT,
200/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), 193 AML_TYPE_NAMED_SIMPLE,
201/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), 194 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
202/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 195 AML_NSNODE | AML_NAMED),
203/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), 196/* 03 */ ACPI_OP("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY,
204/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), 197 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX,
205/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), 198 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
206/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 199 AML_NSNODE | AML_NAMED),
207/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 200/* 04 */ ACPI_OP("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP,
208/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 201 ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT,
209/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 202 AML_TYPE_LITERAL, AML_CONSTANT),
210/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 203/* 05 */ ACPI_OP("WordConst", ARGP_WORD_OP, ARGI_WORD_OP,
211/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 204 ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT,
212/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 205 AML_TYPE_LITERAL, AML_CONSTANT),
213/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), 206/* 06 */ ACPI_OP("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP,
214/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 207 ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT,
215/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 208 AML_TYPE_LITERAL, AML_CONSTANT),
216/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 209/* 07 */ ACPI_OP("String", ARGP_STRING_OP, ARGI_STRING_OP,
217/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 210 ACPI_TYPE_STRING, AML_CLASS_ARGUMENT,
218/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 211 AML_TYPE_LITERAL, AML_CONSTANT),
219/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 212/* 08 */ ACPI_OP("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP,
220/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), 213 ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT,
221/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), 214 AML_TYPE_NAMED_NO_OBJ,
222/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), 215 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
223/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 216 AML_NSNODE | AML_NAMED),
224/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), 217/* 09 */ ACPI_OP("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP,
225/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 218 ACPI_TYPE_BUFFER, AML_CLASS_CREATE,
226/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), 219 AML_TYPE_CREATE_OBJECT,
227/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), 220 AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
228/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 221/* 0A */ ACPI_OP("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP,
229/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), 222 ACPI_TYPE_PACKAGE, AML_CLASS_CREATE,
230/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 223 AML_TYPE_CREATE_OBJECT,
231/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 224 AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
232/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 225/* 0B */ ACPI_OP("Method", ARGP_METHOD_OP, ARGI_METHOD_OP,
233/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 226 ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT,
234/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 227 AML_TYPE_NAMED_COMPLEX,
235/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 228 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
236/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), 229 AML_NSNODE | AML_NAMED | AML_DEFER),
237/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 230/* 0C */ ACPI_OP("Local0", ARGP_LOCAL0, ARGI_LOCAL0,
238/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 231 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
239/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 232 AML_TYPE_LOCAL_VARIABLE, 0),
240/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), 233/* 0D */ ACPI_OP("Local1", ARGP_LOCAL1, ARGI_LOCAL1,
241/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), 234 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
242/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), 235 AML_TYPE_LOCAL_VARIABLE, 0),
243/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), 236/* 0E */ ACPI_OP("Local2", ARGP_LOCAL2, ARGI_LOCAL2,
244/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), 237 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
245/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), 238 AML_TYPE_LOCAL_VARIABLE, 0),
246/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), 239/* 0F */ ACPI_OP("Local3", ARGP_LOCAL3, ARGI_LOCAL3,
247/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), 240 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
248/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), 241 AML_TYPE_LOCAL_VARIABLE, 0),
249/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), 242/* 10 */ ACPI_OP("Local4", ARGP_LOCAL4, ARGI_LOCAL4,
250/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), 243 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
251/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), 244 AML_TYPE_LOCAL_VARIABLE, 0),
252/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), 245/* 11 */ ACPI_OP("Local5", ARGP_LOCAL5, ARGI_LOCAL5,
253/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), 246 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
254/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), 247 AML_TYPE_LOCAL_VARIABLE, 0),
255/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), 248/* 12 */ ACPI_OP("Local6", ARGP_LOCAL6, ARGI_LOCAL6,
256/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), 249 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
257/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), 250 AML_TYPE_LOCAL_VARIABLE, 0),
258/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), 251/* 13 */ ACPI_OP("Local7", ARGP_LOCAL7, ARGI_LOCAL7,
259/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), 252 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
260/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), 253 AML_TYPE_LOCAL_VARIABLE, 0),
261/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), 254/* 14 */ ACPI_OP("Arg0", ARGP_ARG0, ARGI_ARG0,
262/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), 255 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
263/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), 256 AML_TYPE_METHOD_ARGUMENT, 0),
257/* 15 */ ACPI_OP("Arg1", ARGP_ARG1, ARGI_ARG1,
258 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
259 AML_TYPE_METHOD_ARGUMENT, 0),
260/* 16 */ ACPI_OP("Arg2", ARGP_ARG2, ARGI_ARG2,
261 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
262 AML_TYPE_METHOD_ARGUMENT, 0),
263/* 17 */ ACPI_OP("Arg3", ARGP_ARG3, ARGI_ARG3,
264 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
265 AML_TYPE_METHOD_ARGUMENT, 0),
266/* 18 */ ACPI_OP("Arg4", ARGP_ARG4, ARGI_ARG4,
267 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
268 AML_TYPE_METHOD_ARGUMENT, 0),
269/* 19 */ ACPI_OP("Arg5", ARGP_ARG5, ARGI_ARG5,
270 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
271 AML_TYPE_METHOD_ARGUMENT, 0),
272/* 1A */ ACPI_OP("Arg6", ARGP_ARG6, ARGI_ARG6,
273 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
274 AML_TYPE_METHOD_ARGUMENT, 0),
275/* 1B */ ACPI_OP("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY,
276 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
277 AML_FLAGS_EXEC_1A_1T_1R),
278/* 1C */ ACPI_OP("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY,
279 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R,
280 AML_FLAGS_EXEC_1A_0T_1R),
281/* 1D */ ACPI_OP("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY,
282 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
283 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
284/* 1E */ ACPI_OP("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP,
285 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
286 AML_TYPE_EXEC_2A_1T_1R,
287 AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
288/* 1F */ ACPI_OP("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP,
289 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
290 AML_TYPE_EXEC_2A_1T_1R,
291 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
292/* 20 */ ACPI_OP("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP,
293 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
294 AML_TYPE_EXEC_1A_0T_1R,
295 AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
296/* 21 */ ACPI_OP("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP,
297 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
298 AML_TYPE_EXEC_1A_0T_1R,
299 AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
300/* 22 */ ACPI_OP("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP,
301 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
302 AML_TYPE_EXEC_2A_1T_1R,
303 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
304/* 23 */ ACPI_OP("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP,
305 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
306 AML_TYPE_EXEC_2A_2T_1R,
307 AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
308/* 24 */ ACPI_OP("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP,
309 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
310 AML_TYPE_EXEC_2A_1T_1R,
311 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
312/* 25 */ ACPI_OP("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP,
313 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
314 AML_TYPE_EXEC_2A_1T_1R,
315 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
316/* 26 */ ACPI_OP("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY,
317 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
318 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
319/* 27 */ ACPI_OP("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP,
320 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
321 AML_TYPE_EXEC_2A_1T_1R,
322 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
323/* 28 */ ACPI_OP("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY,
324 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
325 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
326/* 29 */ ACPI_OP("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY,
327 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
328 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
329/* 2A */ ACPI_OP("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY,
330 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
331 AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
332/* 2B */ ACPI_OP("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY,
333 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
334 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
335/* 2C */ ACPI_OP("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP,
336 ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY,
337 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
338 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
339/* 2D */ ACPI_OP("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,
340 ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY,
341 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
342 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
343/* 2E */ ACPI_OP("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP,
344 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
345 AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
346/* 2F */ ACPI_OP("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP,
347 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
348 AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R),
349/* 30 */ ACPI_OP("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP,
350 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
351 AML_TYPE_EXEC_1A_0T_1R,
352 AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
353/* 31 */ ACPI_OP("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY,
354 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
355 AML_FLAGS_EXEC_2A_1T_1R),
356/* 32 */ ACPI_OP("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY,
357 AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R,
358 AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
359/* 33 */ ACPI_OP("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,
360 ARGI_CREATE_DWORD_FIELD_OP,
361 ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE,
362 AML_TYPE_CREATE_FIELD,
363 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
364 AML_DEFER | AML_CREATE),
365/* 34 */ ACPI_OP("CreateWordField", ARGP_CREATE_WORD_FIELD_OP,
366 ARGI_CREATE_WORD_FIELD_OP,
367 ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE,
368 AML_TYPE_CREATE_FIELD,
369 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
370 AML_DEFER | AML_CREATE),
371/* 35 */ ACPI_OP("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP,
372 ARGI_CREATE_BYTE_FIELD_OP,
373 ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE,
374 AML_TYPE_CREATE_FIELD,
375 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
376 AML_DEFER | AML_CREATE),
377/* 36 */ ACPI_OP("CreateBitField", ARGP_CREATE_BIT_FIELD_OP,
378 ARGI_CREATE_BIT_FIELD_OP,
379 ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE,
380 AML_TYPE_CREATE_FIELD,
381 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
382 AML_DEFER | AML_CREATE),
383/* 37 */ ACPI_OP("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP,
384 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
385 AML_TYPE_EXEC_1A_0T_1R,
386 AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
387/* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY,
388 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
389 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC |
390 AML_CONSTANT),
391/* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY,
392 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
393 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC |
394 AML_CONSTANT),
395/* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY,
396 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R,
397 AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
398/* 3B */ ACPI_OP("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP,
399 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
400 AML_TYPE_EXEC_2A_0T_1R,
401 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
402/* 3C */ ACPI_OP("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP,
403 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
404 AML_TYPE_EXEC_2A_0T_1R,
405 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
406/* 3D */ ACPI_OP("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY,
407 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
408 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
409/* 3E */ ACPI_OP("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY,
410 AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
411/* 3F */ ACPI_OP("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY,
412 AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
413/* 40 */ ACPI_OP("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY,
414 AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
415/* 41 */ ACPI_OP("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY,
416 AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
417/* 42 */ ACPI_OP("Return", ARGP_RETURN_OP, ARGI_RETURN_OP,
418 ACPI_TYPE_ANY, AML_CLASS_CONTROL,
419 AML_TYPE_CONTROL, AML_HAS_ARGS),
420/* 43 */ ACPI_OP("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY,
421 AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
422/* 44 */ ACPI_OP("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP,
423 ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
424/* 45 */ ACPI_OP("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER,
425 AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
264 426
265/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ 427/* Prefixed opcodes (Two-byte opcodes with a prefix op) */
266 428
267/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 429/* 46 */ ACPI_OP("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX,
268/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), 430 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE,
269/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), 431 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
270/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), 432 AML_NSNODE | AML_NAMED),
271/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), 433/* 47 */ ACPI_OP("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT,
272/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 434 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE,
273/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 435 AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
274/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), 436/* 48 */ ACPI_OP("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP,
275/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 437 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
276/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), 438 AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
277/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 439/* 49 */ ACPI_OP("CreateField", ARGP_CREATE_FIELD_OP,
278/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 440 ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD,
279/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 441 AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD,
280/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 442 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
281/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), 443 AML_DEFER | AML_FIELD | AML_CREATE),
282/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), 444/* 4A */ ACPI_OP("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY,
283/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), 445 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R,
284/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), 446 AML_FLAGS_EXEC_1A_1T_0R),
285/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), 447/* 4B */ ACPI_OP("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY,
286/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), 448 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R,
287/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 449 AML_FLAGS_EXEC_1A_0T_0R),
288/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 450/* 4C */ ACPI_OP("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY,
289/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 451 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R,
290/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 452 AML_FLAGS_EXEC_1A_0T_0R),
291/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), 453/* 4D */ ACPI_OP("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP,
292/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), 454 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
455 AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
456/* 4E */ ACPI_OP("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP,
457 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
458 AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
459/* 4F */ ACPI_OP("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY,
460 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
461 AML_FLAGS_EXEC_2A_0T_1R),
462/* 50 */ ACPI_OP("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY,
463 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R,
464 AML_FLAGS_EXEC_1A_0T_0R),
465/* 51 */ ACPI_OP("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP,
466 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
467 AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
468/* 52 */ ACPI_OP("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP,
469 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
470 AML_TYPE_EXEC_1A_1T_1R,
471 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
472/* 53 */ ACPI_OP("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY,
473 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
474 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
475/* 54 */ ACPI_OP("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP,
476 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
477 AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
478/* 55 */ ACPI_OP("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP,
479 ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT,
480 AML_TYPE_CONSTANT, 0),
481/* 56 */ ACPI_OP("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP,
482 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
483 AML_TYPE_CONSTANT, 0),
484/* 57 */ ACPI_OP("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY,
485 AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R,
486 AML_FLAGS_EXEC_3A_0T_0R),
487/* 58 */ ACPI_OP("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP,
488 ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT,
489 AML_TYPE_NAMED_COMPLEX,
490 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
491 AML_NSNODE | AML_NAMED | AML_DEFER),
492/* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY,
493 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD,
494 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
495 AML_FIELD),
496/* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP,
497 ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT,
498 AML_TYPE_NAMED_NO_OBJ,
499 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
500 AML_NSNODE | AML_NAMED),
501/* 5B */ ACPI_OP("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP,
502 ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT,
503 AML_TYPE_NAMED_SIMPLE,
504 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
505 AML_NSNODE | AML_NAMED),
506/* 5C */ ACPI_OP("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP,
507 ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT,
508 AML_TYPE_NAMED_SIMPLE,
509 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
510 AML_NSNODE | AML_NAMED),
511/* 5D */ ACPI_OP("ThermalZone", ARGP_THERMAL_ZONE_OP,
512 ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL,
513 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ,
514 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
515 AML_NSNODE | AML_NAMED),
516/* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP,
517 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT,
518 AML_TYPE_NAMED_FIELD,
519 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
520 AML_FIELD),
521/* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP,
522 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT,
523 AML_TYPE_NAMED_FIELD,
524 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
525 AML_FIELD),
293 526
294/* Internal opcodes that map to invalid AML opcodes */ 527/* Internal opcodes that map to invalid AML opcodes */
295 528
296/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), 529/* 60 */ ACPI_OP("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP,
297/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), 530 ACPI_TYPE_ANY, AML_CLASS_INTERNAL,
298/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), 531 AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
299/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), 532/* 61 */ ACPI_OP("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP,
300/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), 533 ACPI_TYPE_ANY, AML_CLASS_INTERNAL,
301/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), 534 AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
302/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), 535/* 62 */ ACPI_OP("LGreaterEqual", ARGP_LGREATEREQUAL_OP,
303/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), 536 ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY,
304/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), 537 AML_CLASS_INTERNAL, AML_TYPE_BOGUS,
305/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), 538 AML_HAS_ARGS | AML_CONSTANT),
306/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), 539/* 63 */ ACPI_OP("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP,
307/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), 540 ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT,
308/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), 541 AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE),
309/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), 542/* 64 */ ACPI_OP("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP,
543 ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL,
544 AML_TYPE_METHOD_CALL,
545 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
546/* 65 */ ACPI_OP("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP,
547 ACPI_TYPE_ANY, AML_CLASS_ARGUMENT,
548 AML_TYPE_LITERAL, 0),
549/* 66 */ ACPI_OP("-ReservedField-", ARGP_RESERVEDFIELD_OP,
550 ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY,
551 AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
552/* 67 */ ACPI_OP("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP,
553 ACPI_TYPE_ANY, AML_CLASS_INTERNAL,
554 AML_TYPE_BOGUS,
555 AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
556/* 68 */ ACPI_OP("-AccessField-", ARGP_ACCESSFIELD_OP,
557 ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY,
558 AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
559/* 69 */ ACPI_OP("-StaticString", ARGP_STATICSTRING_OP,
560 ARGI_STATICSTRING_OP, ACPI_TYPE_ANY,
561 AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
562/* 6A */ ACPI_OP("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY,
563 AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN,
564 AML_HAS_ARGS | AML_HAS_RETVAL),
565/* 6B */ ACPI_OP("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID,
566 AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS),
567/* 6C */ ACPI_OP("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY,
568 AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS),
569/* 6D */ ACPI_OP("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY,
570 AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS),
310 571
311/* ACPI 2.0 opcodes */ 572/* ACPI 2.0 opcodes */
312 573
313/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), 574/* 6E */ ACPI_OP("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP,
314/* 6F */ ACPI_OP ("Package /*Var*/", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), 575 ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT,
315/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), 576 AML_TYPE_LITERAL, AML_CONSTANT),
316/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), 577 /* 6F */ ACPI_OP("Package", /* Var */ ARGP_VAR_PACKAGE_OP,
317/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), 578 ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE,
318/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 579 AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT,
319/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 580 AML_HAS_ARGS | AML_DEFER),
320/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 581/* 70 */ ACPI_OP("ConcatenateResTemplate", ARGP_CONCAT_RES_OP,
321/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), 582 ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY,
322/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), 583 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
323/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), 584 AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
324/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), 585/* 71 */ ACPI_OP("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY,
325/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), 586 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R,
326/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), 587 AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
327/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), 588/* 72 */ ACPI_OP("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,
328/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), 589 ARGI_CREATE_QWORD_FIELD_OP,
590 ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE,
591 AML_TYPE_CREATE_FIELD,
592 AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE |
593 AML_DEFER | AML_CREATE),
594/* 73 */ ACPI_OP("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP,
595 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
596 AML_TYPE_EXEC_1A_1T_1R,
597 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
598/* 74 */ ACPI_OP("ToDecimalString", ARGP_TO_DEC_STR_OP,
599 ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY,
600 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R,
601 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
602/* 75 */ ACPI_OP("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP,
603 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
604 AML_TYPE_EXEC_1A_1T_1R,
605 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
606/* 76 */ ACPI_OP("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP,
607 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
608 AML_TYPE_EXEC_1A_1T_1R,
609 AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
610/* 77 */ ACPI_OP("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP,
611 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
612 AML_TYPE_EXEC_2A_1T_1R,
613 AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
614/* 78 */ ACPI_OP("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP,
615 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
616 AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
617/* 79 */ ACPI_OP("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY,
618 AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R,
619 AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
620/* 7A */ ACPI_OP("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP,
621 ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
622/* 7B */ ACPI_OP("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP,
623 ACPI_TYPE_ANY, AML_CLASS_EXECUTE,
624 AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R),
625/* 7C */ ACPI_OP("DataTableRegion", ARGP_DATA_REGION_OP,
626 ARGI_DATA_REGION_OP, ACPI_TYPE_REGION,
627 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE,
628 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
629 AML_NSNODE | AML_NAMED),
630/* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP,
631 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT,
632 AML_TYPE_NAMED_NO_OBJ,
633 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE |
634 AML_NSNODE),
329 635
330/* ACPI 3.0 opcodes */ 636/* ACPI 3.0 opcodes */
331 637
332/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) 638/* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY,
639 AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R,
640 AML_FLAGS_EXEC_0A_0T_1R)
333 641
334/*! [End] no source code translation !*/ 642/*! [End] no source code translation !*/
335}; 643};
@@ -338,73 +646,70 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] =
338 * This table is directly indexed by the opcodes, and returns an 646 * This table is directly indexed by the opcodes, and returns an
339 * index into the table above 647 * index into the table above
340 */ 648 */
341static const u8 acpi_gbl_short_op_index[256] = 649static const u8 acpi_gbl_short_op_index[256] = {
342{
343/* 0 1 2 3 4 5 6 7 */ 650/* 0 1 2 3 4 5 6 7 */
344/* 8 9 A B C D E F */ 651/* 8 9 A B C D E F */
345/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, 652/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
346/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, 653/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
347/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, 654/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
348/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 655/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
349/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 656/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
350/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, 657/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
351/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, 658/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
352/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 659/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
353/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 660/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
354/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 661/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
355/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 662/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
356/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, 663/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
357/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 664/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
358/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, 665/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
359/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 666/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
360/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 667/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
361/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, 668/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
362/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, 669/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
363/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, 670/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
364/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, 671/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
365/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, 672/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
366/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 673/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
367/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 674/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
368/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 675/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
369/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 676/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
370/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, 677/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
371/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 678/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
372/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 679/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
373/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 680/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
374/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 681/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
375/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 682/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
376/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, 683/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
377}; 684};
378 685
379/* 686/*
380 * This table is indexed by the second opcode of the extended opcode 687 * This table is indexed by the second opcode of the extended opcode
381 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) 688 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
382 */ 689 */
383static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = 690static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
384{
385/* 0 1 2 3 4 5 6 7 */ 691/* 0 1 2 3 4 5 6 7 */
386/* 8 9 A B C D E F */ 692/* 8 9 A B C D E F */
387/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, 693/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
388/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 694/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
389/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, 695/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
390/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, 696/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
391/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 697/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
392/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, 698/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
393/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, 699/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
394/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 700/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
395/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 701/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
396/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 702/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
397/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 703/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
398/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 704/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
399/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 705/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
400/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 706/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
401/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 707/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
402/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 708/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
403/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 709/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
404/* 0x88 */ 0x7C, 710/* 0x88 */ 0x7C,
405}; 711};
406 712
407
408/******************************************************************************* 713/*******************************************************************************
409 * 714 *
410 * FUNCTION: acpi_ps_get_opcode_info 715 * FUNCTION: acpi_ps_get_opcode_info
@@ -418,48 +723,36 @@ static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
418 * 723 *
419 ******************************************************************************/ 724 ******************************************************************************/
420 725
421const struct acpi_opcode_info * 726const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
422acpi_ps_get_opcode_info (
423 u16 opcode)
424{ 727{
425 ACPI_FUNCTION_NAME ("ps_get_opcode_info"); 728 ACPI_FUNCTION_NAME("ps_get_opcode_info");
426
427 729
428 /* 730 /*
429 * Detect normal 8-bit opcode or extended 16-bit opcode 731 * Detect normal 8-bit opcode or extended 16-bit opcode
430 */ 732 */
431 switch ((u8) (opcode >> 8)) { 733 if (!(opcode & 0xFF00)) {
432 case 0:
433
434 /* Simple (8-bit) opcode: 0-255, can't index beyond table */ 734 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
435 735
436 return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); 736 return (&acpi_gbl_aml_op_info
437 737 [acpi_gbl_short_op_index[(u8) opcode]]);
438 case AML_EXTOP: 738 }
439
440 /* Extended (16-bit, prefix+opcode) opcode */
441
442 if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
443 return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
444 }
445
446 /* Else fall through to error case below */
447 /*lint -fallthrough */
448 739
449 default: 740 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
741 (((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
742 /* Valid extended (16-bit) opcode */
450 743
451 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 744 return (&acpi_gbl_aml_op_info
452 "Unknown AML opcode [%4.4X]\n", opcode)); 745 [acpi_gbl_long_op_index[(u8) opcode]]);
453 break;
454 } 746 }
455 747
748 /* Unknown AML opcode */
456 749
457 /* Default is "unknown opcode" */ 750 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
751 "Unknown AML opcode [%4.4X]\n", opcode));
458 752
459 return (&acpi_gbl_aml_op_info [_UNK]); 753 return (&acpi_gbl_aml_op_info[_UNK]);
460} 754}
461 755
462
463/******************************************************************************* 756/*******************************************************************************
464 * 757 *
465 * FUNCTION: acpi_ps_get_opcode_name 758 * FUNCTION: acpi_ps_get_opcode_name
@@ -473,16 +766,13 @@ acpi_ps_get_opcode_info (
473 * 766 *
474 ******************************************************************************/ 767 ******************************************************************************/
475 768
476char * 769char *acpi_ps_get_opcode_name(u16 opcode)
477acpi_ps_get_opcode_name (
478 u16 opcode)
479{ 770{
480#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) 771#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
481 772
482 const struct acpi_opcode_info *op; 773 const struct acpi_opcode_info *op;
483 774
484 775 op = acpi_ps_get_opcode_info(opcode);
485 op = acpi_ps_get_opcode_info (opcode);
486 776
487 /* Always guaranteed to return a valid pointer */ 777 /* Always guaranteed to return a valid pointer */
488 778
@@ -493,4 +783,3 @@ acpi_ps_get_opcode_name (
493 783
494#endif 784#endif
495} 785}
496
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index bbfdc1a58c27..76d4d640d83c 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45/* 44/*
46 * Parse the AML and build an operation tree as most interpreters, 45 * Parse the AML and build an operation tree as most interpreters,
47 * 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
@@ -59,28 +58,7 @@
59#include <acpi/acinterp.h> 58#include <acpi/acinterp.h>
60 59
61#define _COMPONENT ACPI_PARSER 60#define _COMPONENT ACPI_PARSER
62 ACPI_MODULE_NAME ("psparse") 61ACPI_MODULE_NAME("psparse")
63
64
65static u32 acpi_gbl_depth = 0;
66
67/* Local prototypes */
68
69static void
70acpi_ps_complete_this_op (
71 struct acpi_walk_state *walk_state,
72 union acpi_parse_object *op);
73
74static acpi_status
75acpi_ps_next_parse_state (
76 struct acpi_walk_state *walk_state,
77 union acpi_parse_object *op,
78 acpi_status callback_status);
79
80static acpi_status
81acpi_ps_parse_loop (
82 struct acpi_walk_state *walk_state);
83
84 62
85/******************************************************************************* 63/*******************************************************************************
86 * 64 *
@@ -93,10 +71,7 @@ acpi_ps_parse_loop (
93 * DESCRIPTION: Get the size of the current opcode. 71 * DESCRIPTION: Get the size of the current opcode.
94 * 72 *
95 ******************************************************************************/ 73 ******************************************************************************/
96 74u32 acpi_ps_get_opcode_size(u32 opcode)
97u32
98acpi_ps_get_opcode_size (
99 u32 opcode)
100{ 75{
101 76
102 /* Extended (2-byte) opcode if > 255 */ 77 /* Extended (2-byte) opcode if > 255 */
@@ -110,7 +85,6 @@ acpi_ps_get_opcode_size (
110 return (1); 85 return (1);
111} 86}
112 87
113
114/******************************************************************************* 88/*******************************************************************************
115 * 89 *
116 * FUNCTION: acpi_ps_peek_opcode 90 * FUNCTION: acpi_ps_peek_opcode
@@ -123,28 +97,24 @@ acpi_ps_get_opcode_size (
123 * 97 *
124 ******************************************************************************/ 98 ******************************************************************************/
125 99
126u16 100u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
127acpi_ps_peek_opcode (
128 struct acpi_parse_state *parser_state)
129{ 101{
130 u8 *aml; 102 u8 *aml;
131 u16 opcode; 103 u16 opcode;
132
133 104
134 aml = parser_state->aml; 105 aml = parser_state->aml;
135 opcode = (u16) ACPI_GET8 (aml); 106 opcode = (u16) ACPI_GET8(aml);
136 107
137 if (opcode == AML_EXTOP) { 108 if (opcode == AML_EXTENDED_OP_PREFIX) {
138 /* Extended opcode */ 109 /* Extended opcode, get the second opcode byte */
139 110
140 aml++; 111 aml++;
141 opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); 112 opcode = (u16) ((opcode << 8) | ACPI_GET8(aml));
142 } 113 }
143 114
144 return (opcode); 115 return (opcode);
145} 116}
146 117
147
148/******************************************************************************* 118/*******************************************************************************
149 * 119 *
150 * FUNCTION: acpi_ps_complete_this_op 120 * FUNCTION: acpi_ps_complete_this_op
@@ -152,47 +122,54 @@ acpi_ps_peek_opcode (
152 * PARAMETERS: walk_state - Current State 122 * PARAMETERS: walk_state - Current State
153 * Op - Op to complete 123 * Op - Op to complete
154 * 124 *
155 * RETURN: None. 125 * RETURN: Status
156 * 126 *
157 * DESCRIPTION: Perform any cleanup at the completion of an Op. 127 * DESCRIPTION: Perform any cleanup at the completion of an Op.
158 * 128 *
159 ******************************************************************************/ 129 ******************************************************************************/
160 130
161static void 131acpi_status
162acpi_ps_complete_this_op ( 132acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
163 struct acpi_walk_state *walk_state, 133 union acpi_parse_object * op)
164 union acpi_parse_object *op)
165{ 134{
166 union acpi_parse_object *prev; 135 union acpi_parse_object *prev;
167 union acpi_parse_object *next; 136 union acpi_parse_object *next;
168 const struct acpi_opcode_info *parent_info; 137 const struct acpi_opcode_info *parent_info;
169 union acpi_parse_object *replacement_op = NULL; 138 union acpi_parse_object *replacement_op = NULL;
170
171
172 ACPI_FUNCTION_TRACE_PTR ("ps_complete_this_op", op);
173 139
140 ACPI_FUNCTION_TRACE_PTR("ps_complete_this_op", op);
174 141
175 /* Check for null Op, can happen if AML code is corrupt */ 142 /* Check for null Op, can happen if AML code is corrupt */
176 143
177 if (!op) { 144 if (!op) {
178 return_VOID; 145 return_ACPI_STATUS(AE_OK); /* OK for now */
179 } 146 }
180 147
181 /* Delete this op and the subtree below it if asked to */ 148 /* Delete this op and the subtree below it if asked to */
182 149
183 if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || 150 if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) !=
184 (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { 151 ACPI_PARSE_DELETE_TREE)
185 return_VOID; 152 || (walk_state->op_info->class == AML_CLASS_ARGUMENT)) {
153 return_ACPI_STATUS(AE_OK);
186 } 154 }
187 155
188 /* Make sure that we only delete this subtree */ 156 /* Make sure that we only delete this subtree */
189 157
190 if (op->common.parent) { 158 if (op->common.parent) {
159 prev = op->common.parent->common.value.arg;
160 if (!prev) {
161 /* Nothing more to do */
162
163 goto cleanup;
164 }
165
191 /* 166 /*
192 * Check if we need to replace the operator and its subtree 167 * Check if we need to replace the operator and its subtree
193 * with a return value op (placeholder op) 168 * with a return value op (placeholder op)
194 */ 169 */
195 parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode); 170 parent_info =
171 acpi_ps_get_opcode_info(op->common.parent->common.
172 aml_opcode);
196 173
197 switch (parent_info->class) { 174 switch (parent_info->class) {
198 case AML_CLASS_CONTROL: 175 case AML_CLASS_CONTROL:
@@ -204,9 +181,10 @@ acpi_ps_complete_this_op (
204 * These opcodes contain term_arg operands. The current 181 * These opcodes contain term_arg operands. The current
205 * op must be replaced by a placeholder return op 182 * op must be replaced by a placeholder return op
206 */ 183 */
207 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); 184 replacement_op =
185 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
208 if (!replacement_op) { 186 if (!replacement_op) {
209 goto cleanup; 187 goto allocate_error;
210 } 188 }
211 break; 189 break;
212 190
@@ -216,91 +194,117 @@ acpi_ps_complete_this_op (
216 * These opcodes contain term_arg operands. The current 194 * These opcodes contain term_arg operands. The current
217 * op must be replaced by a placeholder return op 195 * op must be replaced by a placeholder return op
218 */ 196 */
219 if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || 197 if ((op->common.parent->common.aml_opcode ==
220 (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) || 198 AML_REGION_OP)
221 (op->common.parent->common.aml_opcode == AML_BUFFER_OP) || 199 || (op->common.parent->common.aml_opcode ==
222 (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || 200 AML_DATA_REGION_OP)
223 (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { 201 || (op->common.parent->common.aml_opcode ==
224 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); 202 AML_BUFFER_OP)
203 || (op->common.parent->common.aml_opcode ==
204 AML_PACKAGE_OP)
205 || (op->common.parent->common.aml_opcode ==
206 AML_VAR_PACKAGE_OP)) {
207 replacement_op =
208 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
225 if (!replacement_op) { 209 if (!replacement_op) {
226 goto cleanup; 210 goto allocate_error;
227 } 211 }
228 } 212 } else
229 213 if ((op->common.parent->common.aml_opcode ==
230 if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && 214 AML_NAME_OP)
231 (walk_state->descending_callback != acpi_ds_exec_begin_op)) { 215 && (walk_state->pass_number <=
232 if ((op->common.aml_opcode == AML_BUFFER_OP) || 216 ACPI_IMODE_LOAD_PASS2)) {
233 (op->common.aml_opcode == AML_PACKAGE_OP) || 217 if ((op->common.aml_opcode == AML_BUFFER_OP)
234 (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { 218 || (op->common.aml_opcode == AML_PACKAGE_OP)
235 replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); 219 || (op->common.aml_opcode ==
220 AML_VAR_PACKAGE_OP)) {
221 replacement_op =
222 acpi_ps_alloc_op(op->common.
223 aml_opcode);
236 if (!replacement_op) { 224 if (!replacement_op) {
237 goto cleanup; 225 goto allocate_error;
238 } 226 }
239 227
240 replacement_op->named.data = op->named.data; 228 replacement_op->named.data =
241 replacement_op->named.length = op->named.length; 229 op->named.data;
230 replacement_op->named.length =
231 op->named.length;
242 } 232 }
243 } 233 }
244 break; 234 break;
245 235
246 default: 236 default:
247 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); 237
238 replacement_op =
239 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
248 if (!replacement_op) { 240 if (!replacement_op) {
249 goto cleanup; 241 goto allocate_error;
250 } 242 }
251 } 243 }
252 244
253 /* We must unlink this op from the parent tree */ 245 /* We must unlink this op from the parent tree */
254 246
255 prev = op->common.parent->common.value.arg;
256 if (prev == op) { 247 if (prev == op) {
257 /* This op is the first in the list */ 248 /* This op is the first in the list */
258 249
259 if (replacement_op) { 250 if (replacement_op) {
260 replacement_op->common.parent = op->common.parent; 251 replacement_op->common.parent =
261 replacement_op->common.value.arg = NULL; 252 op->common.parent;
262 replacement_op->common.node = op->common.node; 253 replacement_op->common.value.arg = NULL;
263 op->common.parent->common.value.arg = replacement_op; 254 replacement_op->common.node = op->common.node;
264 replacement_op->common.next = op->common.next; 255 op->common.parent->common.value.arg =
265 } 256 replacement_op;
266 else { 257 replacement_op->common.next = op->common.next;
267 op->common.parent->common.value.arg = op->common.next; 258 } else {
259 op->common.parent->common.value.arg =
260 op->common.next;
268 } 261 }
269 } 262 }
270 263
271 /* Search the parent list */ 264 /* Search the parent list */
272 265
273 else while (prev) { 266 else
274 /* Traverse all siblings in the parent's argument list */ 267 while (prev) {
275 268 /* Traverse all siblings in the parent's argument list */
276 next = prev->common.next; 269
277 if (next == op) { 270 next = prev->common.next;
278 if (replacement_op) { 271 if (next == op) {
279 replacement_op->common.parent = op->common.parent; 272 if (replacement_op) {
280 replacement_op->common.value.arg = NULL; 273 replacement_op->common.parent =
281 replacement_op->common.node = op->common.node; 274 op->common.parent;
282 prev->common.next = replacement_op; 275 replacement_op->common.value.
283 replacement_op->common.next = op->common.next; 276 arg = NULL;
284 next = NULL; 277 replacement_op->common.node =
285 } 278 op->common.node;
286 else { 279 prev->common.next =
287 prev->common.next = op->common.next; 280 replacement_op;
288 next = NULL; 281 replacement_op->common.next =
282 op->common.next;
283 next = NULL;
284 } else {
285 prev->common.next =
286 op->common.next;
287 next = NULL;
288 }
289 } 289 }
290 prev = next;
290 } 291 }
291 prev = next;
292 }
293 } 292 }
294 293
295 294 cleanup:
296cleanup:
297 295
298 /* Now we can actually delete the subtree rooted at Op */ 296 /* Now we can actually delete the subtree rooted at Op */
299 297
300 acpi_ps_delete_parse_tree (op); 298 acpi_ps_delete_parse_tree(op);
301 return_VOID; 299 return_ACPI_STATUS(AE_OK);
302}
303 300
301 allocate_error:
302
303 /* Always delete the subtree, even on error */
304
305 acpi_ps_delete_parse_tree(op);
306 return_ACPI_STATUS(AE_NO_MEMORY);
307}
304 308
305/******************************************************************************* 309/*******************************************************************************
306 * 310 *
@@ -317,18 +321,15 @@ cleanup:
317 * 321 *
318 ******************************************************************************/ 322 ******************************************************************************/
319 323
320static acpi_status 324acpi_status
321acpi_ps_next_parse_state ( 325acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
322 struct acpi_walk_state *walk_state, 326 union acpi_parse_object *op,
323 union acpi_parse_object *op, 327 acpi_status callback_status)
324 acpi_status callback_status)
325{ 328{
326 struct acpi_parse_state *parser_state = &walk_state->parser_state; 329 struct acpi_parse_state *parser_state = &walk_state->parser_state;
327 acpi_status status = AE_CTRL_PENDING; 330 acpi_status status = AE_CTRL_PENDING;
328
329
330 ACPI_FUNCTION_TRACE_PTR ("ps_next_parse_state", op);
331 331
332 ACPI_FUNCTION_TRACE_PTR("ps_next_parse_state", op);
332 333
333 switch (callback_status) { 334 switch (callback_status) {
334 case AE_CTRL_TERMINATE: 335 case AE_CTRL_TERMINATE:
@@ -341,7 +342,6 @@ acpi_ps_next_parse_state (
341 status = AE_CTRL_TERMINATE; 342 status = AE_CTRL_TERMINATE;
342 break; 343 break;
343 344
344
345 case AE_CTRL_BREAK: 345 case AE_CTRL_BREAK:
346 346
347 parser_state->aml = walk_state->aml_last_while; 347 parser_state->aml = walk_state->aml_last_while;
@@ -351,7 +351,6 @@ acpi_ps_next_parse_state (
351 351
352 case AE_CTRL_CONTINUE: 352 case AE_CTRL_CONTINUE:
353 353
354
355 parser_state->aml = walk_state->aml_last_while; 354 parser_state->aml = walk_state->aml_last_while;
356 status = AE_CTRL_CONTINUE; 355 status = AE_CTRL_CONTINUE;
357 break; 356 break;
@@ -375,10 +374,9 @@ acpi_ps_next_parse_state (
375 * Predicate of an IF was true, and we are at the matching ELSE. 374 * Predicate of an IF was true, and we are at the matching ELSE.
376 * Just close out this package 375 * Just close out this package
377 */ 376 */
378 parser_state->aml = acpi_ps_get_next_package_end (parser_state); 377 parser_state->aml = acpi_ps_get_next_package_end(parser_state);
379 break; 378 break;
380 379
381
382 case AE_CTRL_FALSE: 380 case AE_CTRL_FALSE:
383 381
384 /* 382 /*
@@ -396,7 +394,6 @@ acpi_ps_next_parse_state (
396 status = AE_CTRL_END; 394 status = AE_CTRL_END;
397 break; 395 break;
398 396
399
400 case AE_CTRL_TRANSFER: 397 case AE_CTRL_TRANSFER:
401 398
402 /* A method call (invocation) -- transfer control */ 399 /* A method call (invocation) -- transfer control */
@@ -404,14 +401,15 @@ acpi_ps_next_parse_state (
404 status = AE_CTRL_TRANSFER; 401 status = AE_CTRL_TRANSFER;
405 walk_state->prev_op = op; 402 walk_state->prev_op = op;
406 walk_state->method_call_op = op; 403 walk_state->method_call_op = op;
407 walk_state->method_call_node = (op->common.value.arg)->common.node; 404 walk_state->method_call_node =
405 (op->common.value.arg)->common.node;
408 406
409 /* Will return value (if any) be used by the caller? */ 407 /* Will return value (if any) be used by the caller? */
410 408
411 walk_state->return_used = acpi_ds_is_result_used (op, walk_state); 409 walk_state->return_used =
410 acpi_ds_is_result_used(op, walk_state);
412 break; 411 break;
413 412
414
415 default: 413 default:
416 414
417 status = callback_status; 415 status = callback_status;
@@ -421,667 +419,9 @@ acpi_ps_next_parse_state (
421 break; 419 break;
422 } 420 }
423 421
424 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
425} 423}
426 424
427
428/*******************************************************************************
429 *
430 * FUNCTION: acpi_ps_parse_loop
431 *
432 * PARAMETERS: walk_state - Current state
433 *
434 * RETURN: Status
435 *
436 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
437 * a tree of ops.
438 *
439 ******************************************************************************/
440
441static acpi_status
442acpi_ps_parse_loop (
443 struct acpi_walk_state *walk_state)
444{
445 acpi_status status = AE_OK;
446 union acpi_parse_object *op = NULL; /* current op */
447 union acpi_parse_object *arg = NULL;
448 union acpi_parse_object *pre_op = NULL;
449 struct acpi_parse_state *parser_state;
450 u8 *aml_op_start = NULL;
451
452
453 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state);
454
455 if (walk_state->descending_callback == NULL) {
456 return_ACPI_STATUS (AE_BAD_PARAMETER);
457 }
458
459 parser_state = &walk_state->parser_state;
460 walk_state->arg_types = 0;
461
462#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
463
464 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
465 /* We are restarting a preempted control method */
466
467 if (acpi_ps_has_completed_scope (parser_state)) {
468 /*
469 * We must check if a predicate to an IF or WHILE statement
470 * was just completed
471 */
472 if ((parser_state->scope->parse_scope.op) &&
473 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) ||
474 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) &&
475 (walk_state->control_state) &&
476 (walk_state->control_state->common.state ==
477 ACPI_CONTROL_PREDICATE_EXECUTING)) {
478 /*
479 * A predicate was just completed, get the value of the
480 * predicate and branch based on that value
481 */
482 walk_state->op = NULL;
483 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
484 if (ACPI_FAILURE (status) &&
485 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
486 if (status == AE_AML_NO_RETURN_VALUE) {
487 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
488 "Invoked method did not return a value, %s\n",
489 acpi_format_exception (status)));
490
491 }
492 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
493 "get_predicate Failed, %s\n",
494 acpi_format_exception (status)));
495 return_ACPI_STATUS (status);
496 }
497
498 status = acpi_ps_next_parse_state (walk_state, op, status);
499 }
500
501 acpi_ps_pop_scope (parser_state, &op,
502 &walk_state->arg_types, &walk_state->arg_count);
503 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
504 }
505 else if (walk_state->prev_op) {
506 /* We were in the middle of an op */
507
508 op = walk_state->prev_op;
509 walk_state->arg_types = walk_state->prev_arg_types;
510 }
511 }
512#endif
513
514 /* Iterative parsing loop, while there is more AML to process: */
515
516 while ((parser_state->aml < parser_state->aml_end) || (op)) {
517 aml_op_start = parser_state->aml;
518 if (!op) {
519 /* Get the next opcode from the AML stream */
520
521 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
522 parser_state->aml_start);
523 walk_state->opcode = acpi_ps_peek_opcode (parser_state);
524
525 /*
526 * First cut to determine what we have found:
527 * 1) A valid AML opcode
528 * 2) A name string
529 * 3) An unknown/invalid opcode
530 */
531 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
532 switch (walk_state->op_info->class) {
533 case AML_CLASS_ASCII:
534 case AML_CLASS_PREFIX:
535 /*
536 * Starts with a valid prefix or ASCII char, this is a name
537 * string. Convert the bare name string to a namepath.
538 */
539 walk_state->opcode = AML_INT_NAMEPATH_OP;
540 walk_state->arg_types = ARGP_NAMESTRING;
541 break;
542
543 case AML_CLASS_UNKNOWN:
544
545 /* The opcode is unrecognized. Just skip unknown opcodes */
546
547 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
548 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
549 walk_state->opcode, parser_state->aml, walk_state->aml_offset));
550
551 ACPI_DUMP_BUFFER (parser_state->aml, 128);
552
553 /* Assume one-byte bad opcode */
554
555 parser_state->aml++;
556 continue;
557
558 default:
559
560 /* Found opcode info, this is a normal opcode */
561
562 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode);
563 walk_state->arg_types = walk_state->op_info->parse_args;
564 break;
565 }
566
567 /* Create Op structure and append to parent's argument list */
568
569 if (walk_state->op_info->flags & AML_NAMED) {
570 /* Allocate a new pre_op if necessary */
571
572 if (!pre_op) {
573 pre_op = acpi_ps_alloc_op (walk_state->opcode);
574 if (!pre_op) {
575 status = AE_NO_MEMORY;
576 goto close_this_op;
577 }
578 }
579
580 pre_op->common.value.arg = NULL;
581 pre_op->common.aml_opcode = walk_state->opcode;
582
583 /*
584 * Get and append arguments until we find the node that contains
585 * the name (the type ARGP_NAME).
586 */
587 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
588 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) {
589 status = acpi_ps_get_next_arg (walk_state, parser_state,
590 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
591 if (ACPI_FAILURE (status)) {
592 goto close_this_op;
593 }
594
595 acpi_ps_append_arg (pre_op, arg);
596 INCREMENT_ARG_LIST (walk_state->arg_types);
597 }
598
599 /*
600 * Make sure that we found a NAME and didn't run out of
601 * arguments
602 */
603 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
604 status = AE_AML_NO_OPERAND;
605 goto close_this_op;
606 }
607
608 /* We know that this arg is a name, move to next arg */
609
610 INCREMENT_ARG_LIST (walk_state->arg_types);
611
612 /*
613 * Find the object. This will either insert the object into
614 * the namespace or simply look it up
615 */
616 walk_state->op = NULL;
617
618 status = walk_state->descending_callback (walk_state, &op);
619 if (ACPI_FAILURE (status)) {
620 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
621 "During name lookup/catalog, %s\n",
622 acpi_format_exception (status)));
623 goto close_this_op;
624 }
625
626 if (!op) {
627 continue;
628 }
629
630 status = acpi_ps_next_parse_state (walk_state, op, status);
631 if (status == AE_CTRL_PENDING) {
632 status = AE_OK;
633 goto close_this_op;
634 }
635
636 if (ACPI_FAILURE (status)) {
637 goto close_this_op;
638 }
639
640 acpi_ps_append_arg (op, pre_op->common.value.arg);
641 acpi_gbl_depth++;
642
643 if (op->common.aml_opcode == AML_REGION_OP) {
644 /*
645 * Defer final parsing of an operation_region body,
646 * because we don't have enough info in the first pass
647 * to parse it correctly (i.e., there may be method
648 * calls within the term_arg elements of the body.)
649 *
650 * However, we must continue parsing because
651 * the opregion is not a standalone package --
652 * we don't know where the end is at this point.
653 *
654 * (Length is unknown until parse of the body complete)
655 */
656 op->named.data = aml_op_start;
657 op->named.length = 0;
658 }
659 }
660 else {
661 /* Not a named opcode, just allocate Op and append to parent */
662
663 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
664 op = acpi_ps_alloc_op (walk_state->opcode);
665 if (!op) {
666 status = AE_NO_MEMORY;
667 goto close_this_op;
668 }
669
670 if (walk_state->op_info->flags & AML_CREATE) {
671 /*
672 * Backup to beginning of create_xXXfield declaration
673 * body_length is unknown until we parse the body
674 */
675 op->named.data = aml_op_start;
676 op->named.length = 0;
677 }
678
679 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op);
680
681 if ((walk_state->descending_callback != NULL)) {
682 /*
683 * Find the object. This will either insert the object into
684 * the namespace or simply look it up
685 */
686 walk_state->op = op;
687
688 status = walk_state->descending_callback (walk_state, &op);
689 status = acpi_ps_next_parse_state (walk_state, op, status);
690 if (status == AE_CTRL_PENDING) {
691 status = AE_OK;
692 goto close_this_op;
693 }
694
695 if (ACPI_FAILURE (status)) {
696 goto close_this_op;
697 }
698 }
699 }
700
701 op->common.aml_offset = walk_state->aml_offset;
702
703 if (walk_state->op_info) {
704 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
705 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
706 (u32) op->common.aml_opcode, walk_state->op_info->name,
707 op, parser_state->aml, op->common.aml_offset));
708 }
709 }
710
711
712 /*
713 * Start arg_count at zero because we don't know if there are
714 * any args yet
715 */
716 walk_state->arg_count = 0;
717
718 /* Are there any arguments that must be processed? */
719
720 if (walk_state->arg_types) {
721 /* Get arguments */
722
723 switch (op->common.aml_opcode) {
724 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
725 case AML_WORD_OP: /* AML_WORDDATA_ARG */
726 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
727 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
728 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
729
730 /* Fill in constant or string argument directly */
731
732 acpi_ps_get_next_simple_arg (parser_state,
733 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
734 break;
735
736 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
737
738 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1);
739 if (ACPI_FAILURE (status)) {
740 goto close_this_op;
741 }
742
743 walk_state->arg_types = 0;
744 break;
745
746 default:
747
748 /*
749 * Op is not a constant or string, append each argument
750 * to the Op
751 */
752 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
753 !walk_state->arg_count) {
754 walk_state->aml_offset = (u32)
755 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start);
756
757 status = acpi_ps_get_next_arg (walk_state, parser_state,
758 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
759 &arg);
760 if (ACPI_FAILURE (status)) {
761 goto close_this_op;
762 }
763
764 if (arg) {
765 arg->common.aml_offset = walk_state->aml_offset;
766 acpi_ps_append_arg (op, arg);
767 }
768 INCREMENT_ARG_LIST (walk_state->arg_types);
769 }
770
771 /* Special processing for certain opcodes */
772
773 switch (op->common.aml_opcode) {
774 case AML_METHOD_OP:
775
776 /*
777 * Skip parsing of control method
778 * because we don't have enough info in the first pass
779 * to parse it correctly.
780 *
781 * Save the length and address of the body
782 */
783 op->named.data = parser_state->aml;
784 op->named.length = (u32) (parser_state->pkg_end -
785 parser_state->aml);
786
787 /* Skip body of method */
788
789 parser_state->aml = parser_state->pkg_end;
790 walk_state->arg_count = 0;
791 break;
792
793 case AML_BUFFER_OP:
794 case AML_PACKAGE_OP:
795 case AML_VAR_PACKAGE_OP:
796
797 if ((op->common.parent) &&
798 (op->common.parent->common.aml_opcode == AML_NAME_OP) &&
799 (walk_state->descending_callback != acpi_ds_exec_begin_op)) {
800 /*
801 * Skip parsing of Buffers and Packages
802 * because we don't have enough info in the first pass
803 * to parse them correctly.
804 */
805 op->named.data = aml_op_start;
806 op->named.length = (u32) (parser_state->pkg_end -
807 aml_op_start);
808
809 /* Skip body */
810
811 parser_state->aml = parser_state->pkg_end;
812 walk_state->arg_count = 0;
813 }
814 break;
815
816 case AML_WHILE_OP:
817
818 if (walk_state->control_state) {
819 walk_state->control_state->control.package_end =
820 parser_state->pkg_end;
821 }
822 break;
823
824 default:
825
826 /* No action for all other opcodes */
827 break;
828 }
829 break;
830 }
831 }
832
833 /* Check for arguments that need to be processed */
834
835 if (walk_state->arg_count) {
836 /*
837 * There are arguments (complex ones), push Op and
838 * prepare for argument
839 */
840 status = acpi_ps_push_scope (parser_state, op,
841 walk_state->arg_types, walk_state->arg_count);
842 if (ACPI_FAILURE (status)) {
843 goto close_this_op;
844 }
845 op = NULL;
846 continue;
847 }
848
849 /*
850 * All arguments have been processed -- Op is complete,
851 * prepare for next
852 */
853 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
854 if (walk_state->op_info->flags & AML_NAMED) {
855 if (acpi_gbl_depth) {
856 acpi_gbl_depth--;
857 }
858
859 if (op->common.aml_opcode == AML_REGION_OP) {
860 /*
861 * Skip parsing of control method or opregion body,
862 * because we don't have enough info in the first pass
863 * to parse them correctly.
864 *
865 * Completed parsing an op_region declaration, we now
866 * know the length.
867 */
868 op->named.length = (u32) (parser_state->aml - op->named.data);
869 }
870 }
871
872 if (walk_state->op_info->flags & AML_CREATE) {
873 /*
874 * Backup to beginning of create_xXXfield declaration (1 for
875 * Opcode)
876 *
877 * body_length is unknown until we parse the body
878 */
879 op->named.length = (u32) (parser_state->aml - op->named.data);
880 }
881
882 /* This op complete, notify the dispatcher */
883
884 if (walk_state->ascending_callback != NULL) {
885 walk_state->op = op;
886 walk_state->opcode = op->common.aml_opcode;
887
888 status = walk_state->ascending_callback (walk_state);
889 status = acpi_ps_next_parse_state (walk_state, op, status);
890 if (status == AE_CTRL_PENDING) {
891 status = AE_OK;
892 goto close_this_op;
893 }
894 }
895
896
897close_this_op:
898 /*
899 * Finished one argument of the containing scope
900 */
901 parser_state->scope->parse_scope.arg_count--;
902
903 /* Close this Op (will result in parse subtree deletion) */
904
905 acpi_ps_complete_this_op (walk_state, op);
906 op = NULL;
907 if (pre_op) {
908 acpi_ps_free_op (pre_op);
909 pre_op = NULL;
910 }
911
912 switch (status) {
913 case AE_OK:
914 break;
915
916
917 case AE_CTRL_TRANSFER:
918
919 /* We are about to transfer to a called method. */
920
921 walk_state->prev_op = op;
922 walk_state->prev_arg_types = walk_state->arg_types;
923 return_ACPI_STATUS (status);
924
925
926 case AE_CTRL_END:
927
928 acpi_ps_pop_scope (parser_state, &op,
929 &walk_state->arg_types, &walk_state->arg_count);
930
931 if (op) {
932 walk_state->op = op;
933 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
934 walk_state->opcode = op->common.aml_opcode;
935
936 status = walk_state->ascending_callback (walk_state);
937 status = acpi_ps_next_parse_state (walk_state, op, status);
938
939 acpi_ps_complete_this_op (walk_state, op);
940 op = NULL;
941 }
942 status = AE_OK;
943 break;
944
945
946 case AE_CTRL_BREAK:
947 case AE_CTRL_CONTINUE:
948
949 /* Pop off scopes until we find the While */
950
951 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
952 acpi_ps_pop_scope (parser_state, &op,
953 &walk_state->arg_types, &walk_state->arg_count);
954 }
955
956 /* Close this iteration of the While loop */
957
958 walk_state->op = op;
959 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
960 walk_state->opcode = op->common.aml_opcode;
961
962 status = walk_state->ascending_callback (walk_state);
963 status = acpi_ps_next_parse_state (walk_state, op, status);
964
965 acpi_ps_complete_this_op (walk_state, op);
966 op = NULL;
967
968 status = AE_OK;
969 break;
970
971
972 case AE_CTRL_TERMINATE:
973
974 status = AE_OK;
975
976 /* Clean up */
977 do {
978 if (op) {
979 acpi_ps_complete_this_op (walk_state, op);
980 }
981 acpi_ps_pop_scope (parser_state, &op,
982 &walk_state->arg_types, &walk_state->arg_count);
983
984 } while (op);
985
986 return_ACPI_STATUS (status);
987
988
989 default: /* All other non-AE_OK status */
990
991 do {
992 if (op) {
993 acpi_ps_complete_this_op (walk_state, op);
994 }
995 acpi_ps_pop_scope (parser_state, &op,
996 &walk_state->arg_types, &walk_state->arg_count);
997
998 } while (op);
999
1000
1001 /*
1002 * TBD: Cleanup parse ops on error
1003 */
1004#if 0
1005 if (op == NULL) {
1006 acpi_ps_pop_scope (parser_state, &op,
1007 &walk_state->arg_types, &walk_state->arg_count);
1008 }
1009#endif
1010 walk_state->prev_op = op;
1011 walk_state->prev_arg_types = walk_state->arg_types;
1012 return_ACPI_STATUS (status);
1013 }
1014
1015 /* This scope complete? */
1016
1017 if (acpi_ps_has_completed_scope (parser_state)) {
1018 acpi_ps_pop_scope (parser_state, &op,
1019 &walk_state->arg_types, &walk_state->arg_count);
1020 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
1021 }
1022 else {
1023 op = NULL;
1024 }
1025
1026 } /* while parser_state->Aml */
1027
1028
1029 /*
1030 * Complete the last Op (if not completed), and clear the scope stack.
1031 * It is easily possible to end an AML "package" with an unbounded number
1032 * of open scopes (such as when several ASL blocks are closed with
1033 * sequential closing braces). We want to terminate each one cleanly.
1034 */
1035 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op));
1036 do {
1037 if (op) {
1038 if (walk_state->ascending_callback != NULL) {
1039 walk_state->op = op;
1040 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
1041 walk_state->opcode = op->common.aml_opcode;
1042
1043 status = walk_state->ascending_callback (walk_state);
1044 status = acpi_ps_next_parse_state (walk_state, op, status);
1045 if (status == AE_CTRL_PENDING) {
1046 status = AE_OK;
1047 goto close_this_op;
1048 }
1049
1050 if (status == AE_CTRL_TERMINATE) {
1051 status = AE_OK;
1052
1053 /* Clean up */
1054 do {
1055 if (op) {
1056 acpi_ps_complete_this_op (walk_state, op);
1057 }
1058
1059 acpi_ps_pop_scope (parser_state, &op,
1060 &walk_state->arg_types, &walk_state->arg_count);
1061
1062 } while (op);
1063
1064 return_ACPI_STATUS (status);
1065 }
1066
1067 else if (ACPI_FAILURE (status)) {
1068 acpi_ps_complete_this_op (walk_state, op);
1069 return_ACPI_STATUS (status);
1070 }
1071 }
1072
1073 acpi_ps_complete_this_op (walk_state, op);
1074 }
1075
1076 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types,
1077 &walk_state->arg_count);
1078
1079 } while (op);
1080
1081 return_ACPI_STATUS (status);
1082}
1083
1084
1085/******************************************************************************* 425/*******************************************************************************
1086 * 426 *
1087 * FUNCTION: acpi_ps_parse_aml 427 * FUNCTION: acpi_ps_parse_aml
@@ -1095,34 +435,29 @@ close_this_op:
1095 * 435 *
1096 ******************************************************************************/ 436 ******************************************************************************/
1097 437
1098acpi_status 438acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
1099acpi_ps_parse_aml (
1100 struct acpi_walk_state *walk_state)
1101{ 439{
1102 acpi_status status; 440 acpi_status status;
1103 acpi_status terminate_status; 441 struct acpi_thread_state *thread;
1104 struct acpi_thread_state *thread; 442 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list;
1105 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; 443 struct acpi_walk_state *previous_walk_state;
1106 struct acpi_walk_state *previous_walk_state;
1107 444
445 ACPI_FUNCTION_TRACE("ps_parse_aml");
1108 446
1109 ACPI_FUNCTION_TRACE ("ps_parse_aml"); 447 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
1110 448 "Entered with walk_state=%p Aml=%p size=%X\n",
1111 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 449 walk_state, walk_state->parser_state.aml,
1112 "Entered with walk_state=%p Aml=%p size=%X\n", 450 walk_state->parser_state.aml_size));
1113 walk_state, walk_state->parser_state.aml,
1114 walk_state->parser_state.aml_size));
1115
1116 451
1117 /* Create and initialize a new thread state */ 452 /* Create and initialize a new thread state */
1118 453
1119 thread = acpi_ut_create_thread_state (); 454 thread = acpi_ut_create_thread_state();
1120 if (!thread) { 455 if (!thread) {
1121 return_ACPI_STATUS (AE_NO_MEMORY); 456 return_ACPI_STATUS(AE_NO_MEMORY);
1122 } 457 }
1123 458
1124 walk_state->thread = thread; 459 walk_state->thread = thread;
1125 acpi_ds_push_walk_state (walk_state, thread); 460 acpi_ds_push_walk_state(walk_state, thread);
1126 461
1127 /* 462 /*
1128 * This global allows the AML debugger to get a handle to the currently 463 * This global allows the AML debugger to get a handle to the currently
@@ -1134,130 +469,136 @@ acpi_ps_parse_aml (
1134 * Execute the walk loop as long as there is a valid Walk State. This 469 * Execute the walk loop as long as there is a valid Walk State. This
1135 * handles nested control method invocations without recursion. 470 * handles nested control method invocations without recursion.
1136 */ 471 */
1137 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", walk_state)); 472 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state));
1138 473
1139 status = AE_OK; 474 status = AE_OK;
1140 while (walk_state) { 475 while (walk_state) {
1141 if (ACPI_SUCCESS (status)) { 476 if (ACPI_SUCCESS(status)) {
1142 /* 477 /*
1143 * The parse_loop executes AML until the method terminates 478 * The parse_loop executes AML until the method terminates
1144 * or calls another method. 479 * or calls another method.
1145 */ 480 */
1146 status = acpi_ps_parse_loop (walk_state); 481 status = acpi_ps_parse_loop(walk_state);
1147 } 482 }
1148 483
1149 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 484 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
1150 "Completed one call to walk loop, %s State=%p\n", 485 "Completed one call to walk loop, %s State=%p\n",
1151 acpi_format_exception (status), walk_state)); 486 acpi_format_exception(status), walk_state));
1152 487
1153 if (status == AE_CTRL_TRANSFER) { 488 if (status == AE_CTRL_TRANSFER) {
1154 /* 489 /*
1155 * A method call was detected. 490 * A method call was detected.
1156 * Transfer control to the called control method 491 * Transfer control to the called control method
1157 */ 492 */
1158 status = acpi_ds_call_control_method (thread, walk_state, NULL); 493 status =
494 acpi_ds_call_control_method(thread, walk_state,
495 NULL);
1159 496
1160 /* 497 /*
1161 * If the transfer to the new method method call worked, a new walk 498 * If the transfer to the new method method call worked, a new walk
1162 * state was created -- get it 499 * state was created -- get it
1163 */ 500 */
1164 walk_state = acpi_ds_get_current_walk_state (thread); 501 walk_state = acpi_ds_get_current_walk_state(thread);
1165 continue; 502 continue;
1166 } 503 } else if (status == AE_CTRL_TERMINATE) {
1167 else if (status == AE_CTRL_TERMINATE) {
1168 status = AE_OK; 504 status = AE_OK;
1169 } 505 } else if ((status != AE_OK) && (walk_state->method_desc)) {
1170 else if ((status != AE_OK) && (walk_state->method_desc)) { 506 ACPI_REPORT_METHOD_ERROR("Method execution failed",
1171 ACPI_REPORT_METHOD_ERROR ("Method execution failed", 507 walk_state->method_node, NULL,
1172 walk_state->method_node, NULL, status); 508 status);
509
510 /* Ensure proper cleanup */
511
512 walk_state->parse_flags |= ACPI_PARSE_EXECUTE;
1173 513
1174 /* Check for possible multi-thread reentrancy problem */ 514 /* Check for possible multi-thread reentrancy problem */
1175 515
1176 if ((status == AE_ALREADY_EXISTS) && 516 if ((status == AE_ALREADY_EXISTS) &&
1177 (!walk_state->method_desc->method.semaphore)) { 517 (!walk_state->method_desc->method.semaphore)) {
1178 /* 518 /*
1179 * This method is marked not_serialized, but it tried to create 519 * This method is marked not_serialized, but it tried to create
1180 * a named object, causing the second thread entrance to fail. 520 * a named object, causing the second thread entrance to fail.
1181 * We will workaround this by marking the method permanently 521 * We will workaround this by marking the method permanently
1182 * as Serialized. 522 * as Serialized.
1183 */ 523 */
1184 walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED; 524 walk_state->method_desc->method.method_flags |=
525 AML_METHOD_SERIALIZED;
1185 walk_state->method_desc->method.concurrency = 1; 526 walk_state->method_desc->method.concurrency = 1;
1186 } 527 }
1187 } 528 }
1188 529
1189 if (walk_state->method_desc) {
1190 /* Decrement the thread count on the method parse tree */
1191
1192 if (walk_state->method_desc->method.thread_count) {
1193 walk_state->method_desc->method.thread_count--;
1194 }
1195 }
1196
1197 /* We are done with this walk, move on to the parent if any */ 530 /* We are done with this walk, move on to the parent if any */
1198 531
1199 walk_state = acpi_ds_pop_walk_state (thread); 532 walk_state = acpi_ds_pop_walk_state(thread);
1200 533
1201 /* Reset the current scope to the beginning of scope stack */ 534 /* Reset the current scope to the beginning of scope stack */
1202 535
1203 acpi_ds_scope_stack_clear (walk_state); 536 acpi_ds_scope_stack_clear(walk_state);
1204 537
1205 /* 538 /*
1206 * If we just returned from the execution of a control method, 539 * If we just returned from the execution of a control method,
1207 * there's lots of cleanup to do 540 * there's lots of cleanup to do
1208 */ 541 */
1209 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { 542 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
1210 terminate_status = acpi_ds_terminate_control_method (walk_state); 543 ACPI_PARSE_EXECUTE) {
1211 if (ACPI_FAILURE (terminate_status)) { 544 if (walk_state->method_desc) {
1212 ACPI_REPORT_ERROR (( 545 /* Decrement the thread count on the method parse tree */
1213 "Could not terminate control method properly\n"));
1214 546
1215 /* Ignore error and continue */ 547 walk_state->method_desc->method.thread_count--;
1216 } 548 }
549
550 acpi_ds_terminate_control_method(walk_state);
1217 } 551 }
1218 552
1219 /* Delete this walk state and all linked control states */ 553 /* Delete this walk state and all linked control states */
1220 554
1221 acpi_ps_cleanup_scope (&walk_state->parser_state); 555 acpi_ps_cleanup_scope(&walk_state->parser_state);
1222 556
1223 previous_walk_state = walk_state; 557 previous_walk_state = walk_state;
1224 558
1225 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 559 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
1226 "return_value=%p, implicit_value=%p State=%p\n", 560 "return_value=%p, implicit_value=%p State=%p\n",
1227 walk_state->return_desc, walk_state->implicit_return_obj, walk_state)); 561 walk_state->return_desc,
562 walk_state->implicit_return_obj, walk_state));
1228 563
1229 /* Check if we have restarted a preempted walk */ 564 /* Check if we have restarted a preempted walk */
1230 565
1231 walk_state = acpi_ds_get_current_walk_state (thread); 566 walk_state = acpi_ds_get_current_walk_state(thread);
1232 if (walk_state) { 567 if (walk_state) {
1233 if (ACPI_SUCCESS (status)) { 568 if (ACPI_SUCCESS(status)) {
1234 /* 569 /*
1235 * There is another walk state, restart it. 570 * There is another walk state, restart it.
1236 * If the method return value is not used by the parent, 571 * If the method return value is not used by the parent,
1237 * The object is deleted 572 * The object is deleted
1238 */ 573 */
1239 if (!previous_walk_state->return_desc) { 574 if (!previous_walk_state->return_desc) {
1240 status = acpi_ds_restart_control_method (walk_state, 575 status =
1241 previous_walk_state->implicit_return_obj); 576 acpi_ds_restart_control_method
1242 } 577 (walk_state,
1243 else { 578 previous_walk_state->
579 implicit_return_obj);
580 } else {
1244 /* 581 /*
1245 * We have a valid return value, delete any implicit 582 * We have a valid return value, delete any implicit
1246 * return value. 583 * return value.
1247 */ 584 */
1248 acpi_ds_clear_implicit_return (previous_walk_state); 585 acpi_ds_clear_implicit_return
586 (previous_walk_state);
1249 587
1250 status = acpi_ds_restart_control_method (walk_state, 588 status =
1251 previous_walk_state->return_desc); 589 acpi_ds_restart_control_method
590 (walk_state,
591 previous_walk_state->return_desc);
1252 } 592 }
1253 if (ACPI_SUCCESS (status)) { 593 if (ACPI_SUCCESS(status)) {
1254 walk_state->walk_type |= ACPI_WALK_METHOD_RESTART; 594 walk_state->walk_type |=
595 ACPI_WALK_METHOD_RESTART;
1255 } 596 }
1256 } 597 } else {
1257 else {
1258 /* On error, delete any return object */ 598 /* On error, delete any return object */
1259 599
1260 acpi_ut_remove_reference (previous_walk_state->return_desc); 600 acpi_ut_remove_reference(previous_walk_state->
601 return_desc);
1261 } 602 }
1262 } 603 }
1263 604
@@ -1268,37 +609,36 @@ acpi_ps_parse_aml (
1268 else if (previous_walk_state->caller_return_desc) { 609 else if (previous_walk_state->caller_return_desc) {
1269 if (previous_walk_state->implicit_return_obj) { 610 if (previous_walk_state->implicit_return_obj) {
1270 *(previous_walk_state->caller_return_desc) = 611 *(previous_walk_state->caller_return_desc) =
1271 previous_walk_state->implicit_return_obj; 612 previous_walk_state->implicit_return_obj;
1272 } 613 } else {
1273 else { 614 /* NULL if no return value */
1274 /* NULL if no return value */
1275 615
1276 *(previous_walk_state->caller_return_desc) = 616 *(previous_walk_state->caller_return_desc) =
1277 previous_walk_state->return_desc; 617 previous_walk_state->return_desc;
1278 } 618 }
1279 } 619 } else {
1280 else {
1281 if (previous_walk_state->return_desc) { 620 if (previous_walk_state->return_desc) {
1282 /* Caller doesn't want it, must delete it */ 621 /* Caller doesn't want it, must delete it */
1283 622
1284 acpi_ut_remove_reference (previous_walk_state->return_desc); 623 acpi_ut_remove_reference(previous_walk_state->
624 return_desc);
1285 } 625 }
1286 if (previous_walk_state->implicit_return_obj) { 626 if (previous_walk_state->implicit_return_obj) {
1287 /* Caller doesn't want it, must delete it */ 627 /* Caller doesn't want it, must delete it */
1288 628
1289 acpi_ut_remove_reference (previous_walk_state->implicit_return_obj); 629 acpi_ut_remove_reference(previous_walk_state->
630 implicit_return_obj);
1290 } 631 }
1291 } 632 }
1292 633
1293 acpi_ds_delete_walk_state (previous_walk_state); 634 acpi_ds_delete_walk_state(previous_walk_state);
1294 } 635 }
1295 636
1296 /* Normal exit */ 637 /* Normal exit */
1297 638
1298 acpi_ex_release_all_mutexes (thread); 639 acpi_ex_release_all_mutexes(thread);
1299 acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread)); 640 acpi_ut_delete_generic_state(ACPI_CAST_PTR
641 (union acpi_generic_state, thread));
1300 acpi_gbl_current_walk_list = prev_walk_list; 642 acpi_gbl_current_walk_list = prev_walk_list;
1301 return_ACPI_STATUS (status); 643 return_ACPI_STATUS(status);
1302} 644}
1303
1304
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index 8dcd1b1e7131..1c953b6f1af1 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47 46
48#define _COMPONENT ACPI_PARSER 47#define _COMPONENT ACPI_PARSER
49 ACPI_MODULE_NAME ("psscope") 48ACPI_MODULE_NAME("psscope")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -60,16 +58,13 @@
60 * DESCRIPTION: Get parent of current op being parsed 58 * DESCRIPTION: Get parent of current op being parsed
61 * 59 *
62 ******************************************************************************/ 60 ******************************************************************************/
63 61union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
64union acpi_parse_object * 62 *parser_state)
65acpi_ps_get_parent_scope (
66 struct acpi_parse_state *parser_state)
67{ 63{
68 64
69 return (parser_state->scope->parse_scope.op); 65 return (parser_state->scope->parse_scope.op);
70} 66}
71 67
72
73/******************************************************************************* 68/*******************************************************************************
74 * 69 *
75 * FUNCTION: acpi_ps_has_completed_scope 70 * FUNCTION: acpi_ps_has_completed_scope
@@ -84,17 +79,14 @@ acpi_ps_get_parent_scope (
84 * 79 *
85 ******************************************************************************/ 80 ******************************************************************************/
86 81
87u8 82u8 acpi_ps_has_completed_scope(struct acpi_parse_state * parser_state)
88acpi_ps_has_completed_scope (
89 struct acpi_parse_state *parser_state)
90{ 83{
91 84
92 return ((u8) 85 return ((u8)
93 ((parser_state->aml >= parser_state->scope->parse_scope.arg_end || 86 ((parser_state->aml >= parser_state->scope->parse_scope.arg_end
94 !parser_state->scope->parse_scope.arg_count))); 87 || !parser_state->scope->parse_scope.arg_count)));
95} 88}
96 89
97
98/******************************************************************************* 90/*******************************************************************************
99 * 91 *
100 * FUNCTION: acpi_ps_init_scope 92 * FUNCTION: acpi_ps_init_scope
@@ -109,34 +101,30 @@ acpi_ps_has_completed_scope (
109 ******************************************************************************/ 101 ******************************************************************************/
110 102
111acpi_status 103acpi_status
112acpi_ps_init_scope ( 104acpi_ps_init_scope(struct acpi_parse_state * parser_state,
113 struct acpi_parse_state *parser_state, 105 union acpi_parse_object * root_op)
114 union acpi_parse_object *root_op)
115{ 106{
116 union acpi_generic_state *scope; 107 union acpi_generic_state *scope;
117 108
109 ACPI_FUNCTION_TRACE_PTR("ps_init_scope", root_op);
118 110
119 ACPI_FUNCTION_TRACE_PTR ("ps_init_scope", root_op); 111 scope = acpi_ut_create_generic_state();
120
121
122 scope = acpi_ut_create_generic_state ();
123 if (!scope) { 112 if (!scope) {
124 return_ACPI_STATUS (AE_NO_MEMORY); 113 return_ACPI_STATUS(AE_NO_MEMORY);
125 } 114 }
126 115
127 scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE; 116 scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE;
128 scope->parse_scope.op = root_op; 117 scope->parse_scope.op = root_op;
129 scope->parse_scope.arg_count = ACPI_VAR_ARGS; 118 scope->parse_scope.arg_count = ACPI_VAR_ARGS;
130 scope->parse_scope.arg_end = parser_state->aml_end; 119 scope->parse_scope.arg_end = parser_state->aml_end;
131 scope->parse_scope.pkg_end = parser_state->aml_end; 120 scope->parse_scope.pkg_end = parser_state->aml_end;
132 121
133 parser_state->scope = scope; 122 parser_state->scope = scope;
134 parser_state->start_op = root_op; 123 parser_state->start_op = root_op;
135 124
136 return_ACPI_STATUS (AE_OK); 125 return_ACPI_STATUS(AE_OK);
137} 126}
138 127
139
140/******************************************************************************* 128/*******************************************************************************
141 * 129 *
142 * FUNCTION: acpi_ps_push_scope 130 * FUNCTION: acpi_ps_push_scope
@@ -153,48 +141,42 @@ acpi_ps_init_scope (
153 ******************************************************************************/ 141 ******************************************************************************/
154 142
155acpi_status 143acpi_status
156acpi_ps_push_scope ( 144acpi_ps_push_scope(struct acpi_parse_state *parser_state,
157 struct acpi_parse_state *parser_state, 145 union acpi_parse_object *op,
158 union acpi_parse_object *op, 146 u32 remaining_args, u32 arg_count)
159 u32 remaining_args,
160 u32 arg_count)
161{ 147{
162 union acpi_generic_state *scope; 148 union acpi_generic_state *scope;
163
164
165 ACPI_FUNCTION_TRACE_PTR ("ps_push_scope", op);
166 149
150 ACPI_FUNCTION_TRACE_PTR("ps_push_scope", op);
167 151
168 scope = acpi_ut_create_generic_state (); 152 scope = acpi_ut_create_generic_state();
169 if (!scope) { 153 if (!scope) {
170 return_ACPI_STATUS (AE_NO_MEMORY); 154 return_ACPI_STATUS(AE_NO_MEMORY);
171 } 155 }
172 156
173 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; 157 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE;
174 scope->parse_scope.op = op; 158 scope->parse_scope.op = op;
175 scope->parse_scope.arg_list = remaining_args; 159 scope->parse_scope.arg_list = remaining_args;
176 scope->parse_scope.arg_count = arg_count; 160 scope->parse_scope.arg_count = arg_count;
177 scope->parse_scope.pkg_end = parser_state->pkg_end; 161 scope->parse_scope.pkg_end = parser_state->pkg_end;
178 162
179 /* Push onto scope stack */ 163 /* Push onto scope stack */
180 164
181 acpi_ut_push_generic_state (&parser_state->scope, scope); 165 acpi_ut_push_generic_state(&parser_state->scope, scope);
182 166
183 if (arg_count == ACPI_VAR_ARGS) { 167 if (arg_count == ACPI_VAR_ARGS) {
184 /* Multiple arguments */ 168 /* Multiple arguments */
185 169
186 scope->parse_scope.arg_end = parser_state->pkg_end; 170 scope->parse_scope.arg_end = parser_state->pkg_end;
187 } 171 } else {
188 else {
189 /* Single argument */ 172 /* Single argument */
190 173
191 scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR); 174 scope->parse_scope.arg_end = ACPI_TO_POINTER(ACPI_MAX_PTR);
192 } 175 }
193 176
194 return_ACPI_STATUS (AE_OK); 177 return_ACPI_STATUS(AE_OK);
195} 178}
196 179
197
198/******************************************************************************* 180/*******************************************************************************
199 * 181 *
200 * FUNCTION: acpi_ps_pop_scope 182 * FUNCTION: acpi_ps_pop_scope
@@ -212,48 +194,41 @@ acpi_ps_push_scope (
212 ******************************************************************************/ 194 ******************************************************************************/
213 195
214void 196void
215acpi_ps_pop_scope ( 197acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
216 struct acpi_parse_state *parser_state, 198 union acpi_parse_object **op, u32 * arg_list, u32 * arg_count)
217 union acpi_parse_object **op,
218 u32 *arg_list,
219 u32 *arg_count)
220{ 199{
221 union acpi_generic_state *scope = parser_state->scope; 200 union acpi_generic_state *scope = parser_state->scope;
222
223
224 ACPI_FUNCTION_TRACE ("ps_pop_scope");
225 201
202 ACPI_FUNCTION_TRACE("ps_pop_scope");
226 203
227 /* Only pop the scope if there is in fact a next scope */ 204 /* Only pop the scope if there is in fact a next scope */
228 205
229 if (scope->common.next) { 206 if (scope->common.next) {
230 scope = acpi_ut_pop_generic_state (&parser_state->scope); 207 scope = acpi_ut_pop_generic_state(&parser_state->scope);
231 208
232 /* return to parsing previous op */ 209 /* return to parsing previous op */
233 210
234 *op = scope->parse_scope.op; 211 *op = scope->parse_scope.op;
235 *arg_list = scope->parse_scope.arg_list; 212 *arg_list = scope->parse_scope.arg_list;
236 *arg_count = scope->parse_scope.arg_count; 213 *arg_count = scope->parse_scope.arg_count;
237 parser_state->pkg_end = scope->parse_scope.pkg_end; 214 parser_state->pkg_end = scope->parse_scope.pkg_end;
238 215
239 /* All done with this scope state structure */ 216 /* All done with this scope state structure */
240 217
241 acpi_ut_delete_generic_state (scope); 218 acpi_ut_delete_generic_state(scope);
242 } 219 } else {
243 else {
244 /* empty parse stack, prepare to fetch next opcode */ 220 /* empty parse stack, prepare to fetch next opcode */
245 221
246 *op = NULL; 222 *op = NULL;
247 *arg_list = 0; 223 *arg_list = 0;
248 *arg_count = 0; 224 *arg_count = 0;
249 } 225 }
250 226
251 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 227 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
252 "Popped Op %p Args %X\n", *op, *arg_count)); 228 "Popped Op %p Args %X\n", *op, *arg_count));
253 return_VOID; 229 return_VOID;
254} 230}
255 231
256
257/******************************************************************************* 232/*******************************************************************************
258 * 233 *
259 * FUNCTION: acpi_ps_cleanup_scope 234 * FUNCTION: acpi_ps_cleanup_scope
@@ -267,15 +242,11 @@ acpi_ps_pop_scope (
267 * 242 *
268 ******************************************************************************/ 243 ******************************************************************************/
269 244
270void 245void acpi_ps_cleanup_scope(struct acpi_parse_state *parser_state)
271acpi_ps_cleanup_scope (
272 struct acpi_parse_state *parser_state)
273{ 246{
274 union acpi_generic_state *scope; 247 union acpi_generic_state *scope;
275
276
277 ACPI_FUNCTION_TRACE_PTR ("ps_cleanup_scope", parser_state);
278 248
249 ACPI_FUNCTION_TRACE_PTR("ps_cleanup_scope", parser_state);
279 250
280 if (!parser_state) { 251 if (!parser_state) {
281 return_VOID; 252 return_VOID;
@@ -284,10 +255,9 @@ acpi_ps_cleanup_scope (
284 /* Delete anything on the scope stack */ 255 /* Delete anything on the scope stack */
285 256
286 while (parser_state->scope) { 257 while (parser_state->scope) {
287 scope = acpi_ut_pop_generic_state (&parser_state->scope); 258 scope = acpi_ut_pop_generic_state(&parser_state->scope);
288 acpi_ut_delete_generic_state (scope); 259 acpi_ut_delete_generic_state(scope);
289 } 260 }
290 261
291 return_VOID; 262 return_VOID;
292} 263}
293
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
index d5aafe73fca0..f0e755884eea 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/parser/pstree.c
@@ -41,23 +41,18 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48 47
49#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
50 ACPI_MODULE_NAME ("pstree") 49ACPI_MODULE_NAME("pstree")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54#ifdef ACPI_OBSOLETE_FUNCTIONS 52#ifdef ACPI_OBSOLETE_FUNCTIONS
55union acpi_parse_object * 53union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op);
56acpi_ps_get_child (
57 union acpi_parse_object *op);
58#endif 54#endif
59 55
60
61/******************************************************************************* 56/*******************************************************************************
62 * 57 *
63 * FUNCTION: acpi_ps_get_arg 58 * FUNCTION: acpi_ps_get_arg
@@ -71,21 +66,16 @@ acpi_ps_get_child (
71 * 66 *
72 ******************************************************************************/ 67 ******************************************************************************/
73 68
74union acpi_parse_object * 69union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn)
75acpi_ps_get_arg (
76 union acpi_parse_object *op,
77 u32 argn)
78{ 70{
79 union acpi_parse_object *arg = NULL; 71 union acpi_parse_object *arg = NULL;
80 const struct acpi_opcode_info *op_info; 72 const struct acpi_opcode_info *op_info;
81
82
83 ACPI_FUNCTION_ENTRY ();
84 73
74 ACPI_FUNCTION_ENTRY();
85 75
86 /* Get the info structure for this opcode */ 76 /* Get the info structure for this opcode */
87 77
88 op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 78 op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
89 if (op_info->class == AML_CLASS_UNKNOWN) { 79 if (op_info->class == AML_CLASS_UNKNOWN) {
90 /* Invalid opcode or ASCII character */ 80 /* Invalid opcode or ASCII character */
91 81
@@ -111,7 +101,6 @@ acpi_ps_get_arg (
111 return (arg); 101 return (arg);
112} 102}
113 103
114
115/******************************************************************************* 104/*******************************************************************************
116 * 105 *
117 * FUNCTION: acpi_ps_append_arg 106 * FUNCTION: acpi_ps_append_arg
@@ -126,16 +115,12 @@ acpi_ps_get_arg (
126 ******************************************************************************/ 115 ******************************************************************************/
127 116
128void 117void
129acpi_ps_append_arg ( 118acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
130 union acpi_parse_object *op,
131 union acpi_parse_object *arg)
132{ 119{
133 union acpi_parse_object *prev_arg; 120 union acpi_parse_object *prev_arg;
134 const struct acpi_opcode_info *op_info; 121 const struct acpi_opcode_info *op_info;
135
136
137 ACPI_FUNCTION_ENTRY ();
138 122
123 ACPI_FUNCTION_ENTRY();
139 124
140 if (!op) { 125 if (!op) {
141 return; 126 return;
@@ -143,12 +128,11 @@ acpi_ps_append_arg (
143 128
144 /* Get the info structure for this opcode */ 129 /* Get the info structure for this opcode */
145 130
146 op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 131 op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
147 if (op_info->class == AML_CLASS_UNKNOWN) { 132 if (op_info->class == AML_CLASS_UNKNOWN) {
148 /* Invalid opcode */ 133 /* Invalid opcode */
149 134
150 ACPI_REPORT_ERROR (("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", 135 ACPI_REPORT_ERROR(("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->common.aml_opcode));
151 op->common.aml_opcode));
152 return; 136 return;
153 } 137 }
154 138
@@ -170,8 +154,7 @@ acpi_ps_append_arg (
170 prev_arg = prev_arg->common.next; 154 prev_arg = prev_arg->common.next;
171 } 155 }
172 prev_arg->common.next = arg; 156 prev_arg->common.next = arg;
173 } 157 } else {
174 else {
175 /* No argument list, this will be the first argument */ 158 /* No argument list, this will be the first argument */
176 159
177 op->common.value.arg = arg; 160 op->common.value.arg = arg;
@@ -185,7 +168,6 @@ acpi_ps_append_arg (
185 } 168 }
186} 169}
187 170
188
189#ifdef ACPI_FUTURE_USAGE 171#ifdef ACPI_FUTURE_USAGE
190/******************************************************************************* 172/*******************************************************************************
191 * 173 *
@@ -201,18 +183,14 @@ acpi_ps_append_arg (
201 * 183 *
202 ******************************************************************************/ 184 ******************************************************************************/
203 185
204union acpi_parse_object * 186union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
205acpi_ps_get_depth_next ( 187 union acpi_parse_object *op)
206 union acpi_parse_object *origin,
207 union acpi_parse_object *op)
208{ 188{
209 union acpi_parse_object *next = NULL; 189 union acpi_parse_object *next = NULL;
210 union acpi_parse_object *parent; 190 union acpi_parse_object *parent;
211 union acpi_parse_object *arg; 191 union acpi_parse_object *arg;
212
213
214 ACPI_FUNCTION_ENTRY ();
215 192
193 ACPI_FUNCTION_ENTRY();
216 194
217 if (!op) { 195 if (!op) {
218 return (NULL); 196 return (NULL);
@@ -220,7 +198,7 @@ acpi_ps_get_depth_next (
220 198
221 /* Look for an argument or child */ 199 /* Look for an argument or child */
222 200
223 next = acpi_ps_get_arg (op, 0); 201 next = acpi_ps_get_arg(op, 0);
224 if (next) { 202 if (next) {
225 return (next); 203 return (next);
226 } 204 }
@@ -237,7 +215,7 @@ acpi_ps_get_depth_next (
237 parent = op->common.parent; 215 parent = op->common.parent;
238 216
239 while (parent) { 217 while (parent) {
240 arg = acpi_ps_get_arg (parent, 0); 218 arg = acpi_ps_get_arg(parent, 0);
241 while (arg && (arg != origin) && (arg != op)) { 219 while (arg && (arg != origin) && (arg != op)) {
242 arg = arg->common.next; 220 arg = arg->common.next;
243 } 221 }
@@ -261,7 +239,6 @@ acpi_ps_get_depth_next (
261 return (next); 239 return (next);
262} 240}
263 241
264
265#ifdef ACPI_OBSOLETE_FUNCTIONS 242#ifdef ACPI_OBSOLETE_FUNCTIONS
266/******************************************************************************* 243/*******************************************************************************
267 * 244 *
@@ -275,15 +252,11 @@ acpi_ps_get_depth_next (
275 * 252 *
276 ******************************************************************************/ 253 ******************************************************************************/
277 254
278union acpi_parse_object * 255union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op)
279acpi_ps_get_child (
280 union acpi_parse_object *op)
281{ 256{
282 union acpi_parse_object *child = NULL; 257 union acpi_parse_object *child = NULL;
283
284
285 ACPI_FUNCTION_ENTRY ();
286 258
259 ACPI_FUNCTION_ENTRY();
287 260
288 switch (op->common.aml_opcode) { 261 switch (op->common.aml_opcode) {
289 case AML_SCOPE_OP: 262 case AML_SCOPE_OP:
@@ -292,10 +265,9 @@ acpi_ps_get_child (
292 case AML_THERMAL_ZONE_OP: 265 case AML_THERMAL_ZONE_OP:
293 case AML_INT_METHODCALL_OP: 266 case AML_INT_METHODCALL_OP:
294 267
295 child = acpi_ps_get_arg (op, 0); 268 child = acpi_ps_get_arg(op, 0);
296 break; 269 break;
297 270
298
299 case AML_BUFFER_OP: 271 case AML_BUFFER_OP:
300 case AML_PACKAGE_OP: 272 case AML_PACKAGE_OP:
301 case AML_METHOD_OP: 273 case AML_METHOD_OP:
@@ -303,24 +275,21 @@ acpi_ps_get_child (
303 case AML_WHILE_OP: 275 case AML_WHILE_OP:
304 case AML_FIELD_OP: 276 case AML_FIELD_OP:
305 277
306 child = acpi_ps_get_arg (op, 1); 278 child = acpi_ps_get_arg(op, 1);
307 break; 279 break;
308 280
309
310 case AML_POWER_RES_OP: 281 case AML_POWER_RES_OP:
311 case AML_INDEX_FIELD_OP: 282 case AML_INDEX_FIELD_OP:
312 283
313 child = acpi_ps_get_arg (op, 2); 284 child = acpi_ps_get_arg(op, 2);
314 break; 285 break;
315 286
316
317 case AML_PROCESSOR_OP: 287 case AML_PROCESSOR_OP:
318 case AML_BANK_FIELD_OP: 288 case AML_BANK_FIELD_OP:
319 289
320 child = acpi_ps_get_arg (op, 3); 290 child = acpi_ps_get_arg(op, 3);
321 break; 291 break;
322 292
323
324 default: 293 default:
325 /* All others have no children */ 294 /* All others have no children */
326 break; 295 break;
@@ -330,5 +299,4 @@ acpi_ps_get_child (
330} 299}
331#endif 300#endif
332 301
333#endif /* ACPI_FUTURE_USAGE */ 302#endif /* ACPI_FUTURE_USAGE */
334
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index a10f88715d43..2075efbb4324 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -41,14 +41,12 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48 47
49#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
50 ACPI_MODULE_NAME ("psutils") 49ACPI_MODULE_NAME("psutils")
51
52 50
53/******************************************************************************* 51/*******************************************************************************
54 * 52 *
@@ -61,15 +59,11 @@
61 * DESCRIPTION: Create a Scope and associated namepath op with the root name 59 * DESCRIPTION: Create a Scope and associated namepath op with the root name
62 * 60 *
63 ******************************************************************************/ 61 ******************************************************************************/
64 62union acpi_parse_object *acpi_ps_create_scope_op(void)
65union acpi_parse_object *
66acpi_ps_create_scope_op (
67 void)
68{ 63{
69 union acpi_parse_object *scope_op; 64 union acpi_parse_object *scope_op;
70 65
71 66 scope_op = acpi_ps_alloc_op(AML_SCOPE_OP);
72 scope_op = acpi_ps_alloc_op (AML_SCOPE_OP);
73 if (!scope_op) { 67 if (!scope_op) {
74 return (NULL); 68 return (NULL);
75 } 69 }
@@ -78,7 +72,6 @@ acpi_ps_create_scope_op (
78 return (scope_op); 72 return (scope_op);
79} 73}
80 74
81
82/******************************************************************************* 75/*******************************************************************************
83 * 76 *
84 * FUNCTION: acpi_ps_init_op 77 * FUNCTION: acpi_ps_init_op
@@ -92,23 +85,19 @@ acpi_ps_create_scope_op (
92 * 85 *
93 ******************************************************************************/ 86 ******************************************************************************/
94 87
95void 88void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
96acpi_ps_init_op (
97 union acpi_parse_object *op,
98 u16 opcode)
99{ 89{
100 ACPI_FUNCTION_ENTRY (); 90 ACPI_FUNCTION_ENTRY();
101
102 91
103 op->common.data_type = ACPI_DESC_TYPE_PARSER; 92 op->common.data_type = ACPI_DESC_TYPE_PARSER;
104 op->common.aml_opcode = opcode; 93 op->common.aml_opcode = opcode;
105 94
106 ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name, 95 ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name,
107 (acpi_ps_get_opcode_info (opcode))->name, 96 (acpi_ps_get_opcode_info
108 sizeof (op->common.aml_op_name))); 97 (opcode))->name,
98 sizeof(op->common.aml_op_name)));
109} 99}
110 100
111
112/******************************************************************************* 101/*******************************************************************************
113 * 102 *
114 * FUNCTION: acpi_ps_alloc_op 103 * FUNCTION: acpi_ps_alloc_op
@@ -123,29 +112,23 @@ acpi_ps_init_op (
123 * 112 *
124 ******************************************************************************/ 113 ******************************************************************************/
125 114
126union acpi_parse_object* 115union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
127acpi_ps_alloc_op (
128 u16 opcode)
129{ 116{
130 union acpi_parse_object *op; 117 union acpi_parse_object *op;
131 const struct acpi_opcode_info *op_info; 118 const struct acpi_opcode_info *op_info;
132 u8 flags = ACPI_PARSEOP_GENERIC; 119 u8 flags = ACPI_PARSEOP_GENERIC;
133
134 120
135 ACPI_FUNCTION_ENTRY (); 121 ACPI_FUNCTION_ENTRY();
136 122
137 123 op_info = acpi_ps_get_opcode_info(opcode);
138 op_info = acpi_ps_get_opcode_info (opcode);
139 124
140 /* Determine type of parse_op required */ 125 /* Determine type of parse_op required */
141 126
142 if (op_info->flags & AML_DEFER) { 127 if (op_info->flags & AML_DEFER) {
143 flags = ACPI_PARSEOP_DEFERRED; 128 flags = ACPI_PARSEOP_DEFERRED;
144 } 129 } else if (op_info->flags & AML_NAMED) {
145 else if (op_info->flags & AML_NAMED) {
146 flags = ACPI_PARSEOP_NAMED; 130 flags = ACPI_PARSEOP_NAMED;
147 } 131 } else if (opcode == AML_INT_BYTELIST_OP) {
148 else if (opcode == AML_INT_BYTELIST_OP) {
149 flags = ACPI_PARSEOP_BYTELIST; 132 flags = ACPI_PARSEOP_BYTELIST;
150 } 133 }
151 134
@@ -154,25 +137,25 @@ acpi_ps_alloc_op (
154 if (flags == ACPI_PARSEOP_GENERIC) { 137 if (flags == ACPI_PARSEOP_GENERIC) {
155 /* The generic op (default) is by far the most common (16 to 1) */ 138 /* The generic op (default) is by far the most common (16 to 1) */
156 139
157 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); 140 op = acpi_os_acquire_object(acpi_gbl_ps_node_cache);
158 } 141 memset(op, 0, sizeof(struct acpi_parse_obj_common));
159 else { 142 } else {
160 /* Extended parseop */ 143 /* Extended parseop */
161 144
162 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); 145 op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache);
146 memset(op, 0, sizeof(struct acpi_parse_obj_named));
163 } 147 }
164 148
165 /* Initialize the Op */ 149 /* Initialize the Op */
166 150
167 if (op) { 151 if (op) {
168 acpi_ps_init_op (op, opcode); 152 acpi_ps_init_op(op, opcode);
169 op->common.flags = flags; 153 op->common.flags = flags;
170 } 154 }
171 155
172 return (op); 156 return (op);
173} 157}
174 158
175
176/******************************************************************************* 159/*******************************************************************************
177 * 160 *
178 * FUNCTION: acpi_ps_free_op 161 * FUNCTION: acpi_ps_free_op
@@ -186,53 +169,22 @@ acpi_ps_alloc_op (
186 * 169 *
187 ******************************************************************************/ 170 ******************************************************************************/
188 171
189void 172void acpi_ps_free_op(union acpi_parse_object *op)
190acpi_ps_free_op (
191 union acpi_parse_object *op)
192{ 173{
193 ACPI_FUNCTION_NAME ("ps_free_op"); 174 ACPI_FUNCTION_NAME("ps_free_op");
194
195 175
196 if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 176 if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
197 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", op)); 177 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n",
178 op));
198 } 179 }
199 180
200 if (op->common.flags & ACPI_PARSEOP_GENERIC) { 181 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
201 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); 182 (void)acpi_os_release_object(acpi_gbl_ps_node_cache, op);
202 } 183 } else {
203 else { 184 (void)acpi_os_release_object(acpi_gbl_ps_node_ext_cache, op);
204 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op);
205 } 185 }
206} 186}
207 187
208
209#ifdef ACPI_ENABLE_OBJECT_CACHE
210/*******************************************************************************
211 *
212 * FUNCTION: acpi_ps_delete_parse_cache
213 *
214 * PARAMETERS: None
215 *
216 * RETURN: None
217 *
218 * DESCRIPTION: Free all objects that are on the parse cache list.
219 *
220 ******************************************************************************/
221
222void
223acpi_ps_delete_parse_cache (
224 void)
225{
226 ACPI_FUNCTION_TRACE ("ps_delete_parse_cache");
227
228
229 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
230 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT);
231 return_VOID;
232}
233#endif
234
235
236/******************************************************************************* 188/*******************************************************************************
237 * 189 *
238 * FUNCTION: Utility functions 190 * FUNCTION: Utility functions
@@ -241,36 +193,27 @@ acpi_ps_delete_parse_cache (
241 * 193 *
242 ******************************************************************************/ 194 ******************************************************************************/
243 195
244
245/* 196/*
246 * Is "c" a namestring lead character? 197 * Is "c" a namestring lead character?
247 */ 198 */
248u8 199u8 acpi_ps_is_leading_char(u32 c)
249acpi_ps_is_leading_char (
250 u32 c)
251{ 200{
252 return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); 201 return ((u8) (c == '_' || (c >= 'A' && c <= 'Z')));
253} 202}
254 203
255
256/* 204/*
257 * Is "c" a namestring prefix character? 205 * Is "c" a namestring prefix character?
258 */ 206 */
259u8 207u8 acpi_ps_is_prefix_char(u32 c)
260acpi_ps_is_prefix_char (
261 u32 c)
262{ 208{
263 return ((u8) (c == '\\' || c == '^')); 209 return ((u8) (c == '\\' || c == '^'));
264} 210}
265 211
266
267/* 212/*
268 * Get op's name (4-byte name segment) or 0 if unnamed 213 * Get op's name (4-byte name segment) or 0 if unnamed
269 */ 214 */
270#ifdef ACPI_FUTURE_USAGE 215#ifdef ACPI_FUTURE_USAGE
271u32 216u32 acpi_ps_get_name(union acpi_parse_object * op)
272acpi_ps_get_name (
273 union acpi_parse_object *op)
274{ 217{
275 218
276 /* The "generic" object has no name associated with it */ 219 /* The "generic" object has no name associated with it */
@@ -283,16 +226,12 @@ acpi_ps_get_name (
283 226
284 return (op->named.name); 227 return (op->named.name);
285} 228}
286#endif /* ACPI_FUTURE_USAGE */ 229#endif /* ACPI_FUTURE_USAGE */
287
288 230
289/* 231/*
290 * Set op's name 232 * Set op's name
291 */ 233 */
292void 234void acpi_ps_set_name(union acpi_parse_object *op, u32 name)
293acpi_ps_set_name (
294 union acpi_parse_object *op,
295 u32 name)
296{ 235{
297 236
298 /* The "generic" object has no name associated with it */ 237 /* The "generic" object has no name associated with it */
@@ -303,4 +242,3 @@ acpi_ps_set_name (
303 242
304 op->named.name = name; 243 op->named.name = name;
305} 244}
306
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
index 9d20cb2ceb51..08f2321b6ded 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/parser/pswalk.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47 46
48#define _COMPONENT ACPI_PARSER 47#define _COMPONENT ACPI_PARSER
49 ACPI_MODULE_NAME ("pswalk") 48ACPI_MODULE_NAME("pswalk")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -60,18 +58,13 @@
60 * DESCRIPTION: Delete a portion of or an entire parse tree. 58 * DESCRIPTION: Delete a portion of or an entire parse tree.
61 * 59 *
62 ******************************************************************************/ 60 ******************************************************************************/
63 61void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
64void
65acpi_ps_delete_parse_tree (
66 union acpi_parse_object *subtree_root)
67{ 62{
68 union acpi_parse_object *op = subtree_root; 63 union acpi_parse_object *op = subtree_root;
69 union acpi_parse_object *next = NULL; 64 union acpi_parse_object *next = NULL;
70 union acpi_parse_object *parent = NULL; 65 union acpi_parse_object *parent = NULL;
71
72
73 ACPI_FUNCTION_TRACE_PTR ("ps_delete_parse_tree", subtree_root);
74 66
67 ACPI_FUNCTION_TRACE_PTR("ps_delete_parse_tree", subtree_root);
75 68
76 /* Visit all nodes in the subtree */ 69 /* Visit all nodes in the subtree */
77 70
@@ -81,7 +74,7 @@ acpi_ps_delete_parse_tree (
81 if (op != parent) { 74 if (op != parent) {
82 /* Look for an argument or child of the current op */ 75 /* Look for an argument or child of the current op */
83 76
84 next = acpi_ps_get_arg (op, 0); 77 next = acpi_ps_get_arg(op, 0);
85 if (next) { 78 if (next) {
86 /* Still going downward in tree (Op is not completed yet) */ 79 /* Still going downward in tree (Op is not completed yet) */
87 80
@@ -95,7 +88,7 @@ acpi_ps_delete_parse_tree (
95 next = op->common.next; 88 next = op->common.next;
96 parent = op->common.parent; 89 parent = op->common.parent;
97 90
98 acpi_ps_free_op (op); 91 acpi_ps_free_op(op);
99 92
100 /* If we are back to the starting point, the walk is complete. */ 93 /* If we are back to the starting point, the walk is complete. */
101 94
@@ -104,8 +97,7 @@ acpi_ps_delete_parse_tree (
104 } 97 }
105 if (next) { 98 if (next) {
106 op = next; 99 op = next;
107 } 100 } else {
108 else {
109 op = parent; 101 op = parent;
110 } 102 }
111 } 103 }
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index dba893648e84..4dcbd443160e 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -41,24 +41,27 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h>
50
51 48
52#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
53 ACPI_MODULE_NAME ("psxface") 50ACPI_MODULE_NAME("psxface")
51
52/* Local Prototypes */
53static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
54 54
55static void
56acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
55 57
56/******************************************************************************* 58/*******************************************************************************
57 * 59 *
58 * FUNCTION: acpi_psx_execute 60 * FUNCTION: acpi_ps_execute_method
59 * 61 *
60 * PARAMETERS: Info - Method info block, contains: 62 * PARAMETERS: Info - Method info block, contains:
61 * Node - Method Node to execute 63 * Node - Method Node to execute
64 * obj_desc - Method object
62 * Parameters - List of parameters to pass to the method, 65 * Parameters - List of parameters to pass to the method,
63 * terminated by NULL. Params itself may be 66 * terminated by NULL. Params itself may be
64 * NULL if no parameters are being passed. 67 * NULL if no parameters are being passed.
@@ -67,6 +70,7 @@
67 * parameter_type - Type of Parameter list 70 * parameter_type - Type of Parameter list
68 * return_object - Where to put method's return value (if 71 * return_object - Where to put method's return value (if
69 * any). If NULL, no value is returned. 72 * any). If NULL, no value is returned.
73 * pass_number - Parse or execute pass
70 * 74 *
71 * RETURN: Status 75 * RETURN: Status
72 * 76 *
@@ -74,173 +78,170 @@
74 * 78 *
75 ******************************************************************************/ 79 ******************************************************************************/
76 80
77acpi_status 81acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
78acpi_psx_execute (
79 struct acpi_parameter_info *info)
80{ 82{
81 acpi_status status; 83 acpi_status status;
82 union acpi_operand_object *obj_desc;
83 u32 i;
84 union acpi_parse_object *op;
85 struct acpi_walk_state *walk_state;
86
87
88 ACPI_FUNCTION_TRACE ("psx_execute");
89 84
85 ACPI_FUNCTION_TRACE("ps_execute_method");
90 86
91 /* Validate the Node and get the attached object */ 87 /* Validate the Info and method Node */
92 88
93 if (!info || !info->node) { 89 if (!info || !info->node) {
94 return_ACPI_STATUS (AE_NULL_ENTRY); 90 return_ACPI_STATUS(AE_NULL_ENTRY);
95 }
96
97 obj_desc = acpi_ns_get_attached_object (info->node);
98 if (!obj_desc) {
99 return_ACPI_STATUS (AE_NULL_OBJECT);
100 } 91 }
101 92
102 /* Init for new method, wait on concurrency semaphore */ 93 /* Init for new method, wait on concurrency semaphore */
103 94
104 status = acpi_ds_begin_method_execution (info->node, obj_desc, NULL); 95 status =
105 if (ACPI_FAILURE (status)) { 96 acpi_ds_begin_method_execution(info->node, info->obj_desc, NULL);
106 return_ACPI_STATUS (status); 97 if (ACPI_FAILURE(status)) {
98 return_ACPI_STATUS(status);
107 } 99 }
108 100
109 if ((info->parameter_type == ACPI_PARAM_ARGS) && 101 /*
110 (info->parameters)) { 102 * The caller "owns" the parameters, so give each one an extra
111 /* 103 * reference
112 * The caller "owns" the parameters, so give each one an extra 104 */
113 * reference 105 acpi_ps_update_parameter_list(info, REF_INCREMENT);
114 */
115 for (i = 0; info->parameters[i]; i++) {
116 acpi_ut_add_reference (info->parameters[i]);
117 }
118 }
119 106
120 /* 107 /*
121 * 1) Perform the first pass parse of the method to enter any 108 * 1) Perform the first pass parse of the method to enter any
122 * named objects that it creates into the namespace 109 * named objects that it creates into the namespace
123 */ 110 */
124 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 111 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
125 "**** Begin Method Parse **** Entry=%p obj=%p\n", 112 "**** Begin Method Parse **** Entry=%p obj=%p\n",
126 info->node, obj_desc)); 113 info->node, info->obj_desc));
127 114
128 /* Create and init a Root Node */ 115 info->pass_number = 1;
129 116 status = acpi_ps_execute_pass(info);
130 op = acpi_ps_create_scope_op (); 117 if (ACPI_FAILURE(status)) {
131 if (!op) { 118 goto cleanup;
132 status = AE_NO_MEMORY;
133 goto cleanup1;
134 } 119 }
135 120
136 /* 121 /*
137 * Get a new owner_id for objects created by this method. Namespace 122 * 2) Execute the method. Performs second pass parse simultaneously
138 * objects (such as Operation Regions) can be created during the
139 * first pass parse.
140 */ 123 */
141 obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); 124 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
125 "**** Begin Method Execution **** Entry=%p obj=%p\n",
126 info->node, info->obj_desc));
142 127
143 /* Create and initialize a new walk state */ 128 info->pass_number = 3;
129 status = acpi_ps_execute_pass(info);
144 130
145 walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, 131 cleanup:
146 NULL, NULL, NULL); 132 /* Take away the extra reference that we gave the parameters above */
147 if (!walk_state) {
148 status = AE_NO_MEMORY;
149 goto cleanup2;
150 }
151 133
152 status = acpi_ds_init_aml_walk (walk_state, op, info->node, 134 acpi_ps_update_parameter_list(info, REF_DECREMENT);
153 obj_desc->method.aml_start,
154 obj_desc->method.aml_length, NULL, 1);
155 if (ACPI_FAILURE (status)) {
156 goto cleanup3;
157 }
158 135
159 /* Parse the AML */ 136 /* Exit now if error above */
160 137
161 status = acpi_ps_parse_aml (walk_state); 138 if (ACPI_FAILURE(status)) {
162 acpi_ps_delete_parse_tree (op); 139 return_ACPI_STATUS(status);
163 if (ACPI_FAILURE (status)) {
164 goto cleanup1; /* Walk state is already deleted */
165 } 140 }
166 141
167 /* 142 /*
168 * 2) Execute the method. Performs second pass parse simultaneously 143 * If the method has returned an object, signal this to the caller with
144 * a control exception code
169 */ 145 */
170 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 146 if (info->return_object) {
171 "**** Begin Method Execution **** Entry=%p obj=%p\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
172 info->node, obj_desc)); 148 "Method returned obj_desc=%p\n",
173 149 info->return_object));
174 /* Create and init a Root Node */ 150 ACPI_DUMP_STACK_ENTRY(info->return_object);
175 151
176 op = acpi_ps_create_scope_op (); 152 status = AE_CTRL_RETURN_VALUE;
177 if (!op) {
178 status = AE_NO_MEMORY;
179 goto cleanup1;
180 } 153 }
181 154
182 /* Init new op with the method name and pointer back to the NS node */ 155 return_ACPI_STATUS(status);
156}
157
158/*******************************************************************************
159 *
160 * FUNCTION: acpi_ps_update_parameter_list
161 *
162 * PARAMETERS: Info - See struct acpi_parameter_info
163 * (Used: parameter_type and Parameters)
164 * Action - Add or Remove reference
165 *
166 * RETURN: Status
167 *
168 * DESCRIPTION: Update reference count on all method parameter objects
169 *
170 ******************************************************************************/
183 171
184 acpi_ps_set_name (op, info->node->name.integer); 172static void
185 op->common.node = info->node; 173acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action)
174{
175 acpi_native_uint i;
186 176
187 /* Create and initialize a new walk state */ 177 if ((info->parameter_type == ACPI_PARAM_ARGS) && (info->parameters)) {
178 /* Update reference count for each parameter */
188 179
189 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 180 for (i = 0; info->parameters[i]; i++) {
190 if (!walk_state) { 181 /* Ignore errors, just do them all */
191 status = AE_NO_MEMORY;
192 goto cleanup2;
193 }
194 182
195 status = acpi_ds_init_aml_walk (walk_state, op, info->node, 183 (void)acpi_ut_update_object_reference(info->
196 obj_desc->method.aml_start, 184 parameters[i],
197 obj_desc->method.aml_length, info, 3); 185 action);
198 if (ACPI_FAILURE (status)) { 186 }
199 goto cleanup3;
200 } 187 }
188}
201 189
202 /* The walk of the parse tree is where we actually execute the method */ 190/*******************************************************************************
203 191 *
204 status = acpi_ps_parse_aml (walk_state); 192 * FUNCTION: acpi_ps_execute_pass
205 goto cleanup2; /* Walk state already deleted */ 193 *
194 * PARAMETERS: Info - See struct acpi_parameter_info
195 * (Used: pass_number, Node, and obj_desc)
196 *
197 * RETURN: Status
198 *
199 * DESCRIPTION: Single AML pass: Parse or Execute a control method
200 *
201 ******************************************************************************/
206 202
203static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info)
204{
205 acpi_status status;
206 union acpi_parse_object *op;
207 struct acpi_walk_state *walk_state;
207 208
208cleanup3: 209 ACPI_FUNCTION_TRACE("ps_execute_pass");
209 acpi_ds_delete_walk_state (walk_state);
210 210
211cleanup2: 211 /* Create and init a Root Node */
212 acpi_ps_delete_parse_tree (op);
213 212
214cleanup1: 213 op = acpi_ps_create_scope_op();
215 if ((info->parameter_type == ACPI_PARAM_ARGS) && 214 if (!op) {
216 (info->parameters)) { 215 return_ACPI_STATUS(AE_NO_MEMORY);
217 /* Take away the extra reference that we gave the parameters above */ 216 }
218 217
219 for (i = 0; info->parameters[i]; i++) { 218 /* Create and initialize a new walk state */
220 /* Ignore errors, just do them all */
221 219
222 (void) acpi_ut_update_object_reference ( 220 walk_state =
223 info->parameters[i], REF_DECREMENT); 221 acpi_ds_create_walk_state(info->obj_desc->method.owner_id, NULL,
224 } 222 NULL, NULL);
223 if (!walk_state) {
224 status = AE_NO_MEMORY;
225 goto cleanup;
225 } 226 }
226 227
227 if (ACPI_FAILURE (status)) { 228 status = acpi_ds_init_aml_walk(walk_state, op, info->node,
228 return_ACPI_STATUS (status); 229 info->obj_desc->method.aml_start,
230 info->obj_desc->method.aml_length,
231 info->pass_number == 1 ? NULL : info,
232 info->pass_number);
233 if (ACPI_FAILURE(status)) {
234 acpi_ds_delete_walk_state(walk_state);
235 goto cleanup;
229 } 236 }
230 237
231 /* 238 /* Parse the AML */
232 * If the method has returned an object, signal this to the caller with
233 * a control exception code
234 */
235 if (info->return_object) {
236 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
237 info->return_object));
238 ACPI_DUMP_STACK_ENTRY (info->return_object);
239
240 status = AE_CTRL_RETURN_VALUE;
241 }
242 239
243 return_ACPI_STATUS (status); 240 status = acpi_ps_parse_aml(walk_state);
244}
245 241
242 /* Walk state was deleted by parse_aml */
246 243
244 cleanup:
245 acpi_ps_delete_parse_tree(op);
246 return_ACPI_STATUS(status);
247}
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 5148f3c10b5c..2a718df769b5 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -35,22 +35,17 @@
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 36#include <acpi/acpi_drivers.h>
37 37
38
39#define _COMPONENT ACPI_PCI_COMPONENT 38#define _COMPONENT ACPI_PCI_COMPONENT
40ACPI_MODULE_NAME ("pci_bind") 39ACPI_MODULE_NAME("pci_bind")
41 40
42struct acpi_pci_data { 41struct acpi_pci_data {
43 struct acpi_pci_id id; 42 struct acpi_pci_id id;
44 struct pci_bus *bus; 43 struct pci_bus *bus;
45 struct pci_dev *dev; 44 struct pci_dev *dev;
46}; 45};
47 46
48 47static void acpi_pci_data_handler(acpi_handle handle, u32 function,
49void 48 void *context)
50acpi_pci_data_handler (
51 acpi_handle handle,
52 u32 function,
53 void *context)
54{ 49{
55 ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); 50 ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
56 51
@@ -59,7 +54,6 @@ acpi_pci_data_handler (
59 return_VOID; 54 return_VOID;
60} 55}
61 56
62
63/** 57/**
64 * acpi_get_pci_id 58 * acpi_get_pci_id
65 * ------------------ 59 * ------------------
@@ -67,15 +61,12 @@ acpi_pci_data_handler (
67 * to resolve PCI information for ACPI-PCI devices defined in the namespace. 61 * to resolve PCI information for ACPI-PCI devices defined in the namespace.
68 * This typically occurs when resolving PCI operation region information. 62 * This typically occurs when resolving PCI operation region information.
69 */ 63 */
70acpi_status 64acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
71acpi_get_pci_id (
72 acpi_handle handle,
73 struct acpi_pci_id *id)
74{ 65{
75 int result = 0; 66 int result = 0;
76 acpi_status status = AE_OK; 67 acpi_status status = AE_OK;
77 struct acpi_device *device = NULL; 68 struct acpi_device *device = NULL;
78 struct acpi_pci_data *data = NULL; 69 struct acpi_pci_data *data = NULL;
79 70
80 ACPI_FUNCTION_TRACE("acpi_get_pci_id"); 71 ACPI_FUNCTION_TRACE("acpi_get_pci_id");
81 72
@@ -84,52 +75,50 @@ acpi_get_pci_id (
84 75
85 result = acpi_bus_get_device(handle, &device); 76 result = acpi_bus_get_device(handle, &device);
86 if (result) { 77 if (result) {
87 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 78 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
88 "Invalid ACPI Bus context for device %s\n", 79 "Invalid ACPI Bus context for device %s\n",
89 acpi_device_bid(device))); 80 acpi_device_bid(device)));
90 return_ACPI_STATUS(AE_NOT_EXIST); 81 return_ACPI_STATUS(AE_NOT_EXIST);
91 } 82 }
92 83
93 status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); 84 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
94 if (ACPI_FAILURE(status) || !data) { 85 if (ACPI_FAILURE(status) || !data) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
96 "Invalid ACPI-PCI context for device %s\n", 87 "Invalid ACPI-PCI context for device %s\n",
97 acpi_device_bid(device))); 88 acpi_device_bid(device)));
98 return_ACPI_STATUS(status); 89 return_ACPI_STATUS(status);
99 } 90 }
100 91
101 *id = data->id; 92 *id = data->id;
102 93
103 /* 94 /*
104 id->segment = data->id.segment; 95 id->segment = data->id.segment;
105 id->bus = data->id.bus; 96 id->bus = data->id.bus;
106 id->device = data->id.device; 97 id->device = data->id.device;
107 id->function = data->id.function; 98 id->function = data->id.function;
108 */ 99 */
109 100
110 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
111 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 102 "Device %s has PCI address %02x:%02x:%02x.%02x\n",
112 acpi_device_bid(device), id->segment, id->bus, 103 acpi_device_bid(device), id->segment, id->bus,
113 id->device, id->function)); 104 id->device, id->function));
114 105
115 return_ACPI_STATUS(AE_OK); 106 return_ACPI_STATUS(AE_OK);
116} 107}
108
117EXPORT_SYMBOL(acpi_get_pci_id); 109EXPORT_SYMBOL(acpi_get_pci_id);
118 110
119 111int acpi_pci_bind(struct acpi_device *device)
120int
121acpi_pci_bind (
122 struct acpi_device *device)
123{ 112{
124 int result = 0; 113 int result = 0;
125 acpi_status status = AE_OK; 114 acpi_status status = AE_OK;
126 struct acpi_pci_data *data = NULL; 115 struct acpi_pci_data *data = NULL;
127 struct acpi_pci_data *pdata = NULL; 116 struct acpi_pci_data *pdata = NULL;
128 char *pathname = NULL; 117 char *pathname = NULL;
129 struct acpi_buffer buffer = {0, NULL}; 118 struct acpi_buffer buffer = { 0, NULL };
130 acpi_handle handle = NULL; 119 acpi_handle handle = NULL;
131 struct pci_dev *dev; 120 struct pci_dev *dev;
132 struct pci_bus *bus; 121 struct pci_bus *bus;
133 122
134 ACPI_FUNCTION_TRACE("acpi_pci_bind"); 123 ACPI_FUNCTION_TRACE("acpi_pci_bind");
135 124
@@ -137,34 +126,34 @@ acpi_pci_bind (
137 return_VALUE(-EINVAL); 126 return_VALUE(-EINVAL);
138 127
139 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 128 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
140 if(!pathname) 129 if (!pathname)
141 return_VALUE(-ENOMEM); 130 return_VALUE(-ENOMEM);
142 memset(pathname, 0, ACPI_PATHNAME_MAX); 131 memset(pathname, 0, ACPI_PATHNAME_MAX);
143 buffer.length = ACPI_PATHNAME_MAX; 132 buffer.length = ACPI_PATHNAME_MAX;
144 buffer.pointer = pathname; 133 buffer.pointer = pathname;
145 134
146 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 135 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
147 if (!data){ 136 if (!data) {
148 kfree (pathname); 137 kfree(pathname);
149 return_VALUE(-ENOMEM); 138 return_VALUE(-ENOMEM);
150 } 139 }
151 memset(data, 0, sizeof(struct acpi_pci_data)); 140 memset(data, 0, sizeof(struct acpi_pci_data));
152 141
153 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 142 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 143 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
155 pathname)); 144 pathname));
156 145
157 /* 146 /*
158 * Segment & Bus 147 * Segment & Bus
159 * ------------- 148 * -------------
160 * These are obtained via the parent device's ACPI-PCI context. 149 * These are obtained via the parent device's ACPI-PCI context.
161 */ 150 */
162 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 151 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
163 (void**) &pdata); 152 (void **)&pdata);
164 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { 153 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
166 "Invalid ACPI-PCI context for parent device %s\n", 155 "Invalid ACPI-PCI context for parent device %s\n",
167 acpi_device_bid(device->parent))); 156 acpi_device_bid(device->parent)));
168 result = -ENODEV; 157 result = -ENODEV;
169 goto end; 158 goto end;
170 } 159 }
@@ -181,8 +170,8 @@ acpi_pci_bind (
181 data->id.function = device->pnp.bus_address & 0xFFFF; 170 data->id.function = device->pnp.bus_address & 0xFFFF;
182 171
183 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n",
184 data->id.segment, data->id.bus, data->id.device, 173 data->id.segment, data->id.bus, data->id.device,
185 data->id.function)); 174 data->id.function));
186 175
187 /* 176 /*
188 * TBD: Support slot devices (e.g. function=0xFFFF). 177 * TBD: Support slot devices (e.g. function=0xFFFF).
@@ -202,25 +191,25 @@ acpi_pci_bind (
202 if (bus) { 191 if (bus) {
203 list_for_each_entry(dev, &bus->devices, bus_list) { 192 list_for_each_entry(dev, &bus->devices, bus_list) {
204 if (dev->devfn == PCI_DEVFN(data->id.device, 193 if (dev->devfn == PCI_DEVFN(data->id.device,
205 data->id.function)) { 194 data->id.function)) {
206 data->dev = dev; 195 data->dev = dev;
207 break; 196 break;
208 } 197 }
209 } 198 }
210 } 199 }
211 if (!data->dev) { 200 if (!data->dev) {
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 201 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
213 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 202 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
214 data->id.segment, data->id.bus, 203 data->id.segment, data->id.bus,
215 data->id.device, data->id.function)); 204 data->id.device, data->id.function));
216 result = -ENODEV; 205 result = -ENODEV;
217 goto end; 206 goto end;
218 } 207 }
219 if (!data->dev->bus) { 208 if (!data->dev->bus) {
220 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 209 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
221 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 210 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
222 data->id.segment, data->id.bus, 211 data->id.segment, data->id.bus,
223 data->id.device, data->id.function)); 212 data->id.device, data->id.function));
224 result = -ENODEV; 213 result = -ENODEV;
225 goto end; 214 goto end;
226 } 215 }
@@ -232,10 +221,10 @@ acpi_pci_bind (
232 * facilitate callbacks for all of its children. 221 * facilitate callbacks for all of its children.
233 */ 222 */
234 if (data->dev->subordinate) { 223 if (data->dev->subordinate) {
235 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
236 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 225 "Device %02x:%02x:%02x.%02x is a PCI bridge\n",
237 data->id.segment, data->id.bus, 226 data->id.segment, data->id.bus,
238 data->id.device, data->id.function)); 227 data->id.device, data->id.function));
239 data->bus = data->dev->subordinate; 228 data->bus = data->dev->subordinate;
240 device->ops.bind = acpi_pci_bind; 229 device->ops.bind = acpi_pci_bind;
241 device->ops.unbind = acpi_pci_unbind; 230 device->ops.unbind = acpi_pci_unbind;
@@ -249,8 +238,8 @@ acpi_pci_bind (
249 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 238 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
250 if (ACPI_FAILURE(status)) { 239 if (ACPI_FAILURE(status)) {
251 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
252 "Unable to attach ACPI-PCI context to device %s\n", 241 "Unable to attach ACPI-PCI context to device %s\n",
253 acpi_device_bid(device))); 242 acpi_device_bid(device)));
254 result = -ENODEV; 243 result = -ENODEV;
255 goto end; 244 goto end;
256 } 245 }
@@ -267,15 +256,15 @@ acpi_pci_bind (
267 */ 256 */
268 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 257 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
269 if (ACPI_SUCCESS(status)) { 258 if (ACPI_SUCCESS(status)) {
270 if (data->bus) /* PCI-PCI bridge */ 259 if (data->bus) /* PCI-PCI bridge */
271 acpi_pci_irq_add_prt(device->handle, data->id.segment,
272 data->bus->number);
273 else /* non-bridge PCI device */
274 acpi_pci_irq_add_prt(device->handle, data->id.segment, 260 acpi_pci_irq_add_prt(device->handle, data->id.segment,
275 data->id.bus); 261 data->bus->number);
262 else /* non-bridge PCI device */
263 acpi_pci_irq_add_prt(device->handle, data->id.segment,
264 data->id.bus);
276 } 265 }
277 266
278end: 267 end:
279 kfree(pathname); 268 kfree(pathname);
280 if (result) 269 if (result)
281 kfree(data); 270 kfree(data);
@@ -283,22 +272,21 @@ end:
283 return_VALUE(result); 272 return_VALUE(result);
284} 273}
285 274
286int acpi_pci_unbind( 275int acpi_pci_unbind(struct acpi_device *device)
287 struct acpi_device *device)
288{ 276{
289 int result = 0; 277 int result = 0;
290 acpi_status status = AE_OK; 278 acpi_status status = AE_OK;
291 struct acpi_pci_data *data = NULL; 279 struct acpi_pci_data *data = NULL;
292 char *pathname = NULL; 280 char *pathname = NULL;
293 struct acpi_buffer buffer = {0, NULL}; 281 struct acpi_buffer buffer = { 0, NULL };
294 282
295 ACPI_FUNCTION_TRACE("acpi_pci_unbind"); 283 ACPI_FUNCTION_TRACE("acpi_pci_unbind");
296 284
297 if (!device || !device->parent) 285 if (!device || !device->parent)
298 return_VALUE(-EINVAL); 286 return_VALUE(-EINVAL);
299 287
300 pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 288 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
301 if(!pathname) 289 if (!pathname)
302 return_VALUE(-ENOMEM); 290 return_VALUE(-ENOMEM);
303 memset(pathname, 0, ACPI_PATHNAME_MAX); 291 memset(pathname, 0, ACPI_PATHNAME_MAX);
304 292
@@ -306,14 +294,16 @@ int acpi_pci_unbind(
306 buffer.pointer = pathname; 294 buffer.pointer = pathname;
307 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 295 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
308 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 296 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
309 pathname)); 297 pathname));
310 kfree(pathname); 298 kfree(pathname);
311 299
312 status = acpi_get_data(device->handle, acpi_pci_data_handler, (void**)&data); 300 status =
301 acpi_get_data(device->handle, acpi_pci_data_handler,
302 (void **)&data);
313 if (ACPI_FAILURE(status)) { 303 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
315 "Unable to get data from device %s\n", 305 "Unable to get data from device %s\n",
316 acpi_device_bid(device))); 306 acpi_device_bid(device)));
317 result = -ENODEV; 307 result = -ENODEV;
318 goto end; 308 goto end;
319 } 309 }
@@ -321,8 +311,8 @@ int acpi_pci_unbind(
321 status = acpi_detach_data(device->handle, acpi_pci_data_handler); 311 status = acpi_detach_data(device->handle, acpi_pci_data_handler);
322 if (ACPI_FAILURE(status)) { 312 if (ACPI_FAILURE(status)) {
323 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 313 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Unable to detach data from device %s\n", 314 "Unable to detach data from device %s\n",
325 acpi_device_bid(device))); 315 acpi_device_bid(device)));
326 result = -ENODEV; 316 result = -ENODEV;
327 goto end; 317 goto end;
328 } 318 }
@@ -331,39 +321,37 @@ int acpi_pci_unbind(
331 } 321 }
332 kfree(data); 322 kfree(data);
333 323
334end: 324 end:
335 return_VALUE(result); 325 return_VALUE(result);
336} 326}
337 327
338int 328int
339acpi_pci_bind_root ( 329acpi_pci_bind_root(struct acpi_device *device,
340 struct acpi_device *device, 330 struct acpi_pci_id *id, struct pci_bus *bus)
341 struct acpi_pci_id *id,
342 struct pci_bus *bus)
343{ 331{
344 int result = 0; 332 int result = 0;
345 acpi_status status = AE_OK; 333 acpi_status status = AE_OK;
346 struct acpi_pci_data *data = NULL; 334 struct acpi_pci_data *data = NULL;
347 char *pathname = NULL; 335 char *pathname = NULL;
348 struct acpi_buffer buffer = {0, NULL}; 336 struct acpi_buffer buffer = { 0, NULL };
349 337
350 ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); 338 ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
351 339
352 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 340 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
353 if(!pathname) 341 if (!pathname)
354 return_VALUE(-ENOMEM); 342 return_VALUE(-ENOMEM);
355 memset(pathname, 0, ACPI_PATHNAME_MAX); 343 memset(pathname, 0, ACPI_PATHNAME_MAX);
356 344
357 buffer.length = ACPI_PATHNAME_MAX; 345 buffer.length = ACPI_PATHNAME_MAX;
358 buffer.pointer = pathname; 346 buffer.pointer = pathname;
359 347
360 if (!device || !id || !bus){ 348 if (!device || !id || !bus) {
361 kfree(pathname); 349 kfree(pathname);
362 return_VALUE(-EINVAL); 350 return_VALUE(-EINVAL);
363 } 351 }
364 352
365 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 353 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
366 if (!data){ 354 if (!data) {
367 kfree(pathname); 355 kfree(pathname);
368 return_VALUE(-ENOMEM); 356 return_VALUE(-ENOMEM);
369 } 357 }
@@ -377,18 +365,18 @@ acpi_pci_bind_root (
377 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 365 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
378 366
379 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 367 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
380 "%02x:%02x\n", pathname, id->segment, id->bus)); 368 "%02x:%02x\n", pathname, id->segment, id->bus));
381 369
382 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 370 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
383 if (ACPI_FAILURE(status)) { 371 if (ACPI_FAILURE(status)) {
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 372 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "Unable to attach ACPI-PCI context to device %s\n", 373 "Unable to attach ACPI-PCI context to device %s\n",
386 pathname)); 374 pathname));
387 result = -ENODEV; 375 result = -ENODEV;
388 goto end; 376 goto end;
389 } 377 }
390 378
391end: 379 end:
392 kfree(pathname); 380 kfree(pathname);
393 if (result != 0) 381 if (result != 0)
394 kfree(data); 382 kfree(data);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index bb973d2109a1..09567c2edcfb 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -38,26 +38,22 @@
38#include <acpi/acpi_bus.h> 38#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
40 40
41
42#define _COMPONENT ACPI_PCI_COMPONENT 41#define _COMPONENT ACPI_PCI_COMPONENT
43ACPI_MODULE_NAME ("pci_irq") 42ACPI_MODULE_NAME("pci_irq")
44 43
45static struct acpi_prt_list acpi_prt; 44static struct acpi_prt_list acpi_prt;
46static DEFINE_SPINLOCK(acpi_prt_lock); 45static DEFINE_SPINLOCK(acpi_prt_lock);
47 46
48/* -------------------------------------------------------------------------- 47/* --------------------------------------------------------------------------
49 PCI IRQ Routing Table (PRT) Support 48 PCI IRQ Routing Table (PRT) Support
50 -------------------------------------------------------------------------- */ 49 -------------------------------------------------------------------------- */
51 50
52static struct acpi_prt_entry * 51static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
53acpi_pci_irq_find_prt_entry ( 52 int bus,
54 int segment, 53 int device, int pin)
55 int bus,
56 int device,
57 int pin)
58{ 54{
59 struct list_head *node = NULL; 55 struct list_head *node = NULL;
60 struct acpi_prt_entry *entry = NULL; 56 struct acpi_prt_entry *entry = NULL;
61 57
62 ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry"); 58 ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
63 59
@@ -72,10 +68,10 @@ acpi_pci_irq_find_prt_entry (
72 spin_lock(&acpi_prt_lock); 68 spin_lock(&acpi_prt_lock);
73 list_for_each(node, &acpi_prt.entries) { 69 list_for_each(node, &acpi_prt.entries) {
74 entry = list_entry(node, struct acpi_prt_entry, node); 70 entry = list_entry(node, struct acpi_prt_entry, node);
75 if ((segment == entry->id.segment) 71 if ((segment == entry->id.segment)
76 && (bus == entry->id.bus) 72 && (bus == entry->id.bus)
77 && (device == entry->id.device) 73 && (device == entry->id.device)
78 && (pin == entry->pin)) { 74 && (pin == entry->pin)) {
79 spin_unlock(&acpi_prt_lock); 75 spin_unlock(&acpi_prt_lock);
80 return_PTR(entry); 76 return_PTR(entry);
81 } 77 }
@@ -85,15 +81,11 @@ acpi_pci_irq_find_prt_entry (
85 return_PTR(NULL); 81 return_PTR(NULL);
86} 82}
87 83
88
89static int 84static int
90acpi_pci_irq_add_entry ( 85acpi_pci_irq_add_entry(acpi_handle handle,
91 acpi_handle handle, 86 int segment, int bus, struct acpi_pci_routing_table *prt)
92 int segment,
93 int bus,
94 struct acpi_pci_routing_table *prt)
95{ 87{
96 struct acpi_prt_entry *entry = NULL; 88 struct acpi_prt_entry *entry = NULL;
97 89
98 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry"); 90 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry");
99 91
@@ -139,9 +131,10 @@ acpi_pci_irq_add_entry (
139 entry->link.index = prt->source_index; 131 entry->link.index = prt->source_index;
140 132
141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, 133 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
142 " %02X:%02X:%02X[%c] -> %s[%d]\n", 134 " %02X:%02X:%02X[%c] -> %s[%d]\n",
143 entry->id.segment, entry->id.bus, entry->id.device, 135 entry->id.segment, entry->id.bus,
144 ('A' + entry->pin), prt->source, entry->link.index)); 136 entry->id.device, ('A' + entry->pin), prt->source,
137 entry->link.index));
145 138
146 spin_lock(&acpi_prt_lock); 139 spin_lock(&acpi_prt_lock);
147 list_add_tail(&entry->node, &acpi_prt.entries); 140 list_add_tail(&entry->node, &acpi_prt.entries);
@@ -151,38 +144,29 @@ acpi_pci_irq_add_entry (
151 return_VALUE(0); 144 return_VALUE(0);
152} 145}
153 146
154
155static void 147static void
156acpi_pci_irq_del_entry ( 148acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
157 int segment,
158 int bus,
159 struct acpi_prt_entry *entry)
160{ 149{
161 if (segment == entry->id.segment && bus == entry->id.bus){ 150 if (segment == entry->id.segment && bus == entry->id.bus) {
162 acpi_prt.count--; 151 acpi_prt.count--;
163 list_del(&entry->node); 152 list_del(&entry->node);
164 kfree(entry); 153 kfree(entry);
165 } 154 }
166} 155}
167 156
168 157int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
169int
170acpi_pci_irq_add_prt (
171 acpi_handle handle,
172 int segment,
173 int bus)
174{ 158{
175 acpi_status status = AE_OK; 159 acpi_status status = AE_OK;
176 char *pathname = NULL; 160 char *pathname = NULL;
177 struct acpi_buffer buffer = {0, NULL}; 161 struct acpi_buffer buffer = { 0, NULL };
178 struct acpi_pci_routing_table *prt = NULL; 162 struct acpi_pci_routing_table *prt = NULL;
179 struct acpi_pci_routing_table *entry = NULL; 163 struct acpi_pci_routing_table *entry = NULL;
180 static int first_time = 1; 164 static int first_time = 1;
181 165
182 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt"); 166 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
183 167
184 pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 168 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
185 if(!pathname) 169 if (!pathname)
186 return_VALUE(-ENOMEM); 170 return_VALUE(-ENOMEM);
187 memset(pathname, 0, ACPI_PATHNAME_MAX); 171 memset(pathname, 0, ACPI_PATHNAME_MAX);
188 172
@@ -202,7 +186,7 @@ acpi_pci_irq_add_prt (
202 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 186 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
203 187
204 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", 188 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
205 pathname); 189 pathname);
206 190
207 /* 191 /*
208 * Evaluate this _PRT and add its entries to our global list (acpi_prt). 192 * Evaluate this _PRT and add its entries to our global list (acpi_prt).
@@ -214,12 +198,12 @@ acpi_pci_irq_add_prt (
214 status = acpi_get_irq_routing_table(handle, &buffer); 198 status = acpi_get_irq_routing_table(handle, &buffer);
215 if (status != AE_BUFFER_OVERFLOW) { 199 if (status != AE_BUFFER_OVERFLOW) {
216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 200 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
217 acpi_format_exception(status))); 201 acpi_format_exception(status)));
218 return_VALUE(-ENODEV); 202 return_VALUE(-ENODEV);
219 } 203 }
220 204
221 prt = kmalloc(buffer.length, GFP_KERNEL); 205 prt = kmalloc(buffer.length, GFP_KERNEL);
222 if (!prt){ 206 if (!prt) {
223 return_VALUE(-ENOMEM); 207 return_VALUE(-ENOMEM);
224 } 208 }
225 memset(prt, 0, buffer.length); 209 memset(prt, 0, buffer.length);
@@ -228,7 +212,7 @@ acpi_pci_irq_add_prt (
228 status = acpi_get_irq_routing_table(handle, &buffer); 212 status = acpi_get_irq_routing_table(handle, &buffer);
229 if (ACPI_FAILURE(status)) { 213 if (ACPI_FAILURE(status)) {
230 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
231 acpi_format_exception(status))); 215 acpi_format_exception(status)));
232 kfree(buffer.pointer); 216 kfree(buffer.pointer);
233 return_VALUE(-ENODEV); 217 return_VALUE(-ENODEV);
234 } 218 }
@@ -238,7 +222,7 @@ acpi_pci_irq_add_prt (
238 while (entry && (entry->length > 0)) { 222 while (entry && (entry->length > 0)) {
239 acpi_pci_irq_add_entry(handle, segment, bus, entry); 223 acpi_pci_irq_add_entry(handle, segment, bus, entry);
240 entry = (struct acpi_pci_routing_table *) 224 entry = (struct acpi_pci_routing_table *)
241 ((unsigned long) entry + entry->length); 225 ((unsigned long)entry + entry->length);
242 } 226 }
243 227
244 kfree(prt); 228 kfree(prt);
@@ -246,18 +230,18 @@ acpi_pci_irq_add_prt (
246 return_VALUE(0); 230 return_VALUE(0);
247} 231}
248 232
249void 233void acpi_pci_irq_del_prt(int segment, int bus)
250acpi_pci_irq_del_prt (int segment, int bus)
251{ 234{
252 struct list_head *node = NULL, *n = NULL; 235 struct list_head *node = NULL, *n = NULL;
253 struct acpi_prt_entry *entry = NULL; 236 struct acpi_prt_entry *entry = NULL;
254 237
255 if (!acpi_prt.count) { 238 if (!acpi_prt.count) {
256 return; 239 return;
257 } 240 }
258 241
259 printk(KERN_DEBUG "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", 242 printk(KERN_DEBUG
260 segment, bus); 243 "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment,
244 bus);
261 spin_lock(&acpi_prt_lock); 245 spin_lock(&acpi_prt_lock);
262 list_for_each_safe(node, n, &acpi_prt.entries) { 246 list_for_each_safe(node, n, &acpi_prt.entries) {
263 entry = list_entry(node, struct acpi_prt_entry, node); 247 entry = list_entry(node, struct acpi_prt_entry, node);
@@ -266,26 +250,27 @@ acpi_pci_irq_del_prt (int segment, int bus)
266 } 250 }
267 spin_unlock(&acpi_prt_lock); 251 spin_unlock(&acpi_prt_lock);
268} 252}
253
269/* -------------------------------------------------------------------------- 254/* --------------------------------------------------------------------------
270 PCI Interrupt Routing Support 255 PCI Interrupt Routing Support
271 -------------------------------------------------------------------------- */ 256 -------------------------------------------------------------------------- */
272typedef int (*irq_lookup_func)(struct acpi_prt_entry *, int *, int *, char **); 257typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
273 258
274static int 259static int
275acpi_pci_allocate_irq(struct acpi_prt_entry *entry, 260acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
276 int *edge_level, 261 int *edge_level, int *active_high_low, char **link)
277 int *active_high_low,
278 char **link)
279{ 262{
280 int irq; 263 int irq;
281 264
282 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq"); 265 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
283 266
284 if (entry->link.handle) { 267 if (entry->link.handle) {
285 irq = acpi_pci_link_allocate_irq(entry->link.handle, 268 irq = acpi_pci_link_allocate_irq(entry->link.handle,
286 entry->link.index, edge_level, active_high_low, link); 269 entry->link.index, edge_level,
270 active_high_low, link);
287 if (irq < 0) { 271 if (irq < 0) {
288 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n")); 272 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
273 "Invalid IRQ link routing entry\n"));
289 return_VALUE(-1); 274 return_VALUE(-1);
290 } 275 }
291 } else { 276 } else {
@@ -300,11 +285,9 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
300 285
301static int 286static int
302acpi_pci_free_irq(struct acpi_prt_entry *entry, 287acpi_pci_free_irq(struct acpi_prt_entry *entry,
303 int *edge_level, 288 int *edge_level, int *active_high_low, char **link)
304 int *active_high_low,
305 char **link)
306{ 289{
307 int irq; 290 int irq;
308 291
309 ACPI_FUNCTION_TRACE("acpi_pci_free_irq"); 292 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
310 if (entry->link.handle) { 293 if (entry->link.handle) {
@@ -314,38 +297,36 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry,
314 } 297 }
315 return_VALUE(irq); 298 return_VALUE(irq);
316} 299}
300
317/* 301/*
318 * acpi_pci_irq_lookup 302 * acpi_pci_irq_lookup
319 * success: return IRQ >= 0 303 * success: return IRQ >= 0
320 * failure: return -1 304 * failure: return -1
321 */ 305 */
322static int 306static int
323acpi_pci_irq_lookup ( 307acpi_pci_irq_lookup(struct pci_bus *bus,
324 struct pci_bus *bus, 308 int device,
325 int device, 309 int pin,
326 int pin, 310 int *edge_level,
327 int *edge_level, 311 int *active_high_low, char **link, irq_lookup_func func)
328 int *active_high_low,
329 char **link,
330 irq_lookup_func func)
331{ 312{
332 struct acpi_prt_entry *entry = NULL; 313 struct acpi_prt_entry *entry = NULL;
333 int segment = pci_domain_nr(bus); 314 int segment = pci_domain_nr(bus);
334 int bus_nr = bus->number; 315 int bus_nr = bus->number;
335 int ret; 316 int ret;
336 317
337 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); 318 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
338 319
339 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
340 "Searching for PRT entry for %02x:%02x:%02x[%c]\n", 321 "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
341 segment, bus_nr, device, ('A' + pin))); 322 segment, bus_nr, device, ('A' + pin)));
342 323
343 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); 324 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
344 if (!entry) { 325 if (!entry) {
345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); 326 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
346 return_VALUE(-1); 327 return_VALUE(-1);
347 } 328 }
348 329
349 ret = func(entry, edge_level, active_high_low, link); 330 ret = func(entry, edge_level, active_high_low, link);
350 return_VALUE(ret); 331 return_VALUE(ret);
351} 332}
@@ -356,17 +337,14 @@ acpi_pci_irq_lookup (
356 * failure: return < 0 337 * failure: return < 0
357 */ 338 */
358static int 339static int
359acpi_pci_irq_derive ( 340acpi_pci_irq_derive(struct pci_dev *dev,
360 struct pci_dev *dev, 341 int pin,
361 int pin, 342 int *edge_level,
362 int *edge_level, 343 int *active_high_low, char **link, irq_lookup_func func)
363 int *active_high_low,
364 char **link,
365 irq_lookup_func func)
366{ 344{
367 struct pci_dev *bridge = dev; 345 struct pci_dev *bridge = dev;
368 int irq = -1; 346 int irq = -1;
369 u8 bridge_pin = 0; 347 u8 bridge_pin = 0;
370 348
371 ACPI_FUNCTION_TRACE("acpi_pci_irq_derive"); 349 ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
372 350
@@ -383,28 +361,33 @@ acpi_pci_irq_derive (
383 361
384 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { 362 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
385 /* PC card has the same IRQ as its cardbridge */ 363 /* PC card has the same IRQ as its cardbridge */
386 pci_read_config_byte(bridge, PCI_INTERRUPT_PIN, &bridge_pin); 364 pci_read_config_byte(bridge, PCI_INTERRUPT_PIN,
365 &bridge_pin);
387 if (!bridge_pin) { 366 if (!bridge_pin) {
388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
389 "No interrupt pin configured for device %s\n", pci_name(bridge))); 368 "No interrupt pin configured for device %s\n",
369 pci_name(bridge)));
390 return_VALUE(-1); 370 return_VALUE(-1);
391 } 371 }
392 /* Pin is from 0 to 3 */ 372 /* Pin is from 0 to 3 */
393 bridge_pin --; 373 bridge_pin--;
394 pin = bridge_pin; 374 pin = bridge_pin;
395 } 375 }
396 376
397 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 377 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
398 pin, edge_level, active_high_low, link, func); 378 pin, edge_level, active_high_low,
379 link, func);
399 } 380 }
400 381
401 if (irq < 0) { 382 if (irq < 0) {
402 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to derive IRQ for device %s\n", pci_name(dev))); 383 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
384 "Unable to derive IRQ for device %s\n",
385 pci_name(dev)));
403 return_VALUE(-1); 386 return_VALUE(-1);
404 } 387 }
405 388
406 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", 389 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
407 irq, pci_name(dev), pci_name(bridge))); 390 irq, pci_name(dev), pci_name(bridge)));
408 391
409 return_VALUE(irq); 392 return_VALUE(irq);
410} 393}
@@ -415,30 +398,32 @@ acpi_pci_irq_derive (
415 * failure: return < 0 398 * failure: return < 0
416 */ 399 */
417 400
418int 401int acpi_pci_irq_enable(struct pci_dev *dev)
419acpi_pci_irq_enable (
420 struct pci_dev *dev)
421{ 402{
422 int irq = 0; 403 int irq = 0;
423 u8 pin = 0; 404 u8 pin = 0;
424 int edge_level = ACPI_LEVEL_SENSITIVE; 405 int edge_level = ACPI_LEVEL_SENSITIVE;
425 int active_high_low = ACPI_ACTIVE_LOW; 406 int active_high_low = ACPI_ACTIVE_LOW;
426 char *link = NULL; 407 char *link = NULL;
408 int rc;
427 409
428 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); 410 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
429 411
430 if (!dev) 412 if (!dev)
431 return_VALUE(-EINVAL); 413 return_VALUE(-EINVAL);
432 414
433 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 415 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
434 if (!pin) { 416 if (!pin) {
435 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(dev))); 417 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
418 "No interrupt pin configured for device %s\n",
419 pci_name(dev)));
436 return_VALUE(0); 420 return_VALUE(0);
437 } 421 }
438 pin--; 422 pin--;
439 423
440 if (!dev->bus) { 424 if (!dev->bus) {
441 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) 'bus' field\n")); 425 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
426 "Invalid (NULL) 'bus' field\n"));
442 return_VALUE(-ENODEV); 427 return_VALUE(-ENODEV);
443 } 428 }
444 429
@@ -446,69 +431,76 @@ acpi_pci_irq_enable (
446 * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT 431 * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT
447 * values override any BIOS-assigned IRQs set during boot. 432 * values override any BIOS-assigned IRQs set during boot.
448 */ 433 */
449 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 434 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
450 &edge_level, &active_high_low, &link, acpi_pci_allocate_irq); 435 &edge_level, &active_high_low, &link,
436 acpi_pci_allocate_irq);
451 437
452 /* 438 /*
453 * If no PRT entry was found, we'll try to derive an IRQ from the 439 * If no PRT entry was found, we'll try to derive an IRQ from the
454 * device's parent bridge. 440 * device's parent bridge.
455 */ 441 */
456 if (irq < 0) 442 if (irq < 0)
457 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 443 irq = acpi_pci_irq_derive(dev, pin, &edge_level,
458 &active_high_low, &link, acpi_pci_allocate_irq); 444 &active_high_low, &link,
459 445 acpi_pci_allocate_irq);
446
460 /* 447 /*
461 * No IRQ known to the ACPI subsystem - maybe the BIOS / 448 * No IRQ known to the ACPI subsystem - maybe the BIOS /
462 * driver reported one, then use it. Exit in any case. 449 * driver reported one, then use it. Exit in any case.
463 */ 450 */
464 if (irq < 0) { 451 if (irq < 0) {
465 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI", 452 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI",
466 pci_name(dev), ('A' + pin)); 453 pci_name(dev), ('A' + pin));
467 /* Interrupt Line values above 0xF are forbidden */ 454 /* Interrupt Line values above 0xF are forbidden */
468 if (dev->irq > 0 && (dev->irq <= 0xF)) { 455 if (dev->irq > 0 && (dev->irq <= 0xF)) {
469 printk(" - using IRQ %d\n", dev->irq); 456 printk(" - using IRQ %d\n", dev->irq);
470 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); 457 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
458 ACPI_ACTIVE_LOW);
471 return_VALUE(0); 459 return_VALUE(0);
472 } 460 } else {
473 else {
474 printk("\n"); 461 printk("\n");
475 return_VALUE(0); 462 return_VALUE(0);
476 } 463 }
477 } 464 }
478 465
479 dev->irq = acpi_register_gsi(irq, edge_level, active_high_low); 466 rc = acpi_register_gsi(irq, edge_level, active_high_low);
467 if (rc < 0) {
468 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
469 "to register GSI\n", pci_name(dev), ('A' + pin));
470 return_VALUE(rc);
471 }
472 dev->irq = rc;
480 473
481 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", 474 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ",
482 pci_name(dev), 'A' + pin); 475 pci_name(dev), 'A' + pin);
483 476
484 if (link) 477 if (link)
485 printk("Link [%s] -> ", link); 478 printk("Link [%s] -> ", link);
486 479
487 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 480 printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
488 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 481 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
489 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", 482 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
490 dev->irq);
491 483
492 return_VALUE(0); 484 return_VALUE(0);
493} 485}
494EXPORT_SYMBOL(acpi_pci_irq_enable);
495 486
487EXPORT_SYMBOL(acpi_pci_irq_enable);
496 488
497/* FIXME: implement x86/x86_64 version */ 489/* FIXME: implement x86/x86_64 version */
498void __attribute__((weak)) acpi_unregister_gsi(u32 i) {} 490void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
491{
492}
499 493
500void 494void acpi_pci_irq_disable(struct pci_dev *dev)
501acpi_pci_irq_disable (
502 struct pci_dev *dev)
503{ 495{
504 int gsi = 0; 496 int gsi = 0;
505 u8 pin = 0; 497 u8 pin = 0;
506 int edge_level = ACPI_LEVEL_SENSITIVE; 498 int edge_level = ACPI_LEVEL_SENSITIVE;
507 int active_high_low = ACPI_ACTIVE_LOW; 499 int active_high_low = ACPI_ACTIVE_LOW;
508 500
509 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 501 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
510 502
511 if (!dev) 503 if (!dev || !dev->bus)
512 return_VOID; 504 return_VOID;
513 505
514 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 506 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
@@ -516,21 +508,20 @@ acpi_pci_irq_disable (
516 return_VOID; 508 return_VOID;
517 pin--; 509 pin--;
518 510
519 if (!dev->bus)
520 return_VOID;
521
522 /* 511 /*
523 * First we check the PCI IRQ routing table (PRT) for an IRQ. 512 * First we check the PCI IRQ routing table (PRT) for an IRQ.
524 */ 513 */
525 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 514 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
526 &edge_level, &active_high_low, NULL, acpi_pci_free_irq); 515 &edge_level, &active_high_low, NULL,
516 acpi_pci_free_irq);
527 /* 517 /*
528 * If no PRT entry was found, we'll try to derive an IRQ from the 518 * If no PRT entry was found, we'll try to derive an IRQ from the
529 * device's parent bridge. 519 * device's parent bridge.
530 */ 520 */
531 if (gsi < 0) 521 if (gsi < 0)
532 gsi = acpi_pci_irq_derive(dev, pin, 522 gsi = acpi_pci_irq_derive(dev, pin,
533 &edge_level, &active_high_low, NULL, acpi_pci_free_irq); 523 &edge_level, &active_high_low, NULL,
524 acpi_pci_free_irq);
534 if (gsi < 0) 525 if (gsi < 0)
535 return_VOID; 526 return_VOID;
536 527
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 834c2ceff1aa..82292b77e5c6 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -42,30 +42,26 @@
42#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
43#include <acpi/acpi_drivers.h> 43#include <acpi/acpi_drivers.h>
44 44
45
46#define _COMPONENT ACPI_PCI_COMPONENT 45#define _COMPONENT ACPI_PCI_COMPONENT
47ACPI_MODULE_NAME ("pci_link") 46ACPI_MODULE_NAME("pci_link")
48
49#define ACPI_PCI_LINK_CLASS "pci_irq_routing" 47#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
50#define ACPI_PCI_LINK_HID "PNP0C0F" 48#define ACPI_PCI_LINK_HID "PNP0C0F"
51#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" 49#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver"
52#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" 50#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
53#define ACPI_PCI_LINK_FILE_INFO "info" 51#define ACPI_PCI_LINK_FILE_INFO "info"
54#define ACPI_PCI_LINK_FILE_STATUS "state" 52#define ACPI_PCI_LINK_FILE_STATUS "state"
55
56#define ACPI_PCI_LINK_MAX_POSSIBLE 16 53#define ACPI_PCI_LINK_MAX_POSSIBLE 16
57 54static int acpi_pci_link_add(struct acpi_device *device);
58static int acpi_pci_link_add (struct acpi_device *device); 55static int acpi_pci_link_remove(struct acpi_device *device, int type);
59static int acpi_pci_link_remove (struct acpi_device *device, int type);
60 56
61static struct acpi_driver acpi_pci_link_driver = { 57static struct acpi_driver acpi_pci_link_driver = {
62 .name = ACPI_PCI_LINK_DRIVER_NAME, 58 .name = ACPI_PCI_LINK_DRIVER_NAME,
63 .class = ACPI_PCI_LINK_CLASS, 59 .class = ACPI_PCI_LINK_CLASS,
64 .ids = ACPI_PCI_LINK_HID, 60 .ids = ACPI_PCI_LINK_HID,
65 .ops = { 61 .ops = {
66 .add = acpi_pci_link_add, 62 .add = acpi_pci_link_add,
67 .remove = acpi_pci_link_remove, 63 .remove = acpi_pci_link_remove,
68 }, 64 },
69}; 65};
70 66
71/* 67/*
@@ -73,31 +69,30 @@ static struct acpi_driver acpi_pci_link_driver = {
73 * later even the link is disable. Instead, we just repick the active irq 69 * later even the link is disable. Instead, we just repick the active irq
74 */ 70 */
75struct acpi_pci_link_irq { 71struct acpi_pci_link_irq {
76 u8 active; /* Current IRQ */ 72 u8 active; /* Current IRQ */
77 u8 edge_level; /* All IRQs */ 73 u8 edge_level; /* All IRQs */
78 u8 active_high_low; /* All IRQs */ 74 u8 active_high_low; /* All IRQs */
79 u8 resource_type; 75 u8 resource_type;
80 u8 possible_count; 76 u8 possible_count;
81 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
82 u8 initialized:1; 78 u8 initialized:1;
83 u8 reserved:7; 79 u8 reserved:7;
84}; 80};
85 81
86struct acpi_pci_link { 82struct acpi_pci_link {
87 struct list_head node; 83 struct list_head node;
88 struct acpi_device *device; 84 struct acpi_device *device;
89 acpi_handle handle; 85 acpi_handle handle;
90 struct acpi_pci_link_irq irq; 86 struct acpi_pci_link_irq irq;
91 int refcnt; 87 int refcnt;
92}; 88};
93 89
94static struct { 90static struct {
95 int count; 91 int count;
96 struct list_head entries; 92 struct list_head entries;
97} acpi_link; 93} acpi_link;
98DECLARE_MUTEX(acpi_link_lock); 94DECLARE_MUTEX(acpi_link_lock);
99 95
100
101/* -------------------------------------------------------------------------- 96/* --------------------------------------------------------------------------
102 PCI Link Device Management 97 PCI Link Device Management
103 -------------------------------------------------------------------------- */ 98 -------------------------------------------------------------------------- */
@@ -106,12 +101,10 @@ DECLARE_MUTEX(acpi_link_lock);
106 * set context (link) possible list from resource list 101 * set context (link) possible list from resource list
107 */ 102 */
108static acpi_status 103static acpi_status
109acpi_pci_link_check_possible ( 104acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
110 struct acpi_resource *resource,
111 void *context)
112{ 105{
113 struct acpi_pci_link *link = (struct acpi_pci_link *) context; 106 struct acpi_pci_link *link = (struct acpi_pci_link *)context;
114 u32 i = 0; 107 u32 i = 0;
115 108
116 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); 109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
117 110
@@ -119,61 +112,68 @@ acpi_pci_link_check_possible (
119 case ACPI_RSTYPE_START_DPF: 112 case ACPI_RSTYPE_START_DPF:
120 return_ACPI_STATUS(AE_OK); 113 return_ACPI_STATUS(AE_OK);
121 case ACPI_RSTYPE_IRQ: 114 case ACPI_RSTYPE_IRQ:
122 { 115 {
123 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
124 if (!p || !p->number_of_interrupts) { 117 if (!p || !p->number_of_interrupts) {
125 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank IRQ resource\n")); 118 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
126 return_ACPI_STATUS(AE_OK); 119 "Blank IRQ resource\n"));
127 } 120 return_ACPI_STATUS(AE_OK);
128 for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
129 if (!p->interrupts[i]) {
130 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i]));
131 continue;
132 } 121 }
133 link->irq.possible[i] = p->interrupts[i]; 122 for (i = 0;
134 link->irq.possible_count++; 123 (i < p->number_of_interrupts
124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
125 if (!p->interrupts[i]) {
126 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
127 "Invalid IRQ %d\n",
128 p->interrupts[i]));
129 continue;
130 }
131 link->irq.possible[i] = p->interrupts[i];
132 link->irq.possible_count++;
133 }
134 link->irq.edge_level = p->edge_level;
135 link->irq.active_high_low = p->active_high_low;
136 link->irq.resource_type = ACPI_RSTYPE_IRQ;
137 break;
135 } 138 }
136 link->irq.edge_level = p->edge_level;
137 link->irq.active_high_low = p->active_high_low;
138 link->irq.resource_type = ACPI_RSTYPE_IRQ;
139 break;
140 }
141 case ACPI_RSTYPE_EXT_IRQ: 139 case ACPI_RSTYPE_EXT_IRQ:
142 { 140 {
143 struct acpi_resource_ext_irq *p = &resource->data.extended_irq; 141 struct acpi_resource_ext_irq *p =
144 if (!p || !p->number_of_interrupts) { 142 &resource->data.extended_irq;
145 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 143 if (!p || !p->number_of_interrupts) {
146 "Blank EXT IRQ resource\n")); 144 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
147 return_ACPI_STATUS(AE_OK); 145 "Blank EXT IRQ resource\n"));
148 } 146 return_ACPI_STATUS(AE_OK);
149 for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 147 }
150 if (!p->interrupts[i]) { 148 for (i = 0;
151 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i])); 149 (i < p->number_of_interrupts
152 continue; 150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
151 if (!p->interrupts[i]) {
152 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
153 "Invalid IRQ %d\n",
154 p->interrupts[i]));
155 continue;
156 }
157 link->irq.possible[i] = p->interrupts[i];
158 link->irq.possible_count++;
153 } 159 }
154 link->irq.possible[i] = p->interrupts[i]; 160 link->irq.edge_level = p->edge_level;
155 link->irq.possible_count++; 161 link->irq.active_high_low = p->active_high_low;
162 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ;
163 break;
156 } 164 }
157 link->irq.edge_level = p->edge_level;
158 link->irq.active_high_low = p->active_high_low;
159 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ;
160 break;
161 }
162 default: 165 default:
163 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 166 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
164 "Resource is not an IRQ entry\n")); 167 "Resource is not an IRQ entry\n"));
165 return_ACPI_STATUS(AE_OK); 168 return_ACPI_STATUS(AE_OK);
166 } 169 }
167 170
168 return_ACPI_STATUS(AE_CTRL_TERMINATE); 171 return_ACPI_STATUS(AE_CTRL_TERMINATE);
169} 172}
170 173
171 174static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
172static int
173acpi_pci_link_get_possible (
174 struct acpi_pci_link *link)
175{ 175{
176 acpi_status status; 176 acpi_status status;
177 177
178 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible"); 178 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
179 179
@@ -181,62 +181,60 @@ acpi_pci_link_get_possible (
181 return_VALUE(-EINVAL); 181 return_VALUE(-EINVAL);
182 182
183 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, 183 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
184 acpi_pci_link_check_possible, link); 184 acpi_pci_link_check_possible, link);
185 if (ACPI_FAILURE(status)) { 185 if (ACPI_FAILURE(status)) {
186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); 186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n"));
187 return_VALUE(-ENODEV); 187 return_VALUE(-ENODEV);
188 } 188 }
189 189
190 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 190 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
191 "Found %d possible IRQs\n", link->irq.possible_count)); 191 "Found %d possible IRQs\n",
192 link->irq.possible_count));
192 193
193 return_VALUE(0); 194 return_VALUE(0);
194} 195}
195 196
196
197static acpi_status 197static acpi_status
198acpi_pci_link_check_current ( 198acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
199 struct acpi_resource *resource,
200 void *context)
201{ 199{
202 int *irq = (int *) context; 200 int *irq = (int *)context;
203 201
204 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); 202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
205 203
206 switch (resource->id) { 204 switch (resource->id) {
207 case ACPI_RSTYPE_IRQ: 205 case ACPI_RSTYPE_IRQ:
208 { 206 {
209 struct acpi_resource_irq *p = &resource->data.irq; 207 struct acpi_resource_irq *p = &resource->data.irq;
210 if (!p || !p->number_of_interrupts) { 208 if (!p || !p->number_of_interrupts) {
211 /* 209 /*
212 * IRQ descriptors may have no IRQ# bits set, 210 * IRQ descriptors may have no IRQ# bits set,
213 * particularly those those w/ _STA disabled 211 * particularly those those w/ _STA disabled
214 */ 212 */
215 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 213 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
216 "Blank IRQ resource\n")); 214 "Blank IRQ resource\n"));
217 return_ACPI_STATUS(AE_OK); 215 return_ACPI_STATUS(AE_OK);
216 }
217 *irq = p->interrupts[0];
218 break;
218 } 219 }
219 *irq = p->interrupts[0];
220 break;
221 }
222 case ACPI_RSTYPE_EXT_IRQ: 220 case ACPI_RSTYPE_EXT_IRQ:
223 { 221 {
224 struct acpi_resource_ext_irq *p = &resource->data.extended_irq; 222 struct acpi_resource_ext_irq *p =
225 if (!p || !p->number_of_interrupts) { 223 &resource->data.extended_irq;
226 /* 224 if (!p || !p->number_of_interrupts) {
227 * extended IRQ descriptors must 225 /*
228 * return at least 1 IRQ 226 * extended IRQ descriptors must
229 */ 227 * return at least 1 IRQ
230 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 228 */
231 "Blank EXT IRQ resource\n")); 229 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
232 return_ACPI_STATUS(AE_OK); 230 "Blank EXT IRQ resource\n"));
231 return_ACPI_STATUS(AE_OK);
232 }
233 *irq = p->interrupts[0];
234 break;
233 } 235 }
234 *irq = p->interrupts[0];
235 break;
236 }
237 default: 236 default:
238 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource isn't an IRQ\n"));
239 "Resource isn't an IRQ\n"));
240 return_ACPI_STATUS(AE_OK); 238 return_ACPI_STATUS(AE_OK);
241 } 239 }
242 return_ACPI_STATUS(AE_CTRL_TERMINATE); 240 return_ACPI_STATUS(AE_CTRL_TERMINATE);
@@ -249,13 +247,11 @@ acpi_pci_link_check_current (
249 * 0 - success 247 * 0 - success
250 * !0 - failure 248 * !0 - failure
251 */ 249 */
252static int 250static int acpi_pci_link_get_current(struct acpi_pci_link *link)
253acpi_pci_link_get_current (
254 struct acpi_pci_link *link)
255{ 251{
256 int result = 0; 252 int result = 0;
257 acpi_status status = AE_OK; 253 acpi_status status = AE_OK;
258 int irq = 0; 254 int irq = 0;
259 255
260 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current"); 256 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
261 257
@@ -269,7 +265,8 @@ acpi_pci_link_get_current (
269 /* Query _STA, set link->device->status */ 265 /* Query _STA, set link->device->status */
270 result = acpi_bus_get_status(link->device); 266 result = acpi_bus_get_status(link->device);
271 if (result) { 267 if (result) {
272 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); 268 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
269 "Unable to read status\n"));
273 goto end; 270 goto end;
274 } 271 }
275 272
@@ -284,7 +281,7 @@ acpi_pci_link_get_current (
284 */ 281 */
285 282
286 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, 283 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
287 acpi_pci_link_check_current, &irq); 284 acpi_pci_link_check_current, &irq);
288 if (ACPI_FAILURE(status)) { 285 if (ACPI_FAILURE(status)) {
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); 286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n"));
290 result = -ENODEV; 287 result = -ENODEV;
@@ -300,58 +297,61 @@ acpi_pci_link_get_current (
300 297
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); 298 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
302 299
303end: 300 end:
304 return_VALUE(result); 301 return_VALUE(result);
305} 302}
306 303
307static int 304static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
308acpi_pci_link_set (
309 struct acpi_pci_link *link,
310 int irq)
311{ 305{
312 int result = 0; 306 int result = 0;
313 acpi_status status = AE_OK; 307 acpi_status status = AE_OK;
314 struct { 308 struct {
315 struct acpi_resource res; 309 struct acpi_resource res;
316 struct acpi_resource end; 310 struct acpi_resource end;
317 } *resource; 311 } *resource;
318 struct acpi_buffer buffer = {0, NULL}; 312 struct acpi_buffer buffer = { 0, NULL };
319 313
320 ACPI_FUNCTION_TRACE("acpi_pci_link_set"); 314 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
321 315
322 if (!link || !irq) 316 if (!link || !irq)
323 return_VALUE(-EINVAL); 317 return_VALUE(-EINVAL);
324 318
325 resource = kmalloc( sizeof(*resource)+1, GFP_KERNEL); 319 resource = kmalloc(sizeof(*resource) + 1, GFP_KERNEL);
326 if(!resource) 320 if (!resource)
327 return_VALUE(-ENOMEM); 321 return_VALUE(-ENOMEM);
328 322
329 memset(resource, 0, sizeof(*resource)+1); 323 memset(resource, 0, sizeof(*resource) + 1);
330 buffer.length = sizeof(*resource) +1; 324 buffer.length = sizeof(*resource) + 1;
331 buffer.pointer = resource; 325 buffer.pointer = resource;
332 326
333 switch(link->irq.resource_type) { 327 switch (link->irq.resource_type) {
334 case ACPI_RSTYPE_IRQ: 328 case ACPI_RSTYPE_IRQ:
335 resource->res.id = ACPI_RSTYPE_IRQ; 329 resource->res.id = ACPI_RSTYPE_IRQ;
336 resource->res.length = sizeof(struct acpi_resource); 330 resource->res.length = sizeof(struct acpi_resource);
337 resource->res.data.irq.edge_level = link->irq.edge_level; 331 resource->res.data.irq.edge_level = link->irq.edge_level;
338 resource->res.data.irq.active_high_low = link->irq.active_high_low; 332 resource->res.data.irq.active_high_low =
333 link->irq.active_high_low;
339 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 334 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
340 resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE; 335 resource->res.data.irq.shared_exclusive =
336 ACPI_EXCLUSIVE;
341 else 337 else
342 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 338 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
343 resource->res.data.irq.number_of_interrupts = 1; 339 resource->res.data.irq.number_of_interrupts = 1;
344 resource->res.data.irq.interrupts[0] = irq; 340 resource->res.data.irq.interrupts[0] = irq;
345 break; 341 break;
346 342
347 case ACPI_RSTYPE_EXT_IRQ: 343 case ACPI_RSTYPE_EXT_IRQ:
348 resource->res.id = ACPI_RSTYPE_EXT_IRQ; 344 resource->res.id = ACPI_RSTYPE_EXT_IRQ;
349 resource->res.length = sizeof(struct acpi_resource); 345 resource->res.length = sizeof(struct acpi_resource);
350 resource->res.data.extended_irq.producer_consumer = ACPI_CONSUMER; 346 resource->res.data.extended_irq.producer_consumer =
351 resource->res.data.extended_irq.edge_level = link->irq.edge_level; 347 ACPI_CONSUMER;
352 resource->res.data.extended_irq.active_high_low = link->irq.active_high_low; 348 resource->res.data.extended_irq.edge_level =
349 link->irq.edge_level;
350 resource->res.data.extended_irq.active_high_low =
351 link->irq.active_high_low;
353 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 352 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
354 resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE; 353 resource->res.data.irq.shared_exclusive =
354 ACPI_EXCLUSIVE;
355 else 355 else
356 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 356 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
357 resource->res.data.extended_irq.number_of_interrupts = 1; 357 resource->res.data.extended_irq.number_of_interrupts = 1;
@@ -384,9 +384,9 @@ acpi_pci_link_set (
384 } 384 }
385 if (!link->device->status.enabled) { 385 if (!link->device->status.enabled) {
386 printk(KERN_WARNING PREFIX 386 printk(KERN_WARNING PREFIX
387 "%s [%s] disabled and referenced, BIOS bug.\n", 387 "%s [%s] disabled and referenced, BIOS bug.\n",
388 acpi_device_name(link->device), 388 acpi_device_name(link->device),
389 acpi_device_bid(link->device)); 389 acpi_device_bid(link->device));
390 } 390 }
391 391
392 /* Query _CRS, set link->irq.active */ 392 /* Query _CRS, set link->irq.active */
@@ -404,22 +404,20 @@ acpi_pci_link_set (
404 * policy: when _CRS doesn't return what we just _SRS 404 * policy: when _CRS doesn't return what we just _SRS
405 * assume _SRS worked and override _CRS value. 405 * assume _SRS worked and override _CRS value.
406 */ 406 */
407 printk(KERN_WARNING PREFIX 407 printk(KERN_WARNING PREFIX
408 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", 408 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
409 acpi_device_name(link->device), 409 acpi_device_name(link->device),
410 acpi_device_bid(link->device), 410 acpi_device_bid(link->device), link->irq.active, irq);
411 link->irq.active, irq);
412 link->irq.active = irq; 411 link->irq.active = irq;
413 } 412 }
414 413
415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active)); 414 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
416 415
417end: 416 end:
418 kfree(resource); 417 kfree(resource);
419 return_VALUE(result); 418 return_VALUE(result);
420} 419}
421 420
422
423/* -------------------------------------------------------------------------- 421/* --------------------------------------------------------------------------
424 PCI Link IRQ Management 422 PCI Link IRQ Management
425 -------------------------------------------------------------------------- */ 423 -------------------------------------------------------------------------- */
@@ -469,8 +467,8 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
469 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */ 467 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
470 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */ 468 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
471 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */ 469 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
472 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */ 470 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */
473 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */ 471 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */
474 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */ 472 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */
475 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */ 473 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
476 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */ 474 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
@@ -482,15 +480,14 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
482 PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ 480 PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
483 PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ 481 PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
484 PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */ 482 PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
485 /* >IRQ15 */ 483 /* >IRQ15 */
486}; 484};
487 485
488int __init 486int __init acpi_irq_penalty_init(void)
489acpi_irq_penalty_init(void)
490{ 487{
491 struct list_head *node = NULL; 488 struct list_head *node = NULL;
492 struct acpi_pci_link *link = NULL; 489 struct acpi_pci_link *link = NULL;
493 int i = 0; 490 int i = 0;
494 491
495 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init"); 492 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
496 493
@@ -501,7 +498,8 @@ acpi_irq_penalty_init(void)
501 498
502 link = list_entry(node, struct acpi_pci_link, node); 499 link = list_entry(node, struct acpi_pci_link, node);
503 if (!link) { 500 if (!link) {
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 501 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
502 "Invalid link context\n"));
505 continue; 503 continue;
506 } 504 }
507 505
@@ -510,15 +508,20 @@ acpi_irq_penalty_init(void)
510 * useful for breaking ties. 508 * useful for breaking ties.
511 */ 509 */
512 if (link->irq.possible_count) { 510 if (link->irq.possible_count) {
513 int penalty = PIRQ_PENALTY_PCI_POSSIBLE / link->irq.possible_count; 511 int penalty =
512 PIRQ_PENALTY_PCI_POSSIBLE /
513 link->irq.possible_count;
514 514
515 for (i = 0; i < link->irq.possible_count; i++) { 515 for (i = 0; i < link->irq.possible_count; i++) {
516 if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) 516 if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
517 acpi_irq_penalty[link->irq.possible[i]] += penalty; 517 acpi_irq_penalty[link->irq.
518 possible[i]] +=
519 penalty;
518 } 520 }
519 521
520 } else if (link->irq.active) { 522 } else if (link->irq.active) {
521 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_POSSIBLE; 523 acpi_irq_penalty[link->irq.active] +=
524 PIRQ_PENALTY_PCI_POSSIBLE;
522 } 525 }
523 } 526 }
524 /* Add a penalty for the SCI */ 527 /* Add a penalty for the SCI */
@@ -529,11 +532,10 @@ acpi_irq_penalty_init(void)
529 532
530static int acpi_irq_balance; /* 0: static, 1: balance */ 533static int acpi_irq_balance; /* 0: static, 1: balance */
531 534
532static int acpi_pci_link_allocate( 535static int acpi_pci_link_allocate(struct acpi_pci_link *link)
533 struct acpi_pci_link *link)
534{ 536{
535 int irq; 537 int irq;
536 int i; 538 int i;
537 539
538 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); 540 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
539 541
@@ -557,7 +559,7 @@ static int acpi_pci_link_allocate(
557 if (i == link->irq.possible_count) { 559 if (i == link->irq.possible_count) {
558 if (acpi_strict) 560 if (acpi_strict)
559 printk(KERN_WARNING PREFIX "_CRS %d not found" 561 printk(KERN_WARNING PREFIX "_CRS %d not found"
560 " in _PRS\n", link->irq.active); 562 " in _PRS\n", link->irq.active);
561 link->irq.active = 0; 563 link->irq.active = 0;
562 } 564 }
563 565
@@ -576,23 +578,25 @@ static int acpi_pci_link_allocate(
576 * the use of IRQs 9, 10, 11, and >15. 578 * the use of IRQs 9, 10, 11, and >15.
577 */ 579 */
578 for (i = (link->irq.possible_count - 1); i >= 0; i--) { 580 for (i = (link->irq.possible_count - 1); i >= 0; i--) {
579 if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]]) 581 if (acpi_irq_penalty[irq] >
582 acpi_irq_penalty[link->irq.possible[i]])
580 irq = link->irq.possible[i]; 583 irq = link->irq.possible[i];
581 } 584 }
582 } 585 }
583 586
584 /* Attempt to enable the link device at this IRQ. */ 587 /* Attempt to enable the link device at this IRQ. */
585 if (acpi_pci_link_set(link, irq)) { 588 if (acpi_pci_link_set(link, irq)) {
586 printk(PREFIX "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" 589 printk(PREFIX
587 "Try pci=noacpi or acpi=off\n", 590 "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
588 acpi_device_name(link->device), 591 "Try pci=noacpi or acpi=off\n",
589 acpi_device_bid(link->device)); 592 acpi_device_name(link->device),
593 acpi_device_bid(link->device));
590 return_VALUE(-ENODEV); 594 return_VALUE(-ENODEV);
591 } else { 595 } else {
592 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 596 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
593 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 597 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
594 acpi_device_name(link->device), 598 acpi_device_name(link->device),
595 acpi_device_bid(link->device), link->irq.active); 599 acpi_device_bid(link->device), link->irq.active);
596 } 600 }
597 601
598 link->irq.initialized = 1; 602 link->irq.initialized = 1;
@@ -607,16 +611,13 @@ static int acpi_pci_link_allocate(
607 */ 611 */
608 612
609int 613int
610acpi_pci_link_allocate_irq ( 614acpi_pci_link_allocate_irq(acpi_handle handle,
611 acpi_handle handle, 615 int index,
612 int index, 616 int *edge_level, int *active_high_low, char **name)
613 int *edge_level,
614 int *active_high_low,
615 char **name)
616{ 617{
617 int result = 0; 618 int result = 0;
618 struct acpi_device *device = NULL; 619 struct acpi_device *device = NULL;
619 struct acpi_pci_link *link = NULL; 620 struct acpi_pci_link *link = NULL;
620 621
621 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); 622 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
622 623
@@ -626,7 +627,7 @@ acpi_pci_link_allocate_irq (
626 return_VALUE(-1); 627 return_VALUE(-1);
627 } 628 }
628 629
629 link = (struct acpi_pci_link *) acpi_driver_data(device); 630 link = (struct acpi_pci_link *)acpi_driver_data(device);
630 if (!link) { 631 if (!link) {
631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
632 return_VALUE(-1); 633 return_VALUE(-1);
@@ -643,20 +644,24 @@ acpi_pci_link_allocate_irq (
643 up(&acpi_link_lock); 644 up(&acpi_link_lock);
644 return_VALUE(-1); 645 return_VALUE(-1);
645 } 646 }
646 647
647 if (!link->irq.active) { 648 if (!link->irq.active) {
648 up(&acpi_link_lock); 649 up(&acpi_link_lock);
649 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); 650 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
650 return_VALUE(-1); 651 return_VALUE(-1);
651 } 652 }
652 link->refcnt ++; 653 link->refcnt++;
653 up(&acpi_link_lock); 654 up(&acpi_link_lock);
654 655
655 if (edge_level) *edge_level = link->irq.edge_level; 656 if (edge_level)
656 if (active_high_low) *active_high_low = link->irq.active_high_low; 657 *edge_level = link->irq.edge_level;
657 if (name) *name = acpi_device_bid(link->device); 658 if (active_high_low)
659 *active_high_low = link->irq.active_high_low;
660 if (name)
661 *name = acpi_device_bid(link->device);
658 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 662 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
659 "Link %s is referenced\n", acpi_device_bid(link->device))); 663 "Link %s is referenced\n",
664 acpi_device_bid(link->device)));
660 return_VALUE(link->irq.active); 665 return_VALUE(link->irq.active);
661} 666}
662 667
@@ -664,12 +669,11 @@ acpi_pci_link_allocate_irq (
664 * We don't change link's irq information here. After it is reenabled, we 669 * We don't change link's irq information here. After it is reenabled, we
665 * continue use the info 670 * continue use the info
666 */ 671 */
667int 672int acpi_pci_link_free_irq(acpi_handle handle)
668acpi_pci_link_free_irq(acpi_handle handle)
669{ 673{
670 struct acpi_device *device = NULL; 674 struct acpi_device *device = NULL;
671 struct acpi_pci_link *link = NULL; 675 struct acpi_pci_link *link = NULL;
672 acpi_status result; 676 acpi_status result;
673 677
674 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); 678 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
675 679
@@ -679,7 +683,7 @@ acpi_pci_link_free_irq(acpi_handle handle)
679 return_VALUE(-1); 683 return_VALUE(-1);
680 } 684 }
681 685
682 link = (struct acpi_pci_link *) acpi_driver_data(device); 686 link = (struct acpi_pci_link *)acpi_driver_data(device);
683 if (!link) { 687 if (!link) {
684 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 688 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
685 return_VALUE(-1); 689 return_VALUE(-1);
@@ -691,7 +695,6 @@ acpi_pci_link_free_irq(acpi_handle handle)
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); 695 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
692 return_VALUE(-1); 696 return_VALUE(-1);
693 } 697 }
694
695#ifdef FUTURE_USE 698#ifdef FUTURE_USE
696 /* 699 /*
697 * The Link reference count allows us to _DISable an unused link 700 * The Link reference count allows us to _DISable an unused link
@@ -702,10 +705,11 @@ acpi_pci_link_free_irq(acpi_handle handle)
702 * to prevent duplicate acpi_pci_link_set() 705 * to prevent duplicate acpi_pci_link_set()
703 * which would harm some systems 706 * which would harm some systems
704 */ 707 */
705 link->refcnt --; 708 link->refcnt--;
706#endif 709#endif
707 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 710 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
708 "Link %s is dereferenced\n", acpi_device_bid(link->device))); 711 "Link %s is dereferenced\n",
712 acpi_device_bid(link->device)));
709 713
710 if (link->refcnt == 0) { 714 if (link->refcnt == 0) {
711 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 715 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
@@ -713,18 +717,17 @@ acpi_pci_link_free_irq(acpi_handle handle)
713 up(&acpi_link_lock); 717 up(&acpi_link_lock);
714 return_VALUE(link->irq.active); 718 return_VALUE(link->irq.active);
715} 719}
720
716/* -------------------------------------------------------------------------- 721/* --------------------------------------------------------------------------
717 Driver Interface 722 Driver Interface
718 -------------------------------------------------------------------------- */ 723 -------------------------------------------------------------------------- */
719 724
720static int 725static int acpi_pci_link_add(struct acpi_device *device)
721acpi_pci_link_add (
722 struct acpi_device *device)
723{ 726{
724 int result = 0; 727 int result = 0;
725 struct acpi_pci_link *link = NULL; 728 struct acpi_pci_link *link = NULL;
726 int i = 0; 729 int i = 0;
727 int found = 0; 730 int found = 0;
728 731
729 ACPI_FUNCTION_TRACE("acpi_pci_link_add"); 732 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
730 733
@@ -751,13 +754,12 @@ acpi_pci_link_add (
751 acpi_pci_link_get_current(link); 754 acpi_pci_link_get_current(link);
752 755
753 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), 756 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
754 acpi_device_bid(device)); 757 acpi_device_bid(device));
755 for (i = 0; i < link->irq.possible_count; i++) { 758 for (i = 0; i < link->irq.possible_count; i++) {
756 if (link->irq.active == link->irq.possible[i]) { 759 if (link->irq.active == link->irq.possible[i]) {
757 printk(" *%d", link->irq.possible[i]); 760 printk(" *%d", link->irq.possible[i]);
758 found = 1; 761 found = 1;
759 } 762 } else
760 else
761 printk(" %d", link->irq.possible[i]); 763 printk(" %d", link->irq.possible[i]);
762 } 764 }
763 765
@@ -766,7 +768,7 @@ acpi_pci_link_add (
766 if (!found) 768 if (!found)
767 printk(" *%d", link->irq.active); 769 printk(" *%d", link->irq.active);
768 770
769 if(!link->device->status.enabled) 771 if (!link->device->status.enabled)
770 printk(", disabled."); 772 printk(", disabled.");
771 773
772 printk("\n"); 774 printk("\n");
@@ -775,7 +777,7 @@ acpi_pci_link_add (
775 list_add_tail(&link->node, &acpi_link.entries); 777 list_add_tail(&link->node, &acpi_link.entries);
776 acpi_link.count++; 778 acpi_link.count++;
777 779
778end: 780 end:
779 /* disable all links -- to be activated on use */ 781 /* disable all links -- to be activated on use */
780 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 782 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
781 up(&acpi_link_lock); 783 up(&acpi_link_lock);
@@ -786,9 +788,7 @@ end:
786 return_VALUE(result); 788 return_VALUE(result);
787} 789}
788 790
789static int 791static int acpi_pci_link_resume(struct acpi_pci_link *link)
790acpi_pci_link_resume(
791 struct acpi_pci_link *link)
792{ 792{
793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); 793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
794 794
@@ -803,12 +803,10 @@ acpi_pci_link_resume(
803 * after every device calls pci_disable_device in .resume. 803 * after every device calls pci_disable_device in .resume.
804 */ 804 */
805int acpi_in_resume; 805int acpi_in_resume;
806static int 806static int irqrouter_resume(struct sys_device *dev)
807irqrouter_resume(
808 struct sys_device *dev)
809{ 807{
810 struct list_head *node = NULL; 808 struct list_head *node = NULL;
811 struct acpi_pci_link *link = NULL; 809 struct acpi_pci_link *link = NULL;
812 810
813 ACPI_FUNCTION_TRACE("irqrouter_resume"); 811 ACPI_FUNCTION_TRACE("irqrouter_resume");
814 812
@@ -817,7 +815,7 @@ irqrouter_resume(
817 link = list_entry(node, struct acpi_pci_link, node); 815 link = list_entry(node, struct acpi_pci_link, node);
818 if (!link) { 816 if (!link) {
819 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 817 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
820 "Invalid link context\n")); 818 "Invalid link context\n"));
821 continue; 819 continue;
822 } 820 }
823 acpi_pci_link_resume(link); 821 acpi_pci_link_resume(link);
@@ -826,11 +824,7 @@ irqrouter_resume(
826 return_VALUE(0); 824 return_VALUE(0);
827} 825}
828 826
829 827static int acpi_pci_link_remove(struct acpi_device *device, int type)
830static int
831acpi_pci_link_remove (
832 struct acpi_device *device,
833 int type)
834{ 828{
835 struct acpi_pci_link *link = NULL; 829 struct acpi_pci_link *link = NULL;
836 830
@@ -839,7 +833,7 @@ acpi_pci_link_remove (
839 if (!device || !acpi_driver_data(device)) 833 if (!device || !acpi_driver_data(device))
840 return_VALUE(-EINVAL); 834 return_VALUE(-EINVAL);
841 835
842 link = (struct acpi_pci_link *) acpi_driver_data(device); 836 link = (struct acpi_pci_link *)acpi_driver_data(device);
843 837
844 down(&acpi_link_lock); 838 down(&acpi_link_lock);
845 list_del(&link->node); 839 list_del(&link->node);
@@ -861,14 +855,14 @@ static int __init acpi_irq_penalty_update(char *str, int used)
861 int retval; 855 int retval;
862 int irq; 856 int irq;
863 857
864 retval = get_option(&str,&irq); 858 retval = get_option(&str, &irq);
865 859
866 if (!retval) 860 if (!retval)
867 break; /* no number found */ 861 break; /* no number found */
868 862
869 if (irq < 0) 863 if (irq < 0)
870 continue; 864 continue;
871 865
872 if (irq >= ACPI_MAX_IRQS) 866 if (irq >= ACPI_MAX_IRQS)
873 continue; 867 continue;
874 868
@@ -907,6 +901,7 @@ static int __init acpi_irq_isa(char *str)
907{ 901{
908 return acpi_irq_penalty_update(str, 1); 902 return acpi_irq_penalty_update(str, 1);
909} 903}
904
910__setup("acpi_irq_isa=", acpi_irq_isa); 905__setup("acpi_irq_isa=", acpi_irq_isa);
911 906
912/* 907/*
@@ -918,6 +913,7 @@ static int __init acpi_irq_pci(char *str)
918{ 913{
919 return acpi_irq_penalty_update(str, 0); 914 return acpi_irq_penalty_update(str, 0);
920} 915}
916
921__setup("acpi_irq_pci=", acpi_irq_pci); 917__setup("acpi_irq_pci=", acpi_irq_pci);
922 918
923static int __init acpi_irq_nobalance_set(char *str) 919static int __init acpi_irq_nobalance_set(char *str)
@@ -925,6 +921,7 @@ static int __init acpi_irq_nobalance_set(char *str)
925 acpi_irq_balance = 0; 921 acpi_irq_balance = 0;
926 return 1; 922 return 1;
927} 923}
924
928__setup("acpi_irq_nobalance", acpi_irq_nobalance_set); 925__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
929 926
930int __init acpi_irq_balance_set(char *str) 927int __init acpi_irq_balance_set(char *str)
@@ -932,22 +929,20 @@ int __init acpi_irq_balance_set(char *str)
932 acpi_irq_balance = 1; 929 acpi_irq_balance = 1;
933 return 1; 930 return 1;
934} 931}
935__setup("acpi_irq_balance", acpi_irq_balance_set);
936 932
933__setup("acpi_irq_balance", acpi_irq_balance_set);
937 934
938/* FIXME: we will remove this interface after all drivers call pci_disable_device */ 935/* FIXME: we will remove this interface after all drivers call pci_disable_device */
939static struct sysdev_class irqrouter_sysdev_class = { 936static struct sysdev_class irqrouter_sysdev_class = {
940 set_kset_name("irqrouter"), 937 set_kset_name("irqrouter"),
941 .resume = irqrouter_resume, 938 .resume = irqrouter_resume,
942}; 939};
943 940
944
945static struct sys_device device_irqrouter = { 941static struct sys_device device_irqrouter = {
946 .id = 0, 942 .id = 0,
947 .cls = &irqrouter_sysdev_class, 943 .cls = &irqrouter_sysdev_class,
948}; 944};
949 945
950
951static int __init irqrouter_init_sysfs(void) 946static int __init irqrouter_init_sysfs(void)
952{ 947{
953 int error; 948 int error;
@@ -962,12 +957,11 @@ static int __init irqrouter_init_sysfs(void)
962 error = sysdev_register(&device_irqrouter); 957 error = sysdev_register(&device_irqrouter);
963 958
964 return_VALUE(error); 959 return_VALUE(error);
965} 960}
966 961
967device_initcall(irqrouter_init_sysfs); 962device_initcall(irqrouter_init_sysfs);
968 963
969 964static int __init acpi_pci_link_init(void)
970static int __init acpi_pci_link_init (void)
971{ 965{
972 ACPI_FUNCTION_TRACE("acpi_pci_link_init"); 966 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
973 967
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 5d2f77fcd50c..0fd9988c283d 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -35,35 +35,32 @@
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 36#include <acpi/acpi_drivers.h>
37 37
38
39#define _COMPONENT ACPI_PCI_COMPONENT 38#define _COMPONENT ACPI_PCI_COMPONENT
40ACPI_MODULE_NAME ("pci_root") 39ACPI_MODULE_NAME("pci_root")
41
42#define ACPI_PCI_ROOT_CLASS "pci_bridge" 40#define ACPI_PCI_ROOT_CLASS "pci_bridge"
43#define ACPI_PCI_ROOT_HID "PNP0A03" 41#define ACPI_PCI_ROOT_HID "PNP0A03"
44#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" 42#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver"
45#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 43#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
46 44static int acpi_pci_root_add(struct acpi_device *device);
47static int acpi_pci_root_add (struct acpi_device *device); 45static int acpi_pci_root_remove(struct acpi_device *device, int type);
48static int acpi_pci_root_remove (struct acpi_device *device, int type); 46static int acpi_pci_root_start(struct acpi_device *device);
49static int acpi_pci_root_start (struct acpi_device *device);
50 47
51static struct acpi_driver acpi_pci_root_driver = { 48static struct acpi_driver acpi_pci_root_driver = {
52 .name = ACPI_PCI_ROOT_DRIVER_NAME, 49 .name = ACPI_PCI_ROOT_DRIVER_NAME,
53 .class = ACPI_PCI_ROOT_CLASS, 50 .class = ACPI_PCI_ROOT_CLASS,
54 .ids = ACPI_PCI_ROOT_HID, 51 .ids = ACPI_PCI_ROOT_HID,
55 .ops = { 52 .ops = {
56 .add = acpi_pci_root_add, 53 .add = acpi_pci_root_add,
57 .remove = acpi_pci_root_remove, 54 .remove = acpi_pci_root_remove,
58 .start = acpi_pci_root_start, 55 .start = acpi_pci_root_start,
59 }, 56 },
60}; 57};
61 58
62struct acpi_pci_root { 59struct acpi_pci_root {
63 struct list_head node; 60 struct list_head node;
64 acpi_handle handle; 61 acpi_handle handle;
65 struct acpi_pci_id id; 62 struct acpi_pci_id id;
66 struct pci_bus *bus; 63 struct pci_bus *bus;
67}; 64};
68 65
69static LIST_HEAD(acpi_pci_roots); 66static LIST_HEAD(acpi_pci_roots);
@@ -92,6 +89,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver)
92 89
93 return n; 90 return n;
94} 91}
92
95EXPORT_SYMBOL(acpi_pci_register_driver); 93EXPORT_SYMBOL(acpi_pci_register_driver);
96 94
97void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) 95void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
@@ -115,10 +113,11 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
115 driver->remove(root->handle); 113 driver->remove(root->handle);
116 } 114 }
117} 115}
116
118EXPORT_SYMBOL(acpi_pci_unregister_driver); 117EXPORT_SYMBOL(acpi_pci_unregister_driver);
119 118
120static acpi_status 119static acpi_status
121get_root_bridge_busnr_callback (struct acpi_resource *resource, void *data) 120get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
122{ 121{
123 int *busnr = (int *)data; 122 int *busnr = (int *)data;
124 struct acpi_resource_address64 address; 123 struct acpi_resource_address64 address;
@@ -129,20 +128,21 @@ get_root_bridge_busnr_callback (struct acpi_resource *resource, void *data)
129 return AE_OK; 128 return AE_OK;
130 129
131 acpi_resource_to_address64(resource, &address); 130 acpi_resource_to_address64(resource, &address);
132 if ((address.address_length > 0) && 131 if ((address.address_length > 0) &&
133 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 132 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
134 *busnr = address.min_address_range; 133 *busnr = address.min_address_range;
135 134
136 return AE_OK; 135 return AE_OK;
137} 136}
138 137
139static acpi_status 138static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum)
140try_get_root_bridge_busnr(acpi_handle handle, int *busnum)
141{ 139{
142 acpi_status status; 140 acpi_status status;
143 141
144 *busnum = -1; 142 *busnum = -1;
145 status = acpi_walk_resources(handle, METHOD_NAME__CRS, get_root_bridge_busnr_callback, busnum); 143 status =
144 acpi_walk_resources(handle, METHOD_NAME__CRS,
145 get_root_bridge_busnr_callback, busnum);
146 if (ACPI_FAILURE(status)) 146 if (ACPI_FAILURE(status))
147 return status; 147 return status;
148 /* Check if we really get a bus number from _CRS */ 148 /* Check if we really get a bus number from _CRS */
@@ -151,16 +151,14 @@ try_get_root_bridge_busnr(acpi_handle handle, int *busnum)
151 return AE_OK; 151 return AE_OK;
152} 152}
153 153
154static int 154static int acpi_pci_root_add(struct acpi_device *device)
155acpi_pci_root_add (
156 struct acpi_device *device)
157{ 155{
158 int result = 0; 156 int result = 0;
159 struct acpi_pci_root *root = NULL; 157 struct acpi_pci_root *root = NULL;
160 struct acpi_pci_root *tmp; 158 struct acpi_pci_root *tmp;
161 acpi_status status = AE_OK; 159 acpi_status status = AE_OK;
162 unsigned long value = 0; 160 unsigned long value = 0;
163 acpi_handle handle = NULL; 161 acpi_handle handle = NULL;
164 162
165 ACPI_FUNCTION_TRACE("acpi_pci_root_add"); 163 ACPI_FUNCTION_TRACE("acpi_pci_root_add");
166 164
@@ -188,15 +186,15 @@ acpi_pci_root_add (
188 * ------- 186 * -------
189 * Obtained via _SEG, if exists, otherwise assumed to be zero (0). 187 * Obtained via _SEG, if exists, otherwise assumed to be zero (0).
190 */ 188 */
191 status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL, 189 status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL,
192 &value); 190 &value);
193 switch (status) { 191 switch (status) {
194 case AE_OK: 192 case AE_OK:
195 root->id.segment = (u16) value; 193 root->id.segment = (u16) value;
196 break; 194 break;
197 case AE_NOT_FOUND: 195 case AE_NOT_FOUND:
198 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
199 "Assuming segment 0 (no _SEG)\n")); 197 "Assuming segment 0 (no _SEG)\n"));
200 root->id.segment = 0; 198 root->id.segment = 0;
201 break; 199 break;
202 default: 200 default:
@@ -210,8 +208,8 @@ acpi_pci_root_add (
210 * --- 208 * ---
211 * Obtained via _BBN, if exists, otherwise assumed to be zero (0). 209 * Obtained via _BBN, if exists, otherwise assumed to be zero (0).
212 */ 210 */
213 status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL, 211 status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL,
214 &value); 212 &value);
215 switch (status) { 213 switch (status) {
216 case AE_OK: 214 case AE_OK:
217 root->id.bus = (u16) value; 215 root->id.bus = (u16) value;
@@ -229,18 +227,19 @@ acpi_pci_root_add (
229 /* Some systems have wrong _BBN */ 227 /* Some systems have wrong _BBN */
230 list_for_each_entry(tmp, &acpi_pci_roots, node) { 228 list_for_each_entry(tmp, &acpi_pci_roots, node) {
231 if ((tmp->id.segment == root->id.segment) 229 if ((tmp->id.segment == root->id.segment)
232 && (tmp->id.bus == root->id.bus)) { 230 && (tmp->id.bus == root->id.bus)) {
233 int bus = 0; 231 int bus = 0;
234 acpi_status status; 232 acpi_status status;
235 233
236 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 234 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
237 "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); 235 "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n"));
238 236
239 status = try_get_root_bridge_busnr(root->handle, &bus); 237 status = try_get_root_bridge_busnr(root->handle, &bus);
240 if (ACPI_FAILURE(status)) 238 if (ACPI_FAILURE(status))
241 break; 239 break;
242 if (bus != root->id.bus) { 240 if (bus != root->id.bus) {
243 printk(KERN_INFO PREFIX "PCI _CRS %d overrides _BBN 0\n", bus); 241 printk(KERN_INFO PREFIX
242 "PCI _CRS %d overrides _BBN 0\n", bus);
244 root->id.bus = bus; 243 root->id.bus = bus;
245 } 244 }
246 break; 245 break;
@@ -258,12 +257,12 @@ acpi_pci_root_add (
258 * TBD: Need PCI interface for enumeration/configuration of roots. 257 * TBD: Need PCI interface for enumeration/configuration of roots.
259 */ 258 */
260 259
261 /* TBD: Locking */ 260 /* TBD: Locking */
262 list_add_tail(&root->node, &acpi_pci_roots); 261 list_add_tail(&root->node, &acpi_pci_roots);
263 262
264 printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n", 263 printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n",
265 acpi_device_name(device), acpi_device_bid(device), 264 acpi_device_name(device), acpi_device_bid(device),
266 root->id.segment, root->id.bus); 265 root->id.segment, root->id.bus);
267 266
268 /* 267 /*
269 * Scan the Root Bridge 268 * Scan the Root Bridge
@@ -274,9 +273,9 @@ acpi_pci_root_add (
274 */ 273 */
275 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); 274 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus);
276 if (!root->bus) { 275 if (!root->bus) {
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
278 "Bus %04x:%02x not present in PCI namespace\n", 277 "Bus %04x:%02x not present in PCI namespace\n",
279 root->id.segment, root->id.bus)); 278 root->id.segment, root->id.bus));
280 result = -ENODEV; 279 result = -ENODEV;
281 goto end; 280 goto end;
282 } 281 }
@@ -298,9 +297,9 @@ acpi_pci_root_add (
298 status = acpi_get_handle(root->handle, METHOD_NAME__PRT, &handle); 297 status = acpi_get_handle(root->handle, METHOD_NAME__PRT, &handle);
299 if (ACPI_SUCCESS(status)) 298 if (ACPI_SUCCESS(status))
300 result = acpi_pci_irq_add_prt(root->handle, root->id.segment, 299 result = acpi_pci_irq_add_prt(root->handle, root->id.segment,
301 root->id.bus); 300 root->id.bus);
302 301
303end: 302 end:
304 if (result) { 303 if (result) {
305 if (!list_empty(&root->node)) 304 if (!list_empty(&root->node))
306 list_del(&root->node); 305 list_del(&root->node);
@@ -310,11 +309,9 @@ end:
310 return_VALUE(result); 309 return_VALUE(result);
311} 310}
312 311
313static int 312static int acpi_pci_root_start(struct acpi_device *device)
314acpi_pci_root_start (
315 struct acpi_device *device)
316{ 313{
317 struct acpi_pci_root *root; 314 struct acpi_pci_root *root;
318 315
319 ACPI_FUNCTION_TRACE("acpi_pci_root_start"); 316 ACPI_FUNCTION_TRACE("acpi_pci_root_start");
320 317
@@ -327,27 +324,23 @@ acpi_pci_root_start (
327 return_VALUE(-ENODEV); 324 return_VALUE(-ENODEV);
328} 325}
329 326
330static int 327static int acpi_pci_root_remove(struct acpi_device *device, int type)
331acpi_pci_root_remove (
332 struct acpi_device *device,
333 int type)
334{ 328{
335 struct acpi_pci_root *root = NULL; 329 struct acpi_pci_root *root = NULL;
336 330
337 ACPI_FUNCTION_TRACE("acpi_pci_root_remove"); 331 ACPI_FUNCTION_TRACE("acpi_pci_root_remove");
338 332
339 if (!device || !acpi_driver_data(device)) 333 if (!device || !acpi_driver_data(device))
340 return_VALUE(-EINVAL); 334 return_VALUE(-EINVAL);
341 335
342 root = (struct acpi_pci_root *) acpi_driver_data(device); 336 root = (struct acpi_pci_root *)acpi_driver_data(device);
343 337
344 kfree(root); 338 kfree(root);
345 339
346 return_VALUE(0); 340 return_VALUE(0);
347} 341}
348 342
349 343static int __init acpi_pci_root_init(void)
350static int __init acpi_pci_root_init (void)
351{ 344{
352 ACPI_FUNCTION_TRACE("acpi_pci_root_init"); 345 ACPI_FUNCTION_TRACE("acpi_pci_root_init");
353 346
@@ -355,8 +348,8 @@ static int __init acpi_pci_root_init (void)
355 return_VALUE(0); 348 return_VALUE(0);
356 349
357 /* DEBUG: 350 /* DEBUG:
358 acpi_dbg_layer = ACPI_PCI_COMPONENT; 351 acpi_dbg_layer = ACPI_PCI_COMPONENT;
359 acpi_dbg_level = 0xFFFFFFFF; 352 acpi_dbg_level = 0xFFFFFFFF;
360 */ 353 */
361 354
362 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) 355 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
@@ -366,4 +359,3 @@ static int __init acpi_pci_root_init (void)
366} 359}
367 360
368subsys_initcall(acpi_pci_root_init); 361subsys_initcall(acpi_pci_root_init);
369
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 373a3a95bb4e..62a5595ed8bc 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -44,10 +44,8 @@
44#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
46 46
47
48#define _COMPONENT ACPI_POWER_COMPONENT 47#define _COMPONENT ACPI_POWER_COMPONENT
49ACPI_MODULE_NAME ("acpi_power") 48ACPI_MODULE_NAME("acpi_power")
50
51#define ACPI_POWER_COMPONENT 0x00800000 49#define ACPI_POWER_COMPONENT 0x00800000
52#define ACPI_POWER_CLASS "power_resource" 50#define ACPI_POWER_CLASS "power_resource"
53#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" 51#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver"
@@ -57,38 +55,36 @@ ACPI_MODULE_NAME ("acpi_power")
57#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 55#define ACPI_POWER_RESOURCE_STATE_OFF 0x00
58#define ACPI_POWER_RESOURCE_STATE_ON 0x01 56#define ACPI_POWER_RESOURCE_STATE_ON 0x01
59#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF 57#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
60 58static int acpi_power_add(struct acpi_device *device);
61static int acpi_power_add (struct acpi_device *device); 59static int acpi_power_remove(struct acpi_device *device, int type);
62static int acpi_power_remove (struct acpi_device *device, int type);
63static int acpi_power_open_fs(struct inode *inode, struct file *file); 60static int acpi_power_open_fs(struct inode *inode, struct file *file);
64 61
65static struct acpi_driver acpi_power_driver = { 62static struct acpi_driver acpi_power_driver = {
66 .name = ACPI_POWER_DRIVER_NAME, 63 .name = ACPI_POWER_DRIVER_NAME,
67 .class = ACPI_POWER_CLASS, 64 .class = ACPI_POWER_CLASS,
68 .ids = ACPI_POWER_HID, 65 .ids = ACPI_POWER_HID,
69 .ops = { 66 .ops = {
70 .add = acpi_power_add, 67 .add = acpi_power_add,
71 .remove = acpi_power_remove, 68 .remove = acpi_power_remove,
72 }, 69 },
73}; 70};
74 71
75struct acpi_power_resource 72struct acpi_power_resource {
76{ 73 acpi_handle handle;
77 acpi_handle handle; 74 acpi_bus_id name;
78 acpi_bus_id name; 75 u32 system_level;
79 u32 system_level; 76 u32 order;
80 u32 order; 77 int state;
81 int state; 78 int references;
82 int references;
83}; 79};
84 80
85static struct list_head acpi_power_resource_list; 81static struct list_head acpi_power_resource_list;
86 82
87static struct file_operations acpi_power_fops = { 83static struct file_operations acpi_power_fops = {
88 .open = acpi_power_open_fs, 84 .open = acpi_power_open_fs,
89 .read = seq_read, 85 .read = seq_read,
90 .llseek = seq_lseek, 86 .llseek = seq_lseek,
91 .release = single_release, 87 .release = single_release,
92}; 88};
93 89
94/* -------------------------------------------------------------------------- 90/* --------------------------------------------------------------------------
@@ -96,12 +92,11 @@ static struct file_operations acpi_power_fops = {
96 -------------------------------------------------------------------------- */ 92 -------------------------------------------------------------------------- */
97 93
98static int 94static int
99acpi_power_get_context ( 95acpi_power_get_context(acpi_handle handle,
100 acpi_handle handle, 96 struct acpi_power_resource **resource)
101 struct acpi_power_resource **resource)
102{ 97{
103 int result = 0; 98 int result = 0;
104 struct acpi_device *device = NULL; 99 struct acpi_device *device = NULL;
105 100
106 ACPI_FUNCTION_TRACE("acpi_power_get_context"); 101 ACPI_FUNCTION_TRACE("acpi_power_get_context");
107 102
@@ -111,24 +106,21 @@ acpi_power_get_context (
111 result = acpi_bus_get_device(handle, &device); 106 result = acpi_bus_get_device(handle, &device);
112 if (result) { 107 if (result) {
113 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", 108 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n",
114 handle)); 109 handle));
115 return_VALUE(result); 110 return_VALUE(result);
116 } 111 }
117 112
118 *resource = (struct acpi_power_resource *) acpi_driver_data(device); 113 *resource = (struct acpi_power_resource *)acpi_driver_data(device);
119 if (!resource) 114 if (!resource)
120 return_VALUE(-ENODEV); 115 return_VALUE(-ENODEV);
121 116
122 return_VALUE(0); 117 return_VALUE(0);
123} 118}
124 119
125 120static int acpi_power_get_state(struct acpi_power_resource *resource)
126static int
127acpi_power_get_state (
128 struct acpi_power_resource *resource)
129{ 121{
130 acpi_status status = AE_OK; 122 acpi_status status = AE_OK;
131 unsigned long sta = 0; 123 unsigned long sta = 0;
132 124
133 ACPI_FUNCTION_TRACE("acpi_power_get_state"); 125 ACPI_FUNCTION_TRACE("acpi_power_get_state");
134 126
@@ -145,20 +137,16 @@ acpi_power_get_state (
145 resource->state = ACPI_POWER_RESOURCE_STATE_OFF; 137 resource->state = ACPI_POWER_RESOURCE_STATE_OFF;
146 138
147 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
148 resource->name, resource->state?"on":"off")); 140 resource->name, resource->state ? "on" : "off"));
149 141
150 return_VALUE(0); 142 return_VALUE(0);
151} 143}
152 144
153 145static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
154static int
155acpi_power_get_list_state (
156 struct acpi_handle_list *list,
157 int *state)
158{ 146{
159 int result = 0; 147 int result = 0;
160 struct acpi_power_resource *resource = NULL; 148 struct acpi_power_resource *resource = NULL;
161 u32 i = 0; 149 u32 i = 0;
162 150
163 ACPI_FUNCTION_TRACE("acpi_power_get_list_state"); 151 ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
164 152
@@ -167,7 +155,7 @@ acpi_power_get_list_state (
167 155
168 /* The state of the list is 'on' IFF all resources are 'on'. */ 156 /* The state of the list is 'on' IFF all resources are 'on'. */
169 157
170 for (i=0; i<list->count; i++) { 158 for (i = 0; i < list->count; i++) {
171 result = acpi_power_get_context(list->handles[i], &resource); 159 result = acpi_power_get_context(list->handles[i], &resource);
172 if (result) 160 if (result)
173 return_VALUE(result); 161 return_VALUE(result);
@@ -182,19 +170,16 @@ acpi_power_get_list_state (
182 } 170 }
183 171
184 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", 172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
185 *state?"on":"off")); 173 *state ? "on" : "off"));
186 174
187 return_VALUE(result); 175 return_VALUE(result);
188} 176}
189 177
190 178static int acpi_power_on(acpi_handle handle)
191static int
192acpi_power_on (
193 acpi_handle handle)
194{ 179{
195 int result = 0; 180 int result = 0;
196 acpi_status status = AE_OK; 181 acpi_status status = AE_OK;
197 struct acpi_device *device = NULL; 182 struct acpi_device *device = NULL;
198 struct acpi_power_resource *resource = NULL; 183 struct acpi_power_resource *resource = NULL;
199 184
200 ACPI_FUNCTION_TRACE("acpi_power_on"); 185 ACPI_FUNCTION_TRACE("acpi_power_on");
@@ -205,10 +190,10 @@ acpi_power_on (
205 190
206 resource->references++; 191 resource->references++;
207 192
208 if ((resource->references > 1) 193 if ((resource->references > 1)
209 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { 194 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", 195 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
211 resource->name)); 196 resource->name));
212 return_VALUE(0); 197 return_VALUE(0);
213 } 198 }
214 199
@@ -229,19 +214,16 @@ acpi_power_on (
229 device->power.state = ACPI_STATE_D0; 214 device->power.state = ACPI_STATE_D0;
230 215
231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", 216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
232 resource->name)); 217 resource->name));
233 218
234 return_VALUE(0); 219 return_VALUE(0);
235} 220}
236 221
237 222static int acpi_power_off_device(acpi_handle handle)
238static int
239acpi_power_off_device (
240 acpi_handle handle)
241{ 223{
242 int result = 0; 224 int result = 0;
243 acpi_status status = AE_OK; 225 acpi_status status = AE_OK;
244 struct acpi_device *device = NULL; 226 struct acpi_device *device = NULL;
245 struct acpi_power_resource *resource = NULL; 227 struct acpi_power_resource *resource = NULL;
246 228
247 ACPI_FUNCTION_TRACE("acpi_power_off_device"); 229 ACPI_FUNCTION_TRACE("acpi_power_off_device");
@@ -254,15 +236,15 @@ acpi_power_off_device (
254 resource->references--; 236 resource->references--;
255 237
256 if (resource->references) { 238 if (resource->references) {
257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 239 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
258 "Resource [%s] is still in use, dereferencing\n", 240 "Resource [%s] is still in use, dereferencing\n",
259 device->pnp.bus_id)); 241 device->pnp.bus_id));
260 return_VALUE(0); 242 return_VALUE(0);
261 } 243 }
262 244
263 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 245 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
264 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 246 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
265 device->pnp.bus_id)); 247 device->pnp.bus_id));
266 return_VALUE(0); 248 return_VALUE(0);
267 } 249 }
268 250
@@ -283,7 +265,7 @@ acpi_power_off_device (
283 device->power.state = ACPI_STATE_D3; 265 device->power.state = ACPI_STATE_D3;
284 266
285 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 267 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
286 resource->name)); 268 resource->name));
287 269
288 return_VALUE(0); 270 return_VALUE(0);
289} 271}
@@ -293,13 +275,13 @@ acpi_power_off_device (
293 * 1. Power on the power resources required for the wakeup device 275 * 1. Power on the power resources required for the wakeup device
294 * 2. Enable _PSW (power state wake) for the device if present 276 * 2. Enable _PSW (power state wake) for the device if present
295 */ 277 */
296int acpi_enable_wakeup_device_power (struct acpi_device *dev) 278int acpi_enable_wakeup_device_power(struct acpi_device *dev)
297{ 279{
298 union acpi_object arg = {ACPI_TYPE_INTEGER}; 280 union acpi_object arg = { ACPI_TYPE_INTEGER };
299 struct acpi_object_list arg_list = {1, &arg}; 281 struct acpi_object_list arg_list = { 1, &arg };
300 acpi_status status = AE_OK; 282 acpi_status status = AE_OK;
301 int i; 283 int i;
302 int ret = 0; 284 int ret = 0;
303 285
304 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power"); 286 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
305 if (!dev || !dev->wakeup.flags.valid) 287 if (!dev || !dev->wakeup.flags.valid)
@@ -310,8 +292,8 @@ int acpi_enable_wakeup_device_power (struct acpi_device *dev)
310 for (i = 0; i < dev->wakeup.resources.count; i++) { 292 for (i = 0; i < dev->wakeup.resources.count; i++) {
311 ret = acpi_power_on(dev->wakeup.resources.handles[i]); 293 ret = acpi_power_on(dev->wakeup.resources.handles[i]);
312 if (ret) { 294 if (ret) {
313 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
314 "Error transition power state\n")); 296 "Error transition power state\n"));
315 dev->wakeup.flags.valid = 0; 297 dev->wakeup.flags.valid = 0;
316 return_VALUE(-1); 298 return_VALUE(-1);
317 } 299 }
@@ -333,20 +315,20 @@ int acpi_enable_wakeup_device_power (struct acpi_device *dev)
333 * 1. Disable _PSW (power state wake) 315 * 1. Disable _PSW (power state wake)
334 * 2. Shutdown down the power resources 316 * 2. Shutdown down the power resources
335 */ 317 */
336int acpi_disable_wakeup_device_power (struct acpi_device *dev) 318int acpi_disable_wakeup_device_power(struct acpi_device *dev)
337{ 319{
338 union acpi_object arg = {ACPI_TYPE_INTEGER}; 320 union acpi_object arg = { ACPI_TYPE_INTEGER };
339 struct acpi_object_list arg_list = {1, &arg}; 321 struct acpi_object_list arg_list = { 1, &arg };
340 acpi_status status = AE_OK; 322 acpi_status status = AE_OK;
341 int i; 323 int i;
342 int ret = 0; 324 int ret = 0;
343 325
344 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power"); 326 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
345 327
346 if (!dev || !dev->wakeup.flags.valid) 328 if (!dev || !dev->wakeup.flags.valid)
347 return_VALUE(-1); 329 return_VALUE(-1);
348 330
349 arg.integer.value = 0; 331 arg.integer.value = 0;
350 /* Execute PSW */ 332 /* Execute PSW */
351 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 333 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
352 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 334 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
@@ -359,8 +341,8 @@ int acpi_disable_wakeup_device_power (struct acpi_device *dev)
359 for (i = 0; i < dev->wakeup.resources.count; i++) { 341 for (i = 0; i < dev->wakeup.resources.count; i++) {
360 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); 342 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]);
361 if (ret) { 343 if (ret) {
362 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 344 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
363 "Error transition power state\n")); 345 "Error transition power state\n"));
364 dev->wakeup.flags.valid = 0; 346 dev->wakeup.flags.valid = 0;
365 return_VALUE(-1); 347 return_VALUE(-1);
366 } 348 }
@@ -373,14 +355,12 @@ int acpi_disable_wakeup_device_power (struct acpi_device *dev)
373 Device Power Management 355 Device Power Management
374 -------------------------------------------------------------------------- */ 356 -------------------------------------------------------------------------- */
375 357
376int 358int acpi_power_get_inferred_state(struct acpi_device *device)
377acpi_power_get_inferred_state (
378 struct acpi_device *device)
379{ 359{
380 int result = 0; 360 int result = 0;
381 struct acpi_handle_list *list = NULL; 361 struct acpi_handle_list *list = NULL;
382 int list_state = 0; 362 int list_state = 0;
383 int i = 0; 363 int i = 0;
384 364
385 ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state"); 365 ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
386 366
@@ -393,7 +373,7 @@ acpi_power_get_inferred_state (
393 * We know a device's inferred power state when all the resources 373 * We know a device's inferred power state when all the resources
394 * required for a given D-state are 'on'. 374 * required for a given D-state are 'on'.
395 */ 375 */
396 for (i=ACPI_STATE_D0; i<ACPI_STATE_D3; i++) { 376 for (i = ACPI_STATE_D0; i < ACPI_STATE_D3; i++) {
397 list = &device->power.states[i].resources; 377 list = &device->power.states[i].resources;
398 if (list->count < 1) 378 if (list->count < 1)
399 continue; 379 continue;
@@ -413,23 +393,20 @@ acpi_power_get_inferred_state (
413 return_VALUE(0); 393 return_VALUE(0);
414} 394}
415 395
416 396int acpi_power_transition(struct acpi_device *device, int state)
417int
418acpi_power_transition (
419 struct acpi_device *device,
420 int state)
421{ 397{
422 int result = 0; 398 int result = 0;
423 struct acpi_handle_list *cl = NULL; /* Current Resources */ 399 struct acpi_handle_list *cl = NULL; /* Current Resources */
424 struct acpi_handle_list *tl = NULL; /* Target Resources */ 400 struct acpi_handle_list *tl = NULL; /* Target Resources */
425 int i = 0; 401 int i = 0;
426 402
427 ACPI_FUNCTION_TRACE("acpi_power_transition"); 403 ACPI_FUNCTION_TRACE("acpi_power_transition");
428 404
429 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 405 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
430 return_VALUE(-EINVAL); 406 return_VALUE(-EINVAL);
431 407
432 if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) 408 if ((device->power.state < ACPI_STATE_D0)
409 || (device->power.state > ACPI_STATE_D3))
433 return_VALUE(-ENODEV); 410 return_VALUE(-ENODEV);
434 411
435 cl = &device->power.states[device->power.state].resources; 412 cl = &device->power.states[device->power.state].resources;
@@ -448,7 +425,7 @@ acpi_power_transition (
448 * First we reference all power resources required in the target list 425 * First we reference all power resources required in the target list
449 * (e.g. so the device doesn't lose power while transitioning). 426 * (e.g. so the device doesn't lose power while transitioning).
450 */ 427 */
451 for (i=0; i<tl->count; i++) { 428 for (i = 0; i < tl->count; i++) {
452 result = acpi_power_on(tl->handles[i]); 429 result = acpi_power_on(tl->handles[i]);
453 if (result) 430 if (result)
454 goto end; 431 goto end;
@@ -457,7 +434,7 @@ acpi_power_transition (
457 /* 434 /*
458 * Then we dereference all power resources used in the current list. 435 * Then we dereference all power resources used in the current list.
459 */ 436 */
460 for (i=0; i<cl->count; i++) { 437 for (i = 0; i < cl->count; i++) {
461 result = acpi_power_off_device(cl->handles[i]); 438 result = acpi_power_off_device(cl->handles[i]);
462 if (result) 439 if (result)
463 goto end; 440 goto end;
@@ -465,21 +442,20 @@ acpi_power_transition (
465 442
466 /* We shouldn't change the state till all above operations succeed */ 443 /* We shouldn't change the state till all above operations succeed */
467 device->power.state = state; 444 device->power.state = state;
468end: 445 end:
469 if (result) 446 if (result)
470 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 447 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
471 "Error transitioning device [%s] to D%d\n", 448 "Error transitioning device [%s] to D%d\n",
472 device->pnp.bus_id, state)); 449 device->pnp.bus_id, state));
473 450
474 return_VALUE(result); 451 return_VALUE(result);
475} 452}
476 453
477
478/* -------------------------------------------------------------------------- 454/* --------------------------------------------------------------------------
479 FS Interface (/proc) 455 FS Interface (/proc)
480 -------------------------------------------------------------------------- */ 456 -------------------------------------------------------------------------- */
481 457
482static struct proc_dir_entry *acpi_power_dir; 458static struct proc_dir_entry *acpi_power_dir;
483 459
484static int acpi_power_seq_show(struct seq_file *seq, void *offset) 460static int acpi_power_seq_show(struct seq_file *seq, void *offset)
485{ 461{
@@ -506,13 +482,12 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
506 } 482 }
507 483
508 seq_printf(seq, "system level: S%d\n" 484 seq_printf(seq, "system level: S%d\n"
509 "order: %d\n" 485 "order: %d\n"
510 "reference count: %d\n", 486 "reference count: %d\n",
511 resource->system_level, 487 resource->system_level,
512 resource->order, 488 resource->order, resource->references);
513 resource->references);
514 489
515end: 490 end:
516 return_VALUE(0); 491 return_VALUE(0);
517} 492}
518 493
@@ -521,11 +496,9 @@ static int acpi_power_open_fs(struct inode *inode, struct file *file)
521 return single_open(file, acpi_power_seq_show, PDE(inode)->data); 496 return single_open(file, acpi_power_seq_show, PDE(inode)->data);
522} 497}
523 498
524static int 499static int acpi_power_add_fs(struct acpi_device *device)
525acpi_power_add_fs (
526 struct acpi_device *device)
527{ 500{
528 struct proc_dir_entry *entry = NULL; 501 struct proc_dir_entry *entry = NULL;
529 502
530 ACPI_FUNCTION_TRACE("acpi_power_add_fs"); 503 ACPI_FUNCTION_TRACE("acpi_power_add_fs");
531 504
@@ -534,18 +507,18 @@ acpi_power_add_fs (
534 507
535 if (!acpi_device_dir(device)) { 508 if (!acpi_device_dir(device)) {
536 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 509 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
537 acpi_power_dir); 510 acpi_power_dir);
538 if (!acpi_device_dir(device)) 511 if (!acpi_device_dir(device))
539 return_VALUE(-ENODEV); 512 return_VALUE(-ENODEV);
540 } 513 }
541 514
542 /* 'status' [R] */ 515 /* 'status' [R] */
543 entry = create_proc_entry(ACPI_POWER_FILE_STATUS, 516 entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
544 S_IRUGO, acpi_device_dir(device)); 517 S_IRUGO, acpi_device_dir(device));
545 if (!entry) 518 if (!entry)
546 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
547 "Unable to create '%s' fs entry\n", 520 "Unable to create '%s' fs entry\n",
548 ACPI_POWER_FILE_STATUS)); 521 ACPI_POWER_FILE_STATUS));
549 else { 522 else {
550 entry->proc_fops = &acpi_power_fops; 523 entry->proc_fops = &acpi_power_fops;
551 entry->data = acpi_driver_data(device); 524 entry->data = acpi_driver_data(device);
@@ -554,10 +527,7 @@ acpi_power_add_fs (
554 return_VALUE(0); 527 return_VALUE(0);
555} 528}
556 529
557 530static int acpi_power_remove_fs(struct acpi_device *device)
558static int
559acpi_power_remove_fs (
560 struct acpi_device *device)
561{ 531{
562 ACPI_FUNCTION_TRACE("acpi_power_remove_fs"); 532 ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
563 533
@@ -571,20 +541,17 @@ acpi_power_remove_fs (
571 return_VALUE(0); 541 return_VALUE(0);
572} 542}
573 543
574
575/* -------------------------------------------------------------------------- 544/* --------------------------------------------------------------------------
576 Driver Interface 545 Driver Interface
577 -------------------------------------------------------------------------- */ 546 -------------------------------------------------------------------------- */
578 547
579static int 548static int acpi_power_add(struct acpi_device *device)
580acpi_power_add (
581 struct acpi_device *device)
582{ 549{
583 int result = 0; 550 int result = 0;
584 acpi_status status = AE_OK; 551 acpi_status status = AE_OK;
585 struct acpi_power_resource *resource = NULL; 552 struct acpi_power_resource *resource = NULL;
586 union acpi_object acpi_object; 553 union acpi_object acpi_object;
587 struct acpi_buffer buffer = {sizeof(acpi_object), &acpi_object}; 554 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
588 555
589 ACPI_FUNCTION_TRACE("acpi_power_add"); 556 ACPI_FUNCTION_TRACE("acpi_power_add");
590 557
@@ -630,22 +597,18 @@ acpi_power_add (
630 result = acpi_power_add_fs(device); 597 result = acpi_power_add_fs(device);
631 if (result) 598 if (result)
632 goto end; 599 goto end;
633 600
634 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), 601 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device),
635 acpi_device_bid(device), resource->state?"on":"off"); 602 acpi_device_bid(device), resource->state ? "on" : "off");
636 603
637end: 604 end:
638 if (result) 605 if (result)
639 kfree(resource); 606 kfree(resource);
640 607
641 return_VALUE(result); 608 return_VALUE(result);
642} 609}
643 610
644 611static int acpi_power_remove(struct acpi_device *device, int type)
645static int
646acpi_power_remove (
647 struct acpi_device *device,
648 int type)
649{ 612{
650 struct acpi_power_resource *resource = NULL; 613 struct acpi_power_resource *resource = NULL;
651 614
@@ -654,7 +617,7 @@ acpi_power_remove (
654 if (!device || !acpi_driver_data(device)) 617 if (!device || !acpi_driver_data(device))
655 return_VALUE(-EINVAL); 618 return_VALUE(-EINVAL);
656 619
657 resource = (struct acpi_power_resource *) acpi_driver_data(device); 620 resource = (struct acpi_power_resource *)acpi_driver_data(device);
658 621
659 acpi_power_remove_fs(device); 622 acpi_power_remove_fs(device);
660 623
@@ -663,10 +626,9 @@ acpi_power_remove (
663 return_VALUE(0); 626 return_VALUE(0);
664} 627}
665 628
666 629static int __init acpi_power_init(void)
667static int __init acpi_power_init (void)
668{ 630{
669 int result = 0; 631 int result = 0;
670 632
671 ACPI_FUNCTION_TRACE("acpi_power_init"); 633 ACPI_FUNCTION_TRACE("acpi_power_init");
672 634
@@ -689,4 +651,3 @@ static int __init acpi_power_init (void)
689} 651}
690 652
691subsys_initcall(acpi_power_init); 653subsys_initcall(acpi_power_init);
692
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index d56a439ac614..ac2dfa63646c 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -58,7 +58,6 @@
58#include <acpi/acpi_drivers.h> 58#include <acpi/acpi_drivers.h>
59#include <acpi/processor.h> 59#include <acpi/processor.h>
60 60
61
62#define ACPI_PROCESSOR_COMPONENT 0x01000000 61#define ACPI_PROCESSOR_COMPONENT 0x01000000
63#define ACPI_PROCESSOR_CLASS "processor" 62#define ACPI_PROCESSOR_CLASS "processor"
64#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 63#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
@@ -75,59 +74,53 @@
75#define ACPI_STA_PRESENT 0x00000001 74#define ACPI_STA_PRESENT 0x00000001
76 75
77#define _COMPONENT ACPI_PROCESSOR_COMPONENT 76#define _COMPONENT ACPI_PROCESSOR_COMPONENT
78ACPI_MODULE_NAME ("acpi_processor") 77ACPI_MODULE_NAME("acpi_processor")
79 78
80MODULE_AUTHOR("Paul Diefenbaugh"); 79 MODULE_AUTHOR("Paul Diefenbaugh");
81MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME); 80MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
82MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
83 82
84 83static int acpi_processor_add(struct acpi_device *device);
85static int acpi_processor_add (struct acpi_device *device); 84static int acpi_processor_start(struct acpi_device *device);
86static int acpi_processor_start (struct acpi_device *device); 85static int acpi_processor_remove(struct acpi_device *device, int type);
87static int acpi_processor_remove (struct acpi_device *device, int type);
88static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); 86static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
89static void acpi_processor_notify ( acpi_handle handle, u32 event, void *data); 87static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
90static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); 88static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
91static int acpi_processor_handle_eject(struct acpi_processor *pr); 89static int acpi_processor_handle_eject(struct acpi_processor *pr);
92 90
93static struct acpi_driver acpi_processor_driver = { 91static struct acpi_driver acpi_processor_driver = {
94 .name = ACPI_PROCESSOR_DRIVER_NAME, 92 .name = ACPI_PROCESSOR_DRIVER_NAME,
95 .class = ACPI_PROCESSOR_CLASS, 93 .class = ACPI_PROCESSOR_CLASS,
96 .ids = ACPI_PROCESSOR_HID, 94 .ids = ACPI_PROCESSOR_HID,
97 .ops = { 95 .ops = {
98 .add = acpi_processor_add, 96 .add = acpi_processor_add,
99 .remove = acpi_processor_remove, 97 .remove = acpi_processor_remove,
100 .start = acpi_processor_start, 98 .start = acpi_processor_start,
101 }, 99 },
102}; 100};
103 101
104#define INSTALL_NOTIFY_HANDLER 1 102#define INSTALL_NOTIFY_HANDLER 1
105#define UNINSTALL_NOTIFY_HANDLER 2 103#define UNINSTALL_NOTIFY_HANDLER 2
106 104
107
108static struct file_operations acpi_processor_info_fops = { 105static struct file_operations acpi_processor_info_fops = {
109 .open = acpi_processor_info_open_fs, 106 .open = acpi_processor_info_open_fs,
110 .read = seq_read, 107 .read = seq_read,
111 .llseek = seq_lseek, 108 .llseek = seq_lseek,
112 .release = single_release, 109 .release = single_release,
113}; 110};
114 111
115 112struct acpi_processor *processors[NR_CPUS];
116struct acpi_processor *processors[NR_CPUS];
117struct acpi_processor_errata errata; 113struct acpi_processor_errata errata;
118 114
119
120/* -------------------------------------------------------------------------- 115/* --------------------------------------------------------------------------
121 Errata Handling 116 Errata Handling
122 -------------------------------------------------------------------------- */ 117 -------------------------------------------------------------------------- */
123 118
124static int 119static int acpi_processor_errata_piix4(struct pci_dev *dev)
125acpi_processor_errata_piix4 (
126 struct pci_dev *dev)
127{ 120{
128 u8 rev = 0; 121 u8 rev = 0;
129 u8 value1 = 0; 122 u8 value1 = 0;
130 u8 value2 = 0; 123 u8 value2 = 0;
131 124
132 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4"); 125 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
133 126
@@ -188,8 +181,8 @@ acpi_processor_errata_piix4 (
188 * DMA activity. 181 * DMA activity.
189 */ 182 */
190 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 183 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
191 PCI_DEVICE_ID_INTEL_82371AB, 184 PCI_DEVICE_ID_INTEL_82371AB,
192 PCI_ANY_ID, PCI_ANY_ID, NULL); 185 PCI_ANY_ID, PCI_ANY_ID, NULL);
193 if (dev) { 186 if (dev) {
194 errata.piix4.bmisx = pci_resource_start(dev, 4); 187 errata.piix4.bmisx = pci_resource_start(dev, 4);
195 pci_dev_put(dev); 188 pci_dev_put(dev);
@@ -205,8 +198,8 @@ acpi_processor_errata_piix4 (
205 * devices won't operate well if fast DMA is disabled. 198 * devices won't operate well if fast DMA is disabled.
206 */ 199 */
207 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 200 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
208 PCI_DEVICE_ID_INTEL_82371AB_0, 201 PCI_DEVICE_ID_INTEL_82371AB_0,
209 PCI_ANY_ID, PCI_ANY_ID, NULL); 202 PCI_ANY_ID, PCI_ANY_ID, NULL);
210 if (dev) { 203 if (dev) {
211 pci_read_config_byte(dev, 0x76, &value1); 204 pci_read_config_byte(dev, 0x76, &value1);
212 pci_read_config_byte(dev, 0x77, &value2); 205 pci_read_config_byte(dev, 0x77, &value2);
@@ -220,21 +213,18 @@ acpi_processor_errata_piix4 (
220 213
221 if (errata.piix4.bmisx) 214 if (errata.piix4.bmisx)
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 215 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
223 "Bus master activity detection (BM-IDE) erratum enabled\n")); 216 "Bus master activity detection (BM-IDE) erratum enabled\n"));
224 if (errata.piix4.fdma) 217 if (errata.piix4.fdma)
225 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 218 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
226 "Type-F DMA livelock erratum (C3 disabled)\n")); 219 "Type-F DMA livelock erratum (C3 disabled)\n"));
227 220
228 return_VALUE(0); 221 return_VALUE(0);
229} 222}
230 223
231 224static int acpi_processor_errata(struct acpi_processor *pr)
232int
233acpi_processor_errata (
234 struct acpi_processor *pr)
235{ 225{
236 int result = 0; 226 int result = 0;
237 struct pci_dev *dev = NULL; 227 struct pci_dev *dev = NULL;
238 228
239 ACPI_FUNCTION_TRACE("acpi_processor_errata"); 229 ACPI_FUNCTION_TRACE("acpi_processor_errata");
240 230
@@ -245,7 +235,8 @@ acpi_processor_errata (
245 * PIIX4 235 * PIIX4
246 */ 236 */
247 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 237 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
248 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, PCI_ANY_ID, NULL); 238 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
239 PCI_ANY_ID, NULL);
249 if (dev) { 240 if (dev) {
250 result = acpi_processor_errata_piix4(dev); 241 result = acpi_processor_errata_piix4(dev);
251 pci_dev_put(dev); 242 pci_dev_put(dev);
@@ -254,7 +245,6 @@ acpi_processor_errata (
254 return_VALUE(result); 245 return_VALUE(result);
255} 246}
256 247
257
258/* -------------------------------------------------------------------------- 248/* --------------------------------------------------------------------------
259 Common ACPI processor fucntions 249 Common ACPI processor fucntions
260 -------------------------------------------------------------------------- */ 250 -------------------------------------------------------------------------- */
@@ -265,13 +255,13 @@ acpi_processor_errata (
265 */ 255 */
266 256
267int acpi_processor_set_pdc(struct acpi_processor *pr, 257int acpi_processor_set_pdc(struct acpi_processor *pr,
268 struct acpi_object_list *pdc_in) 258 struct acpi_object_list *pdc_in)
269{ 259{
270 acpi_status status = AE_OK; 260 acpi_status status = AE_OK;
271 u32 arg0_buf[3]; 261 u32 arg0_buf[3];
272 union acpi_object arg0 = {ACPI_TYPE_BUFFER}; 262 union acpi_object arg0 = { ACPI_TYPE_BUFFER };
273 struct acpi_object_list no_object = {1, &arg0}; 263 struct acpi_object_list no_object = { 1, &arg0 };
274 struct acpi_object_list *pdc; 264 struct acpi_object_list *pdc;
275 265
276 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); 266 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
277 267
@@ -286,21 +276,21 @@ int acpi_processor_set_pdc(struct acpi_processor *pr,
286 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); 276 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
287 277
288 if ((ACPI_FAILURE(status)) && (pdc_in)) 278 if ((ACPI_FAILURE(status)) && (pdc_in))
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n")); 279 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "Error evaluating _PDC, using legacy perf. control...\n"));
290 281
291 return_VALUE(status); 282 return_VALUE(status);
292} 283}
293 284
294
295/* -------------------------------------------------------------------------- 285/* --------------------------------------------------------------------------
296 FS Interface (/proc) 286 FS Interface (/proc)
297 -------------------------------------------------------------------------- */ 287 -------------------------------------------------------------------------- */
298 288
299static struct proc_dir_entry *acpi_processor_dir = NULL; 289static struct proc_dir_entry *acpi_processor_dir = NULL;
300 290
301static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) 291static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
302{ 292{
303 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 293 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
304 294
305 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show"); 295 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
306 296
@@ -308,40 +298,37 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
308 goto end; 298 goto end;
309 299
310 seq_printf(seq, "processor id: %d\n" 300 seq_printf(seq, "processor id: %d\n"
311 "acpi id: %d\n" 301 "acpi id: %d\n"
312 "bus mastering control: %s\n" 302 "bus mastering control: %s\n"
313 "power management: %s\n" 303 "power management: %s\n"
314 "throttling control: %s\n" 304 "throttling control: %s\n"
315 "limit interface: %s\n", 305 "limit interface: %s\n",
316 pr->id, 306 pr->id,
317 pr->acpi_id, 307 pr->acpi_id,
318 pr->flags.bm_control ? "yes" : "no", 308 pr->flags.bm_control ? "yes" : "no",
319 pr->flags.power ? "yes" : "no", 309 pr->flags.power ? "yes" : "no",
320 pr->flags.throttling ? "yes" : "no", 310 pr->flags.throttling ? "yes" : "no",
321 pr->flags.limit ? "yes" : "no"); 311 pr->flags.limit ? "yes" : "no");
322 312
323end: 313 end:
324 return_VALUE(0); 314 return_VALUE(0);
325} 315}
326 316
327static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) 317static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
328{ 318{
329 return single_open(file, acpi_processor_info_seq_show, 319 return single_open(file, acpi_processor_info_seq_show,
330 PDE(inode)->data); 320 PDE(inode)->data);
331} 321}
332 322
333 323static int acpi_processor_add_fs(struct acpi_device *device)
334static int
335acpi_processor_add_fs (
336 struct acpi_device *device)
337{ 324{
338 struct proc_dir_entry *entry = NULL; 325 struct proc_dir_entry *entry = NULL;
339 326
340 ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); 327 ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
341 328
342 if (!acpi_device_dir(device)) { 329 if (!acpi_device_dir(device)) {
343 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 330 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
344 acpi_processor_dir); 331 acpi_processor_dir);
345 if (!acpi_device_dir(device)) 332 if (!acpi_device_dir(device))
346 return_VALUE(-ENODEV); 333 return_VALUE(-ENODEV);
347 } 334 }
@@ -349,11 +336,11 @@ acpi_processor_add_fs (
349 336
350 /* 'info' [R] */ 337 /* 'info' [R] */
351 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, 338 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
352 S_IRUGO, acpi_device_dir(device)); 339 S_IRUGO, acpi_device_dir(device));
353 if (!entry) 340 if (!entry)
354 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
355 "Unable to create '%s' fs entry\n", 342 "Unable to create '%s' fs entry\n",
356 ACPI_PROCESSOR_FILE_INFO)); 343 ACPI_PROCESSOR_FILE_INFO));
357 else { 344 else {
358 entry->proc_fops = &acpi_processor_info_fops; 345 entry->proc_fops = &acpi_processor_info_fops;
359 entry->data = acpi_driver_data(device); 346 entry->data = acpi_driver_data(device);
@@ -362,11 +349,12 @@ acpi_processor_add_fs (
362 349
363 /* 'throttling' [R/W] */ 350 /* 'throttling' [R/W] */
364 entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 351 entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
365 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 352 S_IFREG | S_IRUGO | S_IWUSR,
353 acpi_device_dir(device));
366 if (!entry) 354 if (!entry)
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 355 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
368 "Unable to create '%s' fs entry\n", 356 "Unable to create '%s' fs entry\n",
369 ACPI_PROCESSOR_FILE_THROTTLING)); 357 ACPI_PROCESSOR_FILE_THROTTLING));
370 else { 358 else {
371 entry->proc_fops = &acpi_processor_throttling_fops; 359 entry->proc_fops = &acpi_processor_throttling_fops;
372 entry->proc_fops->write = acpi_processor_write_throttling; 360 entry->proc_fops->write = acpi_processor_write_throttling;
@@ -376,11 +364,12 @@ acpi_processor_add_fs (
376 364
377 /* 'limit' [R/W] */ 365 /* 'limit' [R/W] */
378 entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, 366 entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
379 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 367 S_IFREG | S_IRUGO | S_IWUSR,
368 acpi_device_dir(device));
380 if (!entry) 369 if (!entry)
381 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
382 "Unable to create '%s' fs entry\n", 371 "Unable to create '%s' fs entry\n",
383 ACPI_PROCESSOR_FILE_LIMIT)); 372 ACPI_PROCESSOR_FILE_LIMIT));
384 else { 373 else {
385 entry->proc_fops = &acpi_processor_limit_fops; 374 entry->proc_fops = &acpi_processor_limit_fops;
386 entry->proc_fops->write = acpi_processor_write_limit; 375 entry->proc_fops->write = acpi_processor_write_limit;
@@ -391,18 +380,17 @@ acpi_processor_add_fs (
391 return_VALUE(0); 380 return_VALUE(0);
392} 381}
393 382
394 383static int acpi_processor_remove_fs(struct acpi_device *device)
395static int
396acpi_processor_remove_fs (
397 struct acpi_device *device)
398{ 384{
399 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); 385 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
400 386
401 if (acpi_device_dir(device)) { 387 if (acpi_device_dir(device)) {
402 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,acpi_device_dir(device)); 388 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
389 acpi_device_dir(device));
403 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 390 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
404 acpi_device_dir(device)); 391 acpi_device_dir(device));
405 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,acpi_device_dir(device)); 392 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
393 acpi_device_dir(device));
406 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); 394 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
407 acpi_device_dir(device) = NULL; 395 acpi_device_dir(device) = NULL;
408 } 396 }
@@ -425,18 +413,20 @@ acpi_processor_remove_fs (
425#define ARCH_BAD_APICID (0xff) 413#define ARCH_BAD_APICID (0xff)
426#endif 414#endif
427 415
428static u8 convert_acpiid_to_cpu(u8 acpi_id) 416static int convert_acpiid_to_cpu(u8 acpi_id, unsigned int *cpu_index)
429{ 417{
430 u16 apic_id; 418 u16 apic_id;
431 int i; 419 unsigned int i;
432 420
433 apic_id = arch_acpiid_to_apicid[acpi_id]; 421 apic_id = arch_acpiid_to_apicid[acpi_id];
434 if (apic_id == ARCH_BAD_APICID) 422 if (apic_id == ARCH_BAD_APICID)
435 return -1; 423 return -1;
436 424
437 for (i = 0; i < NR_CPUS; i++) { 425 for (i = 0; i < NR_CPUS; i++) {
438 if (arch_cpu_to_apicid[i] == apic_id) 426 if (arch_cpu_to_apicid[i] == apic_id) {
439 return i; 427 *cpu_index = i;
428 return 0;
429 }
440 } 430 }
441 return -1; 431 return -1;
442} 432}
@@ -446,15 +436,14 @@ static u8 convert_acpiid_to_cpu(u8 acpi_id)
446 Driver Interface 436 Driver Interface
447 -------------------------------------------------------------------------- */ 437 -------------------------------------------------------------------------- */
448 438
449static int 439static int acpi_processor_get_info(struct acpi_processor *pr)
450acpi_processor_get_info (
451 struct acpi_processor *pr)
452{ 440{
453 acpi_status status = 0; 441 acpi_status status = 0;
454 union acpi_object object = {0}; 442 union acpi_object object = { 0 };
455 struct acpi_buffer buffer = {sizeof(union acpi_object), &object}; 443 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
456 u8 cpu_index; 444 unsigned int cpu_index;
457 static int cpu0_initialized; 445 int retval;
446 static int cpu0_initialized;
458 447
459 ACPI_FUNCTION_TRACE("acpi_processor_get_info"); 448 ACPI_FUNCTION_TRACE("acpi_processor_get_info");
460 449
@@ -473,11 +462,10 @@ acpi_processor_get_info (
473 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) { 462 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) {
474 pr->flags.bm_control = 1; 463 pr->flags.bm_control = 1;
475 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 464 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
476 "Bus mastering arbitration control present\n")); 465 "Bus mastering arbitration control present\n"));
477 } 466 } else
478 else
479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 467 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
480 "No bus mastering arbitration control\n")); 468 "No bus mastering arbitration control\n"));
481 469
482 /* 470 /*
483 * Evalute the processor object. Note that it is common on SMP to 471 * Evalute the processor object. Note that it is common on SMP to
@@ -487,50 +475,51 @@ acpi_processor_get_info (
487 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 475 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
488 if (ACPI_FAILURE(status)) { 476 if (ACPI_FAILURE(status)) {
489 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 477 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
490 "Error evaluating processor object\n")); 478 "Error evaluating processor object\n"));
491 return_VALUE(-ENODEV); 479 return_VALUE(-ENODEV);
492 } 480 }
493 481
494 /* 482 /*
495 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. 483 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
496 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c 484 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c
497 */ 485 */
498 pr->acpi_id = object.processor.proc_id; 486 pr->acpi_id = object.processor.proc_id;
499 487
500 cpu_index = convert_acpiid_to_cpu(pr->acpi_id); 488 retval = convert_acpiid_to_cpu(pr->acpi_id, &cpu_index);
501 489
502 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 490 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
503 if ( !cpu0_initialized && (cpu_index == 0xff) && 491 if (!cpu0_initialized && retval &&
504 (num_online_cpus() == 1)) { 492 (num_online_cpus() == 1)) {
505 cpu_index = 0; 493 cpu_index = 0;
506 } 494 }
507 495
508 cpu0_initialized = 1; 496 cpu0_initialized = 1;
509 497
510 pr->id = cpu_index; 498 pr->id = cpu_index;
511 499
512 /* 500 /*
513 * Extra Processor objects may be enumerated on MP systems with 501 * Extra Processor objects may be enumerated on MP systems with
514 * less than the max # of CPUs. They should be ignored _iff 502 * less than the max # of CPUs. They should be ignored _iff
515 * they are physically not present. 503 * they are physically not present.
516 */ 504 */
517 if (cpu_index >= NR_CPUS) { 505 if (retval) {
518 if (ACPI_FAILURE(acpi_processor_hotadd_init(pr->handle, &pr->id))) { 506 if (ACPI_FAILURE
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 507 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
520 "Error getting cpuindex for acpiid 0x%x\n", 508 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
521 pr->acpi_id)); 509 "Error getting cpuindex for acpiid 0x%x\n",
522 return_VALUE(-ENODEV); 510 pr->acpi_id));
523 } 511 return_VALUE(-ENODEV);
524 } 512 }
513 }
525 514
526 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, 515 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
527 pr->acpi_id)); 516 pr->acpi_id));
528 517
529 if (!object.processor.pblk_address) 518 if (!object.processor.pblk_address)
530 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 519 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
531 else if (object.processor.pblk_length != 6) 520 else if (object.processor.pblk_length != 6)
532 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", 521 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n",
533 object.processor.pblk_length)); 522 object.processor.pblk_length));
534 else { 523 else {
535 pr->throttling.address = object.processor.pblk_address; 524 pr->throttling.address = object.processor.pblk_address;
536 pr->throttling.duty_offset = acpi_fadt.duty_offset; 525 pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -557,13 +546,11 @@ acpi_processor_get_info (
557 return_VALUE(0); 546 return_VALUE(0);
558} 547}
559 548
560static int 549static int acpi_processor_start(struct acpi_device *device)
561acpi_processor_start(
562 struct acpi_device *device)
563{ 550{
564 int result = 0; 551 int result = 0;
565 acpi_status status = AE_OK; 552 acpi_status status = AE_OK;
566 struct acpi_processor *pr; 553 struct acpi_processor *pr;
567 554
568 ACPI_FUNCTION_TRACE("acpi_processor_start"); 555 ACPI_FUNCTION_TRACE("acpi_processor_start");
569 556
@@ -584,36 +571,30 @@ acpi_processor_start(
584 goto end; 571 goto end;
585 572
586 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 573 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
587 acpi_processor_notify, pr); 574 acpi_processor_notify, pr);
588 if (ACPI_FAILURE(status)) { 575 if (ACPI_FAILURE(status)) {
589 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 576 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
590 "Error installing device notify handler\n")); 577 "Error installing device notify handler\n"));
591 } 578 }
592 579
593 acpi_processor_power_init(pr, device); 580 acpi_processor_power_init(pr, device);
594 581
595 if (pr->flags.throttling) { 582 if (pr->flags.throttling) {
596 printk(KERN_INFO PREFIX "%s [%s] (supports", 583 printk(KERN_INFO PREFIX "%s [%s] (supports",
597 acpi_device_name(device), acpi_device_bid(device)); 584 acpi_device_name(device), acpi_device_bid(device));
598 printk(" %d throttling states", pr->throttling.state_count); 585 printk(" %d throttling states", pr->throttling.state_count);
599 printk(")\n"); 586 printk(")\n");
600 } 587 }
601 588
602end: 589 end:
603 590
604 return_VALUE(result); 591 return_VALUE(result);
605} 592}
606 593
607 594static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
608
609static void
610acpi_processor_notify (
611 acpi_handle handle,
612 u32 event,
613 void *data)
614{ 595{
615 struct acpi_processor *pr = (struct acpi_processor *) data; 596 struct acpi_processor *pr = (struct acpi_processor *)data;
616 struct acpi_device *device = NULL; 597 struct acpi_device *device = NULL;
617 598
618 ACPI_FUNCTION_TRACE("acpi_processor_notify"); 599 ACPI_FUNCTION_TRACE("acpi_processor_notify");
619 600
@@ -627,7 +608,7 @@ acpi_processor_notify (
627 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 608 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
628 acpi_processor_ppc_has_changed(pr); 609 acpi_processor_ppc_has_changed(pr);
629 acpi_bus_generate_event(device, event, 610 acpi_bus_generate_event(device, event,
630 pr->performance_platform_limit); 611 pr->performance_platform_limit);
631 break; 612 break;
632 case ACPI_PROCESSOR_NOTIFY_POWER: 613 case ACPI_PROCESSOR_NOTIFY_POWER:
633 acpi_processor_cst_has_changed(pr); 614 acpi_processor_cst_has_changed(pr);
@@ -635,19 +616,16 @@ acpi_processor_notify (
635 break; 616 break;
636 default: 617 default:
637 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 618 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
638 "Unsupported event [0x%x]\n", event)); 619 "Unsupported event [0x%x]\n", event));
639 break; 620 break;
640 } 621 }
641 622
642 return_VOID; 623 return_VOID;
643} 624}
644 625
645 626static int acpi_processor_add(struct acpi_device *device)
646static int
647acpi_processor_add (
648 struct acpi_device *device)
649{ 627{
650 struct acpi_processor *pr = NULL; 628 struct acpi_processor *pr = NULL;
651 629
652 ACPI_FUNCTION_TRACE("acpi_processor_add"); 630 ACPI_FUNCTION_TRACE("acpi_processor_add");
653 631
@@ -667,21 +645,17 @@ acpi_processor_add (
667 return_VALUE(0); 645 return_VALUE(0);
668} 646}
669 647
670 648static int acpi_processor_remove(struct acpi_device *device, int type)
671static int
672acpi_processor_remove (
673 struct acpi_device *device,
674 int type)
675{ 649{
676 acpi_status status = AE_OK; 650 acpi_status status = AE_OK;
677 struct acpi_processor *pr = NULL; 651 struct acpi_processor *pr = NULL;
678 652
679 ACPI_FUNCTION_TRACE("acpi_processor_remove"); 653 ACPI_FUNCTION_TRACE("acpi_processor_remove");
680 654
681 if (!device || !acpi_driver_data(device)) 655 if (!device || !acpi_driver_data(device))
682 return_VALUE(-EINVAL); 656 return_VALUE(-EINVAL);
683 657
684 pr = (struct acpi_processor *) acpi_driver_data(device); 658 pr = (struct acpi_processor *)acpi_driver_data(device);
685 659
686 if (pr->id >= NR_CPUS) { 660 if (pr->id >= NR_CPUS) {
687 kfree(pr); 661 kfree(pr);
@@ -696,10 +670,10 @@ acpi_processor_remove (
696 acpi_processor_power_exit(pr, device); 670 acpi_processor_power_exit(pr, device);
697 671
698 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 672 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
699 acpi_processor_notify); 673 acpi_processor_notify);
700 if (ACPI_FAILURE(status)) { 674 if (ACPI_FAILURE(status)) {
701 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 675 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
702 "Error removing notify handler\n")); 676 "Error removing notify handler\n"));
703 } 677 }
704 678
705 acpi_processor_remove_fs(device); 679 acpi_processor_remove_fs(device);
@@ -718,33 +692,28 @@ acpi_processor_remove (
718 692
719static int is_processor_present(acpi_handle handle); 693static int is_processor_present(acpi_handle handle);
720 694
721static int 695static int is_processor_present(acpi_handle handle)
722is_processor_present(
723 acpi_handle handle)
724{ 696{
725 acpi_status status; 697 acpi_status status;
726 unsigned long sta = 0; 698 unsigned long sta = 0;
727 699
728 ACPI_FUNCTION_TRACE("is_processor_present"); 700 ACPI_FUNCTION_TRACE("is_processor_present");
729 701
730 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 702 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
731 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { 703 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
732 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 704 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
733 "Processor Device is not present\n")); 705 "Processor Device is not present\n"));
734 return_VALUE(0); 706 return_VALUE(0);
735 } 707 }
736 return_VALUE(1); 708 return_VALUE(1);
737} 709}
738 710
739
740static 711static
741int acpi_processor_device_add( 712int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
742 acpi_handle handle,
743 struct acpi_device **device)
744{ 713{
745 acpi_handle phandle; 714 acpi_handle phandle;
746 struct acpi_device *pdev; 715 struct acpi_device *pdev;
747 struct acpi_processor *pr; 716 struct acpi_processor *pr;
748 717
749 ACPI_FUNCTION_TRACE("acpi_processor_device_add"); 718 ACPI_FUNCTION_TRACE("acpi_processor_device_add");
750 719
@@ -766,21 +735,17 @@ int acpi_processor_device_add(
766 if (!pr) 735 if (!pr)
767 return_VALUE(-ENODEV); 736 return_VALUE(-ENODEV);
768 737
769 if ((pr->id >=0) && (pr->id < NR_CPUS)) { 738 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
770 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); 739 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE);
771 } 740 }
772 return_VALUE(0); 741 return_VALUE(0);
773} 742}
774 743
775
776static void 744static void
777acpi_processor_hotplug_notify ( 745acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
778 acpi_handle handle,
779 u32 event,
780 void *data)
781{ 746{
782 struct acpi_processor *pr; 747 struct acpi_processor *pr;
783 struct acpi_device *device = NULL; 748 struct acpi_device *device = NULL;
784 int result; 749 int result;
785 750
786 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); 751 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
@@ -789,8 +754,8 @@ acpi_processor_hotplug_notify (
789 case ACPI_NOTIFY_BUS_CHECK: 754 case ACPI_NOTIFY_BUS_CHECK:
790 case ACPI_NOTIFY_DEVICE_CHECK: 755 case ACPI_NOTIFY_DEVICE_CHECK:
791 printk("Processor driver received %s event\n", 756 printk("Processor driver received %s event\n",
792 (event==ACPI_NOTIFY_BUS_CHECK)? 757 (event == ACPI_NOTIFY_BUS_CHECK) ?
793 "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); 758 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
794 759
795 if (!is_processor_present(handle)) 760 if (!is_processor_present(handle))
796 break; 761 break;
@@ -799,14 +764,14 @@ acpi_processor_hotplug_notify (
799 result = acpi_processor_device_add(handle, &device); 764 result = acpi_processor_device_add(handle, &device);
800 if (result) 765 if (result)
801 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 766 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
802 "Unable to add the device\n")); 767 "Unable to add the device\n"));
803 break; 768 break;
804 } 769 }
805 770
806 pr = acpi_driver_data(device); 771 pr = acpi_driver_data(device);
807 if (!pr) { 772 if (!pr) {
808 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 773 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
809 "Driver data is NULL\n")); 774 "Driver data is NULL\n"));
810 break; 775 break;
811 } 776 }
812 777
@@ -816,24 +781,27 @@ acpi_processor_hotplug_notify (
816 } 781 }
817 782
818 result = acpi_processor_start(device); 783 result = acpi_processor_start(device);
819 if ((!result) && ((pr->id >=0) && (pr->id < NR_CPUS))) { 784 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
820 kobject_hotplug(&device->kobj, KOBJ_ONLINE); 785 kobject_hotplug(&device->kobj, KOBJ_ONLINE);
821 } else { 786 } else {
822 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 787 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
823 "Device [%s] failed to start\n", 788 "Device [%s] failed to start\n",
824 acpi_device_bid(device))); 789 acpi_device_bid(device)));
825 } 790 }
826 break; 791 break;
827 case ACPI_NOTIFY_EJECT_REQUEST: 792 case ACPI_NOTIFY_EJECT_REQUEST:
828 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"received ACPI_NOTIFY_EJECT_REQUEST\n")); 793 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
794 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
829 795
830 if (acpi_bus_get_device(handle, &device)) { 796 if (acpi_bus_get_device(handle, &device)) {
831 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Device don't exist, dropping EJECT\n")); 797 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
798 "Device don't exist, dropping EJECT\n"));
832 break; 799 break;
833 } 800 }
834 pr = acpi_driver_data(device); 801 pr = acpi_driver_data(device);
835 if (!pr) { 802 if (!pr) {
836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Driver data is NULL, dropping EJECT\n")); 803 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
804 "Driver data is NULL, dropping EJECT\n"));
837 return_VOID; 805 return_VOID;
838 } 806 }
839 807
@@ -842,7 +810,7 @@ acpi_processor_hotplug_notify (
842 break; 810 break;
843 default: 811 default:
844 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 812 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
845 "Unsupported event [0x%x]\n", event)); 813 "Unsupported event [0x%x]\n", event));
846 break; 814 break;
847 } 815 }
848 816
@@ -851,45 +819,39 @@ acpi_processor_hotplug_notify (
851 819
852static acpi_status 820static acpi_status
853processor_walk_namespace_cb(acpi_handle handle, 821processor_walk_namespace_cb(acpi_handle handle,
854 u32 lvl, 822 u32 lvl, void *context, void **rv)
855 void *context,
856 void **rv)
857{ 823{
858 acpi_status status; 824 acpi_status status;
859 int *action = context; 825 int *action = context;
860 acpi_object_type type = 0; 826 acpi_object_type type = 0;
861 827
862 status = acpi_get_type(handle, &type); 828 status = acpi_get_type(handle, &type);
863 if (ACPI_FAILURE(status)) 829 if (ACPI_FAILURE(status))
864 return(AE_OK); 830 return (AE_OK);
865 831
866 if (type != ACPI_TYPE_PROCESSOR) 832 if (type != ACPI_TYPE_PROCESSOR)
867 return(AE_OK); 833 return (AE_OK);
868 834
869 switch(*action) { 835 switch (*action) {
870 case INSTALL_NOTIFY_HANDLER: 836 case INSTALL_NOTIFY_HANDLER:
871 acpi_install_notify_handler(handle, 837 acpi_install_notify_handler(handle,
872 ACPI_SYSTEM_NOTIFY, 838 ACPI_SYSTEM_NOTIFY,
873 acpi_processor_hotplug_notify, 839 acpi_processor_hotplug_notify,
874 NULL); 840 NULL);
875 break; 841 break;
876 case UNINSTALL_NOTIFY_HANDLER: 842 case UNINSTALL_NOTIFY_HANDLER:
877 acpi_remove_notify_handler(handle, 843 acpi_remove_notify_handler(handle,
878 ACPI_SYSTEM_NOTIFY, 844 ACPI_SYSTEM_NOTIFY,
879 acpi_processor_hotplug_notify); 845 acpi_processor_hotplug_notify);
880 break; 846 break;
881 default: 847 default:
882 break; 848 break;
883 } 849 }
884 850
885 return(AE_OK); 851 return (AE_OK);
886} 852}
887 853
888 854static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
889static acpi_status
890acpi_processor_hotadd_init(
891 acpi_handle handle,
892 int *p_cpu)
893{ 855{
894 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); 856 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
895 857
@@ -908,57 +870,47 @@ acpi_processor_hotadd_init(
908 return_VALUE(AE_OK); 870 return_VALUE(AE_OK);
909} 871}
910 872
911 873static int acpi_processor_handle_eject(struct acpi_processor *pr)
912static int
913acpi_processor_handle_eject(struct acpi_processor *pr)
914{ 874{
915 if (cpu_online(pr->id)) { 875 if (cpu_online(pr->id)) {
916 return(-EINVAL); 876 return (-EINVAL);
917 } 877 }
918 arch_unregister_cpu(pr->id); 878 arch_unregister_cpu(pr->id);
919 acpi_unmap_lsapic(pr->id); 879 acpi_unmap_lsapic(pr->id);
920 return(0); 880 return (0);
921} 881}
922#else 882#else
923static acpi_status 883static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
924acpi_processor_hotadd_init(
925 acpi_handle handle,
926 int *p_cpu)
927{ 884{
928 return AE_ERROR; 885 return AE_ERROR;
929} 886}
930static int 887static int acpi_processor_handle_eject(struct acpi_processor *pr)
931acpi_processor_handle_eject(struct acpi_processor *pr)
932{ 888{
933 return(-EINVAL); 889 return (-EINVAL);
934} 890}
935#endif 891#endif
936 892
937
938static 893static
939void acpi_processor_install_hotplug_notify(void) 894void acpi_processor_install_hotplug_notify(void)
940{ 895{
941#ifdef CONFIG_ACPI_HOTPLUG_CPU 896#ifdef CONFIG_ACPI_HOTPLUG_CPU
942 int action = INSTALL_NOTIFY_HANDLER; 897 int action = INSTALL_NOTIFY_HANDLER;
943 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 898 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
944 ACPI_ROOT_OBJECT, 899 ACPI_ROOT_OBJECT,
945 ACPI_UINT32_MAX, 900 ACPI_UINT32_MAX,
946 processor_walk_namespace_cb, 901 processor_walk_namespace_cb, &action, NULL);
947 &action, NULL);
948#endif 902#endif
949} 903}
950 904
951
952static 905static
953void acpi_processor_uninstall_hotplug_notify(void) 906void acpi_processor_uninstall_hotplug_notify(void)
954{ 907{
955#ifdef CONFIG_ACPI_HOTPLUG_CPU 908#ifdef CONFIG_ACPI_HOTPLUG_CPU
956 int action = UNINSTALL_NOTIFY_HANDLER; 909 int action = UNINSTALL_NOTIFY_HANDLER;
957 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 910 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
958 ACPI_ROOT_OBJECT, 911 ACPI_ROOT_OBJECT,
959 ACPI_UINT32_MAX, 912 ACPI_UINT32_MAX,
960 processor_walk_namespace_cb, 913 processor_walk_namespace_cb, &action, NULL);
961 &action, NULL);
962#endif 914#endif
963} 915}
964 916
@@ -968,10 +920,9 @@ void acpi_processor_uninstall_hotplug_notify(void)
968 * ACPI, but needs symbols from this driver 920 * ACPI, but needs symbols from this driver
969 */ 921 */
970 922
971static int __init 923static int __init acpi_processor_init(void)
972acpi_processor_init (void)
973{ 924{
974 int result = 0; 925 int result = 0;
975 926
976 ACPI_FUNCTION_TRACE("acpi_processor_init"); 927 ACPI_FUNCTION_TRACE("acpi_processor_init");
977 928
@@ -998,9 +949,7 @@ acpi_processor_init (void)
998 return_VALUE(0); 949 return_VALUE(0);
999} 950}
1000 951
1001 952static void __exit acpi_processor_exit(void)
1002static void __exit
1003acpi_processor_exit (void)
1004{ 953{
1005 ACPI_FUNCTION_TRACE("acpi_processor_exit"); 954 ACPI_FUNCTION_TRACE("acpi_processor_exit");
1006 955
@@ -1017,7 +966,6 @@ acpi_processor_exit (void)
1017 return_VOID; 966 return_VOID;
1018} 967}
1019 968
1020
1021module_init(acpi_processor_init); 969module_init(acpi_processor_init);
1022module_exit(acpi_processor_exit); 970module_exit(acpi_processor_exit);
1023 971
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 2c04740c6543..26a3a4016115 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -48,15 +48,12 @@
48#define ACPI_PROCESSOR_CLASS "processor" 48#define ACPI_PROCESSOR_CLASS "processor"
49#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 49#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
50#define _COMPONENT ACPI_PROCESSOR_COMPONENT 50#define _COMPONENT ACPI_PROCESSOR_COMPONENT
51ACPI_MODULE_NAME ("acpi_processor") 51ACPI_MODULE_NAME("acpi_processor")
52
53#define ACPI_PROCESSOR_FILE_POWER "power" 52#define ACPI_PROCESSOR_FILE_POWER "power"
54
55#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) 53#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
56#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ 54#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */
57#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ 55#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */
58 56static void (*pm_idle_save) (void);
59static void (*pm_idle_save)(void);
60module_param(max_cstate, uint, 0644); 57module_param(max_cstate, uint, 0644);
61 58
62static unsigned int nocst = 0; 59static unsigned int nocst = 0;
@@ -69,7 +66,8 @@ module_param(nocst, uint, 0000);
69 * 100 HZ: 0x0000000F: 4 jiffies = 40ms 66 * 100 HZ: 0x0000000F: 4 jiffies = 40ms
70 * reduce history for more aggressive entry into C3 67 * reduce history for more aggressive entry into C3
71 */ 68 */
72static unsigned int bm_history = (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); 69static unsigned int bm_history =
70 (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1));
73module_param(bm_history, uint, 0644); 71module_param(bm_history, uint, 0644);
74/* -------------------------------------------------------------------------- 72/* --------------------------------------------------------------------------
75 Power Management 73 Power Management
@@ -87,34 +85,36 @@ static int set_max_cstate(struct dmi_system_id *id)
87 return 0; 85 return 0;
88 86
89 printk(KERN_NOTICE PREFIX "%s detected - limiting to C%ld max_cstate." 87 printk(KERN_NOTICE PREFIX "%s detected - limiting to C%ld max_cstate."
90 " Override with \"processor.max_cstate=%d\"\n", id->ident, 88 " Override with \"processor.max_cstate=%d\"\n", id->ident,
91 (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1); 89 (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
92 90
93 max_cstate = (long)id->driver_data; 91 max_cstate = (long)id->driver_data;
94 92
95 return 0; 93 return 0;
96} 94}
97 95
98
99static struct dmi_system_id __initdata processor_power_dmi_table[] = { 96static struct dmi_system_id __initdata processor_power_dmi_table[] = {
100 { set_max_cstate, "IBM ThinkPad R40e", { 97 {set_max_cstate, "IBM ThinkPad R40e", {
101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 98 DMI_MATCH(DMI_BIOS_VENDOR,
102 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1}, 99 "IBM"),
103 { set_max_cstate, "Medion 41700", { 100 DMI_MATCH(DMI_BIOS_VERSION,
104 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 101 "1SET60WW")},
105 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }, (void*)1}, 102 (void *)1},
106 { set_max_cstate, "Clevo 5600D", { 103 {set_max_cstate, "Medion 41700", {
107 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 104 DMI_MATCH(DMI_BIOS_VENDOR,
108 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307") }, 105 "Phoenix Technologies LTD"),
109 (void*)2}, 106 DMI_MATCH(DMI_BIOS_VERSION,
107 "R01-A1J")}, (void *)1},
108 {set_max_cstate, "Clevo 5600D", {
109 DMI_MATCH(DMI_BIOS_VENDOR,
110 "Phoenix Technologies LTD"),
111 DMI_MATCH(DMI_BIOS_VERSION,
112 "SHE845M0.86C.0013.D.0302131307")},
113 (void *)2},
110 {}, 114 {},
111}; 115};
112 116
113 117static inline u32 ticks_elapsed(u32 t1, u32 t2)
114static inline u32
115ticks_elapsed (
116 u32 t1,
117 u32 t2)
118{ 118{
119 if (t2 >= t1) 119 if (t2 >= t1)
120 return (t2 - t1); 120 return (t2 - t1);
@@ -124,13 +124,11 @@ ticks_elapsed (
124 return ((0xFFFFFFFF - t1) + t2); 124 return ((0xFFFFFFFF - t1) + t2);
125} 125}
126 126
127
128static void 127static void
129acpi_processor_power_activate ( 128acpi_processor_power_activate(struct acpi_processor *pr,
130 struct acpi_processor *pr, 129 struct acpi_processor_cx *new)
131 struct acpi_processor_cx *new)
132{ 130{
133 struct acpi_processor_cx *old; 131 struct acpi_processor_cx *old;
134 132
135 if (!pr || !new) 133 if (!pr || !new)
136 return; 134 return;
@@ -139,7 +137,7 @@ acpi_processor_power_activate (
139 137
140 if (old) 138 if (old)
141 old->promotion.count = 0; 139 old->promotion.count = 0;
142 new->demotion.count = 0; 140 new->demotion.count = 0;
143 141
144 /* Cleanup from old state. */ 142 /* Cleanup from old state. */
145 if (old) { 143 if (old) {
@@ -147,7 +145,8 @@ acpi_processor_power_activate (
147 case ACPI_STATE_C3: 145 case ACPI_STATE_C3:
148 /* Disable bus master reload */ 146 /* Disable bus master reload */
149 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check) 147 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
150 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); 148 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0,
149 ACPI_MTX_DO_NOT_LOCK);
151 break; 150 break;
152 } 151 }
153 } 152 }
@@ -157,7 +156,8 @@ acpi_processor_power_activate (
157 case ACPI_STATE_C3: 156 case ACPI_STATE_C3:
158 /* Enable bus master reload */ 157 /* Enable bus master reload */
159 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check) 158 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
160 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK); 159 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1,
160 ACPI_MTX_DO_NOT_LOCK);
161 break; 161 break;
162 } 162 }
163 163
@@ -166,17 +166,15 @@ acpi_processor_power_activate (
166 return; 166 return;
167} 167}
168 168
169static atomic_t c3_cpu_count;
169 170
170static atomic_t c3_cpu_count; 171static void acpi_processor_idle(void)
171
172
173static void acpi_processor_idle (void)
174{ 172{
175 struct acpi_processor *pr = NULL; 173 struct acpi_processor *pr = NULL;
176 struct acpi_processor_cx *cx = NULL; 174 struct acpi_processor_cx *cx = NULL;
177 struct acpi_processor_cx *next_state = NULL; 175 struct acpi_processor_cx *next_state = NULL;
178 int sleep_ticks = 0; 176 int sleep_ticks = 0;
179 u32 t1, t2 = 0; 177 u32 t1, t2 = 0;
180 178
181 pr = processors[raw_smp_processor_id()]; 179 pr = processors[raw_smp_processor_id()];
182 if (!pr) 180 if (!pr)
@@ -208,8 +206,8 @@ static void acpi_processor_idle (void)
208 * for demotion. 206 * for demotion.
209 */ 207 */
210 if (pr->flags.bm_check) { 208 if (pr->flags.bm_check) {
211 u32 bm_status = 0; 209 u32 bm_status = 0;
212 unsigned long diff = jiffies - pr->power.bm_check_timestamp; 210 unsigned long diff = jiffies - pr->power.bm_check_timestamp;
213 211
214 if (diff > 32) 212 if (diff > 32)
215 diff = 32; 213 diff = 32;
@@ -223,11 +221,11 @@ static void acpi_processor_idle (void)
223 } 221 }
224 222
225 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, 223 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS,
226 &bm_status, ACPI_MTX_DO_NOT_LOCK); 224 &bm_status, ACPI_MTX_DO_NOT_LOCK);
227 if (bm_status) { 225 if (bm_status) {
228 pr->power.bm_activity++; 226 pr->power.bm_activity++;
229 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 227 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
230 1, ACPI_MTX_DO_NOT_LOCK); 228 1, ACPI_MTX_DO_NOT_LOCK);
231 } 229 }
232 /* 230 /*
233 * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect 231 * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect
@@ -236,7 +234,7 @@ static void acpi_processor_idle (void)
236 */ 234 */
237 else if (errata.piix4.bmisx) { 235 else if (errata.piix4.bmisx) {
238 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) 236 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
239 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) 237 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
240 pr->power.bm_activity++; 238 pr->power.bm_activity++;
241 } 239 }
242 240
@@ -281,7 +279,7 @@ static void acpi_processor_idle (void)
281 else 279 else
282 safe_halt(); 280 safe_halt();
283 /* 281 /*
284 * TBD: Can't get time duration while in C1, as resumes 282 * TBD: Can't get time duration while in C1, as resumes
285 * go to an ISR rather than here. Need to instrument 283 * go to an ISR rather than here. Need to instrument
286 * base interrupt handler. 284 * base interrupt handler.
287 */ 285 */
@@ -300,26 +298,27 @@ static void acpi_processor_idle (void)
300 /* Re-enable interrupts */ 298 /* Re-enable interrupts */
301 local_irq_enable(); 299 local_irq_enable();
302 /* Compute time (ticks) that we were actually asleep */ 300 /* Compute time (ticks) that we were actually asleep */
303 sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; 301 sleep_ticks =
302 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
304 break; 303 break;
305 304
306 case ACPI_STATE_C3: 305 case ACPI_STATE_C3:
307 306
308 if (pr->flags.bm_check) { 307 if (pr->flags.bm_check) {
309 if (atomic_inc_return(&c3_cpu_count) == 308 if (atomic_inc_return(&c3_cpu_count) ==
310 num_online_cpus()) { 309 num_online_cpus()) {
311 /* 310 /*
312 * All CPUs are trying to go to C3 311 * All CPUs are trying to go to C3
313 * Disable bus master arbitration 312 * Disable bus master arbitration
314 */ 313 */
315 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, 314 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
316 ACPI_MTX_DO_NOT_LOCK); 315 ACPI_MTX_DO_NOT_LOCK);
317 } 316 }
318 } else { 317 } else {
319 /* SMP with no shared cache... Invalidate cache */ 318 /* SMP with no shared cache... Invalidate cache */
320 ACPI_FLUSH_CPU_CACHE(); 319 ACPI_FLUSH_CPU_CACHE();
321 } 320 }
322 321
323 /* Get start time (ticks) */ 322 /* Get start time (ticks) */
324 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 323 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
325 /* Invoke C3 */ 324 /* Invoke C3 */
@@ -331,13 +330,15 @@ static void acpi_processor_idle (void)
331 if (pr->flags.bm_check) { 330 if (pr->flags.bm_check) {
332 /* Enable bus master arbitration */ 331 /* Enable bus master arbitration */
333 atomic_dec(&c3_cpu_count); 332 atomic_dec(&c3_cpu_count);
334 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK); 333 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0,
334 ACPI_MTX_DO_NOT_LOCK);
335 } 335 }
336 336
337 /* Re-enable interrupts */ 337 /* Re-enable interrupts */
338 local_irq_enable(); 338 local_irq_enable();
339 /* Compute time (ticks) that we were actually asleep */ 339 /* Compute time (ticks) that we were actually asleep */
340 sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; 340 sleep_ticks =
341 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
341 break; 342 break;
342 343
343 default: 344 default:
@@ -359,15 +360,18 @@ static void acpi_processor_idle (void)
359 ((cx->promotion.state - pr->power.states) <= max_cstate)) { 360 ((cx->promotion.state - pr->power.states) <= max_cstate)) {
360 if (sleep_ticks > cx->promotion.threshold.ticks) { 361 if (sleep_ticks > cx->promotion.threshold.ticks) {
361 cx->promotion.count++; 362 cx->promotion.count++;
362 cx->demotion.count = 0; 363 cx->demotion.count = 0;
363 if (cx->promotion.count >= cx->promotion.threshold.count) { 364 if (cx->promotion.count >=
365 cx->promotion.threshold.count) {
364 if (pr->flags.bm_check) { 366 if (pr->flags.bm_check) {
365 if (!(pr->power.bm_activity & cx->promotion.threshold.bm)) { 367 if (!
366 next_state = cx->promotion.state; 368 (pr->power.bm_activity & cx->
369 promotion.threshold.bm)) {
370 next_state =
371 cx->promotion.state;
367 goto end; 372 goto end;
368 } 373 }
369 } 374 } else {
370 else {
371 next_state = cx->promotion.state; 375 next_state = cx->promotion.state;
372 goto end; 376 goto end;
373 } 377 }
@@ -392,7 +396,7 @@ static void acpi_processor_idle (void)
392 } 396 }
393 } 397 }
394 398
395end: 399 end:
396 /* 400 /*
397 * Demote if current state exceeds max_cstate 401 * Demote if current state exceeds max_cstate
398 */ 402 */
@@ -412,7 +416,7 @@ end:
412 416
413 return; 417 return;
414 418
415 easy_out: 419 easy_out:
416 /* do C1 instead of busy loop */ 420 /* do C1 instead of busy loop */
417 if (pm_idle_save) 421 if (pm_idle_save)
418 pm_idle_save(); 422 pm_idle_save();
@@ -421,10 +425,7 @@ end:
421 return; 425 return;
422} 426}
423 427
424 428static int acpi_processor_set_power_policy(struct acpi_processor *pr)
425static int
426acpi_processor_set_power_policy (
427 struct acpi_processor *pr)
428{ 429{
429 unsigned int i; 430 unsigned int i;
430 unsigned int state_is_set = 0; 431 unsigned int state_is_set = 0;
@@ -432,7 +433,7 @@ acpi_processor_set_power_policy (
432 struct acpi_processor_cx *higher = NULL; 433 struct acpi_processor_cx *higher = NULL;
433 struct acpi_processor_cx *cx; 434 struct acpi_processor_cx *cx;
434 435
435 ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy"); 436 ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy");
436 437
437 if (!pr) 438 if (!pr)
438 return_VALUE(-EINVAL); 439 return_VALUE(-EINVAL);
@@ -447,7 +448,7 @@ acpi_processor_set_power_policy (
447 */ 448 */
448 449
449 /* startup state */ 450 /* startup state */
450 for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 451 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
451 cx = &pr->power.states[i]; 452 cx = &pr->power.states[i];
452 if (!cx->valid) 453 if (!cx->valid)
453 continue; 454 continue;
@@ -456,13 +457,13 @@ acpi_processor_set_power_policy (
456 pr->power.state = cx; 457 pr->power.state = cx;
457 state_is_set++; 458 state_is_set++;
458 break; 459 break;
459 } 460 }
460 461
461 if (!state_is_set) 462 if (!state_is_set)
462 return_VALUE(-ENODEV); 463 return_VALUE(-ENODEV);
463 464
464 /* demotion */ 465 /* demotion */
465 for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 466 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
466 cx = &pr->power.states[i]; 467 cx = &pr->power.states[i];
467 if (!cx->valid) 468 if (!cx->valid)
468 continue; 469 continue;
@@ -485,7 +486,7 @@ acpi_processor_set_power_policy (
485 continue; 486 continue;
486 487
487 if (higher) { 488 if (higher) {
488 cx->promotion.state = higher; 489 cx->promotion.state = higher;
489 cx->promotion.threshold.ticks = cx->latency_ticks; 490 cx->promotion.threshold.ticks = cx->latency_ticks;
490 if (cx->type >= ACPI_STATE_C2) 491 if (cx->type >= ACPI_STATE_C2)
491 cx->promotion.threshold.count = 4; 492 cx->promotion.threshold.count = 4;
@@ -498,11 +499,10 @@ acpi_processor_set_power_policy (
498 higher = cx; 499 higher = cx;
499 } 500 }
500 501
501 return_VALUE(0); 502 return_VALUE(0);
502} 503}
503 504
504 505static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
505static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr)
506{ 506{
507 int i; 507 int i;
508 508
@@ -543,15 +543,14 @@ static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr)
543 return_VALUE(0); 543 return_VALUE(0);
544} 544}
545 545
546 546static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
547static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
548{ 547{
549 int i; 548 int i;
550 549
551 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 550 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
552 551
553 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 552 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
554 memset(&(pr->power.states[i]), 0, 553 memset(&(pr->power.states[i]), 0,
555 sizeof(struct acpi_processor_cx)); 554 sizeof(struct acpi_processor_cx));
556 555
557 /* if info is obtained from pblk/fadt, type equals state */ 556 /* if info is obtained from pblk/fadt, type equals state */
@@ -567,14 +566,13 @@ static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
567 return_VALUE(0); 566 return_VALUE(0);
568} 567}
569 568
570 569static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
571static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
572{ 570{
573 acpi_status status = 0; 571 acpi_status status = 0;
574 acpi_integer count; 572 acpi_integer count;
575 int i; 573 int i;
576 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 574 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
577 union acpi_object *cst; 575 union acpi_object *cst;
578 576
579 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); 577 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
580 578
@@ -583,20 +581,21 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
583 581
584 pr->power.count = 0; 582 pr->power.count = 0;
585 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 583 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
586 memset(&(pr->power.states[i]), 0, 584 memset(&(pr->power.states[i]), 0,
587 sizeof(struct acpi_processor_cx)); 585 sizeof(struct acpi_processor_cx));
588 586
589 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 587 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
590 if (ACPI_FAILURE(status)) { 588 if (ACPI_FAILURE(status)) {
591 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); 589 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n"));
592 return_VALUE(-ENODEV); 590 return_VALUE(-ENODEV);
593 } 591 }
594 592
595 cst = (union acpi_object *) buffer.pointer; 593 cst = (union acpi_object *)buffer.pointer;
596 594
597 /* There must be at least 2 elements */ 595 /* There must be at least 2 elements */
598 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { 596 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
599 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "not enough elements in _CST\n")); 597 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
598 "not enough elements in _CST\n"));
600 status = -EFAULT; 599 status = -EFAULT;
601 goto end; 600 goto end;
602 } 601 }
@@ -605,15 +604,19 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
605 604
606 /* Validate number of power states. */ 605 /* Validate number of power states. */
607 if (count < 1 || count != cst->package.count - 1) { 606 if (count < 1 || count != cst->package.count - 1) {
608 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "count given by _CST is not valid\n")); 607 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
608 "count given by _CST is not valid\n"));
609 status = -EFAULT; 609 status = -EFAULT;
610 goto end; 610 goto end;
611 } 611 }
612 612
613 /* We support up to ACPI_PROCESSOR_MAX_POWER. */ 613 /* We support up to ACPI_PROCESSOR_MAX_POWER. */
614 if (count > ACPI_PROCESSOR_MAX_POWER) { 614 if (count > ACPI_PROCESSOR_MAX_POWER) {
615 printk(KERN_WARNING "Limiting number of power states to max (%d)\n", ACPI_PROCESSOR_MAX_POWER); 615 printk(KERN_WARNING
616 printk(KERN_WARNING "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n"); 616 "Limiting number of power states to max (%d)\n",
617 ACPI_PROCESSOR_MAX_POWER);
618 printk(KERN_WARNING
619 "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n");
617 count = ACPI_PROCESSOR_MAX_POWER; 620 count = ACPI_PROCESSOR_MAX_POWER;
618 } 621 }
619 622
@@ -628,29 +631,29 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
628 631
629 memset(&cx, 0, sizeof(cx)); 632 memset(&cx, 0, sizeof(cx));
630 633
631 element = (union acpi_object *) &(cst->package.elements[i]); 634 element = (union acpi_object *)&(cst->package.elements[i]);
632 if (element->type != ACPI_TYPE_PACKAGE) 635 if (element->type != ACPI_TYPE_PACKAGE)
633 continue; 636 continue;
634 637
635 if (element->package.count != 4) 638 if (element->package.count != 4)
636 continue; 639 continue;
637 640
638 obj = (union acpi_object *) &(element->package.elements[0]); 641 obj = (union acpi_object *)&(element->package.elements[0]);
639 642
640 if (obj->type != ACPI_TYPE_BUFFER) 643 if (obj->type != ACPI_TYPE_BUFFER)
641 continue; 644 continue;
642 645
643 reg = (struct acpi_power_register *) obj->buffer.pointer; 646 reg = (struct acpi_power_register *)obj->buffer.pointer;
644 647
645 if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO && 648 if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO &&
646 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) 649 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
647 continue; 650 continue;
648 651
649 cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ? 652 cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
650 0 : reg->address; 653 0 : reg->address;
651 654
652 /* There should be an easy way to extract an integer... */ 655 /* There should be an easy way to extract an integer... */
653 obj = (union acpi_object *) &(element->package.elements[1]); 656 obj = (union acpi_object *)&(element->package.elements[1]);
654 if (obj->type != ACPI_TYPE_INTEGER) 657 if (obj->type != ACPI_TYPE_INTEGER)
655 continue; 658 continue;
656 659
@@ -660,17 +663,16 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
660 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) 663 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
661 continue; 664 continue;
662 665
663 if ((cx.type < ACPI_STATE_C1) || 666 if ((cx.type < ACPI_STATE_C1) || (cx.type > ACPI_STATE_C3))
664 (cx.type > ACPI_STATE_C3))
665 continue; 667 continue;
666 668
667 obj = (union acpi_object *) &(element->package.elements[2]); 669 obj = (union acpi_object *)&(element->package.elements[2]);
668 if (obj->type != ACPI_TYPE_INTEGER) 670 if (obj->type != ACPI_TYPE_INTEGER)
669 continue; 671 continue;
670 672
671 cx.latency = obj->integer.value; 673 cx.latency = obj->integer.value;
672 674
673 obj = (union acpi_object *) &(element->package.elements[3]); 675 obj = (union acpi_object *)&(element->package.elements[3]);
674 if (obj->type != ACPI_TYPE_INTEGER) 676 if (obj->type != ACPI_TYPE_INTEGER)
675 continue; 677 continue;
676 678
@@ -680,19 +682,19 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
680 memcpy(&(pr->power.states[pr->power.count]), &cx, sizeof(cx)); 682 memcpy(&(pr->power.states[pr->power.count]), &cx, sizeof(cx));
681 } 683 }
682 684
683 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n", pr->power.count)); 685 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n",
686 pr->power.count));
684 687
685 /* Validate number of power states discovered */ 688 /* Validate number of power states discovered */
686 if (pr->power.count < 2) 689 if (pr->power.count < 2)
687 status = -ENODEV; 690 status = -ENODEV;
688 691
689end: 692 end:
690 acpi_os_free(buffer.pointer); 693 acpi_os_free(buffer.pointer);
691 694
692 return_VALUE(status); 695 return_VALUE(status);
693} 696}
694 697
695
696static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) 698static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
697{ 699{
698 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2"); 700 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2");
@@ -706,8 +708,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
706 */ 708 */
707 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { 709 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
708 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 710 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
709 "latency too large [%d]\n", 711 "latency too large [%d]\n", cx->latency));
710 cx->latency));
711 return_VOID; 712 return_VOID;
712 } 713 }
713 714
@@ -721,10 +722,8 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
721 return_VOID; 722 return_VOID;
722} 723}
723 724
724 725static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
725static void acpi_processor_power_verify_c3( 726 struct acpi_processor_cx *cx)
726 struct acpi_processor *pr,
727 struct acpi_processor_cx *cx)
728{ 727{
729 static int bm_check_flag; 728 static int bm_check_flag;
730 729
@@ -739,8 +738,7 @@ static void acpi_processor_power_verify_c3(
739 */ 738 */
740 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { 739 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
741 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 740 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
742 "latency too large [%d]\n", 741 "latency too large [%d]\n", cx->latency));
743 cx->latency));
744 return_VOID; 742 return_VOID;
745 } 743 }
746 744
@@ -753,7 +751,7 @@ static void acpi_processor_power_verify_c3(
753 */ 751 */
754 else if (errata.piix4.fdma) { 752 else if (errata.piix4.fdma) {
755 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 753 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
756 "C3 not supported on PIIX4 with Type-F DMA\n")); 754 "C3 not supported on PIIX4 with Type-F DMA\n"));
757 return_VOID; 755 return_VOID;
758 } 756 }
759 757
@@ -770,7 +768,7 @@ static void acpi_processor_power_verify_c3(
770 /* bus mastering control is necessary */ 768 /* bus mastering control is necessary */
771 if (!pr->flags.bm_control) { 769 if (!pr->flags.bm_control) {
772 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 770 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
773 "C3 support requires bus mastering control\n")); 771 "C3 support requires bus mastering control\n"));
774 return_VOID; 772 return_VOID;
775 } 773 }
776 } else { 774 } else {
@@ -780,12 +778,12 @@ static void acpi_processor_power_verify_c3(
780 */ 778 */
781 if (acpi_fadt.wb_invd != 1) { 779 if (acpi_fadt.wb_invd != 1) {
782 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 780 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
783 "Cache invalidation should work properly" 781 "Cache invalidation should work properly"
784 " for C3 to be enabled on SMP systems\n")); 782 " for C3 to be enabled on SMP systems\n"));
785 return_VOID; 783 return_VOID;
786 } 784 }
787 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 785 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
788 0, ACPI_MTX_DO_NOT_LOCK); 786 0, ACPI_MTX_DO_NOT_LOCK);
789 } 787 }
790 788
791 /* 789 /*
@@ -800,13 +798,12 @@ static void acpi_processor_power_verify_c3(
800 return_VOID; 798 return_VOID;
801} 799}
802 800
803
804static int acpi_processor_power_verify(struct acpi_processor *pr) 801static int acpi_processor_power_verify(struct acpi_processor *pr)
805{ 802{
806 unsigned int i; 803 unsigned int i;
807 unsigned int working = 0; 804 unsigned int working = 0;
808 805
809 for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 806 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
810 struct acpi_processor_cx *cx = &pr->power.states[i]; 807 struct acpi_processor_cx *cx = &pr->power.states[i];
811 808
812 switch (cx->type) { 809 switch (cx->type) {
@@ -830,8 +827,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
830 return (working); 827 return (working);
831} 828}
832 829
833static int acpi_processor_get_power_info ( 830static int acpi_processor_get_power_info(struct acpi_processor *pr)
834 struct acpi_processor *pr)
835{ 831{
836 unsigned int i; 832 unsigned int i;
837 int result; 833 int result;
@@ -874,16 +870,16 @@ static int acpi_processor_get_power_info (
874 return_VALUE(0); 870 return_VALUE(0);
875} 871}
876 872
877int acpi_processor_cst_has_changed (struct acpi_processor *pr) 873int acpi_processor_cst_has_changed(struct acpi_processor *pr)
878{ 874{
879 int result = 0; 875 int result = 0;
880 876
881 ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed"); 877 ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed");
882 878
883 if (!pr) 879 if (!pr)
884 return_VALUE(-EINVAL); 880 return_VALUE(-EINVAL);
885 881
886 if ( nocst) { 882 if (nocst) {
887 return_VALUE(-ENODEV); 883 return_VALUE(-ENODEV);
888 } 884 }
889 885
@@ -892,7 +888,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
892 888
893 /* Fall back to the default idle loop */ 889 /* Fall back to the default idle loop */
894 pm_idle = pm_idle_save; 890 pm_idle = pm_idle_save;
895 synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ 891 synchronize_sched(); /* Relies on interrupts forcing exit from idle. */
896 892
897 pr->flags.power = 0; 893 pr->flags.power = 0;
898 result = acpi_processor_get_power_info(pr); 894 result = acpi_processor_get_power_info(pr);
@@ -906,8 +902,8 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
906 902
907static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) 903static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
908{ 904{
909 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 905 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
910 unsigned int i; 906 unsigned int i;
911 907
912 ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show"); 908 ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
913 909
@@ -915,17 +911,17 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
915 goto end; 911 goto end;
916 912
917 seq_printf(seq, "active state: C%zd\n" 913 seq_printf(seq, "active state: C%zd\n"
918 "max_cstate: C%d\n" 914 "max_cstate: C%d\n"
919 "bus master activity: %08x\n", 915 "bus master activity: %08x\n",
920 pr->power.state ? pr->power.state - pr->power.states : 0, 916 pr->power.state ? pr->power.state - pr->power.states : 0,
921 max_cstate, 917 max_cstate, (unsigned)pr->power.bm_activity);
922 (unsigned)pr->power.bm_activity);
923 918
924 seq_puts(seq, "states:\n"); 919 seq_puts(seq, "states:\n");
925 920
926 for (i = 1; i <= pr->power.count; i++) { 921 for (i = 1; i <= pr->power.count; i++) {
927 seq_printf(seq, " %cC%d: ", 922 seq_printf(seq, " %cC%d: ",
928 (&pr->power.states[i] == pr->power.state?'*':' '), i); 923 (&pr->power.states[i] ==
924 pr->power.state ? '*' : ' '), i);
929 925
930 if (!pr->power.states[i].valid) { 926 if (!pr->power.states[i].valid) {
931 seq_puts(seq, "<not supported>\n"); 927 seq_puts(seq, "<not supported>\n");
@@ -949,45 +945,46 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
949 945
950 if (pr->power.states[i].promotion.state) 946 if (pr->power.states[i].promotion.state)
951 seq_printf(seq, "promotion[C%zd] ", 947 seq_printf(seq, "promotion[C%zd] ",
952 (pr->power.states[i].promotion.state - 948 (pr->power.states[i].promotion.state -
953 pr->power.states)); 949 pr->power.states));
954 else 950 else
955 seq_puts(seq, "promotion[--] "); 951 seq_puts(seq, "promotion[--] ");
956 952
957 if (pr->power.states[i].demotion.state) 953 if (pr->power.states[i].demotion.state)
958 seq_printf(seq, "demotion[C%zd] ", 954 seq_printf(seq, "demotion[C%zd] ",
959 (pr->power.states[i].demotion.state - 955 (pr->power.states[i].demotion.state -
960 pr->power.states)); 956 pr->power.states));
961 else 957 else
962 seq_puts(seq, "demotion[--] "); 958 seq_puts(seq, "demotion[--] ");
963 959
964 seq_printf(seq, "latency[%03d] usage[%08d]\n", 960 seq_printf(seq, "latency[%03d] usage[%08d]\n",
965 pr->power.states[i].latency, 961 pr->power.states[i].latency,
966 pr->power.states[i].usage); 962 pr->power.states[i].usage);
967 } 963 }
968 964
969end: 965 end:
970 return_VALUE(0); 966 return_VALUE(0);
971} 967}
972 968
973static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) 969static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
974{ 970{
975 return single_open(file, acpi_processor_power_seq_show, 971 return single_open(file, acpi_processor_power_seq_show,
976 PDE(inode)->data); 972 PDE(inode)->data);
977} 973}
978 974
979static struct file_operations acpi_processor_power_fops = { 975static struct file_operations acpi_processor_power_fops = {
980 .open = acpi_processor_power_open_fs, 976 .open = acpi_processor_power_open_fs,
981 .read = seq_read, 977 .read = seq_read,
982 .llseek = seq_lseek, 978 .llseek = seq_lseek,
983 .release = single_release, 979 .release = single_release,
984}; 980};
985 981
986int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device) 982int acpi_processor_power_init(struct acpi_processor *pr,
983 struct acpi_device *device)
987{ 984{
988 acpi_status status = 0; 985 acpi_status status = 0;
989 static int first_run = 0; 986 static int first_run = 0;
990 struct proc_dir_entry *entry = NULL; 987 struct proc_dir_entry *entry = NULL;
991 unsigned int i; 988 unsigned int i;
992 989
993 ACPI_FUNCTION_TRACE("acpi_processor_power_init"); 990 ACPI_FUNCTION_TRACE("acpi_processor_power_init");
@@ -995,7 +992,9 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
995 if (!first_run) { 992 if (!first_run) {
996 dmi_check_system(processor_power_dmi_table); 993 dmi_check_system(processor_power_dmi_table);
997 if (max_cstate < ACPI_C_STATES_MAX) 994 if (max_cstate < ACPI_C_STATES_MAX)
998 printk(KERN_NOTICE "ACPI: processor limited to max C-state %d\n", max_cstate); 995 printk(KERN_NOTICE
996 "ACPI: processor limited to max C-state %d\n",
997 max_cstate);
999 first_run++; 998 first_run++;
1000 } 999 }
1001 1000
@@ -1003,7 +1002,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
1003 return_VALUE(-EINVAL); 1002 return_VALUE(-EINVAL);
1004 1003
1005 if (acpi_fadt.cst_cnt && !nocst) { 1004 if (acpi_fadt.cst_cnt && !nocst) {
1006 status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); 1005 status =
1006 acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
1007 if (ACPI_FAILURE(status)) { 1007 if (ACPI_FAILURE(status)) {
1008 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1008 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1009 "Notifying BIOS of _CST ability failed\n")); 1009 "Notifying BIOS of _CST ability failed\n"));
@@ -1023,7 +1023,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
1023 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); 1023 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id);
1024 for (i = 1; i <= pr->power.count; i++) 1024 for (i = 1; i <= pr->power.count; i++)
1025 if (pr->power.states[i].valid) 1025 if (pr->power.states[i].valid)
1026 printk(" C%d[C%d]", i, pr->power.states[i].type); 1026 printk(" C%d[C%d]", i,
1027 pr->power.states[i].type);
1027 printk(")\n"); 1028 printk(")\n");
1028 1029
1029 if (pr->id == 0) { 1030 if (pr->id == 0) {
@@ -1034,11 +1035,11 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
1034 1035
1035 /* 'power' [R] */ 1036 /* 'power' [R] */
1036 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1037 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1037 S_IRUGO, acpi_device_dir(device)); 1038 S_IRUGO, acpi_device_dir(device));
1038 if (!entry) 1039 if (!entry)
1039 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1040 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1040 "Unable to create '%s' fs entry\n", 1041 "Unable to create '%s' fs entry\n",
1041 ACPI_PROCESSOR_FILE_POWER)); 1042 ACPI_PROCESSOR_FILE_POWER));
1042 else { 1043 else {
1043 entry->proc_fops = &acpi_processor_power_fops; 1044 entry->proc_fops = &acpi_processor_power_fops;
1044 entry->data = acpi_driver_data(device); 1045 entry->data = acpi_driver_data(device);
@@ -1050,14 +1051,16 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
1050 return_VALUE(0); 1051 return_VALUE(0);
1051} 1052}
1052 1053
1053int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device) 1054int acpi_processor_power_exit(struct acpi_processor *pr,
1055 struct acpi_device *device)
1054{ 1056{
1055 ACPI_FUNCTION_TRACE("acpi_processor_power_exit"); 1057 ACPI_FUNCTION_TRACE("acpi_processor_power_exit");
1056 1058
1057 pr->flags.power_setup_done = 0; 1059 pr->flags.power_setup_done = 0;
1058 1060
1059 if (acpi_device_dir(device)) 1061 if (acpi_device_dir(device))
1060 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,acpi_device_dir(device)); 1062 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1063 acpi_device_dir(device));
1061 1064
1062 /* Unregister the idle handler when processor #0 is removed. */ 1065 /* Unregister the idle handler when processor #0 is removed. */
1063 if (pr->id == 0) { 1066 if (pr->id == 0) {
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 1f0d6256302f..22c7bb66c200 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -26,7 +26,6 @@
26 * 26 *
27 */ 27 */
28 28
29
30#include <linux/kernel.h> 29#include <linux/kernel.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/init.h> 31#include <linux/init.h>
@@ -42,14 +41,12 @@
42#include <acpi/acpi_bus.h> 41#include <acpi/acpi_bus.h>
43#include <acpi/processor.h> 42#include <acpi/processor.h>
44 43
45
46#define ACPI_PROCESSOR_COMPONENT 0x01000000 44#define ACPI_PROCESSOR_COMPONENT 0x01000000
47#define ACPI_PROCESSOR_CLASS "processor" 45#define ACPI_PROCESSOR_CLASS "processor"
48#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 46#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
49#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" 47#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
50#define _COMPONENT ACPI_PROCESSOR_COMPONENT 48#define _COMPONENT ACPI_PROCESSOR_COMPONENT
51ACPI_MODULE_NAME ("acpi_processor") 49ACPI_MODULE_NAME("acpi_processor")
52
53 50
54static DECLARE_MUTEX(performance_sem); 51static DECLARE_MUTEX(performance_sem);
55 52
@@ -69,8 +66,7 @@ static DECLARE_MUTEX(performance_sem);
69static int acpi_processor_ppc_status = 0; 66static int acpi_processor_ppc_status = 0;
70 67
71static int acpi_processor_ppc_notifier(struct notifier_block *nb, 68static int acpi_processor_ppc_notifier(struct notifier_block *nb,
72 unsigned long event, 69 unsigned long event, void *data)
73 void *data)
74{ 70{
75 struct cpufreq_policy *policy = data; 71 struct cpufreq_policy *policy = data;
76 struct acpi_processor *pr; 72 struct acpi_processor *pr;
@@ -85,7 +81,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
85 if (!pr || !pr->performance) 81 if (!pr || !pr->performance)
86 goto out; 82 goto out;
87 83
88 ppc = (unsigned int) pr->performance_platform_limit; 84 ppc = (unsigned int)pr->performance_platform_limit;
89 if (!ppc) 85 if (!ppc)
90 goto out; 86 goto out;
91 87
@@ -93,26 +89,23 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
93 goto out; 89 goto out;
94 90
95 cpufreq_verify_within_limits(policy, 0, 91 cpufreq_verify_within_limits(policy, 0,
96 pr->performance->states[ppc].core_frequency * 1000); 92 pr->performance->states[ppc].
93 core_frequency * 1000);
97 94
98 out: 95 out:
99 up(&performance_sem); 96 up(&performance_sem);
100 97
101 return 0; 98 return 0;
102} 99}
103 100
104
105static struct notifier_block acpi_ppc_notifier_block = { 101static struct notifier_block acpi_ppc_notifier_block = {
106 .notifier_call = acpi_processor_ppc_notifier, 102 .notifier_call = acpi_processor_ppc_notifier,
107}; 103};
108 104
109 105static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
110static int
111acpi_processor_get_platform_limit (
112 struct acpi_processor* pr)
113{ 106{
114 acpi_status status = 0; 107 acpi_status status = 0;
115 unsigned long ppc = 0; 108 unsigned long ppc = 0;
116 109
117 ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit"); 110 ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
118 111
@@ -128,19 +121,17 @@ acpi_processor_get_platform_limit (
128 if (status != AE_NOT_FOUND) 121 if (status != AE_NOT_FOUND)
129 acpi_processor_ppc_status |= PPC_IN_USE; 122 acpi_processor_ppc_status |= PPC_IN_USE;
130 123
131 if(ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 124 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); 125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n"));
133 return_VALUE(-ENODEV); 126 return_VALUE(-ENODEV);
134 } 127 }
135 128
136 pr->performance_platform_limit = (int) ppc; 129 pr->performance_platform_limit = (int)ppc;
137 130
138 return_VALUE(0); 131 return_VALUE(0);
139} 132}
140 133
141 134int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
142int acpi_processor_ppc_has_changed(
143 struct acpi_processor *pr)
144{ 135{
145 int ret = acpi_processor_get_platform_limit(pr); 136 int ret = acpi_processor_get_platform_limit(pr);
146 if (ret < 0) 137 if (ret < 0)
@@ -149,44 +140,44 @@ int acpi_processor_ppc_has_changed(
149 return cpufreq_update_policy(pr->id); 140 return cpufreq_update_policy(pr->id);
150} 141}
151 142
152 143void acpi_processor_ppc_init(void)
153void acpi_processor_ppc_init(void) { 144{
154 if (!cpufreq_register_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER)) 145 if (!cpufreq_register_notifier
146 (&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
155 acpi_processor_ppc_status |= PPC_REGISTERED; 147 acpi_processor_ppc_status |= PPC_REGISTERED;
156 else 148 else
157 printk(KERN_DEBUG "Warning: Processor Platform Limit not supported.\n"); 149 printk(KERN_DEBUG
150 "Warning: Processor Platform Limit not supported.\n");
158} 151}
159 152
160 153void acpi_processor_ppc_exit(void)
161void acpi_processor_ppc_exit(void) { 154{
162 if (acpi_processor_ppc_status & PPC_REGISTERED) 155 if (acpi_processor_ppc_status & PPC_REGISTERED)
163 cpufreq_unregister_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER); 156 cpufreq_unregister_notifier(&acpi_ppc_notifier_block,
157 CPUFREQ_POLICY_NOTIFIER);
164 158
165 acpi_processor_ppc_status &= ~PPC_REGISTERED; 159 acpi_processor_ppc_status &= ~PPC_REGISTERED;
166} 160}
167 161
168 162static int acpi_processor_get_performance_control(struct acpi_processor *pr)
169static int
170acpi_processor_get_performance_control (
171 struct acpi_processor *pr)
172{ 163{
173 int result = 0; 164 int result = 0;
174 acpi_status status = 0; 165 acpi_status status = 0;
175 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 166 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
176 union acpi_object *pct = NULL; 167 union acpi_object *pct = NULL;
177 union acpi_object obj = {0}; 168 union acpi_object obj = { 0 };
178 169
179 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control"); 170 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
180 171
181 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); 172 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
182 if(ACPI_FAILURE(status)) { 173 if (ACPI_FAILURE(status)) {
183 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); 174 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n"));
184 return_VALUE(-ENODEV); 175 return_VALUE(-ENODEV);
185 } 176 }
186 177
187 pct = (union acpi_object *) buffer.pointer; 178 pct = (union acpi_object *)buffer.pointer;
188 if (!pct || (pct->type != ACPI_TYPE_PACKAGE) 179 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
189 || (pct->package.count != 2)) { 180 || (pct->package.count != 2)) {
190 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); 181 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n"));
191 result = -EFAULT; 182 result = -EFAULT;
192 goto end; 183 goto end;
@@ -199,15 +190,15 @@ acpi_processor_get_performance_control (
199 obj = pct->package.elements[0]; 190 obj = pct->package.elements[0];
200 191
201 if ((obj.type != ACPI_TYPE_BUFFER) 192 if ((obj.type != ACPI_TYPE_BUFFER)
202 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 193 || (obj.buffer.length < sizeof(struct acpi_pct_register))
203 || (obj.buffer.pointer == NULL)) { 194 || (obj.buffer.pointer == NULL)) {
204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 195 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
205 "Invalid _PCT data (control_register)\n")); 196 "Invalid _PCT data (control_register)\n"));
206 result = -EFAULT; 197 result = -EFAULT;
207 goto end; 198 goto end;
208 } 199 }
209 memcpy(&pr->performance->control_register, obj.buffer.pointer, sizeof(struct acpi_pct_register)); 200 memcpy(&pr->performance->control_register, obj.buffer.pointer,
210 201 sizeof(struct acpi_pct_register));
211 202
212 /* 203 /*
213 * status_register 204 * status_register
@@ -216,44 +207,42 @@ acpi_processor_get_performance_control (
216 obj = pct->package.elements[1]; 207 obj = pct->package.elements[1];
217 208
218 if ((obj.type != ACPI_TYPE_BUFFER) 209 if ((obj.type != ACPI_TYPE_BUFFER)
219 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 210 || (obj.buffer.length < sizeof(struct acpi_pct_register))
220 || (obj.buffer.pointer == NULL)) { 211 || (obj.buffer.pointer == NULL)) {
221 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 212 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
222 "Invalid _PCT data (status_register)\n")); 213 "Invalid _PCT data (status_register)\n"));
223 result = -EFAULT; 214 result = -EFAULT;
224 goto end; 215 goto end;
225 } 216 }
226 217
227 memcpy(&pr->performance->status_register, obj.buffer.pointer, sizeof(struct acpi_pct_register)); 218 memcpy(&pr->performance->status_register, obj.buffer.pointer,
219 sizeof(struct acpi_pct_register));
228 220
229end: 221 end:
230 acpi_os_free(buffer.pointer); 222 acpi_os_free(buffer.pointer);
231 223
232 return_VALUE(result); 224 return_VALUE(result);
233} 225}
234 226
235 227static int acpi_processor_get_performance_states(struct acpi_processor *pr)
236static int
237acpi_processor_get_performance_states (
238 struct acpi_processor *pr)
239{ 228{
240 int result = 0; 229 int result = 0;
241 acpi_status status = AE_OK; 230 acpi_status status = AE_OK;
242 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 231 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
243 struct acpi_buffer format = {sizeof("NNNNNN"), "NNNNNN"}; 232 struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" };
244 struct acpi_buffer state = {0, NULL}; 233 struct acpi_buffer state = { 0, NULL };
245 union acpi_object *pss = NULL; 234 union acpi_object *pss = NULL;
246 int i; 235 int i;
247 236
248 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states"); 237 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
249 238
250 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); 239 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
251 if(ACPI_FAILURE(status)) { 240 if (ACPI_FAILURE(status)) {
252 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); 241 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n"));
253 return_VALUE(-ENODEV); 242 return_VALUE(-ENODEV);
254 } 243 }
255 244
256 pss = (union acpi_object *) buffer.pointer; 245 pss = (union acpi_object *)buffer.pointer;
257 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { 246 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
258 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); 247 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
259 result = -EFAULT; 248 result = -EFAULT;
@@ -261,10 +250,12 @@ acpi_processor_get_performance_states (
261 } 250 }
262 251
263 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n", 252 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
264 pss->package.count)); 253 pss->package.count));
265 254
266 pr->performance->state_count = pss->package.count; 255 pr->performance->state_count = pss->package.count;
267 pr->performance->states = kmalloc(sizeof(struct acpi_processor_px) * pss->package.count, GFP_KERNEL); 256 pr->performance->states =
257 kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
258 GFP_KERNEL);
268 if (!pr->performance->states) { 259 if (!pr->performance->states) {
269 result = -ENOMEM; 260 result = -ENOMEM;
270 goto end; 261 goto end;
@@ -280,46 +271,44 @@ acpi_processor_get_performance_states (
280 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i)); 271 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
281 272
282 status = acpi_extract_package(&(pss->package.elements[i]), 273 status = acpi_extract_package(&(pss->package.elements[i]),
283 &format, &state); 274 &format, &state);
284 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
285 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); 276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
277 "Invalid _PSS data\n"));
286 result = -EFAULT; 278 result = -EFAULT;
287 kfree(pr->performance->states); 279 kfree(pr->performance->states);
288 goto end; 280 goto end;
289 } 281 }
290 282
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
292 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n", 284 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
293 i, 285 i,
294 (u32) px->core_frequency, 286 (u32) px->core_frequency,
295 (u32) px->power, 287 (u32) px->power,
296 (u32) px->transition_latency, 288 (u32) px->transition_latency,
297 (u32) px->bus_master_latency, 289 (u32) px->bus_master_latency,
298 (u32) px->control, 290 (u32) px->control, (u32) px->status));
299 (u32) px->status));
300 291
301 if (!px->core_frequency) { 292 if (!px->core_frequency) {
302 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data: freq is zero\n")); 293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
294 "Invalid _PSS data: freq is zero\n"));
303 result = -EFAULT; 295 result = -EFAULT;
304 kfree(pr->performance->states); 296 kfree(pr->performance->states);
305 goto end; 297 goto end;
306 } 298 }
307 } 299 }
308 300
309end: 301 end:
310 acpi_os_free(buffer.pointer); 302 acpi_os_free(buffer.pointer);
311 303
312 return_VALUE(result); 304 return_VALUE(result);
313} 305}
314 306
315 307static int acpi_processor_get_performance_info(struct acpi_processor *pr)
316static int
317acpi_processor_get_performance_info (
318 struct acpi_processor *pr)
319{ 308{
320 int result = 0; 309 int result = 0;
321 acpi_status status = AE_OK; 310 acpi_status status = AE_OK;
322 acpi_handle handle = NULL; 311 acpi_handle handle = NULL;
323 312
324 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info"); 313 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
325 314
@@ -331,7 +320,7 @@ acpi_processor_get_performance_info (
331 status = acpi_get_handle(pr->handle, "_PCT", &handle); 320 status = acpi_get_handle(pr->handle, "_PCT", &handle);
332 if (ACPI_FAILURE(status)) { 321 if (ACPI_FAILURE(status)) {
333 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 322 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
334 "ACPI-based processor performance control unavailable\n")); 323 "ACPI-based processor performance control unavailable\n"));
335 return_VALUE(-ENODEV); 324 return_VALUE(-ENODEV);
336 } 325 }
337 326
@@ -350,10 +339,10 @@ acpi_processor_get_performance_info (
350 return_VALUE(0); 339 return_VALUE(0);
351} 340}
352 341
353 342int acpi_processor_notify_smm(struct module *calling_module)
354int acpi_processor_notify_smm(struct module *calling_module) { 343{
355 acpi_status status; 344 acpi_status status;
356 static int is_done = 0; 345 static int is_done = 0;
357 346
358 ACPI_FUNCTION_TRACE("acpi_processor_notify_smm"); 347 ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
359 348
@@ -371,8 +360,7 @@ int acpi_processor_notify_smm(struct module *calling_module) {
371 if (is_done > 0) { 360 if (is_done > 0) {
372 module_put(calling_module); 361 module_put(calling_module);
373 return_VALUE(0); 362 return_VALUE(0);
374 } 363 } else if (is_done < 0) {
375 else if (is_done < 0) {
376 module_put(calling_module); 364 module_put(calling_module);
377 return_VALUE(is_done); 365 return_VALUE(is_done);
378 } 366 }
@@ -380,28 +368,30 @@ int acpi_processor_notify_smm(struct module *calling_module) {
380 is_done = -EIO; 368 is_done = -EIO;
381 369
382 /* Can't write pstate_cnt to smi_cmd if either value is zero */ 370 /* Can't write pstate_cnt to smi_cmd if either value is zero */
383 if ((!acpi_fadt.smi_cmd) || 371 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) {
384 (!acpi_fadt.pstate_cnt)) { 372 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n"));
385 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
386 "No SMI port or pstate_cnt\n"));
387 module_put(calling_module); 373 module_put(calling_module);
388 return_VALUE(0); 374 return_VALUE(0);
389 } 375 }
390 376
391 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd)); 377 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
378 "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n",
379 acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd));
392 380
393 /* FADT v1 doesn't support pstate_cnt, many BIOS vendors use 381 /* FADT v1 doesn't support pstate_cnt, many BIOS vendors use
394 * it anyway, so we need to support it... */ 382 * it anyway, so we need to support it... */
395 if (acpi_fadt_is_v1) { 383 if (acpi_fadt_is_v1) {
396 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Using v1.0 FADT reserved value for pstate_cnt\n")); 384 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
385 "Using v1.0 FADT reserved value for pstate_cnt\n"));
397 } 386 }
398 387
399 status = acpi_os_write_port (acpi_fadt.smi_cmd, 388 status = acpi_os_write_port(acpi_fadt.smi_cmd,
400 (u32) acpi_fadt.pstate_cnt, 8); 389 (u32) acpi_fadt.pstate_cnt, 8);
401 if (ACPI_FAILURE (status)) { 390 if (ACPI_FAILURE(status)) {
402 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 391 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
403 "Failed to write pstate_cnt [0x%x] to " 392 "Failed to write pstate_cnt [0x%x] to "
404 "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd)); 393 "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt,
394 acpi_fadt.smi_cmd));
405 module_put(calling_module); 395 module_put(calling_module);
406 return_VALUE(status); 396 return_VALUE(status);
407 } 397 }
@@ -415,24 +405,24 @@ int acpi_processor_notify_smm(struct module *calling_module) {
415 405
416 return_VALUE(0); 406 return_VALUE(0);
417} 407}
418EXPORT_SYMBOL(acpi_processor_notify_smm);
419 408
409EXPORT_SYMBOL(acpi_processor_notify_smm);
420 410
421#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF 411#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
422/* /proc/acpi/processor/../performance interface (DEPRECATED) */ 412/* /proc/acpi/processor/../performance interface (DEPRECATED) */
423 413
424static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file); 414static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
425static struct file_operations acpi_processor_perf_fops = { 415static struct file_operations acpi_processor_perf_fops = {
426 .open = acpi_processor_perf_open_fs, 416 .open = acpi_processor_perf_open_fs,
427 .read = seq_read, 417 .read = seq_read,
428 .llseek = seq_lseek, 418 .llseek = seq_lseek,
429 .release = single_release, 419 .release = single_release,
430}; 420};
431 421
432static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) 422static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
433{ 423{
434 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 424 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
435 int i; 425 int i;
436 426
437 ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show"); 427 ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
438 428
@@ -445,42 +435,40 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
445 } 435 }
446 436
447 seq_printf(seq, "state count: %d\n" 437 seq_printf(seq, "state count: %d\n"
448 "active state: P%d\n", 438 "active state: P%d\n",
449 pr->performance->state_count, 439 pr->performance->state_count, pr->performance->state);
450 pr->performance->state);
451 440
452 seq_puts(seq, "states:\n"); 441 seq_puts(seq, "states:\n");
453 for (i = 0; i < pr->performance->state_count; i++) 442 for (i = 0; i < pr->performance->state_count; i++)
454 seq_printf(seq, " %cP%d: %d MHz, %d mW, %d uS\n", 443 seq_printf(seq,
455 (i == pr->performance->state?'*':' '), i, 444 " %cP%d: %d MHz, %d mW, %d uS\n",
456 (u32) pr->performance->states[i].core_frequency, 445 (i == pr->performance->state ? '*' : ' '), i,
457 (u32) pr->performance->states[i].power, 446 (u32) pr->performance->states[i].core_frequency,
458 (u32) pr->performance->states[i].transition_latency); 447 (u32) pr->performance->states[i].power,
459 448 (u32) pr->performance->states[i].transition_latency);
460end: 449
450 end:
461 return_VALUE(0); 451 return_VALUE(0);
462} 452}
463 453
464static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) 454static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
465{ 455{
466 return single_open(file, acpi_processor_perf_seq_show, 456 return single_open(file, acpi_processor_perf_seq_show,
467 PDE(inode)->data); 457 PDE(inode)->data);
468} 458}
469 459
470static ssize_t 460static ssize_t
471acpi_processor_write_performance ( 461acpi_processor_write_performance(struct file *file,
472 struct file *file, 462 const char __user * buffer,
473 const char __user *buffer, 463 size_t count, loff_t * data)
474 size_t count,
475 loff_t *data)
476{ 464{
477 int result = 0; 465 int result = 0;
478 struct seq_file *m = (struct seq_file *) file->private_data; 466 struct seq_file *m = (struct seq_file *)file->private_data;
479 struct acpi_processor *pr = (struct acpi_processor *) m->private; 467 struct acpi_processor *pr = (struct acpi_processor *)m->private;
480 struct acpi_processor_performance *perf; 468 struct acpi_processor_performance *perf;
481 char state_string[12] = {'\0'}; 469 char state_string[12] = { '\0' };
482 unsigned int new_state = 0; 470 unsigned int new_state = 0;
483 struct cpufreq_policy policy; 471 struct cpufreq_policy policy;
484 472
485 ACPI_FUNCTION_TRACE("acpi_processor_write_performance"); 473 ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
486 474
@@ -513,12 +501,10 @@ acpi_processor_write_performance (
513 return_VALUE(count); 501 return_VALUE(count);
514} 502}
515 503
516static void 504static void acpi_cpufreq_add_file(struct acpi_processor *pr)
517acpi_cpufreq_add_file (
518 struct acpi_processor *pr)
519{ 505{
520 struct proc_dir_entry *entry = NULL; 506 struct proc_dir_entry *entry = NULL;
521 struct acpi_device *device = NULL; 507 struct acpi_device *device = NULL;
522 508
523 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); 509 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
524 510
@@ -527,11 +513,12 @@ acpi_cpufreq_add_file (
527 513
528 /* add file 'performance' [R/W] */ 514 /* add file 'performance' [R/W] */
529 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 515 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
530 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 516 S_IFREG | S_IRUGO | S_IWUSR,
517 acpi_device_dir(device));
531 if (!entry) 518 if (!entry)
532 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
533 "Unable to create '%s' fs entry\n", 520 "Unable to create '%s' fs entry\n",
534 ACPI_PROCESSOR_FILE_PERFORMANCE)); 521 ACPI_PROCESSOR_FILE_PERFORMANCE));
535 else { 522 else {
536 entry->proc_fops = &acpi_processor_perf_fops; 523 entry->proc_fops = &acpi_processor_perf_fops;
537 entry->proc_fops->write = acpi_processor_write_performance; 524 entry->proc_fops->write = acpi_processor_write_performance;
@@ -541,11 +528,9 @@ acpi_cpufreq_add_file (
541 return_VOID; 528 return_VOID;
542} 529}
543 530
544static void 531static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
545acpi_cpufreq_remove_file (
546 struct acpi_processor *pr)
547{ 532{
548 struct acpi_device *device = NULL; 533 struct acpi_device *device = NULL;
549 534
550 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); 535 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
551 536
@@ -554,21 +539,25 @@ acpi_cpufreq_remove_file (
554 539
555 /* remove file 'performance' */ 540 /* remove file 'performance' */
556 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 541 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
557 acpi_device_dir(device)); 542 acpi_device_dir(device));
558 543
559 return_VOID; 544 return_VOID;
560} 545}
561 546
562#else 547#else
563static void acpi_cpufreq_add_file (struct acpi_processor *pr) { return; } 548static void acpi_cpufreq_add_file(struct acpi_processor *pr)
564static void acpi_cpufreq_remove_file (struct acpi_processor *pr) { return; } 549{
565#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */ 550 return;
566 551}
552static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
553{
554 return;
555}
556#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
567 557
568int 558int
569acpi_processor_register_performance ( 559acpi_processor_register_performance(struct acpi_processor_performance
570 struct acpi_processor_performance * performance, 560 *performance, unsigned int cpu)
571 unsigned int cpu)
572{ 561{
573 struct acpi_processor *pr; 562 struct acpi_processor *pr;
574 563
@@ -603,13 +592,12 @@ acpi_processor_register_performance (
603 up(&performance_sem); 592 up(&performance_sem);
604 return_VALUE(0); 593 return_VALUE(0);
605} 594}
606EXPORT_SYMBOL(acpi_processor_register_performance);
607 595
596EXPORT_SYMBOL(acpi_processor_register_performance);
608 597
609void 598void
610acpi_processor_unregister_performance ( 599acpi_processor_unregister_performance(struct acpi_processor_performance
611 struct acpi_processor_performance * performance, 600 *performance, unsigned int cpu)
612 unsigned int cpu)
613{ 601{
614 struct acpi_processor *pr; 602 struct acpi_processor *pr;
615 603
@@ -632,4 +620,5 @@ acpi_processor_unregister_performance (
632 620
633 return_VOID; 621 return_VOID;
634} 622}
623
635EXPORT_SYMBOL(acpi_processor_unregister_performance); 624EXPORT_SYMBOL(acpi_processor_unregister_performance);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 12bd980a12e9..37528c3b64b0 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -43,20 +43,16 @@
43#define ACPI_PROCESSOR_CLASS "processor" 43#define ACPI_PROCESSOR_CLASS "processor"
44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
45#define _COMPONENT ACPI_PROCESSOR_COMPONENT 45#define _COMPONENT ACPI_PROCESSOR_COMPONENT
46ACPI_MODULE_NAME ("acpi_processor") 46ACPI_MODULE_NAME("acpi_processor")
47
48 47
49/* -------------------------------------------------------------------------- 48/* --------------------------------------------------------------------------
50 Limit Interface 49 Limit Interface
51 -------------------------------------------------------------------------- */ 50 -------------------------------------------------------------------------- */
52 51static int acpi_processor_apply_limit(struct acpi_processor *pr)
53static int
54acpi_processor_apply_limit (
55 struct acpi_processor* pr)
56{ 52{
57 int result = 0; 53 int result = 0;
58 u16 px = 0; 54 u16 px = 0;
59 u16 tx = 0; 55 u16 tx = 0;
60 56
61 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit"); 57 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
62 58
@@ -80,19 +76,17 @@ acpi_processor_apply_limit (
80 pr->limit.state.px = px; 76 pr->limit.state.px = px;
81 pr->limit.state.tx = tx; 77 pr->limit.state.tx = tx;
82 78
83 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d] limit set to (P%d:T%d)\n", 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
84 pr->id, 80 "Processor [%d] limit set to (P%d:T%d)\n", pr->id,
85 pr->limit.state.px, 81 pr->limit.state.px, pr->limit.state.tx));
86 pr->limit.state.tx));
87 82
88end: 83 end:
89 if (result) 84 if (result)
90 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); 85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
91 86
92 return_VALUE(result); 87 return_VALUE(result);
93} 88}
94 89
95
96#ifdef CONFIG_CPU_FREQ 90#ifdef CONFIG_CPU_FREQ
97 91
98/* If a passive cooling situation is detected, primarily CPUfreq is used, as it 92/* If a passive cooling situation is detected, primarily CPUfreq is used, as it
@@ -104,7 +98,6 @@ end:
104static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS]; 98static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS];
105static unsigned int acpi_thermal_cpufreq_is_init = 0; 99static unsigned int acpi_thermal_cpufreq_is_init = 0;
106 100
107
108static int cpu_has_cpufreq(unsigned int cpu) 101static int cpu_has_cpufreq(unsigned int cpu)
109{ 102{
110 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
@@ -115,7 +108,6 @@ static int cpu_has_cpufreq(unsigned int cpu)
115 return 0; 108 return 0;
116} 109}
117 110
118
119static int acpi_thermal_cpufreq_increase(unsigned int cpu) 111static int acpi_thermal_cpufreq_increase(unsigned int cpu)
120{ 112{
121 if (!cpu_has_cpufreq(cpu)) 113 if (!cpu_has_cpufreq(cpu))
@@ -130,7 +122,6 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu)
130 return -ERANGE; 122 return -ERANGE;
131} 123}
132 124
133
134static int acpi_thermal_cpufreq_decrease(unsigned int cpu) 125static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
135{ 126{
136 if (!cpu_has_cpufreq(cpu)) 127 if (!cpu_has_cpufreq(cpu))
@@ -145,11 +136,8 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
145 return -ERANGE; 136 return -ERANGE;
146} 137}
147 138
148 139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
149static int acpi_thermal_cpufreq_notifier( 140 unsigned long event, void *data)
150 struct notifier_block *nb,
151 unsigned long event,
152 void *data)
153{ 141{
154 struct cpufreq_policy *policy = data; 142 struct cpufreq_policy *policy = data;
155 unsigned long max_freq = 0; 143 unsigned long max_freq = 0;
@@ -157,68 +145,74 @@ static int acpi_thermal_cpufreq_notifier(
157 if (event != CPUFREQ_ADJUST) 145 if (event != CPUFREQ_ADJUST)
158 goto out; 146 goto out;
159 147
160 max_freq = (policy->cpuinfo.max_freq * (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100; 148 max_freq =
149 (policy->cpuinfo.max_freq *
150 (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100;
161 151
162 cpufreq_verify_within_limits(policy, 0, max_freq); 152 cpufreq_verify_within_limits(policy, 0, max_freq);
163 153
164 out: 154 out:
165 return 0; 155 return 0;
166} 156}
167 157
168
169static struct notifier_block acpi_thermal_cpufreq_notifier_block = { 158static struct notifier_block acpi_thermal_cpufreq_notifier_block = {
170 .notifier_call = acpi_thermal_cpufreq_notifier, 159 .notifier_call = acpi_thermal_cpufreq_notifier,
171}; 160};
172 161
173 162void acpi_thermal_cpufreq_init(void)
174void acpi_thermal_cpufreq_init(void) { 163{
175 int i; 164 int i;
176 165
177 for (i=0; i<NR_CPUS; i++) 166 for (i = 0; i < NR_CPUS; i++)
178 cpufreq_thermal_reduction_pctg[i] = 0; 167 cpufreq_thermal_reduction_pctg[i] = 0;
179 168
180 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); 169 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
170 CPUFREQ_POLICY_NOTIFIER);
181 if (!i) 171 if (!i)
182 acpi_thermal_cpufreq_is_init = 1; 172 acpi_thermal_cpufreq_is_init = 1;
183} 173}
184 174
185void acpi_thermal_cpufreq_exit(void) { 175void acpi_thermal_cpufreq_exit(void)
176{
186 if (acpi_thermal_cpufreq_is_init) 177 if (acpi_thermal_cpufreq_is_init)
187 cpufreq_unregister_notifier(&acpi_thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); 178 cpufreq_unregister_notifier
179 (&acpi_thermal_cpufreq_notifier_block,
180 CPUFREQ_POLICY_NOTIFIER);
188 181
189 acpi_thermal_cpufreq_is_init = 0; 182 acpi_thermal_cpufreq_is_init = 0;
190} 183}
191 184
192#else /* ! CONFIG_CPU_FREQ */ 185#else /* ! CONFIG_CPU_FREQ */
193
194static int acpi_thermal_cpufreq_increase(unsigned int cpu) { return -ENODEV; }
195static int acpi_thermal_cpufreq_decrease(unsigned int cpu) { return -ENODEV; }
196 186
187static int acpi_thermal_cpufreq_increase(unsigned int cpu)
188{
189 return -ENODEV;
190}
191static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
192{
193 return -ENODEV;
194}
197 195
198#endif 196#endif
199 197
200 198int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
201int
202acpi_processor_set_thermal_limit (
203 acpi_handle handle,
204 int type)
205{ 199{
206 int result = 0; 200 int result = 0;
207 struct acpi_processor *pr = NULL; 201 struct acpi_processor *pr = NULL;
208 struct acpi_device *device = NULL; 202 struct acpi_device *device = NULL;
209 int tx = 0; 203 int tx = 0;
210 204
211 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
212 206
213 if ((type < ACPI_PROCESSOR_LIMIT_NONE) 207 if ((type < ACPI_PROCESSOR_LIMIT_NONE)
214 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) 208 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
215 return_VALUE(-EINVAL); 209 return_VALUE(-EINVAL);
216 210
217 result = acpi_bus_get_device(handle, &device); 211 result = acpi_bus_get_device(handle, &device);
218 if (result) 212 if (result)
219 return_VALUE(result); 213 return_VALUE(result);
220 214
221 pr = (struct acpi_processor *) acpi_driver_data(device); 215 pr = (struct acpi_processor *)acpi_driver_data(device);
222 if (!pr) 216 if (!pr)
223 return_VALUE(-ENODEV); 217 return_VALUE(-ENODEV);
224 218
@@ -250,12 +244,12 @@ acpi_processor_set_thermal_limit (
250 goto end; 244 goto end;
251 else if (result == -ERANGE) 245 else if (result == -ERANGE)
252 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 246 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
253 "At maximum performance state\n")); 247 "At maximum performance state\n"));
254 248
255 if (pr->flags.throttling) { 249 if (pr->flags.throttling) {
256 if (tx == (pr->throttling.state_count - 1)) 250 if (tx == (pr->throttling.state_count - 1))
257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 251 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
258 "At maximum throttling state\n")); 252 "At maximum throttling state\n"));
259 else 253 else
260 tx++; 254 tx++;
261 } 255 }
@@ -267,7 +261,7 @@ acpi_processor_set_thermal_limit (
267 if (pr->flags.throttling) { 261 if (pr->flags.throttling) {
268 if (tx == 0) 262 if (tx == 0)
269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 263 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
270 "At minimum throttling state\n")); 264 "At minimum throttling state\n"));
271 else { 265 else {
272 tx--; 266 tx--;
273 goto end; 267 goto end;
@@ -277,12 +271,12 @@ acpi_processor_set_thermal_limit (
277 result = acpi_thermal_cpufreq_decrease(pr->id); 271 result = acpi_thermal_cpufreq_decrease(pr->id);
278 if (result == -ERANGE) 272 if (result == -ERANGE)
279 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "At minimum performance state\n")); 274 "At minimum performance state\n"));
281 275
282 break; 276 break;
283 } 277 }
284 278
285end: 279 end:
286 if (pr->flags.throttling) { 280 if (pr->flags.throttling) {
287 pr->limit.thermal.px = 0; 281 pr->limit.thermal.px = 0;
288 pr->limit.thermal.tx = tx; 282 pr->limit.thermal.tx = tx;
@@ -293,18 +287,14 @@ end:
293 "Unable to set thermal limit\n")); 287 "Unable to set thermal limit\n"));
294 288
295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", 289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
296 pr->limit.thermal.px, 290 pr->limit.thermal.px, pr->limit.thermal.tx));
297 pr->limit.thermal.tx));
298 } else 291 } else
299 result = 0; 292 result = 0;
300 293
301 return_VALUE(result); 294 return_VALUE(result);
302} 295}
303 296
304 297int acpi_processor_get_limit_info(struct acpi_processor *pr)
305int
306acpi_processor_get_limit_info (
307 struct acpi_processor *pr)
308{ 298{
309 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info"); 299 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
310 300
@@ -317,12 +307,11 @@ acpi_processor_get_limit_info (
317 return_VALUE(0); 307 return_VALUE(0);
318} 308}
319 309
320
321/* /proc interface */ 310/* /proc interface */
322 311
323static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) 312static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
324{ 313{
325 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 314 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
326 315
327 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show"); 316 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
328 317
@@ -335,34 +324,32 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
335 } 324 }
336 325
337 seq_printf(seq, "active limit: P%d:T%d\n" 326 seq_printf(seq, "active limit: P%d:T%d\n"
338 "user limit: P%d:T%d\n" 327 "user limit: P%d:T%d\n"
339 "thermal limit: P%d:T%d\n", 328 "thermal limit: P%d:T%d\n",
340 pr->limit.state.px, pr->limit.state.tx, 329 pr->limit.state.px, pr->limit.state.tx,
341 pr->limit.user.px, pr->limit.user.tx, 330 pr->limit.user.px, pr->limit.user.tx,
342 pr->limit.thermal.px, pr->limit.thermal.tx); 331 pr->limit.thermal.px, pr->limit.thermal.tx);
343 332
344end: 333 end:
345 return_VALUE(0); 334 return_VALUE(0);
346} 335}
347 336
348static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) 337static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
349{ 338{
350 return single_open(file, acpi_processor_limit_seq_show, 339 return single_open(file, acpi_processor_limit_seq_show,
351 PDE(inode)->data); 340 PDE(inode)->data);
352} 341}
353 342
354ssize_t acpi_processor_write_limit ( 343ssize_t acpi_processor_write_limit(struct file * file,
355 struct file *file, 344 const char __user * buffer,
356 const char __user *buffer, 345 size_t count, loff_t * data)
357 size_t count,
358 loff_t *data)
359{ 346{
360 int result = 0; 347 int result = 0;
361 struct seq_file *m = (struct seq_file *)file->private_data; 348 struct seq_file *m = (struct seq_file *)file->private_data;
362 struct acpi_processor *pr = (struct acpi_processor *)m->private; 349 struct acpi_processor *pr = (struct acpi_processor *)m->private;
363 char limit_string[25] = {'\0'}; 350 char limit_string[25] = { '\0' };
364 int px = 0; 351 int px = 0;
365 int tx = 0; 352 int tx = 0;
366 353
367 ACPI_FUNCTION_TRACE("acpi_processor_write_limit"); 354 ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
368 355
@@ -396,11 +383,9 @@ ssize_t acpi_processor_write_limit (
396 return_VALUE(count); 383 return_VALUE(count);
397} 384}
398 385
399
400struct file_operations acpi_processor_limit_fops = { 386struct file_operations acpi_processor_limit_fops = {
401 .open = acpi_processor_limit_open_fs, 387 .open = acpi_processor_limit_open_fs,
402 .read = seq_read, 388 .read = seq_read,
403 .llseek = seq_lseek, 389 .llseek = seq_lseek,
404 .release = single_release, 390 .release = single_release,
405}; 391};
406
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index be9f569d39d3..74a52d4e79ae 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -43,21 +43,17 @@
43#define ACPI_PROCESSOR_CLASS "processor" 43#define ACPI_PROCESSOR_CLASS "processor"
44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
45#define _COMPONENT ACPI_PROCESSOR_COMPONENT 45#define _COMPONENT ACPI_PROCESSOR_COMPONENT
46ACPI_MODULE_NAME ("acpi_processor") 46ACPI_MODULE_NAME("acpi_processor")
47
48 47
49/* -------------------------------------------------------------------------- 48/* --------------------------------------------------------------------------
50 Throttling Control 49 Throttling Control
51 -------------------------------------------------------------------------- */ 50 -------------------------------------------------------------------------- */
52 51static int acpi_processor_get_throttling(struct acpi_processor *pr)
53static int
54acpi_processor_get_throttling (
55 struct acpi_processor *pr)
56{ 52{
57 int state = 0; 53 int state = 0;
58 u32 value = 0; 54 u32 value = 0;
59 u32 duty_mask = 0; 55 u32 duty_mask = 0;
60 u32 duty_value = 0; 56 u32 duty_value = 0;
61 57
62 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling"); 58 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
63 59
@@ -86,7 +82,7 @@ acpi_processor_get_throttling (
86 duty_value >>= pr->throttling.duty_offset; 82 duty_value >>= pr->throttling.duty_offset;
87 83
88 if (duty_value) 84 if (duty_value)
89 state = pr->throttling.state_count-duty_value; 85 state = pr->throttling.state_count - duty_value;
90 } 86 }
91 87
92 pr->throttling.state = state; 88 pr->throttling.state = state;
@@ -94,20 +90,17 @@ acpi_processor_get_throttling (
94 local_irq_enable(); 90 local_irq_enable();
95 91
96 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 92 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
97 "Throttling state is T%d (%d%% throttling applied)\n", 93 "Throttling state is T%d (%d%% throttling applied)\n",
98 state, pr->throttling.states[state].performance)); 94 state, pr->throttling.states[state].performance));
99 95
100 return_VALUE(0); 96 return_VALUE(0);
101} 97}
102 98
103 99int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
104int acpi_processor_set_throttling (
105 struct acpi_processor *pr,
106 int state)
107{ 100{
108 u32 value = 0; 101 u32 value = 0;
109 u32 duty_mask = 0; 102 u32 duty_mask = 0;
110 u32 duty_value = 0; 103 u32 duty_value = 0;
111 104
112 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling"); 105 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
113 106
@@ -168,28 +161,26 @@ int acpi_processor_set_throttling (
168 local_irq_enable(); 161 local_irq_enable();
169 162
170 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 163 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
171 "Throttling state set to T%d (%d%%)\n", state, 164 "Throttling state set to T%d (%d%%)\n", state,
172 (pr->throttling.states[state].performance?pr->throttling.states[state].performance/10:0))); 165 (pr->throttling.states[state].performance ? pr->
166 throttling.states[state].performance / 10 : 0)));
173 167
174 return_VALUE(0); 168 return_VALUE(0);
175} 169}
176 170
177 171int acpi_processor_get_throttling_info(struct acpi_processor *pr)
178int
179acpi_processor_get_throttling_info (
180 struct acpi_processor *pr)
181{ 172{
182 int result = 0; 173 int result = 0;
183 int step = 0; 174 int step = 0;
184 int i = 0; 175 int i = 0;
185 176
186 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info"); 177 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
187 178
188 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
189 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 180 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
190 pr->throttling.address, 181 pr->throttling.address,
191 pr->throttling.duty_offset, 182 pr->throttling.duty_offset,
192 pr->throttling.duty_width)); 183 pr->throttling.duty_width));
193 184
194 if (!pr) 185 if (!pr)
195 return_VALUE(-EINVAL); 186 return_VALUE(-EINVAL);
@@ -199,14 +190,12 @@ acpi_processor_get_throttling_info (
199 if (!pr->throttling.address) { 190 if (!pr->throttling.address) {
200 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
201 return_VALUE(0); 192 return_VALUE(0);
202 } 193 } else if (!pr->throttling.duty_width) {
203 else if (!pr->throttling.duty_width) {
204 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); 194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
205 return_VALUE(0); 195 return_VALUE(0);
206 } 196 }
207 /* TBD: Support duty_cycle values that span bit 4. */ 197 /* TBD: Support duty_cycle values that span bit 4. */
208 else if ((pr->throttling.duty_offset 198 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
209 + pr->throttling.duty_width) > 4) {
210 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); 199 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n"));
211 return_VALUE(0); 200 return_VALUE(0);
212 } 201 }
@@ -218,7 +207,7 @@ acpi_processor_get_throttling_info (
218 */ 207 */
219 if (errata.piix4.throttle) { 208 if (errata.piix4.throttle) {
220 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 209 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
221 "Throttling not supported on PIIX4 A- or B-step\n")); 210 "Throttling not supported on PIIX4 A- or B-step\n"));
222 return_VALUE(0); 211 return_VALUE(0);
223 } 212 }
224 213
@@ -232,13 +221,13 @@ acpi_processor_get_throttling_info (
232 221
233 step = (1000 / pr->throttling.state_count); 222 step = (1000 / pr->throttling.state_count);
234 223
235 for (i=0; i<pr->throttling.state_count; i++) { 224 for (i = 0; i < pr->throttling.state_count; i++) {
236 pr->throttling.states[i].performance = step * i; 225 pr->throttling.states[i].performance = step * i;
237 pr->throttling.states[i].power = step * i; 226 pr->throttling.states[i].power = step * i;
238 } 227 }
239 228
240 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
241 pr->throttling.state_count)); 230 pr->throttling.state_count));
242 231
243 pr->flags.throttling = 1; 232 pr->flags.throttling = 1;
244 233
@@ -253,28 +242,29 @@ acpi_processor_get_throttling_info (
253 goto end; 242 goto end;
254 243
255 if (pr->throttling.state) { 244 if (pr->throttling.state) {
256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n", 245 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
257 pr->throttling.state)); 246 "Disabling throttling (was T%d)\n",
247 pr->throttling.state));
258 result = acpi_processor_set_throttling(pr, 0); 248 result = acpi_processor_set_throttling(pr, 0);
259 if (result) 249 if (result)
260 goto end; 250 goto end;
261 } 251 }
262 252
263end: 253 end:
264 if (result) 254 if (result)
265 pr->flags.throttling = 0; 255 pr->flags.throttling = 0;
266 256
267 return_VALUE(result); 257 return_VALUE(result);
268} 258}
269 259
270
271/* proc interface */ 260/* proc interface */
272 261
273static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset) 262static int acpi_processor_throttling_seq_show(struct seq_file *seq,
263 void *offset)
274{ 264{
275 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 265 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
276 int i = 0; 266 int i = 0;
277 int result = 0; 267 int result = 0;
278 268
279 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show"); 269 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
280 270
@@ -289,41 +279,41 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset
289 result = acpi_processor_get_throttling(pr); 279 result = acpi_processor_get_throttling(pr);
290 280
291 if (result) { 281 if (result) {
292 seq_puts(seq, "Could not determine current throttling state.\n"); 282 seq_puts(seq,
283 "Could not determine current throttling state.\n");
293 goto end; 284 goto end;
294 } 285 }
295 286
296 seq_printf(seq, "state count: %d\n" 287 seq_printf(seq, "state count: %d\n"
297 "active state: T%d\n", 288 "active state: T%d\n",
298 pr->throttling.state_count, 289 pr->throttling.state_count, pr->throttling.state);
299 pr->throttling.state);
300 290
301 seq_puts(seq, "states:\n"); 291 seq_puts(seq, "states:\n");
302 for (i = 0; i < pr->throttling.state_count; i++) 292 for (i = 0; i < pr->throttling.state_count; i++)
303 seq_printf(seq, " %cT%d: %02d%%\n", 293 seq_printf(seq, " %cT%d: %02d%%\n",
304 (i == pr->throttling.state?'*':' '), i, 294 (i == pr->throttling.state ? '*' : ' '), i,
305 (pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0)); 295 (pr->throttling.states[i].performance ? pr->
296 throttling.states[i].performance / 10 : 0));
306 297
307end: 298 end:
308 return_VALUE(0); 299 return_VALUE(0);
309} 300}
310 301
311static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file) 302static int acpi_processor_throttling_open_fs(struct inode *inode,
303 struct file *file)
312{ 304{
313 return single_open(file, acpi_processor_throttling_seq_show, 305 return single_open(file, acpi_processor_throttling_seq_show,
314 PDE(inode)->data); 306 PDE(inode)->data);
315} 307}
316 308
317ssize_t acpi_processor_write_throttling ( 309ssize_t acpi_processor_write_throttling(struct file * file,
318 struct file *file, 310 const char __user * buffer,
319 const char __user *buffer, 311 size_t count, loff_t * data)
320 size_t count,
321 loff_t *data)
322{ 312{
323 int result = 0; 313 int result = 0;
324 struct seq_file *m = (struct seq_file *)file->private_data; 314 struct seq_file *m = (struct seq_file *)file->private_data;
325 struct acpi_processor *pr = (struct acpi_processor *)m->private; 315 struct acpi_processor *pr = (struct acpi_processor *)m->private;
326 char state_string[12] = {'\0'}; 316 char state_string[12] = { '\0' };
327 317
328 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); 318 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
329 319
@@ -336,7 +326,8 @@ ssize_t acpi_processor_write_throttling (
336 state_string[count] = '\0'; 326 state_string[count] = '\0';
337 327
338 result = acpi_processor_set_throttling(pr, 328 result = acpi_processor_set_throttling(pr,
339 simple_strtoul(state_string, NULL, 0)); 329 simple_strtoul(state_string,
330 NULL, 0));
340 if (result) 331 if (result)
341 return_VALUE(result); 332 return_VALUE(result);
342 333
@@ -344,8 +335,8 @@ ssize_t acpi_processor_write_throttling (
344} 335}
345 336
346struct file_operations acpi_processor_throttling_fops = { 337struct file_operations acpi_processor_throttling_fops = {
347 .open = acpi_processor_throttling_open_fs, 338 .open = acpi_processor_throttling_open_fs,
348 .read = seq_read, 339 .read = seq_read,
349 .llseek = seq_lseek, 340 .llseek = seq_lseek,
350 .release = single_release, 341 .release = single_release,
351}; 342};
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 55d264771c48..23b54baa0cb2 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -41,13 +41,185 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsaddr") 48ACPI_MODULE_NAME("rsaddr")
49
50/* Local prototypes */
51static void
52acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags);
53
54static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource);
55
56static void
57acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
58
59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
60
61/*******************************************************************************
62 *
63 * FUNCTION: acpi_rs_decode_general_flags
64 *
65 * PARAMETERS: Resource - Address resource data struct
66 * Flags - Actual flag byte
67 *
68 * RETURN: Decoded flag bits in resource struct
69 *
70 * DESCRIPTION: Decode a general flag byte to an address resource struct
71 *
72 ******************************************************************************/
73
74static void
75acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags)
76{
77 ACPI_FUNCTION_ENTRY();
78
79 /* Producer / Consumer - flag bit[0] */
80
81 resource->address.producer_consumer = (u32) (flags & 0x01);
82
83 /* Decode (_DEC) - flag bit[1] */
50 84
85 resource->address.decode = (u32) ((flags >> 1) & 0x01);
86
87 /* Min Address Fixed (_MIF) - flag bit[2] */
88
89 resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01);
90
91 /* Max Address Fixed (_MAF) - flag bit[3] */
92
93 resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01);
94}
95
96/*******************************************************************************
97 *
98 * FUNCTION: acpi_rs_encode_general_flags
99 *
100 * PARAMETERS: Resource - Address resource data struct
101 *
102 * RETURN: Encoded general flag byte
103 *
104 * DESCRIPTION: Construct a general flag byte from an address resource struct
105 *
106 ******************************************************************************/
107
108static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
109{
110 u8 flags;
111
112 ACPI_FUNCTION_ENTRY();
113
114 /* Producer / Consumer - flag bit[0] */
115
116 flags = (u8) (resource->address.producer_consumer & 0x01);
117
118 /* Decode (_DEC) - flag bit[1] */
119
120 flags |= (u8) ((resource->address.decode & 0x01) << 1);
121
122 /* Min Address Fixed (_MIF) - flag bit[2] */
123
124 flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2);
125
126 /* Max Address Fixed (_MAF) - flag bit[3] */
127
128 flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3);
129
130 return (flags);
131}
132
133/*******************************************************************************
134 *
135 * FUNCTION: acpi_rs_decode_specific_flags
136 *
137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Actual flag byte
139 *
140 * RETURN: Decoded flag bits in attribute struct
141 *
142 * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
143 * Type-specific flags are only defined for the Memory and IO
144 * resource types.
145 *
146 ******************************************************************************/
147
148static void
149acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags)
150{
151 ACPI_FUNCTION_ENTRY();
152
153 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
154 /* Write Status (_RW) - flag bit[0] */
155
156 resource->address.attribute.memory.read_write_attribute =
157 (u16) (flags & 0x01);
158
159 /* Memory Attributes (_MEM) - flag bits[2:1] */
160
161 resource->address.attribute.memory.cache_attribute =
162 (u16) ((flags >> 1) & 0x03);
163 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
164 /* Ranges (_RNG) - flag bits[1:0] */
165
166 resource->address.attribute.io.range_attribute =
167 (u16) (flags & 0x03);
168
169 /* Translations (_TTP and _TRS) - flag bits[5:4] */
170
171 resource->address.attribute.io.translation_attribute =
172 (u16) ((flags >> 4) & 0x03);
173 }
174}
175
176/*******************************************************************************
177 *
178 * FUNCTION: acpi_rs_encode_specific_flags
179 *
180 * PARAMETERS: Resource - Address resource data struct
181 *
182 * RETURN: Encoded type-specific flag byte
183 *
184 * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
185 * Type-specific flags are only defined for the Memory and IO
186 * resource types.
187 *
188 ******************************************************************************/
189
190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource)
191{
192 u8 flags = 0;
193
194 ACPI_FUNCTION_ENTRY();
195
196 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
197 /* Write Status (_RW) - flag bit[0] */
198
199 flags = (u8)
200 (resource->address.attribute.memory.
201 read_write_attribute & 0x01);
202
203 /* Memory Attributes (_MEM) - flag bits[2:1] */
204
205 flags |= (u8)
206 ((resource->address.attribute.memory.
207 cache_attribute & 0x03) << 1);
208 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
209 /* Ranges (_RNG) - flag bits[1:0] */
210
211 flags = (u8)
212 (resource->address.attribute.io.range_attribute & 0x03);
213
214 /* Translations (_TTP and _TRS) - flag bits[5:4] */
215
216 flags |= (u8)
217 ((resource->address.attribute.io.
218 translation_attribute & 0x03) << 4);
219 }
220
221 return (flags);
222}
51 223
52/******************************************************************************* 224/*******************************************************************************
53 * 225 *
@@ -71,34 +243,30 @@
71 ******************************************************************************/ 243 ******************************************************************************/
72 244
73acpi_status 245acpi_status
74acpi_rs_address16_resource ( 246acpi_rs_address16_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 247 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 248 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 249{
80 u32 index; 250 u32 index;
81 u16 temp16; 251 u16 temp16;
82 u8 temp8; 252 u8 temp8;
83 u8 *temp_ptr; 253 u8 *temp_ptr;
84 u8 *buffer = byte_stream_buffer; 254 u8 *buffer = byte_stream_buffer;
85 struct acpi_resource *output_struct = (void *) *output_buffer; 255 struct acpi_resource *output_struct = (void *)*output_buffer;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 256 acpi_size struct_size =
87 struct acpi_resource_address16); 257 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
88
89 258
90 ACPI_FUNCTION_TRACE ("rs_address16_resource"); 259 ACPI_FUNCTION_TRACE("rs_address16_resource");
91 260
92 261 /* Get the Descriptor Length field */
93 /* Point past the Descriptor to get the number of bytes consumed */
94 262
95 buffer += 1; 263 buffer += 1;
96 ACPI_MOVE_16_TO_16 (&temp16, buffer); 264 ACPI_MOVE_16_TO_16(&temp16, buffer);
97 265
98 /* Validate minimum descriptor length */ 266 /* Validate minimum descriptor length */
99 267
100 if (temp16 < 13) { 268 if (temp16 < 13) {
101 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 269 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
102 } 270 }
103 271
104 *bytes_consumed = temp16 + 3; 272 *bytes_consumed = temp16 + 3;
@@ -112,7 +280,7 @@ acpi_rs_address16_resource (
112 /* Values 0-2 and 0xC0-0xFF are valid */ 280 /* Values 0-2 and 0xC0-0xFF are valid */
113 281
114 if ((temp8 > 2) && (temp8 < 0xC0)) { 282 if ((temp8 > 2) && (temp8 < 0xC0)) {
115 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 283 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
116 } 284 }
117 285
118 output_struct->data.address16.resource_type = temp8; 286 output_struct->data.address16.resource_type = temp8;
@@ -120,73 +288,41 @@ acpi_rs_address16_resource (
120 /* Get the General Flags (Byte4) */ 288 /* Get the General Flags (Byte4) */
121 289
122 buffer += 1; 290 buffer += 1;
123 temp8 = *buffer; 291 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
124
125 /* Producer / Consumer */
126
127 output_struct->data.address16.producer_consumer = temp8 & 0x01;
128
129 /* Decode */
130
131 output_struct->data.address16.decode = (temp8 >> 1) & 0x01;
132
133 /* Min Address Fixed */
134
135 output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01;
136
137 /* Max Address Fixed */
138
139 output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01;
140 292
141 /* Get the Type Specific Flags (Byte5) */ 293 /* Get the Type Specific Flags (Byte5) */
142 294
143 buffer += 1; 295 buffer += 1;
144 temp8 = *buffer; 296 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
145
146 if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) {
147 output_struct->data.address16.attribute.memory.read_write_attribute =
148 (u16) (temp8 & 0x01);
149 output_struct->data.address16.attribute.memory.cache_attribute =
150 (u16) ((temp8 >> 1) & 0x03);
151 }
152 else {
153 if (ACPI_IO_RANGE == output_struct->data.address16.resource_type) {
154 output_struct->data.address16.attribute.io.range_attribute =
155 (u16) (temp8 & 0x03);
156 output_struct->data.address16.attribute.io.translation_attribute =
157 (u16) ((temp8 >> 4) & 0x03);
158 }
159 else {
160 /* BUS_NUMBER_RANGE == Address16.Data->resource_type */
161 /* Nothing needs to be filled in */
162 }
163 }
164 297
165 /* Get Granularity (Bytes 6-7) */ 298 /* Get Granularity (Bytes 6-7) */
166 299
167 buffer += 1; 300 buffer += 1;
168 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer); 301 ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
169 302
170 /* Get min_address_range (Bytes 8-9) */ 303 /* Get min_address_range (Bytes 8-9) */
171 304
172 buffer += 2; 305 buffer += 2;
173 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer); 306 ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
307 buffer);
174 308
175 /* Get max_address_range (Bytes 10-11) */ 309 /* Get max_address_range (Bytes 10-11) */
176 310
177 buffer += 2; 311 buffer += 2;
178 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer); 312 ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
313 buffer);
179 314
180 /* Get address_translation_offset (Bytes 12-13) */ 315 /* Get address_translation_offset (Bytes 12-13) */
181 316
182 buffer += 2; 317 buffer += 2;
183 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, 318 ACPI_MOVE_16_TO_32(&output_struct->data.address16.
184 buffer); 319 address_translation_offset, buffer);
185 320
186 /* Get address_length (Bytes 14-15) */ 321 /* Get address_length (Bytes 14-15) */
187 322
188 buffer += 2; 323 buffer += 2;
189 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer); 324 ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length,
325 buffer);
190 326
191 /* Resource Source Index (if present) */ 327 /* Resource Source Index (if present) */
192 328
@@ -205,8 +341,8 @@ acpi_rs_address16_resource (
205 if (*bytes_consumed > (16 + 1)) { 341 if (*bytes_consumed > (16 + 1)) {
206 /* Dereference the Index */ 342 /* Dereference the Index */
207 343
208 temp8 = *buffer; 344 output_struct->data.address16.resource_source.index =
209 output_struct->data.address16.resource_source.index = (u32) temp8; 345 (u32) * buffer;
210 346
211 /* Point to the String */ 347 /* Point to the String */
212 348
@@ -215,28 +351,27 @@ acpi_rs_address16_resource (
215 /* Point the String pointer to the end of this structure */ 351 /* Point the String pointer to the end of this structure */
216 352
217 output_struct->data.address16.resource_source.string_ptr = 353 output_struct->data.address16.resource_source.string_ptr =
218 (char *)((u8 * )output_struct + struct_size); 354 (char *)((u8 *) output_struct + struct_size);
219 355
220 temp_ptr = (u8 *) 356 temp_ptr = (u8 *)
221 output_struct->data.address16.resource_source.string_ptr; 357 output_struct->data.address16.resource_source.string_ptr;
222 358
223 /* Copy the string into the buffer */ 359 /* Copy the resource_source string into the buffer */
224 360
225 index = 0; 361 index = 0;
226 362 while (*buffer) {
227 while (0x00 != *buffer) {
228 *temp_ptr = *buffer; 363 *temp_ptr = *buffer;
229 364
230 temp_ptr += 1; 365 temp_ptr++;
231 buffer += 1; 366 buffer++;
232 index += 1; 367 index++;
233 } 368 }
234 369
235 /* Add the terminating null */ 370 /* Add the terminating null and set the string length */
236
237 *temp_ptr = 0x00;
238 371
239 output_struct->data.address16.resource_source.string_length = index + 1; 372 *temp_ptr = 0;
373 output_struct->data.address16.resource_source.string_length =
374 index + 1;
240 375
241 /* 376 /*
242 * In order for the struct_size to fall on a 32-bit boundary, 377 * In order for the struct_size to fall on a 32-bit boundary,
@@ -244,10 +379,9 @@ acpi_rs_address16_resource (
244 * struct_size to the next 32-bit boundary. 379 * struct_size to the next 32-bit boundary.
245 */ 380 */
246 temp8 = (u8) (index + 1); 381 temp8 = (u8) (index + 1);
247 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 382 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
248 } 383 } else {
249 else { 384 output_struct->data.address16.resource_source.index = 0;
250 output_struct->data.address16.resource_source.index = 0x00;
251 output_struct->data.address16.resource_source.string_length = 0; 385 output_struct->data.address16.resource_source.string_length = 0;
252 output_struct->data.address16.resource_source.string_ptr = NULL; 386 output_struct->data.address16.resource_source.string_ptr = NULL;
253 } 387 }
@@ -259,10 +393,9 @@ acpi_rs_address16_resource (
259 /* Return the final size of the structure */ 393 /* Return the final size of the structure */
260 394
261 *structure_size = struct_size; 395 *structure_size = struct_size;
262 return_ACPI_STATUS (AE_OK); 396 return_ACPI_STATUS(AE_OK);
263} 397}
264 398
265
266/******************************************************************************* 399/*******************************************************************************
267 * 400 *
268 * FUNCTION: acpi_rs_address16_stream 401 * FUNCTION: acpi_rs_address16_stream
@@ -280,24 +413,18 @@ acpi_rs_address16_resource (
280 ******************************************************************************/ 413 ******************************************************************************/
281 414
282acpi_status 415acpi_status
283acpi_rs_address16_stream ( 416acpi_rs_address16_stream(struct acpi_resource *linked_list,
284 struct acpi_resource *linked_list, 417 u8 ** output_buffer, acpi_size * bytes_consumed)
285 u8 **output_buffer,
286 acpi_size *bytes_consumed)
287{ 418{
288 u8 *buffer = *output_buffer; 419 u8 *buffer = *output_buffer;
289 u8 *length_field; 420 u8 *length_field;
290 u8 temp8; 421 acpi_size actual_bytes;
291 char *temp_pointer = NULL;
292 acpi_size actual_bytes;
293
294
295 ACPI_FUNCTION_TRACE ("rs_address16_stream");
296 422
423 ACPI_FUNCTION_TRACE("rs_address16_stream");
297 424
298 /* The descriptor field is static */ 425 /* Set the Descriptor Type field */
299 426
300 *buffer = 0x88; 427 *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
301 buffer += 1; 428 buffer += 1;
302 429
303 /* Save a pointer to the Length field - to be filled in later */ 430 /* Save a pointer to the Length field - to be filled in later */
@@ -307,98 +434,74 @@ acpi_rs_address16_stream (
307 434
308 /* Set the Resource Type (Memory, Io, bus_number) */ 435 /* Set the Resource Type (Memory, Io, bus_number) */
309 436
310 temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); 437 *buffer = (u8) (linked_list->data.address16.resource_type & 0x03);
311 *buffer = temp8;
312 buffer += 1; 438 buffer += 1;
313 439
314 /* Set the general flags */ 440 /* Set the general flags */
315 441
316 temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); 442 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
317
318 temp8 |= (linked_list->data.address16.decode & 0x01) << 1;
319 temp8 |= (linked_list->data.address16.min_address_fixed & 0x01) << 2;
320 temp8 |= (linked_list->data.address16.max_address_fixed & 0x01) << 3;
321
322 *buffer = temp8;
323 buffer += 1; 443 buffer += 1;
324 444
325 /* Set the type specific flags */ 445 /* Set the type specific flags */
326 446
327 temp8 = 0; 447 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
328
329 if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
330 temp8 = (u8)
331 (linked_list->data.address16.attribute.memory.read_write_attribute &
332 0x01);
333
334 temp8 |=
335 (linked_list->data.address16.attribute.memory.cache_attribute &
336 0x03) << 1;
337 }
338 else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) {
339 temp8 = (u8)
340 (linked_list->data.address16.attribute.io.range_attribute &
341 0x03);
342 temp8 |=
343 (linked_list->data.address16.attribute.io.translation_attribute &
344 0x03) << 4;
345 }
346
347 *buffer = temp8;
348 buffer += 1; 448 buffer += 1;
349 449
350 /* Set the address space granularity */ 450 /* Set the address space granularity */
351 451
352 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity); 452 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.granularity);
353 buffer += 2; 453 buffer += 2;
354 454
355 /* Set the address range minimum */ 455 /* Set the address range minimum */
356 456
357 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range); 457 ACPI_MOVE_32_TO_16(buffer,
458 &linked_list->data.address16.min_address_range);
358 buffer += 2; 459 buffer += 2;
359 460
360 /* Set the address range maximum */ 461 /* Set the address range maximum */
361 462
362 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range); 463 ACPI_MOVE_32_TO_16(buffer,
464 &linked_list->data.address16.max_address_range);
363 buffer += 2; 465 buffer += 2;
364 466
365 /* Set the address translation offset */ 467 /* Set the address translation offset */
366 468
367 ACPI_MOVE_32_TO_16 (buffer, 469 ACPI_MOVE_32_TO_16(buffer,
368 &linked_list->data.address16.address_translation_offset); 470 &linked_list->data.address16.
471 address_translation_offset);
369 buffer += 2; 472 buffer += 2;
370 473
371 /* Set the address length */ 474 /* Set the address length */
372 475
373 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length); 476 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.address_length);
374 buffer += 2; 477 buffer += 2;
375 478
376 /* Resource Source Index and Resource Source are optional */ 479 /* Resource Source Index and Resource Source are optional */
377 480
378 if (0 != linked_list->data.address16.resource_source.string_length) { 481 if (linked_list->data.address16.resource_source.string_length) {
379 temp8 = (u8) linked_list->data.address16.resource_source.index; 482 *buffer =
380 483 (u8) linked_list->data.address16.resource_source.index;
381 *buffer = temp8;
382 buffer += 1; 484 buffer += 1;
383 485
384 temp_pointer = (char *) buffer; 486 /* Copy the resource_source string */
385
386 /* Copy the string */
387 487
388 ACPI_STRCPY (temp_pointer, 488 ACPI_STRCPY((char *)buffer,
389 linked_list->data.address16.resource_source.string_ptr); 489 linked_list->data.address16.resource_source.
490 string_ptr);
390 491
391 /* 492 /*
392 * Buffer needs to be set to the length of the sting + one for the 493 * Buffer needs to be set to the length of the string + one for the
393 * terminating null 494 * terminating null
394 */ 495 */
395 buffer += (acpi_size)(ACPI_STRLEN ( 496 buffer +=
396 linked_list->data.address16.resource_source.string_ptr) + 1); 497 (acpi_size) (ACPI_STRLEN
498 (linked_list->data.address16.resource_source.
499 string_ptr) + 1);
397 } 500 }
398 501
399 /* Return the number of bytes consumed in this operation */ 502 /* Return the number of bytes consumed in this operation */
400 503
401 actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer); 504 actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
402 *bytes_consumed = actual_bytes; 505 *bytes_consumed = actual_bytes;
403 506
404 /* 507 /*
@@ -406,11 +509,10 @@ acpi_rs_address16_stream (
406 * minus the header size (3 bytes) 509 * minus the header size (3 bytes)
407 */ 510 */
408 actual_bytes -= 3; 511 actual_bytes -= 3;
409 ACPI_MOVE_SIZE_TO_16 (length_field, &actual_bytes); 512 ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
410 return_ACPI_STATUS (AE_OK); 513 return_ACPI_STATUS(AE_OK);
411} 514}
412 515
413
414/******************************************************************************* 516/*******************************************************************************
415 * 517 *
416 * FUNCTION: acpi_rs_address32_resource 518 * FUNCTION: acpi_rs_address32_resource
@@ -433,36 +535,30 @@ acpi_rs_address16_stream (
433 ******************************************************************************/ 535 ******************************************************************************/
434 536
435acpi_status 537acpi_status
436acpi_rs_address32_resource ( 538acpi_rs_address32_resource(u8 * byte_stream_buffer,
437 u8 *byte_stream_buffer, 539 acpi_size * bytes_consumed,
438 acpi_size *bytes_consumed, 540 u8 ** output_buffer, acpi_size * structure_size)
439 u8 **output_buffer,
440 acpi_size *structure_size)
441{ 541{
442 u8 *buffer; 542 u16 temp16;
443 struct acpi_resource *output_struct= (void *) *output_buffer; 543 u8 temp8;
444 u16 temp16; 544 u8 *temp_ptr;
445 u8 temp8; 545 u32 index;
446 u8 *temp_ptr; 546 u8 *buffer = byte_stream_buffer;
447 acpi_size struct_size; 547 struct acpi_resource *output_struct = (void *)*output_buffer;
448 u32 index; 548 acpi_size struct_size =
449 549 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
450
451 ACPI_FUNCTION_TRACE ("rs_address32_resource");
452 550
551 ACPI_FUNCTION_TRACE("rs_address32_resource");
453 552
454 buffer = byte_stream_buffer; 553 /* Get the Descriptor Length field */
455 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32);
456
457 /* Point past the Descriptor to get the number of bytes consumed */
458 554
459 buffer += 1; 555 buffer += 1;
460 ACPI_MOVE_16_TO_16 (&temp16, buffer); 556 ACPI_MOVE_16_TO_16(&temp16, buffer);
461 557
462 /* Validate minimum descriptor length */ 558 /* Validate minimum descriptor length */
463 559
464 if (temp16 < 23) { 560 if (temp16 < 23) {
465 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 561 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
466 } 562 }
467 563
468 *bytes_consumed = temp16 + 3; 564 *bytes_consumed = temp16 + 3;
@@ -476,7 +572,7 @@ acpi_rs_address32_resource (
476 /* Values 0-2 and 0xC0-0xFF are valid */ 572 /* Values 0-2 and 0xC0-0xFF are valid */
477 573
478 if ((temp8 > 2) && (temp8 < 0xC0)) { 574 if ((temp8 > 2) && (temp8 < 0xC0)) {
479 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 575 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
480 } 576 }
481 577
482 output_struct->data.address32.resource_type = temp8; 578 output_struct->data.address32.resource_type = temp8;
@@ -484,74 +580,41 @@ acpi_rs_address32_resource (
484 /* Get the General Flags (Byte4) */ 580 /* Get the General Flags (Byte4) */
485 581
486 buffer += 1; 582 buffer += 1;
487 temp8 = *buffer; 583 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
488
489 /* Producer / Consumer */
490
491 output_struct->data.address32.producer_consumer = temp8 & 0x01;
492
493 /* Decode */
494
495 output_struct->data.address32.decode = (temp8 >> 1) & 0x01;
496
497 /* Min Address Fixed */
498
499 output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01;
500
501 /* Max Address Fixed */
502
503 output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01;
504 584
505 /* Get the Type Specific Flags (Byte5) */ 585 /* Get the Type Specific Flags (Byte5) */
506 586
507 buffer += 1; 587 buffer += 1;
508 temp8 = *buffer; 588 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
509
510 if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) {
511 output_struct->data.address32.attribute.memory.read_write_attribute =
512 (u16) (temp8 & 0x01);
513
514 output_struct->data.address32.attribute.memory.cache_attribute =
515 (u16) ((temp8 >> 1) & 0x03);
516 }
517 else {
518 if (ACPI_IO_RANGE == output_struct->data.address32.resource_type) {
519 output_struct->data.address32.attribute.io.range_attribute =
520 (u16) (temp8 & 0x03);
521 output_struct->data.address32.attribute.io.translation_attribute =
522 (u16) ((temp8 >> 4) & 0x03);
523 }
524 else {
525 /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */
526 /* Nothing needs to be filled in */
527 }
528 }
529 589
530 /* Get Granularity (Bytes 6-9) */ 590 /* Get Granularity (Bytes 6-9) */
531 591
532 buffer += 1; 592 buffer += 1;
533 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer); 593 ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
534 594
535 /* Get min_address_range (Bytes 10-13) */ 595 /* Get min_address_range (Bytes 10-13) */
536 596
537 buffer += 4; 597 buffer += 4;
538 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer); 598 ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
599 buffer);
539 600
540 /* Get max_address_range (Bytes 14-17) */ 601 /* Get max_address_range (Bytes 14-17) */
541 602
542 buffer += 4; 603 buffer += 4;
543 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer); 604 ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
605 buffer);
544 606
545 /* Get address_translation_offset (Bytes 18-21) */ 607 /* Get address_translation_offset (Bytes 18-21) */
546 608
547 buffer += 4; 609 buffer += 4;
548 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, 610 ACPI_MOVE_32_TO_32(&output_struct->data.address32.
549 buffer); 611 address_translation_offset, buffer);
550 612
551 /* Get address_length (Bytes 22-25) */ 613 /* Get address_length (Bytes 22-25) */
552 614
553 buffer += 4; 615 buffer += 4;
554 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer); 616 ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
617 buffer);
555 618
556 /* Resource Source Index (if present) */ 619 /* Resource Source Index (if present) */
557 620
@@ -568,9 +631,8 @@ acpi_rs_address32_resource (
568 if (*bytes_consumed > (26 + 1)) { 631 if (*bytes_consumed > (26 + 1)) {
569 /* Dereference the Index */ 632 /* Dereference the Index */
570 633
571 temp8 = *buffer;
572 output_struct->data.address32.resource_source.index = 634 output_struct->data.address32.resource_source.index =
573 (u32) temp8; 635 (u32) * buffer;
574 636
575 /* Point to the String */ 637 /* Point to the String */
576 638
@@ -579,26 +641,27 @@ acpi_rs_address32_resource (
579 /* Point the String pointer to the end of this structure */ 641 /* Point the String pointer to the end of this structure */
580 642
581 output_struct->data.address32.resource_source.string_ptr = 643 output_struct->data.address32.resource_source.string_ptr =
582 (char *)((u8 *)output_struct + struct_size); 644 (char *)((u8 *) output_struct + struct_size);
583 645
584 temp_ptr = (u8 *) 646 temp_ptr = (u8 *)
585 output_struct->data.address32.resource_source.string_ptr; 647 output_struct->data.address32.resource_source.string_ptr;
586 648
587 /* Copy the string into the buffer */ 649 /* Copy the resource_source string into the buffer */
588 650
589 index = 0; 651 index = 0;
590 while (0x00 != *buffer) { 652 while (*buffer) {
591 *temp_ptr = *buffer; 653 *temp_ptr = *buffer;
592 654
593 temp_ptr += 1; 655 temp_ptr++;
594 buffer += 1; 656 buffer++;
595 index += 1; 657 index++;
596 } 658 }
597 659
598 /* Add the terminating null */ 660 /* Add the terminating null and set the string length */
599 661
600 *temp_ptr = 0x00; 662 *temp_ptr = 0;
601 output_struct->data.address32.resource_source.string_length = index + 1; 663 output_struct->data.address32.resource_source.string_length =
664 index + 1;
602 665
603 /* 666 /*
604 * In order for the struct_size to fall on a 32-bit boundary, 667 * In order for the struct_size to fall on a 32-bit boundary,
@@ -606,10 +669,9 @@ acpi_rs_address32_resource (
606 * struct_size to the next 32-bit boundary. 669 * struct_size to the next 32-bit boundary.
607 */ 670 */
608 temp8 = (u8) (index + 1); 671 temp8 = (u8) (index + 1);
609 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 672 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
610 } 673 } else {
611 else { 674 output_struct->data.address32.resource_source.index = 0;
612 output_struct->data.address32.resource_source.index = 0x00;
613 output_struct->data.address32.resource_source.string_length = 0; 675 output_struct->data.address32.resource_source.string_length = 0;
614 output_struct->data.address32.resource_source.string_ptr = NULL; 676 output_struct->data.address32.resource_source.string_ptr = NULL;
615 } 677 }
@@ -621,10 +683,9 @@ acpi_rs_address32_resource (
621 /* Return the final size of the structure */ 683 /* Return the final size of the structure */
622 684
623 *structure_size = struct_size; 685 *structure_size = struct_size;
624 return_ACPI_STATUS (AE_OK); 686 return_ACPI_STATUS(AE_OK);
625} 687}
626 688
627
628/******************************************************************************* 689/*******************************************************************************
629 * 690 *
630 * FUNCTION: acpi_rs_address32_stream 691 * FUNCTION: acpi_rs_address32_stream
@@ -642,136 +703,105 @@ acpi_rs_address32_resource (
642 ******************************************************************************/ 703 ******************************************************************************/
643 704
644acpi_status 705acpi_status
645acpi_rs_address32_stream ( 706acpi_rs_address32_stream(struct acpi_resource *linked_list,
646 struct acpi_resource *linked_list, 707 u8 ** output_buffer, acpi_size * bytes_consumed)
647 u8 **output_buffer,
648 acpi_size *bytes_consumed)
649{ 708{
650 u8 *buffer; 709 u8 *buffer;
651 u16 *length_field; 710 u16 *length_field;
652 u8 temp8;
653 char *temp_pointer;
654
655
656 ACPI_FUNCTION_TRACE ("rs_address32_stream");
657 711
712 ACPI_FUNCTION_TRACE("rs_address32_stream");
658 713
659 buffer = *output_buffer; 714 buffer = *output_buffer;
660 715
661 /* The descriptor field is static */ 716 /* Set the Descriptor Type field */
662 717
663 *buffer = 0x87; 718 *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
664 buffer += 1; 719 buffer += 1;
665 720
666 /* Set a pointer to the Length field - to be filled in later */ 721 /* Save a pointer to the Length field - to be filled in later */
667 722
668 length_field = ACPI_CAST_PTR (u16, buffer); 723 length_field = ACPI_CAST_PTR(u16, buffer);
669 buffer += 2; 724 buffer += 2;
670 725
671 /* Set the Resource Type (Memory, Io, bus_number) */ 726 /* Set the Resource Type (Memory, Io, bus_number) */
672 727
673 temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); 728 *buffer = (u8) (linked_list->data.address32.resource_type & 0x03);
674
675 *buffer = temp8;
676 buffer += 1; 729 buffer += 1;
677 730
678 /* Set the general flags */ 731 /* Set the general flags */
679 732
680 temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); 733 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
681 temp8 |= (linked_list->data.address32.decode & 0x01) << 1;
682 temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2;
683 temp8 |= (linked_list->data.address32.max_address_fixed & 0x01) << 3;
684
685 *buffer = temp8;
686 buffer += 1; 734 buffer += 1;
687 735
688 /* Set the type specific flags */ 736 /* Set the type specific flags */
689 737
690 temp8 = 0; 738 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
691
692 if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
693 temp8 = (u8)
694 (linked_list->data.address32.attribute.memory.read_write_attribute &
695 0x01);
696
697 temp8 |=
698 (linked_list->data.address32.attribute.memory.cache_attribute &
699 0x03) << 1;
700 }
701 else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) {
702 temp8 = (u8)
703 (linked_list->data.address32.attribute.io.range_attribute &
704 0x03);
705 temp8 |=
706 (linked_list->data.address32.attribute.io.translation_attribute &
707 0x03) << 4;
708 }
709
710 *buffer = temp8;
711 buffer += 1; 739 buffer += 1;
712 740
713 /* Set the address space granularity */ 741 /* Set the address space granularity */
714 742
715 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity); 743 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.granularity);
716 buffer += 4; 744 buffer += 4;
717 745
718 /* Set the address range minimum */ 746 /* Set the address range minimum */
719 747
720 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range); 748 ACPI_MOVE_32_TO_32(buffer,
749 &linked_list->data.address32.min_address_range);
721 buffer += 4; 750 buffer += 4;
722 751
723 /* Set the address range maximum */ 752 /* Set the address range maximum */
724 753
725 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range); 754 ACPI_MOVE_32_TO_32(buffer,
755 &linked_list->data.address32.max_address_range);
726 buffer += 4; 756 buffer += 4;
727 757
728 /* Set the address translation offset */ 758 /* Set the address translation offset */
729 759
730 ACPI_MOVE_32_TO_32 (buffer, 760 ACPI_MOVE_32_TO_32(buffer,
731 &linked_list->data.address32.address_translation_offset); 761 &linked_list->data.address32.
762 address_translation_offset);
732 buffer += 4; 763 buffer += 4;
733 764
734 /* Set the address length */ 765 /* Set the address length */
735 766
736 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length); 767 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.address_length);
737 buffer += 4; 768 buffer += 4;
738 769
739 /* Resource Source Index and Resource Source are optional */ 770 /* Resource Source Index and Resource Source are optional */
740 771
741 if (0 != linked_list->data.address32.resource_source.string_length) { 772 if (linked_list->data.address32.resource_source.string_length) {
742 temp8 = (u8) linked_list->data.address32.resource_source.index; 773 *buffer =
743 774 (u8) linked_list->data.address32.resource_source.index;
744 *buffer = temp8;
745 buffer += 1; 775 buffer += 1;
746 776
747 temp_pointer = (char *) buffer; 777 /* Copy the resource_source string */
748
749 /* Copy the string */
750 778
751 ACPI_STRCPY (temp_pointer, 779 ACPI_STRCPY((char *)buffer,
752 linked_list->data.address32.resource_source.string_ptr); 780 linked_list->data.address32.resource_source.
781 string_ptr);
753 782
754 /* 783 /*
755 * Buffer needs to be set to the length of the sting + one for the 784 * Buffer needs to be set to the length of the string + one for the
756 * terminating null 785 * terminating null
757 */ 786 */
758 buffer += (acpi_size)(ACPI_STRLEN ( 787 buffer +=
759 linked_list->data.address32.resource_source.string_ptr) + 1); 788 (acpi_size) (ACPI_STRLEN
789 (linked_list->data.address32.resource_source.
790 string_ptr) + 1);
760 } 791 }
761 792
762 /* Return the number of bytes consumed in this operation */ 793 /* Return the number of bytes consumed in this operation */
763 794
764 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 795 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
765 796
766 /* 797 /*
767 * Set the length field to the number of bytes consumed 798 * Set the length field to the number of bytes consumed
768 * minus the header size (3 bytes) 799 * minus the header size (3 bytes)
769 */ 800 */
770 *length_field = (u16) (*bytes_consumed - 3); 801 *length_field = (u16) (*bytes_consumed - 3);
771 return_ACPI_STATUS (AE_OK); 802 return_ACPI_STATUS(AE_OK);
772} 803}
773 804
774
775/******************************************************************************* 805/*******************************************************************************
776 * 806 *
777 * FUNCTION: acpi_rs_address64_resource 807 * FUNCTION: acpi_rs_address64_resource
@@ -794,38 +824,35 @@ acpi_rs_address32_stream (
794 ******************************************************************************/ 824 ******************************************************************************/
795 825
796acpi_status 826acpi_status
797acpi_rs_address64_resource ( 827acpi_rs_address64_resource(u8 * byte_stream_buffer,
798 u8 *byte_stream_buffer, 828 acpi_size * bytes_consumed,
799 acpi_size *bytes_consumed, 829 u8 ** output_buffer, acpi_size * structure_size)
800 u8 **output_buffer,
801 acpi_size *structure_size)
802{ 830{
803 u8 *buffer; 831 u16 temp16;
804 struct acpi_resource *output_struct = (void *) *output_buffer; 832 u8 temp8;
805 u16 temp16; 833 u8 resource_type;
806 u8 temp8; 834 u8 *temp_ptr;
807 u8 resource_type; 835 u32 index;
808 u8 *temp_ptr; 836 u8 *buffer = byte_stream_buffer;
809 acpi_size struct_size; 837 struct acpi_resource *output_struct = (void *)*output_buffer;
810 u32 index; 838 acpi_size struct_size =
811 839 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
812 840
813 ACPI_FUNCTION_TRACE ("rs_address64_resource"); 841 ACPI_FUNCTION_TRACE("rs_address64_resource");
814 842
843 /* Get the Descriptor Type */
815 844
816 buffer = byte_stream_buffer;
817 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64);
818 resource_type = *buffer; 845 resource_type = *buffer;
819 846
820 /* Point past the Descriptor to get the number of bytes consumed */ 847 /* Get the Descriptor Length field */
821 848
822 buffer += 1; 849 buffer += 1;
823 ACPI_MOVE_16_TO_16 (&temp16, buffer); 850 ACPI_MOVE_16_TO_16(&temp16, buffer);
824 851
825 /* Validate minimum descriptor length */ 852 /* Validate minimum descriptor length */
826 853
827 if (temp16 < 43) { 854 if (temp16 < 43) {
828 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 855 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
829 } 856 }
830 857
831 *bytes_consumed = temp16 + 3; 858 *bytes_consumed = temp16 + 3;
@@ -839,7 +866,7 @@ acpi_rs_address64_resource (
839 /* Values 0-2 and 0xC0-0xFF are valid */ 866 /* Values 0-2 and 0xC0-0xFF are valid */
840 867
841 if ((temp8 > 2) && (temp8 < 0xC0)) { 868 if ((temp8 > 2) && (temp8 < 0xC0)) {
842 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 869 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
843 } 870 }
844 871
845 output_struct->data.address64.resource_type = temp8; 872 output_struct->data.address64.resource_type = temp8;
@@ -847,48 +874,12 @@ acpi_rs_address64_resource (
847 /* Get the General Flags (Byte4) */ 874 /* Get the General Flags (Byte4) */
848 875
849 buffer += 1; 876 buffer += 1;
850 temp8 = *buffer; 877 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
851
852 /* Producer / Consumer */
853
854 output_struct->data.address64.producer_consumer = temp8 & 0x01;
855
856 /* Decode */
857
858 output_struct->data.address64.decode = (temp8 >> 1) & 0x01;
859
860 /* Min Address Fixed */
861
862 output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01;
863
864 /* Max Address Fixed */
865
866 output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01;
867 878
868 /* Get the Type Specific Flags (Byte5) */ 879 /* Get the Type Specific Flags (Byte5) */
869 880
870 buffer += 1; 881 buffer += 1;
871 temp8 = *buffer; 882 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
872
873 if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) {
874 output_struct->data.address64.attribute.memory.read_write_attribute =
875 (u16) (temp8 & 0x01);
876
877 output_struct->data.address64.attribute.memory.cache_attribute =
878 (u16) ((temp8 >> 1) & 0x03);
879 }
880 else {
881 if (ACPI_IO_RANGE == output_struct->data.address64.resource_type) {
882 output_struct->data.address64.attribute.io.range_attribute =
883 (u16) (temp8 & 0x03);
884 output_struct->data.address64.attribute.io.translation_attribute =
885 (u16) ((temp8 >> 4) & 0x03);
886 }
887 else {
888 /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */
889 /* Nothing needs to be filled in */
890 }
891 }
892 883
893 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 884 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) {
894 /* Move past revision_id and Reserved byte */ 885 /* Move past revision_id and Reserved byte */
@@ -899,30 +890,33 @@ acpi_rs_address64_resource (
899 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ 890 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
900 891
901 buffer += 1; 892 buffer += 1;
902 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer); 893 ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
903 894
904 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ 895 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
905 896
906 buffer += 8; 897 buffer += 8;
907 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer); 898 ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
899 buffer);
908 900
909 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ 901 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
910 902
911 buffer += 8; 903 buffer += 8;
912 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer); 904 ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
905 buffer);
913 906
914 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ 907 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
915 908
916 buffer += 8; 909 buffer += 8;
917 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, 910 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
918 buffer); 911 address_translation_offset, buffer);
919 912
920 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 913 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
921 914
922 buffer += 8; 915 buffer += 8;
923 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer); 916 ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length,
917 buffer);
924 918
925 output_struct->data.address64.resource_source.index = 0x00; 919 output_struct->data.address64.resource_source.index = 0;
926 output_struct->data.address64.resource_source.string_length = 0; 920 output_struct->data.address64.resource_source.string_length = 0;
927 output_struct->data.address64.resource_source.string_ptr = NULL; 921 output_struct->data.address64.resource_source.string_ptr = NULL;
928 922
@@ -930,11 +924,9 @@ acpi_rs_address64_resource (
930 /* Get type_specific_attribute (Bytes 48-55) */ 924 /* Get type_specific_attribute (Bytes 48-55) */
931 925
932 buffer += 8; 926 buffer += 8;
933 ACPI_MOVE_64_TO_64 ( 927 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
934 &output_struct->data.address64.type_specific_attributes, 928 type_specific_attributes, buffer);
935 buffer); 929 } else {
936 }
937 else {
938 output_struct->data.address64.type_specific_attributes = 0; 930 output_struct->data.address64.type_specific_attributes = 0;
939 931
940 /* Resource Source Index (if present) */ 932 /* Resource Source Index (if present) */
@@ -954,9 +946,8 @@ acpi_rs_address64_resource (
954 if (*bytes_consumed > (46 + 1)) { 946 if (*bytes_consumed > (46 + 1)) {
955 /* Dereference the Index */ 947 /* Dereference the Index */
956 948
957 temp8 = *buffer;
958 output_struct->data.address64.resource_source.index = 949 output_struct->data.address64.resource_source.index =
959 (u32) temp8; 950 (u32) * buffer;
960 951
961 /* Point to the String */ 952 /* Point to the String */
962 953
@@ -964,29 +955,31 @@ acpi_rs_address64_resource (
964 955
965 /* Point the String pointer to the end of this structure */ 956 /* Point the String pointer to the end of this structure */
966 957
967 output_struct->data.address64.resource_source.string_ptr = 958 output_struct->data.address64.resource_source.
968 (char *)((u8 *)output_struct + struct_size); 959 string_ptr =
960 (char *)((u8 *) output_struct + struct_size);
969 961
970 temp_ptr = (u8 *) 962 temp_ptr = (u8 *)
971 output_struct->data.address64.resource_source.string_ptr; 963 output_struct->data.address64.resource_source.
964 string_ptr;
972 965
973 /* Copy the string into the buffer */ 966 /* Copy the resource_source string into the buffer */
974 967
975 index = 0; 968 index = 0;
976 while (0x00 != *buffer) { 969 while (*buffer) {
977 *temp_ptr = *buffer; 970 *temp_ptr = *buffer;
978 971
979 temp_ptr += 1; 972 temp_ptr++;
980 buffer += 1; 973 buffer++;
981 index += 1; 974 index++;
982 } 975 }
983 976
984 /* 977 /*
985 * Add the terminating null 978 * Add the terminating null and set the string length
986 */ 979 */
987 *temp_ptr = 0x00; 980 *temp_ptr = 0;
988 output_struct->data.address64.resource_source.string_length = 981 output_struct->data.address64.resource_source.
989 index + 1; 982 string_length = index + 1;
990 983
991 /* 984 /*
992 * In order for the struct_size to fall on a 32-bit boundary, 985 * In order for the struct_size to fall on a 32-bit boundary,
@@ -994,7 +987,7 @@ acpi_rs_address64_resource (
994 * struct_size to the next 32-bit boundary. 987 * struct_size to the next 32-bit boundary.
995 */ 988 */
996 temp8 = (u8) (index + 1); 989 temp8 = (u8) (index + 1);
997 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 990 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
998 } 991 }
999 } 992 }
1000 993
@@ -1005,10 +998,9 @@ acpi_rs_address64_resource (
1005 /* Return the final size of the structure */ 998 /* Return the final size of the structure */
1006 999
1007 *structure_size = struct_size; 1000 *structure_size = struct_size;
1008 return_ACPI_STATUS (AE_OK); 1001 return_ACPI_STATUS(AE_OK);
1009} 1002}
1010 1003
1011
1012/******************************************************************************* 1004/*******************************************************************************
1013 * 1005 *
1014 * FUNCTION: acpi_rs_address64_stream 1006 * FUNCTION: acpi_rs_address64_stream
@@ -1026,132 +1018,101 @@ acpi_rs_address64_resource (
1026 ******************************************************************************/ 1018 ******************************************************************************/
1027 1019
1028acpi_status 1020acpi_status
1029acpi_rs_address64_stream ( 1021acpi_rs_address64_stream(struct acpi_resource *linked_list,
1030 struct acpi_resource *linked_list, 1022 u8 ** output_buffer, acpi_size * bytes_consumed)
1031 u8 **output_buffer,
1032 acpi_size *bytes_consumed)
1033{ 1023{
1034 u8 *buffer; 1024 u8 *buffer;
1035 u16 *length_field; 1025 u16 *length_field;
1036 u8 temp8;
1037 char *temp_pointer;
1038
1039
1040 ACPI_FUNCTION_TRACE ("rs_address64_stream");
1041 1026
1027 ACPI_FUNCTION_TRACE("rs_address64_stream");
1042 1028
1043 buffer = *output_buffer; 1029 buffer = *output_buffer;
1044 1030
1045 /* The descriptor field is static */ 1031 /* Set the Descriptor Type field */
1046 1032
1047 *buffer = 0x8A; 1033 *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
1048 buffer += 1; 1034 buffer += 1;
1049 1035
1050 /* Set a pointer to the Length field - to be filled in later */ 1036 /* Save a pointer to the Length field - to be filled in later */
1051 1037
1052 length_field = ACPI_CAST_PTR (u16, buffer); 1038 length_field = ACPI_CAST_PTR(u16, buffer);
1053 buffer += 2; 1039 buffer += 2;
1054 1040
1055 /* Set the Resource Type (Memory, Io, bus_number) */ 1041 /* Set the Resource Type (Memory, Io, bus_number) */
1056 1042
1057 temp8 = (u8) (linked_list->data.address64.resource_type & 0x03); 1043 *buffer = (u8) (linked_list->data.address64.resource_type & 0x03);
1058
1059 *buffer = temp8;
1060 buffer += 1; 1044 buffer += 1;
1061 1045
1062 /* Set the general flags */ 1046 /* Set the general flags */
1063 1047
1064 temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01); 1048 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
1065 temp8 |= (linked_list->data.address64.decode & 0x01) << 1;
1066 temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2;
1067 temp8 |= (linked_list->data.address64.max_address_fixed & 0x01) << 3;
1068
1069 *buffer = temp8;
1070 buffer += 1; 1049 buffer += 1;
1071 1050
1072 /* Set the type specific flags */ 1051 /* Set the type specific flags */
1073 1052
1074 temp8 = 0; 1053 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
1075
1076 if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
1077 temp8 = (u8)
1078 (linked_list->data.address64.attribute.memory.read_write_attribute &
1079 0x01);
1080
1081 temp8 |=
1082 (linked_list->data.address64.attribute.memory.cache_attribute &
1083 0x03) << 1;
1084 }
1085 else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) {
1086 temp8 = (u8)
1087 (linked_list->data.address64.attribute.io.range_attribute &
1088 0x03);
1089 temp8 |=
1090 (linked_list->data.address64.attribute.io.range_attribute &
1091 0x03) << 4;
1092 }
1093
1094 *buffer = temp8;
1095 buffer += 1; 1054 buffer += 1;
1096 1055
1097 /* Set the address space granularity */ 1056 /* Set the address space granularity */
1098 1057
1099 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity); 1058 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.granularity);
1100 buffer += 8; 1059 buffer += 8;
1101 1060
1102 /* Set the address range minimum */ 1061 /* Set the address range minimum */
1103 1062
1104 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range); 1063 ACPI_MOVE_64_TO_64(buffer,
1064 &linked_list->data.address64.min_address_range);
1105 buffer += 8; 1065 buffer += 8;
1106 1066
1107 /* Set the address range maximum */ 1067 /* Set the address range maximum */
1108 1068
1109 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range); 1069 ACPI_MOVE_64_TO_64(buffer,
1070 &linked_list->data.address64.max_address_range);
1110 buffer += 8; 1071 buffer += 8;
1111 1072
1112 /* Set the address translation offset */ 1073 /* Set the address translation offset */
1113 1074
1114 ACPI_MOVE_64_TO_64 (buffer, 1075 ACPI_MOVE_64_TO_64(buffer,
1115 &linked_list->data.address64.address_translation_offset); 1076 &linked_list->data.address64.
1077 address_translation_offset);
1116 buffer += 8; 1078 buffer += 8;
1117 1079
1118 /* Set the address length */ 1080 /* Set the address length */
1119 1081
1120 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length); 1082 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.address_length);
1121 buffer += 8; 1083 buffer += 8;
1122 1084
1123 /* Resource Source Index and Resource Source are optional */ 1085 /* Resource Source Index and Resource Source are optional */
1124 1086
1125 if (0 != linked_list->data.address64.resource_source.string_length) { 1087 if (linked_list->data.address64.resource_source.string_length) {
1126 temp8 = (u8) linked_list->data.address64.resource_source.index; 1088 *buffer =
1127 1089 (u8) linked_list->data.address64.resource_source.index;
1128 *buffer = temp8;
1129 buffer += 1; 1090 buffer += 1;
1130 1091
1131 temp_pointer = (char *) buffer; 1092 /* Copy the resource_source string */
1132 1093
1133 /* Copy the string */ 1094 ACPI_STRCPY((char *)buffer,
1134 1095 linked_list->data.address64.resource_source.
1135 ACPI_STRCPY (temp_pointer, 1096 string_ptr);
1136 linked_list->data.address64.resource_source.string_ptr);
1137 1097
1138 /* 1098 /*
1139 * Buffer needs to be set to the length of the sting + one for the 1099 * Buffer needs to be set to the length of the string + one for the
1140 * terminating null 1100 * terminating null
1141 */ 1101 */
1142 buffer += (acpi_size)(ACPI_STRLEN ( 1102 buffer +=
1143 linked_list->data.address64.resource_source.string_ptr) + 1); 1103 (acpi_size) (ACPI_STRLEN
1104 (linked_list->data.address64.resource_source.
1105 string_ptr) + 1);
1144 } 1106 }
1145 1107
1146 /* Return the number of bytes consumed in this operation */ 1108 /* Return the number of bytes consumed in this operation */
1147 1109
1148 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 1110 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
1149 1111
1150 /* 1112 /*
1151 * Set the length field to the number of bytes consumed 1113 * Set the length field to the number of bytes consumed
1152 * minus the header size (3 bytes) 1114 * minus the header size (3 bytes)
1153 */ 1115 */
1154 *length_field = (u16) (*bytes_consumed - 3); 1116 *length_field = (u16) (*bytes_consumed - 3);
1155 return_ACPI_STATUS (AE_OK); 1117 return_ACPI_STATUS(AE_OK);
1156} 1118}
1157
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 98176f2fcb5d..378f58390fc1 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -41,15 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rscalc") 50ACPI_MODULE_NAME("rscalc")
52
53 51
54/******************************************************************************* 52/*******************************************************************************
55 * 53 *
@@ -66,19 +64,15 @@
66 * the resource data. 64 * the resource data.
67 * 65 *
68 ******************************************************************************/ 66 ******************************************************************************/
69
70acpi_status 67acpi_status
71acpi_rs_get_byte_stream_length ( 68acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list,
72 struct acpi_resource *linked_list, 69 acpi_size * size_needed)
73 acpi_size *size_needed)
74{ 70{
75 acpi_size byte_stream_size_needed = 0; 71 acpi_size byte_stream_size_needed = 0;
76 acpi_size segment_size; 72 acpi_size segment_size;
77 u8 done = FALSE; 73 u8 done = FALSE;
78
79
80 ACPI_FUNCTION_TRACE ("rs_get_byte_stream_length");
81 74
75 ACPI_FUNCTION_TRACE("rs_get_byte_stream_length");
82 76
83 while (!done) { 77 while (!done) {
84 /* Init the variable that will hold the size to add to the total. */ 78 /* Init the variable that will hold the size to add to the total. */
@@ -145,11 +139,11 @@ acpi_rs_get_byte_stream_length (
145 */ 139 */
146 if (linked_list->data.vendor_specific.length > 7) { 140 if (linked_list->data.vendor_specific.length > 7) {
147 segment_size = 3; 141 segment_size = 3;
148 } 142 } else {
149 else {
150 segment_size = 1; 143 segment_size = 1;
151 } 144 }
152 segment_size += linked_list->data.vendor_specific.length; 145 segment_size +=
146 linked_list->data.vendor_specific.length;
153 break; 147 break;
154 148
155 case ACPI_RSTYPE_END_TAG: 149 case ACPI_RSTYPE_END_TAG:
@@ -194,9 +188,11 @@ acpi_rs_get_byte_stream_length (
194 */ 188 */
195 segment_size = 16; 189 segment_size = 16;
196 190
197 if (linked_list->data.address16.resource_source.string_ptr) { 191 if (linked_list->data.address16.resource_source.
192 string_ptr) {
198 segment_size += 193 segment_size +=
199 linked_list->data.address16.resource_source.string_length; 194 linked_list->data.address16.resource_source.
195 string_length;
200 segment_size++; 196 segment_size++;
201 } 197 }
202 break; 198 break;
@@ -211,9 +207,11 @@ acpi_rs_get_byte_stream_length (
211 */ 207 */
212 segment_size = 26; 208 segment_size = 26;
213 209
214 if (linked_list->data.address32.resource_source.string_ptr) { 210 if (linked_list->data.address32.resource_source.
211 string_ptr) {
215 segment_size += 212 segment_size +=
216 linked_list->data.address32.resource_source.string_length; 213 linked_list->data.address32.resource_source.
214 string_length;
217 segment_size++; 215 segment_size++;
218 } 216 }
219 break; 217 break;
@@ -227,9 +225,11 @@ acpi_rs_get_byte_stream_length (
227 */ 225 */
228 segment_size = 46; 226 segment_size = 46;
229 227
230 if (linked_list->data.address64.resource_source.string_ptr) { 228 if (linked_list->data.address64.resource_source.
229 string_ptr) {
231 segment_size += 230 segment_size +=
232 linked_list->data.address64.resource_source.string_length; 231 linked_list->data.address64.resource_source.
232 string_length;
233 segment_size++; 233 segment_size++;
234 } 234 }
235 break; 235 break;
@@ -244,11 +244,14 @@ acpi_rs_get_byte_stream_length (
244 * Resource Source + 1 for the null. 244 * Resource Source + 1 for the null.
245 */ 245 */
246 segment_size = 9 + (((acpi_size) 246 segment_size = 9 + (((acpi_size)
247 linked_list->data.extended_irq.number_of_interrupts - 1) * 4); 247 linked_list->data.extended_irq.
248 number_of_interrupts - 1) * 4);
248 249
249 if (linked_list->data.extended_irq.resource_source.string_ptr) { 250 if (linked_list->data.extended_irq.resource_source.
251 string_ptr) {
250 segment_size += 252 segment_size +=
251 linked_list->data.extended_irq.resource_source.string_length; 253 linked_list->data.extended_irq.
254 resource_source.string_length;
252 segment_size++; 255 segment_size++;
253 } 256 }
254 break; 257 break;
@@ -257,9 +260,9 @@ acpi_rs_get_byte_stream_length (
257 260
258 /* If we get here, everything is out of sync, exit with error */ 261 /* If we get here, everything is out of sync, exit with error */
259 262
260 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 263 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
261 264
262 } /* switch (linked_list->Id) */ 265 } /* switch (linked_list->Id) */
263 266
264 /* Update the total */ 267 /* Update the total */
265 268
@@ -267,17 +270,16 @@ acpi_rs_get_byte_stream_length (
267 270
268 /* Point to the next object */ 271 /* Point to the next object */
269 272
270 linked_list = ACPI_PTR_ADD (struct acpi_resource, 273 linked_list = ACPI_PTR_ADD(struct acpi_resource,
271 linked_list, linked_list->length); 274 linked_list, linked_list->length);
272 } 275 }
273 276
274 /* This is the data the caller needs */ 277 /* This is the data the caller needs */
275 278
276 *size_needed = byte_stream_size_needed; 279 *size_needed = byte_stream_size_needed;
277 return_ACPI_STATUS (AE_OK); 280 return_ACPI_STATUS(AE_OK);
278} 281}
279 282
280
281/******************************************************************************* 283/*******************************************************************************
282 * 284 *
283 * FUNCTION: acpi_rs_get_list_length 285 * FUNCTION: acpi_rs_get_list_length
@@ -297,32 +299,28 @@ acpi_rs_get_byte_stream_length (
297 ******************************************************************************/ 299 ******************************************************************************/
298 300
299acpi_status 301acpi_status
300acpi_rs_get_list_length ( 302acpi_rs_get_list_length(u8 * byte_stream_buffer,
301 u8 *byte_stream_buffer, 303 u32 byte_stream_buffer_length, acpi_size * size_needed)
302 u32 byte_stream_buffer_length,
303 acpi_size *size_needed)
304{ 304{
305 u32 buffer_size = 0; 305 u32 buffer_size = 0;
306 u32 bytes_parsed = 0; 306 u32 bytes_parsed = 0;
307 u8 number_of_interrupts = 0; 307 u8 number_of_interrupts = 0;
308 u8 number_of_channels = 0; 308 u8 number_of_channels = 0;
309 u8 resource_type; 309 u8 resource_type;
310 u32 structure_size; 310 u32 structure_size;
311 u32 bytes_consumed; 311 u32 bytes_consumed;
312 u8 *buffer; 312 u8 *buffer;
313 u8 temp8; 313 u8 temp8;
314 u16 temp16; 314 u16 temp16;
315 u8 index; 315 u8 index;
316 u8 additional_bytes; 316 u8 additional_bytes;
317 317
318 318 ACPI_FUNCTION_TRACE("rs_get_list_length");
319 ACPI_FUNCTION_TRACE ("rs_get_list_length");
320
321 319
322 while (bytes_parsed < byte_stream_buffer_length) { 320 while (bytes_parsed < byte_stream_buffer_length) {
323 /* The next byte in the stream is the resource type */ 321 /* The next byte in the stream is the resource type */
324 322
325 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); 323 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
326 324
327 switch (resource_type) { 325 switch (resource_type) {
328 case ACPI_RDESC_TYPE_MEMORY_24: 326 case ACPI_RDESC_TYPE_MEMORY_24:
@@ -331,10 +329,10 @@ acpi_rs_get_list_length (
331 */ 329 */
332 bytes_consumed = 12; 330 bytes_consumed = 12;
333 331
334 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24); 332 structure_size =
333 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
335 break; 334 break;
336 335
337
338 case ACPI_RDESC_TYPE_LARGE_VENDOR: 336 case ACPI_RDESC_TYPE_LARGE_VENDOR:
339 /* 337 /*
340 * Vendor Defined Resource 338 * Vendor Defined Resource
@@ -342,38 +340,39 @@ acpi_rs_get_list_length (
342 buffer = byte_stream_buffer; 340 buffer = byte_stream_buffer;
343 ++buffer; 341 ++buffer;
344 342
345 ACPI_MOVE_16_TO_16 (&temp16, buffer); 343 ACPI_MOVE_16_TO_16(&temp16, buffer);
346 bytes_consumed = temp16 + 3; 344 bytes_consumed = temp16 + 3;
347 345
348 /* Ensure a 32-bit boundary for the structure */ 346 /* Ensure a 32-bit boundary for the structure */
349 347
350 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16); 348 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS(temp16);
351 349
352 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + 350 structure_size =
353 (temp16 * sizeof (u8)); 351 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
352 (temp16 * sizeof(u8));
354 break; 353 break;
355 354
356
357 case ACPI_RDESC_TYPE_MEMORY_32: 355 case ACPI_RDESC_TYPE_MEMORY_32:
358 /* 356 /*
359 * 32-Bit Memory Range Resource 357 * 32-Bit Memory Range Resource
360 */ 358 */
361 bytes_consumed = 20; 359 bytes_consumed = 20;
362 360
363 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32); 361 structure_size =
362 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
364 break; 363 break;
365 364
366
367 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 365 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
368 /* 366 /*
369 * 32-Bit Fixed Memory Resource 367 * 32-Bit Fixed Memory Resource
370 */ 368 */
371 bytes_consumed = 12; 369 bytes_consumed = 12;
372 370
373 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32); 371 structure_size =
372 ACPI_SIZEOF_RESOURCE(struct
373 acpi_resource_fixed_mem32);
374 break; 374 break;
375 375
376
377 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: 376 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
378 /* 377 /*
379 * 64-Bit Address Resource 378 * 64-Bit Address Resource
@@ -381,13 +380,14 @@ acpi_rs_get_list_length (
381 buffer = byte_stream_buffer; 380 buffer = byte_stream_buffer;
382 381
383 ++buffer; 382 ++buffer;
384 ACPI_MOVE_16_TO_16 (&temp16, buffer); 383 ACPI_MOVE_16_TO_16(&temp16, buffer);
385 384
386 bytes_consumed = temp16 + 3; 385 bytes_consumed = temp16 + 3;
387 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); 386 structure_size =
387 ACPI_SIZEOF_RESOURCE(struct
388 acpi_resource_address64);
388 break; 389 break;
389 390
390
391 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 391 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
392 /* 392 /*
393 * 64-Bit Address Resource 393 * 64-Bit Address Resource
@@ -395,7 +395,7 @@ acpi_rs_get_list_length (
395 buffer = byte_stream_buffer; 395 buffer = byte_stream_buffer;
396 396
397 ++buffer; 397 ++buffer;
398 ACPI_MOVE_16_TO_16 (&temp16, buffer); 398 ACPI_MOVE_16_TO_16(&temp16, buffer);
399 399
400 bytes_consumed = temp16 + 3; 400 bytes_consumed = temp16 + 3;
401 401
@@ -409,20 +409,19 @@ acpi_rs_get_list_length (
409 */ 409 */
410 if (43 < temp16) { 410 if (43 < temp16) {
411 temp8 = (u8) (temp16 - 44); 411 temp8 = (u8) (temp16 - 44);
412 } 412 } else {
413 else {
414 temp8 = 0; 413 temp8 = 0;
415 } 414 }
416 415
417 /* Ensure a 64-bit boundary for the structure */ 416 /* Ensure a 64-bit boundary for the structure */
418 417
419 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8); 418 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS(temp8);
420 419
421 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) + 420 structure_size =
422 (temp8 * sizeof (u8)); 421 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)
422 + (temp8 * sizeof(u8));
423 break; 423 break;
424 424
425
426 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 425 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
427 /* 426 /*
428 * 32-Bit Address Resource 427 * 32-Bit Address Resource
@@ -430,7 +429,7 @@ acpi_rs_get_list_length (
430 buffer = byte_stream_buffer; 429 buffer = byte_stream_buffer;
431 430
432 ++buffer; 431 ++buffer;
433 ACPI_MOVE_16_TO_16 (&temp16, buffer); 432 ACPI_MOVE_16_TO_16(&temp16, buffer);
434 433
435 bytes_consumed = temp16 + 3; 434 bytes_consumed = temp16 + 3;
436 435
@@ -444,20 +443,19 @@ acpi_rs_get_list_length (
444 */ 443 */
445 if (23 < temp16) { 444 if (23 < temp16) {
446 temp8 = (u8) (temp16 - 24); 445 temp8 = (u8) (temp16 - 24);
447 } 446 } else {
448 else {
449 temp8 = 0; 447 temp8 = 0;
450 } 448 }
451 449
452 /* Ensure a 32-bit boundary for the structure */ 450 /* Ensure a 32-bit boundary for the structure */
453 451
454 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 452 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
455 453
456 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) + 454 structure_size =
457 (temp8 * sizeof (u8)); 455 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)
456 + (temp8 * sizeof(u8));
458 break; 457 break;
459 458
460
461 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 459 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
462 /* 460 /*
463 * 16-Bit Address Resource 461 * 16-Bit Address Resource
@@ -465,7 +463,7 @@ acpi_rs_get_list_length (
465 buffer = byte_stream_buffer; 463 buffer = byte_stream_buffer;
466 464
467 ++buffer; 465 ++buffer;
468 ACPI_MOVE_16_TO_16 (&temp16, buffer); 466 ACPI_MOVE_16_TO_16(&temp16, buffer);
469 467
470 bytes_consumed = temp16 + 3; 468 bytes_consumed = temp16 + 3;
471 469
@@ -479,20 +477,19 @@ acpi_rs_get_list_length (
479 */ 477 */
480 if (13 < temp16) { 478 if (13 < temp16) {
481 temp8 = (u8) (temp16 - 14); 479 temp8 = (u8) (temp16 - 14);
482 } 480 } else {
483 else {
484 temp8 = 0; 481 temp8 = 0;
485 } 482 }
486 483
487 /* Ensure a 32-bit boundary for the structure */ 484 /* Ensure a 32-bit boundary for the structure */
488 485
489 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 486 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
490 487
491 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) + 488 structure_size =
492 (temp8 * sizeof (u8)); 489 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)
490 + (temp8 * sizeof(u8));
493 break; 491 break;
494 492
495
496 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 493 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
497 /* 494 /*
498 * Extended IRQ 495 * Extended IRQ
@@ -500,7 +497,7 @@ acpi_rs_get_list_length (
500 buffer = byte_stream_buffer; 497 buffer = byte_stream_buffer;
501 498
502 ++buffer; 499 ++buffer;
503 ACPI_MOVE_16_TO_16 (&temp16, buffer); 500 ACPI_MOVE_16_TO_16(&temp16, buffer);
504 501
505 bytes_consumed = temp16 + 3; 502 bytes_consumed = temp16 + 3;
506 503
@@ -527,21 +524,20 @@ acpi_rs_get_list_length (
527 */ 524 */
528 if (9 + additional_bytes < temp16) { 525 if (9 + additional_bytes < temp16) {
529 temp8 = (u8) (temp16 - (9 + additional_bytes)); 526 temp8 = (u8) (temp16 - (9 + additional_bytes));
530 } 527 } else {
531 else {
532 temp8 = 0; 528 temp8 = 0;
533 } 529 }
534 530
535 /* Ensure a 32-bit boundary for the structure */ 531 /* Ensure a 32-bit boundary for the structure */
536 532
537 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 533 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
538 534
539 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) + 535 structure_size =
540 (additional_bytes * sizeof (u8)) + 536 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq) +
541 (temp8 * sizeof (u8)); 537 (additional_bytes * sizeof(u8)) +
538 (temp8 * sizeof(u8));
542 break; 539 break;
543 540
544
545 case ACPI_RDESC_TYPE_IRQ_FORMAT: 541 case ACPI_RDESC_TYPE_IRQ_FORMAT:
546 /* 542 /*
547 * IRQ Resource. 543 * IRQ Resource.
@@ -550,10 +546,9 @@ acpi_rs_get_list_length (
550 buffer = byte_stream_buffer; 546 buffer = byte_stream_buffer;
551 temp8 = *buffer; 547 temp8 = *buffer;
552 548
553 if(temp8 & 0x01) { 549 if (temp8 & 0x01) {
554 bytes_consumed = 4; 550 bytes_consumed = 4;
555 } 551 } else {
556 else {
557 bytes_consumed = 3; 552 bytes_consumed = 3;
558 } 553 }
559 554
@@ -563,7 +558,7 @@ acpi_rs_get_list_length (
563 558
564 /* Look at the number of bits set */ 559 /* Look at the number of bits set */
565 560
566 ACPI_MOVE_16_TO_16 (&temp16, buffer); 561 ACPI_MOVE_16_TO_16(&temp16, buffer);
567 562
568 for (index = 0; index < 16; index++) { 563 for (index = 0; index < 16; index++) {
569 if (temp16 & 0x1) { 564 if (temp16 & 0x1) {
@@ -573,11 +568,11 @@ acpi_rs_get_list_length (
573 temp16 >>= 1; 568 temp16 >>= 1;
574 } 569 }
575 570
576 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io) + 571 structure_size =
577 (number_of_interrupts * sizeof (u32)); 572 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io) +
573 (number_of_interrupts * sizeof(u32));
578 break; 574 break;
579 575
580
581 case ACPI_RDESC_TYPE_DMA_FORMAT: 576 case ACPI_RDESC_TYPE_DMA_FORMAT:
582 /* 577 /*
583 * DMA Resource 578 * DMA Resource
@@ -593,19 +588,19 @@ acpi_rs_get_list_length (
593 588
594 temp8 = *buffer; 589 temp8 = *buffer;
595 590
596 for(index = 0; index < 8; index++) { 591 for (index = 0; index < 8; index++) {
597 if(temp8 & 0x1) { 592 if (temp8 & 0x1) {
598 ++number_of_channels; 593 ++number_of_channels;
599 } 594 }
600 595
601 temp8 >>= 1; 596 temp8 >>= 1;
602 } 597 }
603 598
604 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma) + 599 structure_size =
605 (number_of_channels * sizeof (u32)); 600 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma) +
601 (number_of_channels * sizeof(u32));
606 break; 602 break;
607 603
608
609 case ACPI_RDESC_TYPE_START_DEPENDENT: 604 case ACPI_RDESC_TYPE_START_DEPENDENT:
610 /* 605 /*
611 * Start Dependent Functions Resource 606 * Start Dependent Functions Resource
@@ -614,17 +609,17 @@ acpi_rs_get_list_length (
614 buffer = byte_stream_buffer; 609 buffer = byte_stream_buffer;
615 temp8 = *buffer; 610 temp8 = *buffer;
616 611
617 if(temp8 & 0x01) { 612 if (temp8 & 0x01) {
618 bytes_consumed = 2; 613 bytes_consumed = 2;
619 } 614 } else {
620 else {
621 bytes_consumed = 1; 615 bytes_consumed = 1;
622 } 616 }
623 617
624 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf); 618 structure_size =
619 ACPI_SIZEOF_RESOURCE(struct
620 acpi_resource_start_dpf);
625 break; 621 break;
626 622
627
628 case ACPI_RDESC_TYPE_END_DEPENDENT: 623 case ACPI_RDESC_TYPE_END_DEPENDENT:
629 /* 624 /*
630 * End Dependent Functions Resource 625 * End Dependent Functions Resource
@@ -633,25 +628,24 @@ acpi_rs_get_list_length (
633 structure_size = ACPI_RESOURCE_LENGTH; 628 structure_size = ACPI_RESOURCE_LENGTH;
634 break; 629 break;
635 630
636
637 case ACPI_RDESC_TYPE_IO_PORT: 631 case ACPI_RDESC_TYPE_IO_PORT:
638 /* 632 /*
639 * IO Port Resource 633 * IO Port Resource
640 */ 634 */
641 bytes_consumed = 8; 635 bytes_consumed = 8;
642 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io); 636 structure_size =
637 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
643 break; 638 break;
644 639
645
646 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 640 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
647 /* 641 /*
648 * Fixed IO Port Resource 642 * Fixed IO Port Resource
649 */ 643 */
650 bytes_consumed = 4; 644 bytes_consumed = 4;
651 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io); 645 structure_size =
646 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
652 break; 647 break;
653 648
654
655 case ACPI_RDESC_TYPE_SMALL_VENDOR: 649 case ACPI_RDESC_TYPE_SMALL_VENDOR:
656 /* 650 /*
657 * Vendor Specific Resource 651 * Vendor Specific Resource
@@ -664,12 +658,12 @@ acpi_rs_get_list_length (
664 658
665 /* Ensure a 32-bit boundary for the structure */ 659 /* Ensure a 32-bit boundary for the structure */
666 660
667 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 661 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
668 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + 662 structure_size =
669 (temp8 * sizeof (u8)); 663 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
664 (temp8 * sizeof(u8));
670 break; 665 break;
671 666
672
673 case ACPI_RDESC_TYPE_END_TAG: 667 case ACPI_RDESC_TYPE_END_TAG:
674 /* 668 /*
675 * End Tag 669 * End Tag
@@ -679,18 +673,17 @@ acpi_rs_get_list_length (
679 byte_stream_buffer_length = bytes_parsed; 673 byte_stream_buffer_length = bytes_parsed;
680 break; 674 break;
681 675
682
683 default: 676 default:
684 /* 677 /*
685 * If we get here, everything is out of sync, 678 * If we get here, everything is out of sync,
686 * exit with an error 679 * exit with an error
687 */ 680 */
688 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 681 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
689 } 682 }
690 683
691 /* Update the return value and counter */ 684 /* Update the return value and counter */
692 685
693 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size); 686 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(structure_size);
694 bytes_parsed += bytes_consumed; 687 bytes_parsed += bytes_consumed;
695 688
696 /* Set the byte stream to point to the next resource */ 689 /* Set the byte stream to point to the next resource */
@@ -701,10 +694,9 @@ acpi_rs_get_list_length (
701 /* This is the data the caller needs */ 694 /* This is the data the caller needs */
702 695
703 *size_needed = buffer_size; 696 *size_needed = buffer_size;
704 return_ACPI_STATUS (AE_OK); 697 return_ACPI_STATUS(AE_OK);
705} 698}
706 699
707
708/******************************************************************************* 700/*******************************************************************************
709 * 701 *
710 * FUNCTION: acpi_rs_get_pci_routing_table_length 702 * FUNCTION: acpi_rs_get_pci_routing_table_length
@@ -723,22 +715,19 @@ acpi_rs_get_list_length (
723 ******************************************************************************/ 715 ******************************************************************************/
724 716
725acpi_status 717acpi_status
726acpi_rs_get_pci_routing_table_length ( 718acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
727 union acpi_operand_object *package_object, 719 acpi_size * buffer_size_needed)
728 acpi_size *buffer_size_needed)
729{ 720{
730 u32 number_of_elements; 721 u32 number_of_elements;
731 acpi_size temp_size_needed = 0; 722 acpi_size temp_size_needed = 0;
732 union acpi_operand_object **top_object_list; 723 union acpi_operand_object **top_object_list;
733 u32 index; 724 u32 index;
734 union acpi_operand_object *package_element; 725 union acpi_operand_object *package_element;
735 union acpi_operand_object **sub_object_list; 726 union acpi_operand_object **sub_object_list;
736 u8 name_found; 727 u8 name_found;
737 u32 table_index; 728 u32 table_index;
738
739
740 ACPI_FUNCTION_TRACE ("rs_get_pci_routing_table_length");
741 729
730 ACPI_FUNCTION_TRACE("rs_get_pci_routing_table_length");
742 731
743 number_of_elements = package_object->package.count; 732 number_of_elements = package_object->package.count;
744 733
@@ -769,53 +758,51 @@ acpi_rs_get_pci_routing_table_length (
769 758
770 name_found = FALSE; 759 name_found = FALSE;
771 760
772 for (table_index = 0; table_index < 4 && !name_found; table_index++) { 761 for (table_index = 0; table_index < 4 && !name_found;
762 table_index++) {
773 if ((ACPI_TYPE_STRING == 763 if ((ACPI_TYPE_STRING ==
774 ACPI_GET_OBJECT_TYPE (*sub_object_list)) || 764 ACPI_GET_OBJECT_TYPE(*sub_object_list))
775 765 ||
776 ((ACPI_TYPE_LOCAL_REFERENCE == 766 ((ACPI_TYPE_LOCAL_REFERENCE ==
777 ACPI_GET_OBJECT_TYPE (*sub_object_list)) && 767 ACPI_GET_OBJECT_TYPE(*sub_object_list))
778 768 && ((*sub_object_list)->reference.opcode ==
779 ((*sub_object_list)->reference.opcode == 769 AML_INT_NAMEPATH_OP))) {
780 AML_INT_NAMEPATH_OP))) {
781 name_found = TRUE; 770 name_found = TRUE;
782 } 771 } else {
783 else {
784 /* Look at the next element */ 772 /* Look at the next element */
785 773
786 sub_object_list++; 774 sub_object_list++;
787 } 775 }
788 } 776 }
789 777
790 temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4); 778 temp_size_needed += (sizeof(struct acpi_pci_routing_table) - 4);
791 779
792 /* Was a String type found? */ 780 /* Was a String type found? */
793 781
794 if (name_found) { 782 if (name_found) {
795 if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) { 783 if (ACPI_GET_OBJECT_TYPE(*sub_object_list) ==
784 ACPI_TYPE_STRING) {
796 /* 785 /*
797 * The length String.Length field does not include the 786 * The length String.Length field does not include the
798 * terminating NULL, add 1 787 * terminating NULL, add 1
799 */ 788 */
800 temp_size_needed += ((acpi_size) 789 temp_size_needed += ((acpi_size)
801 (*sub_object_list)->string.length + 1); 790 (*sub_object_list)->string.
791 length + 1);
792 } else {
793 temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
802 } 794 }
803 else { 795 } else {
804 temp_size_needed += acpi_ns_get_pathname_length (
805 (*sub_object_list)->reference.node);
806 }
807 }
808 else {
809 /* 796 /*
810 * If no name was found, then this is a NULL, which is 797 * If no name was found, then this is a NULL, which is
811 * translated as a u32 zero. 798 * translated as a u32 zero.
812 */ 799 */
813 temp_size_needed += sizeof (u32); 800 temp_size_needed += sizeof(u32);
814 } 801 }
815 802
816 /* Round up the size since each element must be aligned */ 803 /* Round up the size since each element must be aligned */
817 804
818 temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed); 805 temp_size_needed = ACPI_ROUND_UP_to_64_bITS(temp_size_needed);
819 806
820 /* Point to the next union acpi_operand_object */ 807 /* Point to the next union acpi_operand_object */
821 808
@@ -826,6 +813,7 @@ acpi_rs_get_pci_routing_table_length (
826 * Adding an extra element to the end of the list, essentially a 813 * Adding an extra element to the end of the list, essentially a
827 * NULL terminator 814 * NULL terminator
828 */ 815 */
829 *buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table); 816 *buffer_size_needed =
830 return_ACPI_STATUS (AE_OK); 817 temp_size_needed + sizeof(struct acpi_pci_routing_table);
818 return_ACPI_STATUS(AE_OK);
831} 819}
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 8e0eae0d50bb..0911526b7ad8 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -41,15 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rscreate") 50ACPI_MODULE_NAME("rscreate")
52
53 51
54/******************************************************************************* 52/*******************************************************************************
55 * 53 *
@@ -68,24 +66,20 @@
68 * of device resources. 66 * of device resources.
69 * 67 *
70 ******************************************************************************/ 68 ******************************************************************************/
71
72acpi_status 69acpi_status
73acpi_rs_create_resource_list ( 70acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
74 union acpi_operand_object *byte_stream_buffer, 71 struct acpi_buffer *output_buffer)
75 struct acpi_buffer *output_buffer)
76{ 72{
77 73
78 acpi_status status; 74 acpi_status status;
79 u8 *byte_stream_start; 75 u8 *byte_stream_start;
80 acpi_size list_size_needed = 0; 76 acpi_size list_size_needed = 0;
81 u32 byte_stream_buffer_length; 77 u32 byte_stream_buffer_length;
82 78
79 ACPI_FUNCTION_TRACE("rs_create_resource_list");
83 80
84 ACPI_FUNCTION_TRACE ("rs_create_resource_list"); 81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
85 82 byte_stream_buffer));
86
87 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
88 byte_stream_buffer));
89 83
90 /* Params already validated, so we don't re-validate here */ 84 /* Params already validated, so we don't re-validate here */
91 85
@@ -96,36 +90,39 @@ acpi_rs_create_resource_list (
96 * Pass the byte_stream_buffer into a module that can calculate 90 * Pass the byte_stream_buffer into a module that can calculate
97 * the buffer size needed for the linked list 91 * the buffer size needed for the linked list
98 */ 92 */
99 status = acpi_rs_get_list_length (byte_stream_start, byte_stream_buffer_length, 93 status =
100 &list_size_needed); 94 acpi_rs_get_list_length(byte_stream_start,
101 95 byte_stream_buffer_length,
102 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", 96 &list_size_needed);
103 status, (u32) list_size_needed)); 97
104 if (ACPI_FAILURE (status)) { 98 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
105 return_ACPI_STATUS (status); 99 status, (u32) list_size_needed));
100 if (ACPI_FAILURE(status)) {
101 return_ACPI_STATUS(status);
106 } 102 }
107 103
108 /* Validate/Allocate/Clear caller buffer */ 104 /* Validate/Allocate/Clear caller buffer */
109 105
110 status = acpi_ut_initialize_buffer (output_buffer, list_size_needed); 106 status = acpi_ut_initialize_buffer(output_buffer, list_size_needed);
111 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS (status); 108 return_ACPI_STATUS(status);
113 } 109 }
114 110
115 /* Do the conversion */ 111 /* Do the conversion */
116 112
117 status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length, 113 status =
118 output_buffer->pointer); 114 acpi_rs_byte_stream_to_list(byte_stream_start,
119 if (ACPI_FAILURE (status)) { 115 byte_stream_buffer_length,
120 return_ACPI_STATUS (status); 116 output_buffer->pointer);
117 if (ACPI_FAILURE(status)) {
118 return_ACPI_STATUS(status);
121 } 119 }
122 120
123 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", 121 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n",
124 output_buffer->pointer, (u32) output_buffer->length)); 122 output_buffer->pointer, (u32) output_buffer->length));
125 return_ACPI_STATUS (AE_OK); 123 return_ACPI_STATUS(AE_OK);
126} 124}
127 125
128
129/******************************************************************************* 126/*******************************************************************************
130 * 127 *
131 * FUNCTION: acpi_rs_create_pci_routing_table 128 * FUNCTION: acpi_rs_create_pci_routing_table
@@ -148,44 +145,41 @@ acpi_rs_create_resource_list (
148 ******************************************************************************/ 145 ******************************************************************************/
149 146
150acpi_status 147acpi_status
151acpi_rs_create_pci_routing_table ( 148acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
152 union acpi_operand_object *package_object, 149 struct acpi_buffer *output_buffer)
153 struct acpi_buffer *output_buffer)
154{ 150{
155 u8 *buffer; 151 u8 *buffer;
156 union acpi_operand_object **top_object_list; 152 union acpi_operand_object **top_object_list;
157 union acpi_operand_object **sub_object_list; 153 union acpi_operand_object **sub_object_list;
158 union acpi_operand_object *obj_desc; 154 union acpi_operand_object *obj_desc;
159 acpi_size buffer_size_needed = 0; 155 acpi_size buffer_size_needed = 0;
160 u32 number_of_elements; 156 u32 number_of_elements;
161 u32 index; 157 u32 index;
162 struct acpi_pci_routing_table *user_prt; 158 struct acpi_pci_routing_table *user_prt;
163 struct acpi_namespace_node *node; 159 struct acpi_namespace_node *node;
164 acpi_status status; 160 acpi_status status;
165 struct acpi_buffer path_buffer; 161 struct acpi_buffer path_buffer;
166 162
167 163 ACPI_FUNCTION_TRACE("rs_create_pci_routing_table");
168 ACPI_FUNCTION_TRACE ("rs_create_pci_routing_table");
169
170 164
171 /* Params already validated, so we don't re-validate here */ 165 /* Params already validated, so we don't re-validate here */
172 166
173 /* Get the required buffer length */ 167 /* Get the required buffer length */
174 168
175 status = acpi_rs_get_pci_routing_table_length (package_object, 169 status = acpi_rs_get_pci_routing_table_length(package_object,
176 &buffer_size_needed); 170 &buffer_size_needed);
177 if (ACPI_FAILURE (status)) { 171 if (ACPI_FAILURE(status)) {
178 return_ACPI_STATUS (status); 172 return_ACPI_STATUS(status);
179 } 173 }
180 174
181 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "buffer_size_needed = %X\n", 175 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "buffer_size_needed = %X\n",
182 (u32) buffer_size_needed)); 176 (u32) buffer_size_needed));
183 177
184 /* Validate/Allocate/Clear caller buffer */ 178 /* Validate/Allocate/Clear caller buffer */
185 179
186 status = acpi_ut_initialize_buffer (output_buffer, buffer_size_needed); 180 status = acpi_ut_initialize_buffer(output_buffer, buffer_size_needed);
187 if (ACPI_FAILURE (status)) { 181 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS (status); 182 return_ACPI_STATUS(status);
189 } 183 }
190 184
191 /* 185 /*
@@ -193,10 +187,10 @@ acpi_rs_create_pci_routing_table (
193 * should be a package that in turn contains an 187 * should be a package that in turn contains an
194 * acpi_integer Address, a u8 Pin, a Name and a u8 source_index. 188 * acpi_integer Address, a u8 Pin, a Name and a u8 source_index.
195 */ 189 */
196 top_object_list = package_object->package.elements; 190 top_object_list = package_object->package.elements;
197 number_of_elements = package_object->package.count; 191 number_of_elements = package_object->package.count;
198 buffer = output_buffer->pointer; 192 buffer = output_buffer->pointer;
199 user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 193 user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
200 194
201 for (index = 0; index < number_of_elements; index++) { 195 for (index = 0; index < number_of_elements; index++) {
202 /* 196 /*
@@ -206,31 +200,34 @@ acpi_rs_create_pci_routing_table (
206 * be zero because we cleared the return buffer earlier 200 * be zero because we cleared the return buffer earlier
207 */ 201 */
208 buffer += user_prt->length; 202 buffer += user_prt->length;
209 user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 203 user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
210 204
211 /* 205 /*
212 * Fill in the Length field with the information we have at this point. 206 * Fill in the Length field with the information we have at this point.
213 * The minus four is to subtract the size of the u8 Source[4] member 207 * The minus four is to subtract the size of the u8 Source[4] member
214 * because it is added below. 208 * because it is added below.
215 */ 209 */
216 user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4); 210 user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4);
217 211
218 /* Each element of the top-level package must also be a package */ 212 /* Each element of the top-level package must also be a package */
219 213
220 if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) { 214 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) {
221 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
222 "(PRT[%X]) Need sub-package, found %s\n", 216 "(PRT[%X]) Need sub-package, found %s\n",
223 index, acpi_ut_get_object_type_name (*top_object_list))); 217 index,
224 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 218 acpi_ut_get_object_type_name
219 (*top_object_list)));
220 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
225 } 221 }
226 222
227 /* Each sub-package must be of length 4 */ 223 /* Each sub-package must be of length 4 */
228 224
229 if ((*top_object_list)->package.count != 4) { 225 if ((*top_object_list)->package.count != 4) {
230 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
231 "(PRT[%X]) Need package of length 4, found length %d\n", 227 "(PRT[%X]) Need package of length 4, found length %d\n",
232 index, (*top_object_list)->package.count)); 228 index,
233 return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); 229 (*top_object_list)->package.count));
230 return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT);
234 } 231 }
235 232
236 /* 233 /*
@@ -243,40 +240,43 @@ acpi_rs_create_pci_routing_table (
243 /* 1) First subobject: Dereference the PRT.Address */ 240 /* 1) First subobject: Dereference the PRT.Address */
244 241
245 obj_desc = sub_object_list[0]; 242 obj_desc = sub_object_list[0];
246 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 243 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
247 user_prt->address = obj_desc->integer.value; 244 user_prt->address = obj_desc->integer.value;
248 } 245 } else {
249 else { 246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 247 "(PRT[%X].Address) Need Integer, found %s\n",
251 "(PRT[%X].Address) Need Integer, found %s\n", 248 index,
252 index, acpi_ut_get_object_type_name (obj_desc))); 249 acpi_ut_get_object_type_name
253 return_ACPI_STATUS (AE_BAD_DATA); 250 (obj_desc)));
251 return_ACPI_STATUS(AE_BAD_DATA);
254 } 252 }
255 253
256 /* 2) Second subobject: Dereference the PRT.Pin */ 254 /* 2) Second subobject: Dereference the PRT.Pin */
257 255
258 obj_desc = sub_object_list[1]; 256 obj_desc = sub_object_list[1];
259 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 257 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
260 user_prt->pin = (u32) obj_desc->integer.value; 258 user_prt->pin = (u32) obj_desc->integer.value;
261 } 259 } else {
262 else { 260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
263 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 261 "(PRT[%X].Pin) Need Integer, found %s\n",
264 "(PRT[%X].Pin) Need Integer, found %s\n", 262 index,
265 index, acpi_ut_get_object_type_name (obj_desc))); 263 acpi_ut_get_object_type_name
266 return_ACPI_STATUS (AE_BAD_DATA); 264 (obj_desc)));
265 return_ACPI_STATUS(AE_BAD_DATA);
267 } 266 }
268 267
269 /* 3) Third subobject: Dereference the PRT.source_name */ 268 /* 3) Third subobject: Dereference the PRT.source_name */
270 269
271 obj_desc = sub_object_list[2]; 270 obj_desc = sub_object_list[2];
272 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 271 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
273 case ACPI_TYPE_LOCAL_REFERENCE: 272 case ACPI_TYPE_LOCAL_REFERENCE:
274 273
275 if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { 274 if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) {
276 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
277 "(PRT[%X].Source) Need name, found reference op %X\n", 276 "(PRT[%X].Source) Need name, found reference op %X\n",
278 index, obj_desc->reference.opcode)); 277 index,
279 return_ACPI_STATUS (AE_BAD_DATA); 278 obj_desc->reference.opcode));
279 return_ACPI_STATUS(AE_BAD_DATA);
280 } 280 }
281 281
282 node = obj_desc->reference.node; 282 node = obj_desc->reference.node;
@@ -284,21 +284,23 @@ acpi_rs_create_pci_routing_table (
284 /* Use *remaining* length of the buffer as max for pathname */ 284 /* Use *remaining* length of the buffer as max for pathname */
285 285
286 path_buffer.length = output_buffer->length - 286 path_buffer.length = output_buffer->length -
287 (u32) ((u8 *) user_prt->source - 287 (u32) ((u8 *) user_prt->source -
288 (u8 *) output_buffer->pointer); 288 (u8 *) output_buffer->pointer);
289 path_buffer.pointer = user_prt->source; 289 path_buffer.pointer = user_prt->source;
290 290
291 status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer); 291 status =
292 acpi_ns_handle_to_pathname((acpi_handle) node,
293 &path_buffer);
292 294
293 /* +1 to include null terminator */ 295 /* +1 to include null terminator */
294 296
295 user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; 297 user_prt->length +=
298 (u32) ACPI_STRLEN(user_prt->source) + 1;
296 break; 299 break;
297 300
298
299 case ACPI_TYPE_STRING: 301 case ACPI_TYPE_STRING:
300 302
301 ACPI_STRCPY (user_prt->source, obj_desc->string.pointer); 303 ACPI_STRCPY(user_prt->source, obj_desc->string.pointer);
302 304
303 /* 305 /*
304 * Add to the Length field the length of the string 306 * Add to the Length field the length of the string
@@ -307,7 +309,6 @@ acpi_rs_create_pci_routing_table (
307 user_prt->length += obj_desc->string.length + 1; 309 user_prt->length += obj_desc->string.length + 1;
308 break; 310 break;
309 311
310
311 case ACPI_TYPE_INTEGER: 312 case ACPI_TYPE_INTEGER:
312 /* 313 /*
313 * If this is a number, then the Source Name is NULL, since the 314 * If this is a number, then the Source Name is NULL, since the
@@ -315,33 +316,36 @@ acpi_rs_create_pci_routing_table (
315 * 316 *
316 * Add to the Length field the length of the u32 NULL 317 * Add to the Length field the length of the u32 NULL
317 */ 318 */
318 user_prt->length += sizeof (u32); 319 user_prt->length += sizeof(u32);
319 break; 320 break;
320 321
321
322 default: 322 default:
323 323
324 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 324 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
325 "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", 325 "(PRT[%X].Source) Need Ref/String/Integer, found %s\n",
326 index, acpi_ut_get_object_type_name (obj_desc))); 326 index,
327 return_ACPI_STATUS (AE_BAD_DATA); 327 acpi_ut_get_object_type_name
328 (obj_desc)));
329 return_ACPI_STATUS(AE_BAD_DATA);
328 } 330 }
329 331
330 /* Now align the current length */ 332 /* Now align the current length */
331 333
332 user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length); 334 user_prt->length =
335 (u32) ACPI_ROUND_UP_to_64_bITS(user_prt->length);
333 336
334 /* 4) Fourth subobject: Dereference the PRT.source_index */ 337 /* 4) Fourth subobject: Dereference the PRT.source_index */
335 338
336 obj_desc = sub_object_list[3]; 339 obj_desc = sub_object_list[3];
337 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 340 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
338 user_prt->source_index = (u32) obj_desc->integer.value; 341 user_prt->source_index = (u32) obj_desc->integer.value;
339 } 342 } else {
340 else { 343 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
341 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 344 "(PRT[%X].source_index) Need Integer, found %s\n",
342 "(PRT[%X].source_index) Need Integer, found %s\n", 345 index,
343 index, acpi_ut_get_object_type_name (obj_desc))); 346 acpi_ut_get_object_type_name
344 return_ACPI_STATUS (AE_BAD_DATA); 347 (obj_desc)));
348 return_ACPI_STATUS(AE_BAD_DATA);
345 } 349 }
346 350
347 /* Point to the next union acpi_operand_object in the top level package */ 351 /* Point to the next union acpi_operand_object in the top level package */
@@ -349,12 +353,11 @@ acpi_rs_create_pci_routing_table (
349 top_object_list++; 353 top_object_list++;
350 } 354 }
351 355
352 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", 356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n",
353 output_buffer->pointer, (u32) output_buffer->length)); 357 output_buffer->pointer, (u32) output_buffer->length));
354 return_ACPI_STATUS (AE_OK); 358 return_ACPI_STATUS(AE_OK);
355} 359}
356 360
357
358/******************************************************************************* 361/*******************************************************************************
359 * 362 *
360 * FUNCTION: acpi_rs_create_byte_stream 363 * FUNCTION: acpi_rs_create_byte_stream
@@ -374,19 +377,16 @@ acpi_rs_create_pci_routing_table (
374 ******************************************************************************/ 377 ******************************************************************************/
375 378
376acpi_status 379acpi_status
377acpi_rs_create_byte_stream ( 380acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
378 struct acpi_resource *linked_list_buffer, 381 struct acpi_buffer *output_buffer)
379 struct acpi_buffer *output_buffer)
380{ 382{
381 acpi_status status; 383 acpi_status status;
382 acpi_size byte_stream_size_needed = 0; 384 acpi_size byte_stream_size_needed = 0;
383
384
385 ACPI_FUNCTION_TRACE ("rs_create_byte_stream");
386 385
386 ACPI_FUNCTION_TRACE("rs_create_byte_stream");
387 387
388 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "linked_list_buffer = %p\n", 388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n",
389 linked_list_buffer)); 389 linked_list_buffer));
390 390
391 /* 391 /*
392 * Params already validated, so we don't re-validate here 392 * Params already validated, so we don't re-validate here
@@ -394,32 +394,35 @@ acpi_rs_create_byte_stream (
394 * Pass the linked_list_buffer into a module that calculates 394 * Pass the linked_list_buffer into a module that calculates
395 * the buffer size needed for the byte stream. 395 * the buffer size needed for the byte stream.
396 */ 396 */
397 status = acpi_rs_get_byte_stream_length (linked_list_buffer, 397 status = acpi_rs_get_byte_stream_length(linked_list_buffer,
398 &byte_stream_size_needed); 398 &byte_stream_size_needed);
399 399
400 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", 400 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n",
401 (u32) byte_stream_size_needed, acpi_format_exception (status))); 401 (u32) byte_stream_size_needed,
402 if (ACPI_FAILURE (status)) { 402 acpi_format_exception(status)));
403 return_ACPI_STATUS (status); 403 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS(status);
404 } 405 }
405 406
406 /* Validate/Allocate/Clear caller buffer */ 407 /* Validate/Allocate/Clear caller buffer */
407 408
408 status = acpi_ut_initialize_buffer (output_buffer, byte_stream_size_needed); 409 status =
409 if (ACPI_FAILURE (status)) { 410 acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed);
410 return_ACPI_STATUS (status); 411 if (ACPI_FAILURE(status)) {
412 return_ACPI_STATUS(status);
411 } 413 }
412 414
413 /* Do the conversion */ 415 /* Do the conversion */
414 416
415 status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed, 417 status =
416 output_buffer->pointer); 418 acpi_rs_list_to_byte_stream(linked_list_buffer,
417 if (ACPI_FAILURE (status)) { 419 byte_stream_size_needed,
418 return_ACPI_STATUS (status); 420 output_buffer->pointer);
421 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status);
419 } 423 }
420 424
421 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", 425 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n",
422 output_buffer->pointer, (u32) output_buffer->length)); 426 output_buffer->pointer, (u32) output_buffer->length));
423 return_ACPI_STATUS (AE_OK); 427 return_ACPI_STATUS(AE_OK);
424} 428}
425
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 1935dab2ab51..75bd34d1783f 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -41,69 +41,40 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsdump") 48ACPI_MODULE_NAME("rsdump")
50 49
50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_rs_dump_irq(union acpi_resource_data *data);
52 53
53static void 54static void acpi_rs_dump_address16(union acpi_resource_data *data);
54acpi_rs_dump_irq (
55 union acpi_resource_data *data);
56
57static void
58acpi_rs_dump_address16 (
59 union acpi_resource_data *data);
60
61static void
62acpi_rs_dump_address32 (
63 union acpi_resource_data *data);
64 55
65static void 56static void acpi_rs_dump_address32(union acpi_resource_data *data);
66acpi_rs_dump_address64 (
67 union acpi_resource_data *data);
68 57
69static void 58static void acpi_rs_dump_address64(union acpi_resource_data *data);
70acpi_rs_dump_dma (
71 union acpi_resource_data *data);
72 59
73static void 60static void acpi_rs_dump_dma(union acpi_resource_data *data);
74acpi_rs_dump_io (
75 union acpi_resource_data *data);
76 61
77static void 62static void acpi_rs_dump_io(union acpi_resource_data *data);
78acpi_rs_dump_extended_irq (
79 union acpi_resource_data *data);
80 63
81static void 64static void acpi_rs_dump_extended_irq(union acpi_resource_data *data);
82acpi_rs_dump_fixed_io (
83 union acpi_resource_data *data);
84 65
85static void 66static void acpi_rs_dump_fixed_io(union acpi_resource_data *data);
86acpi_rs_dump_fixed_memory32 (
87 union acpi_resource_data *data);
88 67
89static void 68static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data);
90acpi_rs_dump_memory24 (
91 union acpi_resource_data *data);
92 69
93static void 70static void acpi_rs_dump_memory24(union acpi_resource_data *data);
94acpi_rs_dump_memory32 (
95 union acpi_resource_data *data);
96 71
97static void 72static void acpi_rs_dump_memory32(union acpi_resource_data *data);
98acpi_rs_dump_start_depend_fns (
99 union acpi_resource_data *data);
100 73
101static void 74static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data);
102acpi_rs_dump_vendor_specific (
103 union acpi_resource_data *data);
104 75
76static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data);
105 77
106#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
107/******************************************************************************* 78/*******************************************************************************
108 * 79 *
109 * FUNCTION: acpi_rs_dump_irq 80 * FUNCTION: acpi_rs_dump_irq
@@ -116,39 +87,37 @@ acpi_rs_dump_vendor_specific (
116 * 87 *
117 ******************************************************************************/ 88 ******************************************************************************/
118 89
119static void 90static void acpi_rs_dump_irq(union acpi_resource_data *data)
120acpi_rs_dump_irq (
121 union acpi_resource_data *data)
122{ 91{
123 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *) data; 92 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *)data;
124 u8 index = 0; 93 u8 index = 0;
125
126
127 ACPI_FUNCTION_ENTRY ();
128 94
95 ACPI_FUNCTION_ENTRY();
129 96
130 acpi_os_printf ("IRQ Resource\n"); 97 acpi_os_printf("IRQ Resource\n");
131 98
132 acpi_os_printf (" %s Triggered\n", 99 acpi_os_printf(" %s Triggered\n",
133 ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); 100 ACPI_LEVEL_SENSITIVE ==
101 irq_data->edge_level ? "Level" : "Edge");
134 102
135 acpi_os_printf (" Active %s\n", 103 acpi_os_printf(" Active %s\n",
136 ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); 104 ACPI_ACTIVE_LOW ==
105 irq_data->active_high_low ? "Low" : "High");
137 106
138 acpi_os_printf (" %s\n", 107 acpi_os_printf(" %s\n",
139 ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); 108 ACPI_SHARED ==
109 irq_data->shared_exclusive ? "Shared" : "Exclusive");
140 110
141 acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts); 111 acpi_os_printf(" %X Interrupts ( ", irq_data->number_of_interrupts);
142 112
143 for (index = 0; index < irq_data->number_of_interrupts; index++) { 113 for (index = 0; index < irq_data->number_of_interrupts; index++) {
144 acpi_os_printf ("%X ", irq_data->interrupts[index]); 114 acpi_os_printf("%X ", irq_data->interrupts[index]);
145 } 115 }
146 116
147 acpi_os_printf (")\n"); 117 acpi_os_printf(")\n");
148 return; 118 return;
149} 119}
150 120
151
152/******************************************************************************* 121/*******************************************************************************
153 * 122 *
154 * FUNCTION: acpi_rs_dump_dma 123 * FUNCTION: acpi_rs_dump_dma
@@ -161,75 +130,69 @@ acpi_rs_dump_irq (
161 * 130 *
162 ******************************************************************************/ 131 ******************************************************************************/
163 132
164static void 133static void acpi_rs_dump_dma(union acpi_resource_data *data)
165acpi_rs_dump_dma (
166 union acpi_resource_data *data)
167{ 134{
168 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *) data; 135 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *)data;
169 u8 index = 0; 136 u8 index = 0;
170
171
172 ACPI_FUNCTION_ENTRY ();
173 137
138 ACPI_FUNCTION_ENTRY();
174 139
175 acpi_os_printf ("DMA Resource\n"); 140 acpi_os_printf("DMA Resource\n");
176 141
177 switch (dma_data->type) { 142 switch (dma_data->type) {
178 case ACPI_COMPATIBILITY: 143 case ACPI_COMPATIBILITY:
179 acpi_os_printf (" Compatibility mode\n"); 144 acpi_os_printf(" Compatibility mode\n");
180 break; 145 break;
181 146
182 case ACPI_TYPE_A: 147 case ACPI_TYPE_A:
183 acpi_os_printf (" Type A\n"); 148 acpi_os_printf(" Type A\n");
184 break; 149 break;
185 150
186 case ACPI_TYPE_B: 151 case ACPI_TYPE_B:
187 acpi_os_printf (" Type B\n"); 152 acpi_os_printf(" Type B\n");
188 break; 153 break;
189 154
190 case ACPI_TYPE_F: 155 case ACPI_TYPE_F:
191 acpi_os_printf (" Type F\n"); 156 acpi_os_printf(" Type F\n");
192 break; 157 break;
193 158
194 default: 159 default:
195 acpi_os_printf (" Invalid DMA type\n"); 160 acpi_os_printf(" Invalid DMA type\n");
196 break; 161 break;
197 } 162 }
198 163
199 acpi_os_printf (" %sBus Master\n", 164 acpi_os_printf(" %sBus Master\n",
200 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); 165 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
201
202 166
203 switch (dma_data->transfer) { 167 switch (dma_data->transfer) {
204 case ACPI_TRANSFER_8: 168 case ACPI_TRANSFER_8:
205 acpi_os_printf (" 8-bit only transfer\n"); 169 acpi_os_printf(" 8-bit only transfer\n");
206 break; 170 break;
207 171
208 case ACPI_TRANSFER_8_16: 172 case ACPI_TRANSFER_8_16:
209 acpi_os_printf (" 8 and 16-bit transfer\n"); 173 acpi_os_printf(" 8 and 16-bit transfer\n");
210 break; 174 break;
211 175
212 case ACPI_TRANSFER_16: 176 case ACPI_TRANSFER_16:
213 acpi_os_printf (" 16 bit only transfer\n"); 177 acpi_os_printf(" 16 bit only transfer\n");
214 break; 178 break;
215 179
216 default: 180 default:
217 acpi_os_printf (" Invalid transfer preference\n"); 181 acpi_os_printf(" Invalid transfer preference\n");
218 break; 182 break;
219 } 183 }
220 184
221 acpi_os_printf (" Number of Channels: %X ( ", 185 acpi_os_printf(" Number of Channels: %X ( ",
222 dma_data->number_of_channels); 186 dma_data->number_of_channels);
223 187
224 for (index = 0; index < dma_data->number_of_channels; index++) { 188 for (index = 0; index < dma_data->number_of_channels; index++) {
225 acpi_os_printf ("%X ", dma_data->channels[index]); 189 acpi_os_printf("%X ", dma_data->channels[index]);
226 } 190 }
227 191
228 acpi_os_printf (")\n"); 192 acpi_os_printf(")\n");
229 return; 193 return;
230} 194}
231 195
232
233/******************************************************************************* 196/*******************************************************************************
234 * 197 *
235 * FUNCTION: acpi_rs_dump_start_depend_fns 198 * FUNCTION: acpi_rs_dump_start_depend_fns
@@ -242,58 +205,54 @@ acpi_rs_dump_dma (
242 * 205 *
243 ******************************************************************************/ 206 ******************************************************************************/
244 207
245static void 208static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data)
246acpi_rs_dump_start_depend_fns (
247 union acpi_resource_data *data)
248{ 209{
249 struct acpi_resource_start_dpf *sdf_data = (struct acpi_resource_start_dpf *) data; 210 struct acpi_resource_start_dpf *sdf_data =
250 211 (struct acpi_resource_start_dpf *)data;
251 212
252 ACPI_FUNCTION_ENTRY (); 213 ACPI_FUNCTION_ENTRY();
253 214
254 215 acpi_os_printf("Start Dependent Functions Resource\n");
255 acpi_os_printf ("Start Dependent Functions Resource\n");
256 216
257 switch (sdf_data->compatibility_priority) { 217 switch (sdf_data->compatibility_priority) {
258 case ACPI_GOOD_CONFIGURATION: 218 case ACPI_GOOD_CONFIGURATION:
259 acpi_os_printf (" Good configuration\n"); 219 acpi_os_printf(" Good configuration\n");
260 break; 220 break;
261 221
262 case ACPI_ACCEPTABLE_CONFIGURATION: 222 case ACPI_ACCEPTABLE_CONFIGURATION:
263 acpi_os_printf (" Acceptable configuration\n"); 223 acpi_os_printf(" Acceptable configuration\n");
264 break; 224 break;
265 225
266 case ACPI_SUB_OPTIMAL_CONFIGURATION: 226 case ACPI_SUB_OPTIMAL_CONFIGURATION:
267 acpi_os_printf (" Sub-optimal configuration\n"); 227 acpi_os_printf(" Sub-optimal configuration\n");
268 break; 228 break;
269 229
270 default: 230 default:
271 acpi_os_printf (" Invalid compatibility priority\n"); 231 acpi_os_printf(" Invalid compatibility priority\n");
272 break; 232 break;
273 } 233 }
274 234
275 switch(sdf_data->performance_robustness) { 235 switch (sdf_data->performance_robustness) {
276 case ACPI_GOOD_CONFIGURATION: 236 case ACPI_GOOD_CONFIGURATION:
277 acpi_os_printf (" Good configuration\n"); 237 acpi_os_printf(" Good configuration\n");
278 break; 238 break;
279 239
280 case ACPI_ACCEPTABLE_CONFIGURATION: 240 case ACPI_ACCEPTABLE_CONFIGURATION:
281 acpi_os_printf (" Acceptable configuration\n"); 241 acpi_os_printf(" Acceptable configuration\n");
282 break; 242 break;
283 243
284 case ACPI_SUB_OPTIMAL_CONFIGURATION: 244 case ACPI_SUB_OPTIMAL_CONFIGURATION:
285 acpi_os_printf (" Sub-optimal configuration\n"); 245 acpi_os_printf(" Sub-optimal configuration\n");
286 break; 246 break;
287 247
288 default: 248 default:
289 acpi_os_printf (" Invalid performance robustness preference\n"); 249 acpi_os_printf(" Invalid performance robustness preference\n");
290 break; 250 break;
291 } 251 }
292 252
293 return; 253 return;
294} 254}
295 255
296
297/******************************************************************************* 256/*******************************************************************************
298 * 257 *
299 * FUNCTION: acpi_rs_dump_io 258 * FUNCTION: acpi_rs_dump_io
@@ -306,33 +265,30 @@ acpi_rs_dump_start_depend_fns (
306 * 265 *
307 ******************************************************************************/ 266 ******************************************************************************/
308 267
309static void 268static void acpi_rs_dump_io(union acpi_resource_data *data)
310acpi_rs_dump_io (
311 union acpi_resource_data *data)
312{ 269{
313 struct acpi_resource_io *io_data = (struct acpi_resource_io *) data; 270 struct acpi_resource_io *io_data = (struct acpi_resource_io *)data;
314
315 271
316 ACPI_FUNCTION_ENTRY (); 272 ACPI_FUNCTION_ENTRY();
317 273
274 acpi_os_printf("Io Resource\n");
318 275
319 acpi_os_printf ("Io Resource\n"); 276 acpi_os_printf(" %d bit decode\n",
277 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
320 278
321 acpi_os_printf (" %d bit decode\n", 279 acpi_os_printf(" Range minimum base: %08X\n",
322 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); 280 io_data->min_base_address);
323 281
324 acpi_os_printf (" Range minimum base: %08X\n", io_data->min_base_address); 282 acpi_os_printf(" Range maximum base: %08X\n",
283 io_data->max_base_address);
325 284
326 acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address); 285 acpi_os_printf(" Alignment: %08X\n", io_data->alignment);
327 286
328 acpi_os_printf (" Alignment: %08X\n", io_data->alignment); 287 acpi_os_printf(" Range Length: %08X\n", io_data->range_length);
329
330 acpi_os_printf (" Range Length: %08X\n", io_data->range_length);
331 288
332 return; 289 return;
333} 290}
334 291
335
336/******************************************************************************* 292/*******************************************************************************
337 * 293 *
338 * FUNCTION: acpi_rs_dump_fixed_io 294 * FUNCTION: acpi_rs_dump_fixed_io
@@ -345,25 +301,22 @@ acpi_rs_dump_io (
345 * 301 *
346 ******************************************************************************/ 302 ******************************************************************************/
347 303
348static void 304static void acpi_rs_dump_fixed_io(union acpi_resource_data *data)
349acpi_rs_dump_fixed_io (
350 union acpi_resource_data *data)
351{ 305{
352 struct acpi_resource_fixed_io *fixed_io_data = (struct acpi_resource_fixed_io *) data; 306 struct acpi_resource_fixed_io *fixed_io_data =
353 307 (struct acpi_resource_fixed_io *)data;
354 308
355 ACPI_FUNCTION_ENTRY (); 309 ACPI_FUNCTION_ENTRY();
356 310
311 acpi_os_printf("Fixed Io Resource\n");
312 acpi_os_printf(" Range base address: %08X",
313 fixed_io_data->base_address);
357 314
358 acpi_os_printf ("Fixed Io Resource\n"); 315 acpi_os_printf(" Range length: %08X", fixed_io_data->range_length);
359 acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address);
360
361 acpi_os_printf (" Range length: %08X", fixed_io_data->range_length);
362 316
363 return; 317 return;
364} 318}
365 319
366
367/******************************************************************************* 320/*******************************************************************************
368 * 321 *
369 * FUNCTION: acpi_rs_dump_vendor_specific 322 * FUNCTION: acpi_rs_dump_vendor_specific
@@ -376,30 +329,26 @@ acpi_rs_dump_fixed_io (
376 * 329 *
377 ******************************************************************************/ 330 ******************************************************************************/
378 331
379static void 332static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data)
380acpi_rs_dump_vendor_specific (
381 union acpi_resource_data *data)
382{ 333{
383 struct acpi_resource_vendor *vendor_data = (struct acpi_resource_vendor *) data; 334 struct acpi_resource_vendor *vendor_data =
384 u16 index = 0; 335 (struct acpi_resource_vendor *)data;
385 336 u16 index = 0;
386 337
387 ACPI_FUNCTION_ENTRY (); 338 ACPI_FUNCTION_ENTRY();
388 339
340 acpi_os_printf("Vendor Specific Resource\n");
389 341
390 acpi_os_printf ("Vendor Specific Resource\n"); 342 acpi_os_printf(" Length: %08X\n", vendor_data->length);
391
392 acpi_os_printf (" Length: %08X\n", vendor_data->length);
393 343
394 for (index = 0; index < vendor_data->length; index++) { 344 for (index = 0; index < vendor_data->length; index++) {
395 acpi_os_printf (" Byte %X: %08X\n", 345 acpi_os_printf(" Byte %X: %08X\n",
396 index, vendor_data->reserved[index]); 346 index, vendor_data->reserved[index]);
397 } 347 }
398 348
399 return; 349 return;
400} 350}
401 351
402
403/******************************************************************************* 352/*******************************************************************************
404 * 353 *
405 * FUNCTION: acpi_rs_dump_memory24 354 * FUNCTION: acpi_rs_dump_memory24
@@ -412,37 +361,33 @@ acpi_rs_dump_vendor_specific (
412 * 361 *
413 ******************************************************************************/ 362 ******************************************************************************/
414 363
415static void 364static void acpi_rs_dump_memory24(union acpi_resource_data *data)
416acpi_rs_dump_memory24 (
417 union acpi_resource_data *data)
418{ 365{
419 struct acpi_resource_mem24 *memory24_data = (struct acpi_resource_mem24 *) data; 366 struct acpi_resource_mem24 *memory24_data =
420 367 (struct acpi_resource_mem24 *)data;
421 368
422 ACPI_FUNCTION_ENTRY (); 369 ACPI_FUNCTION_ENTRY();
423 370
371 acpi_os_printf("24-Bit Memory Range Resource\n");
424 372
425 acpi_os_printf ("24-Bit Memory Range Resource\n"); 373 acpi_os_printf(" Read%s\n",
374 ACPI_READ_WRITE_MEMORY ==
375 memory24_data->read_write_attribute ?
376 "/Write" : " only");
426 377
427 acpi_os_printf (" Read%s\n", 378 acpi_os_printf(" Range minimum base: %08X\n",
428 ACPI_READ_WRITE_MEMORY == 379 memory24_data->min_base_address);
429 memory24_data->read_write_attribute ?
430 "/Write" : " only");
431 380
432 acpi_os_printf (" Range minimum base: %08X\n", 381 acpi_os_printf(" Range maximum base: %08X\n",
433 memory24_data->min_base_address); 382 memory24_data->max_base_address);
434 383
435 acpi_os_printf (" Range maximum base: %08X\n", 384 acpi_os_printf(" Alignment: %08X\n", memory24_data->alignment);
436 memory24_data->max_base_address);
437 385
438 acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment); 386 acpi_os_printf(" Range length: %08X\n", memory24_data->range_length);
439
440 acpi_os_printf (" Range length: %08X\n", memory24_data->range_length);
441 387
442 return; 388 return;
443} 389}
444 390
445
446/******************************************************************************* 391/*******************************************************************************
447 * 392 *
448 * FUNCTION: acpi_rs_dump_memory32 393 * FUNCTION: acpi_rs_dump_memory32
@@ -455,37 +400,33 @@ acpi_rs_dump_memory24 (
455 * 400 *
456 ******************************************************************************/ 401 ******************************************************************************/
457 402
458static void 403static void acpi_rs_dump_memory32(union acpi_resource_data *data)
459acpi_rs_dump_memory32 (
460 union acpi_resource_data *data)
461{ 404{
462 struct acpi_resource_mem32 *memory32_data = (struct acpi_resource_mem32 *) data; 405 struct acpi_resource_mem32 *memory32_data =
463 406 (struct acpi_resource_mem32 *)data;
464
465 ACPI_FUNCTION_ENTRY ();
466 407
408 ACPI_FUNCTION_ENTRY();
467 409
468 acpi_os_printf ("32-Bit Memory Range Resource\n"); 410 acpi_os_printf("32-Bit Memory Range Resource\n");
469 411
470 acpi_os_printf (" Read%s\n", 412 acpi_os_printf(" Read%s\n",
471 ACPI_READ_WRITE_MEMORY == 413 ACPI_READ_WRITE_MEMORY ==
472 memory32_data->read_write_attribute ? 414 memory32_data->read_write_attribute ?
473 "/Write" : " only"); 415 "/Write" : " only");
474 416
475 acpi_os_printf (" Range minimum base: %08X\n", 417 acpi_os_printf(" Range minimum base: %08X\n",
476 memory32_data->min_base_address); 418 memory32_data->min_base_address);
477 419
478 acpi_os_printf (" Range maximum base: %08X\n", 420 acpi_os_printf(" Range maximum base: %08X\n",
479 memory32_data->max_base_address); 421 memory32_data->max_base_address);
480 422
481 acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment); 423 acpi_os_printf(" Alignment: %08X\n", memory32_data->alignment);
482 424
483 acpi_os_printf (" Range length: %08X\n", memory32_data->range_length); 425 acpi_os_printf(" Range length: %08X\n", memory32_data->range_length);
484 426
485 return; 427 return;
486} 428}
487 429
488
489/******************************************************************************* 430/*******************************************************************************
490 * 431 *
491 * FUNCTION: acpi_rs_dump_fixed_memory32 432 * FUNCTION: acpi_rs_dump_fixed_memory32
@@ -498,33 +439,29 @@ acpi_rs_dump_memory32 (
498 * 439 *
499 ******************************************************************************/ 440 ******************************************************************************/
500 441
501static void 442static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data)
502acpi_rs_dump_fixed_memory32 (
503 union acpi_resource_data *data)
504{ 443{
505 struct acpi_resource_fixed_mem32 *fixed_memory32_data = 444 struct acpi_resource_fixed_mem32 *fixed_memory32_data =
506 (struct acpi_resource_fixed_mem32 *) data; 445 (struct acpi_resource_fixed_mem32 *)data;
507
508
509 ACPI_FUNCTION_ENTRY ();
510 446
447 ACPI_FUNCTION_ENTRY();
511 448
512 acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n"); 449 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
513 450
514 acpi_os_printf (" Read%s\n", 451 acpi_os_printf(" Read%s\n",
515 ACPI_READ_WRITE_MEMORY == 452 ACPI_READ_WRITE_MEMORY ==
516 fixed_memory32_data->read_write_attribute ? "/Write" : " Only"); 453 fixed_memory32_data->
454 read_write_attribute ? "/Write" : " Only");
517 455
518 acpi_os_printf (" Range base address: %08X\n", 456 acpi_os_printf(" Range base address: %08X\n",
519 fixed_memory32_data->range_base_address); 457 fixed_memory32_data->range_base_address);
520 458
521 acpi_os_printf (" Range length: %08X\n", 459 acpi_os_printf(" Range length: %08X\n",
522 fixed_memory32_data->range_length); 460 fixed_memory32_data->range_length);
523 461
524 return; 462 return;
525} 463}
526 464
527
528/******************************************************************************* 465/*******************************************************************************
529 * 466 *
530 * FUNCTION: acpi_rs_dump_address16 467 * FUNCTION: acpi_rs_dump_address16
@@ -537,134 +474,136 @@ acpi_rs_dump_fixed_memory32 (
537 * 474 *
538 ******************************************************************************/ 475 ******************************************************************************/
539 476
540static void 477static void acpi_rs_dump_address16(union acpi_resource_data *data)
541acpi_rs_dump_address16 (
542 union acpi_resource_data *data)
543{ 478{
544 struct acpi_resource_address16 *address16_data = (struct acpi_resource_address16 *) data; 479 struct acpi_resource_address16 *address16_data =
545 480 (struct acpi_resource_address16 *)data;
546
547 ACPI_FUNCTION_ENTRY ();
548 481
482 ACPI_FUNCTION_ENTRY();
549 483
550 acpi_os_printf ("16-Bit Address Space Resource\n"); 484 acpi_os_printf("16-Bit Address Space Resource\n");
551 acpi_os_printf (" Resource Type: "); 485 acpi_os_printf(" Resource Type: ");
552 486
553 switch (address16_data->resource_type) { 487 switch (address16_data->resource_type) {
554 case ACPI_MEMORY_RANGE: 488 case ACPI_MEMORY_RANGE:
555 489
556 acpi_os_printf ("Memory Range\n"); 490 acpi_os_printf("Memory Range\n");
557 491
558 switch (address16_data->attribute.memory.cache_attribute) { 492 switch (address16_data->attribute.memory.cache_attribute) {
559 case ACPI_NON_CACHEABLE_MEMORY: 493 case ACPI_NON_CACHEABLE_MEMORY:
560 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 494 acpi_os_printf
495 (" Type Specific: Noncacheable memory\n");
561 break; 496 break;
562 497
563 case ACPI_CACHABLE_MEMORY: 498 case ACPI_CACHABLE_MEMORY:
564 acpi_os_printf (" Type Specific: Cacheable memory\n"); 499 acpi_os_printf(" Type Specific: Cacheable memory\n");
565 break; 500 break;
566 501
567 case ACPI_WRITE_COMBINING_MEMORY: 502 case ACPI_WRITE_COMBINING_MEMORY:
568 acpi_os_printf (" Type Specific: Write-combining memory\n"); 503 acpi_os_printf
504 (" Type Specific: Write-combining memory\n");
569 break; 505 break;
570 506
571 case ACPI_PREFETCHABLE_MEMORY: 507 case ACPI_PREFETCHABLE_MEMORY:
572 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 508 acpi_os_printf
509 (" Type Specific: Prefetchable memory\n");
573 break; 510 break;
574 511
575 default: 512 default:
576 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 513 acpi_os_printf
514 (" Type Specific: Invalid cache attribute\n");
577 break; 515 break;
578 } 516 }
579 517
580 acpi_os_printf (" Type Specific: Read%s\n", 518 acpi_os_printf(" Type Specific: Read%s\n",
581 ACPI_READ_WRITE_MEMORY == 519 ACPI_READ_WRITE_MEMORY ==
582 address16_data->attribute.memory.read_write_attribute ? 520 address16_data->attribute.memory.
583 "/Write" : " Only"); 521 read_write_attribute ? "/Write" : " Only");
584 break; 522 break;
585 523
586 case ACPI_IO_RANGE: 524 case ACPI_IO_RANGE:
587 525
588 acpi_os_printf ("I/O Range\n"); 526 acpi_os_printf("I/O Range\n");
589 527
590 switch (address16_data->attribute.io.range_attribute) { 528 switch (address16_data->attribute.io.range_attribute) {
591 case ACPI_NON_ISA_ONLY_RANGES: 529 case ACPI_NON_ISA_ONLY_RANGES:
592 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 530 acpi_os_printf
531 (" Type Specific: Non-ISA Io Addresses\n");
593 break; 532 break;
594 533
595 case ACPI_ISA_ONLY_RANGES: 534 case ACPI_ISA_ONLY_RANGES:
596 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 535 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
597 break; 536 break;
598 537
599 case ACPI_ENTIRE_RANGE: 538 case ACPI_ENTIRE_RANGE:
600 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); 539 acpi_os_printf
540 (" Type Specific: ISA and non-ISA Io Addresses\n");
601 break; 541 break;
602 542
603 default: 543 default:
604 acpi_os_printf (" Type Specific: Invalid range attribute\n"); 544 acpi_os_printf
545 (" Type Specific: Invalid range attribute\n");
605 break; 546 break;
606 } 547 }
607 548
608 acpi_os_printf (" Type Specific: %s Translation\n", 549 acpi_os_printf(" Type Specific: %s Translation\n",
609 ACPI_SPARSE_TRANSLATION == 550 ACPI_SPARSE_TRANSLATION ==
610 address16_data->attribute.io.translation_attribute ? 551 address16_data->attribute.io.
611 "Sparse" : "Dense"); 552 translation_attribute ? "Sparse" : "Dense");
612 break; 553 break;
613 554
614 case ACPI_BUS_NUMBER_RANGE: 555 case ACPI_BUS_NUMBER_RANGE:
615 556
616 acpi_os_printf ("Bus Number Range\n"); 557 acpi_os_printf("Bus Number Range\n");
617 break; 558 break;
618 559
619 default: 560 default:
620 561
621 acpi_os_printf ("0x%2.2X\n", address16_data->resource_type); 562 acpi_os_printf("0x%2.2X\n", address16_data->resource_type);
622 break; 563 break;
623 } 564 }
624 565
625 acpi_os_printf (" Resource %s\n", 566 acpi_os_printf(" Resource %s\n",
626 ACPI_CONSUMER == address16_data->producer_consumer ? 567 ACPI_CONSUMER == address16_data->producer_consumer ?
627 "Consumer" : "Producer"); 568 "Consumer" : "Producer");
628 569
629 acpi_os_printf (" %s decode\n", 570 acpi_os_printf(" %s decode\n",
630 ACPI_SUB_DECODE == address16_data->decode ? 571 ACPI_SUB_DECODE == address16_data->decode ?
631 "Subtractive" : "Positive"); 572 "Subtractive" : "Positive");
632 573
633 acpi_os_printf (" Min address is %s fixed\n", 574 acpi_os_printf(" Min address is %s fixed\n",
634 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? 575 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
635 "" : "not"); 576 "" : "not");
636 577
637 acpi_os_printf (" Max address is %s fixed\n", 578 acpi_os_printf(" Max address is %s fixed\n",
638 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? 579 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
639 "" : "not"); 580 "" : "not");
640 581
641 acpi_os_printf (" Granularity: %08X\n", 582 acpi_os_printf(" Granularity: %08X\n", address16_data->granularity);
642 address16_data->granularity);
643 583
644 acpi_os_printf (" Address range min: %08X\n", 584 acpi_os_printf(" Address range min: %08X\n",
645 address16_data->min_address_range); 585 address16_data->min_address_range);
646 586
647 acpi_os_printf (" Address range max: %08X\n", 587 acpi_os_printf(" Address range max: %08X\n",
648 address16_data->max_address_range); 588 address16_data->max_address_range);
649 589
650 acpi_os_printf (" Address translation offset: %08X\n", 590 acpi_os_printf(" Address translation offset: %08X\n",
651 address16_data->address_translation_offset); 591 address16_data->address_translation_offset);
652 592
653 acpi_os_printf (" Address Length: %08X\n", 593 acpi_os_printf(" Address Length: %08X\n",
654 address16_data->address_length); 594 address16_data->address_length);
655 595
656 if (0xFF != address16_data->resource_source.index) { 596 if (0xFF != address16_data->resource_source.index) {
657 acpi_os_printf (" Resource Source Index: %X\n", 597 acpi_os_printf(" Resource Source Index: %X\n",
658 address16_data->resource_source.index); 598 address16_data->resource_source.index);
659 599
660 acpi_os_printf (" Resource Source: %s\n", 600 acpi_os_printf(" Resource Source: %s\n",
661 address16_data->resource_source.string_ptr); 601 address16_data->resource_source.string_ptr);
662 } 602 }
663 603
664 return; 604 return;
665} 605}
666 606
667
668/******************************************************************************* 607/*******************************************************************************
669 * 608 *
670 * FUNCTION: acpi_rs_dump_address32 609 * FUNCTION: acpi_rs_dump_address32
@@ -677,134 +616,136 @@ acpi_rs_dump_address16 (
677 * 616 *
678 ******************************************************************************/ 617 ******************************************************************************/
679 618
680static void 619static void acpi_rs_dump_address32(union acpi_resource_data *data)
681acpi_rs_dump_address32 (
682 union acpi_resource_data *data)
683{ 620{
684 struct acpi_resource_address32 *address32_data = (struct acpi_resource_address32 *) data; 621 struct acpi_resource_address32 *address32_data =
685 622 (struct acpi_resource_address32 *)data;
686
687 ACPI_FUNCTION_ENTRY ();
688 623
624 ACPI_FUNCTION_ENTRY();
689 625
690 acpi_os_printf ("32-Bit Address Space Resource\n"); 626 acpi_os_printf("32-Bit Address Space Resource\n");
691 627
692 switch (address32_data->resource_type) { 628 switch (address32_data->resource_type) {
693 case ACPI_MEMORY_RANGE: 629 case ACPI_MEMORY_RANGE:
694 630
695 acpi_os_printf (" Resource Type: Memory Range\n"); 631 acpi_os_printf(" Resource Type: Memory Range\n");
696 632
697 switch (address32_data->attribute.memory.cache_attribute) { 633 switch (address32_data->attribute.memory.cache_attribute) {
698 case ACPI_NON_CACHEABLE_MEMORY: 634 case ACPI_NON_CACHEABLE_MEMORY:
699 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 635 acpi_os_printf
636 (" Type Specific: Noncacheable memory\n");
700 break; 637 break;
701 638
702 case ACPI_CACHABLE_MEMORY: 639 case ACPI_CACHABLE_MEMORY:
703 acpi_os_printf (" Type Specific: Cacheable memory\n"); 640 acpi_os_printf(" Type Specific: Cacheable memory\n");
704 break; 641 break;
705 642
706 case ACPI_WRITE_COMBINING_MEMORY: 643 case ACPI_WRITE_COMBINING_MEMORY:
707 acpi_os_printf (" Type Specific: Write-combining memory\n"); 644 acpi_os_printf
645 (" Type Specific: Write-combining memory\n");
708 break; 646 break;
709 647
710 case ACPI_PREFETCHABLE_MEMORY: 648 case ACPI_PREFETCHABLE_MEMORY:
711 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 649 acpi_os_printf
650 (" Type Specific: Prefetchable memory\n");
712 break; 651 break;
713 652
714 default: 653 default:
715 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 654 acpi_os_printf
655 (" Type Specific: Invalid cache attribute\n");
716 break; 656 break;
717 } 657 }
718 658
719 acpi_os_printf (" Type Specific: Read%s\n", 659 acpi_os_printf(" Type Specific: Read%s\n",
720 ACPI_READ_WRITE_MEMORY == 660 ACPI_READ_WRITE_MEMORY ==
721 address32_data->attribute.memory.read_write_attribute ? 661 address32_data->attribute.memory.
722 "/Write" : " Only"); 662 read_write_attribute ? "/Write" : " Only");
723 break; 663 break;
724 664
725 case ACPI_IO_RANGE: 665 case ACPI_IO_RANGE:
726 666
727 acpi_os_printf (" Resource Type: Io Range\n"); 667 acpi_os_printf(" Resource Type: Io Range\n");
728 668
729 switch (address32_data->attribute.io.range_attribute) { 669 switch (address32_data->attribute.io.range_attribute) {
730 case ACPI_NON_ISA_ONLY_RANGES: 670 case ACPI_NON_ISA_ONLY_RANGES:
731 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 671 acpi_os_printf
672 (" Type Specific: Non-ISA Io Addresses\n");
732 break; 673 break;
733 674
734 case ACPI_ISA_ONLY_RANGES: 675 case ACPI_ISA_ONLY_RANGES:
735 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 676 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
736 break; 677 break;
737 678
738 case ACPI_ENTIRE_RANGE: 679 case ACPI_ENTIRE_RANGE:
739 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); 680 acpi_os_printf
681 (" Type Specific: ISA and non-ISA Io Addresses\n");
740 break; 682 break;
741 683
742 default: 684 default:
743 acpi_os_printf (" Type Specific: Invalid Range attribute"); 685 acpi_os_printf
686 (" Type Specific: Invalid Range attribute");
744 break; 687 break;
745 } 688 }
746 689
747 acpi_os_printf (" Type Specific: %s Translation\n", 690 acpi_os_printf(" Type Specific: %s Translation\n",
748 ACPI_SPARSE_TRANSLATION == 691 ACPI_SPARSE_TRANSLATION ==
749 address32_data->attribute.io.translation_attribute ? 692 address32_data->attribute.io.
750 "Sparse" : "Dense"); 693 translation_attribute ? "Sparse" : "Dense");
751 break; 694 break;
752 695
753 case ACPI_BUS_NUMBER_RANGE: 696 case ACPI_BUS_NUMBER_RANGE:
754 697
755 acpi_os_printf (" Resource Type: Bus Number Range\n"); 698 acpi_os_printf(" Resource Type: Bus Number Range\n");
756 break; 699 break;
757 700
758 default: 701 default:
759 702
760 acpi_os_printf (" Resource Type: 0x%2.2X\n", 703 acpi_os_printf(" Resource Type: 0x%2.2X\n",
761 address32_data->resource_type); 704 address32_data->resource_type);
762 break; 705 break;
763 } 706 }
764 707
765 acpi_os_printf (" Resource %s\n", 708 acpi_os_printf(" Resource %s\n",
766 ACPI_CONSUMER == address32_data->producer_consumer ? 709 ACPI_CONSUMER == address32_data->producer_consumer ?
767 "Consumer" : "Producer"); 710 "Consumer" : "Producer");
768 711
769 acpi_os_printf (" %s decode\n", 712 acpi_os_printf(" %s decode\n",
770 ACPI_SUB_DECODE == address32_data->decode ? 713 ACPI_SUB_DECODE == address32_data->decode ?
771 "Subtractive" : "Positive"); 714 "Subtractive" : "Positive");
772 715
773 acpi_os_printf (" Min address is %s fixed\n", 716 acpi_os_printf(" Min address is %s fixed\n",
774 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? 717 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
775 "" : "not "); 718 "" : "not ");
776 719
777 acpi_os_printf (" Max address is %s fixed\n", 720 acpi_os_printf(" Max address is %s fixed\n",
778 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? 721 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
779 "" : "not "); 722 "" : "not ");
780 723
781 acpi_os_printf (" Granularity: %08X\n", 724 acpi_os_printf(" Granularity: %08X\n", address32_data->granularity);
782 address32_data->granularity);
783 725
784 acpi_os_printf (" Address range min: %08X\n", 726 acpi_os_printf(" Address range min: %08X\n",
785 address32_data->min_address_range); 727 address32_data->min_address_range);
786 728
787 acpi_os_printf (" Address range max: %08X\n", 729 acpi_os_printf(" Address range max: %08X\n",
788 address32_data->max_address_range); 730 address32_data->max_address_range);
789 731
790 acpi_os_printf (" Address translation offset: %08X\n", 732 acpi_os_printf(" Address translation offset: %08X\n",
791 address32_data->address_translation_offset); 733 address32_data->address_translation_offset);
792 734
793 acpi_os_printf (" Address Length: %08X\n", 735 acpi_os_printf(" Address Length: %08X\n",
794 address32_data->address_length); 736 address32_data->address_length);
795 737
796 if(0xFF != address32_data->resource_source.index) { 738 if (0xFF != address32_data->resource_source.index) {
797 acpi_os_printf (" Resource Source Index: %X\n", 739 acpi_os_printf(" Resource Source Index: %X\n",
798 address32_data->resource_source.index); 740 address32_data->resource_source.index);
799 741
800 acpi_os_printf (" Resource Source: %s\n", 742 acpi_os_printf(" Resource Source: %s\n",
801 address32_data->resource_source.string_ptr); 743 address32_data->resource_source.string_ptr);
802 } 744 }
803 745
804 return; 746 return;
805} 747}
806 748
807
808/******************************************************************************* 749/*******************************************************************************
809 * 750 *
810 * FUNCTION: acpi_rs_dump_address64 751 * FUNCTION: acpi_rs_dump_address64
@@ -817,137 +758,142 @@ acpi_rs_dump_address32 (
817 * 758 *
818 ******************************************************************************/ 759 ******************************************************************************/
819 760
820static void 761static void acpi_rs_dump_address64(union acpi_resource_data *data)
821acpi_rs_dump_address64 (
822 union acpi_resource_data *data)
823{ 762{
824 struct acpi_resource_address64 *address64_data = (struct acpi_resource_address64 *) data; 763 struct acpi_resource_address64 *address64_data =
825 764 (struct acpi_resource_address64 *)data;
826
827 ACPI_FUNCTION_ENTRY ();
828 765
766 ACPI_FUNCTION_ENTRY();
829 767
830 acpi_os_printf ("64-Bit Address Space Resource\n"); 768 acpi_os_printf("64-Bit Address Space Resource\n");
831 769
832 switch (address64_data->resource_type) { 770 switch (address64_data->resource_type) {
833 case ACPI_MEMORY_RANGE: 771 case ACPI_MEMORY_RANGE:
834 772
835 acpi_os_printf (" Resource Type: Memory Range\n"); 773 acpi_os_printf(" Resource Type: Memory Range\n");
836 774
837 switch (address64_data->attribute.memory.cache_attribute) { 775 switch (address64_data->attribute.memory.cache_attribute) {
838 case ACPI_NON_CACHEABLE_MEMORY: 776 case ACPI_NON_CACHEABLE_MEMORY:
839 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 777 acpi_os_printf
778 (" Type Specific: Noncacheable memory\n");
840 break; 779 break;
841 780
842 case ACPI_CACHABLE_MEMORY: 781 case ACPI_CACHABLE_MEMORY:
843 acpi_os_printf (" Type Specific: Cacheable memory\n"); 782 acpi_os_printf(" Type Specific: Cacheable memory\n");
844 break; 783 break;
845 784
846 case ACPI_WRITE_COMBINING_MEMORY: 785 case ACPI_WRITE_COMBINING_MEMORY:
847 acpi_os_printf (" Type Specific: Write-combining memory\n"); 786 acpi_os_printf
787 (" Type Specific: Write-combining memory\n");
848 break; 788 break;
849 789
850 case ACPI_PREFETCHABLE_MEMORY: 790 case ACPI_PREFETCHABLE_MEMORY:
851 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 791 acpi_os_printf
792 (" Type Specific: Prefetchable memory\n");
852 break; 793 break;
853 794
854 default: 795 default:
855 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 796 acpi_os_printf
797 (" Type Specific: Invalid cache attribute\n");
856 break; 798 break;
857 } 799 }
858 800
859 acpi_os_printf (" Type Specific: Read%s\n", 801 acpi_os_printf(" Type Specific: Read%s\n",
860 ACPI_READ_WRITE_MEMORY == 802 ACPI_READ_WRITE_MEMORY ==
861 address64_data->attribute.memory.read_write_attribute ? 803 address64_data->attribute.memory.
862 "/Write" : " Only"); 804 read_write_attribute ? "/Write" : " Only");
863 break; 805 break;
864 806
865 case ACPI_IO_RANGE: 807 case ACPI_IO_RANGE:
866 808
867 acpi_os_printf (" Resource Type: Io Range\n"); 809 acpi_os_printf(" Resource Type: Io Range\n");
868 810
869 switch (address64_data->attribute.io.range_attribute) { 811 switch (address64_data->attribute.io.range_attribute) {
870 case ACPI_NON_ISA_ONLY_RANGES: 812 case ACPI_NON_ISA_ONLY_RANGES:
871 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 813 acpi_os_printf
814 (" Type Specific: Non-ISA Io Addresses\n");
872 break; 815 break;
873 816
874 case ACPI_ISA_ONLY_RANGES: 817 case ACPI_ISA_ONLY_RANGES:
875 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 818 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
876 break; 819 break;
877 820
878 case ACPI_ENTIRE_RANGE: 821 case ACPI_ENTIRE_RANGE:
879 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); 822 acpi_os_printf
823 (" Type Specific: ISA and non-ISA Io Addresses\n");
880 break; 824 break;
881 825
882 default: 826 default:
883 acpi_os_printf (" Type Specific: Invalid Range attribute"); 827 acpi_os_printf
828 (" Type Specific: Invalid Range attribute");
884 break; 829 break;
885 } 830 }
886 831
887 acpi_os_printf (" Type Specific: %s Translation\n", 832 acpi_os_printf(" Type Specific: %s Translation\n",
888 ACPI_SPARSE_TRANSLATION == 833 ACPI_SPARSE_TRANSLATION ==
889 address64_data->attribute.io.translation_attribute ? 834 address64_data->attribute.io.
890 "Sparse" : "Dense"); 835 translation_attribute ? "Sparse" : "Dense");
891 break; 836 break;
892 837
893 case ACPI_BUS_NUMBER_RANGE: 838 case ACPI_BUS_NUMBER_RANGE:
894 839
895 acpi_os_printf (" Resource Type: Bus Number Range\n"); 840 acpi_os_printf(" Resource Type: Bus Number Range\n");
896 break; 841 break;
897 842
898 default: 843 default:
899 844
900 acpi_os_printf (" Resource Type: 0x%2.2X\n", 845 acpi_os_printf(" Resource Type: 0x%2.2X\n",
901 address64_data->resource_type); 846 address64_data->resource_type);
902 break; 847 break;
903 } 848 }
904 849
905 acpi_os_printf (" Resource %s\n", 850 acpi_os_printf(" Resource %s\n",
906 ACPI_CONSUMER == address64_data->producer_consumer ? 851 ACPI_CONSUMER == address64_data->producer_consumer ?
907 "Consumer" : "Producer"); 852 "Consumer" : "Producer");
908 853
909 acpi_os_printf (" %s decode\n", 854 acpi_os_printf(" %s decode\n",
910 ACPI_SUB_DECODE == address64_data->decode ? 855 ACPI_SUB_DECODE == address64_data->decode ?
911 "Subtractive" : "Positive"); 856 "Subtractive" : "Positive");
912 857
913 acpi_os_printf (" Min address is %s fixed\n", 858 acpi_os_printf(" Min address is %s fixed\n",
914 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? 859 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
915 "" : "not "); 860 "" : "not ");
916 861
917 acpi_os_printf (" Max address is %s fixed\n", 862 acpi_os_printf(" Max address is %s fixed\n",
918 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? 863 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
919 "" : "not "); 864 "" : "not ");
920 865
921 acpi_os_printf (" Granularity: %8.8X%8.8X\n", 866 acpi_os_printf(" Granularity: %8.8X%8.8X\n",
922 ACPI_FORMAT_UINT64 (address64_data->granularity)); 867 ACPI_FORMAT_UINT64(address64_data->granularity));
923 868
924 acpi_os_printf (" Address range min: %8.8X%8.8X\n", 869 acpi_os_printf(" Address range min: %8.8X%8.8X\n",
925 ACPI_FORMAT_UINT64 (address64_data->min_address_range)); 870 ACPI_FORMAT_UINT64(address64_data->min_address_range));
926 871
927 acpi_os_printf (" Address range max: %8.8X%8.8X\n", 872 acpi_os_printf(" Address range max: %8.8X%8.8X\n",
928 ACPI_FORMAT_UINT64 (address64_data->max_address_range)); 873 ACPI_FORMAT_UINT64(address64_data->max_address_range));
929 874
930 acpi_os_printf (" Address translation offset: %8.8X%8.8X\n", 875 acpi_os_printf(" Address translation offset: %8.8X%8.8X\n",
931 ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); 876 ACPI_FORMAT_UINT64(address64_data->
877 address_translation_offset));
932 878
933 acpi_os_printf (" Address Length: %8.8X%8.8X\n", 879 acpi_os_printf(" Address Length: %8.8X%8.8X\n",
934 ACPI_FORMAT_UINT64 (address64_data->address_length)); 880 ACPI_FORMAT_UINT64(address64_data->address_length));
935 881
936 acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n", 882 acpi_os_printf(" Type Specific Attributes: %8.8X%8.8X\n",
937 ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); 883 ACPI_FORMAT_UINT64(address64_data->
884 type_specific_attributes));
938 885
939 if (0xFF != address64_data->resource_source.index) { 886 if (0xFF != address64_data->resource_source.index) {
940 acpi_os_printf (" Resource Source Index: %X\n", 887 acpi_os_printf(" Resource Source Index: %X\n",
941 address64_data->resource_source.index); 888 address64_data->resource_source.index);
942 889
943 acpi_os_printf (" Resource Source: %s\n", 890 acpi_os_printf(" Resource Source: %s\n",
944 address64_data->resource_source.string_ptr); 891 address64_data->resource_source.string_ptr);
945 } 892 }
946 893
947 return; 894 return;
948} 895}
949 896
950
951/******************************************************************************* 897/*******************************************************************************
952 * 898 *
953 * FUNCTION: acpi_rs_dump_extended_irq 899 * FUNCTION: acpi_rs_dump_extended_irq
@@ -960,55 +906,52 @@ acpi_rs_dump_address64 (
960 * 906 *
961 ******************************************************************************/ 907 ******************************************************************************/
962 908
963static void 909static void acpi_rs_dump_extended_irq(union acpi_resource_data *data)
964acpi_rs_dump_extended_irq (
965 union acpi_resource_data *data)
966{ 910{
967 struct acpi_resource_ext_irq *ext_irq_data = (struct acpi_resource_ext_irq *) data; 911 struct acpi_resource_ext_irq *ext_irq_data =
968 u8 index = 0; 912 (struct acpi_resource_ext_irq *)data;
969 913 u8 index = 0;
970
971 ACPI_FUNCTION_ENTRY ();
972 914
915 ACPI_FUNCTION_ENTRY();
973 916
974 acpi_os_printf ("Extended IRQ Resource\n"); 917 acpi_os_printf("Extended IRQ Resource\n");
975 918
976 acpi_os_printf (" Resource %s\n", 919 acpi_os_printf(" Resource %s\n",
977 ACPI_CONSUMER == ext_irq_data->producer_consumer ? 920 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
978 "Consumer" : "Producer"); 921 "Consumer" : "Producer");
979 922
980 acpi_os_printf (" %s\n", 923 acpi_os_printf(" %s\n",
981 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? 924 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
982 "Level" : "Edge"); 925 "Level" : "Edge");
983 926
984 acpi_os_printf (" Active %s\n", 927 acpi_os_printf(" Active %s\n",
985 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? 928 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
986 "low" : "high"); 929 "low" : "high");
987 930
988 acpi_os_printf (" %s\n", 931 acpi_os_printf(" %s\n",
989 ACPI_SHARED == ext_irq_data->shared_exclusive ? 932 ACPI_SHARED == ext_irq_data->shared_exclusive ?
990 "Shared" : "Exclusive"); 933 "Shared" : "Exclusive");
991 934
992 acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts); 935 acpi_os_printf(" Interrupts : %X ( ",
936 ext_irq_data->number_of_interrupts);
993 937
994 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { 938 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
995 acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); 939 acpi_os_printf("%X ", ext_irq_data->interrupts[index]);
996 } 940 }
997 941
998 acpi_os_printf (")\n"); 942 acpi_os_printf(")\n");
999 943
1000 if(0xFF != ext_irq_data->resource_source.index) { 944 if (0xFF != ext_irq_data->resource_source.index) {
1001 acpi_os_printf (" Resource Source Index: %X", 945 acpi_os_printf(" Resource Source Index: %X",
1002 ext_irq_data->resource_source.index); 946 ext_irq_data->resource_source.index);
1003 947
1004 acpi_os_printf (" Resource Source: %s", 948 acpi_os_printf(" Resource Source: %s",
1005 ext_irq_data->resource_source.string_ptr); 949 ext_irq_data->resource_source.string_ptr);
1006 } 950 }
1007 951
1008 return; 952 return;
1009} 953}
1010 954
1011
1012/******************************************************************************* 955/*******************************************************************************
1013 * 956 *
1014 * FUNCTION: acpi_rs_dump_resource_list 957 * FUNCTION: acpi_rs_dump_resource_list
@@ -1021,92 +964,91 @@ acpi_rs_dump_extended_irq (
1021 * 964 *
1022 ******************************************************************************/ 965 ******************************************************************************/
1023 966
1024void 967void acpi_rs_dump_resource_list(struct acpi_resource *resource)
1025acpi_rs_dump_resource_list (
1026 struct acpi_resource *resource)
1027{ 968{
1028 u8 count = 0; 969 u8 count = 0;
1029 u8 done = FALSE; 970 u8 done = FALSE;
1030
1031
1032 ACPI_FUNCTION_ENTRY ();
1033 971
972 ACPI_FUNCTION_ENTRY();
1034 973
1035 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 974 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
1036 while (!done) { 975 while (!done) {
1037 acpi_os_printf ("Resource structure %X.\n", count++); 976 acpi_os_printf("Resource structure %X.\n", count++);
1038 977
1039 switch (resource->id) { 978 switch (resource->id) {
1040 case ACPI_RSTYPE_IRQ: 979 case ACPI_RSTYPE_IRQ:
1041 acpi_rs_dump_irq (&resource->data); 980 acpi_rs_dump_irq(&resource->data);
1042 break; 981 break;
1043 982
1044 case ACPI_RSTYPE_DMA: 983 case ACPI_RSTYPE_DMA:
1045 acpi_rs_dump_dma (&resource->data); 984 acpi_rs_dump_dma(&resource->data);
1046 break; 985 break;
1047 986
1048 case ACPI_RSTYPE_START_DPF: 987 case ACPI_RSTYPE_START_DPF:
1049 acpi_rs_dump_start_depend_fns (&resource->data); 988 acpi_rs_dump_start_depend_fns(&resource->data);
1050 break; 989 break;
1051 990
1052 case ACPI_RSTYPE_END_DPF: 991 case ACPI_RSTYPE_END_DPF:
1053 acpi_os_printf ("end_dependent_functions Resource\n"); 992 acpi_os_printf
1054 /* acpi_rs_dump_end_dependent_functions (Resource->Data);*/ 993 ("end_dependent_functions Resource\n");
994 /* acpi_rs_dump_end_dependent_functions (Resource->Data); */
1055 break; 995 break;
1056 996
1057 case ACPI_RSTYPE_IO: 997 case ACPI_RSTYPE_IO:
1058 acpi_rs_dump_io (&resource->data); 998 acpi_rs_dump_io(&resource->data);
1059 break; 999 break;
1060 1000
1061 case ACPI_RSTYPE_FIXED_IO: 1001 case ACPI_RSTYPE_FIXED_IO:
1062 acpi_rs_dump_fixed_io (&resource->data); 1002 acpi_rs_dump_fixed_io(&resource->data);
1063 break; 1003 break;
1064 1004
1065 case ACPI_RSTYPE_VENDOR: 1005 case ACPI_RSTYPE_VENDOR:
1066 acpi_rs_dump_vendor_specific (&resource->data); 1006 acpi_rs_dump_vendor_specific(&resource->data);
1067 break; 1007 break;
1068 1008
1069 case ACPI_RSTYPE_END_TAG: 1009 case ACPI_RSTYPE_END_TAG:
1070 /*rs_dump_end_tag (Resource->Data);*/ 1010 /*rs_dump_end_tag (Resource->Data); */
1071 acpi_os_printf ("end_tag Resource\n"); 1011 acpi_os_printf("end_tag Resource\n");
1072 done = TRUE; 1012 done = TRUE;
1073 break; 1013 break;
1074 1014
1075 case ACPI_RSTYPE_MEM24: 1015 case ACPI_RSTYPE_MEM24:
1076 acpi_rs_dump_memory24 (&resource->data); 1016 acpi_rs_dump_memory24(&resource->data);
1077 break; 1017 break;
1078 1018
1079 case ACPI_RSTYPE_MEM32: 1019 case ACPI_RSTYPE_MEM32:
1080 acpi_rs_dump_memory32 (&resource->data); 1020 acpi_rs_dump_memory32(&resource->data);
1081 break; 1021 break;
1082 1022
1083 case ACPI_RSTYPE_FIXED_MEM32: 1023 case ACPI_RSTYPE_FIXED_MEM32:
1084 acpi_rs_dump_fixed_memory32 (&resource->data); 1024 acpi_rs_dump_fixed_memory32(&resource->data);
1085 break; 1025 break;
1086 1026
1087 case ACPI_RSTYPE_ADDRESS16: 1027 case ACPI_RSTYPE_ADDRESS16:
1088 acpi_rs_dump_address16 (&resource->data); 1028 acpi_rs_dump_address16(&resource->data);
1089 break; 1029 break;
1090 1030
1091 case ACPI_RSTYPE_ADDRESS32: 1031 case ACPI_RSTYPE_ADDRESS32:
1092 acpi_rs_dump_address32 (&resource->data); 1032 acpi_rs_dump_address32(&resource->data);
1093 break; 1033 break;
1094 1034
1095 case ACPI_RSTYPE_ADDRESS64: 1035 case ACPI_RSTYPE_ADDRESS64:
1096 acpi_rs_dump_address64 (&resource->data); 1036 acpi_rs_dump_address64(&resource->data);
1097 break; 1037 break;
1098 1038
1099 case ACPI_RSTYPE_EXT_IRQ: 1039 case ACPI_RSTYPE_EXT_IRQ:
1100 acpi_rs_dump_extended_irq (&resource->data); 1040 acpi_rs_dump_extended_irq(&resource->data);
1101 break; 1041 break;
1102 1042
1103 default: 1043 default:
1104 acpi_os_printf ("Invalid resource type\n"); 1044 acpi_os_printf("Invalid resource type\n");
1105 break; 1045 break;
1106 1046
1107 } 1047 }
1108 1048
1109 resource = ACPI_PTR_ADD (struct acpi_resource, resource, resource->length); 1049 resource =
1050 ACPI_PTR_ADD(struct acpi_resource, resource,
1051 resource->length);
1110 } 1052 }
1111 } 1053 }
1112 1054
@@ -1125,36 +1067,38 @@ acpi_rs_dump_resource_list (
1125 * 1067 *
1126 ******************************************************************************/ 1068 ******************************************************************************/
1127 1069
1128void 1070void acpi_rs_dump_irq_list(u8 * route_table)
1129acpi_rs_dump_irq_list (
1130 u8 *route_table)
1131{ 1071{
1132 u8 *buffer = route_table; 1072 u8 *buffer = route_table;
1133 u8 count = 0; 1073 u8 count = 0;
1134 u8 done = FALSE; 1074 u8 done = FALSE;
1135 struct acpi_pci_routing_table *prt_element; 1075 struct acpi_pci_routing_table *prt_element;
1136
1137
1138 ACPI_FUNCTION_ENTRY ();
1139 1076
1077 ACPI_FUNCTION_ENTRY();
1140 1078
1141 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 1079 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
1142 prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 1080 prt_element =
1081 ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
1143 1082
1144 while (!done) { 1083 while (!done) {
1145 acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++); 1084 acpi_os_printf("PCI IRQ Routing Table structure %X.\n",
1085 count++);
1146 1086
1147 acpi_os_printf (" Address: %8.8X%8.8X\n", 1087 acpi_os_printf(" Address: %8.8X%8.8X\n",
1148 ACPI_FORMAT_UINT64 (prt_element->address)); 1088 ACPI_FORMAT_UINT64(prt_element->
1089 address));
1149 1090
1150 acpi_os_printf (" Pin: %X\n", prt_element->pin); 1091 acpi_os_printf(" Pin: %X\n", prt_element->pin);
1151 1092
1152 acpi_os_printf (" Source: %s\n", prt_element->source); 1093 acpi_os_printf(" Source: %s\n", prt_element->source);
1153 1094
1154 acpi_os_printf (" source_index: %X\n", prt_element->source_index); 1095 acpi_os_printf(" source_index: %X\n",
1096 prt_element->source_index);
1155 1097
1156 buffer += prt_element->length; 1098 buffer += prt_element->length;
1157 prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 1099 prt_element =
1100 ACPI_CAST_PTR(struct acpi_pci_routing_table,
1101 buffer);
1158 if (0 == prt_element->length) { 1102 if (0 == prt_element->length) {
1159 done = TRUE; 1103 done = TRUE;
1160 } 1104 }
@@ -1165,4 +1109,3 @@ acpi_rs_dump_irq_list (
1165} 1109}
1166 1110
1167#endif 1111#endif
1168
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index 23a4d149fac8..d53bbe89e851 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsio") 48ACPI_MODULE_NAME("rsio")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,24 +67,18 @@
69 * number of bytes consumed from the byte stream. 67 * number of bytes consumed from the byte stream.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_rs_io_resource ( 71acpi_rs_io_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 72 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 73 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 74{
80 u8 *buffer = byte_stream_buffer; 75 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer; 76 struct acpi_resource *output_struct = (void *)*output_buffer;
82 u16 temp16 = 0; 77 u16 temp16 = 0;
83 u8 temp8 = 0; 78 u8 temp8 = 0;
84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 79 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
85 struct acpi_resource_io);
86
87
88 ACPI_FUNCTION_TRACE ("rs_io_resource");
89 80
81 ACPI_FUNCTION_TRACE("rs_io_resource");
90 82
91 /* The number of bytes consumed are Constant */ 83 /* The number of bytes consumed are Constant */
92 84
@@ -104,14 +96,14 @@ acpi_rs_io_resource (
104 /* Check min_base Address */ 96 /* Check min_base Address */
105 97
106 buffer += 1; 98 buffer += 1;
107 ACPI_MOVE_16_TO_16 (&temp16, buffer); 99 ACPI_MOVE_16_TO_16(&temp16, buffer);
108 100
109 output_struct->data.io.min_base_address = temp16; 101 output_struct->data.io.min_base_address = temp16;
110 102
111 /* Check max_base Address */ 103 /* Check max_base Address */
112 104
113 buffer += 2; 105 buffer += 2;
114 ACPI_MOVE_16_TO_16 (&temp16, buffer); 106 ACPI_MOVE_16_TO_16(&temp16, buffer);
115 107
116 output_struct->data.io.max_base_address = temp16; 108 output_struct->data.io.max_base_address = temp16;
117 109
@@ -136,10 +128,9 @@ acpi_rs_io_resource (
136 /* Return the final size of the structure */ 128 /* Return the final size of the structure */
137 129
138 *structure_size = struct_size; 130 *structure_size = struct_size;
139 return_ACPI_STATUS (AE_OK); 131 return_ACPI_STATUS(AE_OK);
140} 132}
141 133
142
143/******************************************************************************* 134/*******************************************************************************
144 * 135 *
145 * FUNCTION: acpi_rs_fixed_io_resource 136 * FUNCTION: acpi_rs_fixed_io_resource
@@ -162,22 +153,18 @@ acpi_rs_io_resource (
162 ******************************************************************************/ 153 ******************************************************************************/
163 154
164acpi_status 155acpi_status
165acpi_rs_fixed_io_resource ( 156acpi_rs_fixed_io_resource(u8 * byte_stream_buffer,
166 u8 *byte_stream_buffer, 157 acpi_size * bytes_consumed,
167 acpi_size *bytes_consumed, 158 u8 ** output_buffer, acpi_size * structure_size)
168 u8 **output_buffer,
169 acpi_size *structure_size)
170{ 159{
171 u8 *buffer = byte_stream_buffer; 160 u8 *buffer = byte_stream_buffer;
172 struct acpi_resource *output_struct = (void *) *output_buffer; 161 struct acpi_resource *output_struct = (void *)*output_buffer;
173 u16 temp16 = 0; 162 u16 temp16 = 0;
174 u8 temp8 = 0; 163 u8 temp8 = 0;
175 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 164 acpi_size struct_size =
176 struct acpi_resource_fixed_io); 165 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
177
178
179 ACPI_FUNCTION_TRACE ("rs_fixed_io_resource");
180 166
167 ACPI_FUNCTION_TRACE("rs_fixed_io_resource");
181 168
182 /* The number of bytes consumed are Constant */ 169 /* The number of bytes consumed are Constant */
183 170
@@ -188,7 +175,7 @@ acpi_rs_fixed_io_resource (
188 /* Check Range Base Address */ 175 /* Check Range Base Address */
189 176
190 buffer += 1; 177 buffer += 1;
191 ACPI_MOVE_16_TO_16 (&temp16, buffer); 178 ACPI_MOVE_16_TO_16(&temp16, buffer);
192 179
193 output_struct->data.fixed_io.base_address = temp16; 180 output_struct->data.fixed_io.base_address = temp16;
194 181
@@ -206,10 +193,9 @@ acpi_rs_fixed_io_resource (
206 /* Return the final size of the structure */ 193 /* Return the final size of the structure */
207 194
208 *structure_size = struct_size; 195 *structure_size = struct_size;
209 return_ACPI_STATUS (AE_OK); 196 return_ACPI_STATUS(AE_OK);
210} 197}
211 198
212
213/******************************************************************************* 199/*******************************************************************************
214 * 200 *
215 * FUNCTION: acpi_rs_io_stream 201 * FUNCTION: acpi_rs_io_stream
@@ -227,18 +213,14 @@ acpi_rs_fixed_io_resource (
227 ******************************************************************************/ 213 ******************************************************************************/
228 214
229acpi_status 215acpi_status
230acpi_rs_io_stream ( 216acpi_rs_io_stream(struct acpi_resource *linked_list,
231 struct acpi_resource *linked_list, 217 u8 ** output_buffer, acpi_size * bytes_consumed)
232 u8 **output_buffer,
233 acpi_size *bytes_consumed)
234{ 218{
235 u8 *buffer = *output_buffer; 219 u8 *buffer = *output_buffer;
236 u16 temp16 = 0; 220 u16 temp16 = 0;
237 u8 temp8 = 0; 221 u8 temp8 = 0;
238
239
240 ACPI_FUNCTION_TRACE ("rs_io_stream");
241 222
223 ACPI_FUNCTION_TRACE("rs_io_stream");
242 224
243 /* The descriptor field is static */ 225 /* The descriptor field is static */
244 226
@@ -256,14 +238,14 @@ acpi_rs_io_stream (
256 238
257 temp16 = (u16) linked_list->data.io.min_base_address; 239 temp16 = (u16) linked_list->data.io.min_base_address;
258 240
259 ACPI_MOVE_16_TO_16 (buffer, &temp16); 241 ACPI_MOVE_16_TO_16(buffer, &temp16);
260 buffer += 2; 242 buffer += 2;
261 243
262 /* Set the Range maximum base address */ 244 /* Set the Range maximum base address */
263 245
264 temp16 = (u16) linked_list->data.io.max_base_address; 246 temp16 = (u16) linked_list->data.io.max_base_address;
265 247
266 ACPI_MOVE_16_TO_16 (buffer, &temp16); 248 ACPI_MOVE_16_TO_16(buffer, &temp16);
267 buffer += 2; 249 buffer += 2;
268 250
269 /* Set the base alignment */ 251 /* Set the base alignment */
@@ -282,11 +264,10 @@ acpi_rs_io_stream (
282 264
283 /* Return the number of bytes consumed in this operation */ 265 /* Return the number of bytes consumed in this operation */
284 266
285 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 267 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
286 return_ACPI_STATUS (AE_OK); 268 return_ACPI_STATUS(AE_OK);
287} 269}
288 270
289
290/******************************************************************************* 271/*******************************************************************************
291 * 272 *
292 * FUNCTION: acpi_rs_fixed_io_stream 273 * FUNCTION: acpi_rs_fixed_io_stream
@@ -304,18 +285,14 @@ acpi_rs_io_stream (
304 ******************************************************************************/ 285 ******************************************************************************/
305 286
306acpi_status 287acpi_status
307acpi_rs_fixed_io_stream ( 288acpi_rs_fixed_io_stream(struct acpi_resource *linked_list,
308 struct acpi_resource *linked_list, 289 u8 ** output_buffer, acpi_size * bytes_consumed)
309 u8 **output_buffer,
310 acpi_size *bytes_consumed)
311{ 290{
312 u8 *buffer = *output_buffer; 291 u8 *buffer = *output_buffer;
313 u16 temp16 = 0; 292 u16 temp16 = 0;
314 u8 temp8 = 0; 293 u8 temp8 = 0;
315
316
317 ACPI_FUNCTION_TRACE ("rs_fixed_io_stream");
318 294
295 ACPI_FUNCTION_TRACE("rs_fixed_io_stream");
319 296
320 /* The descriptor field is static */ 297 /* The descriptor field is static */
321 298
@@ -327,7 +304,7 @@ acpi_rs_fixed_io_stream (
327 304
328 temp16 = (u16) linked_list->data.fixed_io.base_address; 305 temp16 = (u16) linked_list->data.fixed_io.base_address;
329 306
330 ACPI_MOVE_16_TO_16 (buffer, &temp16); 307 ACPI_MOVE_16_TO_16(buffer, &temp16);
331 buffer += 2; 308 buffer += 2;
332 309
333 /* Set the range length */ 310 /* Set the range length */
@@ -339,11 +316,10 @@ acpi_rs_fixed_io_stream (
339 316
340 /* Return the number of bytes consumed in this operation */ 317 /* Return the number of bytes consumed in this operation */
341 318
342 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 319 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
343 return_ACPI_STATUS (AE_OK); 320 return_ACPI_STATUS(AE_OK);
344} 321}
345 322
346
347/******************************************************************************* 323/*******************************************************************************
348 * 324 *
349 * FUNCTION: acpi_rs_dma_resource 325 * FUNCTION: acpi_rs_dma_resource
@@ -366,23 +342,18 @@ acpi_rs_fixed_io_stream (
366 ******************************************************************************/ 342 ******************************************************************************/
367 343
368acpi_status 344acpi_status
369acpi_rs_dma_resource ( 345acpi_rs_dma_resource(u8 * byte_stream_buffer,
370 u8 *byte_stream_buffer, 346 acpi_size * bytes_consumed,
371 acpi_size *bytes_consumed, 347 u8 ** output_buffer, acpi_size * structure_size)
372 u8 **output_buffer,
373 acpi_size *structure_size)
374{ 348{
375 u8 *buffer = byte_stream_buffer; 349 u8 *buffer = byte_stream_buffer;
376 struct acpi_resource *output_struct = (void *) *output_buffer; 350 struct acpi_resource *output_struct = (void *)*output_buffer;
377 u8 temp8 = 0; 351 u8 temp8 = 0;
378 u8 index; 352 u8 index;
379 u8 i; 353 u8 i;
380 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 354 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
381 struct acpi_resource_dma);
382
383
384 ACPI_FUNCTION_TRACE ("rs_dma_resource");
385 355
356 ACPI_FUNCTION_TRACE("rs_dma_resource");
386 357
387 /* The number of bytes consumed are Constant */ 358 /* The number of bytes consumed are Constant */
388 359
@@ -422,9 +393,9 @@ acpi_rs_dma_resource (
422 output_struct->data.dma.transfer = temp8 & 0x03; 393 output_struct->data.dma.transfer = temp8 & 0x03;
423 394
424 if (0x03 == output_struct->data.dma.transfer) { 395 if (0x03 == output_struct->data.dma.transfer) {
425 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
426 "Invalid DMA.Transfer preference (3)\n")); 397 "Invalid DMA.Transfer preference (3)\n"));
427 return_ACPI_STATUS (AE_BAD_DATA); 398 return_ACPI_STATUS(AE_BAD_DATA);
428 } 399 }
429 400
430 /* Get bus master preference (Bit[2]) */ 401 /* Get bus master preference (Bit[2]) */
@@ -442,10 +413,9 @@ acpi_rs_dma_resource (
442 /* Return the final size of the structure */ 413 /* Return the final size of the structure */
443 414
444 *structure_size = struct_size; 415 *structure_size = struct_size;
445 return_ACPI_STATUS (AE_OK); 416 return_ACPI_STATUS(AE_OK);
446} 417}
447 418
448
449/******************************************************************************* 419/*******************************************************************************
450 * 420 *
451 * FUNCTION: acpi_rs_dma_stream 421 * FUNCTION: acpi_rs_dma_stream
@@ -463,19 +433,15 @@ acpi_rs_dma_resource (
463 ******************************************************************************/ 433 ******************************************************************************/
464 434
465acpi_status 435acpi_status
466acpi_rs_dma_stream ( 436acpi_rs_dma_stream(struct acpi_resource *linked_list,
467 struct acpi_resource *linked_list, 437 u8 ** output_buffer, acpi_size * bytes_consumed)
468 u8 **output_buffer,
469 acpi_size *bytes_consumed)
470{ 438{
471 u8 *buffer = *output_buffer; 439 u8 *buffer = *output_buffer;
472 u16 temp16 = 0; 440 u16 temp16 = 0;
473 u8 temp8 = 0; 441 u8 temp8 = 0;
474 u8 index; 442 u8 index;
475
476
477 ACPI_FUNCTION_TRACE ("rs_dma_stream");
478 443
444 ACPI_FUNCTION_TRACE("rs_dma_stream");
479 445
480 /* The descriptor field is static */ 446 /* The descriptor field is static */
481 447
@@ -486,8 +452,7 @@ acpi_rs_dma_stream (
486 /* Loop through all of the Channels and set the mask bits */ 452 /* Loop through all of the Channels and set the mask bits */
487 453
488 for (index = 0; 454 for (index = 0;
489 index < linked_list->data.dma.number_of_channels; 455 index < linked_list->data.dma.number_of_channels; index++) {
490 index++) {
491 temp16 = (u16) linked_list->data.dma.channels[index]; 456 temp16 = (u16) linked_list->data.dma.channels[index];
492 temp8 |= 0x1 << temp16; 457 temp8 |= 0x1 << temp16;
493 } 458 }
@@ -506,7 +471,6 @@ acpi_rs_dma_stream (
506 471
507 /* Return the number of bytes consumed in this operation */ 472 /* Return the number of bytes consumed in this operation */
508 473
509 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 474 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
510 return_ACPI_STATUS (AE_OK); 475 return_ACPI_STATUS(AE_OK);
511} 476}
512
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 8a2b630be45b..56043fee96cb 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsirq") 48ACPI_MODULE_NAME("rsirq")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,26 +67,20 @@
69 * number of bytes consumed from the byte stream. 67 * number of bytes consumed from the byte stream.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_rs_irq_resource ( 71acpi_rs_irq_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 72 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 73 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 74{
80 u8 *buffer = byte_stream_buffer; 75 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer; 76 struct acpi_resource *output_struct = (void *)*output_buffer;
82 u16 temp16 = 0; 77 u16 temp16 = 0;
83 u8 temp8 = 0; 78 u8 temp8 = 0;
84 u8 index; 79 u8 index;
85 u8 i; 80 u8 i;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 81 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
87 struct acpi_resource_irq);
88
89
90 ACPI_FUNCTION_TRACE ("rs_irq_resource");
91 82
83 ACPI_FUNCTION_TRACE("rs_irq_resource");
92 84
93 /* 85 /*
94 * The number of bytes consumed are contained in the descriptor 86 * The number of bytes consumed are contained in the descriptor
@@ -101,7 +93,7 @@ acpi_rs_irq_resource (
101 /* Point to the 16-bits of Bytes 1 and 2 */ 93 /* Point to the 16-bits of Bytes 1 and 2 */
102 94
103 buffer += 1; 95 buffer += 1;
104 ACPI_MOVE_16_TO_16 (&temp16, buffer); 96 ACPI_MOVE_16_TO_16(&temp16, buffer);
105 97
106 output_struct->data.irq.number_of_interrupts = 0; 98 output_struct->data.irq.number_of_interrupts = 0;
107 99
@@ -132,14 +124,18 @@ acpi_rs_irq_resource (
132 /* Check for HE, LL interrupts */ 124 /* Check for HE, LL interrupts */
133 125
134 switch (temp8 & 0x09) { 126 switch (temp8 & 0x09) {
135 case 0x01: /* HE */ 127 case 0x01: /* HE */
136 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 128 output_struct->data.irq.edge_level =
137 output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; 129 ACPI_EDGE_SENSITIVE;
130 output_struct->data.irq.active_high_low =
131 ACPI_ACTIVE_HIGH;
138 break; 132 break;
139 133
140 case 0x08: /* LL */ 134 case 0x08: /* LL */
141 output_struct->data.irq.edge_level = ACPI_LEVEL_SENSITIVE; 135 output_struct->data.irq.edge_level =
142 output_struct->data.irq.active_high_low = ACPI_ACTIVE_LOW; 136 ACPI_LEVEL_SENSITIVE;
137 output_struct->data.irq.active_high_low =
138 ACPI_ACTIVE_LOW;
143 break; 139 break;
144 140
145 default: 141 default:
@@ -148,17 +144,16 @@ acpi_rs_irq_resource (
148 * are allowed (ACPI spec, section "IRQ Format") 144 * are allowed (ACPI spec, section "IRQ Format")
149 * so 0x00 and 0x09 are illegal. 145 * so 0x00 and 0x09 are illegal.
150 */ 146 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
152 "Invalid interrupt polarity/trigger in resource list, %X\n", 148 "Invalid interrupt polarity/trigger in resource list, %X\n",
153 temp8)); 149 temp8));
154 return_ACPI_STATUS (AE_BAD_DATA); 150 return_ACPI_STATUS(AE_BAD_DATA);
155 } 151 }
156 152
157 /* Check for sharable */ 153 /* Check for sharable */
158 154
159 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 155 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
160 } 156 } else {
161 else {
162 /* 157 /*
163 * Assume Edge Sensitive, Active High, Non-Sharable 158 * Assume Edge Sensitive, Active High, Non-Sharable
164 * per ACPI Specification 159 * per ACPI Specification
@@ -175,10 +170,9 @@ acpi_rs_irq_resource (
175 /* Return the final size of the structure */ 170 /* Return the final size of the structure */
176 171
177 *structure_size = struct_size; 172 *structure_size = struct_size;
178 return_ACPI_STATUS (AE_OK); 173 return_ACPI_STATUS(AE_OK);
179} 174}
180 175
181
182/******************************************************************************* 176/*******************************************************************************
183 * 177 *
184 * FUNCTION: acpi_rs_irq_stream 178 * FUNCTION: acpi_rs_irq_stream
@@ -196,32 +190,27 @@ acpi_rs_irq_resource (
196 ******************************************************************************/ 190 ******************************************************************************/
197 191
198acpi_status 192acpi_status
199acpi_rs_irq_stream ( 193acpi_rs_irq_stream(struct acpi_resource *linked_list,
200 struct acpi_resource *linked_list, 194 u8 ** output_buffer, acpi_size * bytes_consumed)
201 u8 **output_buffer,
202 acpi_size *bytes_consumed)
203{ 195{
204 u8 *buffer = *output_buffer; 196 u8 *buffer = *output_buffer;
205 u16 temp16 = 0; 197 u16 temp16 = 0;
206 u8 temp8 = 0; 198 u8 temp8 = 0;
207 u8 index; 199 u8 index;
208 u8 IRqinfo_byte_needed; 200 u8 IRqinfo_byte_needed;
209
210
211 ACPI_FUNCTION_TRACE ("rs_irq_stream");
212 201
202 ACPI_FUNCTION_TRACE("rs_irq_stream");
213 203
214 /* 204 /*
215 * The descriptor field is set based upon whether a third byte is 205 * The descriptor field is set based upon whether a third byte is
216 * needed to contain the IRQ Information. 206 * needed to contain the IRQ Information.
217 */ 207 */
218 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level && 208 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
219 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low && 209 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
220 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) { 210 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
221 *buffer = 0x22; 211 *buffer = 0x22;
222 IRqinfo_byte_needed = FALSE; 212 IRqinfo_byte_needed = FALSE;
223 } 213 } else {
224 else {
225 *buffer = 0x23; 214 *buffer = 0x23;
226 IRqinfo_byte_needed = TRUE; 215 IRqinfo_byte_needed = TRUE;
227 } 216 }
@@ -231,14 +220,13 @@ acpi_rs_irq_stream (
231 220
232 /* Loop through all of the interrupts and set the mask bits */ 221 /* Loop through all of the interrupts and set the mask bits */
233 222
234 for(index = 0; 223 for (index = 0;
235 index < linked_list->data.irq.number_of_interrupts; 224 index < linked_list->data.irq.number_of_interrupts; index++) {
236 index++) {
237 temp8 = (u8) linked_list->data.irq.interrupts[index]; 225 temp8 = (u8) linked_list->data.irq.interrupts[index];
238 temp16 |= 0x1 << temp8; 226 temp16 |= 0x1 << temp8;
239 } 227 }
240 228
241 ACPI_MOVE_16_TO_16 (buffer, &temp16); 229 ACPI_MOVE_16_TO_16(buffer, &temp16);
242 buffer += 2; 230 buffer += 2;
243 231
244 /* Set the IRQ Info byte if needed. */ 232 /* Set the IRQ Info byte if needed. */
@@ -246,13 +234,12 @@ acpi_rs_irq_stream (
246 if (IRqinfo_byte_needed) { 234 if (IRqinfo_byte_needed) {
247 temp8 = 0; 235 temp8 = 0;
248 temp8 = (u8) ((linked_list->data.irq.shared_exclusive & 236 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
249 0x01) << 4); 237 0x01) << 4);
250 238
251 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level && 239 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
252 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) { 240 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
253 temp8 |= 0x08; 241 temp8 |= 0x08;
254 } 242 } else {
255 else {
256 temp8 |= 0x01; 243 temp8 |= 0x01;
257 } 244 }
258 245
@@ -262,11 +249,10 @@ acpi_rs_irq_stream (
262 249
263 /* Return the number of bytes consumed in this operation */ 250 /* Return the number of bytes consumed in this operation */
264 251
265 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 252 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
266 return_ACPI_STATUS (AE_OK); 253 return_ACPI_STATUS(AE_OK);
267} 254}
268 255
269
270/******************************************************************************* 256/*******************************************************************************
271 * 257 *
272 * FUNCTION: acpi_rs_extended_irq_resource 258 * FUNCTION: acpi_rs_extended_irq_resource
@@ -289,34 +275,30 @@ acpi_rs_irq_stream (
289 ******************************************************************************/ 275 ******************************************************************************/
290 276
291acpi_status 277acpi_status
292acpi_rs_extended_irq_resource ( 278acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
293 u8 *byte_stream_buffer, 279 acpi_size * bytes_consumed,
294 acpi_size *bytes_consumed, 280 u8 ** output_buffer, acpi_size * structure_size)
295 u8 **output_buffer,
296 acpi_size *structure_size)
297{ 281{
298 u8 *buffer = byte_stream_buffer; 282 u8 *buffer = byte_stream_buffer;
299 struct acpi_resource *output_struct = (void *) *output_buffer; 283 struct acpi_resource *output_struct = (void *)*output_buffer;
300 u16 temp16 = 0; 284 u16 temp16 = 0;
301 u8 temp8 = 0; 285 u8 temp8 = 0;
302 u8 *temp_ptr; 286 u8 *temp_ptr;
303 u8 index; 287 u8 index;
304 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 288 acpi_size struct_size =
305 struct acpi_resource_ext_irq); 289 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
306
307
308 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
309 290
291 ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
310 292
311 /* Point past the Descriptor to get the number of bytes consumed */ 293 /* Get the Descriptor Length field */
312 294
313 buffer += 1; 295 buffer += 1;
314 ACPI_MOVE_16_TO_16 (&temp16, buffer); 296 ACPI_MOVE_16_TO_16(&temp16, buffer);
315 297
316 /* Validate minimum descriptor length */ 298 /* Validate minimum descriptor length */
317 299
318 if (temp16 < 6) { 300 if (temp16 < 6) {
319 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 301 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
320 } 302 }
321 303
322 *bytes_consumed = temp16 + 3; 304 *bytes_consumed = temp16 + 3;
@@ -338,7 +320,7 @@ acpi_rs_extended_irq_resource (
338 * - Edge/Level are defined opposite in the table vs the headers 320 * - Edge/Level are defined opposite in the table vs the headers
339 */ 321 */
340 output_struct->data.extended_irq.edge_level = 322 output_struct->data.extended_irq.edge_level =
341 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
342 324
343 /* Check Interrupt Polarity */ 325 /* Check Interrupt Polarity */
344 326
@@ -356,7 +338,7 @@ acpi_rs_extended_irq_resource (
356 /* Must have at least one IRQ */ 338 /* Must have at least one IRQ */
357 339
358 if (temp8 < 1) { 340 if (temp8 < 1) {
359 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 341 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
360 } 342 }
361 343
362 output_struct->data.extended_irq.number_of_interrupts = temp8; 344 output_struct->data.extended_irq.number_of_interrupts = temp8;
@@ -374,8 +356,8 @@ acpi_rs_extended_irq_resource (
374 /* Cycle through every IRQ in the table */ 356 /* Cycle through every IRQ in the table */
375 357
376 for (index = 0; index < temp8; index++) { 358 for (index = 0; index < temp8; index++) {
377 ACPI_MOVE_32_TO_32 ( 359 ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq.
378 &output_struct->data.extended_irq.interrupts[index], buffer); 360 interrupts[index], buffer);
379 361
380 /* Point to the next IRQ */ 362 /* Point to the next IRQ */
381 363
@@ -393,12 +375,13 @@ acpi_rs_extended_irq_resource (
393 * we add 1 to the length. 375 * we add 1 to the length.
394 */ 376 */
395 if (*bytes_consumed > 377 if (*bytes_consumed >
396 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + 378 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
397 (5 + 1)) { 379 4) + (5 + 1)) {
398 /* Dereference the Index */ 380 /* Dereference the Index */
399 381
400 temp8 = *buffer; 382 temp8 = *buffer;
401 output_struct->data.extended_irq.resource_source.index = (u32) temp8; 383 output_struct->data.extended_irq.resource_source.index =
384 (u32) temp8;
402 385
403 /* Point to the String */ 386 /* Point to the String */
404 387
@@ -407,15 +390,15 @@ acpi_rs_extended_irq_resource (
407 /* Point the String pointer to the end of this structure. */ 390 /* Point the String pointer to the end of this structure. */
408 391
409 output_struct->data.extended_irq.resource_source.string_ptr = 392 output_struct->data.extended_irq.resource_source.string_ptr =
410 (char *)((char *) output_struct + struct_size); 393 (char *)((char *)output_struct + struct_size);
411 394
412 temp_ptr = (u8 *) 395 temp_ptr = (u8 *)
413 output_struct->data.extended_irq.resource_source.string_ptr; 396 output_struct->data.extended_irq.resource_source.string_ptr;
414 397
415 /* Copy the string into the buffer */ 398 /* Copy the string into the buffer */
416 399
417 index = 0; 400 index = 0;
418 while (0x00 != *buffer) { 401 while (*buffer) {
419 *temp_ptr = *buffer; 402 *temp_ptr = *buffer;
420 403
421 temp_ptr += 1; 404 temp_ptr += 1;
@@ -425,8 +408,9 @@ acpi_rs_extended_irq_resource (
425 408
426 /* Add the terminating null */ 409 /* Add the terminating null */
427 410
428 *temp_ptr = 0x00; 411 *temp_ptr = 0;
429 output_struct->data.extended_irq.resource_source.string_length = index + 1; 412 output_struct->data.extended_irq.resource_source.string_length =
413 index + 1;
430 414
431 /* 415 /*
432 * In order for the struct_size to fall on a 32-bit boundary, 416 * In order for the struct_size to fall on a 32-bit boundary,
@@ -434,12 +418,13 @@ acpi_rs_extended_irq_resource (
434 * struct_size to the next 32-bit boundary. 418 * struct_size to the next 32-bit boundary.
435 */ 419 */
436 temp8 = (u8) (index + 1); 420 temp8 = (u8) (index + 1);
437 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 421 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
438 } 422 } else {
439 else { 423 output_struct->data.extended_irq.resource_source.index = 0;
440 output_struct->data.extended_irq.resource_source.index = 0x00; 424 output_struct->data.extended_irq.resource_source.string_length =
441 output_struct->data.extended_irq.resource_source.string_length = 0; 425 0;
442 output_struct->data.extended_irq.resource_source.string_ptr = NULL; 426 output_struct->data.extended_irq.resource_source.string_ptr =
427 NULL;
443 } 428 }
444 429
445 /* Set the Length parameter */ 430 /* Set the Length parameter */
@@ -449,10 +434,9 @@ acpi_rs_extended_irq_resource (
449 /* Return the final size of the structure */ 434 /* Return the final size of the structure */
450 435
451 *structure_size = struct_size; 436 *structure_size = struct_size;
452 return_ACPI_STATUS (AE_OK); 437 return_ACPI_STATUS(AE_OK);
453} 438}
454 439
455
456/******************************************************************************* 440/*******************************************************************************
457 * 441 *
458 * FUNCTION: acpi_rs_extended_irq_stream 442 * FUNCTION: acpi_rs_extended_irq_stream
@@ -470,35 +454,31 @@ acpi_rs_extended_irq_resource (
470 ******************************************************************************/ 454 ******************************************************************************/
471 455
472acpi_status 456acpi_status
473acpi_rs_extended_irq_stream ( 457acpi_rs_extended_irq_stream(struct acpi_resource *linked_list,
474 struct acpi_resource *linked_list, 458 u8 ** output_buffer, acpi_size * bytes_consumed)
475 u8 **output_buffer,
476 acpi_size *bytes_consumed)
477{ 459{
478 u8 *buffer = *output_buffer; 460 u8 *buffer = *output_buffer;
479 u16 *length_field; 461 u16 *length_field;
480 u8 temp8 = 0; 462 u8 temp8 = 0;
481 u8 index; 463 u8 index;
482 char *temp_pointer = NULL;
483
484
485 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
486 464
465 ACPI_FUNCTION_TRACE("rs_extended_irq_stream");
487 466
488 /* The descriptor field is static */ 467 /* Set the Descriptor Type field */
489 468
490 *buffer = 0x89; 469 *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT;
491 buffer += 1; 470 buffer += 1;
492 471
493 /* Set a pointer to the Length field - to be filled in later */ 472 /* Save a pointer to the Length field - to be filled in later */
494 473
495 length_field = ACPI_CAST_PTR (u16, buffer); 474 length_field = ACPI_CAST_PTR(u16, buffer);
496 buffer += 2; 475 buffer += 2;
497 476
498 /* Set the Interrupt vector flags */ 477 /* Set the Interrupt vector flags */
499 478
500 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); 479 temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01);
501 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); 480 temp8 |=
481 ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
502 482
503 /* 483 /*
504 * Set the Interrupt Mode 484 * Set the Interrupt Mode
@@ -527,43 +507,46 @@ acpi_rs_extended_irq_stream (
527 *buffer = temp8; 507 *buffer = temp8;
528 buffer += 1; 508 buffer += 1;
529 509
530 for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts; 510 for (index = 0;
531 index++) { 511 index < linked_list->data.extended_irq.number_of_interrupts;
532 ACPI_MOVE_32_TO_32 (buffer, 512 index++) {
533 &linked_list->data.extended_irq.interrupts[index]); 513 ACPI_MOVE_32_TO_32(buffer,
514 &linked_list->data.extended_irq.
515 interrupts[index]);
534 buffer += 4; 516 buffer += 4;
535 } 517 }
536 518
537 /* Resource Source Index and Resource Source are optional */ 519 /* Resource Source Index and Resource Source are optional */
538 520
539 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 521 if (0 != linked_list->data.extended_irq.resource_source.string_length) {
540 *buffer = (u8) linked_list->data.extended_irq.resource_source.index; 522 *buffer =
523 (u8) linked_list->data.extended_irq.resource_source.index;
541 buffer += 1; 524 buffer += 1;
542 525
543 temp_pointer = (char *) buffer;
544
545 /* Copy the string */ 526 /* Copy the string */
546 527
547 ACPI_STRCPY (temp_pointer, 528 ACPI_STRCPY((char *)buffer,
548 linked_list->data.extended_irq.resource_source.string_ptr); 529 linked_list->data.extended_irq.resource_source.
530 string_ptr);
549 531
550 /* 532 /*
551 * Buffer needs to be set to the length of the sting + one for the 533 * Buffer needs to be set to the length of the string + one for the
552 * terminating null 534 * terminating null
553 */ 535 */
554 buffer += (acpi_size) (ACPI_STRLEN ( 536 buffer +=
555 linked_list->data.extended_irq.resource_source.string_ptr) + 1); 537 (acpi_size) (ACPI_STRLEN
538 (linked_list->data.extended_irq.
539 resource_source.string_ptr) + 1);
556 } 540 }
557 541
558 /* Return the number of bytes consumed in this operation */ 542 /* Return the number of bytes consumed in this operation */
559 543
560 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 544 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
561 545
562 /* 546 /*
563 * Set the length field to the number of bytes consumed 547 * Set the length field to the number of bytes consumed
564 * minus the header size (3 bytes) 548 * minus the header size (3 bytes)
565 */ 549 */
566 *length_field = (u16) (*bytes_consumed - 3); 550 *length_field = (u16) (*bytes_consumed - 3);
567 return_ACPI_STATUS (AE_OK); 551 return_ACPI_STATUS(AE_OK);
568} 552}
569
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index db7bcb4e60e3..103eb31c284e 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rslist") 48ACPI_MODULE_NAME("rslist")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -61,14 +59,10 @@
61 * a resource descriptor. 59 * a resource descriptor.
62 * 60 *
63 ******************************************************************************/ 61 ******************************************************************************/
64 62u8 acpi_rs_get_resource_type(u8 resource_start_byte)
65u8
66acpi_rs_get_resource_type (
67 u8 resource_start_byte)
68{ 63{
69 64
70 ACPI_FUNCTION_ENTRY (); 65 ACPI_FUNCTION_ENTRY();
71
72 66
73 /* Determine if this is a small or large resource */ 67 /* Determine if this is a small or large resource */
74 68
@@ -79,14 +73,12 @@ acpi_rs_get_resource_type (
79 73
80 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK)); 74 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
81 75
82
83 case ACPI_RDESC_TYPE_LARGE: 76 case ACPI_RDESC_TYPE_LARGE:
84 77
85 /* Large Resource Type -- All bits are valid */ 78 /* Large Resource Type -- All bits are valid */
86 79
87 return (resource_start_byte); 80 return (resource_start_byte);
88 81
89
90 default: 82 default:
91 /* Invalid type */ 83 /* Invalid type */
92 break; 84 break;
@@ -95,7 +87,6 @@ acpi_rs_get_resource_type (
95 return (0xFF); 87 return (0xFF);
96} 88}
97 89
98
99/******************************************************************************* 90/*******************************************************************************
100 * 91 *
101 * FUNCTION: acpi_rs_byte_stream_to_list 92 * FUNCTION: acpi_rs_byte_stream_to_list
@@ -113,176 +104,189 @@ acpi_rs_get_resource_type (
113 ******************************************************************************/ 104 ******************************************************************************/
114 105
115acpi_status 106acpi_status
116acpi_rs_byte_stream_to_list ( 107acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
117 u8 *byte_stream_buffer, 108 u32 byte_stream_buffer_length, u8 * output_buffer)
118 u32 byte_stream_buffer_length,
119 u8 *output_buffer)
120{ 109{
121 acpi_status status; 110 acpi_status status;
122 acpi_size bytes_parsed = 0; 111 acpi_size bytes_parsed = 0;
123 u8 resource_type = 0; 112 u8 resource_type = 0;
124 acpi_size bytes_consumed = 0; 113 acpi_size bytes_consumed = 0;
125 u8 *buffer = output_buffer; 114 u8 *buffer = output_buffer;
126 acpi_size structure_size = 0; 115 acpi_size structure_size = 0;
127 u8 end_tag_processed = FALSE; 116 u8 end_tag_processed = FALSE;
128 struct acpi_resource *resource; 117 struct acpi_resource *resource;
129 118
130 ACPI_FUNCTION_TRACE ("rs_byte_stream_to_list"); 119 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list");
131 120
132 121 while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) {
133 while (bytes_parsed < byte_stream_buffer_length &&
134 !end_tag_processed) {
135 /* The next byte in the stream is the resource type */ 122 /* The next byte in the stream is the resource type */
136 123
137 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); 124 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
138 125
139 switch (resource_type) { 126 switch (resource_type) {
140 case ACPI_RDESC_TYPE_MEMORY_24: 127 case ACPI_RDESC_TYPE_MEMORY_24:
141 /* 128 /*
142 * 24-Bit Memory Resource 129 * 24-Bit Memory Resource
143 */ 130 */
144 status = acpi_rs_memory24_resource (byte_stream_buffer, 131 status = acpi_rs_memory24_resource(byte_stream_buffer,
145 &bytes_consumed, &buffer, &structure_size); 132 &bytes_consumed,
133 &buffer,
134 &structure_size);
146 break; 135 break;
147 136
148
149 case ACPI_RDESC_TYPE_LARGE_VENDOR: 137 case ACPI_RDESC_TYPE_LARGE_VENDOR:
150 /* 138 /*
151 * Vendor Defined Resource 139 * Vendor Defined Resource
152 */ 140 */
153 status = acpi_rs_vendor_resource (byte_stream_buffer, 141 status = acpi_rs_vendor_resource(byte_stream_buffer,
154 &bytes_consumed, &buffer, &structure_size); 142 &bytes_consumed,
143 &buffer,
144 &structure_size);
155 break; 145 break;
156 146
157
158 case ACPI_RDESC_TYPE_MEMORY_32: 147 case ACPI_RDESC_TYPE_MEMORY_32:
159 /* 148 /*
160 * 32-Bit Memory Range Resource 149 * 32-Bit Memory Range Resource
161 */ 150 */
162 status = acpi_rs_memory32_range_resource (byte_stream_buffer, 151 status =
163 &bytes_consumed, &buffer, &structure_size); 152 acpi_rs_memory32_range_resource(byte_stream_buffer,
153 &bytes_consumed,
154 &buffer,
155 &structure_size);
164 break; 156 break;
165 157
166
167 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 158 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
168 /* 159 /*
169 * 32-Bit Fixed Memory Resource 160 * 32-Bit Fixed Memory Resource
170 */ 161 */
171 status = acpi_rs_fixed_memory32_resource (byte_stream_buffer, 162 status =
172 &bytes_consumed, &buffer, &structure_size); 163 acpi_rs_fixed_memory32_resource(byte_stream_buffer,
164 &bytes_consumed,
165 &buffer,
166 &structure_size);
173 break; 167 break;
174 168
175
176 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 169 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
177 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: 170 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
178 /* 171 /*
179 * 64-Bit Address Resource 172 * 64-Bit Address Resource
180 */ 173 */
181 status = acpi_rs_address64_resource (byte_stream_buffer, 174 status = acpi_rs_address64_resource(byte_stream_buffer,
182 &bytes_consumed, &buffer, &structure_size); 175 &bytes_consumed,
176 &buffer,
177 &structure_size);
183 break; 178 break;
184 179
185
186 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 180 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
187 /* 181 /*
188 * 32-Bit Address Resource 182 * 32-Bit Address Resource
189 */ 183 */
190 status = acpi_rs_address32_resource (byte_stream_buffer, 184 status = acpi_rs_address32_resource(byte_stream_buffer,
191 &bytes_consumed, &buffer, &structure_size); 185 &bytes_consumed,
186 &buffer,
187 &structure_size);
192 break; 188 break;
193 189
194
195 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 190 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
196 /* 191 /*
197 * 16-Bit Address Resource 192 * 16-Bit Address Resource
198 */ 193 */
199 status = acpi_rs_address16_resource (byte_stream_buffer, 194 status = acpi_rs_address16_resource(byte_stream_buffer,
200 &bytes_consumed, &buffer, &structure_size); 195 &bytes_consumed,
196 &buffer,
197 &structure_size);
201 break; 198 break;
202 199
203
204 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 200 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
205 /* 201 /*
206 * Extended IRQ 202 * Extended IRQ
207 */ 203 */
208 status = acpi_rs_extended_irq_resource (byte_stream_buffer, 204 status =
209 &bytes_consumed, &buffer, &structure_size); 205 acpi_rs_extended_irq_resource(byte_stream_buffer,
206 &bytes_consumed,
207 &buffer,
208 &structure_size);
210 break; 209 break;
211 210
212
213 case ACPI_RDESC_TYPE_IRQ_FORMAT: 211 case ACPI_RDESC_TYPE_IRQ_FORMAT:
214 /* 212 /*
215 * IRQ Resource 213 * IRQ Resource
216 */ 214 */
217 status = acpi_rs_irq_resource (byte_stream_buffer, 215 status = acpi_rs_irq_resource(byte_stream_buffer,
218 &bytes_consumed, &buffer, &structure_size); 216 &bytes_consumed, &buffer,
217 &structure_size);
219 break; 218 break;
220 219
221
222 case ACPI_RDESC_TYPE_DMA_FORMAT: 220 case ACPI_RDESC_TYPE_DMA_FORMAT:
223 /* 221 /*
224 * DMA Resource 222 * DMA Resource
225 */ 223 */
226 status = acpi_rs_dma_resource (byte_stream_buffer, 224 status = acpi_rs_dma_resource(byte_stream_buffer,
227 &bytes_consumed, &buffer, &structure_size); 225 &bytes_consumed, &buffer,
226 &structure_size);
228 break; 227 break;
229 228
230
231 case ACPI_RDESC_TYPE_START_DEPENDENT: 229 case ACPI_RDESC_TYPE_START_DEPENDENT:
232 /* 230 /*
233 * Start Dependent Functions Resource 231 * Start Dependent Functions Resource
234 */ 232 */
235 status = acpi_rs_start_depend_fns_resource (byte_stream_buffer, 233 status =
236 &bytes_consumed, &buffer, &structure_size); 234 acpi_rs_start_depend_fns_resource
235 (byte_stream_buffer, &bytes_consumed, &buffer,
236 &structure_size);
237 break; 237 break;
238 238
239
240 case ACPI_RDESC_TYPE_END_DEPENDENT: 239 case ACPI_RDESC_TYPE_END_DEPENDENT:
241 /* 240 /*
242 * End Dependent Functions Resource 241 * End Dependent Functions Resource
243 */ 242 */
244 status = acpi_rs_end_depend_fns_resource (byte_stream_buffer, 243 status =
245 &bytes_consumed, &buffer, &structure_size); 244 acpi_rs_end_depend_fns_resource(byte_stream_buffer,
245 &bytes_consumed,
246 &buffer,
247 &structure_size);
246 break; 248 break;
247 249
248
249 case ACPI_RDESC_TYPE_IO_PORT: 250 case ACPI_RDESC_TYPE_IO_PORT:
250 /* 251 /*
251 * IO Port Resource 252 * IO Port Resource
252 */ 253 */
253 status = acpi_rs_io_resource (byte_stream_buffer, 254 status = acpi_rs_io_resource(byte_stream_buffer,
254 &bytes_consumed, &buffer, &structure_size); 255 &bytes_consumed, &buffer,
256 &structure_size);
255 break; 257 break;
256 258
257
258 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 259 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
259 /* 260 /*
260 * Fixed IO Port Resource 261 * Fixed IO Port Resource
261 */ 262 */
262 status = acpi_rs_fixed_io_resource (byte_stream_buffer, 263 status = acpi_rs_fixed_io_resource(byte_stream_buffer,
263 &bytes_consumed, &buffer, &structure_size); 264 &bytes_consumed,
265 &buffer,
266 &structure_size);
264 break; 267 break;
265 268
266
267 case ACPI_RDESC_TYPE_SMALL_VENDOR: 269 case ACPI_RDESC_TYPE_SMALL_VENDOR:
268 /* 270 /*
269 * Vendor Specific Resource 271 * Vendor Specific Resource
270 */ 272 */
271 status = acpi_rs_vendor_resource (byte_stream_buffer, 273 status = acpi_rs_vendor_resource(byte_stream_buffer,
272 &bytes_consumed, &buffer, &structure_size); 274 &bytes_consumed,
275 &buffer,
276 &structure_size);
273 break; 277 break;
274 278
275
276 case ACPI_RDESC_TYPE_END_TAG: 279 case ACPI_RDESC_TYPE_END_TAG:
277 /* 280 /*
278 * End Tag 281 * End Tag
279 */ 282 */
280 end_tag_processed = TRUE; 283 end_tag_processed = TRUE;
281 status = acpi_rs_end_tag_resource (byte_stream_buffer, 284 status = acpi_rs_end_tag_resource(byte_stream_buffer,
282 &bytes_consumed, &buffer, &structure_size); 285 &bytes_consumed,
286 &buffer,
287 &structure_size);
283 break; 288 break;
284 289
285
286 default: 290 default:
287 /* 291 /*
288 * Invalid/Unknown resource type 292 * Invalid/Unknown resource type
@@ -291,8 +295,8 @@ acpi_rs_byte_stream_to_list (
291 break; 295 break;
292 } 296 }
293 297
294 if (ACPI_FAILURE (status)) { 298 if (ACPI_FAILURE(status)) {
295 return_ACPI_STATUS (status); 299 return_ACPI_STATUS(status);
296 } 300 }
297 301
298 /* Update the return value and counter */ 302 /* Update the return value and counter */
@@ -305,21 +309,21 @@ acpi_rs_byte_stream_to_list (
305 309
306 /* Set the Buffer to the next structure */ 310 /* Set the Buffer to the next structure */
307 311
308 resource = ACPI_CAST_PTR (struct acpi_resource, buffer); 312 resource = ACPI_CAST_PTR(struct acpi_resource, buffer);
309 resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length); 313 resource->length =
310 buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size); 314 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
315 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
311 } 316 }
312 317
313 /* Check the reason for exiting the while loop */ 318 /* Check the reason for exiting the while loop */
314 319
315 if (!end_tag_processed) { 320 if (!end_tag_processed) {
316 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 321 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
317 } 322 }
318 323
319 return_ACPI_STATUS (AE_OK); 324 return_ACPI_STATUS(AE_OK);
320} 325}
321 326
322
323/******************************************************************************* 327/*******************************************************************************
324 * 328 *
325 * FUNCTION: acpi_rs_list_to_byte_stream 329 * FUNCTION: acpi_rs_list_to_byte_stream
@@ -342,19 +346,16 @@ acpi_rs_byte_stream_to_list (
342 ******************************************************************************/ 346 ******************************************************************************/
343 347
344acpi_status 348acpi_status
345acpi_rs_list_to_byte_stream ( 349acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list,
346 struct acpi_resource *linked_list, 350 acpi_size byte_stream_size_needed,
347 acpi_size byte_stream_size_needed, 351 u8 * output_buffer)
348 u8 *output_buffer)
349{ 352{
350 acpi_status status; 353 acpi_status status;
351 u8 *buffer = output_buffer; 354 u8 *buffer = output_buffer;
352 acpi_size bytes_consumed = 0; 355 acpi_size bytes_consumed = 0;
353 u8 done = FALSE; 356 u8 done = FALSE;
354
355
356 ACPI_FUNCTION_TRACE ("rs_list_to_byte_stream");
357 357
358 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream");
358 359
359 while (!done) { 360 while (!done) {
360 switch (linked_list->id) { 361 switch (linked_list->id) {
@@ -362,58 +363,72 @@ acpi_rs_list_to_byte_stream (
362 /* 363 /*
363 * IRQ Resource 364 * IRQ Resource
364 */ 365 */
365 status = acpi_rs_irq_stream (linked_list, &buffer, &bytes_consumed); 366 status =
367 acpi_rs_irq_stream(linked_list, &buffer,
368 &bytes_consumed);
366 break; 369 break;
367 370
368 case ACPI_RSTYPE_DMA: 371 case ACPI_RSTYPE_DMA:
369 /* 372 /*
370 * DMA Resource 373 * DMA Resource
371 */ 374 */
372 status = acpi_rs_dma_stream (linked_list, &buffer, &bytes_consumed); 375 status =
376 acpi_rs_dma_stream(linked_list, &buffer,
377 &bytes_consumed);
373 break; 378 break;
374 379
375 case ACPI_RSTYPE_START_DPF: 380 case ACPI_RSTYPE_START_DPF:
376 /* 381 /*
377 * Start Dependent Functions Resource 382 * Start Dependent Functions Resource
378 */ 383 */
379 status = acpi_rs_start_depend_fns_stream (linked_list, 384 status = acpi_rs_start_depend_fns_stream(linked_list,
380 &buffer, &bytes_consumed); 385 &buffer,
386 &bytes_consumed);
381 break; 387 break;
382 388
383 case ACPI_RSTYPE_END_DPF: 389 case ACPI_RSTYPE_END_DPF:
384 /* 390 /*
385 * End Dependent Functions Resource 391 * End Dependent Functions Resource
386 */ 392 */
387 status = acpi_rs_end_depend_fns_stream (linked_list, 393 status = acpi_rs_end_depend_fns_stream(linked_list,
388 &buffer, &bytes_consumed); 394 &buffer,
395 &bytes_consumed);
389 break; 396 break;
390 397
391 case ACPI_RSTYPE_IO: 398 case ACPI_RSTYPE_IO:
392 /* 399 /*
393 * IO Port Resource 400 * IO Port Resource
394 */ 401 */
395 status = acpi_rs_io_stream (linked_list, &buffer, &bytes_consumed); 402 status =
403 acpi_rs_io_stream(linked_list, &buffer,
404 &bytes_consumed);
396 break; 405 break;
397 406
398 case ACPI_RSTYPE_FIXED_IO: 407 case ACPI_RSTYPE_FIXED_IO:
399 /* 408 /*
400 * Fixed IO Port Resource 409 * Fixed IO Port Resource
401 */ 410 */
402 status = acpi_rs_fixed_io_stream (linked_list, &buffer, &bytes_consumed); 411 status =
412 acpi_rs_fixed_io_stream(linked_list, &buffer,
413 &bytes_consumed);
403 break; 414 break;
404 415
405 case ACPI_RSTYPE_VENDOR: 416 case ACPI_RSTYPE_VENDOR:
406 /* 417 /*
407 * Vendor Defined Resource 418 * Vendor Defined Resource
408 */ 419 */
409 status = acpi_rs_vendor_stream (linked_list, &buffer, &bytes_consumed); 420 status =
421 acpi_rs_vendor_stream(linked_list, &buffer,
422 &bytes_consumed);
410 break; 423 break;
411 424
412 case ACPI_RSTYPE_END_TAG: 425 case ACPI_RSTYPE_END_TAG:
413 /* 426 /*
414 * End Tag 427 * End Tag
415 */ 428 */
416 status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed); 429 status =
430 acpi_rs_end_tag_stream(linked_list, &buffer,
431 &bytes_consumed);
417 432
418 /* An End Tag indicates the end of the Resource Template */ 433 /* An End Tag indicates the end of the Resource Template */
419 434
@@ -424,55 +439,60 @@ acpi_rs_list_to_byte_stream (
424 /* 439 /*
425 * 24-Bit Memory Resource 440 * 24-Bit Memory Resource
426 */ 441 */
427 status = acpi_rs_memory24_stream (linked_list, &buffer, &bytes_consumed); 442 status =
443 acpi_rs_memory24_stream(linked_list, &buffer,
444 &bytes_consumed);
428 break; 445 break;
429 446
430 case ACPI_RSTYPE_MEM32: 447 case ACPI_RSTYPE_MEM32:
431 /* 448 /*
432 * 32-Bit Memory Range Resource 449 * 32-Bit Memory Range Resource
433 */ 450 */
434 status = acpi_rs_memory32_range_stream (linked_list, &buffer, 451 status =
435 &bytes_consumed); 452 acpi_rs_memory32_range_stream(linked_list, &buffer,
453 &bytes_consumed);
436 break; 454 break;
437 455
438 case ACPI_RSTYPE_FIXED_MEM32: 456 case ACPI_RSTYPE_FIXED_MEM32:
439 /* 457 /*
440 * 32-Bit Fixed Memory Resource 458 * 32-Bit Fixed Memory Resource
441 */ 459 */
442 status = acpi_rs_fixed_memory32_stream (linked_list, &buffer, 460 status =
443 &bytes_consumed); 461 acpi_rs_fixed_memory32_stream(linked_list, &buffer,
462 &bytes_consumed);
444 break; 463 break;
445 464
446 case ACPI_RSTYPE_ADDRESS16: 465 case ACPI_RSTYPE_ADDRESS16:
447 /* 466 /*
448 * 16-Bit Address Descriptor Resource 467 * 16-Bit Address Descriptor Resource
449 */ 468 */
450 status = acpi_rs_address16_stream (linked_list, &buffer, 469 status = acpi_rs_address16_stream(linked_list, &buffer,
451 &bytes_consumed); 470 &bytes_consumed);
452 break; 471 break;
453 472
454 case ACPI_RSTYPE_ADDRESS32: 473 case ACPI_RSTYPE_ADDRESS32:
455 /* 474 /*
456 * 32-Bit Address Descriptor Resource 475 * 32-Bit Address Descriptor Resource
457 */ 476 */
458 status = acpi_rs_address32_stream (linked_list, &buffer, 477 status = acpi_rs_address32_stream(linked_list, &buffer,
459 &bytes_consumed); 478 &bytes_consumed);
460 break; 479 break;
461 480
462 case ACPI_RSTYPE_ADDRESS64: 481 case ACPI_RSTYPE_ADDRESS64:
463 /* 482 /*
464 * 64-Bit Address Descriptor Resource 483 * 64-Bit Address Descriptor Resource
465 */ 484 */
466 status = acpi_rs_address64_stream (linked_list, &buffer, 485 status = acpi_rs_address64_stream(linked_list, &buffer,
467 &bytes_consumed); 486 &bytes_consumed);
468 break; 487 break;
469 488
470 case ACPI_RSTYPE_EXT_IRQ: 489 case ACPI_RSTYPE_EXT_IRQ:
471 /* 490 /*
472 * Extended IRQ Resource 491 * Extended IRQ Resource
473 */ 492 */
474 status = acpi_rs_extended_irq_stream (linked_list, &buffer, 493 status =
475 &bytes_consumed); 494 acpi_rs_extended_irq_stream(linked_list, &buffer,
495 &bytes_consumed);
476 break; 496 break;
477 497
478 default: 498 default:
@@ -480,15 +500,15 @@ acpi_rs_list_to_byte_stream (
480 * If we get here, everything is out of sync, 500 * If we get here, everything is out of sync,
481 * so exit with an error 501 * so exit with an error
482 */ 502 */
483 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 503 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
484 "Invalid descriptor type (%X) in resource list\n", 504 "Invalid descriptor type (%X) in resource list\n",
485 linked_list->id)); 505 linked_list->id));
486 status = AE_BAD_DATA; 506 status = AE_BAD_DATA;
487 break; 507 break;
488 } 508 }
489 509
490 if (ACPI_FAILURE (status)) { 510 if (ACPI_FAILURE(status)) {
491 return_ACPI_STATUS (status); 511 return_ACPI_STATUS(status);
492 } 512 }
493 513
494 /* Set the Buffer to point to the open byte */ 514 /* Set the Buffer to point to the open byte */
@@ -497,10 +517,9 @@ acpi_rs_list_to_byte_stream (
497 517
498 /* Point to the next object */ 518 /* Point to the next object */
499 519
500 linked_list = ACPI_PTR_ADD (struct acpi_resource, 520 linked_list = ACPI_PTR_ADD(struct acpi_resource,
501 linked_list, linked_list->length); 521 linked_list, linked_list->length);
502 } 522 }
503 523
504 return_ACPI_STATUS (AE_OK); 524 return_ACPI_STATUS(AE_OK);
505} 525}
506
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index 91d0207f01ac..daba1a1ed46d 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsmemory") 48ACPI_MODULE_NAME("rsmemory")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,30 +67,25 @@
69 * number of bytes consumed from the byte stream. 67 * number of bytes consumed from the byte stream.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_rs_memory24_resource ( 71acpi_rs_memory24_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 72 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 73 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 74{
80 u8 *buffer = byte_stream_buffer; 75 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer; 76 struct acpi_resource *output_struct = (void *)*output_buffer;
82 u16 temp16 = 0; 77 u16 temp16 = 0;
83 u8 temp8 = 0; 78 u8 temp8 = 0;
84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 79 acpi_size struct_size =
85 struct acpi_resource_mem24); 80 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
86
87
88 ACPI_FUNCTION_TRACE ("rs_memory24_resource");
89 81
82 ACPI_FUNCTION_TRACE("rs_memory24_resource");
90 83
91 /* Point past the Descriptor to get the number of bytes consumed */ 84 /* Point past the Descriptor to get the number of bytes consumed */
92 85
93 buffer += 1; 86 buffer += 1;
94 87
95 ACPI_MOVE_16_TO_16 (&temp16, buffer); 88 ACPI_MOVE_16_TO_16(&temp16, buffer);
96 buffer += 2; 89 buffer += 2;
97 *bytes_consumed = (acpi_size) temp16 + 3; 90 *bytes_consumed = (acpi_size) temp16 + 3;
98 output_struct->id = ACPI_RSTYPE_MEM24; 91 output_struct->id = ACPI_RSTYPE_MEM24;
@@ -105,25 +98,25 @@ acpi_rs_memory24_resource (
105 98
106 /* Get min_base_address (Bytes 4-5) */ 99 /* Get min_base_address (Bytes 4-5) */
107 100
108 ACPI_MOVE_16_TO_16 (&temp16, buffer); 101 ACPI_MOVE_16_TO_16(&temp16, buffer);
109 buffer += 2; 102 buffer += 2;
110 output_struct->data.memory24.min_base_address = temp16; 103 output_struct->data.memory24.min_base_address = temp16;
111 104
112 /* Get max_base_address (Bytes 6-7) */ 105 /* Get max_base_address (Bytes 6-7) */
113 106
114 ACPI_MOVE_16_TO_16 (&temp16, buffer); 107 ACPI_MOVE_16_TO_16(&temp16, buffer);
115 buffer += 2; 108 buffer += 2;
116 output_struct->data.memory24.max_base_address = temp16; 109 output_struct->data.memory24.max_base_address = temp16;
117 110
118 /* Get Alignment (Bytes 8-9) */ 111 /* Get Alignment (Bytes 8-9) */
119 112
120 ACPI_MOVE_16_TO_16 (&temp16, buffer); 113 ACPI_MOVE_16_TO_16(&temp16, buffer);
121 buffer += 2; 114 buffer += 2;
122 output_struct->data.memory24.alignment = temp16; 115 output_struct->data.memory24.alignment = temp16;
123 116
124 /* Get range_length (Bytes 10-11) */ 117 /* Get range_length (Bytes 10-11) */
125 118
126 ACPI_MOVE_16_TO_16 (&temp16, buffer); 119 ACPI_MOVE_16_TO_16(&temp16, buffer);
127 output_struct->data.memory24.range_length = temp16; 120 output_struct->data.memory24.range_length = temp16;
128 121
129 /* Set the Length parameter */ 122 /* Set the Length parameter */
@@ -133,10 +126,9 @@ acpi_rs_memory24_resource (
133 /* Return the final size of the structure */ 126 /* Return the final size of the structure */
134 127
135 *structure_size = struct_size; 128 *structure_size = struct_size;
136 return_ACPI_STATUS (AE_OK); 129 return_ACPI_STATUS(AE_OK);
137} 130}
138 131
139
140/******************************************************************************* 132/*******************************************************************************
141 * 133 *
142 * FUNCTION: acpi_rs_memory24_stream 134 * FUNCTION: acpi_rs_memory24_stream
@@ -154,18 +146,14 @@ acpi_rs_memory24_resource (
154 ******************************************************************************/ 146 ******************************************************************************/
155 147
156acpi_status 148acpi_status
157acpi_rs_memory24_stream ( 149acpi_rs_memory24_stream(struct acpi_resource *linked_list,
158 struct acpi_resource *linked_list, 150 u8 ** output_buffer, acpi_size * bytes_consumed)
159 u8 **output_buffer,
160 acpi_size *bytes_consumed)
161{ 151{
162 u8 *buffer = *output_buffer; 152 u8 *buffer = *output_buffer;
163 u16 temp16 = 0; 153 u16 temp16 = 0;
164 u8 temp8 = 0; 154 u8 temp8 = 0;
165
166
167 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
168 155
156 ACPI_FUNCTION_TRACE("rs_memory24_stream");
169 157
170 /* The descriptor field is static */ 158 /* The descriptor field is static */
171 159
@@ -175,7 +163,7 @@ acpi_rs_memory24_stream (
175 /* The length field is static */ 163 /* The length field is static */
176 164
177 temp16 = 0x09; 165 temp16 = 0x09;
178 ACPI_MOVE_16_TO_16 (buffer, &temp16); 166 ACPI_MOVE_16_TO_16(buffer, &temp16);
179 buffer += 2; 167 buffer += 2;
180 168
181 /* Set the Information Byte */ 169 /* Set the Information Byte */
@@ -186,31 +174,32 @@ acpi_rs_memory24_stream (
186 174
187 /* Set the Range minimum base address */ 175 /* Set the Range minimum base address */
188 176
189 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address); 177 ACPI_MOVE_32_TO_16(buffer,
178 &linked_list->data.memory24.min_base_address);
190 buffer += 2; 179 buffer += 2;
191 180
192 /* Set the Range maximum base address */ 181 /* Set the Range maximum base address */
193 182
194 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address); 183 ACPI_MOVE_32_TO_16(buffer,
184 &linked_list->data.memory24.max_base_address);
195 buffer += 2; 185 buffer += 2;
196 186
197 /* Set the base alignment */ 187 /* Set the base alignment */
198 188
199 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment); 189 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment);
200 buffer += 2; 190 buffer += 2;
201 191
202 /* Set the range length */ 192 /* Set the range length */
203 193
204 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length); 194 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length);
205 buffer += 2; 195 buffer += 2;
206 196
207 /* Return the number of bytes consumed in this operation */ 197 /* Return the number of bytes consumed in this operation */
208 198
209 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 199 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
210 return_ACPI_STATUS (AE_OK); 200 return_ACPI_STATUS(AE_OK);
211} 201}
212 202
213
214/******************************************************************************* 203/*******************************************************************************
215 * 204 *
216 * FUNCTION: acpi_rs_memory32_range_resource 205 * FUNCTION: acpi_rs_memory32_range_resource
@@ -233,28 +222,24 @@ acpi_rs_memory24_stream (
233 ******************************************************************************/ 222 ******************************************************************************/
234 223
235acpi_status 224acpi_status
236acpi_rs_memory32_range_resource ( 225acpi_rs_memory32_range_resource(u8 * byte_stream_buffer,
237 u8 *byte_stream_buffer, 226 acpi_size * bytes_consumed,
238 acpi_size *bytes_consumed, 227 u8 ** output_buffer, acpi_size * structure_size)
239 u8 **output_buffer,
240 acpi_size *structure_size)
241{ 228{
242 u8 *buffer = byte_stream_buffer; 229 u8 *buffer = byte_stream_buffer;
243 struct acpi_resource *output_struct = (void *) *output_buffer; 230 struct acpi_resource *output_struct = (void *)*output_buffer;
244 u16 temp16 = 0; 231 u16 temp16 = 0;
245 u8 temp8 = 0; 232 u8 temp8 = 0;
246 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 233 acpi_size struct_size =
247 struct acpi_resource_mem32); 234 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
248
249
250 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
251 235
236 ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
252 237
253 /* Point past the Descriptor to get the number of bytes consumed */ 238 /* Point past the Descriptor to get the number of bytes consumed */
254 239
255 buffer += 1; 240 buffer += 1;
256 241
257 ACPI_MOVE_16_TO_16 (&temp16, buffer); 242 ACPI_MOVE_16_TO_16(&temp16, buffer);
258 buffer += 2; 243 buffer += 2;
259 *bytes_consumed = (acpi_size) temp16 + 3; 244 *bytes_consumed = (acpi_size) temp16 + 3;
260 245
@@ -279,22 +264,24 @@ acpi_rs_memory32_range_resource (
279 264
280 /* Get min_base_address (Bytes 4-7) */ 265 /* Get min_base_address (Bytes 4-7) */
281 266
282 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer); 267 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
268 buffer);
283 buffer += 4; 269 buffer += 4;
284 270
285 /* Get max_base_address (Bytes 8-11) */ 271 /* Get max_base_address (Bytes 8-11) */
286 272
287 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer); 273 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
274 buffer);
288 buffer += 4; 275 buffer += 4;
289 276
290 /* Get Alignment (Bytes 12-15) */ 277 /* Get Alignment (Bytes 12-15) */
291 278
292 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer); 279 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
293 buffer += 4; 280 buffer += 4;
294 281
295 /* Get range_length (Bytes 16-19) */ 282 /* Get range_length (Bytes 16-19) */
296 283
297 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer); 284 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
298 285
299 /* Set the Length parameter */ 286 /* Set the Length parameter */
300 287
@@ -303,10 +290,9 @@ acpi_rs_memory32_range_resource (
303 /* Return the final size of the structure */ 290 /* Return the final size of the structure */
304 291
305 *structure_size = struct_size; 292 *structure_size = struct_size;
306 return_ACPI_STATUS (AE_OK); 293 return_ACPI_STATUS(AE_OK);
307} 294}
308 295
309
310/******************************************************************************* 296/*******************************************************************************
311 * 297 *
312 * FUNCTION: acpi_rs_fixed_memory32_resource 298 * FUNCTION: acpi_rs_fixed_memory32_resource
@@ -329,27 +315,23 @@ acpi_rs_memory32_range_resource (
329 ******************************************************************************/ 315 ******************************************************************************/
330 316
331acpi_status 317acpi_status
332acpi_rs_fixed_memory32_resource ( 318acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer,
333 u8 *byte_stream_buffer, 319 acpi_size * bytes_consumed,
334 acpi_size *bytes_consumed, 320 u8 ** output_buffer, acpi_size * structure_size)
335 u8 **output_buffer,
336 acpi_size *structure_size)
337{ 321{
338 u8 *buffer = byte_stream_buffer; 322 u8 *buffer = byte_stream_buffer;
339 struct acpi_resource *output_struct = (void *) *output_buffer; 323 struct acpi_resource *output_struct = (void *)*output_buffer;
340 u16 temp16 = 0; 324 u16 temp16 = 0;
341 u8 temp8 = 0; 325 u8 temp8 = 0;
342 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 326 acpi_size struct_size =
343 struct acpi_resource_fixed_mem32); 327 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
344
345
346 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
347 328
329 ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
348 330
349 /* Point past the Descriptor to get the number of bytes consumed */ 331 /* Point past the Descriptor to get the number of bytes consumed */
350 332
351 buffer += 1; 333 buffer += 1;
352 ACPI_MOVE_16_TO_16 (&temp16, buffer); 334 ACPI_MOVE_16_TO_16(&temp16, buffer);
353 335
354 buffer += 2; 336 buffer += 2;
355 *bytes_consumed = (acpi_size) temp16 + 3; 337 *bytes_consumed = (acpi_size) temp16 + 3;
@@ -364,13 +346,14 @@ acpi_rs_fixed_memory32_resource (
364 346
365 /* Get range_base_address (Bytes 4-7) */ 347 /* Get range_base_address (Bytes 4-7) */
366 348
367 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, 349 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
368 buffer); 350 range_base_address, buffer);
369 buffer += 4; 351 buffer += 4;
370 352
371 /* Get range_length (Bytes 8-11) */ 353 /* Get range_length (Bytes 8-11) */
372 354
373 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer); 355 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length,
356 buffer);
374 357
375 /* Set the Length parameter */ 358 /* Set the Length parameter */
376 359
@@ -379,10 +362,9 @@ acpi_rs_fixed_memory32_resource (
379 /* Return the final size of the structure */ 362 /* Return the final size of the structure */
380 363
381 *structure_size = struct_size; 364 *structure_size = struct_size;
382 return_ACPI_STATUS (AE_OK); 365 return_ACPI_STATUS(AE_OK);
383} 366}
384 367
385
386/******************************************************************************* 368/*******************************************************************************
387 * 369 *
388 * FUNCTION: acpi_rs_memory32_range_stream 370 * FUNCTION: acpi_rs_memory32_range_stream
@@ -400,18 +382,14 @@ acpi_rs_fixed_memory32_resource (
400 ******************************************************************************/ 382 ******************************************************************************/
401 383
402acpi_status 384acpi_status
403acpi_rs_memory32_range_stream ( 385acpi_rs_memory32_range_stream(struct acpi_resource *linked_list,
404 struct acpi_resource *linked_list, 386 u8 ** output_buffer, acpi_size * bytes_consumed)
405 u8 **output_buffer,
406 acpi_size *bytes_consumed)
407{ 387{
408 u8 *buffer = *output_buffer; 388 u8 *buffer = *output_buffer;
409 u16 temp16 = 0; 389 u16 temp16 = 0;
410 u8 temp8 = 0; 390 u8 temp8 = 0;
411
412
413 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
414 391
392 ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
415 393
416 /* The descriptor field is static */ 394 /* The descriptor field is static */
417 395
@@ -422,7 +400,7 @@ acpi_rs_memory32_range_stream (
422 400
423 temp16 = 0x11; 401 temp16 = 0x11;
424 402
425 ACPI_MOVE_16_TO_16 (buffer, &temp16); 403 ACPI_MOVE_16_TO_16(buffer, &temp16);
426 buffer += 2; 404 buffer += 2;
427 405
428 /* Set the Information Byte */ 406 /* Set the Information Byte */
@@ -433,31 +411,32 @@ acpi_rs_memory32_range_stream (
433 411
434 /* Set the Range minimum base address */ 412 /* Set the Range minimum base address */
435 413
436 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); 414 ACPI_MOVE_32_TO_32(buffer,
415 &linked_list->data.memory32.min_base_address);
437 buffer += 4; 416 buffer += 4;
438 417
439 /* Set the Range maximum base address */ 418 /* Set the Range maximum base address */
440 419
441 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); 420 ACPI_MOVE_32_TO_32(buffer,
421 &linked_list->data.memory32.max_base_address);
442 buffer += 4; 422 buffer += 4;
443 423
444 /* Set the base alignment */ 424 /* Set the base alignment */
445 425
446 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment); 426 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment);
447 buffer += 4; 427 buffer += 4;
448 428
449 /* Set the range length */ 429 /* Set the range length */
450 430
451 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length); 431 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length);
452 buffer += 4; 432 buffer += 4;
453 433
454 /* Return the number of bytes consumed in this operation */ 434 /* Return the number of bytes consumed in this operation */
455 435
456 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 436 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
457 return_ACPI_STATUS (AE_OK); 437 return_ACPI_STATUS(AE_OK);
458} 438}
459 439
460
461/******************************************************************************* 440/*******************************************************************************
462 * 441 *
463 * FUNCTION: acpi_rs_fixed_memory32_stream 442 * FUNCTION: acpi_rs_fixed_memory32_stream
@@ -475,18 +454,14 @@ acpi_rs_memory32_range_stream (
475 ******************************************************************************/ 454 ******************************************************************************/
476 455
477acpi_status 456acpi_status
478acpi_rs_fixed_memory32_stream ( 457acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list,
479 struct acpi_resource *linked_list, 458 u8 ** output_buffer, acpi_size * bytes_consumed)
480 u8 **output_buffer,
481 acpi_size *bytes_consumed)
482{ 459{
483 u8 *buffer = *output_buffer; 460 u8 *buffer = *output_buffer;
484 u16 temp16 = 0; 461 u16 temp16 = 0;
485 u8 temp8 = 0; 462 u8 temp8 = 0;
486
487
488 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
489 463
464 ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
490 465
491 /* The descriptor field is static */ 466 /* The descriptor field is static */
492 467
@@ -497,30 +472,31 @@ acpi_rs_fixed_memory32_stream (
497 472
498 temp16 = 0x09; 473 temp16 = 0x09;
499 474
500 ACPI_MOVE_16_TO_16 (buffer, &temp16); 475 ACPI_MOVE_16_TO_16(buffer, &temp16);
501 buffer += 2; 476 buffer += 2;
502 477
503 /* Set the Information Byte */ 478 /* Set the Information Byte */
504 479
505 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); 480 temp8 =
481 (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
506 *buffer = temp8; 482 *buffer = temp8;
507 buffer += 1; 483 buffer += 1;
508 484
509 /* Set the Range base address */ 485 /* Set the Range base address */
510 486
511 ACPI_MOVE_32_TO_32 (buffer, 487 ACPI_MOVE_32_TO_32(buffer,
512 &linked_list->data.fixed_memory32.range_base_address); 488 &linked_list->data.fixed_memory32.
489 range_base_address);
513 buffer += 4; 490 buffer += 4;
514 491
515 /* Set the range length */ 492 /* Set the range length */
516 493
517 ACPI_MOVE_32_TO_32 (buffer, 494 ACPI_MOVE_32_TO_32(buffer,
518 &linked_list->data.fixed_memory32.range_length); 495 &linked_list->data.fixed_memory32.range_length);
519 buffer += 4; 496 buffer += 4;
520 497
521 /* Return the number of bytes consumed in this operation */ 498 /* Return the number of bytes consumed in this operation */
522 499
523 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 500 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
524 return_ACPI_STATUS (AE_OK); 501 return_ACPI_STATUS(AE_OK);
525} 502}
526
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index a1f1741f0d83..7a8a34e757f5 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsmisc") 48ACPI_MODULE_NAME("rsmisc")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,20 +67,15 @@
69 * number of bytes consumed from the byte stream. 67 * number of bytes consumed from the byte stream.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_rs_end_tag_resource ( 71acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 72 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 73 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 74{
80 struct acpi_resource *output_struct = (void *) *output_buffer; 75 struct acpi_resource *output_struct = (void *)*output_buffer;
81 acpi_size struct_size = ACPI_RESOURCE_LENGTH; 76 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
82
83
84 ACPI_FUNCTION_TRACE ("rs_end_tag_resource");
85 77
78 ACPI_FUNCTION_TRACE("rs_end_tag_resource");
86 79
87 /* The number of bytes consumed is static */ 80 /* The number of bytes consumed is static */
88 81
@@ -99,10 +92,9 @@ acpi_rs_end_tag_resource (
99 /* Return the final size of the structure */ 92 /* Return the final size of the structure */
100 93
101 *structure_size = struct_size; 94 *structure_size = struct_size;
102 return_ACPI_STATUS (AE_OK); 95 return_ACPI_STATUS(AE_OK);
103} 96}
104 97
105
106/******************************************************************************* 98/*******************************************************************************
107 * 99 *
108 * FUNCTION: acpi_rs_end_tag_stream 100 * FUNCTION: acpi_rs_end_tag_stream
@@ -120,17 +112,13 @@ acpi_rs_end_tag_resource (
120 ******************************************************************************/ 112 ******************************************************************************/
121 113
122acpi_status 114acpi_status
123acpi_rs_end_tag_stream ( 115acpi_rs_end_tag_stream(struct acpi_resource *linked_list,
124 struct acpi_resource *linked_list, 116 u8 ** output_buffer, acpi_size * bytes_consumed)
125 u8 **output_buffer,
126 acpi_size *bytes_consumed)
127{ 117{
128 u8 *buffer = *output_buffer; 118 u8 *buffer = *output_buffer;
129 u8 temp8 = 0; 119 u8 temp8 = 0;
130
131
132 ACPI_FUNCTION_TRACE ("rs_end_tag_stream");
133 120
121 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
134 122
135 /* The descriptor field is static */ 123 /* The descriptor field is static */
136 124
@@ -148,11 +136,10 @@ acpi_rs_end_tag_stream (
148 136
149 /* Return the number of bytes consumed in this operation */ 137 /* Return the number of bytes consumed in this operation */
150 138
151 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 139 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
152 return_ACPI_STATUS (AE_OK); 140 return_ACPI_STATUS(AE_OK);
153} 141}
154 142
155
156/******************************************************************************* 143/*******************************************************************************
157 * 144 *
158 * FUNCTION: acpi_rs_vendor_resource 145 * FUNCTION: acpi_rs_vendor_resource
@@ -175,23 +162,19 @@ acpi_rs_end_tag_stream (
175 ******************************************************************************/ 162 ******************************************************************************/
176 163
177acpi_status 164acpi_status
178acpi_rs_vendor_resource ( 165acpi_rs_vendor_resource(u8 * byte_stream_buffer,
179 u8 *byte_stream_buffer, 166 acpi_size * bytes_consumed,
180 acpi_size *bytes_consumed, 167 u8 ** output_buffer, acpi_size * structure_size)
181 u8 **output_buffer,
182 acpi_size *structure_size)
183{ 168{
184 u8 *buffer = byte_stream_buffer; 169 u8 *buffer = byte_stream_buffer;
185 struct acpi_resource *output_struct = (void *) *output_buffer; 170 struct acpi_resource *output_struct = (void *)*output_buffer;
186 u16 temp16 = 0; 171 u16 temp16 = 0;
187 u8 temp8 = 0; 172 u8 temp8 = 0;
188 u8 index; 173 u8 index;
189 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 174 acpi_size struct_size =
190 struct acpi_resource_vendor); 175 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
191
192
193 ACPI_FUNCTION_TRACE ("rs_vendor_resource");
194 176
177 ACPI_FUNCTION_TRACE("rs_vendor_resource");
195 178
196 /* Dereference the Descriptor to find if this is a large or small item. */ 179 /* Dereference the Descriptor to find if this is a large or small item. */
197 180
@@ -204,7 +187,7 @@ acpi_rs_vendor_resource (
204 187
205 /* Dereference */ 188 /* Dereference */
206 189
207 ACPI_MOVE_16_TO_16 (&temp16, buffer); 190 ACPI_MOVE_16_TO_16(&temp16, buffer);
208 191
209 /* Calculate bytes consumed */ 192 /* Calculate bytes consumed */
210 193
@@ -213,11 +196,10 @@ acpi_rs_vendor_resource (
213 /* Point to the first vendor byte */ 196 /* Point to the first vendor byte */
214 197
215 buffer += 2; 198 buffer += 2;
216 } 199 } else {
217 else {
218 /* Small Item, dereference the size */ 200 /* Small Item, dereference the size */
219 201
220 temp16 = (u8)(*buffer & 0x07); 202 temp16 = (u8) (*buffer & 0x07);
221 203
222 /* Calculate bytes consumed */ 204 /* Calculate bytes consumed */
223 205
@@ -241,7 +223,7 @@ acpi_rs_vendor_resource (
241 * calculate the length of the vendor string and expand the 223 * calculate the length of the vendor string and expand the
242 * struct_size to the next 32-bit boundary. 224 * struct_size to the next 32-bit boundary.
243 */ 225 */
244 struct_size += ACPI_ROUND_UP_to_32_bITS (temp16); 226 struct_size += ACPI_ROUND_UP_to_32_bITS(temp16);
245 227
246 /* Set the Length parameter */ 228 /* Set the Length parameter */
247 229
@@ -250,10 +232,9 @@ acpi_rs_vendor_resource (
250 /* Return the final size of the structure */ 232 /* Return the final size of the structure */
251 233
252 *structure_size = struct_size; 234 *structure_size = struct_size;
253 return_ACPI_STATUS (AE_OK); 235 return_ACPI_STATUS(AE_OK);
254} 236}
255 237
256
257/******************************************************************************* 238/*******************************************************************************
258 * 239 *
259 * FUNCTION: acpi_rs_vendor_stream 240 * FUNCTION: acpi_rs_vendor_stream
@@ -271,23 +252,19 @@ acpi_rs_vendor_resource (
271 ******************************************************************************/ 252 ******************************************************************************/
272 253
273acpi_status 254acpi_status
274acpi_rs_vendor_stream ( 255acpi_rs_vendor_stream(struct acpi_resource *linked_list,
275 struct acpi_resource *linked_list, 256 u8 ** output_buffer, acpi_size * bytes_consumed)
276 u8 **output_buffer,
277 acpi_size *bytes_consumed)
278{ 257{
279 u8 *buffer = *output_buffer; 258 u8 *buffer = *output_buffer;
280 u16 temp16 = 0; 259 u16 temp16 = 0;
281 u8 temp8 = 0; 260 u8 temp8 = 0;
282 u8 index; 261 u8 index;
283
284
285 ACPI_FUNCTION_TRACE ("rs_vendor_stream");
286 262
263 ACPI_FUNCTION_TRACE("rs_vendor_stream");
287 264
288 /* Dereference the length to find if this is a large or small item. */ 265 /* Dereference the length to find if this is a large or small item. */
289 266
290 if(linked_list->data.vendor_specific.length > 7) { 267 if (linked_list->data.vendor_specific.length > 7) {
291 /* Large Item, Set the descriptor field and length bytes */ 268 /* Large Item, Set the descriptor field and length bytes */
292 269
293 *buffer = 0x84; 270 *buffer = 0x84;
@@ -295,10 +272,9 @@ acpi_rs_vendor_stream (
295 272
296 temp16 = (u16) linked_list->data.vendor_specific.length; 273 temp16 = (u16) linked_list->data.vendor_specific.length;
297 274
298 ACPI_MOVE_16_TO_16 (buffer, &temp16); 275 ACPI_MOVE_16_TO_16(buffer, &temp16);
299 buffer += 2; 276 buffer += 2;
300 } 277 } else {
301 else {
302 /* Small Item, Set the descriptor field */ 278 /* Small Item, Set the descriptor field */
303 279
304 temp8 = 0x70; 280 temp8 = 0x70;
@@ -310,7 +286,8 @@ acpi_rs_vendor_stream (
310 286
311 /* Loop through all of the Vendor Specific fields */ 287 /* Loop through all of the Vendor Specific fields */
312 288
313 for (index = 0; index < linked_list->data.vendor_specific.length; index++) { 289 for (index = 0; index < linked_list->data.vendor_specific.length;
290 index++) {
314 temp8 = linked_list->data.vendor_specific.reserved[index]; 291 temp8 = linked_list->data.vendor_specific.reserved[index];
315 292
316 *buffer = temp8; 293 *buffer = temp8;
@@ -319,11 +296,10 @@ acpi_rs_vendor_stream (
319 296
320 /* Return the number of bytes consumed in this operation */ 297 /* Return the number of bytes consumed in this operation */
321 298
322 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 299 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
323 return_ACPI_STATUS (AE_OK); 300 return_ACPI_STATUS(AE_OK);
324} 301}
325 302
326
327/******************************************************************************* 303/*******************************************************************************
328 * 304 *
329 * FUNCTION: acpi_rs_start_depend_fns_resource 305 * FUNCTION: acpi_rs_start_depend_fns_resource
@@ -346,21 +322,18 @@ acpi_rs_vendor_stream (
346 ******************************************************************************/ 322 ******************************************************************************/
347 323
348acpi_status 324acpi_status
349acpi_rs_start_depend_fns_resource ( 325acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer,
350 u8 *byte_stream_buffer, 326 acpi_size * bytes_consumed,
351 acpi_size *bytes_consumed, 327 u8 ** output_buffer,
352 u8 **output_buffer, 328 acpi_size * structure_size)
353 acpi_size *structure_size)
354{ 329{
355 u8 *buffer = byte_stream_buffer; 330 u8 *buffer = byte_stream_buffer;
356 struct acpi_resource *output_struct = (void *) *output_buffer; 331 struct acpi_resource *output_struct = (void *)*output_buffer;
357 u8 temp8 = 0; 332 u8 temp8 = 0;
358 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 333 acpi_size struct_size =
359 struct acpi_resource_start_dpf); 334 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf);
360
361
362 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource");
363 335
336 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
364 337
365 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ 338 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
366 339
@@ -378,26 +351,27 @@ acpi_rs_start_depend_fns_resource (
378 351
379 /* Check Compatibility priority */ 352 /* Check Compatibility priority */
380 353
381 output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03; 354 output_struct->data.start_dpf.compatibility_priority =
355 temp8 & 0x03;
382 356
383 if (3 == output_struct->data.start_dpf.compatibility_priority) { 357 if (3 == output_struct->data.start_dpf.compatibility_priority) {
384 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 358 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
385 } 359 }
386 360
387 /* Check Performance/Robustness preference */ 361 /* Check Performance/Robustness preference */
388 362
389 output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03; 363 output_struct->data.start_dpf.performance_robustness =
364 (temp8 >> 2) & 0x03;
390 365
391 if (3 == output_struct->data.start_dpf.performance_robustness) { 366 if (3 == output_struct->data.start_dpf.performance_robustness) {
392 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 367 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
393 } 368 }
394 } 369 } else {
395 else {
396 output_struct->data.start_dpf.compatibility_priority = 370 output_struct->data.start_dpf.compatibility_priority =
397 ACPI_ACCEPTABLE_CONFIGURATION; 371 ACPI_ACCEPTABLE_CONFIGURATION;
398 372
399 output_struct->data.start_dpf.performance_robustness = 373 output_struct->data.start_dpf.performance_robustness =
400 ACPI_ACCEPTABLE_CONFIGURATION; 374 ACPI_ACCEPTABLE_CONFIGURATION;
401 } 375 }
402 376
403 /* Set the Length parameter */ 377 /* Set the Length parameter */
@@ -407,10 +381,9 @@ acpi_rs_start_depend_fns_resource (
407 /* Return the final size of the structure */ 381 /* Return the final size of the structure */
408 382
409 *structure_size = struct_size; 383 *structure_size = struct_size;
410 return_ACPI_STATUS (AE_OK); 384 return_ACPI_STATUS(AE_OK);
411} 385}
412 386
413
414/******************************************************************************* 387/*******************************************************************************
415 * 388 *
416 * FUNCTION: acpi_rs_end_depend_fns_resource 389 * FUNCTION: acpi_rs_end_depend_fns_resource
@@ -433,18 +406,14 @@ acpi_rs_start_depend_fns_resource (
433 ******************************************************************************/ 406 ******************************************************************************/
434 407
435acpi_status 408acpi_status
436acpi_rs_end_depend_fns_resource ( 409acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
437 u8 *byte_stream_buffer, 410 acpi_size * bytes_consumed,
438 acpi_size *bytes_consumed, 411 u8 ** output_buffer, acpi_size * structure_size)
439 u8 **output_buffer,
440 acpi_size *structure_size)
441{ 412{
442 struct acpi_resource *output_struct = (void *) *output_buffer; 413 struct acpi_resource *output_struct = (void *)*output_buffer;
443 acpi_size struct_size = ACPI_RESOURCE_LENGTH; 414 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
444
445
446 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource");
447 415
416 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
448 417
449 /* The number of bytes consumed is static */ 418 /* The number of bytes consumed is static */
450 419
@@ -461,10 +430,9 @@ acpi_rs_end_depend_fns_resource (
461 /* Return the final size of the structure */ 430 /* Return the final size of the structure */
462 431
463 *structure_size = struct_size; 432 *structure_size = struct_size;
464 return_ACPI_STATUS (AE_OK); 433 return_ACPI_STATUS(AE_OK);
465} 434}
466 435
467
468/******************************************************************************* 436/*******************************************************************************
469 * 437 *
470 * FUNCTION: acpi_rs_start_depend_fns_stream 438 * FUNCTION: acpi_rs_start_depend_fns_stream
@@ -483,39 +451,35 @@ acpi_rs_end_depend_fns_resource (
483 ******************************************************************************/ 451 ******************************************************************************/
484 452
485acpi_status 453acpi_status
486acpi_rs_start_depend_fns_stream ( 454acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
487 struct acpi_resource *linked_list, 455 u8 ** output_buffer, acpi_size * bytes_consumed)
488 u8 **output_buffer,
489 acpi_size *bytes_consumed)
490{ 456{
491 u8 *buffer = *output_buffer; 457 u8 *buffer = *output_buffer;
492 u8 temp8 = 0; 458 u8 temp8 = 0;
493
494
495 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_stream");
496 459
460 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
497 461
498 /* 462 /*
499 * The descriptor field is set based upon whether a byte is needed 463 * The descriptor field is set based upon whether a byte is needed
500 * to contain Priority data. 464 * to contain Priority data.
501 */ 465 */
502 if (ACPI_ACCEPTABLE_CONFIGURATION == 466 if (ACPI_ACCEPTABLE_CONFIGURATION ==
503 linked_list->data.start_dpf.compatibility_priority && 467 linked_list->data.start_dpf.compatibility_priority &&
504 ACPI_ACCEPTABLE_CONFIGURATION == 468 ACPI_ACCEPTABLE_CONFIGURATION ==
505 linked_list->data.start_dpf.performance_robustness) { 469 linked_list->data.start_dpf.performance_robustness) {
506 *buffer = 0x30; 470 *buffer = 0x30;
507 } 471 } else {
508 else {
509 *buffer = 0x31; 472 *buffer = 0x31;
510 buffer += 1; 473 buffer += 1;
511 474
512 /* Set the Priority Byte Definition */ 475 /* Set the Priority Byte Definition */
513 476
514 temp8 = 0; 477 temp8 = 0;
515 temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness & 478 temp8 =
516 0x03) << 2); 479 (u8) ((linked_list->data.start_dpf.
517 temp8 |= (linked_list->data.start_dpf.compatibility_priority & 480 performance_robustness & 0x03) << 2);
518 0x03); 481 temp8 |=
482 (linked_list->data.start_dpf.compatibility_priority & 0x03);
519 *buffer = temp8; 483 *buffer = temp8;
520 } 484 }
521 485
@@ -523,11 +487,10 @@ acpi_rs_start_depend_fns_stream (
523 487
524 /* Return the number of bytes consumed in this operation */ 488 /* Return the number of bytes consumed in this operation */
525 489
526 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 490 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
527 return_ACPI_STATUS (AE_OK); 491 return_ACPI_STATUS(AE_OK);
528} 492}
529 493
530
531/******************************************************************************* 494/*******************************************************************************
532 * 495 *
533 * FUNCTION: acpi_rs_end_depend_fns_stream 496 * FUNCTION: acpi_rs_end_depend_fns_stream
@@ -545,16 +508,12 @@ acpi_rs_start_depend_fns_stream (
545 ******************************************************************************/ 508 ******************************************************************************/
546 509
547acpi_status 510acpi_status
548acpi_rs_end_depend_fns_stream ( 511acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list,
549 struct acpi_resource *linked_list, 512 u8 ** output_buffer, acpi_size * bytes_consumed)
550 u8 **output_buffer,
551 acpi_size *bytes_consumed)
552{ 513{
553 u8 *buffer = *output_buffer; 514 u8 *buffer = *output_buffer;
554
555
556 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream");
557 515
516 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
558 517
559 /* The descriptor field is static */ 518 /* The descriptor field is static */
560 519
@@ -563,7 +522,6 @@ acpi_rs_end_depend_fns_stream (
563 522
564 /* Return the number of bytes consumed in this operation */ 523 /* Return the number of bytes consumed in this operation */
565 524
566 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 525 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
567 return_ACPI_STATUS (AE_OK); 526 return_ACPI_STATUS(AE_OK);
568} 527}
569
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 700cf7d65d76..4446778eaf79 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -41,15 +41,12 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acresrc.h> 46#include <acpi/acresrc.h>
48 47
49
50#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rsutils") 49ACPI_MODULE_NAME("rsutils")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -68,42 +65,36 @@
68 * and the contents of the callers buffer is undefined. 65 * and the contents of the callers buffer is undefined.
69 * 66 *
70 ******************************************************************************/ 67 ******************************************************************************/
71
72acpi_status 68acpi_status
73acpi_rs_get_prt_method_data ( 69acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
74 acpi_handle handle,
75 struct acpi_buffer *ret_buffer)
76{ 70{
77 union acpi_operand_object *obj_desc; 71 union acpi_operand_object *obj_desc;
78 acpi_status status; 72 acpi_status status;
79
80
81 ACPI_FUNCTION_TRACE ("rs_get_prt_method_data");
82 73
74 ACPI_FUNCTION_TRACE("rs_get_prt_method_data");
83 75
84 /* Parameters guaranteed valid by caller */ 76 /* Parameters guaranteed valid by caller */
85 77
86 /* Execute the method, no parameters */ 78 /* Execute the method, no parameters */
87 79
88 status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRT, 80 status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRT,
89 ACPI_BTYPE_PACKAGE, &obj_desc); 81 ACPI_BTYPE_PACKAGE, &obj_desc);
90 if (ACPI_FAILURE (status)) { 82 if (ACPI_FAILURE(status)) {
91 return_ACPI_STATUS (status); 83 return_ACPI_STATUS(status);
92 } 84 }
93 85
94 /* 86 /*
95 * Create a resource linked list from the byte stream buffer that comes 87 * Create a resource linked list from the byte stream buffer that comes
96 * back from the _CRS method execution. 88 * back from the _CRS method execution.
97 */ 89 */
98 status = acpi_rs_create_pci_routing_table (obj_desc, ret_buffer); 90 status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer);
99 91
100 /* On exit, we must delete the object returned by evaluate_object */ 92 /* On exit, we must delete the object returned by evaluate_object */
101 93
102 acpi_ut_remove_reference (obj_desc); 94 acpi_ut_remove_reference(obj_desc);
103 return_ACPI_STATUS (status); 95 return_ACPI_STATUS(status);
104} 96}
105 97
106
107/******************************************************************************* 98/*******************************************************************************
108 * 99 *
109 * FUNCTION: acpi_rs_get_crs_method_data 100 * FUNCTION: acpi_rs_get_crs_method_data
@@ -123,25 +114,21 @@ acpi_rs_get_prt_method_data (
123 ******************************************************************************/ 114 ******************************************************************************/
124 115
125acpi_status 116acpi_status
126acpi_rs_get_crs_method_data ( 117acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
127 acpi_handle handle,
128 struct acpi_buffer *ret_buffer)
129{ 118{
130 union acpi_operand_object *obj_desc; 119 union acpi_operand_object *obj_desc;
131 acpi_status status; 120 acpi_status status;
132
133
134 ACPI_FUNCTION_TRACE ("rs_get_crs_method_data");
135 121
122 ACPI_FUNCTION_TRACE("rs_get_crs_method_data");
136 123
137 /* Parameters guaranteed valid by caller */ 124 /* Parameters guaranteed valid by caller */
138 125
139 /* Execute the method, no parameters */ 126 /* Execute the method, no parameters */
140 127
141 status = acpi_ut_evaluate_object (handle, METHOD_NAME__CRS, 128 status = acpi_ut_evaluate_object(handle, METHOD_NAME__CRS,
142 ACPI_BTYPE_BUFFER, &obj_desc); 129 ACPI_BTYPE_BUFFER, &obj_desc);
143 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
144 return_ACPI_STATUS (status); 131 return_ACPI_STATUS(status);
145 } 132 }
146 133
147 /* 134 /*
@@ -149,15 +136,14 @@ acpi_rs_get_crs_method_data (
149 * byte stream buffer that comes back from the _CRS method 136 * byte stream buffer that comes back from the _CRS method
150 * execution. 137 * execution.
151 */ 138 */
152 status = acpi_rs_create_resource_list (obj_desc, ret_buffer); 139 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
153 140
154 /* on exit, we must delete the object returned by evaluate_object */ 141 /* on exit, we must delete the object returned by evaluate_object */
155 142
156 acpi_ut_remove_reference (obj_desc); 143 acpi_ut_remove_reference(obj_desc);
157 return_ACPI_STATUS (status); 144 return_ACPI_STATUS(status);
158} 145}
159 146
160
161/******************************************************************************* 147/*******************************************************************************
162 * 148 *
163 * FUNCTION: acpi_rs_get_prs_method_data 149 * FUNCTION: acpi_rs_get_prs_method_data
@@ -178,25 +164,21 @@ acpi_rs_get_crs_method_data (
178 164
179#ifdef ACPI_FUTURE_USAGE 165#ifdef ACPI_FUTURE_USAGE
180acpi_status 166acpi_status
181acpi_rs_get_prs_method_data ( 167acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
182 acpi_handle handle,
183 struct acpi_buffer *ret_buffer)
184{ 168{
185 union acpi_operand_object *obj_desc; 169 union acpi_operand_object *obj_desc;
186 acpi_status status; 170 acpi_status status;
187
188
189 ACPI_FUNCTION_TRACE ("rs_get_prs_method_data");
190 171
172 ACPI_FUNCTION_TRACE("rs_get_prs_method_data");
191 173
192 /* Parameters guaranteed valid by caller */ 174 /* Parameters guaranteed valid by caller */
193 175
194 /* Execute the method, no parameters */ 176 /* Execute the method, no parameters */
195 177
196 status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRS, 178 status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRS,
197 ACPI_BTYPE_BUFFER, &obj_desc); 179 ACPI_BTYPE_BUFFER, &obj_desc);
198 if (ACPI_FAILURE (status)) { 180 if (ACPI_FAILURE(status)) {
199 return_ACPI_STATUS (status); 181 return_ACPI_STATUS(status);
200 } 182 }
201 183
202 /* 184 /*
@@ -204,15 +186,14 @@ acpi_rs_get_prs_method_data (
204 * byte stream buffer that comes back from the _CRS method 186 * byte stream buffer that comes back from the _CRS method
205 * execution. 187 * execution.
206 */ 188 */
207 status = acpi_rs_create_resource_list (obj_desc, ret_buffer); 189 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
208 190
209 /* on exit, we must delete the object returned by evaluate_object */ 191 /* on exit, we must delete the object returned by evaluate_object */
210 192
211 acpi_ut_remove_reference (obj_desc); 193 acpi_ut_remove_reference(obj_desc);
212 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
213} 195}
214#endif /* ACPI_FUTURE_USAGE */ 196#endif /* ACPI_FUTURE_USAGE */
215
216 197
217/******************************************************************************* 198/*******************************************************************************
218 * 199 *
@@ -234,25 +215,22 @@ acpi_rs_get_prs_method_data (
234 ******************************************************************************/ 215 ******************************************************************************/
235 216
236acpi_status 217acpi_status
237acpi_rs_get_method_data ( 218acpi_rs_get_method_data(acpi_handle handle,
238 acpi_handle handle, 219 char *path, struct acpi_buffer *ret_buffer)
239 char *path,
240 struct acpi_buffer *ret_buffer)
241{ 220{
242 union acpi_operand_object *obj_desc; 221 union acpi_operand_object *obj_desc;
243 acpi_status status; 222 acpi_status status;
244
245
246 ACPI_FUNCTION_TRACE ("rs_get_method_data");
247 223
224 ACPI_FUNCTION_TRACE("rs_get_method_data");
248 225
249 /* Parameters guaranteed valid by caller */ 226 /* Parameters guaranteed valid by caller */
250 227
251 /* Execute the method, no parameters */ 228 /* Execute the method, no parameters */
252 229
253 status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc); 230 status =
254 if (ACPI_FAILURE (status)) { 231 acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
255 return_ACPI_STATUS (status); 232 if (ACPI_FAILURE(status)) {
233 return_ACPI_STATUS(status);
256 } 234 }
257 235
258 /* 236 /*
@@ -260,12 +238,12 @@ acpi_rs_get_method_data (
260 * byte stream buffer that comes back from the method 238 * byte stream buffer that comes back from the method
261 * execution. 239 * execution.
262 */ 240 */
263 status = acpi_rs_create_resource_list (obj_desc, ret_buffer); 241 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
264 242
265 /* On exit, we must delete the object returned by evaluate_object */ 243 /* On exit, we must delete the object returned by evaluate_object */
266 244
267 acpi_ut_remove_reference (obj_desc); 245 acpi_ut_remove_reference(obj_desc);
268 return_ACPI_STATUS (status); 246 return_ACPI_STATUS(status);
269} 247}
270 248
271/******************************************************************************* 249/*******************************************************************************
@@ -287,18 +265,14 @@ acpi_rs_get_method_data (
287 ******************************************************************************/ 265 ******************************************************************************/
288 266
289acpi_status 267acpi_status
290acpi_rs_set_srs_method_data ( 268acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer)
291 acpi_handle handle,
292 struct acpi_buffer *in_buffer)
293{ 269{
294 struct acpi_parameter_info info; 270 struct acpi_parameter_info info;
295 union acpi_operand_object *params[2]; 271 union acpi_operand_object *params[2];
296 acpi_status status; 272 acpi_status status;
297 struct acpi_buffer buffer; 273 struct acpi_buffer buffer;
298
299
300 ACPI_FUNCTION_TRACE ("rs_set_srs_method_data");
301 274
275 ACPI_FUNCTION_TRACE("rs_set_srs_method_data");
302 276
303 /* Parameters guaranteed valid by caller */ 277 /* Parameters guaranteed valid by caller */
304 278
@@ -310,24 +284,24 @@ acpi_rs_set_srs_method_data (
310 * Convert the linked list into a byte stream 284 * Convert the linked list into a byte stream
311 */ 285 */
312 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 286 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
313 status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer); 287 status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer);
314 if (ACPI_FAILURE (status)) { 288 if (ACPI_FAILURE(status)) {
315 return_ACPI_STATUS (status); 289 return_ACPI_STATUS(status);
316 } 290 }
317 291
318 /* Init the param object */ 292 /* Init the param object */
319 293
320 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); 294 params[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
321 if (!params[0]) { 295 if (!params[0]) {
322 acpi_os_free (buffer.pointer); 296 acpi_os_free(buffer.pointer);
323 return_ACPI_STATUS (AE_NO_MEMORY); 297 return_ACPI_STATUS(AE_NO_MEMORY);
324 } 298 }
325 299
326 /* Set up the parameter object */ 300 /* Set up the parameter object */
327 301
328 params[0]->buffer.length = (u32) buffer.length; 302 params[0]->buffer.length = (u32) buffer.length;
329 params[0]->buffer.pointer = buffer.pointer; 303 params[0]->buffer.pointer = buffer.pointer;
330 params[0]->common.flags = AOPOBJ_DATA_VALID; 304 params[0]->common.flags = AOPOBJ_DATA_VALID;
331 params[1] = NULL; 305 params[1] = NULL;
332 306
333 info.node = handle; 307 info.node = handle;
@@ -336,18 +310,17 @@ acpi_rs_set_srs_method_data (
336 310
337 /* Execute the method, no return value */ 311 /* Execute the method, no return value */
338 312
339 status = acpi_ns_evaluate_relative (METHOD_NAME__SRS, &info); 313 status = acpi_ns_evaluate_relative(METHOD_NAME__SRS, &info);
340 if (ACPI_SUCCESS (status)) { 314 if (ACPI_SUCCESS(status)) {
341 /* Delete any return object (especially if implicit_return is enabled) */ 315 /* Delete any return object (especially if implicit_return is enabled) */
342 316
343 if (info.return_object) { 317 if (info.return_object) {
344 acpi_ut_remove_reference (info.return_object); 318 acpi_ut_remove_reference(info.return_object);
345 } 319 }
346 } 320 }
347 321
348 /* Clean up and return the status from acpi_ns_evaluate_relative */ 322 /* Clean up and return the status from acpi_ns_evaluate_relative */
349 323
350 acpi_ut_remove_reference (params[0]); 324 acpi_ut_remove_reference(params[0]);
351 return_ACPI_STATUS (status); 325 return_ACPI_STATUS(status);
352} 326}
353
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index 83c944b8b097..ee5a5c509199 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -47,10 +47,9 @@
47#include <acpi/acresrc.h> 47#include <acpi/acresrc.h>
48 48
49#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
50 ACPI_MODULE_NAME ("rsxface") 50ACPI_MODULE_NAME("rsxface")
51 51
52/* Local macros for 16,32-bit to 64-bit conversion */ 52/* Local macros for 16,32-bit to 64-bit conversion */
53
54#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field) 53#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
55#define ACPI_COPY_ADDRESS(out, in) \ 54#define ACPI_COPY_ADDRESS(out, in) \
56 ACPI_COPY_FIELD(out, in, resource_type); \ 55 ACPI_COPY_FIELD(out, in, resource_type); \
@@ -65,8 +64,6 @@
65 ACPI_COPY_FIELD(out, in, address_translation_offset); \ 64 ACPI_COPY_FIELD(out, in, address_translation_offset); \
66 ACPI_COPY_FIELD(out, in, address_length); \ 65 ACPI_COPY_FIELD(out, in, address_length); \
67 ACPI_COPY_FIELD(out, in, resource_source); 66 ACPI_COPY_FIELD(out, in, resource_source);
68
69
70/******************************************************************************* 67/*******************************************************************************
71 * 68 *
72 * FUNCTION: acpi_get_irq_routing_table 69 * FUNCTION: acpi_get_irq_routing_table
@@ -89,17 +86,13 @@
89 * the object indicated by the passed device_handle. 86 * the object indicated by the passed device_handle.
90 * 87 *
91 ******************************************************************************/ 88 ******************************************************************************/
92
93acpi_status 89acpi_status
94acpi_get_irq_routing_table ( 90acpi_get_irq_routing_table(acpi_handle device_handle,
95 acpi_handle device_handle, 91 struct acpi_buffer *ret_buffer)
96 struct acpi_buffer *ret_buffer)
97{ 92{
98 acpi_status status; 93 acpi_status status;
99
100
101 ACPI_FUNCTION_TRACE ("acpi_get_irq_routing_table ");
102 94
95 ACPI_FUNCTION_TRACE("acpi_get_irq_routing_table ");
103 96
104 /* 97 /*
105 * Must have a valid handle and buffer, So we have to have a handle 98 * Must have a valid handle and buffer, So we have to have a handle
@@ -108,19 +101,18 @@ acpi_get_irq_routing_table (
108 * we'll be returning the needed buffer size, so keep going. 101 * we'll be returning the needed buffer size, so keep going.
109 */ 102 */
110 if (!device_handle) { 103 if (!device_handle) {
111 return_ACPI_STATUS (AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
112 } 105 }
113 106
114 status = acpi_ut_validate_buffer (ret_buffer); 107 status = acpi_ut_validate_buffer(ret_buffer);
115 if (ACPI_FAILURE (status)) { 108 if (ACPI_FAILURE(status)) {
116 return_ACPI_STATUS (status); 109 return_ACPI_STATUS(status);
117 } 110 }
118 111
119 status = acpi_rs_get_prt_method_data (device_handle, ret_buffer); 112 status = acpi_rs_get_prt_method_data(device_handle, ret_buffer);
120 return_ACPI_STATUS (status); 113 return_ACPI_STATUS(status);
121} 114}
122 115
123
124/******************************************************************************* 116/*******************************************************************************
125 * 117 *
126 * FUNCTION: acpi_get_current_resources 118 * FUNCTION: acpi_get_current_resources
@@ -146,15 +138,12 @@ acpi_get_irq_routing_table (
146 ******************************************************************************/ 138 ******************************************************************************/
147 139
148acpi_status 140acpi_status
149acpi_get_current_resources ( 141acpi_get_current_resources(acpi_handle device_handle,
150 acpi_handle device_handle, 142 struct acpi_buffer *ret_buffer)
151 struct acpi_buffer *ret_buffer)
152{ 143{
153 acpi_status status; 144 acpi_status status;
154
155
156 ACPI_FUNCTION_TRACE ("acpi_get_current_resources");
157 145
146 ACPI_FUNCTION_TRACE("acpi_get_current_resources");
158 147
159 /* 148 /*
160 * Must have a valid handle and buffer, So we have to have a handle 149 * Must have a valid handle and buffer, So we have to have a handle
@@ -163,19 +152,19 @@ acpi_get_current_resources (
163 * we'll be returning the needed buffer size, so keep going. 152 * we'll be returning the needed buffer size, so keep going.
164 */ 153 */
165 if (!device_handle) { 154 if (!device_handle) {
166 return_ACPI_STATUS (AE_BAD_PARAMETER); 155 return_ACPI_STATUS(AE_BAD_PARAMETER);
167 } 156 }
168 157
169 status = acpi_ut_validate_buffer (ret_buffer); 158 status = acpi_ut_validate_buffer(ret_buffer);
170 if (ACPI_FAILURE (status)) { 159 if (ACPI_FAILURE(status)) {
171 return_ACPI_STATUS (status); 160 return_ACPI_STATUS(status);
172 } 161 }
173 162
174 status = acpi_rs_get_crs_method_data (device_handle, ret_buffer); 163 status = acpi_rs_get_crs_method_data(device_handle, ret_buffer);
175 return_ACPI_STATUS (status); 164 return_ACPI_STATUS(status);
176} 165}
177EXPORT_SYMBOL(acpi_get_current_resources);
178 166
167EXPORT_SYMBOL(acpi_get_current_resources);
179 168
180/******************************************************************************* 169/*******************************************************************************
181 * 170 *
@@ -200,15 +189,12 @@ EXPORT_SYMBOL(acpi_get_current_resources);
200 189
201#ifdef ACPI_FUTURE_USAGE 190#ifdef ACPI_FUTURE_USAGE
202acpi_status 191acpi_status
203acpi_get_possible_resources ( 192acpi_get_possible_resources(acpi_handle device_handle,
204 acpi_handle device_handle, 193 struct acpi_buffer *ret_buffer)
205 struct acpi_buffer *ret_buffer)
206{ 194{
207 acpi_status status; 195 acpi_status status;
208
209
210 ACPI_FUNCTION_TRACE ("acpi_get_possible_resources");
211 196
197 ACPI_FUNCTION_TRACE("acpi_get_possible_resources");
212 198
213 /* 199 /*
214 * Must have a valid handle and buffer, So we have to have a handle 200 * Must have a valid handle and buffer, So we have to have a handle
@@ -217,20 +203,20 @@ acpi_get_possible_resources (
217 * we'll be returning the needed buffer size, so keep going. 203 * we'll be returning the needed buffer size, so keep going.
218 */ 204 */
219 if (!device_handle) { 205 if (!device_handle) {
220 return_ACPI_STATUS (AE_BAD_PARAMETER); 206 return_ACPI_STATUS(AE_BAD_PARAMETER);
221 } 207 }
222 208
223 status = acpi_ut_validate_buffer (ret_buffer); 209 status = acpi_ut_validate_buffer(ret_buffer);
224 if (ACPI_FAILURE (status)) { 210 if (ACPI_FAILURE(status)) {
225 return_ACPI_STATUS (status); 211 return_ACPI_STATUS(status);
226 } 212 }
227 213
228 status = acpi_rs_get_prs_method_data (device_handle, ret_buffer); 214 status = acpi_rs_get_prs_method_data(device_handle, ret_buffer);
229 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
230} 216}
231EXPORT_SYMBOL(acpi_get_possible_resources);
232#endif /* ACPI_FUTURE_USAGE */
233 217
218EXPORT_SYMBOL(acpi_get_possible_resources);
219#endif /* ACPI_FUTURE_USAGE */
234 220
235/******************************************************************************* 221/*******************************************************************************
236 * 222 *
@@ -252,37 +238,33 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
252 ******************************************************************************/ 238 ******************************************************************************/
253 239
254acpi_status 240acpi_status
255acpi_walk_resources ( 241acpi_walk_resources(acpi_handle device_handle,
256 acpi_handle device_handle, 242 char *path,
257 char *path, 243 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
258 ACPI_WALK_RESOURCE_CALLBACK user_function,
259 void *context)
260{ 244{
261 acpi_status status; 245 acpi_status status;
262 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 246 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
263 struct acpi_resource *resource; 247 struct acpi_resource *resource;
264 struct acpi_resource *buffer_end; 248 struct acpi_resource *buffer_end;
265
266
267 ACPI_FUNCTION_TRACE ("acpi_walk_resources");
268 249
250 ACPI_FUNCTION_TRACE("acpi_walk_resources");
269 251
270 if (!device_handle || 252 if (!device_handle ||
271 (ACPI_STRNCMP (path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) && 253 (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
272 ACPI_STRNCMP (path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) { 254 ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
273 return_ACPI_STATUS (AE_BAD_PARAMETER); 255 return_ACPI_STATUS(AE_BAD_PARAMETER);
274 } 256 }
275 257
276 status = acpi_rs_get_method_data (device_handle, path, &buffer); 258 status = acpi_rs_get_method_data(device_handle, path, &buffer);
277 if (ACPI_FAILURE (status)) { 259 if (ACPI_FAILURE(status)) {
278 return_ACPI_STATUS (status); 260 return_ACPI_STATUS(status);
279 } 261 }
280 262
281 /* Setup pointers */ 263 /* Setup pointers */
282 264
283 resource = (struct acpi_resource *) buffer.pointer; 265 resource = (struct acpi_resource *)buffer.pointer;
284 buffer_end = ACPI_CAST_PTR (struct acpi_resource, 266 buffer_end = ACPI_CAST_PTR(struct acpi_resource,
285 ((u8 *) buffer.pointer + buffer.length)); 267 ((u8 *) buffer.pointer + buffer.length));
286 268
287 /* Walk the resource list */ 269 /* Walk the resource list */
288 270
@@ -291,7 +273,7 @@ acpi_walk_resources (
291 break; 273 break;
292 } 274 }
293 275
294 status = user_function (resource, context); 276 status = user_function(resource, context);
295 277
296 switch (status) { 278 switch (status) {
297 case AE_OK: 279 case AE_OK:
@@ -318,7 +300,7 @@ acpi_walk_resources (
318 300
319 /* Get the next resource descriptor */ 301 /* Get the next resource descriptor */
320 302
321 resource = ACPI_NEXT_RESOURCE (resource); 303 resource = ACPI_NEXT_RESOURCE(resource);
322 304
323 /* Check for end-of-buffer */ 305 /* Check for end-of-buffer */
324 306
@@ -327,13 +309,13 @@ acpi_walk_resources (
327 } 309 }
328 } 310 }
329 311
330cleanup: 312 cleanup:
331 313
332 acpi_os_free (buffer.pointer); 314 acpi_os_free(buffer.pointer);
333 return_ACPI_STATUS (status); 315 return_ACPI_STATUS(status);
334} 316}
335EXPORT_SYMBOL(acpi_walk_resources);
336 317
318EXPORT_SYMBOL(acpi_walk_resources);
337 319
338/******************************************************************************* 320/*******************************************************************************
339 * 321 *
@@ -354,30 +336,25 @@ EXPORT_SYMBOL(acpi_walk_resources);
354 ******************************************************************************/ 336 ******************************************************************************/
355 337
356acpi_status 338acpi_status
357acpi_set_current_resources ( 339acpi_set_current_resources(acpi_handle device_handle,
358 acpi_handle device_handle, 340 struct acpi_buffer *in_buffer)
359 struct acpi_buffer *in_buffer)
360{ 341{
361 acpi_status status; 342 acpi_status status;
362
363
364 ACPI_FUNCTION_TRACE ("acpi_set_current_resources");
365 343
344 ACPI_FUNCTION_TRACE("acpi_set_current_resources");
366 345
367 /* Must have a valid handle and buffer */ 346 /* Must have a valid handle and buffer */
368 347
369 if ((!device_handle) || 348 if ((!device_handle) ||
370 (!in_buffer) || 349 (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) {
371 (!in_buffer->pointer) || 350 return_ACPI_STATUS(AE_BAD_PARAMETER);
372 (!in_buffer->length)) {
373 return_ACPI_STATUS (AE_BAD_PARAMETER);
374 } 351 }
375 352
376 status = acpi_rs_set_srs_method_data (device_handle, in_buffer); 353 status = acpi_rs_set_srs_method_data(device_handle, in_buffer);
377 return_ACPI_STATUS (status); 354 return_ACPI_STATUS(status);
378} 355}
379EXPORT_SYMBOL(acpi_set_current_resources);
380 356
357EXPORT_SYMBOL(acpi_set_current_resources);
381 358
382/****************************************************************************** 359/******************************************************************************
383 * 360 *
@@ -398,41 +375,38 @@ EXPORT_SYMBOL(acpi_set_current_resources);
398 ******************************************************************************/ 375 ******************************************************************************/
399 376
400acpi_status 377acpi_status
401acpi_resource_to_address64 ( 378acpi_resource_to_address64(struct acpi_resource *resource,
402 struct acpi_resource *resource, 379 struct acpi_resource_address64 *out)
403 struct acpi_resource_address64 *out)
404{ 380{
405 struct acpi_resource_address16 *address16; 381 struct acpi_resource_address16 *address16;
406 struct acpi_resource_address32 *address32; 382 struct acpi_resource_address32 *address32;
407
408 383
409 switch (resource->id) { 384 switch (resource->id) {
410 case ACPI_RSTYPE_ADDRESS16: 385 case ACPI_RSTYPE_ADDRESS16:
411 386
412 address16 = (struct acpi_resource_address16 *) &resource->data; 387 address16 = (struct acpi_resource_address16 *)&resource->data;
413 ACPI_COPY_ADDRESS (out, address16); 388 ACPI_COPY_ADDRESS(out, address16);
414 break; 389 break;
415 390
416
417 case ACPI_RSTYPE_ADDRESS32: 391 case ACPI_RSTYPE_ADDRESS32:
418 392
419 address32 = (struct acpi_resource_address32 *) &resource->data; 393 address32 = (struct acpi_resource_address32 *)&resource->data;
420 ACPI_COPY_ADDRESS (out, address32); 394 ACPI_COPY_ADDRESS(out, address32);
421 break; 395 break;
422 396
423
424 case ACPI_RSTYPE_ADDRESS64: 397 case ACPI_RSTYPE_ADDRESS64:
425 398
426 /* Simple copy for 64 bit source */ 399 /* Simple copy for 64 bit source */
427 400
428 ACPI_MEMCPY (out, &resource->data, sizeof (struct acpi_resource_address64)); 401 ACPI_MEMCPY(out, &resource->data,
402 sizeof(struct acpi_resource_address64));
429 break; 403 break;
430 404
431
432 default: 405 default:
433 return (AE_BAD_PARAMETER); 406 return (AE_BAD_PARAMETER);
434 } 407 }
435 408
436 return (AE_OK); 409 return (AE_OK);
437} 410}
411
438EXPORT_SYMBOL(acpi_resource_to_address64); 412EXPORT_SYMBOL(acpi_resource_to_address64);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index cbcda30c172d..c6db591479de 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -9,14 +9,10 @@
9#include <acpi/acpi_drivers.h> 9#include <acpi/acpi_drivers.h>
10#include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */ 10#include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */
11 11
12
13#define _COMPONENT ACPI_BUS_COMPONENT 12#define _COMPONENT ACPI_BUS_COMPONENT
14ACPI_MODULE_NAME ("scan") 13ACPI_MODULE_NAME("scan")
15
16#define STRUCT_TO_INT(s) (*((int*)&s)) 14#define STRUCT_TO_INT(s) (*((int*)&s))
17 15extern struct acpi_device *acpi_root;
18extern struct acpi_device *acpi_root;
19
20 16
21#define ACPI_BUS_CLASS "system_bus" 17#define ACPI_BUS_CLASS "system_bus"
22#define ACPI_BUS_HID "ACPI_BUS" 18#define ACPI_BUS_HID "ACPI_BUS"
@@ -27,13 +23,11 @@ static LIST_HEAD(acpi_device_list);
27DEFINE_SPINLOCK(acpi_device_lock); 23DEFINE_SPINLOCK(acpi_device_lock);
28LIST_HEAD(acpi_wakeup_device_list); 24LIST_HEAD(acpi_wakeup_device_list);
29 25
30static int 26static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
31acpi_bus_trim(struct acpi_device *start,
32 int rmdevice);
33 27
34static void acpi_device_release(struct kobject * kobj) 28static void acpi_device_release(struct kobject *kobj)
35{ 29{
36 struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj); 30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj);
37 if (dev->pnp.cid_list) 31 if (dev->pnp.cid_list)
38 kfree(dev->pnp.cid_list); 32 kfree(dev->pnp.cid_list);
39 kfree(dev); 33 kfree(dev);
@@ -41,34 +35,34 @@ static void acpi_device_release(struct kobject * kobj)
41 35
42struct acpi_device_attribute { 36struct acpi_device_attribute {
43 struct attribute attr; 37 struct attribute attr;
44 ssize_t (*show)(struct acpi_device *, char *); 38 ssize_t(*show) (struct acpi_device *, char *);
45 ssize_t (*store)(struct acpi_device *, const char *, size_t); 39 ssize_t(*store) (struct acpi_device *, const char *, size_t);
46}; 40};
47 41
48typedef void acpi_device_sysfs_files(struct kobject *, 42typedef void acpi_device_sysfs_files(struct kobject *,
49 const struct attribute *); 43 const struct attribute *);
50 44
51static void setup_sys_fs_device_files(struct acpi_device *dev, 45static void setup_sys_fs_device_files(struct acpi_device *dev,
52 acpi_device_sysfs_files *func); 46 acpi_device_sysfs_files * func);
53 47
54#define create_sysfs_device_files(dev) \ 48#define create_sysfs_device_files(dev) \
55 setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file) 49 setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file)
56#define remove_sysfs_device_files(dev) \ 50#define remove_sysfs_device_files(dev) \
57 setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file) 51 setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file)
58 52
59
60#define to_acpi_device(n) container_of(n, struct acpi_device, kobj) 53#define to_acpi_device(n) container_of(n, struct acpi_device, kobj)
61#define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr); 54#define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr);
62 55
63static ssize_t acpi_device_attr_show(struct kobject *kobj, 56static ssize_t acpi_device_attr_show(struct kobject *kobj,
64 struct attribute *attr, char *buf) 57 struct attribute *attr, char *buf)
65{ 58{
66 struct acpi_device *device = to_acpi_device(kobj); 59 struct acpi_device *device = to_acpi_device(kobj);
67 struct acpi_device_attribute *attribute = to_handle_attr(attr); 60 struct acpi_device_attribute *attribute = to_handle_attr(attr);
68 return attribute->show ? attribute->show(device, buf) : -EIO; 61 return attribute->show ? attribute->show(device, buf) : -EIO;
69} 62}
70static ssize_t acpi_device_attr_store(struct kobject *kobj, 63static ssize_t acpi_device_attr_store(struct kobject *kobj,
71 struct attribute *attr, const char *buf, size_t len) 64 struct attribute *attr, const char *buf,
65 size_t len)
72{ 66{
73 struct acpi_device *device = to_acpi_device(kobj); 67 struct acpi_device *device = to_acpi_device(kobj);
74 struct acpi_device_attribute *attribute = to_handle_attr(attr); 68 struct acpi_device_attribute *attribute = to_handle_attr(attr);
@@ -76,13 +70,13 @@ static ssize_t acpi_device_attr_store(struct kobject *kobj,
76} 70}
77 71
78static struct sysfs_ops acpi_device_sysfs_ops = { 72static struct sysfs_ops acpi_device_sysfs_ops = {
79 .show = acpi_device_attr_show, 73 .show = acpi_device_attr_show,
80 .store = acpi_device_attr_store, 74 .store = acpi_device_attr_store,
81}; 75};
82 76
83static struct kobj_type ktype_acpi_ns = { 77static struct kobj_type ktype_acpi_ns = {
84 .sysfs_ops = &acpi_device_sysfs_ops, 78 .sysfs_ops = &acpi_device_sysfs_ops,
85 .release = acpi_device_release, 79 .release = acpi_device_release,
86}; 80};
87 81
88static int namespace_hotplug(struct kset *kset, struct kobject *kobj, 82static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
@@ -110,16 +104,16 @@ static struct kset_hotplug_ops namespace_hotplug_ops = {
110}; 104};
111 105
112static struct kset acpi_namespace_kset = { 106static struct kset acpi_namespace_kset = {
113 .kobj = { 107 .kobj = {
114 .name = "namespace", 108 .name = "namespace",
115 }, 109 },
116 .subsys = &acpi_subsys, 110 .subsys = &acpi_subsys,
117 .ktype = &ktype_acpi_ns, 111 .ktype = &ktype_acpi_ns,
118 .hotplug_ops = &namespace_hotplug_ops, 112 .hotplug_ops = &namespace_hotplug_ops,
119}; 113};
120 114
121 115static void acpi_device_register(struct acpi_device *device,
122static void acpi_device_register(struct acpi_device * device, struct acpi_device * parent) 116 struct acpi_device *parent)
123{ 117{
124 /* 118 /*
125 * Linkage 119 * Linkage
@@ -134,14 +128,14 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device
134 spin_lock(&acpi_device_lock); 128 spin_lock(&acpi_device_lock);
135 if (device->parent) { 129 if (device->parent) {
136 list_add_tail(&device->node, &device->parent->children); 130 list_add_tail(&device->node, &device->parent->children);
137 list_add_tail(&device->g_list,&device->parent->g_list); 131 list_add_tail(&device->g_list, &device->parent->g_list);
138 } else 132 } else
139 list_add_tail(&device->g_list,&acpi_device_list); 133 list_add_tail(&device->g_list, &acpi_device_list);
140 if (device->wakeup.flags.valid) 134 if (device->wakeup.flags.valid)
141 list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list); 135 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
142 spin_unlock(&acpi_device_lock); 136 spin_unlock(&acpi_device_lock);
143 137
144 strlcpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN); 138 strlcpy(device->kobj.name, device->pnp.bus_id, KOBJ_NAME_LEN);
145 if (parent) 139 if (parent)
146 device->kobj.parent = &parent->kobj; 140 device->kobj.parent = &parent->kobj;
147 device->kobj.ktype = &ktype_acpi_ns; 141 device->kobj.ktype = &ktype_acpi_ns;
@@ -150,10 +144,7 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device
150 create_sysfs_device_files(device); 144 create_sysfs_device_files(device);
151} 145}
152 146
153static int 147static int acpi_device_unregister(struct acpi_device *device, int type)
154acpi_device_unregister (
155 struct acpi_device *device,
156 int type)
157{ 148{
158 spin_lock(&acpi_device_lock); 149 spin_lock(&acpi_device_lock);
159 if (device->parent) { 150 if (device->parent) {
@@ -172,11 +163,7 @@ acpi_device_unregister (
172 return 0; 163 return 0;
173} 164}
174 165
175void 166void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
176acpi_bus_data_handler (
177 acpi_handle handle,
178 u32 function,
179 void *context)
180{ 167{
181 ACPI_FUNCTION_TRACE("acpi_bus_data_handler"); 168 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
182 169
@@ -185,13 +172,11 @@ acpi_bus_data_handler (
185 return_VOID; 172 return_VOID;
186} 173}
187 174
188static int 175static int acpi_bus_get_power_flags(struct acpi_device *device)
189acpi_bus_get_power_flags (
190 struct acpi_device *device)
191{ 176{
192 acpi_status status = 0; 177 acpi_status status = 0;
193 acpi_handle handle = NULL; 178 acpi_handle handle = NULL;
194 u32 i = 0; 179 u32 i = 0;
195 180
196 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); 181 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
197 182
@@ -210,11 +195,11 @@ acpi_bus_get_power_flags (
210 */ 195 */
211 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { 196 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
212 struct acpi_device_power_state *ps = &device->power.states[i]; 197 struct acpi_device_power_state *ps = &device->power.states[i];
213 char object_name[5] = {'_','P','R','0'+i,'\0'}; 198 char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' };
214 199
215 /* Evaluate "_PRx" to se if power resources are referenced */ 200 /* Evaluate "_PRx" to se if power resources are referenced */
216 acpi_evaluate_reference(device->handle, object_name, NULL, 201 acpi_evaluate_reference(device->handle, object_name, NULL,
217 &ps->resources); 202 &ps->resources);
218 if (ps->resources.count) { 203 if (ps->resources.count) {
219 device->power.flags.power_resources = 1; 204 device->power.flags.power_resources = 1;
220 ps->flags.valid = 1; 205 ps->flags.valid = 1;
@@ -232,7 +217,7 @@ acpi_bus_get_power_flags (
232 if (ps->resources.count || ps->flags.explicit_set) 217 if (ps->resources.count || ps->flags.explicit_set)
233 ps->flags.valid = 1; 218 ps->flags.valid = 1;
234 219
235 ps->power = -1; /* Unknown - driver assigned */ 220 ps->power = -1; /* Unknown - driver assigned */
236 ps->latency = -1; /* Unknown - driver assigned */ 221 ps->latency = -1; /* Unknown - driver assigned */
237 } 222 }
238 223
@@ -249,13 +234,10 @@ acpi_bus_get_power_flags (
249 return_VALUE(0); 234 return_VALUE(0);
250} 235}
251 236
252int 237int acpi_match_ids(struct acpi_device *device, char *ids)
253acpi_match_ids (
254 struct acpi_device *device,
255 char *ids)
256{ 238{
257 int error = 0; 239 int error = 0;
258 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 240 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
259 241
260 if (device->flags.hardware_id) 242 if (device->flags.hardware_id)
261 if (strstr(ids, device->pnp.hardware_id)) 243 if (strstr(ids, device->pnp.hardware_id))
@@ -266,27 +248,25 @@ acpi_match_ids (
266 int i; 248 int i;
267 249
268 /* compare multiple _CID entries against driver ids */ 250 /* compare multiple _CID entries against driver ids */
269 for (i = 0; i < cid_list->count; i++) 251 for (i = 0; i < cid_list->count; i++) {
270 {
271 if (strstr(ids, cid_list->id[i].value)) 252 if (strstr(ids, cid_list->id[i].value))
272 goto Done; 253 goto Done;
273 } 254 }
274 } 255 }
275 error = -ENOENT; 256 error = -ENOENT;
276 257
277 Done: 258 Done:
278 if (buffer.pointer) 259 if (buffer.pointer)
279 acpi_os_free(buffer.pointer); 260 acpi_os_free(buffer.pointer);
280 return error; 261 return error;
281} 262}
282 263
283static acpi_status 264static acpi_status
284acpi_bus_extract_wakeup_device_power_package ( 265acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device,
285 struct acpi_device *device, 266 union acpi_object *package)
286 union acpi_object *package)
287{ 267{
288 int i = 0; 268 int i = 0;
289 union acpi_object *element = NULL; 269 union acpi_object *element = NULL;
290 270
291 if (!device || !package || (package->package.count < 2)) 271 if (!device || !package || (package->package.count < 2))
292 return AE_BAD_PARAMETER; 272 return AE_BAD_PARAMETER;
@@ -296,14 +276,17 @@ acpi_bus_extract_wakeup_device_power_package (
296 return AE_BAD_PARAMETER; 276 return AE_BAD_PARAMETER;
297 if (element->type == ACPI_TYPE_PACKAGE) { 277 if (element->type == ACPI_TYPE_PACKAGE) {
298 if ((element->package.count < 2) || 278 if ((element->package.count < 2) ||
299 (element->package.elements[0].type != ACPI_TYPE_LOCAL_REFERENCE) || 279 (element->package.elements[0].type !=
300 (element->package.elements[1].type != ACPI_TYPE_INTEGER)) 280 ACPI_TYPE_LOCAL_REFERENCE)
281 || (element->package.elements[1].type != ACPI_TYPE_INTEGER))
301 return AE_BAD_DATA; 282 return AE_BAD_DATA;
302 device->wakeup.gpe_device = element->package.elements[0].reference.handle; 283 device->wakeup.gpe_device =
303 device->wakeup.gpe_number = (u32)element->package.elements[1].integer.value; 284 element->package.elements[0].reference.handle;
304 }else if (element->type == ACPI_TYPE_INTEGER) { 285 device->wakeup.gpe_number =
286 (u32) element->package.elements[1].integer.value;
287 } else if (element->type == ACPI_TYPE_INTEGER) {
305 device->wakeup.gpe_number = element->integer.value; 288 device->wakeup.gpe_number = element->integer.value;
306 }else 289 } else
307 return AE_BAD_DATA; 290 return AE_BAD_DATA;
308 291
309 element = &(package->package.elements[1]); 292 element = &(package->package.elements[1]);
@@ -316,9 +299,9 @@ acpi_bus_extract_wakeup_device_power_package (
316 return AE_NO_MEMORY; 299 return AE_NO_MEMORY;
317 } 300 }
318 device->wakeup.resources.count = package->package.count - 2; 301 device->wakeup.resources.count = package->package.count - 2;
319 for (i=0; i < device->wakeup.resources.count; i++) { 302 for (i = 0; i < device->wakeup.resources.count; i++) {
320 element = &(package->package.elements[i + 2]); 303 element = &(package->package.elements[i + 2]);
321 if (element->type != ACPI_TYPE_ANY ) { 304 if (element->type != ACPI_TYPE_ANY) {
322 return AE_BAD_DATA; 305 return AE_BAD_DATA;
323 } 306 }
324 307
@@ -328,13 +311,11 @@ acpi_bus_extract_wakeup_device_power_package (
328 return AE_OK; 311 return AE_OK;
329} 312}
330 313
331static int 314static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
332acpi_bus_get_wakeup_device_flags (
333 struct acpi_device *device)
334{ 315{
335 acpi_status status = 0; 316 acpi_status status = 0;
336 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 317 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
337 union acpi_object *package = NULL; 318 union acpi_object *package = NULL;
338 319
339 ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags"); 320 ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
340 321
@@ -345,21 +326,22 @@ acpi_bus_get_wakeup_device_flags (
345 goto end; 326 goto end;
346 } 327 }
347 328
348 package = (union acpi_object *) buffer.pointer; 329 package = (union acpi_object *)buffer.pointer;
349 status = acpi_bus_extract_wakeup_device_power_package(device, package); 330 status = acpi_bus_extract_wakeup_device_power_package(device, package);
350 if (ACPI_FAILURE(status)) { 331 if (ACPI_FAILURE(status)) {
351 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _PRW package\n")); 332 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
333 "Error extracting _PRW package\n"));
352 goto end; 334 goto end;
353 } 335 }
354 336
355 acpi_os_free(buffer.pointer); 337 acpi_os_free(buffer.pointer);
356 338
357 device->wakeup.flags.valid = 1; 339 device->wakeup.flags.valid = 1;
358 /* Power button, Lid switch always enable wakeup*/ 340 /* Power button, Lid switch always enable wakeup */
359 if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E")) 341 if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
360 device->wakeup.flags.run_wake = 1; 342 device->wakeup.flags.run_wake = 1;
361 343
362end: 344 end:
363 if (ACPI_FAILURE(status)) 345 if (ACPI_FAILURE(status))
364 device->flags.wake_capable = 0; 346 device->flags.wake_capable = 0;
365 return_VALUE(0); 347 return_VALUE(0);
@@ -368,8 +350,8 @@ end:
368/* -------------------------------------------------------------------------- 350/* --------------------------------------------------------------------------
369 ACPI hotplug sysfs device file support 351 ACPI hotplug sysfs device file support
370 -------------------------------------------------------------------------- */ 352 -------------------------------------------------------------------------- */
371static ssize_t acpi_eject_store(struct acpi_device *device, 353static ssize_t acpi_eject_store(struct acpi_device *device,
372 const char *buf, size_t count); 354 const char *buf, size_t count);
373 355
374#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \ 356#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
375static struct acpi_device_attribute acpi_device_attr_##_name = \ 357static struct acpi_device_attribute acpi_device_attr_##_name = \
@@ -383,12 +365,11 @@ ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
383 * @func: function pointer to create or destroy the device file 365 * @func: function pointer to create or destroy the device file
384 */ 366 */
385static void 367static void
386setup_sys_fs_device_files ( 368setup_sys_fs_device_files(struct acpi_device *dev,
387 struct acpi_device *dev, 369 acpi_device_sysfs_files * func)
388 acpi_device_sysfs_files *func)
389{ 370{
390 acpi_status status; 371 acpi_status status;
391 acpi_handle temp = NULL; 372 acpi_handle temp = NULL;
392 373
393 /* 374 /*
394 * If device has _EJ0, 'eject' file is created that is used to trigger 375 * If device has _EJ0, 'eject' file is created that is used to trigger
@@ -396,11 +377,10 @@ setup_sys_fs_device_files (
396 */ 377 */
397 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 378 status = acpi_get_handle(dev->handle, "_EJ0", &temp);
398 if (ACPI_SUCCESS(status)) 379 if (ACPI_SUCCESS(status))
399 (*(func))(&dev->kobj,&acpi_device_attr_eject.attr); 380 (*(func)) (&dev->kobj, &acpi_device_attr_eject.attr);
400} 381}
401 382
402static int 383static int acpi_eject_operation(acpi_handle handle, int lockable)
403acpi_eject_operation(acpi_handle handle, int lockable)
404{ 384{
405 struct acpi_object_list arg_list; 385 struct acpi_object_list arg_list;
406 union acpi_object arg; 386 union acpi_object arg;
@@ -429,27 +409,25 @@ acpi_eject_operation(acpi_handle handle, int lockable)
429 409
430 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); 410 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
431 if (ACPI_FAILURE(status)) { 411 if (ACPI_FAILURE(status)) {
432 return(-ENODEV); 412 return (-ENODEV);
433 } 413 }
434 414
435 return(0); 415 return (0);
436} 416}
437 417
438
439static ssize_t 418static ssize_t
440acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) 419acpi_eject_store(struct acpi_device *device, const char *buf, size_t count)
441{ 420{
442 int result; 421 int result;
443 int ret = count; 422 int ret = count;
444 int islockable; 423 int islockable;
445 acpi_status status; 424 acpi_status status;
446 acpi_handle handle; 425 acpi_handle handle;
447 acpi_object_type type = 0; 426 acpi_object_type type = 0;
448 427
449 if ((!count) || (buf[0] != '1')) { 428 if ((!count) || (buf[0] != '1')) {
450 return -EINVAL; 429 return -EINVAL;
451 } 430 }
452
453#ifndef FORCE_EJECT 431#ifndef FORCE_EJECT
454 if (device->driver == NULL) { 432 if (device->driver == NULL) {
455 ret = -ENODEV; 433 ret = -ENODEV;
@@ -457,7 +435,7 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count)
457 } 435 }
458#endif 436#endif
459 status = acpi_get_type(device->handle, &type); 437 status = acpi_get_type(device->handle, &type);
460 if (ACPI_FAILURE(status) || (!device->flags.ejectable) ) { 438 if (ACPI_FAILURE(status) || (!device->flags.ejectable)) {
461 ret = -ENODEV; 439 ret = -ENODEV;
462 goto err; 440 goto err;
463 } 441 }
@@ -476,18 +454,15 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count)
476 if (result) { 454 if (result) {
477 ret = -EBUSY; 455 ret = -EBUSY;
478 } 456 }
479err: 457 err:
480 return ret; 458 return ret;
481} 459}
482 460
483
484/* -------------------------------------------------------------------------- 461/* --------------------------------------------------------------------------
485 Performance Management 462 Performance Management
486 -------------------------------------------------------------------------- */ 463 -------------------------------------------------------------------------- */
487 464
488static int 465static int acpi_bus_get_perf_flags(struct acpi_device *device)
489acpi_bus_get_perf_flags (
490 struct acpi_device *device)
491{ 466{
492 device->performance.state = ACPI_STATE_UNKNOWN; 467 device->performance.state = ACPI_STATE_UNKNOWN;
493 return 0; 468 return 0;
@@ -500,7 +475,6 @@ acpi_bus_get_perf_flags (
500static LIST_HEAD(acpi_bus_drivers); 475static LIST_HEAD(acpi_bus_drivers);
501static DECLARE_MUTEX(acpi_bus_drivers_lock); 476static DECLARE_MUTEX(acpi_bus_drivers_lock);
502 477
503
504/** 478/**
505 * acpi_bus_match 479 * acpi_bus_match
506 * -------------- 480 * --------------
@@ -508,16 +482,13 @@ static DECLARE_MUTEX(acpi_bus_drivers_lock);
508 * matches the specified driver's criteria. 482 * matches the specified driver's criteria.
509 */ 483 */
510static int 484static int
511acpi_bus_match ( 485acpi_bus_match(struct acpi_device *device, struct acpi_driver *driver)
512 struct acpi_device *device,
513 struct acpi_driver *driver)
514{ 486{
515 if (driver && driver->ops.match) 487 if (driver && driver->ops.match)
516 return driver->ops.match(device, driver); 488 return driver->ops.match(device, driver);
517 return acpi_match_ids(device, driver->ids); 489 return acpi_match_ids(device, driver->ids);
518} 490}
519 491
520
521/** 492/**
522 * acpi_bus_driver_init 493 * acpi_bus_driver_init
523 * -------------------- 494 * --------------------
@@ -525,11 +496,9 @@ acpi_bus_match (
525 * driver is bound to a device. Invokes the driver's add() and start() ops. 496 * driver is bound to a device. Invokes the driver's add() and start() ops.
526 */ 497 */
527static int 498static int
528acpi_bus_driver_init ( 499acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
529 struct acpi_device *device,
530 struct acpi_driver *driver)
531{ 500{
532 int result = 0; 501 int result = 0;
533 502
534 ACPI_FUNCTION_TRACE("acpi_bus_driver_init"); 503 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
535 504
@@ -553,13 +522,12 @@ acpi_bus_driver_init (
553 * upon possible configuration and currently allocated resources. 522 * upon possible configuration and currently allocated resources.
554 */ 523 */
555 524
556 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); 525 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
526 "Driver successfully bound to device\n"));
557 return_VALUE(0); 527 return_VALUE(0);
558} 528}
559 529
560int 530static int acpi_start_single_object(struct acpi_device *device)
561acpi_start_single_object (
562 struct acpi_device *device)
563{ 531{
564 int result = 0; 532 int result = 0;
565 struct acpi_driver *driver; 533 struct acpi_driver *driver;
@@ -578,16 +546,17 @@ acpi_start_single_object (
578 return_VALUE(result); 546 return_VALUE(result);
579} 547}
580 548
581static int acpi_driver_attach(struct acpi_driver * drv) 549static int acpi_driver_attach(struct acpi_driver *drv)
582{ 550{
583 struct list_head * node, * next; 551 struct list_head *node, *next;
584 int count = 0; 552 int count = 0;
585 553
586 ACPI_FUNCTION_TRACE("acpi_driver_attach"); 554 ACPI_FUNCTION_TRACE("acpi_driver_attach");
587 555
588 spin_lock(&acpi_device_lock); 556 spin_lock(&acpi_device_lock);
589 list_for_each_safe(node, next, &acpi_device_list) { 557 list_for_each_safe(node, next, &acpi_device_list) {
590 struct acpi_device * dev = container_of(node, struct acpi_device, g_list); 558 struct acpi_device *dev =
559 container_of(node, struct acpi_device, g_list);
591 560
592 if (dev->driver || !dev->status.present) 561 if (dev->driver || !dev->status.present)
593 continue; 562 continue;
@@ -598,7 +567,8 @@ static int acpi_driver_attach(struct acpi_driver * drv)
598 acpi_start_single_object(dev); 567 acpi_start_single_object(dev);
599 atomic_inc(&drv->references); 568 atomic_inc(&drv->references);
600 count++; 569 count++;
601 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", 570 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
571 "Found driver [%s] for device [%s]\n",
602 drv->name, dev->pnp.bus_id)); 572 drv->name, dev->pnp.bus_id));
603 } 573 }
604 } 574 }
@@ -608,20 +578,21 @@ static int acpi_driver_attach(struct acpi_driver * drv)
608 return_VALUE(count); 578 return_VALUE(count);
609} 579}
610 580
611static int acpi_driver_detach(struct acpi_driver * drv) 581static int acpi_driver_detach(struct acpi_driver *drv)
612{ 582{
613 struct list_head * node, * next; 583 struct list_head *node, *next;
614 584
615 ACPI_FUNCTION_TRACE("acpi_driver_detach"); 585 ACPI_FUNCTION_TRACE("acpi_driver_detach");
616 586
617 spin_lock(&acpi_device_lock); 587 spin_lock(&acpi_device_lock);
618 list_for_each_safe(node,next,&acpi_device_list) { 588 list_for_each_safe(node, next, &acpi_device_list) {
619 struct acpi_device * dev = container_of(node,struct acpi_device,g_list); 589 struct acpi_device *dev =
590 container_of(node, struct acpi_device, g_list);
620 591
621 if (dev->driver == drv) { 592 if (dev->driver == drv) {
622 spin_unlock(&acpi_device_lock); 593 spin_unlock(&acpi_device_lock);
623 if (drv->ops.remove) 594 if (drv->ops.remove)
624 drv->ops.remove(dev,ACPI_BUS_REMOVAL_NORMAL); 595 drv->ops.remove(dev, ACPI_BUS_REMOVAL_NORMAL);
625 spin_lock(&acpi_device_lock); 596 spin_lock(&acpi_device_lock);
626 dev->driver = NULL; 597 dev->driver = NULL;
627 dev->driver_data = NULL; 598 dev->driver_data = NULL;
@@ -640,9 +611,7 @@ static int acpi_driver_detach(struct acpi_driver * drv)
640 * number of devices that were claimed by the driver, or a negative 611 * number of devices that were claimed by the driver, or a negative
641 * error status for failure. 612 * error status for failure.
642 */ 613 */
643int 614int acpi_bus_register_driver(struct acpi_driver *driver)
644acpi_bus_register_driver (
645 struct acpi_driver *driver)
646{ 615{
647 int count; 616 int count;
648 617
@@ -661,8 +630,8 @@ acpi_bus_register_driver (
661 630
662 return_VALUE(count); 631 return_VALUE(count);
663} 632}
664EXPORT_SYMBOL(acpi_bus_register_driver);
665 633
634EXPORT_SYMBOL(acpi_bus_register_driver);
666 635
667/** 636/**
668 * acpi_bus_unregister_driver 637 * acpi_bus_unregister_driver
@@ -670,9 +639,7 @@ EXPORT_SYMBOL(acpi_bus_register_driver);
670 * Unregisters a driver with the ACPI bus. Searches the namespace for all 639 * Unregisters a driver with the ACPI bus. Searches the namespace for all
671 * devices that match the driver's criteria and unbinds. 640 * devices that match the driver's criteria and unbinds.
672 */ 641 */
673int 642int acpi_bus_unregister_driver(struct acpi_driver *driver)
674acpi_bus_unregister_driver (
675 struct acpi_driver *driver)
676{ 643{
677 int error = 0; 644 int error = 0;
678 645
@@ -685,11 +652,12 @@ acpi_bus_unregister_driver (
685 spin_lock(&acpi_device_lock); 652 spin_lock(&acpi_device_lock);
686 list_del_init(&driver->node); 653 list_del_init(&driver->node);
687 spin_unlock(&acpi_device_lock); 654 spin_unlock(&acpi_device_lock);
688 } 655 }
689 } else 656 } else
690 error = -EINVAL; 657 error = -EINVAL;
691 return_VALUE(error); 658 return_VALUE(error);
692} 659}
660
693EXPORT_SYMBOL(acpi_bus_unregister_driver); 661EXPORT_SYMBOL(acpi_bus_unregister_driver);
694 662
695/** 663/**
@@ -698,18 +666,17 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver);
698 * Parses the list of registered drivers looking for a driver applicable for 666 * Parses the list of registered drivers looking for a driver applicable for
699 * the specified device. 667 * the specified device.
700 */ 668 */
701static int 669static int acpi_bus_find_driver(struct acpi_device *device)
702acpi_bus_find_driver (
703 struct acpi_device *device)
704{ 670{
705 int result = 0; 671 int result = 0;
706 struct list_head * node, *next; 672 struct list_head *node, *next;
707 673
708 ACPI_FUNCTION_TRACE("acpi_bus_find_driver"); 674 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
709 675
710 spin_lock(&acpi_device_lock); 676 spin_lock(&acpi_device_lock);
711 list_for_each_safe(node,next,&acpi_bus_drivers) { 677 list_for_each_safe(node, next, &acpi_bus_drivers) {
712 struct acpi_driver * driver = container_of(node,struct acpi_driver,node); 678 struct acpi_driver *driver =
679 container_of(node, struct acpi_driver, node);
713 680
714 atomic_inc(&driver->references); 681 atomic_inc(&driver->references);
715 spin_unlock(&acpi_device_lock); 682 spin_unlock(&acpi_device_lock);
@@ -723,21 +690,18 @@ acpi_bus_find_driver (
723 } 690 }
724 spin_unlock(&acpi_device_lock); 691 spin_unlock(&acpi_device_lock);
725 692
726 Done: 693 Done:
727 return_VALUE(result); 694 return_VALUE(result);
728} 695}
729 696
730
731/* -------------------------------------------------------------------------- 697/* --------------------------------------------------------------------------
732 Device Enumeration 698 Device Enumeration
733 -------------------------------------------------------------------------- */ 699 -------------------------------------------------------------------------- */
734 700
735static int 701static int acpi_bus_get_flags(struct acpi_device *device)
736acpi_bus_get_flags (
737 struct acpi_device *device)
738{ 702{
739 acpi_status status = AE_OK; 703 acpi_status status = AE_OK;
740 acpi_handle temp = NULL; 704 acpi_handle temp = NULL;
741 705
742 ACPI_FUNCTION_TRACE("acpi_bus_get_flags"); 706 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
743 707
@@ -788,11 +752,12 @@ acpi_bus_get_flags (
788 return_VALUE(0); 752 return_VALUE(0);
789} 753}
790 754
791static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handle, int type) 755static void acpi_device_get_busid(struct acpi_device *device,
756 acpi_handle handle, int type)
792{ 757{
793 char bus_id[5] = {'?',0}; 758 char bus_id[5] = { '?', 0 };
794 struct acpi_buffer buffer = {sizeof(bus_id), bus_id}; 759 struct acpi_buffer buffer = { sizeof(bus_id), bus_id };
795 int i = 0; 760 int i = 0;
796 761
797 /* 762 /*
798 * Bus ID 763 * Bus ID
@@ -824,21 +789,22 @@ static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handl
824 } 789 }
825} 790}
826 791
827static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * parent, 792static void acpi_device_set_id(struct acpi_device *device,
828 acpi_handle handle, int type) 793 struct acpi_device *parent, acpi_handle handle,
794 int type)
829{ 795{
830 struct acpi_device_info *info; 796 struct acpi_device_info *info;
831 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 797 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
832 char *hid = NULL; 798 char *hid = NULL;
833 char *uid = NULL; 799 char *uid = NULL;
834 struct acpi_compatible_id_list *cid_list = NULL; 800 struct acpi_compatible_id_list *cid_list = NULL;
835 acpi_status status; 801 acpi_status status;
836 802
837 switch (type) { 803 switch (type) {
838 case ACPI_BUS_TYPE_DEVICE: 804 case ACPI_BUS_TYPE_DEVICE:
839 status = acpi_get_object_info(handle, &buffer); 805 status = acpi_get_object_info(handle, &buffer);
840 if (ACPI_FAILURE(status)) { 806 if (ACPI_FAILURE(status)) {
841 printk("%s: Error reading device info\n",__FUNCTION__); 807 printk("%s: Error reading device info\n", __FUNCTION__);
842 return; 808 return;
843 } 809 }
844 810
@@ -904,7 +870,7 @@ static void acpi_device_set_id(struct acpi_device * device, struct acpi_device *
904 acpi_os_free(buffer.pointer); 870 acpi_os_free(buffer.pointer);
905} 871}
906 872
907static int acpi_device_set_context(struct acpi_device * device, int type) 873static int acpi_device_set_context(struct acpi_device *device, int type)
908{ 874{
909 acpi_status status = AE_OK; 875 acpi_status status = AE_OK;
910 int result = 0; 876 int result = 0;
@@ -916,10 +882,10 @@ static int acpi_device_set_context(struct acpi_device * device, int type)
916 * to be careful with fixed-feature devices as they all attach to the 882 * to be careful with fixed-feature devices as they all attach to the
917 * root object. 883 * root object.
918 */ 884 */
919 if (type != ACPI_BUS_TYPE_POWER_BUTTON && 885 if (type != ACPI_BUS_TYPE_POWER_BUTTON &&
920 type != ACPI_BUS_TYPE_SLEEP_BUTTON) { 886 type != ACPI_BUS_TYPE_SLEEP_BUTTON) {
921 status = acpi_attach_data(device->handle, 887 status = acpi_attach_data(device->handle,
922 acpi_bus_data_handler, device); 888 acpi_bus_data_handler, device);
923 889
924 if (ACPI_FAILURE(status)) { 890 if (ACPI_FAILURE(status)) {
925 printk("Error attaching device data\n"); 891 printk("Error attaching device data\n");
@@ -929,12 +895,13 @@ static int acpi_device_set_context(struct acpi_device * device, int type)
929 return result; 895 return result;
930} 896}
931 897
932static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle, int type) 898static void acpi_device_get_debug_info(struct acpi_device *device,
899 acpi_handle handle, int type)
933{ 900{
934#ifdef CONFIG_ACPI_DEBUG_OUTPUT 901#ifdef CONFIG_ACPI_DEBUG_OUTPUT
935 char *type_string = NULL; 902 char *type_string = NULL;
936 char name[80] = {'?','\0'}; 903 char name[80] = { '?', '\0' };
937 struct acpi_buffer buffer = {sizeof(name), name}; 904 struct acpi_buffer buffer = { sizeof(name), name };
938 905
939 switch (type) { 906 switch (type) {
940 case ACPI_BUS_TYPE_DEVICE: 907 case ACPI_BUS_TYPE_DEVICE:
@@ -968,18 +935,14 @@ static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle
968 } 935 }
969 936
970 printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle); 937 printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle);
971#endif /*CONFIG_ACPI_DEBUG_OUTPUT*/ 938#endif /*CONFIG_ACPI_DEBUG_OUTPUT */
972} 939}
973 940
974 941static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
975static int
976acpi_bus_remove (
977 struct acpi_device *dev,
978 int rmdevice)
979{ 942{
980 int result = 0; 943 int result = 0;
981 struct acpi_driver *driver; 944 struct acpi_driver *driver;
982 945
983 ACPI_FUNCTION_TRACE("acpi_bus_remove"); 946 ACPI_FUNCTION_TRACE("acpi_bus_remove");
984 947
985 if (!dev) 948 if (!dev)
@@ -1012,22 +975,18 @@ acpi_bus_remove (
1012 if ((dev->parent) && (dev->parent->ops.unbind)) 975 if ((dev->parent) && (dev->parent->ops.unbind))
1013 dev->parent->ops.unbind(dev); 976 dev->parent->ops.unbind(dev);
1014 } 977 }
1015 978
1016 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 979 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
1017 980
1018 return_VALUE(0); 981 return_VALUE(0);
1019} 982}
1020 983
1021
1022static int 984static int
1023acpi_add_single_object ( 985acpi_add_single_object(struct acpi_device **child,
1024 struct acpi_device **child, 986 struct acpi_device *parent, acpi_handle handle, int type)
1025 struct acpi_device *parent,
1026 acpi_handle handle,
1027 int type)
1028{ 987{
1029 int result = 0; 988 int result = 0;
1030 struct acpi_device *device = NULL; 989 struct acpi_device *device = NULL;
1031 990
1032 ACPI_FUNCTION_TRACE("acpi_add_single_object"); 991 ACPI_FUNCTION_TRACE("acpi_add_single_object");
1033 992
@@ -1044,7 +1003,7 @@ acpi_add_single_object (
1044 device->handle = handle; 1003 device->handle = handle;
1045 device->parent = parent; 1004 device->parent = parent;
1046 1005
1047 acpi_device_get_busid(device,handle,type); 1006 acpi_device_get_busid(device, handle, type);
1048 1007
1049 /* 1008 /*
1050 * Flags 1009 * Flags
@@ -1092,7 +1051,7 @@ acpi_add_single_object (
1092 * Hardware ID, Unique ID, & Bus Address 1051 * Hardware ID, Unique ID, & Bus Address
1093 * ------------------------------------- 1052 * -------------------------------------
1094 */ 1053 */
1095 acpi_device_set_id(device,parent,handle,type); 1054 acpi_device_set_id(device, parent, handle, type);
1096 1055
1097 /* 1056 /*
1098 * Power Management 1057 * Power Management
@@ -1104,7 +1063,7 @@ acpi_add_single_object (
1104 goto end; 1063 goto end;
1105 } 1064 }
1106 1065
1107 /* 1066 /*
1108 * Wakeup device management 1067 * Wakeup device management
1109 *----------------------- 1068 *-----------------------
1110 */ 1069 */
@@ -1124,12 +1083,12 @@ acpi_add_single_object (
1124 goto end; 1083 goto end;
1125 } 1084 }
1126 1085
1127 if ((result = acpi_device_set_context(device,type))) 1086 if ((result = acpi_device_set_context(device, type)))
1128 goto end; 1087 goto end;
1129 1088
1130 acpi_device_get_debug_info(device,handle,type); 1089 acpi_device_get_debug_info(device, handle, type);
1131 1090
1132 acpi_device_register(device,parent); 1091 acpi_device_register(device, parent);
1133 1092
1134 /* 1093 /*
1135 * Bind _ADR-Based Devices 1094 * Bind _ADR-Based Devices
@@ -1154,7 +1113,7 @@ acpi_add_single_object (
1154 */ 1113 */
1155 result = acpi_bus_find_driver(device); 1114 result = acpi_bus_find_driver(device);
1156 1115
1157end: 1116 end:
1158 if (!result) 1117 if (!result)
1159 *child = device; 1118 *child = device;
1160 else { 1119 else {
@@ -1166,17 +1125,15 @@ end:
1166 return_VALUE(result); 1125 return_VALUE(result);
1167} 1126}
1168 1127
1169 1128static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1170static int acpi_bus_scan (struct acpi_device *start,
1171 struct acpi_bus_ops *ops)
1172{ 1129{
1173 acpi_status status = AE_OK; 1130 acpi_status status = AE_OK;
1174 struct acpi_device *parent = NULL; 1131 struct acpi_device *parent = NULL;
1175 struct acpi_device *child = NULL; 1132 struct acpi_device *child = NULL;
1176 acpi_handle phandle = NULL; 1133 acpi_handle phandle = NULL;
1177 acpi_handle chandle = NULL; 1134 acpi_handle chandle = NULL;
1178 acpi_object_type type = 0; 1135 acpi_object_type type = 0;
1179 u32 level = 1; 1136 u32 level = 1;
1180 1137
1181 ACPI_FUNCTION_TRACE("acpi_bus_scan"); 1138 ACPI_FUNCTION_TRACE("acpi_bus_scan");
1182 1139
@@ -1185,7 +1142,7 @@ static int acpi_bus_scan (struct acpi_device *start,
1185 1142
1186 parent = start; 1143 parent = start;
1187 phandle = start->handle; 1144 phandle = start->handle;
1188 1145
1189 /* 1146 /*
1190 * Parse through the ACPI namespace, identify all 'devices', and 1147 * Parse through the ACPI namespace, identify all 'devices', and
1191 * create a new 'struct acpi_device' for each. 1148 * create a new 'struct acpi_device' for each.
@@ -1193,7 +1150,7 @@ static int acpi_bus_scan (struct acpi_device *start,
1193 while ((level > 0) && parent) { 1150 while ((level > 0) && parent) {
1194 1151
1195 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1152 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
1196 chandle, &chandle); 1153 chandle, &chandle);
1197 1154
1198 /* 1155 /*
1199 * If this scope is exhausted then move our way back up. 1156 * If this scope is exhausted then move our way back up.
@@ -1243,12 +1200,12 @@ static int acpi_bus_scan (struct acpi_device *start,
1243 1200
1244 if (ops->acpi_op_add) 1201 if (ops->acpi_op_add)
1245 status = acpi_add_single_object(&child, parent, 1202 status = acpi_add_single_object(&child, parent,
1246 chandle, type); 1203 chandle, type);
1247 else 1204 else
1248 status = acpi_bus_get_device(chandle, &child); 1205 status = acpi_bus_get_device(chandle, &child);
1249 1206
1250 if (ACPI_FAILURE(status)) 1207 if (ACPI_FAILURE(status))
1251 continue; 1208 continue;
1252 1209
1253 if (ops->acpi_op_start) { 1210 if (ops->acpi_op_start) {
1254 status = acpi_start_single_object(child); 1211 status = acpi_start_single_object(child);
@@ -1264,7 +1221,7 @@ static int acpi_bus_scan (struct acpi_device *start,
1264 * which will be enumerated when the parent is inserted). 1221 * which will be enumerated when the parent is inserted).
1265 * 1222 *
1266 * TBD: Need notifications and other detection mechanisms 1223 * TBD: Need notifications and other detection mechanisms
1267 * in place before we can fully implement this. 1224 * in place before we can fully implement this.
1268 */ 1225 */
1269 if (child->status.present) { 1226 if (child->status.present) {
1270 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, 1227 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
@@ -1282,11 +1239,8 @@ static int acpi_bus_scan (struct acpi_device *start,
1282} 1239}
1283 1240
1284int 1241int
1285acpi_bus_add ( 1242acpi_bus_add(struct acpi_device **child,
1286 struct acpi_device **child, 1243 struct acpi_device *parent, acpi_handle handle, int type)
1287 struct acpi_device *parent,
1288 acpi_handle handle,
1289 int type)
1290{ 1244{
1291 int result; 1245 int result;
1292 struct acpi_bus_ops ops; 1246 struct acpi_bus_ops ops;
@@ -1301,11 +1255,10 @@ acpi_bus_add (
1301 } 1255 }
1302 return_VALUE(result); 1256 return_VALUE(result);
1303} 1257}
1258
1304EXPORT_SYMBOL(acpi_bus_add); 1259EXPORT_SYMBOL(acpi_bus_add);
1305 1260
1306int 1261int acpi_bus_start(struct acpi_device *device)
1307acpi_bus_start (
1308 struct acpi_device *device)
1309{ 1262{
1310 int result; 1263 int result;
1311 struct acpi_bus_ops ops; 1264 struct acpi_bus_ops ops;
@@ -1323,26 +1276,25 @@ acpi_bus_start (
1323 } 1276 }
1324 return_VALUE(result); 1277 return_VALUE(result);
1325} 1278}
1279
1326EXPORT_SYMBOL(acpi_bus_start); 1280EXPORT_SYMBOL(acpi_bus_start);
1327 1281
1328static int 1282static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
1329acpi_bus_trim(struct acpi_device *start,
1330 int rmdevice)
1331{ 1283{
1332 acpi_status status; 1284 acpi_status status;
1333 struct acpi_device *parent, *child; 1285 struct acpi_device *parent, *child;
1334 acpi_handle phandle, chandle; 1286 acpi_handle phandle, chandle;
1335 acpi_object_type type; 1287 acpi_object_type type;
1336 u32 level = 1; 1288 u32 level = 1;
1337 int err = 0; 1289 int err = 0;
1338 1290
1339 parent = start; 1291 parent = start;
1340 phandle = start->handle; 1292 phandle = start->handle;
1341 child = chandle = NULL; 1293 child = chandle = NULL;
1342 1294
1343 while ((level > 0) && parent && (!err)) { 1295 while ((level > 0) && parent && (!err)) {
1344 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1296 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
1345 chandle, &chandle); 1297 chandle, &chandle);
1346 1298
1347 /* 1299 /*
1348 * If this scope is exhausted then move our way back up. 1300 * If this scope is exhausted then move our way back up.
@@ -1381,12 +1333,10 @@ acpi_bus_trim(struct acpi_device *start,
1381 return err; 1333 return err;
1382} 1334}
1383 1335
1384static int 1336static int acpi_bus_scan_fixed(struct acpi_device *root)
1385acpi_bus_scan_fixed (
1386 struct acpi_device *root)
1387{ 1337{
1388 int result = 0; 1338 int result = 0;
1389 struct acpi_device *device = NULL; 1339 struct acpi_device *device = NULL;
1390 1340
1391 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed"); 1341 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
1392 1342
@@ -1398,14 +1348,16 @@ acpi_bus_scan_fixed (
1398 */ 1348 */
1399 if (acpi_fadt.pwr_button == 0) { 1349 if (acpi_fadt.pwr_button == 0) {
1400 result = acpi_add_single_object(&device, acpi_root, 1350 result = acpi_add_single_object(&device, acpi_root,
1401 NULL, ACPI_BUS_TYPE_POWER_BUTTON); 1351 NULL,
1352 ACPI_BUS_TYPE_POWER_BUTTON);
1402 if (!result) 1353 if (!result)
1403 result = acpi_start_single_object(device); 1354 result = acpi_start_single_object(device);
1404 } 1355 }
1405 1356
1406 if (acpi_fadt.sleep_button == 0) { 1357 if (acpi_fadt.sleep_button == 0) {
1407 result = acpi_add_single_object(&device, acpi_root, 1358 result = acpi_add_single_object(&device, acpi_root,
1408 NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); 1359 NULL,
1360 ACPI_BUS_TYPE_SLEEP_BUTTON);
1409 if (!result) 1361 if (!result)
1410 result = acpi_start_single_object(device); 1362 result = acpi_start_single_object(device);
1411 } 1363 }
@@ -1413,7 +1365,6 @@ acpi_bus_scan_fixed (
1413 return_VALUE(result); 1365 return_VALUE(result);
1414} 1366}
1415 1367
1416
1417static int __init acpi_scan_init(void) 1368static int __init acpi_scan_init(void)
1418{ 1369{
1419 int result; 1370 int result;
@@ -1430,7 +1381,7 @@ static int __init acpi_scan_init(void)
1430 * Create the root device in the bus's device tree 1381 * Create the root device in the bus's device tree
1431 */ 1382 */
1432 result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, 1383 result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT,
1433 ACPI_BUS_TYPE_SYSTEM); 1384 ACPI_BUS_TYPE_SYSTEM);
1434 if (result) 1385 if (result)
1435 goto Done; 1386 goto Done;
1436 1387
@@ -1450,7 +1401,7 @@ static int __init acpi_scan_init(void)
1450 if (result) 1401 if (result)
1451 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1402 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1452 1403
1453 Done: 1404 Done:
1454 return_VALUE(result); 1405 return_VALUE(result);
1455} 1406}
1456 1407
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index f93d2ee54800..a5f947de879b 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -95,4 +95,4 @@ static int acpi_poweroff_init(void)
95 95
96late_initcall(acpi_poweroff_init); 96late_initcall(acpi_poweroff_init);
97 97
98#endif /* CONFIG_PM */ 98#endif /* CONFIG_PM */
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 1be99f0996d6..09a603f3523e 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -13,27 +13,18 @@
13 13
14#include "sleep.h" 14#include "sleep.h"
15 15
16#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
17#define ACPI_SYSTEM_FILE_SLEEP "sleep"
18#endif
19
20#define ACPI_SYSTEM_FILE_ALARM "alarm"
21#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup"
22
23#define _COMPONENT ACPI_SYSTEM_COMPONENT 16#define _COMPONENT ACPI_SYSTEM_COMPONENT
24ACPI_MODULE_NAME ("sleep") 17ACPI_MODULE_NAME("sleep")
25
26#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 18#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
27
28static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) 19static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
29{ 20{
30 int i; 21 int i;
31 22
32 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show"); 23 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
33 24
34 for (i = 0; i <= ACPI_STATE_S5; i++) { 25 for (i = 0; i <= ACPI_STATE_S5; i++) {
35 if (sleep_states[i]) { 26 if (sleep_states[i]) {
36 seq_printf(seq,"S%d ", i); 27 seq_printf(seq, "S%d ", i);
37 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) 28 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f)
38 seq_printf(seq, "S4bios "); 29 seq_printf(seq, "S4bios ");
39 } 30 }
@@ -50,24 +41,21 @@ static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file)
50} 41}
51 42
52static ssize_t 43static ssize_t
53acpi_system_write_sleep ( 44acpi_system_write_sleep(struct file *file,
54 struct file *file, 45 const char __user * buffer, size_t count, loff_t * ppos)
55 const char __user *buffer,
56 size_t count,
57 loff_t *ppos)
58{ 46{
59 char str[12]; 47 char str[12];
60 u32 state = 0; 48 u32 state = 0;
61 int error = 0; 49 int error = 0;
62 50
63 if (count > sizeof(str) - 1) 51 if (count > sizeof(str) - 1)
64 goto Done; 52 goto Done;
65 memset(str,0,sizeof(str)); 53 memset(str, 0, sizeof(str));
66 if (copy_from_user(str, buffer, count)) 54 if (copy_from_user(str, buffer, count))
67 return -EFAULT; 55 return -EFAULT;
68 56
69 /* Check for S4 bios request */ 57 /* Check for S4 bios request */
70 if (!strcmp(str,"4b")) { 58 if (!strcmp(str, "4b")) {
71 error = acpi_suspend(4); 59 error = acpi_suspend(4);
72 goto Done; 60 goto Done;
73 } 61 }
@@ -79,17 +67,17 @@ acpi_system_write_sleep (
79 } 67 }
80#endif 68#endif
81 error = acpi_suspend(state); 69 error = acpi_suspend(state);
82 Done: 70 Done:
83 return error ? error : count; 71 return error ? error : count;
84} 72}
85#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 73#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
86 74
87static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) 75static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
88{ 76{
89 u32 sec, min, hr; 77 u32 sec, min, hr;
90 u32 day, mo, yr; 78 u32 day, mo, yr;
91 unsigned char rtc_control = 0; 79 unsigned char rtc_control = 0;
92 unsigned long flags; 80 unsigned long flags;
93 81
94 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show"); 82 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
95 83
@@ -105,13 +93,14 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
105 /* ACPI spec: only low 6 its should be cared */ 93 /* ACPI spec: only low 6 its should be cared */
106 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F; 94 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F;
107 else 95 else
108 day = CMOS_READ(RTC_DAY_OF_MONTH); 96 day = CMOS_READ(RTC_DAY_OF_MONTH);
109 if (acpi_gbl_FADT->mon_alrm) 97 if (acpi_gbl_FADT->mon_alrm)
110 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm); 98 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
111 else 99 else
112 mo = CMOS_READ(RTC_MONTH); 100 mo = CMOS_READ(RTC_MONTH);
113 if (acpi_gbl_FADT->century) 101 if (acpi_gbl_FADT->century)
114 yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR); 102 yr = CMOS_READ(acpi_gbl_FADT->century) * 100 +
103 CMOS_READ(RTC_YEAR);
115 else 104 else
116 yr = CMOS_READ(RTC_YEAR); 105 yr = CMOS_READ(RTC_YEAR);
117 106
@@ -126,33 +115,33 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
126 BCD_TO_BIN(yr); 115 BCD_TO_BIN(yr);
127 } 116 }
128 117
129 /* we're trusting the FADT (see above)*/ 118 /* we're trusting the FADT (see above) */
130 if (!acpi_gbl_FADT->century) 119 if (!acpi_gbl_FADT->century)
131 /* If we're not trusting the FADT, we should at least make it 120 /* If we're not trusting the FADT, we should at least make it
132 * right for _this_ century... ehm, what is _this_ century? 121 * right for _this_ century... ehm, what is _this_ century?
133 * 122 *
134 * TBD: 123 * TBD:
135 * ASAP: find piece of code in the kernel, e.g. star tracker driver, 124 * ASAP: find piece of code in the kernel, e.g. star tracker driver,
136 * which we can trust to determine the century correctly. Atom 125 * which we can trust to determine the century correctly. Atom
137 * watch driver would be nice, too... 126 * watch driver would be nice, too...
138 * 127 *
139 * if that has not happened, change for first release in 2050: 128 * if that has not happened, change for first release in 2050:
140 * if (yr<50) 129 * if (yr<50)
141 * yr += 2100; 130 * yr += 2100;
142 * else 131 * else
143 * yr += 2000; // current line of code 132 * yr += 2000; // current line of code
144 * 133 *
145 * if that has not happened either, please do on 2099/12/31:23:59:59 134 * if that has not happened either, please do on 2099/12/31:23:59:59
146 * s/2000/2100 135 * s/2000/2100
147 * 136 *
148 */ 137 */
149 yr += 2000; 138 yr += 2000;
150 139
151 seq_printf(seq,"%4.4u-", yr); 140 seq_printf(seq, "%4.4u-", yr);
152 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 141 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
153 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 142 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
154 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); 143 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
155 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); 144 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
156 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec); 145 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
157 146
158 return 0; 147 return 0;
@@ -163,15 +152,11 @@ static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
163 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data); 152 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
164} 153}
165 154
166 155static int get_date_field(char **p, u32 * value)
167static int
168get_date_field (
169 char **p,
170 u32 *value)
171{ 156{
172 char *next = NULL; 157 char *next = NULL;
173 char *string_end = NULL; 158 char *string_end = NULL;
174 int result = -EINVAL; 159 int result = -EINVAL;
175 160
176 /* 161 /*
177 * Try to find delimeter, only to insert null. The end of the 162 * Try to find delimeter, only to insert null. The end of the
@@ -193,26 +178,22 @@ get_date_field (
193 return result; 178 return result;
194} 179}
195 180
196
197static ssize_t 181static ssize_t
198acpi_system_write_alarm ( 182acpi_system_write_alarm(struct file *file,
199 struct file *file, 183 const char __user * buffer, size_t count, loff_t * ppos)
200 const char __user *buffer,
201 size_t count,
202 loff_t *ppos)
203{ 184{
204 int result = 0; 185 int result = 0;
205 char alarm_string[30] = {'\0'}; 186 char alarm_string[30] = { '\0' };
206 char *p = alarm_string; 187 char *p = alarm_string;
207 u32 sec, min, hr, day, mo, yr; 188 u32 sec, min, hr, day, mo, yr;
208 int adjust = 0; 189 int adjust = 0;
209 unsigned char rtc_control = 0; 190 unsigned char rtc_control = 0;
210 191
211 ACPI_FUNCTION_TRACE("acpi_system_write_alarm"); 192 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
212 193
213 if (count > sizeof(alarm_string) - 1) 194 if (count > sizeof(alarm_string) - 1)
214 return_VALUE(-EINVAL); 195 return_VALUE(-EINVAL);
215 196
216 if (copy_from_user(alarm_string, buffer, count)) 197 if (copy_from_user(alarm_string, buffer, count))
217 return_VALUE(-EFAULT); 198 return_VALUE(-EFAULT);
218 199
@@ -271,10 +252,10 @@ acpi_system_write_alarm (
271 } 252 }
272 253
273 if (adjust) { 254 if (adjust) {
274 yr += CMOS_READ(RTC_YEAR); 255 yr += CMOS_READ(RTC_YEAR);
275 mo += CMOS_READ(RTC_MONTH); 256 mo += CMOS_READ(RTC_MONTH);
276 day += CMOS_READ(RTC_DAY_OF_MONTH); 257 day += CMOS_READ(RTC_DAY_OF_MONTH);
277 hr += CMOS_READ(RTC_HOURS); 258 hr += CMOS_READ(RTC_HOURS);
278 min += CMOS_READ(RTC_MINUTES); 259 min += CMOS_READ(RTC_MINUTES);
279 sec += CMOS_READ(RTC_SECONDS); 260 sec += CMOS_READ(RTC_SECONDS);
280 } 261 }
@@ -343,7 +324,7 @@ acpi_system_write_alarm (
343 if (acpi_gbl_FADT->mon_alrm) 324 if (acpi_gbl_FADT->mon_alrm)
344 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm); 325 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm);
345 if (acpi_gbl_FADT->century) 326 if (acpi_gbl_FADT->century)
346 CMOS_WRITE(yr/100, acpi_gbl_FADT->century); 327 CMOS_WRITE(yr / 100, acpi_gbl_FADT->century);
347 /* enable the rtc alarm interrupt */ 328 /* enable the rtc alarm interrupt */
348 rtc_control |= RTC_AIE; 329 rtc_control |= RTC_AIE;
349 CMOS_WRITE(rtc_control, RTC_CONTROL); 330 CMOS_WRITE(rtc_control, RTC_CONTROL);
@@ -357,35 +338,33 @@ acpi_system_write_alarm (
357 *ppos += count; 338 *ppos += count;
358 339
359 result = 0; 340 result = 0;
360end: 341 end:
361 return_VALUE(result ? result : count); 342 return_VALUE(result ? result : count);
362} 343}
363 344
364extern struct list_head acpi_wakeup_device_list; 345extern struct list_head acpi_wakeup_device_list;
365extern spinlock_t acpi_device_lock; 346extern spinlock_t acpi_device_lock;
366 347
367static int 348static int
368acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) 349acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
369{ 350{
370 struct list_head * node, * next; 351 struct list_head *node, *next;
371 352
372 seq_printf(seq, "Device Sleep state Status\n"); 353 seq_printf(seq, "Device Sleep state Status\n");
373 354
374 spin_lock(&acpi_device_lock); 355 spin_lock(&acpi_device_lock);
375 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 356 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
376 struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); 357 struct acpi_device *dev =
358 container_of(node, struct acpi_device, wakeup_list);
377 359
378 if (!dev->wakeup.flags.valid) 360 if (!dev->wakeup.flags.valid)
379 continue; 361 continue;
380 spin_unlock(&acpi_device_lock); 362 spin_unlock(&acpi_device_lock);
381 if (dev->wakeup.flags.run_wake) 363 seq_printf(seq, "%4s %4d %s%8s\n",
382 seq_printf(seq, "%4s %4d %8s\n", 364 dev->pnp.bus_id,
383 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, 365 (u32) dev->wakeup.sleep_state,
384 dev->wakeup.state.enabled ? "*enabled" : "*disabled"); 366 dev->wakeup.flags.run_wake ? "*" : "",
385 else 367 dev->wakeup.state.enabled ? "enabled" : "disabled");
386 seq_printf(seq, "%4s %4d %8s\n",
387 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state,
388 dev->wakeup.state.enabled ? "enabled" : "disabled");
389 spin_lock(&acpi_device_lock); 368 spin_lock(&acpi_device_lock);
390 } 369 }
391 spin_unlock(&acpi_device_lock); 370 spin_unlock(&acpi_device_lock);
@@ -393,19 +372,18 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
393} 372}
394 373
395static ssize_t 374static ssize_t
396acpi_system_write_wakeup_device ( 375acpi_system_write_wakeup_device(struct file *file,
397 struct file *file, 376 const char __user * buffer,
398 const char __user *buffer, 377 size_t count, loff_t * ppos)
399 size_t count,
400 loff_t *ppos)
401{ 378{
402 struct list_head * node, * next; 379 struct list_head *node, *next;
403 char strbuf[5]; 380 char strbuf[5];
404 char str[5] = ""; 381 char str[5] = "";
405 int len = count; 382 int len = count;
406 struct acpi_device *found_dev = NULL; 383 struct acpi_device *found_dev = NULL;
407 384
408 if (len > 4) len = 4; 385 if (len > 4)
386 len = 4;
409 387
410 if (copy_from_user(strbuf, buffer, len)) 388 if (copy_from_user(strbuf, buffer, len))
411 return -EFAULT; 389 return -EFAULT;
@@ -414,28 +392,36 @@ acpi_system_write_wakeup_device (
414 392
415 spin_lock(&acpi_device_lock); 393 spin_lock(&acpi_device_lock);
416 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 394 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
417 struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); 395 struct acpi_device *dev =
396 container_of(node, struct acpi_device, wakeup_list);
418 if (!dev->wakeup.flags.valid) 397 if (!dev->wakeup.flags.valid)
419 continue; 398 continue;
420 399
421 if (!strncmp(dev->pnp.bus_id, str, 4)) { 400 if (!strncmp(dev->pnp.bus_id, str, 4)) {
422 dev->wakeup.state.enabled = dev->wakeup.state.enabled ? 0:1; 401 dev->wakeup.state.enabled =
402 dev->wakeup.state.enabled ? 0 : 1;
423 found_dev = dev; 403 found_dev = dev;
424 break; 404 break;
425 } 405 }
426 } 406 }
427 if (found_dev) { 407 if (found_dev) {
428 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 408 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
429 struct acpi_device * dev = container_of(node, 409 struct acpi_device *dev = container_of(node,
430 struct acpi_device, wakeup_list); 410 struct
411 acpi_device,
412 wakeup_list);
431 413
432 if ((dev != found_dev) && 414 if ((dev != found_dev) &&
433 (dev->wakeup.gpe_number == found_dev->wakeup.gpe_number) && 415 (dev->wakeup.gpe_number ==
434 (dev->wakeup.gpe_device == found_dev->wakeup.gpe_device)) { 416 found_dev->wakeup.gpe_number)
435 printk(KERN_WARNING "ACPI: '%s' and '%s' have the same GPE, " 417 && (dev->wakeup.gpe_device ==
436 "can't disable/enable one seperately\n", 418 found_dev->wakeup.gpe_device)) {
437 dev->pnp.bus_id, found_dev->pnp.bus_id); 419 printk(KERN_WARNING
438 dev->wakeup.state.enabled = found_dev->wakeup.state.enabled; 420 "ACPI: '%s' and '%s' have the same GPE, "
421 "can't disable/enable one seperately\n",
422 dev->pnp.bus_id, found_dev->pnp.bus_id);
423 dev->wakeup.state.enabled =
424 found_dev->wakeup.state.enabled;
439 } 425 }
440 } 426 }
441 } 427 }
@@ -446,37 +432,37 @@ acpi_system_write_wakeup_device (
446static int 432static int
447acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) 433acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
448{ 434{
449 return single_open(file, acpi_system_wakeup_device_seq_show, PDE(inode)->data); 435 return single_open(file, acpi_system_wakeup_device_seq_show,
436 PDE(inode)->data);
450} 437}
451 438
452static struct file_operations acpi_system_wakeup_device_fops = { 439static struct file_operations acpi_system_wakeup_device_fops = {
453 .open = acpi_system_wakeup_device_open_fs, 440 .open = acpi_system_wakeup_device_open_fs,
454 .read = seq_read, 441 .read = seq_read,
455 .write = acpi_system_write_wakeup_device, 442 .write = acpi_system_write_wakeup_device,
456 .llseek = seq_lseek, 443 .llseek = seq_lseek,
457 .release = single_release, 444 .release = single_release,
458}; 445};
459 446
460#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 447#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
461static struct file_operations acpi_system_sleep_fops = { 448static struct file_operations acpi_system_sleep_fops = {
462 .open = acpi_system_sleep_open_fs, 449 .open = acpi_system_sleep_open_fs,
463 .read = seq_read, 450 .read = seq_read,
464 .write = acpi_system_write_sleep, 451 .write = acpi_system_write_sleep,
465 .llseek = seq_lseek, 452 .llseek = seq_lseek,
466 .release = single_release, 453 .release = single_release,
467}; 454};
468#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 455#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
469 456
470static struct file_operations acpi_system_alarm_fops = { 457static struct file_operations acpi_system_alarm_fops = {
471 .open = acpi_system_alarm_open_fs, 458 .open = acpi_system_alarm_open_fs,
472 .read = seq_read, 459 .read = seq_read,
473 .write = acpi_system_write_alarm, 460 .write = acpi_system_write_alarm,
474 .llseek = seq_lseek, 461 .llseek = seq_lseek,
475 .release = single_release, 462 .release = single_release,
476}; 463};
477 464
478 465static u32 rtc_handler(void *context)
479static u32 rtc_handler(void * context)
480{ 466{
481 acpi_clear_event(ACPI_EVENT_RTC); 467 acpi_clear_event(ACPI_EVENT_RTC);
482 acpi_disable_event(ACPI_EVENT_RTC, 0); 468 acpi_disable_event(ACPI_EVENT_RTC, 0);
@@ -486,28 +472,31 @@ static u32 rtc_handler(void * context)
486 472
487static int acpi_sleep_proc_init(void) 473static int acpi_sleep_proc_init(void)
488{ 474{
489 struct proc_dir_entry *entry = NULL; 475 struct proc_dir_entry *entry = NULL;
490 476
491 if (acpi_disabled) 477 if (acpi_disabled)
492 return 0; 478 return 0;
493 479
494#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 480#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
495 /* 'sleep' [R/W]*/ 481 /* 'sleep' [R/W] */
496 entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, 482 entry =
497 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 483 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
484 acpi_root_dir);
498 if (entry) 485 if (entry)
499 entry->proc_fops = &acpi_system_sleep_fops; 486 entry->proc_fops = &acpi_system_sleep_fops;
500#endif 487#endif
501 488
502 /* 'alarm' [R/W] */ 489 /* 'alarm' [R/W] */
503 entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, 490 entry =
504 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 491 create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
492 acpi_root_dir);
505 if (entry) 493 if (entry)
506 entry->proc_fops = &acpi_system_alarm_fops; 494 entry->proc_fops = &acpi_system_alarm_fops;
507 495
508 /* 'wakeup device' [R/W]*/ 496 /* 'wakeup device' [R/W] */
509 entry = create_proc_entry(ACPI_SYSTEM_FILE_WAKEUP_DEVICE, 497 entry =
510 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 498 create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
499 acpi_root_dir);
511 if (entry) 500 if (entry)
512 entry->proc_fops = &acpi_system_wakeup_device_fops; 501 entry->proc_fops = &acpi_system_wakeup_device_fops;
513 502
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index d9b199969d5d..4134ed43d026 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -12,9 +12,9 @@
12#include "sleep.h" 12#include "sleep.h"
13 13
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 14#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME ("wakeup_devices") 15ACPI_MODULE_NAME("wakeup_devices")
16 16
17extern struct list_head acpi_wakeup_device_list; 17extern struct list_head acpi_wakeup_device_list;
18extern spinlock_t acpi_device_lock; 18extern spinlock_t acpi_device_lock;
19 19
20#ifdef CONFIG_ACPI_SLEEP 20#ifdef CONFIG_ACPI_SLEEP
@@ -25,22 +25,21 @@ extern spinlock_t acpi_device_lock;
25 * is higher than requested sleep level 25 * is higher than requested sleep level
26 */ 26 */
27 27
28void 28void acpi_enable_wakeup_device_prep(u8 sleep_state)
29acpi_enable_wakeup_device_prep(
30 u8 sleep_state)
31{ 29{
32 struct list_head * node, * next; 30 struct list_head *node, *next;
33 31
34 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep"); 32 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep");
35 33
36 spin_lock(&acpi_device_lock); 34 spin_lock(&acpi_device_lock);
37 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
38 struct acpi_device * dev = container_of(node, 36 struct acpi_device *dev = container_of(node,
39 struct acpi_device, wakeup_list); 37 struct acpi_device,
40 38 wakeup_list);
41 if (!dev->wakeup.flags.valid || 39
42 !dev->wakeup.state.enabled || 40 if (!dev->wakeup.flags.valid ||
43 (sleep_state > (u32) dev->wakeup.sleep_state)) 41 !dev->wakeup.state.enabled ||
42 (sleep_state > (u32) dev->wakeup.sleep_state))
44 continue; 43 continue;
45 44
46 spin_unlock(&acpi_device_lock); 45 spin_unlock(&acpi_device_lock);
@@ -55,11 +54,9 @@ acpi_enable_wakeup_device_prep(
55 * @sleep_state: ACPI state 54 * @sleep_state: ACPI state
56 * Enable all wakup devices's GPE 55 * Enable all wakup devices's GPE
57 */ 56 */
58void 57void acpi_enable_wakeup_device(u8 sleep_state)
59acpi_enable_wakeup_device(
60 u8 sleep_state)
61{ 58{
62 struct list_head * node, * next; 59 struct list_head *node, *next;
63 60
64 /* 61 /*
65 * Caution: this routine must be invoked when interrupt is disabled 62 * Caution: this routine must be invoked when interrupt is disabled
@@ -68,33 +65,35 @@ acpi_enable_wakeup_device(
68 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); 65 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
69 spin_lock(&acpi_device_lock); 66 spin_lock(&acpi_device_lock);
70 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 67 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
71 struct acpi_device * dev = container_of(node, 68 struct acpi_device *dev = container_of(node,
72 struct acpi_device, wakeup_list); 69 struct acpi_device,
70 wakeup_list);
73 71
74 /* If users want to disable run-wake GPE, 72 /* If users want to disable run-wake GPE,
75 * we only disable it for wake and leave it for runtime 73 * we only disable it for wake and leave it for runtime
76 */ 74 */
77 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 75 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
78 spin_unlock(&acpi_device_lock); 76 spin_unlock(&acpi_device_lock);
79 acpi_set_gpe_type(dev->wakeup.gpe_device, 77 acpi_set_gpe_type(dev->wakeup.gpe_device,
80 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 78 dev->wakeup.gpe_number,
79 ACPI_GPE_TYPE_RUNTIME);
81 /* Re-enable it, since set_gpe_type will disable it */ 80 /* Re-enable it, since set_gpe_type will disable it */
82 acpi_enable_gpe(dev->wakeup.gpe_device, 81 acpi_enable_gpe(dev->wakeup.gpe_device,
83 dev->wakeup.gpe_number, ACPI_ISR); 82 dev->wakeup.gpe_number, ACPI_ISR);
84 spin_lock(&acpi_device_lock); 83 spin_lock(&acpi_device_lock);
85 continue; 84 continue;
86 } 85 }
87 86
88 if (!dev->wakeup.flags.valid || 87 if (!dev->wakeup.flags.valid ||
89 !dev->wakeup.state.enabled || 88 !dev->wakeup.state.enabled ||
90 (sleep_state > (u32) dev->wakeup.sleep_state)) 89 (sleep_state > (u32) dev->wakeup.sleep_state))
91 continue; 90 continue;
92 91
93 spin_unlock(&acpi_device_lock); 92 spin_unlock(&acpi_device_lock);
94 /* run-wake GPE has been enabled */ 93 /* run-wake GPE has been enabled */
95 if (!dev->wakeup.flags.run_wake) 94 if (!dev->wakeup.flags.run_wake)
96 acpi_enable_gpe(dev->wakeup.gpe_device, 95 acpi_enable_gpe(dev->wakeup.gpe_device,
97 dev->wakeup.gpe_number, ACPI_ISR); 96 dev->wakeup.gpe_number, ACPI_ISR);
98 dev->wakeup.state.active = 1; 97 dev->wakeup.state.active = 1;
99 spin_lock(&acpi_device_lock); 98 spin_lock(&acpi_device_lock);
100 } 99 }
@@ -106,43 +105,43 @@ acpi_enable_wakeup_device(
106 * @sleep_state: ACPI state 105 * @sleep_state: ACPI state
107 * Disable all wakup devices's GPE and wakeup capability 106 * Disable all wakup devices's GPE and wakeup capability
108 */ 107 */
109void 108void acpi_disable_wakeup_device(u8 sleep_state)
110acpi_disable_wakeup_device (
111 u8 sleep_state)
112{ 109{
113 struct list_head * node, * next; 110 struct list_head *node, *next;
114 111
115 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device"); 112 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device");
116 113
117 spin_lock(&acpi_device_lock); 114 spin_lock(&acpi_device_lock);
118 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 115 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
119 struct acpi_device * dev = container_of(node, 116 struct acpi_device *dev = container_of(node,
120 struct acpi_device, wakeup_list); 117 struct acpi_device,
118 wakeup_list);
121 119
122 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 120 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
123 spin_unlock(&acpi_device_lock); 121 spin_unlock(&acpi_device_lock);
124 acpi_set_gpe_type(dev->wakeup.gpe_device, 122 acpi_set_gpe_type(dev->wakeup.gpe_device,
125 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 123 dev->wakeup.gpe_number,
124 ACPI_GPE_TYPE_WAKE_RUN);
126 /* Re-enable it, since set_gpe_type will disable it */ 125 /* Re-enable it, since set_gpe_type will disable it */
127 acpi_enable_gpe(dev->wakeup.gpe_device, 126 acpi_enable_gpe(dev->wakeup.gpe_device,
128 dev->wakeup.gpe_number, ACPI_NOT_ISR); 127 dev->wakeup.gpe_number, ACPI_NOT_ISR);
129 spin_lock(&acpi_device_lock); 128 spin_lock(&acpi_device_lock);
130 continue; 129 continue;
131 } 130 }
132 131
133 if (!dev->wakeup.flags.valid || 132 if (!dev->wakeup.flags.valid ||
134 !dev->wakeup.state.active || 133 !dev->wakeup.state.active ||
135 (sleep_state > (u32) dev->wakeup.sleep_state)) 134 (sleep_state > (u32) dev->wakeup.sleep_state))
136 continue; 135 continue;
137 136
138 spin_unlock(&acpi_device_lock); 137 spin_unlock(&acpi_device_lock);
139 acpi_disable_wakeup_device_power(dev); 138 acpi_disable_wakeup_device_power(dev);
140 /* Never disable run-wake GPE */ 139 /* Never disable run-wake GPE */
141 if (!dev->wakeup.flags.run_wake) { 140 if (!dev->wakeup.flags.run_wake) {
142 acpi_disable_gpe(dev->wakeup.gpe_device, 141 acpi_disable_gpe(dev->wakeup.gpe_device,
143 dev->wakeup.gpe_number, ACPI_NOT_ISR); 142 dev->wakeup.gpe_number, ACPI_NOT_ISR);
144 acpi_clear_gpe(dev->wakeup.gpe_device, 143 acpi_clear_gpe(dev->wakeup.gpe_device,
145 dev->wakeup.gpe_number, ACPI_NOT_ISR); 144 dev->wakeup.gpe_number, ACPI_NOT_ISR);
146 } 145 }
147 dev->wakeup.state.active = 0; 146 dev->wakeup.state.active = 0;
148 spin_lock(&acpi_device_lock); 147 spin_lock(&acpi_device_lock);
@@ -152,7 +151,7 @@ acpi_disable_wakeup_device (
152 151
153static int __init acpi_wakeup_device_init(void) 152static int __init acpi_wakeup_device_init(void)
154{ 153{
155 struct list_head * node, * next; 154 struct list_head *node, *next;
156 155
157 if (acpi_disabled) 156 if (acpi_disabled)
158 return 0; 157 return 0;
@@ -160,16 +159,18 @@ static int __init acpi_wakeup_device_init(void)
160 159
161 spin_lock(&acpi_device_lock); 160 spin_lock(&acpi_device_lock);
162 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 161 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
163 struct acpi_device * dev = container_of(node, 162 struct acpi_device *dev = container_of(node,
164 struct acpi_device, wakeup_list); 163 struct acpi_device,
165 164 wakeup_list);
165
166 /* In case user doesn't load button driver */ 166 /* In case user doesn't load button driver */
167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
168 spin_unlock(&acpi_device_lock); 168 spin_unlock(&acpi_device_lock);
169 acpi_set_gpe_type(dev->wakeup.gpe_device, 169 acpi_set_gpe_type(dev->wakeup.gpe_device,
170 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 170 dev->wakeup.gpe_number,
171 acpi_enable_gpe(dev->wakeup.gpe_device, 171 ACPI_GPE_TYPE_WAKE_RUN);
172 dev->wakeup.gpe_number, ACPI_NOT_ISR); 172 acpi_enable_gpe(dev->wakeup.gpe_device,
173 dev->wakeup.gpe_number, ACPI_NOT_ISR);
173 dev->wakeup.state.enabled = 1; 174 dev->wakeup.state.enabled = 1;
174 spin_lock(&acpi_device_lock); 175 spin_lock(&acpi_device_lock);
175 } 176 }
@@ -193,17 +194,19 @@ late_initcall(acpi_wakeup_device_init);
193 */ 194 */
194void acpi_wakeup_gpe_poweroff_prepare(void) 195void acpi_wakeup_gpe_poweroff_prepare(void)
195{ 196{
196 struct list_head * node, * next; 197 struct list_head *node, *next;
197 198
198 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 199 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
199 struct acpi_device * dev = container_of(node, 200 struct acpi_device *dev = container_of(node,
200 struct acpi_device, wakeup_list); 201 struct acpi_device,
202 wakeup_list);
201 203
202 /* The GPE can wakeup system from S5, don't touch it */ 204 /* The GPE can wakeup system from S5, don't touch it */
203 if ((u32)dev->wakeup.sleep_state == ACPI_STATE_S5) 205 if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5)
204 continue; 206 continue;
205 /* acpi_set_gpe_type will automatically disable GPE */ 207 /* acpi_set_gpe_type will automatically disable GPE */
206 acpi_set_gpe_type(dev->wakeup.gpe_device, 208 acpi_set_gpe_type(dev->wakeup.gpe_device,
207 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 209 dev->wakeup.gpe_number,
210 ACPI_GPE_TYPE_RUNTIME);
208 } 211 }
209} 212}
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 8925a6ca5f87..e4308c7a6743 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -30,10 +30,8 @@
30 30
31#include <acpi/acpi_drivers.h> 31#include <acpi/acpi_drivers.h>
32 32
33
34#define _COMPONENT ACPI_SYSTEM_COMPONENT 33#define _COMPONENT ACPI_SYSTEM_COMPONENT
35ACPI_MODULE_NAME ("acpi_system") 34ACPI_MODULE_NAME("acpi_system")
36
37#define ACPI_SYSTEM_CLASS "system" 35#define ACPI_SYSTEM_CLASS "system"
38#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" 36#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver"
39#define ACPI_SYSTEM_DEVICE_NAME "System" 37#define ACPI_SYSTEM_DEVICE_NAME "System"
@@ -41,15 +39,13 @@ ACPI_MODULE_NAME ("acpi_system")
41#define ACPI_SYSTEM_FILE_EVENT "event" 39#define ACPI_SYSTEM_FILE_EVENT "event"
42#define ACPI_SYSTEM_FILE_DSDT "dsdt" 40#define ACPI_SYSTEM_FILE_DSDT "dsdt"
43#define ACPI_SYSTEM_FILE_FADT "fadt" 41#define ACPI_SYSTEM_FILE_FADT "fadt"
44 42extern FADT_DESCRIPTOR acpi_fadt;
45extern FADT_DESCRIPTOR acpi_fadt;
46 43
47/* -------------------------------------------------------------------------- 44/* --------------------------------------------------------------------------
48 FS Interface (/proc) 45 FS Interface (/proc)
49 -------------------------------------------------------------------------- */ 46 -------------------------------------------------------------------------- */
50 47
51static int 48static int acpi_system_read_info(struct seq_file *seq, void *offset)
52acpi_system_read_info (struct seq_file *seq, void *offset)
53{ 49{
54 ACPI_FUNCTION_TRACE("acpi_system_read_info"); 50 ACPI_FUNCTION_TRACE("acpi_system_read_info");
55 51
@@ -63,28 +59,26 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
63} 59}
64 60
65static struct file_operations acpi_system_info_ops = { 61static struct file_operations acpi_system_info_ops = {
66 .open = acpi_system_info_open_fs, 62 .open = acpi_system_info_open_fs,
67 .read = seq_read, 63 .read = seq_read,
68 .llseek = seq_lseek, 64 .llseek = seq_lseek,
69 .release = single_release, 65 .release = single_release,
70}; 66};
71 67
72static ssize_t acpi_system_read_dsdt (struct file*, char __user *, size_t, loff_t*); 68static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
69 loff_t *);
73 70
74static struct file_operations acpi_system_dsdt_ops = { 71static struct file_operations acpi_system_dsdt_ops = {
75 .read = acpi_system_read_dsdt, 72 .read = acpi_system_read_dsdt,
76}; 73};
77 74
78static ssize_t 75static ssize_t
79acpi_system_read_dsdt ( 76acpi_system_read_dsdt(struct file *file,
80 struct file *file, 77 char __user * buffer, size_t count, loff_t * ppos)
81 char __user *buffer,
82 size_t count,
83 loff_t *ppos)
84{ 78{
85 acpi_status status = AE_OK; 79 acpi_status status = AE_OK;
86 struct acpi_buffer dsdt = {ACPI_ALLOCATE_BUFFER, NULL}; 80 struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
87 ssize_t res; 81 ssize_t res;
88 82
89 ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); 83 ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
90 84
@@ -99,23 +93,20 @@ acpi_system_read_dsdt (
99 return_VALUE(res); 93 return_VALUE(res);
100} 94}
101 95
102 96static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
103static ssize_t acpi_system_read_fadt (struct file*, char __user *, size_t, loff_t*); 97 loff_t *);
104 98
105static struct file_operations acpi_system_fadt_ops = { 99static struct file_operations acpi_system_fadt_ops = {
106 .read = acpi_system_read_fadt, 100 .read = acpi_system_read_fadt,
107}; 101};
108 102
109static ssize_t 103static ssize_t
110acpi_system_read_fadt ( 104acpi_system_read_fadt(struct file *file,
111 struct file *file, 105 char __user * buffer, size_t count, loff_t * ppos)
112 char __user *buffer,
113 size_t count,
114 loff_t *ppos)
115{ 106{
116 acpi_status status = AE_OK; 107 acpi_status status = AE_OK;
117 struct acpi_buffer fadt = {ACPI_ALLOCATE_BUFFER, NULL}; 108 struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL };
118 ssize_t res; 109 ssize_t res;
119 110
120 ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); 111 ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
121 112
@@ -130,12 +121,11 @@ acpi_system_read_fadt (
130 return_VALUE(res); 121 return_VALUE(res);
131} 122}
132 123
133 124static int __init acpi_system_init(void)
134static int __init acpi_system_init (void)
135{ 125{
136 struct proc_dir_entry *entry; 126 struct proc_dir_entry *entry;
137 int error = 0; 127 int error = 0;
138 char * name; 128 char *name;
139 129
140 ACPI_FUNCTION_TRACE("acpi_system_init"); 130 ACPI_FUNCTION_TRACE("acpi_system_init");
141 131
@@ -144,8 +134,7 @@ static int __init acpi_system_init (void)
144 134
145 /* 'info' [R] */ 135 /* 'info' [R] */
146 name = ACPI_SYSTEM_FILE_INFO; 136 name = ACPI_SYSTEM_FILE_INFO;
147 entry = create_proc_entry(name, 137 entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
148 S_IRUGO, acpi_root_dir);
149 if (!entry) 138 if (!entry)
150 goto Error; 139 goto Error;
151 else { 140 else {
@@ -157,7 +146,7 @@ static int __init acpi_system_init (void)
157 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); 146 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
158 if (entry) 147 if (entry)
159 entry->proc_fops = &acpi_system_dsdt_ops; 148 entry->proc_fops = &acpi_system_dsdt_ops;
160 else 149 else
161 goto Error; 150 goto Error;
162 151
163 /* 'fadt' [R] */ 152 /* 'fadt' [R] */
@@ -168,12 +157,12 @@ static int __init acpi_system_init (void)
168 else 157 else
169 goto Error; 158 goto Error;
170 159
171 Done: 160 Done:
172 return_VALUE(error); 161 return_VALUE(error);
173 162
174 Error: 163 Error:
175 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
176 "Unable to create '%s' proc fs entry\n", name)); 165 "Unable to create '%s' proc fs entry\n", name));
177 166
178 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); 167 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
179 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); 168 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
@@ -183,5 +172,4 @@ static int __init acpi_system_init (void)
183 goto Done; 172 goto Done;
184} 173}
185 174
186
187subsys_initcall(acpi_system_init); 175subsys_initcall(acpi_system_init);
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index fb64bd5d2e18..a2bf25b05e1c 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -40,25 +40,25 @@
40#define ACPI_MAX_TABLES 256 40#define ACPI_MAX_TABLES 256
41 41
42static char *acpi_table_signatures[ACPI_TABLE_COUNT] = { 42static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
43 [ACPI_TABLE_UNKNOWN] = "????", 43 [ACPI_TABLE_UNKNOWN] = "????",
44 [ACPI_APIC] = "APIC", 44 [ACPI_APIC] = "APIC",
45 [ACPI_BOOT] = "BOOT", 45 [ACPI_BOOT] = "BOOT",
46 [ACPI_DBGP] = "DBGP", 46 [ACPI_DBGP] = "DBGP",
47 [ACPI_DSDT] = "DSDT", 47 [ACPI_DSDT] = "DSDT",
48 [ACPI_ECDT] = "ECDT", 48 [ACPI_ECDT] = "ECDT",
49 [ACPI_ETDT] = "ETDT", 49 [ACPI_ETDT] = "ETDT",
50 [ACPI_FADT] = "FACP", 50 [ACPI_FADT] = "FACP",
51 [ACPI_FACS] = "FACS", 51 [ACPI_FACS] = "FACS",
52 [ACPI_OEMX] = "OEM", 52 [ACPI_OEMX] = "OEM",
53 [ACPI_PSDT] = "PSDT", 53 [ACPI_PSDT] = "PSDT",
54 [ACPI_SBST] = "SBST", 54 [ACPI_SBST] = "SBST",
55 [ACPI_SLIT] = "SLIT", 55 [ACPI_SLIT] = "SLIT",
56 [ACPI_SPCR] = "SPCR", 56 [ACPI_SPCR] = "SPCR",
57 [ACPI_SRAT] = "SRAT", 57 [ACPI_SRAT] = "SRAT",
58 [ACPI_SSDT] = "SSDT", 58 [ACPI_SSDT] = "SSDT",
59 [ACPI_SPMI] = "SPMI", 59 [ACPI_SPMI] = "SPMI",
60 [ACPI_HPET] = "HPET", 60 [ACPI_HPET] = "HPET",
61 [ACPI_MCFG] = "MCFG", 61 [ACPI_MCFG] = "MCFG",
62}; 62};
63 63
64static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; 64static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
@@ -66,52 +66,44 @@ static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
66 66
67/* System Description Table (RSDT/XSDT) */ 67/* System Description Table (RSDT/XSDT) */
68struct acpi_table_sdt { 68struct acpi_table_sdt {
69 unsigned long pa; 69 unsigned long pa;
70 enum acpi_table_id id; 70 enum acpi_table_id id;
71 unsigned long size; 71 unsigned long size;
72} __attribute__ ((packed)); 72} __attribute__ ((packed));
73 73
74static unsigned long sdt_pa; /* Physical Address */ 74static unsigned long sdt_pa; /* Physical Address */
75static unsigned long sdt_count; /* Table count */ 75static unsigned long sdt_count; /* Table count */
76 76
77static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES]; 77static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES];
78 78
79void 79void acpi_table_print(struct acpi_table_header *header, unsigned long phys_addr)
80acpi_table_print (
81 struct acpi_table_header *header,
82 unsigned long phys_addr)
83{ 80{
84 char *name = NULL; 81 char *name = NULL;
85 82
86 if (!header) 83 if (!header)
87 return; 84 return;
88 85
89 /* Some table signatures aren't good table names */ 86 /* Some table signatures aren't good table names */
90 87
91 if (!strncmp((char *) &header->signature, 88 if (!strncmp((char *)&header->signature,
92 acpi_table_signatures[ACPI_APIC], 89 acpi_table_signatures[ACPI_APIC],
93 sizeof(header->signature))) { 90 sizeof(header->signature))) {
94 name = "MADT"; 91 name = "MADT";
95 } 92 } else if (!strncmp((char *)&header->signature,
96 else if (!strncmp((char *) &header->signature, 93 acpi_table_signatures[ACPI_FADT],
97 acpi_table_signatures[ACPI_FADT], 94 sizeof(header->signature))) {
98 sizeof(header->signature))) {
99 name = "FADT"; 95 name = "FADT";
100 } 96 } else
101 else
102 name = header->signature; 97 name = header->signature;
103 98
104 printk(KERN_DEBUG PREFIX "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", 99 printk(KERN_DEBUG PREFIX
105 name, header->revision, header->oem_id, 100 "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", name,
106 header->oem_table_id, header->oem_revision, 101 header->revision, header->oem_id, header->oem_table_id,
107 header->asl_compiler_id, header->asl_compiler_revision, 102 header->oem_revision, header->asl_compiler_id,
108 (void *) phys_addr); 103 header->asl_compiler_revision, (void *)phys_addr);
109} 104}
110 105
111 106void acpi_table_print_madt_entry(acpi_table_entry_header * header)
112void
113acpi_table_print_madt_entry (
114 acpi_table_entry_header *header)
115{ 107{
116 if (!header) 108 if (!header)
117 return; 109 return;
@@ -119,113 +111,127 @@ acpi_table_print_madt_entry (
119 switch (header->type) { 111 switch (header->type) {
120 112
121 case ACPI_MADT_LAPIC: 113 case ACPI_MADT_LAPIC:
122 { 114 {
123 struct acpi_table_lapic *p = 115 struct acpi_table_lapic *p =
124 (struct acpi_table_lapic*) header; 116 (struct acpi_table_lapic *)header;
125 printk(KERN_INFO PREFIX "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", 117 printk(KERN_INFO PREFIX
126 p->acpi_id, p->id, p->flags.enabled?"enabled":"disabled"); 118 "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
127 } 119 p->acpi_id, p->id,
120 p->flags.enabled ? "enabled" : "disabled");
121 }
128 break; 122 break;
129 123
130 case ACPI_MADT_IOAPIC: 124 case ACPI_MADT_IOAPIC:
131 { 125 {
132 struct acpi_table_ioapic *p = 126 struct acpi_table_ioapic *p =
133 (struct acpi_table_ioapic*) header; 127 (struct acpi_table_ioapic *)header;
134 printk(KERN_INFO PREFIX "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", 128 printk(KERN_INFO PREFIX
135 p->id, p->address, p->global_irq_base); 129 "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
136 } 130 p->id, p->address, p->global_irq_base);
131 }
137 break; 132 break;
138 133
139 case ACPI_MADT_INT_SRC_OVR: 134 case ACPI_MADT_INT_SRC_OVR:
140 { 135 {
141 struct acpi_table_int_src_ovr *p = 136 struct acpi_table_int_src_ovr *p =
142 (struct acpi_table_int_src_ovr*) header; 137 (struct acpi_table_int_src_ovr *)header;
143 printk(KERN_INFO PREFIX "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", 138 printk(KERN_INFO PREFIX
144 p->bus, p->bus_irq, p->global_irq, 139 "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n",
145 mps_inti_flags_polarity[p->flags.polarity], 140 p->bus, p->bus_irq, p->global_irq,
146 mps_inti_flags_trigger[p->flags.trigger]); 141 mps_inti_flags_polarity[p->flags.polarity],
147 if(p->flags.reserved) 142 mps_inti_flags_trigger[p->flags.trigger]);
148 printk(KERN_INFO PREFIX "INT_SRC_OVR unexpected reserved flags: 0x%x\n", 143 if (p->flags.reserved)
149 p->flags.reserved); 144 printk(KERN_INFO PREFIX
145 "INT_SRC_OVR unexpected reserved flags: 0x%x\n",
146 p->flags.reserved);
150 147
151 } 148 }
152 break; 149 break;
153 150
154 case ACPI_MADT_NMI_SRC: 151 case ACPI_MADT_NMI_SRC:
155 { 152 {
156 struct acpi_table_nmi_src *p = 153 struct acpi_table_nmi_src *p =
157 (struct acpi_table_nmi_src*) header; 154 (struct acpi_table_nmi_src *)header;
158 printk(KERN_INFO PREFIX "NMI_SRC (%s %s global_irq %d)\n", 155 printk(KERN_INFO PREFIX
159 mps_inti_flags_polarity[p->flags.polarity], 156 "NMI_SRC (%s %s global_irq %d)\n",
160 mps_inti_flags_trigger[p->flags.trigger], p->global_irq); 157 mps_inti_flags_polarity[p->flags.polarity],
161 } 158 mps_inti_flags_trigger[p->flags.trigger],
159 p->global_irq);
160 }
162 break; 161 break;
163 162
164 case ACPI_MADT_LAPIC_NMI: 163 case ACPI_MADT_LAPIC_NMI:
165 { 164 {
166 struct acpi_table_lapic_nmi *p = 165 struct acpi_table_lapic_nmi *p =
167 (struct acpi_table_lapic_nmi*) header; 166 (struct acpi_table_lapic_nmi *)header;
168 printk(KERN_INFO PREFIX "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", 167 printk(KERN_INFO PREFIX
169 p->acpi_id, 168 "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n",
170 mps_inti_flags_polarity[p->flags.polarity], 169 p->acpi_id,
171 mps_inti_flags_trigger[p->flags.trigger], p->lint); 170 mps_inti_flags_polarity[p->flags.polarity],
172 } 171 mps_inti_flags_trigger[p->flags.trigger],
172 p->lint);
173 }
173 break; 174 break;
174 175
175 case ACPI_MADT_LAPIC_ADDR_OVR: 176 case ACPI_MADT_LAPIC_ADDR_OVR:
176 { 177 {
177 struct acpi_table_lapic_addr_ovr *p = 178 struct acpi_table_lapic_addr_ovr *p =
178 (struct acpi_table_lapic_addr_ovr*) header; 179 (struct acpi_table_lapic_addr_ovr *)header;
179 printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[%p])\n", 180 printk(KERN_INFO PREFIX
180 (void *) (unsigned long) p->address); 181 "LAPIC_ADDR_OVR (address[%p])\n",
181 } 182 (void *)(unsigned long)p->address);
183 }
182 break; 184 break;
183 185
184 case ACPI_MADT_IOSAPIC: 186 case ACPI_MADT_IOSAPIC:
185 { 187 {
186 struct acpi_table_iosapic *p = 188 struct acpi_table_iosapic *p =
187 (struct acpi_table_iosapic*) header; 189 (struct acpi_table_iosapic *)header;
188 printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", 190 printk(KERN_INFO PREFIX
189 p->id, (void *) (unsigned long) p->address, p->global_irq_base); 191 "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
190 } 192 p->id, (void *)(unsigned long)p->address,
193 p->global_irq_base);
194 }
191 break; 195 break;
192 196
193 case ACPI_MADT_LSAPIC: 197 case ACPI_MADT_LSAPIC:
194 { 198 {
195 struct acpi_table_lsapic *p = 199 struct acpi_table_lsapic *p =
196 (struct acpi_table_lsapic*) header; 200 (struct acpi_table_lsapic *)header;
197 printk(KERN_INFO PREFIX "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", 201 printk(KERN_INFO PREFIX
198 p->acpi_id, p->id, p->eid, p->flags.enabled?"enabled":"disabled"); 202 "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
199 } 203 p->acpi_id, p->id, p->eid,
204 p->flags.enabled ? "enabled" : "disabled");
205 }
200 break; 206 break;
201 207
202 case ACPI_MADT_PLAT_INT_SRC: 208 case ACPI_MADT_PLAT_INT_SRC:
203 { 209 {
204 struct acpi_table_plat_int_src *p = 210 struct acpi_table_plat_int_src *p =
205 (struct acpi_table_plat_int_src*) header; 211 (struct acpi_table_plat_int_src *)header;
206 printk(KERN_INFO PREFIX "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", 212 printk(KERN_INFO PREFIX
207 mps_inti_flags_polarity[p->flags.polarity], 213 "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
208 mps_inti_flags_trigger[p->flags.trigger], 214 mps_inti_flags_polarity[p->flags.polarity],
209 p->type, p->id, p->eid, p->iosapic_vector, p->global_irq); 215 mps_inti_flags_trigger[p->flags.trigger],
210 } 216 p->type, p->id, p->eid, p->iosapic_vector,
217 p->global_irq);
218 }
211 break; 219 break;
212 220
213 default: 221 default:
214 printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = 0x%x)\n", 222 printk(KERN_WARNING PREFIX
215 header->type); 223 "Found unsupported MADT entry (type = 0x%x)\n",
224 header->type);
216 break; 225 break;
217 } 226 }
218} 227}
219 228
220
221static int 229static int
222acpi_table_compute_checksum ( 230acpi_table_compute_checksum(void *table_pointer, unsigned long length)
223 void *table_pointer,
224 unsigned long length)
225{ 231{
226 u8 *p = (u8 *) table_pointer; 232 u8 *p = (u8 *) table_pointer;
227 unsigned long remains = length; 233 unsigned long remains = length;
228 unsigned long sum = 0; 234 unsigned long sum = 0;
229 235
230 if (!p || !length) 236 if (!p || !length)
231 return -EINVAL; 237 return -EINVAL;
@@ -241,9 +247,8 @@ acpi_table_compute_checksum (
241 * for acpi_blacklisted(), acpi_table_get_sdt() 247 * for acpi_blacklisted(), acpi_table_get_sdt()
242 */ 248 */
243int __init 249int __init
244acpi_get_table_header_early ( 250acpi_get_table_header_early(enum acpi_table_id id,
245 enum acpi_table_id id, 251 struct acpi_table_header **header)
246 struct acpi_table_header **header)
247{ 252{
248 unsigned int i; 253 unsigned int i;
249 enum acpi_table_id temp_id; 254 enum acpi_table_id temp_id;
@@ -260,7 +265,7 @@ acpi_get_table_header_early (
260 if (sdt_entry[i].id != temp_id) 265 if (sdt_entry[i].id != temp_id)
261 continue; 266 continue;
262 *header = (void *) 267 *header = (void *)
263 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); 268 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
264 if (!*header) { 269 if (!*header) {
265 printk(KERN_WARNING PREFIX "Unable to map %s\n", 270 printk(KERN_WARNING PREFIX "Unable to map %s\n",
266 acpi_table_signatures[temp_id]); 271 acpi_table_signatures[temp_id]);
@@ -277,14 +282,17 @@ acpi_get_table_header_early (
277 282
278 /* Map the DSDT header via the pointer in the FADT */ 283 /* Map the DSDT header via the pointer in the FADT */
279 if (id == ACPI_DSDT) { 284 if (id == ACPI_DSDT) {
280 struct fadt_descriptor_rev2 *fadt = (struct fadt_descriptor_rev2 *) *header; 285 struct fadt_descriptor_rev2 *fadt =
286 (struct fadt_descriptor_rev2 *)*header;
281 287
282 if (fadt->revision == 3 && fadt->Xdsdt) { 288 if (fadt->revision == 3 && fadt->Xdsdt) {
283 *header = (void *) __acpi_map_table(fadt->Xdsdt, 289 *header = (void *)__acpi_map_table(fadt->Xdsdt,
284 sizeof(struct acpi_table_header)); 290 sizeof(struct
291 acpi_table_header));
285 } else if (fadt->V1_dsdt) { 292 } else if (fadt->V1_dsdt) {
286 *header = (void *) __acpi_map_table(fadt->V1_dsdt, 293 *header = (void *)__acpi_map_table(fadt->V1_dsdt,
287 sizeof(struct acpi_table_header)); 294 sizeof(struct
295 acpi_table_header));
288 } else 296 } else
289 *header = NULL; 297 *header = NULL;
290 298
@@ -296,21 +304,19 @@ acpi_get_table_header_early (
296 304
297 return 0; 305 return 0;
298} 306}
299
300 307
301int __init 308int __init
302acpi_table_parse_madt_family ( 309acpi_table_parse_madt_family(enum acpi_table_id id,
303 enum acpi_table_id id, 310 unsigned long madt_size,
304 unsigned long madt_size, 311 int entry_id,
305 int entry_id, 312 acpi_madt_entry_handler handler,
306 acpi_madt_entry_handler handler, 313 unsigned int max_entries)
307 unsigned int max_entries)
308{ 314{
309 void *madt = NULL; 315 void *madt = NULL;
310 acpi_table_entry_header *entry; 316 acpi_table_entry_header *entry;
311 unsigned int count = 0; 317 unsigned int count = 0;
312 unsigned long madt_end; 318 unsigned long madt_end;
313 unsigned int i; 319 unsigned int i;
314 320
315 if (!handler) 321 if (!handler)
316 return -EINVAL; 322 return -EINVAL;
@@ -321,7 +327,7 @@ acpi_table_parse_madt_family (
321 if (sdt_entry[i].id != id) 327 if (sdt_entry[i].id != id)
322 continue; 328 continue;
323 madt = (void *) 329 madt = (void *)
324 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); 330 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
325 if (!madt) { 331 if (!madt) {
326 printk(KERN_WARNING PREFIX "Unable to map %s\n", 332 printk(KERN_WARNING PREFIX "Unable to map %s\n",
327 acpi_table_signatures[id]); 333 acpi_table_signatures[id]);
@@ -336,21 +342,22 @@ acpi_table_parse_madt_family (
336 return -ENODEV; 342 return -ENODEV;
337 } 343 }
338 344
339 madt_end = (unsigned long) madt + sdt_entry[i].size; 345 madt_end = (unsigned long)madt + sdt_entry[i].size;
340 346
341 /* Parse all entries looking for a match. */ 347 /* Parse all entries looking for a match. */
342 348
343 entry = (acpi_table_entry_header *) 349 entry = (acpi_table_entry_header *)
344 ((unsigned long) madt + madt_size); 350 ((unsigned long)madt + madt_size);
345 351
346 while (((unsigned long) entry) + sizeof(acpi_table_entry_header) < madt_end) { 352 while (((unsigned long)entry) + sizeof(acpi_table_entry_header) <
347 if (entry->type == entry_id && 353 madt_end) {
348 (!max_entries || count++ < max_entries)) 354 if (entry->type == entry_id
355 && (!max_entries || count++ < max_entries))
349 if (handler(entry, madt_end)) 356 if (handler(entry, madt_end))
350 return -EINVAL; 357 return -EINVAL;
351 358
352 entry = (acpi_table_entry_header *) 359 entry = (acpi_table_entry_header *)
353 ((unsigned long) entry + entry->length); 360 ((unsigned long)entry + entry->length);
354 } 361 }
355 if (max_entries && count > max_entries) { 362 if (max_entries && count > max_entries) {
356 printk(KERN_WARNING PREFIX "[%s:0x%02x] ignored %i entries of " 363 printk(KERN_WARNING PREFIX "[%s:0x%02x] ignored %i entries of "
@@ -361,25 +368,19 @@ acpi_table_parse_madt_family (
361 return count; 368 return count;
362} 369}
363 370
364
365int __init 371int __init
366acpi_table_parse_madt ( 372acpi_table_parse_madt(enum acpi_madt_entry_id id,
367 enum acpi_madt_entry_id id, 373 acpi_madt_entry_handler handler, unsigned int max_entries)
368 acpi_madt_entry_handler handler,
369 unsigned int max_entries)
370{ 374{
371 return acpi_table_parse_madt_family(ACPI_APIC, sizeof(struct acpi_table_madt), 375 return acpi_table_parse_madt_family(ACPI_APIC,
372 id, handler, max_entries); 376 sizeof(struct acpi_table_madt), id,
377 handler, max_entries);
373} 378}
374 379
375 380int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler)
376int __init
377acpi_table_parse (
378 enum acpi_table_id id,
379 acpi_table_handler handler)
380{ 381{
381 int count = 0; 382 int count = 0;
382 unsigned int i = 0; 383 unsigned int i = 0;
383 384
384 if (!handler) 385 if (!handler)
385 return -EINVAL; 386 return -EINVAL;
@@ -392,20 +393,18 @@ acpi_table_parse (
392 handler(sdt_entry[i].pa, sdt_entry[i].size); 393 handler(sdt_entry[i].pa, sdt_entry[i].size);
393 394
394 else 395 else
395 printk(KERN_WARNING PREFIX "%d duplicate %s table ignored.\n", 396 printk(KERN_WARNING PREFIX
396 count, acpi_table_signatures[id]); 397 "%d duplicate %s table ignored.\n", count,
398 acpi_table_signatures[id]);
397 } 399 }
398 400
399 return count; 401 return count;
400} 402}
401 403
402 404static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
403static int __init
404acpi_table_get_sdt (
405 struct acpi_table_rsdp *rsdp)
406{ 405{
407 struct acpi_table_header *header = NULL; 406 struct acpi_table_header *header = NULL;
408 unsigned int i, id = 0; 407 unsigned int i, id = 0;
409 408
410 if (!rsdp) 409 if (!rsdp)
411 return -EINVAL; 410 return -EINVAL;
@@ -413,24 +412,25 @@ acpi_table_get_sdt (
413 /* First check XSDT (but only on ACPI 2.0-compatible systems) */ 412 /* First check XSDT (but only on ACPI 2.0-compatible systems) */
414 413
415 if ((rsdp->revision >= 2) && 414 if ((rsdp->revision >= 2) &&
416 (((struct acpi20_table_rsdp*)rsdp)->xsdt_address)) { 415 (((struct acpi20_table_rsdp *)rsdp)->xsdt_address)) {
417 416
418 struct acpi_table_xsdt *mapped_xsdt = NULL; 417 struct acpi_table_xsdt *mapped_xsdt = NULL;
419 418
420 sdt_pa = ((struct acpi20_table_rsdp*)rsdp)->xsdt_address; 419 sdt_pa = ((struct acpi20_table_rsdp *)rsdp)->xsdt_address;
421 420
422 /* map in just the header */ 421 /* map in just the header */
423 header = (struct acpi_table_header *) 422 header = (struct acpi_table_header *)
424 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); 423 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
425 424
426 if (!header) { 425 if (!header) {
427 printk(KERN_WARNING PREFIX "Unable to map XSDT header\n"); 426 printk(KERN_WARNING PREFIX
427 "Unable to map XSDT header\n");
428 return -ENODEV; 428 return -ENODEV;
429 } 429 }
430 430
431 /* remap in the entire table before processing */ 431 /* remap in the entire table before processing */
432 mapped_xsdt = (struct acpi_table_xsdt *) 432 mapped_xsdt = (struct acpi_table_xsdt *)
433 __acpi_map_table(sdt_pa, header->length); 433 __acpi_map_table(sdt_pa, header->length);
434 if (!mapped_xsdt) { 434 if (!mapped_xsdt) {
435 printk(KERN_WARNING PREFIX "Unable to map XSDT\n"); 435 printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
436 return -ENODEV; 436 return -ENODEV;
@@ -438,7 +438,8 @@ acpi_table_get_sdt (
438 header = &mapped_xsdt->header; 438 header = &mapped_xsdt->header;
439 439
440 if (strncmp(header->signature, "XSDT", 4)) { 440 if (strncmp(header->signature, "XSDT", 4)) {
441 printk(KERN_WARNING PREFIX "XSDT signature incorrect\n"); 441 printk(KERN_WARNING PREFIX
442 "XSDT signature incorrect\n");
442 return -ENODEV; 443 return -ENODEV;
443 } 444 }
444 445
@@ -447,36 +448,39 @@ acpi_table_get_sdt (
447 return -ENODEV; 448 return -ENODEV;
448 } 449 }
449 450
450 sdt_count = (header->length - sizeof(struct acpi_table_header)) >> 3; 451 sdt_count =
452 (header->length - sizeof(struct acpi_table_header)) >> 3;
451 if (sdt_count > ACPI_MAX_TABLES) { 453 if (sdt_count > ACPI_MAX_TABLES) {
452 printk(KERN_WARNING PREFIX "Truncated %lu XSDT entries\n", 454 printk(KERN_WARNING PREFIX
453 (sdt_count - ACPI_MAX_TABLES)); 455 "Truncated %lu XSDT entries\n",
456 (sdt_count - ACPI_MAX_TABLES));
454 sdt_count = ACPI_MAX_TABLES; 457 sdt_count = ACPI_MAX_TABLES;
455 } 458 }
456 459
457 for (i = 0; i < sdt_count; i++) 460 for (i = 0; i < sdt_count; i++)
458 sdt_entry[i].pa = (unsigned long) mapped_xsdt->entry[i]; 461 sdt_entry[i].pa = (unsigned long)mapped_xsdt->entry[i];
459 } 462 }
460 463
461 /* Then check RSDT */ 464 /* Then check RSDT */
462 465
463 else if (rsdp->rsdt_address) { 466 else if (rsdp->rsdt_address) {
464 467
465 struct acpi_table_rsdt *mapped_rsdt = NULL; 468 struct acpi_table_rsdt *mapped_rsdt = NULL;
466 469
467 sdt_pa = rsdp->rsdt_address; 470 sdt_pa = rsdp->rsdt_address;
468 471
469 /* map in just the header */ 472 /* map in just the header */
470 header = (struct acpi_table_header *) 473 header = (struct acpi_table_header *)
471 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); 474 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
472 if (!header) { 475 if (!header) {
473 printk(KERN_WARNING PREFIX "Unable to map RSDT header\n"); 476 printk(KERN_WARNING PREFIX
477 "Unable to map RSDT header\n");
474 return -ENODEV; 478 return -ENODEV;
475 } 479 }
476 480
477 /* remap in the entire table before processing */ 481 /* remap in the entire table before processing */
478 mapped_rsdt = (struct acpi_table_rsdt *) 482 mapped_rsdt = (struct acpi_table_rsdt *)
479 __acpi_map_table(sdt_pa, header->length); 483 __acpi_map_table(sdt_pa, header->length);
480 if (!mapped_rsdt) { 484 if (!mapped_rsdt) {
481 printk(KERN_WARNING PREFIX "Unable to map RSDT\n"); 485 printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
482 return -ENODEV; 486 return -ENODEV;
@@ -484,7 +488,8 @@ acpi_table_get_sdt (
484 header = &mapped_rsdt->header; 488 header = &mapped_rsdt->header;
485 489
486 if (strncmp(header->signature, "RSDT", 4)) { 490 if (strncmp(header->signature, "RSDT", 4)) {
487 printk(KERN_WARNING PREFIX "RSDT signature incorrect\n"); 491 printk(KERN_WARNING PREFIX
492 "RSDT signature incorrect\n");
488 return -ENODEV; 493 return -ENODEV;
489 } 494 }
490 495
@@ -493,19 +498,22 @@ acpi_table_get_sdt (
493 return -ENODEV; 498 return -ENODEV;
494 } 499 }
495 500
496 sdt_count = (header->length - sizeof(struct acpi_table_header)) >> 2; 501 sdt_count =
502 (header->length - sizeof(struct acpi_table_header)) >> 2;
497 if (sdt_count > ACPI_MAX_TABLES) { 503 if (sdt_count > ACPI_MAX_TABLES) {
498 printk(KERN_WARNING PREFIX "Truncated %lu RSDT entries\n", 504 printk(KERN_WARNING PREFIX
499 (sdt_count - ACPI_MAX_TABLES)); 505 "Truncated %lu RSDT entries\n",
506 (sdt_count - ACPI_MAX_TABLES));
500 sdt_count = ACPI_MAX_TABLES; 507 sdt_count = ACPI_MAX_TABLES;
501 } 508 }
502 509
503 for (i = 0; i < sdt_count; i++) 510 for (i = 0; i < sdt_count; i++)
504 sdt_entry[i].pa = (unsigned long) mapped_rsdt->entry[i]; 511 sdt_entry[i].pa = (unsigned long)mapped_rsdt->entry[i];
505 } 512 }
506 513
507 else { 514 else {
508 printk(KERN_WARNING PREFIX "No System Description Table (RSDT/XSDT) specified in RSDP\n"); 515 printk(KERN_WARNING PREFIX
516 "No System Description Table (RSDT/XSDT) specified in RSDP\n");
509 return -ENODEV; 517 return -ENODEV;
510 } 518 }
511 519
@@ -515,18 +523,17 @@ acpi_table_get_sdt (
515 523
516 /* map in just the header */ 524 /* map in just the header */
517 header = (struct acpi_table_header *) 525 header = (struct acpi_table_header *)
518 __acpi_map_table(sdt_entry[i].pa, 526 __acpi_map_table(sdt_entry[i].pa,
519 sizeof(struct acpi_table_header)); 527 sizeof(struct acpi_table_header));
520 if (!header) 528 if (!header)
521 continue; 529 continue;
522 530
523 /* remap in the entire table before processing */ 531 /* remap in the entire table before processing */
524 header = (struct acpi_table_header *) 532 header = (struct acpi_table_header *)
525 __acpi_map_table(sdt_entry[i].pa, 533 __acpi_map_table(sdt_entry[i].pa, header->length);
526 header->length);
527 if (!header) 534 if (!header)
528 continue; 535 continue;
529 536
530 acpi_table_print(header, sdt_entry[i].pa); 537 acpi_table_print(header, sdt_entry[i].pa);
531 538
532 if (acpi_table_compute_checksum(header, header->length)) { 539 if (acpi_table_compute_checksum(header, header->length)) {
@@ -537,9 +544,9 @@ acpi_table_get_sdt (
537 sdt_entry[i].size = header->length; 544 sdt_entry[i].size = header->length;
538 545
539 for (id = 0; id < ACPI_TABLE_COUNT; id++) { 546 for (id = 0; id < ACPI_TABLE_COUNT; id++) {
540 if (!strncmp((char *) &header->signature, 547 if (!strncmp((char *)&header->signature,
541 acpi_table_signatures[id], 548 acpi_table_signatures[id],
542 sizeof(header->signature))) { 549 sizeof(header->signature))) {
543 sdt_entry[i].id = id; 550 sdt_entry[i].id = id;
544 } 551 }
545 } 552 }
@@ -551,7 +558,7 @@ acpi_table_get_sdt (
551 * against. Unfortunately, we don't know the phys_addr, so just 558 * against. Unfortunately, we don't know the phys_addr, so just
552 * print 0. Maybe no one will notice. 559 * print 0. Maybe no one will notice.
553 */ 560 */
554 if(!acpi_get_table_header_early(ACPI_DSDT, &header)) 561 if (!acpi_get_table_header_early(ACPI_DSDT, &header))
555 acpi_table_print(header, 0); 562 acpi_table_print(header, 0);
556 563
557 return 0; 564 return 0;
@@ -566,12 +573,11 @@ acpi_table_get_sdt (
566 * result: sdt_entry[] is initialized 573 * result: sdt_entry[] is initialized
567 */ 574 */
568 575
569int __init 576int __init acpi_table_init(void)
570acpi_table_init (void)
571{ 577{
572 struct acpi_table_rsdp *rsdp = NULL; 578 struct acpi_table_rsdp *rsdp = NULL;
573 unsigned long rsdp_phys = 0; 579 unsigned long rsdp_phys = 0;
574 int result = 0; 580 int result = 0;
575 581
576 /* Locate and map the Root System Description Table (RSDP) */ 582 /* Locate and map the Root System Description Table (RSDP) */
577 583
@@ -581,19 +587,25 @@ acpi_table_init (void)
581 return -ENODEV; 587 return -ENODEV;
582 } 588 }
583 589
584 rsdp = (struct acpi_table_rsdp *) __va(rsdp_phys); 590 rsdp = (struct acpi_table_rsdp *)__va(rsdp_phys);
585 if (!rsdp) { 591 if (!rsdp) {
586 printk(KERN_WARNING PREFIX "Unable to map RSDP\n"); 592 printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
587 return -ENODEV; 593 return -ENODEV;
588 } 594 }
589 595
590 printk(KERN_DEBUG PREFIX "RSDP (v%3.3d %6.6s ) @ 0x%p\n", 596 printk(KERN_DEBUG PREFIX
591 rsdp->revision, rsdp->oem_id, (void *) rsdp_phys); 597 "RSDP (v%3.3d %6.6s ) @ 0x%p\n",
598 rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);
592 599
593 if (rsdp->revision < 2) 600 if (rsdp->revision < 2)
594 result = acpi_table_compute_checksum(rsdp, sizeof(struct acpi_table_rsdp)); 601 result =
602 acpi_table_compute_checksum(rsdp,
603 sizeof(struct acpi_table_rsdp));
595 else 604 else
596 result = acpi_table_compute_checksum(rsdp, ((struct acpi20_table_rsdp *)rsdp)->length); 605 result =
606 acpi_table_compute_checksum(rsdp,
607 ((struct acpi20_table_rsdp *)
608 rsdp)->length);
597 609
598 if (result) { 610 if (result) {
599 printk(KERN_WARNING " >>> ERROR: Invalid checksum\n"); 611 printk(KERN_WARNING " >>> ERROR: Invalid checksum\n");
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 92e0c31539be..a03939399fa9 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -46,28 +46,22 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/actables.h> 47#include <acpi/actables.h>
48 48
49
50#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbconvrt") 50ACPI_MODULE_NAME("tbconvrt")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static void 53static void
56acpi_tb_init_generic_address ( 54acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
57 struct acpi_generic_address *new_gas_struct, 55 u8 register_bit_width,
58 u8 register_bit_width, 56 acpi_physical_address address);
59 acpi_physical_address address);
60 57
61static void 58static void
62acpi_tb_convert_fadt1 ( 59acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
63 struct fadt_descriptor_rev2 *local_fadt, 60 struct fadt_descriptor_rev1 *original_fadt);
64 struct fadt_descriptor_rev1 *original_fadt);
65 61
66static void 62static void
67acpi_tb_convert_fadt2 ( 63acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
68 struct fadt_descriptor_rev2 *local_fadt, 64 struct fadt_descriptor_rev2 *original_fadt);
69 struct fadt_descriptor_rev2 *original_fadt);
70
71 65
72u8 acpi_fadt_is_v1; 66u8 acpi_fadt_is_v1;
73EXPORT_SYMBOL(acpi_fadt_is_v1); 67EXPORT_SYMBOL(acpi_fadt_is_v1);
@@ -87,21 +81,19 @@ EXPORT_SYMBOL(acpi_fadt_is_v1);
87 ******************************************************************************/ 81 ******************************************************************************/
88 82
89u32 83u32
90acpi_tb_get_table_count ( 84acpi_tb_get_table_count(struct rsdp_descriptor *RSDP,
91 struct rsdp_descriptor *RSDP, 85 struct acpi_table_header *RSDT)
92 struct acpi_table_header *RSDT)
93{ 86{
94 u32 pointer_size; 87 u32 pointer_size;
95 88
89 ACPI_FUNCTION_ENTRY();
96 90
97 ACPI_FUNCTION_ENTRY (); 91 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
98 92
99 93 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
100 if (RSDP->revision < 2) { 94 pointer_size = sizeof(u32);
101 pointer_size = sizeof (u32); 95 } else {
102 } 96 pointer_size = sizeof(u64);
103 else {
104 pointer_size = sizeof (u64);
105 } 97 }
106 98
107 /* 99 /*
@@ -110,10 +102,10 @@ acpi_tb_get_table_count (
110 * pointers contained within the RSDT/XSDT. The size of the pointers 102 * pointers contained within the RSDT/XSDT. The size of the pointers
111 * is architecture-dependent. 103 * is architecture-dependent.
112 */ 104 */
113 return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size); 105 return ((RSDT->length -
106 sizeof(struct acpi_table_header)) / pointer_size);
114} 107}
115 108
116
117/******************************************************************************* 109/*******************************************************************************
118 * 110 *
119 * FUNCTION: acpi_tb_convert_to_xsdt 111 * FUNCTION: acpi_tb_convert_to_xsdt
@@ -126,64 +118,65 @@ acpi_tb_get_table_count (
126 * 118 *
127 ******************************************************************************/ 119 ******************************************************************************/
128 120
129acpi_status 121acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
130acpi_tb_convert_to_xsdt (
131 struct acpi_table_desc *table_info)
132{ 122{
133 acpi_size table_size; 123 acpi_size table_size;
134 u32 i; 124 u32 i;
135 XSDT_DESCRIPTOR *new_table; 125 XSDT_DESCRIPTOR *new_table;
136
137
138 ACPI_FUNCTION_ENTRY ();
139 126
127 ACPI_FUNCTION_ENTRY();
140 128
141 /* Compute size of the converted XSDT */ 129 /* Compute size of the converted XSDT */
142 130
143 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) + 131 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) +
144 sizeof (struct acpi_table_header); 132 sizeof(struct acpi_table_header);
145 133
146 /* Allocate an XSDT */ 134 /* Allocate an XSDT */
147 135
148 new_table = ACPI_MEM_CALLOCATE (table_size); 136 new_table = ACPI_MEM_CALLOCATE(table_size);
149 if (!new_table) { 137 if (!new_table) {
150 return (AE_NO_MEMORY); 138 return (AE_NO_MEMORY);
151 } 139 }
152 140
153 /* Copy the header and set the length */ 141 /* Copy the header and set the length */
154 142
155 ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header)); 143 ACPI_MEMCPY(new_table, table_info->pointer,
144 sizeof(struct acpi_table_header));
156 new_table->length = (u32) table_size; 145 new_table->length = (u32) table_size;
157 146
158 /* Copy the table pointers */ 147 /* Copy the table pointers */
159 148
160 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 149 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
161 if (acpi_gbl_RSDP->revision < 2) { 150 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
162 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], 151
163 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, 152 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
164 table_info->pointer))->table_offset_entry[i]); 153 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
165 } 154 (ACPI_CAST_PTR
166 else { 155 (struct rsdt_descriptor_rev1,
156 table_info->pointer))->
157 table_offset_entry[i]);
158 } else {
167 new_table->table_offset_entry[i] = 159 new_table->table_offset_entry[i] =
168 (ACPI_CAST_PTR (XSDT_DESCRIPTOR, 160 (ACPI_CAST_PTR(XSDT_DESCRIPTOR,
169 table_info->pointer))->table_offset_entry[i]; 161 table_info->pointer))->
162 table_offset_entry[i];
170 } 163 }
171 } 164 }
172 165
173 /* Delete the original table (either mapped or in a buffer) */ 166 /* Delete the original table (either mapped or in a buffer) */
174 167
175 acpi_tb_delete_single_table (table_info); 168 acpi_tb_delete_single_table(table_info);
176 169
177 /* Point the table descriptor to the new table */ 170 /* Point the table descriptor to the new table */
178 171
179 table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table); 172 table_info->pointer =
180 table_info->length = table_size; 173 ACPI_CAST_PTR(struct acpi_table_header, new_table);
181 table_info->allocation = ACPI_MEM_ALLOCATED; 174 table_info->length = table_size;
175 table_info->allocation = ACPI_MEM_ALLOCATED;
182 176
183 return (AE_OK); 177 return (AE_OK);
184} 178}
185 179
186
187/******************************************************************************* 180/*******************************************************************************
188 * 181 *
189 * FUNCTION: acpi_tb_init_generic_address 182 * FUNCTION: acpi_tb_init_generic_address
@@ -199,21 +192,19 @@ acpi_tb_convert_to_xsdt (
199 ******************************************************************************/ 192 ******************************************************************************/
200 193
201static void 194static void
202acpi_tb_init_generic_address ( 195acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
203 struct acpi_generic_address *new_gas_struct, 196 u8 register_bit_width,
204 u8 register_bit_width, 197 acpi_physical_address address)
205 acpi_physical_address address)
206{ 198{
207 199
208 ACPI_STORE_ADDRESS (new_gas_struct->address, address); 200 ACPI_STORE_ADDRESS(new_gas_struct->address, address);
209 201
210 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 202 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
211 new_gas_struct->register_bit_width = register_bit_width; 203 new_gas_struct->register_bit_width = register_bit_width;
212 new_gas_struct->register_bit_offset = 0; 204 new_gas_struct->register_bit_offset = 0;
213 new_gas_struct->access_width = 0; 205 new_gas_struct->access_width = 0;
214} 206}
215 207
216
217/******************************************************************************* 208/*******************************************************************************
218 * 209 *
219 * FUNCTION: acpi_tb_convert_fadt1 210 * FUNCTION: acpi_tb_convert_fadt1
@@ -228,9 +219,8 @@ acpi_tb_init_generic_address (
228 ******************************************************************************/ 219 ******************************************************************************/
229 220
230static void 221static void
231acpi_tb_convert_fadt1 ( 222acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
232 struct fadt_descriptor_rev2 *local_fadt, 223 struct fadt_descriptor_rev1 *original_fadt)
233 struct fadt_descriptor_rev1 *original_fadt)
234{ 224{
235 225
236 /* ACPI 1.0 FACS */ 226 /* ACPI 1.0 FACS */
@@ -243,12 +233,14 @@ acpi_tb_convert_fadt1 (
243 * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 233 * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
244 * table can be copied first, then expand some fields to 64 bits. 234 * table can be copied first, then expand some fields to 64 bits.
245 */ 235 */
246 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1)); 236 ACPI_MEMCPY(local_fadt, original_fadt,
237 sizeof(struct fadt_descriptor_rev1));
247 238
248 /* Convert table pointers to 64-bit fields */ 239 /* Convert table pointers to 64-bit fields */
249 240
250 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); 241 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
251 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 242 local_fadt->V1_firmware_ctrl);
243 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
252 244
253 /* 245 /*
254 * System Interrupt Model isn't used in ACPI 2.0 246 * System Interrupt Model isn't used in ACPI 2.0
@@ -283,17 +275,17 @@ acpi_tb_convert_fadt1 (
283 * It primarily adds the FADT reset mechanism. 275 * It primarily adds the FADT reset mechanism.
284 */ 276 */
285 if ((original_fadt->revision == 2) && 277 if ((original_fadt->revision == 2) &&
286 (original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) { 278 (original_fadt->length ==
279 sizeof(struct fadt_descriptor_rev2_minus))) {
287 /* 280 /*
288 * Grab the entire generic address struct, plus the 1-byte reset value 281 * Grab the entire generic address struct, plus the 1-byte reset value
289 * that immediately follows. 282 * that immediately follows.
290 */ 283 */
291 ACPI_MEMCPY (&local_fadt->reset_register, 284 ACPI_MEMCPY(&local_fadt->reset_register,
292 &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, 285 &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus,
293 original_fadt))->reset_register, 286 original_fadt))->reset_register,
294 sizeof (struct acpi_generic_address) + 1); 287 sizeof(struct acpi_generic_address) + 1);
295 } 288 } else {
296 else {
297 /* 289 /*
298 * Since there isn't any equivalence in 1.0 and since it is highly 290 * Since there isn't any equivalence in 1.0 and since it is highly
299 * likely that a 1.0 system has legacy support. 291 * likely that a 1.0 system has legacy support.
@@ -304,43 +296,60 @@ acpi_tb_convert_fadt1 (
304 /* 296 /*
305 * Convert the V1.0 block addresses to V2.0 GAS structures 297 * Convert the V1.0 block addresses to V2.0 GAS structures
306 */ 298 */
307 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len, 299 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
308 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 300 local_fadt->pm1_evt_len,
309 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len, 301 (acpi_physical_address) local_fadt->
310 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 302 V1_pm1a_evt_blk);
311 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len, 303 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
312 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 304 local_fadt->pm1_evt_len,
313 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len, 305 (acpi_physical_address) local_fadt->
314 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 306 V1_pm1b_evt_blk);
315 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len, 307 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
316 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 308 local_fadt->pm1_cnt_len,
317 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len, 309 (acpi_physical_address) local_fadt->
318 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 310 V1_pm1a_cnt_blk);
319 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0, 311 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
320 (acpi_physical_address) local_fadt->V1_gpe0_blk); 312 local_fadt->pm1_cnt_len,
321 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0, 313 (acpi_physical_address) local_fadt->
322 (acpi_physical_address) local_fadt->V1_gpe1_blk); 314 V1_pm1b_cnt_blk);
315 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
316 local_fadt->pm2_cnt_len,
317 (acpi_physical_address) local_fadt->
318 V1_pm2_cnt_blk);
319 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
320 local_fadt->pm_tm_len,
321 (acpi_physical_address) local_fadt->
322 V1_pm_tmr_blk);
323 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, 0,
324 (acpi_physical_address) local_fadt->
325 V1_gpe0_blk);
326 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, 0,
327 (acpi_physical_address) local_fadt->
328 V1_gpe1_blk);
323 329
324 /* Create separate GAS structs for the PM1 Enable registers */ 330 /* Create separate GAS structs for the PM1 Enable registers */
325 331
326 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 332 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
327 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 333 (u8) ACPI_DIV_2(acpi_gbl_FADT->
328 (acpi_physical_address) 334 pm1_evt_len),
329 (local_fadt->xpm1a_evt_blk.address + 335 (acpi_physical_address)
330 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 336 (local_fadt->xpm1a_evt_blk.address +
337 ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
331 338
332 /* PM1B is optional; leave null if not present */ 339 /* PM1B is optional; leave null if not present */
333 340
334 if (local_fadt->xpm1b_evt_blk.address) { 341 if (local_fadt->xpm1b_evt_blk.address) {
335 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 342 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
336 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 343 (u8) ACPI_DIV_2(acpi_gbl_FADT->
337 (acpi_physical_address) 344 pm1_evt_len),
338 (local_fadt->xpm1b_evt_blk.address + 345 (acpi_physical_address)
339 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 346 (local_fadt->xpm1b_evt_blk.
347 address +
348 ACPI_DIV_2(acpi_gbl_FADT->
349 pm1_evt_len)));
340 } 350 }
341} 351}
342 352
343
344/******************************************************************************* 353/*******************************************************************************
345 * 354 *
346 * FUNCTION: acpi_tb_convert_fadt2 355 * FUNCTION: acpi_tb_convert_fadt2
@@ -356,14 +365,14 @@ acpi_tb_convert_fadt1 (
356 ******************************************************************************/ 365 ******************************************************************************/
357 366
358static void 367static void
359acpi_tb_convert_fadt2 ( 368acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
360 struct fadt_descriptor_rev2 *local_fadt, 369 struct fadt_descriptor_rev2 *original_fadt)
361 struct fadt_descriptor_rev2 *original_fadt)
362{ 370{
363 371
364 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ 372 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
365 373
366 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2)); 374 ACPI_MEMCPY(local_fadt, original_fadt,
375 sizeof(struct fadt_descriptor_rev2));
367 376
368 /* 377 /*
369 * "X" fields are optional extensions to the original V1.0 fields, so 378 * "X" fields are optional extensions to the original V1.0 fields, so
@@ -371,86 +380,99 @@ acpi_tb_convert_fadt2 (
371 * is zero. 380 * is zero.
372 */ 381 */
373 if (!(local_fadt->xfirmware_ctrl)) { 382 if (!(local_fadt->xfirmware_ctrl)) {
374 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, 383 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
375 local_fadt->V1_firmware_ctrl); 384 local_fadt->V1_firmware_ctrl);
376 } 385 }
377 386
378 if (!(local_fadt->Xdsdt)) { 387 if (!(local_fadt->Xdsdt)) {
379 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 388 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
380 } 389 }
381 390
382 if (!(local_fadt->xpm1a_evt_blk.address)) { 391 if (!(local_fadt->xpm1a_evt_blk.address)) {
383 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, 392 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
384 local_fadt->pm1_evt_len, 393 local_fadt->pm1_evt_len,
385 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 394 (acpi_physical_address)
395 local_fadt->V1_pm1a_evt_blk);
386 } 396 }
387 397
388 if (!(local_fadt->xpm1b_evt_blk.address)) { 398 if (!(local_fadt->xpm1b_evt_blk.address)) {
389 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, 399 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
390 local_fadt->pm1_evt_len, 400 local_fadt->pm1_evt_len,
391 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 401 (acpi_physical_address)
402 local_fadt->V1_pm1b_evt_blk);
392 } 403 }
393 404
394 if (!(local_fadt->xpm1a_cnt_blk.address)) { 405 if (!(local_fadt->xpm1a_cnt_blk.address)) {
395 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, 406 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
396 local_fadt->pm1_cnt_len, 407 local_fadt->pm1_cnt_len,
397 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 408 (acpi_physical_address)
409 local_fadt->V1_pm1a_cnt_blk);
398 } 410 }
399 411
400 if (!(local_fadt->xpm1b_cnt_blk.address)) { 412 if (!(local_fadt->xpm1b_cnt_blk.address)) {
401 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, 413 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
402 local_fadt->pm1_cnt_len, 414 local_fadt->pm1_cnt_len,
403 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 415 (acpi_physical_address)
416 local_fadt->V1_pm1b_cnt_blk);
404 } 417 }
405 418
406 if (!(local_fadt->xpm2_cnt_blk.address)) { 419 if (!(local_fadt->xpm2_cnt_blk.address)) {
407 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, 420 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
408 local_fadt->pm2_cnt_len, 421 local_fadt->pm2_cnt_len,
409 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 422 (acpi_physical_address)
423 local_fadt->V1_pm2_cnt_blk);
410 } 424 }
411 425
412 if (!(local_fadt->xpm_tmr_blk.address)) { 426 if (!(local_fadt->xpm_tmr_blk.address)) {
413 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, 427 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
414 local_fadt->pm_tm_len, 428 local_fadt->pm_tm_len,
415 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 429 (acpi_physical_address)
430 local_fadt->V1_pm_tmr_blk);
416 } 431 }
417 432
418 if (!(local_fadt->xgpe0_blk.address)) { 433 if (!(local_fadt->xgpe0_blk.address)) {
419 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 434 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk,
420 0, (acpi_physical_address) local_fadt->V1_gpe0_blk); 435 0,
436 (acpi_physical_address)
437 local_fadt->V1_gpe0_blk);
421 } 438 }
422 439
423 if (!(local_fadt->xgpe1_blk.address)) { 440 if (!(local_fadt->xgpe1_blk.address)) {
424 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 441 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk,
425 0, (acpi_physical_address) local_fadt->V1_gpe1_blk); 442 0,
443 (acpi_physical_address)
444 local_fadt->V1_gpe1_blk);
426 } 445 }
427 446
428 /* Create separate GAS structs for the PM1 Enable registers */ 447 /* Create separate GAS structs for the PM1 Enable registers */
429 448
430 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 449 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
431 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 450 (u8) ACPI_DIV_2(acpi_gbl_FADT->
432 (acpi_physical_address) 451 pm1_evt_len),
433 (local_fadt->xpm1a_evt_blk.address + 452 (acpi_physical_address)
434 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 453 (local_fadt->xpm1a_evt_blk.address +
454 ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
435 455
436 acpi_gbl_xpm1a_enable.address_space_id = 456 acpi_gbl_xpm1a_enable.address_space_id =
437 local_fadt->xpm1a_evt_blk.address_space_id; 457 local_fadt->xpm1a_evt_blk.address_space_id;
438 458
439 /* PM1B is optional; leave null if not present */ 459 /* PM1B is optional; leave null if not present */
440 460
441 if (local_fadt->xpm1b_evt_blk.address) { 461 if (local_fadt->xpm1b_evt_blk.address) {
442 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 462 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
443 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 463 (u8) ACPI_DIV_2(acpi_gbl_FADT->
444 (acpi_physical_address) 464 pm1_evt_len),
445 (local_fadt->xpm1b_evt_blk.address + 465 (acpi_physical_address)
446 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 466 (local_fadt->xpm1b_evt_blk.
467 address +
468 ACPI_DIV_2(acpi_gbl_FADT->
469 pm1_evt_len)));
447 470
448 acpi_gbl_xpm1b_enable.address_space_id = 471 acpi_gbl_xpm1b_enable.address_space_id =
449 local_fadt->xpm1b_evt_blk.address_space_id; 472 local_fadt->xpm1b_evt_blk.address_space_id;
450 } 473 }
451} 474}
452 475
453
454/******************************************************************************* 476/*******************************************************************************
455 * 477 *
456 * FUNCTION: acpi_tb_convert_table_fadt 478 * FUNCTION: acpi_tb_convert_table_fadt
@@ -467,83 +489,76 @@ acpi_tb_convert_fadt2 (
467 * 489 *
468 ******************************************************************************/ 490 ******************************************************************************/
469 491
470acpi_status 492acpi_status acpi_tb_convert_table_fadt(void)
471acpi_tb_convert_table_fadt (
472 void)
473{ 493{
474 struct fadt_descriptor_rev2 *local_fadt; 494 struct fadt_descriptor_rev2 *local_fadt;
475 struct acpi_table_desc *table_desc; 495 struct acpi_table_desc *table_desc;
476
477
478 ACPI_FUNCTION_TRACE ("tb_convert_table_fadt");
479 496
497 ACPI_FUNCTION_TRACE("tb_convert_table_fadt");
480 498
481 /* 499 /*
482 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be 500 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
483 * at least as long as the version 1.0 FADT 501 * at least as long as the version 1.0 FADT
484 */ 502 */
485 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { 503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
486 ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", 504 ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n",
487 acpi_gbl_FADT->length)); 505 acpi_gbl_FADT->length));
488 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
489 } 507 }
490 508
491 /* Allocate buffer for the ACPI 2.0(+) FADT */ 509 /* Allocate buffer for the ACPI 2.0(+) FADT */
492 510
493 local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2)); 511 local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2));
494 if (!local_fadt) { 512 if (!local_fadt) {
495 return_ACPI_STATUS (AE_NO_MEMORY); 513 return_ACPI_STATUS(AE_NO_MEMORY);
496 } 514 }
497 515
498 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { 516 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
499 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { 517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) {
500 /* Length is too short to be a V2.0 table */ 518 /* Length is too short to be a V2.0 table */
501 519
502 ACPI_REPORT_WARNING (( 520 ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
503 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
504 acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
505 521
506 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 522 acpi_tb_convert_fadt1(local_fadt,
507 } 523 (void *)acpi_gbl_FADT);
508 else { 524 } else {
509 /* Valid V2.0 table */ 525 /* Valid V2.0 table */
510 526
511 acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT); 527 acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT);
512 } 528 }
513 } 529 } else {
514 else {
515 /* Valid V1.0 table */ 530 /* Valid V1.0 table */
516 531
517 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 532 acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT);
518 } 533 }
519 534
520 /* Global FADT pointer will point to the new common V2.0 FADT */ 535 /* Global FADT pointer will point to the new common V2.0 FADT */
521 536
522 acpi_gbl_FADT = local_fadt; 537 acpi_gbl_FADT = local_fadt;
523 acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); 538 acpi_gbl_FADT->length = sizeof(FADT_DESCRIPTOR);
524 539
525 /* Free the original table */ 540 /* Free the original table */
526 541
527 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; 542 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next;
528 acpi_tb_delete_single_table (table_desc); 543 acpi_tb_delete_single_table(table_desc);
529 544
530 /* Install the new table */ 545 /* Install the new table */
531 546
532 table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT); 547 table_desc->pointer =
533 table_desc->allocation = ACPI_MEM_ALLOCATED; 548 ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
534 table_desc->length = sizeof (struct fadt_descriptor_rev2); 549 table_desc->allocation = ACPI_MEM_ALLOCATED;
550 table_desc->length = sizeof(struct fadt_descriptor_rev2);
535 551
536 /* Dump the entire FADT */ 552 /* Dump the entire FADT */
537 553
538 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
539 "Hex dump of common internal FADT, size %d (%X)\n", 555 "Hex dump of common internal FADT, size %d (%X)\n",
540 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 556 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
541 ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length);
542 558
543 return_ACPI_STATUS (AE_OK); 559 return_ACPI_STATUS(AE_OK);
544} 560}
545 561
546
547/******************************************************************************* 562/*******************************************************************************
548 * 563 *
549 * FUNCTION: acpi_tb_build_common_facs 564 * FUNCTION: acpi_tb_build_common_facs
@@ -557,26 +572,21 @@ acpi_tb_convert_table_fadt (
557 * 572 *
558 ******************************************************************************/ 573 ******************************************************************************/
559 574
560acpi_status 575acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
561acpi_tb_build_common_facs (
562 struct acpi_table_desc *table_info)
563{ 576{
564 577
565 ACPI_FUNCTION_TRACE ("tb_build_common_facs"); 578 ACPI_FUNCTION_TRACE("tb_build_common_facs");
566
567 579
568 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 580 /* Absolute minimum length is 24, but the ACPI spec says 64 */
569 581
570 if (acpi_gbl_FACS->length < 24) { 582 if (acpi_gbl_FACS->length < 24) {
571 ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", 583 ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n",
572 acpi_gbl_FACS->length)); 584 acpi_gbl_FACS->length));
573 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 585 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
574 } 586 }
575 587
576 if (acpi_gbl_FACS->length < 64) { 588 if (acpi_gbl_FACS->length < 64) {
577 ACPI_REPORT_WARNING (( 589 ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length));
578 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
579 acpi_gbl_FACS->length));
580 } 590 }
581 591
582 /* Copy fields to the new FACS */ 592 /* Copy fields to the new FACS */
@@ -584,22 +594,22 @@ acpi_tb_build_common_facs (
584 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock); 594 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
585 595
586 if ((acpi_gbl_RSDP->revision < 2) || 596 if ((acpi_gbl_RSDP->revision < 2) ||
587 (acpi_gbl_FACS->length < 32) || 597 (acpi_gbl_FACS->length < 32) ||
588 (!(acpi_gbl_FACS->xfirmware_waking_vector))) { 598 (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
589 /* ACPI 1.0 FACS or short table or optional X_ field is zero */ 599 /* ACPI 1.0 FACS or short table or optional X_ field is zero */
590 600
591 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, 601 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
592 &(acpi_gbl_FACS->firmware_waking_vector)); 602 &
603 (acpi_gbl_FACS->
604 firmware_waking_vector));
593 acpi_gbl_common_fACS.vector_width = 32; 605 acpi_gbl_common_fACS.vector_width = 32;
594 } 606 } else {
595 else {
596 /* ACPI 2.0 FACS with valid X_ field */ 607 /* ACPI 2.0 FACS with valid X_ field */
597 608
598 acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector; 609 acpi_gbl_common_fACS.firmware_waking_vector =
610 &acpi_gbl_FACS->xfirmware_waking_vector;
599 acpi_gbl_common_fACS.vector_width = 64; 611 acpi_gbl_common_fACS.vector_width = 64;
600 } 612 }
601 613
602 return_ACPI_STATUS (AE_OK); 614 return_ACPI_STATUS(AE_OK);
603} 615}
604
605
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 4ab2aadc6133..6acd5aeb093e 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -41,27 +41,21 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbget") 48ACPI_MODULE_NAME("tbget")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_get_this_table ( 52acpi_tb_get_this_table(struct acpi_pointer *address,
56 struct acpi_pointer *address, 53 struct acpi_table_header *header,
57 struct acpi_table_header *header, 54 struct acpi_table_desc *table_info);
58 struct acpi_table_desc *table_info);
59 55
60static acpi_status 56static acpi_status
61acpi_tb_table_override ( 57acpi_tb_table_override(struct acpi_table_header *header,
62 struct acpi_table_header *header, 58 struct acpi_table_desc *table_info);
63 struct acpi_table_desc *table_info);
64
65 59
66/******************************************************************************* 60/*******************************************************************************
67 * 61 *
@@ -78,37 +72,34 @@ acpi_tb_table_override (
78 ******************************************************************************/ 72 ******************************************************************************/
79 73
80acpi_status 74acpi_status
81acpi_tb_get_table ( 75acpi_tb_get_table(struct acpi_pointer *address,
82 struct acpi_pointer *address, 76 struct acpi_table_desc *table_info)
83 struct acpi_table_desc *table_info)
84{ 77{
85 acpi_status status; 78 acpi_status status;
86 struct acpi_table_header header; 79 struct acpi_table_header header;
87
88
89 ACPI_FUNCTION_TRACE ("tb_get_table");
90 80
81 ACPI_FUNCTION_TRACE("tb_get_table");
91 82
92 /* Get the header in order to get signature and table size */ 83 /* Get the header in order to get signature and table size */
93 84
94 status = acpi_tb_get_table_header (address, &header); 85 status = acpi_tb_get_table_header(address, &header);
95 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
96 return_ACPI_STATUS (status); 87 return_ACPI_STATUS(status);
97 } 88 }
98 89
99 /* Get the entire table */ 90 /* Get the entire table */
100 91
101 status = acpi_tb_get_table_body (address, &header, table_info); 92 status = acpi_tb_get_table_body(address, &header, table_info);
102 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n", 94 ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n",
104 header.length, acpi_format_exception (status))); 95 header.length,
105 return_ACPI_STATUS (status); 96 acpi_format_exception(status)));
97 return_ACPI_STATUS(status);
106 } 98 }
107 99
108 return_ACPI_STATUS (AE_OK); 100 return_ACPI_STATUS(AE_OK);
109} 101}
110 102
111
112/******************************************************************************* 103/*******************************************************************************
113 * 104 *
114 * FUNCTION: acpi_tb_get_table_header 105 * FUNCTION: acpi_tb_get_table_header
@@ -127,16 +118,13 @@ acpi_tb_get_table (
127 ******************************************************************************/ 118 ******************************************************************************/
128 119
129acpi_status 120acpi_status
130acpi_tb_get_table_header ( 121acpi_tb_get_table_header(struct acpi_pointer *address,
131 struct acpi_pointer *address, 122 struct acpi_table_header *return_header)
132 struct acpi_table_header *return_header)
133{ 123{
134 acpi_status status = AE_OK; 124 acpi_status status = AE_OK;
135 struct acpi_table_header *header = NULL; 125 struct acpi_table_header *header = NULL;
136
137
138 ACPI_FUNCTION_TRACE ("tb_get_table_header");
139 126
127 ACPI_FUNCTION_TRACE("tb_get_table_header");
140 128
141 /* 129 /*
142 * Flags contains the current processor mode (Virtual or Physical 130 * Flags contains the current processor mode (Virtual or Physical
@@ -148,46 +136,42 @@ acpi_tb_get_table_header (
148 136
149 /* Pointer matches processor mode, copy the header */ 137 /* Pointer matches processor mode, copy the header */
150 138
151 ACPI_MEMCPY (return_header, address->pointer.logical, 139 ACPI_MEMCPY(return_header, address->pointer.logical,
152 sizeof (struct acpi_table_header)); 140 sizeof(struct acpi_table_header));
153 break; 141 break;
154 142
155
156 case ACPI_LOGMODE_PHYSPTR: 143 case ACPI_LOGMODE_PHYSPTR:
157 144
158 /* Create a logical address for the physical pointer*/ 145 /* Create a logical address for the physical pointer */
159 146
160 status = acpi_os_map_memory (address->pointer.physical, 147 status = acpi_os_map_memory(address->pointer.physical,
161 sizeof (struct acpi_table_header), (void *) &header); 148 sizeof(struct acpi_table_header),
162 if (ACPI_FAILURE (status)) { 149 (void *)&header);
163 ACPI_REPORT_ERROR (( 150 if (ACPI_FAILURE(status)) {
164 "Could not map memory at %8.8X%8.8X for length %X\n", 151 ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header)));
165 ACPI_FORMAT_UINT64 (address->pointer.physical), 152 return_ACPI_STATUS(status);
166 sizeof (struct acpi_table_header)));
167 return_ACPI_STATUS (status);
168 } 153 }
169 154
170 /* Copy header and delete mapping */ 155 /* Copy header and delete mapping */
171 156
172 ACPI_MEMCPY (return_header, header, sizeof (struct acpi_table_header)); 157 ACPI_MEMCPY(return_header, header,
173 acpi_os_unmap_memory (header, sizeof (struct acpi_table_header)); 158 sizeof(struct acpi_table_header));
159 acpi_os_unmap_memory(header, sizeof(struct acpi_table_header));
174 break; 160 break;
175 161
176
177 default: 162 default:
178 163
179 ACPI_REPORT_ERROR (("Invalid address flags %X\n", 164 ACPI_REPORT_ERROR(("Invalid address flags %X\n",
180 address->pointer_type)); 165 address->pointer_type));
181 return_ACPI_STATUS (AE_BAD_PARAMETER); 166 return_ACPI_STATUS(AE_BAD_PARAMETER);
182 } 167 }
183 168
184 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n",
185 return_header->signature)); 170 return_header->signature));
186 171
187 return_ACPI_STATUS (AE_OK); 172 return_ACPI_STATUS(AE_OK);
188} 173}
189 174
190
191/******************************************************************************* 175/*******************************************************************************
192 * 176 *
193 * FUNCTION: acpi_tb_get_table_body 177 * FUNCTION: acpi_tb_get_table_body
@@ -209,37 +193,33 @@ acpi_tb_get_table_header (
209 ******************************************************************************/ 193 ******************************************************************************/
210 194
211acpi_status 195acpi_status
212acpi_tb_get_table_body ( 196acpi_tb_get_table_body(struct acpi_pointer *address,
213 struct acpi_pointer *address, 197 struct acpi_table_header *header,
214 struct acpi_table_header *header, 198 struct acpi_table_desc *table_info)
215 struct acpi_table_desc *table_info)
216{ 199{
217 acpi_status status; 200 acpi_status status;
218
219
220 ACPI_FUNCTION_TRACE ("tb_get_table_body");
221 201
202 ACPI_FUNCTION_TRACE("tb_get_table_body");
222 203
223 if (!table_info || !address) { 204 if (!table_info || !address) {
224 return_ACPI_STATUS (AE_BAD_PARAMETER); 205 return_ACPI_STATUS(AE_BAD_PARAMETER);
225 } 206 }
226 207
227 /* Attempt table override. */ 208 /* Attempt table override. */
228 209
229 status = acpi_tb_table_override (header, table_info); 210 status = acpi_tb_table_override(header, table_info);
230 if (ACPI_SUCCESS (status)) { 211 if (ACPI_SUCCESS(status)) {
231 /* Table was overridden by the host OS */ 212 /* Table was overridden by the host OS */
232 213
233 return_ACPI_STATUS (status); 214 return_ACPI_STATUS(status);
234 } 215 }
235 216
236 /* No override, get the original table */ 217 /* No override, get the original table */
237 218
238 status = acpi_tb_get_this_table (address, header, table_info); 219 status = acpi_tb_get_this_table(address, header, table_info);
239 return_ACPI_STATUS (status); 220 return_ACPI_STATUS(status);
240} 221}
241 222
242
243/******************************************************************************* 223/*******************************************************************************
244 * 224 *
245 * FUNCTION: acpi_tb_table_override 225 * FUNCTION: acpi_tb_table_override
@@ -255,61 +235,57 @@ acpi_tb_get_table_body (
255 ******************************************************************************/ 235 ******************************************************************************/
256 236
257static acpi_status 237static acpi_status
258acpi_tb_table_override ( 238acpi_tb_table_override(struct acpi_table_header *header,
259 struct acpi_table_header *header, 239 struct acpi_table_desc *table_info)
260 struct acpi_table_desc *table_info)
261{ 240{
262 struct acpi_table_header *new_table; 241 struct acpi_table_header *new_table;
263 acpi_status status; 242 acpi_status status;
264 struct acpi_pointer address; 243 struct acpi_pointer address;
265
266
267 ACPI_FUNCTION_TRACE ("tb_table_override");
268 244
245 ACPI_FUNCTION_TRACE("tb_table_override");
269 246
270 /* 247 /*
271 * The OSL will examine the header and decide whether to override this 248 * The OSL will examine the header and decide whether to override this
272 * table. If it decides to override, a table will be returned in new_table, 249 * table. If it decides to override, a table will be returned in new_table,
273 * which we will then copy. 250 * which we will then copy.
274 */ 251 */
275 status = acpi_os_table_override (header, &new_table); 252 status = acpi_os_table_override(header, &new_table);
276 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
277 /* Some severe error from the OSL, but we basically ignore it */ 254 /* Some severe error from the OSL, but we basically ignore it */
278 255
279 ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n", 256 ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n",
280 acpi_format_exception (status))); 257 acpi_format_exception(status)));
281 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
282 } 259 }
283 260
284 if (!new_table) { 261 if (!new_table) {
285 /* No table override */ 262 /* No table override */
286 263
287 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 264 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
288 } 265 }
289 266
290 /* 267 /*
291 * We have a new table to override the old one. Get a copy of 268 * We have a new table to override the old one. Get a copy of
292 * the new one. We know that the new table has a logical pointer. 269 * the new one. We know that the new table has a logical pointer.
293 */ 270 */
294 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; 271 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
295 address.pointer.logical = new_table; 272 address.pointer.logical = new_table;
296 273
297 status = acpi_tb_get_this_table (&address, new_table, table_info); 274 status = acpi_tb_get_this_table(&address, new_table, table_info);
298 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
299 ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n", 276 ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n",
300 acpi_format_exception (status))); 277 acpi_format_exception(status)));
301 return_ACPI_STATUS (status); 278 return_ACPI_STATUS(status);
302 } 279 }
303 280
304 /* Copy the table info */ 281 /* Copy the table info */
305 282
306 ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n", 283 ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n",
307 table_info->pointer->signature)); 284 table_info->pointer->signature));
308 285
309 return_ACPI_STATUS (AE_OK); 286 return_ACPI_STATUS(AE_OK);
310} 287}
311 288
312
313/******************************************************************************* 289/*******************************************************************************
314 * 290 *
315 * FUNCTION: acpi_tb_get_this_table 291 * FUNCTION: acpi_tb_get_this_table
@@ -329,18 +305,15 @@ acpi_tb_table_override (
329 ******************************************************************************/ 305 ******************************************************************************/
330 306
331static acpi_status 307static acpi_status
332acpi_tb_get_this_table ( 308acpi_tb_get_this_table(struct acpi_pointer *address,
333 struct acpi_pointer *address, 309 struct acpi_table_header *header,
334 struct acpi_table_header *header, 310 struct acpi_table_desc *table_info)
335 struct acpi_table_desc *table_info)
336{ 311{
337 struct acpi_table_header *full_table = NULL; 312 struct acpi_table_header *full_table = NULL;
338 u8 allocation; 313 u8 allocation;
339 acpi_status status = AE_OK; 314 acpi_status status = AE_OK;
340
341
342 ACPI_FUNCTION_TRACE ("tb_get_this_table");
343 315
316 ACPI_FUNCTION_TRACE("tb_get_this_table");
344 317
345 /* 318 /*
346 * Flags contains the current processor mode (Virtual or Physical 319 * Flags contains the current processor mode (Virtual or Physical
@@ -352,38 +325,33 @@ acpi_tb_get_this_table (
352 325
353 /* Pointer matches processor mode, copy the table to a new buffer */ 326 /* Pointer matches processor mode, copy the table to a new buffer */
354 327
355 full_table = ACPI_MEM_ALLOCATE (header->length); 328 full_table = ACPI_MEM_ALLOCATE(header->length);
356 if (!full_table) { 329 if (!full_table) {
357 ACPI_REPORT_ERROR (( 330 ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length));
358 "Could not allocate table memory for [%4.4s] length %X\n", 331 return_ACPI_STATUS(AE_NO_MEMORY);
359 header->signature, header->length));
360 return_ACPI_STATUS (AE_NO_MEMORY);
361 } 332 }
362 333
363 /* Copy the entire table (including header) to the local buffer */ 334 /* Copy the entire table (including header) to the local buffer */
364 335
365 ACPI_MEMCPY (full_table, address->pointer.logical, header->length); 336 ACPI_MEMCPY(full_table, address->pointer.logical,
337 header->length);
366 338
367 /* Save allocation type */ 339 /* Save allocation type */
368 340
369 allocation = ACPI_MEM_ALLOCATED; 341 allocation = ACPI_MEM_ALLOCATED;
370 break; 342 break;
371 343
372
373 case ACPI_LOGMODE_PHYSPTR: 344 case ACPI_LOGMODE_PHYSPTR:
374 345
375 /* 346 /*
376 * Just map the table's physical memory 347 * Just map the table's physical memory
377 * into our address space. 348 * into our address space.
378 */ 349 */
379 status = acpi_os_map_memory (address->pointer.physical, 350 status = acpi_os_map_memory(address->pointer.physical,
380 (acpi_size) header->length, (void *) &full_table); 351 (acpi_size) header->length,
381 if (ACPI_FAILURE (status)) { 352 (void *)&full_table);
382 ACPI_REPORT_ERROR (( 353 if (ACPI_FAILURE(status)) {
383 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", 354 ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length));
384 header->signature,
385 ACPI_FORMAT_UINT64 (address->pointer.physical),
386 header->length));
387 return (status); 355 return (status);
388 } 356 }
389 357
@@ -392,12 +360,11 @@ acpi_tb_get_this_table (
392 allocation = ACPI_MEM_MAPPED; 360 allocation = ACPI_MEM_MAPPED;
393 break; 361 break;
394 362
395
396 default: 363 default:
397 364
398 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n", 365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n",
399 address->pointer_type)); 366 address->pointer_type));
400 return_ACPI_STATUS (AE_BAD_PARAMETER); 367 return_ACPI_STATUS(AE_BAD_PARAMETER);
401 } 368 }
402 369
403 /* 370 /*
@@ -405,10 +372,10 @@ acpi_tb_get_this_table (
405 * even the ones whose signature we don't recognize 372 * even the ones whose signature we don't recognize
406 */ 373 */
407 if (table_info->type != ACPI_TABLE_FACS) { 374 if (table_info->type != ACPI_TABLE_FACS) {
408 status = acpi_tb_verify_table_checksum (full_table); 375 status = acpi_tb_verify_table_checksum(full_table);
409 376
410#if (!ACPI_CHECKSUM_ABORT) 377#if (!ACPI_CHECKSUM_ABORT)
411 if (ACPI_FAILURE (status)) { 378 if (ACPI_FAILURE(status)) {
412 /* Ignore the error if configuration says so */ 379 /* Ignore the error if configuration says so */
413 380
414 status = AE_OK; 381 status = AE_OK;
@@ -418,19 +385,19 @@ acpi_tb_get_this_table (
418 385
419 /* Return values */ 386 /* Return values */
420 387
421 table_info->pointer = full_table; 388 table_info->pointer = full_table;
422 table_info->length = (acpi_size) header->length; 389 table_info->length = (acpi_size) header->length;
423 table_info->allocation = allocation; 390 table_info->allocation = allocation;
424 391
425 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 392 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
426 "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n", 393 "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n",
427 full_table->signature, 394 full_table->signature,
428 ACPI_FORMAT_UINT64 (address->pointer.physical), full_table)); 395 ACPI_FORMAT_UINT64(address->pointer.physical),
396 full_table));
429 397
430 return_ACPI_STATUS (status); 398 return_ACPI_STATUS(status);
431} 399}
432 400
433
434/******************************************************************************* 401/*******************************************************************************
435 * 402 *
436 * FUNCTION: acpi_tb_get_table_ptr 403 * FUNCTION: acpi_tb_get_table_ptr
@@ -447,24 +414,20 @@ acpi_tb_get_this_table (
447 ******************************************************************************/ 414 ******************************************************************************/
448 415
449acpi_status 416acpi_status
450acpi_tb_get_table_ptr ( 417acpi_tb_get_table_ptr(acpi_table_type table_type,
451 acpi_table_type table_type, 418 u32 instance, struct acpi_table_header **table_ptr_loc)
452 u32 instance,
453 struct acpi_table_header **table_ptr_loc)
454{ 419{
455 struct acpi_table_desc *table_desc; 420 struct acpi_table_desc *table_desc;
456 u32 i; 421 u32 i;
457
458
459 ACPI_FUNCTION_TRACE ("tb_get_table_ptr");
460 422
423 ACPI_FUNCTION_TRACE("tb_get_table_ptr");
461 424
462 if (!acpi_gbl_DSDT) { 425 if (!acpi_gbl_DSDT) {
463 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 426 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
464 } 427 }
465 428
466 if (table_type > ACPI_TABLE_MAX) { 429 if (table_type > ACPI_TABLE_MAX) {
467 return_ACPI_STATUS (AE_BAD_PARAMETER); 430 return_ACPI_STATUS(AE_BAD_PARAMETER);
468 } 431 }
469 432
470 /* 433 /*
@@ -476,15 +439,16 @@ acpi_tb_get_table_ptr (
476 439
477 *table_ptr_loc = NULL; 440 *table_ptr_loc = NULL;
478 if (acpi_gbl_table_lists[table_type].next) { 441 if (acpi_gbl_table_lists[table_type].next) {
479 *table_ptr_loc = acpi_gbl_table_lists[table_type].next->pointer; 442 *table_ptr_loc =
443 acpi_gbl_table_lists[table_type].next->pointer;
480 } 444 }
481 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS(AE_OK);
482 } 446 }
483 447
484 /* Check for instance out of range */ 448 /* Check for instance out of range */
485 449
486 if (instance > acpi_gbl_table_lists[table_type].count) { 450 if (instance > acpi_gbl_table_lists[table_type].count) {
487 return_ACPI_STATUS (AE_NOT_EXIST); 451 return_ACPI_STATUS(AE_NOT_EXIST);
488 } 452 }
489 453
490 /* Walk the list to get the desired table 454 /* Walk the list to get the desired table
@@ -503,6 +467,5 @@ acpi_tb_get_table_ptr (
503 467
504 *table_ptr_loc = table_desc->pointer; 468 *table_ptr_loc = table_desc->pointer;
505 469
506 return_ACPI_STATUS (AE_OK); 470 return_ACPI_STATUS(AE_OK);
507} 471}
508
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index eea5b8cb5ebb..8d72343537e7 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -41,27 +41,21 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbgetall") 48ACPI_MODULE_NAME("tbgetall")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_get_primary_table ( 52acpi_tb_get_primary_table(struct acpi_pointer *address,
56 struct acpi_pointer *address, 53 struct acpi_table_desc *table_info);
57 struct acpi_table_desc *table_info);
58 54
59static acpi_status 55static acpi_status
60acpi_tb_get_secondary_table ( 56acpi_tb_get_secondary_table(struct acpi_pointer *address,
61 struct acpi_pointer *address, 57 acpi_string signature,
62 acpi_string signature, 58 struct acpi_table_desc *table_info);
63 struct acpi_table_desc *table_info);
64
65 59
66/******************************************************************************* 60/*******************************************************************************
67 * 61 *
@@ -77,58 +71,54 @@ acpi_tb_get_secondary_table (
77 ******************************************************************************/ 71 ******************************************************************************/
78 72
79static acpi_status 73static acpi_status
80acpi_tb_get_primary_table ( 74acpi_tb_get_primary_table(struct acpi_pointer *address,
81 struct acpi_pointer *address, 75 struct acpi_table_desc *table_info)
82 struct acpi_table_desc *table_info)
83{ 76{
84 acpi_status status; 77 acpi_status status;
85 struct acpi_table_header header; 78 struct acpi_table_header header;
86
87
88 ACPI_FUNCTION_TRACE ("tb_get_primary_table");
89 79
80 ACPI_FUNCTION_TRACE("tb_get_primary_table");
90 81
91 /* Ignore a NULL address in the RSDT */ 82 /* Ignore a NULL address in the RSDT */
92 83
93 if (!address->pointer.value) { 84 if (!address->pointer.value) {
94 return_ACPI_STATUS (AE_OK); 85 return_ACPI_STATUS(AE_OK);
95 } 86 }
96 87
97 /* Get the header in order to get signature and table size */ 88 /* Get the header in order to get signature and table size */
98 89
99 status = acpi_tb_get_table_header (address, &header); 90 status = acpi_tb_get_table_header(address, &header);
100 if (ACPI_FAILURE (status)) { 91 if (ACPI_FAILURE(status)) {
101 return_ACPI_STATUS (status); 92 return_ACPI_STATUS(status);
102 } 93 }
103 94
104 /* Clear the table_info */ 95 /* Clear the table_info */
105 96
106 ACPI_MEMSET (table_info, 0, sizeof (struct acpi_table_desc)); 97 ACPI_MEMSET(table_info, 0, sizeof(struct acpi_table_desc));
107 98
108 /* 99 /*
109 * Check the table signature and make sure it is recognized. 100 * Check the table signature and make sure it is recognized.
110 * Also checks the header checksum 101 * Also checks the header checksum
111 */ 102 */
112 table_info->pointer = &header; 103 table_info->pointer = &header;
113 status = acpi_tb_recognize_table (table_info, ACPI_TABLE_PRIMARY); 104 status = acpi_tb_recognize_table(table_info, ACPI_TABLE_PRIMARY);
114 if (ACPI_FAILURE (status)) { 105 if (ACPI_FAILURE(status)) {
115 return_ACPI_STATUS (status); 106 return_ACPI_STATUS(status);
116 } 107 }
117 108
118 /* Get the entire table */ 109 /* Get the entire table */
119 110
120 status = acpi_tb_get_table_body (address, &header, table_info); 111 status = acpi_tb_get_table_body(address, &header, table_info);
121 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS (status); 113 return_ACPI_STATUS(status);
123 } 114 }
124 115
125 /* Install the table */ 116 /* Install the table */
126 117
127 status = acpi_tb_install_table (table_info); 118 status = acpi_tb_install_table(table_info);
128 return_ACPI_STATUS (status); 119 return_ACPI_STATUS(status);
129} 120}
130 121
131
132/******************************************************************************* 122/*******************************************************************************
133 * 123 *
134 * FUNCTION: acpi_tb_get_secondary_table 124 * FUNCTION: acpi_tb_get_secondary_table
@@ -143,32 +133,27 @@ acpi_tb_get_primary_table (
143 ******************************************************************************/ 133 ******************************************************************************/
144 134
145static acpi_status 135static acpi_status
146acpi_tb_get_secondary_table ( 136acpi_tb_get_secondary_table(struct acpi_pointer *address,
147 struct acpi_pointer *address, 137 acpi_string signature,
148 acpi_string signature, 138 struct acpi_table_desc *table_info)
149 struct acpi_table_desc *table_info)
150{ 139{
151 acpi_status status; 140 acpi_status status;
152 struct acpi_table_header header; 141 struct acpi_table_header header;
153
154
155 ACPI_FUNCTION_TRACE_STR ("tb_get_secondary_table", signature);
156 142
143 ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature);
157 144
158 /* Get the header in order to match the signature */ 145 /* Get the header in order to match the signature */
159 146
160 status = acpi_tb_get_table_header (address, &header); 147 status = acpi_tb_get_table_header(address, &header);
161 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
162 return_ACPI_STATUS (status); 149 return_ACPI_STATUS(status);
163 } 150 }
164 151
165 /* Signature must match request */ 152 /* Signature must match request */
166 153
167 if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) { 154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) {
168 ACPI_REPORT_ERROR (( 155 ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature));
169 "Incorrect table signature - wanted [%s] found [%4.4s]\n", 156 return_ACPI_STATUS(AE_BAD_SIGNATURE);
170 signature, header.signature));
171 return_ACPI_STATUS (AE_BAD_SIGNATURE);
172 } 157 }
173 158
174 /* 159 /*
@@ -176,25 +161,24 @@ acpi_tb_get_secondary_table (
176 * Also checks the header checksum 161 * Also checks the header checksum
177 */ 162 */
178 table_info->pointer = &header; 163 table_info->pointer = &header;
179 status = acpi_tb_recognize_table (table_info, ACPI_TABLE_SECONDARY); 164 status = acpi_tb_recognize_table(table_info, ACPI_TABLE_SECONDARY);
180 if (ACPI_FAILURE (status)) { 165 if (ACPI_FAILURE(status)) {
181 return_ACPI_STATUS (status); 166 return_ACPI_STATUS(status);
182 } 167 }
183 168
184 /* Get the entire table */ 169 /* Get the entire table */
185 170
186 status = acpi_tb_get_table_body (address, &header, table_info); 171 status = acpi_tb_get_table_body(address, &header, table_info);
187 if (ACPI_FAILURE (status)) { 172 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
189 } 174 }
190 175
191 /* Install the table */ 176 /* Install the table */
192 177
193 status = acpi_tb_install_table (table_info); 178 status = acpi_tb_install_table(table_info);
194 return_ACPI_STATUS (status); 179 return_ACPI_STATUS(status);
195} 180}
196 181
197
198/******************************************************************************* 182/*******************************************************************************
199 * 183 *
200 * FUNCTION: acpi_tb_get_required_tables 184 * FUNCTION: acpi_tb_get_required_tables
@@ -214,23 +198,19 @@ acpi_tb_get_secondary_table (
214 * 198 *
215 ******************************************************************************/ 199 ******************************************************************************/
216 200
217acpi_status 201acpi_status acpi_tb_get_required_tables(void)
218acpi_tb_get_required_tables (
219 void)
220{ 202{
221 acpi_status status = AE_OK; 203 acpi_status status = AE_OK;
222 u32 i; 204 u32 i;
223 struct acpi_table_desc table_info; 205 struct acpi_table_desc table_info;
224 struct acpi_pointer address; 206 struct acpi_pointer address;
225
226 207
227 ACPI_FUNCTION_TRACE ("tb_get_required_tables"); 208 ACPI_FUNCTION_TRACE("tb_get_required_tables");
228 209
229 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
230 acpi_gbl_rsdt_table_count)); 211 acpi_gbl_rsdt_table_count));
231 212
232 213 address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
233 address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
234 214
235 /* 215 /*
236 * Loop through all table pointers found in RSDT. 216 * Loop through all table pointers found in RSDT.
@@ -243,84 +223,79 @@ acpi_tb_get_required_tables (
243 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 223 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
244 /* Get the table address from the common internal XSDT */ 224 /* Get the table address from the common internal XSDT */
245 225
246 address.pointer.value = 226 address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
247 acpi_gbl_XSDT->table_offset_entry[i];
248 227
249 /* 228 /*
250 * Get the tables needed by this subsystem (FADT and any SSDTs). 229 * Get the tables needed by this subsystem (FADT and any SSDTs).
251 * NOTE: All other tables are completely ignored at this time. 230 * NOTE: All other tables are completely ignored at this time.
252 */ 231 */
253 status = acpi_tb_get_primary_table (&address, &table_info); 232 status = acpi_tb_get_primary_table(&address, &table_info);
254 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { 233 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
255 ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n", 234 ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value)));
256 acpi_format_exception (status),
257 ACPI_FORMAT_UINT64 (address.pointer.value)));
258 } 235 }
259 } 236 }
260 237
261 /* We must have a FADT to continue */ 238 /* We must have a FADT to continue */
262 239
263 if (!acpi_gbl_FADT) { 240 if (!acpi_gbl_FADT) {
264 ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n")); 241 ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n"));
265 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 242 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
266 } 243 }
267 244
268 /* 245 /*
269 * Convert the FADT to a common format. This allows earlier revisions of 246 * Convert the FADT to a common format. This allows earlier revisions of
270 * the table to coexist with newer versions, using common access code. 247 * the table to coexist with newer versions, using common access code.
271 */ 248 */
272 status = acpi_tb_convert_table_fadt (); 249 status = acpi_tb_convert_table_fadt();
273 if (ACPI_FAILURE (status)) { 250 if (ACPI_FAILURE(status)) {
274 ACPI_REPORT_ERROR (( 251 ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n"));
275 "Could not convert FADT to internal common format\n")); 252 return_ACPI_STATUS(status);
276 return_ACPI_STATUS (status);
277 } 253 }
278 254
279 /* Get the FACS (Pointed to by the FADT) */ 255 /* Get the FACS (Pointed to by the FADT) */
280 256
281 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl; 257 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
282 258
283 status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info); 259 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info);
284 if (ACPI_FAILURE (status)) { 260 if (ACPI_FAILURE(status)) {
285 ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n", 261 ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n",
286 acpi_format_exception (status))); 262 acpi_format_exception(status)));
287 return_ACPI_STATUS (status); 263 return_ACPI_STATUS(status);
288 } 264 }
289 265
290 /* 266 /*
291 * Create the common FACS pointer table 267 * Create the common FACS pointer table
292 * (Contains pointers to the original table) 268 * (Contains pointers to the original table)
293 */ 269 */
294 status = acpi_tb_build_common_facs (&table_info); 270 status = acpi_tb_build_common_facs(&table_info);
295 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
296 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
297 } 273 }
298 274
299 /* Get/install the DSDT (Pointed to by the FADT) */ 275 /* Get/install the DSDT (Pointed to by the FADT) */
300 276
301 address.pointer.value = acpi_gbl_FADT->Xdsdt; 277 address.pointer.value = acpi_gbl_FADT->Xdsdt;
302 278
303 status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info); 279 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info);
304 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
305 ACPI_REPORT_ERROR (("Could not get/install the DSDT\n")); 281 ACPI_REPORT_ERROR(("Could not get/install the DSDT\n"));
306 return_ACPI_STATUS (status); 282 return_ACPI_STATUS(status);
307 } 283 }
308 284
309 /* Set Integer Width (32/64) based upon DSDT revision */ 285 /* Set Integer Width (32/64) based upon DSDT revision */
310 286
311 acpi_ut_set_integer_width (acpi_gbl_DSDT->revision); 287 acpi_ut_set_integer_width(acpi_gbl_DSDT->revision);
312 288
313 /* Dump the entire DSDT */ 289 /* Dump the entire DSDT */
314 290
315 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 291 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
316 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", 292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
317 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width)); 293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
318 ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); 294 acpi_gbl_integer_bit_width));
295 ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
319 296
320 /* Always delete the RSDP mapping, we are done with it */ 297 /* Always delete the RSDP mapping, we are done with it */
321 298
322 acpi_tb_delete_tables_by_type (ACPI_TABLE_RSDP); 299 acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP);
323 return_ACPI_STATUS (status); 300 return_ACPI_STATUS(status);
324} 301}
325
326
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 629b64c8193d..10db8484e462 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -41,22 +41,16 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbinstal") 48ACPI_MODULE_NAME("tbinstal")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_match_signature ( 52acpi_tb_match_signature(char *signature,
56 char *signature, 53 struct acpi_table_desc *table_info, u8 search_type);
57 struct acpi_table_desc *table_info,
58 u8 search_type);
59
60 54
61/******************************************************************************* 55/*******************************************************************************
62 * 56 *
@@ -74,16 +68,12 @@ acpi_tb_match_signature (
74 ******************************************************************************/ 68 ******************************************************************************/
75 69
76static acpi_status 70static acpi_status
77acpi_tb_match_signature ( 71acpi_tb_match_signature(char *signature,
78 char *signature, 72 struct acpi_table_desc *table_info, u8 search_type)
79 struct acpi_table_desc *table_info,
80 u8 search_type)
81{ 73{
82 acpi_native_uint i; 74 acpi_native_uint i;
83
84
85 ACPI_FUNCTION_TRACE ("tb_match_signature");
86 75
76 ACPI_FUNCTION_TRACE("tb_match_signature");
87 77
88 /* Search for a signature match among the known table types */ 78 /* Search for a signature match among the known table types */
89 79
@@ -92,30 +82,30 @@ acpi_tb_match_signature (
92 continue; 82 continue;
93 } 83 }
94 84
95 if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature, 85 if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature,
96 acpi_gbl_table_data[i].sig_length)) { 86 acpi_gbl_table_data[i].sig_length)) {
97 /* Found a signature match, return index if requested */ 87 /* Found a signature match, return index if requested */
98 88
99 if (table_info) { 89 if (table_info) {
100 table_info->type = (u8) i; 90 table_info->type = (u8) i;
101 } 91 }
102 92
103 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 93 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
104 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", 94 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n",
105 (char *) acpi_gbl_table_data[i].signature)); 95 (char *)acpi_gbl_table_data[i].
96 signature));
106 97
107 return_ACPI_STATUS (AE_OK); 98 return_ACPI_STATUS(AE_OK);
108 } 99 }
109 } 100 }
110 101
111 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 102 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
112 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", 103 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n",
113 (char *) signature)); 104 (char *)signature));
114 105
115 return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); 106 return_ACPI_STATUS(AE_TABLE_NOT_SUPPORTED);
116} 107}
117 108
118
119/******************************************************************************* 109/*******************************************************************************
120 * 110 *
121 * FUNCTION: acpi_tb_install_table 111 * FUNCTION: acpi_tb_install_table
@@ -124,46 +114,52 @@ acpi_tb_match_signature (
124 * 114 *
125 * RETURN: Status 115 * RETURN: Status
126 * 116 *
127 * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must 117 * DESCRIPTION: Install the table into the global data structures.
128 * already be loaded and validated.
129 * Install the table into the global data structs.
130 * 118 *
131 ******************************************************************************/ 119 ******************************************************************************/
132 120
133acpi_status 121acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
134acpi_tb_install_table (
135 struct acpi_table_desc *table_info)
136{ 122{
137 acpi_status status; 123 acpi_status status;
138
139 ACPI_FUNCTION_TRACE ("tb_install_table");
140 124
125 ACPI_FUNCTION_TRACE("tb_install_table");
141 126
142 /* Lock tables while installing */ 127 /* Lock tables while installing */
143 128
144 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
145 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
146 ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", 131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n",
147 table_info->pointer->signature, acpi_format_exception (status))); 132 acpi_format_exception(status)));
148 return_ACPI_STATUS (status); 133 return_ACPI_STATUS(status);
134 }
135
136 /*
137 * Ignore a table that is already installed. For example, some BIOS
138 * ASL code will repeatedly attempt to load the same SSDT.
139 */
140 status = acpi_tb_is_table_installed(table_info);
141 if (ACPI_FAILURE(status)) {
142 goto unlock_and_exit;
149 } 143 }
150 144
151 /* Install the table into the global data structure */ 145 /* Install the table into the global data structure */
152 146
153 status = acpi_tb_init_table_descriptor (table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
154 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
155 ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", 149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n",
156 table_info->pointer->signature, acpi_format_exception (status))); 150 table_info->pointer->signature,
151 acpi_format_exception(status)));
157 } 152 }
158 153
159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
160 acpi_gbl_table_data[table_info->type].name, table_info->pointer)); 155 acpi_gbl_table_data[table_info->type].name,
156 table_info->pointer));
161 157
162 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 158 unlock_and_exit:
163 return_ACPI_STATUS (status); 159 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
160 return_ACPI_STATUS(status);
164} 161}
165 162
166
167/******************************************************************************* 163/*******************************************************************************
168 * 164 *
169 * FUNCTION: acpi_tb_recognize_table 165 * FUNCTION: acpi_tb_recognize_table
@@ -186,22 +182,18 @@ acpi_tb_install_table (
186 ******************************************************************************/ 182 ******************************************************************************/
187 183
188acpi_status 184acpi_status
189acpi_tb_recognize_table ( 185acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
190 struct acpi_table_desc *table_info,
191 u8 search_type)
192{ 186{
193 struct acpi_table_header *table_header; 187 struct acpi_table_header *table_header;
194 acpi_status status; 188 acpi_status status;
195
196
197 ACPI_FUNCTION_TRACE ("tb_recognize_table");
198 189
190 ACPI_FUNCTION_TRACE("tb_recognize_table");
199 191
200 /* Ensure that we have a valid table pointer */ 192 /* Ensure that we have a valid table pointer */
201 193
202 table_header = (struct acpi_table_header *) table_info->pointer; 194 table_header = (struct acpi_table_header *)table_info->pointer;
203 if (!table_header) { 195 if (!table_header) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 196 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 197 }
206 198
207 /* 199 /*
@@ -212,25 +204,24 @@ acpi_tb_recognize_table (
212 * This can be any one of many valid ACPI tables, it just isn't one of 204 * This can be any one of many valid ACPI tables, it just isn't one of
213 * the tables that is consumed by the core subsystem 205 * the tables that is consumed by the core subsystem
214 */ 206 */
215 status = acpi_tb_match_signature (table_header->signature, 207 status = acpi_tb_match_signature(table_header->signature,
216 table_info, search_type); 208 table_info, search_type);
217 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
219 } 211 }
220 212
221 status = acpi_tb_validate_table_header (table_header); 213 status = acpi_tb_validate_table_header(table_header);
222 if (ACPI_FAILURE (status)) { 214 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
224 } 216 }
225 217
226 /* Return the table type and length via the info struct */ 218 /* Return the table type and length via the info struct */
227 219
228 table_info->length = (acpi_size) table_header->length; 220 table_info->length = (acpi_size) table_header->length;
229 221
230 return_ACPI_STATUS (status); 222 return_ACPI_STATUS(status);
231} 223}
232 224
233
234/******************************************************************************* 225/*******************************************************************************
235 * 226 *
236 * FUNCTION: acpi_tb_init_table_descriptor 227 * FUNCTION: acpi_tb_init_table_descriptor
@@ -245,22 +236,27 @@ acpi_tb_recognize_table (
245 ******************************************************************************/ 236 ******************************************************************************/
246 237
247acpi_status 238acpi_status
248acpi_tb_init_table_descriptor ( 239acpi_tb_init_table_descriptor(acpi_table_type table_type,
249 acpi_table_type table_type, 240 struct acpi_table_desc *table_info)
250 struct acpi_table_desc *table_info)
251{ 241{
252 struct acpi_table_list *list_head; 242 struct acpi_table_list *list_head;
253 struct acpi_table_desc *table_desc; 243 struct acpi_table_desc *table_desc;
254 244 acpi_status status;
255
256 ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type);
257 245
246 ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type);
258 247
259 /* Allocate a descriptor for this table */ 248 /* Allocate a descriptor for this table */
260 249
261 table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 250 table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
262 if (!table_desc) { 251 if (!table_desc) {
263 return_ACPI_STATUS (AE_NO_MEMORY); 252 return_ACPI_STATUS(AE_NO_MEMORY);
253 }
254
255 /* Get a new owner ID for the table */
256
257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id);
258 if (ACPI_FAILURE(status)) {
259 return_ACPI_STATUS(status);
264 } 260 }
265 261
266 /* Install the table into the global data structure */ 262 /* Install the table into the global data structure */
@@ -272,14 +268,14 @@ acpi_tb_init_table_descriptor (
272 * includes most ACPI tables such as the DSDT. 2) Multiple instances of 268 * includes most ACPI tables such as the DSDT. 2) Multiple instances of
273 * the table are allowed. This includes SSDT and PSDTs. 269 * the table are allowed. This includes SSDT and PSDTs.
274 */ 270 */
275 if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) { 271 if (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags)) {
276 /* 272 /*
277 * Only one table allowed, and a table has alread been installed 273 * Only one table allowed, and a table has alread been installed
278 * at this location, so return an error. 274 * at this location, so return an error.
279 */ 275 */
280 if (list_head->next) { 276 if (list_head->next) {
281 ACPI_MEM_FREE (table_desc); 277 ACPI_MEM_FREE(table_desc);
282 return_ACPI_STATUS (AE_ALREADY_EXISTS); 278 return_ACPI_STATUS(AE_ALREADY_EXISTS);
283 } 279 }
284 280
285 table_desc->next = list_head->next; 281 table_desc->next = list_head->next;
@@ -290,8 +286,7 @@ acpi_tb_init_table_descriptor (
290 } 286 }
291 287
292 list_head->count++; 288 list_head->count++;
293 } 289 } else {
294 else {
295 /* 290 /*
296 * Link the new table in to the list of tables of this type. 291 * Link the new table in to the list of tables of this type.
297 * Insert at the end of the list, order IS IMPORTANT. 292 * Insert at the end of the list, order IS IMPORTANT.
@@ -302,8 +297,7 @@ acpi_tb_init_table_descriptor (
302 297
303 if (!list_head->next) { 298 if (!list_head->next) {
304 list_head->next = table_desc; 299 list_head->next = table_desc;
305 } 300 } else {
306 else {
307 table_desc->next = list_head->next; 301 table_desc->next = list_head->next;
308 302
309 while (table_desc->next->next) { 303 while (table_desc->next->next) {
@@ -318,15 +312,14 @@ acpi_tb_init_table_descriptor (
318 312
319 /* Finish initialization of the table descriptor */ 313 /* Finish initialization of the table descriptor */
320 314
321 table_desc->type = (u8) table_type; 315 table_desc->type = (u8) table_type;
322 table_desc->pointer = table_info->pointer; 316 table_desc->pointer = table_info->pointer;
323 table_desc->length = table_info->length; 317 table_desc->length = table_info->length;
324 table_desc->allocation = table_info->allocation; 318 table_desc->allocation = table_info->allocation;
325 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 319 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
326 table_desc->aml_length = (u32) (table_desc->length - 320 table_desc->aml_length = (u32) (table_desc->length -
327 (u32) sizeof (struct acpi_table_header)); 321 (u32) sizeof(struct
328 table_desc->table_id = acpi_ut_allocate_owner_id ( 322 acpi_table_header));
329 ACPI_OWNER_TYPE_TABLE);
330 table_desc->loaded_into_namespace = FALSE; 323 table_desc->loaded_into_namespace = FALSE;
331 324
332 /* 325 /*
@@ -334,18 +327,18 @@ acpi_tb_init_table_descriptor (
334 * newly installed table 327 * newly installed table
335 */ 328 */
336 if (acpi_gbl_table_data[table_type].global_ptr) { 329 if (acpi_gbl_table_data[table_type].global_ptr) {
337 *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; 330 *(acpi_gbl_table_data[table_type].global_ptr) =
331 table_info->pointer;
338 } 332 }
339 333
340 /* Return Data */ 334 /* Return Data */
341 335
342 table_info->table_id = table_desc->table_id; 336 table_info->owner_id = table_desc->owner_id;
343 table_info->installed_desc = table_desc; 337 table_info->installed_desc = table_desc;
344 338
345 return_ACPI_STATUS (AE_OK); 339 return_ACPI_STATUS(AE_OK);
346} 340}
347 341
348
349/******************************************************************************* 342/*******************************************************************************
350 * 343 *
351 * FUNCTION: acpi_tb_delete_all_tables 344 * FUNCTION: acpi_tb_delete_all_tables
@@ -358,23 +351,19 @@ acpi_tb_init_table_descriptor (
358 * 351 *
359 ******************************************************************************/ 352 ******************************************************************************/
360 353
361void 354void acpi_tb_delete_all_tables(void)
362acpi_tb_delete_all_tables (
363 void)
364{ 355{
365 acpi_table_type type; 356 acpi_table_type type;
366
367 357
368 /* 358 /*
369 * Free memory allocated for ACPI tables 359 * Free memory allocated for ACPI tables
370 * Memory can either be mapped or allocated 360 * Memory can either be mapped or allocated
371 */ 361 */
372 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { 362 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) {
373 acpi_tb_delete_tables_by_type (type); 363 acpi_tb_delete_tables_by_type(type);
374 } 364 }
375} 365}
376 366
377
378/******************************************************************************* 367/*******************************************************************************
379 * 368 *
380 * FUNCTION: acpi_tb_delete_tables_by_type 369 * FUNCTION: acpi_tb_delete_tables_by_type
@@ -388,23 +377,19 @@ acpi_tb_delete_all_tables (
388 * 377 *
389 ******************************************************************************/ 378 ******************************************************************************/
390 379
391void 380void acpi_tb_delete_tables_by_type(acpi_table_type type)
392acpi_tb_delete_tables_by_type (
393 acpi_table_type type)
394{ 381{
395 struct acpi_table_desc *table_desc; 382 struct acpi_table_desc *table_desc;
396 u32 count; 383 u32 count;
397 u32 i; 384 u32 i;
398
399
400 ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type);
401 385
386 ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type);
402 387
403 if (type > ACPI_TABLE_MAX) { 388 if (type > ACPI_TABLE_MAX) {
404 return_VOID; 389 return_VOID;
405 } 390 }
406 391
407 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { 392 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) {
408 return; 393 return;
409 } 394 }
410 395
@@ -442,21 +427,20 @@ acpi_tb_delete_tables_by_type (
442 * 1) Get the head of the list 427 * 1) Get the head of the list
443 */ 428 */
444 table_desc = acpi_gbl_table_lists[type].next; 429 table_desc = acpi_gbl_table_lists[type].next;
445 count = acpi_gbl_table_lists[type].count; 430 count = acpi_gbl_table_lists[type].count;
446 431
447 /* 432 /*
448 * 2) Walk the entire list, deleting both the allocated tables 433 * 2) Walk the entire list, deleting both the allocated tables
449 * and the table descriptors 434 * and the table descriptors
450 */ 435 */
451 for (i = 0; i < count; i++) { 436 for (i = 0; i < count; i++) {
452 table_desc = acpi_tb_uninstall_table (table_desc); 437 table_desc = acpi_tb_uninstall_table(table_desc);
453 } 438 }
454 439
455 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 440 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
456 return_VOID; 441 return_VOID;
457} 442}
458 443
459
460/******************************************************************************* 444/*******************************************************************************
461 * 445 *
462 * FUNCTION: acpi_tb_delete_single_table 446 * FUNCTION: acpi_tb_delete_single_table
@@ -470,15 +454,12 @@ acpi_tb_delete_tables_by_type (
470 * 454 *
471 ******************************************************************************/ 455 ******************************************************************************/
472 456
473void 457void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc)
474acpi_tb_delete_single_table (
475 struct acpi_table_desc *table_desc)
476{ 458{
477 459
478 /* Must have a valid table descriptor and pointer */ 460 /* Must have a valid table descriptor and pointer */
479 461
480 if ((!table_desc) || 462 if ((!table_desc) || (!table_desc->pointer)) {
481 (!table_desc->pointer)) {
482 return; 463 return;
483 } 464 }
484 465
@@ -490,12 +471,12 @@ acpi_tb_delete_single_table (
490 471
491 case ACPI_MEM_ALLOCATED: 472 case ACPI_MEM_ALLOCATED:
492 473
493 ACPI_MEM_FREE (table_desc->pointer); 474 ACPI_MEM_FREE(table_desc->pointer);
494 break; 475 break;
495 476
496 case ACPI_MEM_MAPPED: 477 case ACPI_MEM_MAPPED:
497 478
498 acpi_os_unmap_memory (table_desc->pointer, table_desc->length); 479 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
499 break; 480 break;
500 481
501 default: 482 default:
@@ -503,7 +484,6 @@ acpi_tb_delete_single_table (
503 } 484 }
504} 485}
505 486
506
507/******************************************************************************* 487/*******************************************************************************
508 * 488 *
509 * FUNCTION: acpi_tb_uninstall_table 489 * FUNCTION: acpi_tb_uninstall_table
@@ -518,26 +498,22 @@ acpi_tb_delete_single_table (
518 * 498 *
519 ******************************************************************************/ 499 ******************************************************************************/
520 500
521struct acpi_table_desc * 501struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
522acpi_tb_uninstall_table ( 502 *table_desc)
523 struct acpi_table_desc *table_desc)
524{ 503{
525 struct acpi_table_desc *next_desc; 504 struct acpi_table_desc *next_desc;
526
527
528 ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc);
529 505
506 ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc);
530 507
531 if (!table_desc) { 508 if (!table_desc) {
532 return_PTR (NULL); 509 return_PTR(NULL);
533 } 510 }
534 511
535 /* Unlink the descriptor from the doubly linked list */ 512 /* Unlink the descriptor from the doubly linked list */
536 513
537 if (table_desc->prev) { 514 if (table_desc->prev) {
538 table_desc->prev->next = table_desc->next; 515 table_desc->prev->next = table_desc->next;
539 } 516 } else {
540 else {
541 /* Is first on list, update list head */ 517 /* Is first on list, update list head */
542 518
543 acpi_gbl_table_lists[table_desc->type].next = table_desc->next; 519 acpi_gbl_table_lists[table_desc->type].next = table_desc->next;
@@ -549,16 +525,14 @@ acpi_tb_uninstall_table (
549 525
550 /* Free the memory allocated for the table itself */ 526 /* Free the memory allocated for the table itself */
551 527
552 acpi_tb_delete_single_table (table_desc); 528 acpi_tb_delete_single_table(table_desc);
553 529
554 /* Free the table descriptor */ 530 /* Free the table descriptor */
555 531
556 next_desc = table_desc->next; 532 next_desc = table_desc->next;
557 ACPI_MEM_FREE (table_desc); 533 ACPI_MEM_FREE(table_desc);
558 534
559 /* Return pointer to the next descriptor */ 535 /* Return pointer to the next descriptor */
560 536
561 return_PTR (next_desc); 537 return_PTR(next_desc);
562} 538}
563
564
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index b7ffe39c3626..ad0252c2f7db 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbrsdt") 48ACPI_MODULE_NAME("tbrsdt")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -61,18 +58,13 @@
61 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) 58 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
62 * 59 *
63 ******************************************************************************/ 60 ******************************************************************************/
64 61acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
65acpi_status
66acpi_tb_verify_rsdp (
67 struct acpi_pointer *address)
68{ 62{
69 struct acpi_table_desc table_info; 63 struct acpi_table_desc table_info;
70 acpi_status status; 64 acpi_status status;
71 struct rsdp_descriptor *rsdp; 65 struct rsdp_descriptor *rsdp;
72
73
74 ACPI_FUNCTION_TRACE ("tb_verify_rsdp");
75 66
67 ACPI_FUNCTION_TRACE("tb_verify_rsdp");
76 68
77 switch (address->pointer_type) { 69 switch (address->pointer_type) {
78 case ACPI_LOGICAL_POINTER: 70 case ACPI_LOGICAL_POINTER:
@@ -84,73 +76,53 @@ acpi_tb_verify_rsdp (
84 /* 76 /*
85 * Obtain access to the RSDP structure 77 * Obtain access to the RSDP structure
86 */ 78 */
87 status = acpi_os_map_memory (address->pointer.physical, 79 status = acpi_os_map_memory(address->pointer.physical,
88 sizeof (struct rsdp_descriptor), 80 sizeof(struct rsdp_descriptor),
89 (void *) &rsdp); 81 (void *)&rsdp);
90 if (ACPI_FAILURE (status)) { 82 if (ACPI_FAILURE(status)) {
91 return_ACPI_STATUS (status); 83 return_ACPI_STATUS(status);
92 } 84 }
93 break; 85 break;
94 86
95 default: 87 default:
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 /* 91 /* Verify RSDP signature and checksum */
100 * The signature and checksum must both be correct
101 */
102 if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
103 /* Nope, BAD Signature */
104 92
105 status = AE_BAD_SIGNATURE; 93 status = acpi_tb_validate_rsdp(rsdp);
94 if (ACPI_FAILURE(status)) {
106 goto cleanup; 95 goto cleanup;
107 } 96 }
108 97
109 /* Check the standard checksum */
110
111 if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
112 status = AE_BAD_CHECKSUM;
113 goto cleanup;
114 }
115
116 /* Check extended checksum if table version >= 2 */
117
118 if (rsdp->revision >= 2) {
119 if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) {
120 status = AE_BAD_CHECKSUM;
121 goto cleanup;
122 }
123 }
124
125 /* The RSDP supplied is OK */ 98 /* The RSDP supplied is OK */
126 99
127 table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); 100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp);
128 table_info.length = sizeof (struct rsdp_descriptor); 101 table_info.length = sizeof(struct rsdp_descriptor);
129 table_info.allocation = ACPI_MEM_MAPPED; 102 table_info.allocation = ACPI_MEM_MAPPED;
130 103
131 /* Save the table pointers and allocation info */ 104 /* Save the table pointers and allocation info */
132 105
133 status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); 106 status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info);
134 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
135 goto cleanup; 108 goto cleanup;
136 } 109 }
137 110
138 /* Save the RSDP in a global for easy access */ 111 /* Save the RSDP in a global for easy access */
139 112
140 acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer); 113 acpi_gbl_RSDP =
141 return_ACPI_STATUS (status); 114 ACPI_CAST_PTR(struct rsdp_descriptor, table_info.pointer);
142 115 return_ACPI_STATUS(status);
143 116
144 /* Error exit */ 117 /* Error exit */
145cleanup: 118 cleanup:
146 119
147 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) { 120 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) {
148 acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor)); 121 acpi_os_unmap_memory(rsdp, sizeof(struct rsdp_descriptor));
149 } 122 }
150 return_ACPI_STATUS (status); 123 return_ACPI_STATUS(status);
151} 124}
152 125
153
154/******************************************************************************* 126/*******************************************************************************
155 * 127 *
156 * FUNCTION: acpi_tb_get_rsdt_address 128 * FUNCTION: acpi_tb_get_rsdt_address
@@ -159,35 +131,35 @@ cleanup:
159 * 131 *
160 * RETURN: None, Address 132 * RETURN: None, Address
161 * 133 *
162 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the 134 * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the
163 * version of the RSDP 135 * version of the RSDP and whether the XSDT pointer is valid
164 * 136 *
165 ******************************************************************************/ 137 ******************************************************************************/
166 138
167void 139void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address)
168acpi_tb_get_rsdt_address (
169 struct acpi_pointer *out_address)
170{ 140{
171 141
172 ACPI_FUNCTION_ENTRY (); 142 ACPI_FUNCTION_ENTRY();
173 143
144 out_address->pointer_type =
145 acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
174 146
175 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; 147 /* Use XSDT if it is present */
176 148
177 /* 149 if ((acpi_gbl_RSDP->revision >= 2) &&
178 * For RSDP revision 0 or 1, we use the RSDT. 150 acpi_gbl_RSDP->xsdt_physical_address) {
179 * For RSDP revision 2 (and above), we use the XSDT
180 */
181 if (acpi_gbl_RSDP->revision < 2) {
182 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
183 }
184 else {
185 out_address->pointer.value = 151 out_address->pointer.value =
186 acpi_gbl_RSDP->xsdt_physical_address; 152 acpi_gbl_RSDP->xsdt_physical_address;
153 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
154 } else {
155 /* No XSDT, use the RSDT */
156
157 out_address->pointer.value =
158 acpi_gbl_RSDP->rsdt_physical_address;
159 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
187 } 160 }
188} 161}
189 162
190
191/******************************************************************************* 163/*******************************************************************************
192 * 164 *
193 * FUNCTION: acpi_tb_validate_rsdt 165 * FUNCTION: acpi_tb_validate_rsdt
@@ -200,50 +172,43 @@ acpi_tb_get_rsdt_address (
200 * 172 *
201 ******************************************************************************/ 173 ******************************************************************************/
202 174
203acpi_status 175acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
204acpi_tb_validate_rsdt (
205 struct acpi_table_header *table_ptr)
206{ 176{
207 int no_match; 177 int no_match;
208
209
210 ACPI_FUNCTION_NAME ("tb_validate_rsdt");
211 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt");
212 180
213 /* 181 /*
214 * For RSDP revision 0 or 1, we use the RSDT. 182 * Search for appropriate signature, RSDT or XSDT
215 * For RSDP revision 2 and above, we use the XSDT
216 */ 183 */
217 if (acpi_gbl_RSDP->revision < 2) { 184 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
218 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, 185 no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG,
219 sizeof (RSDT_SIG) -1); 186 sizeof(RSDT_SIG) - 1);
220 } 187 } else {
221 else { 188 no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG,
222 no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG, 189 sizeof(XSDT_SIG) - 1);
223 sizeof (XSDT_SIG) -1);
224 } 190 }
225 191
226 if (no_match) { 192 if (no_match) {
227 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
228 194
229 ACPI_REPORT_ERROR (( 195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
230 "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
231 196
232 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); 197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
233 198
234 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, 199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR,
235 "RSDT/XSDT signature at %X (%p) is invalid\n", 200 "RSDT/XSDT signature at %X (%p) is invalid\n",
236 acpi_gbl_RSDP->rsdt_physical_address, 201 acpi_gbl_RSDP->rsdt_physical_address,
237 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); 202 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address));
238 204
239 if (acpi_gbl_RSDP->revision < 2) { 205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
240 ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) 206 ACPI_REPORT_ERROR(("Looking for RSDT\n"))
241 } 207 } else {
242 else { 208 ACPI_REPORT_ERROR(("Looking for XSDT\n"))
243 ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n"))
244 } 209 }
245 210
246 ACPI_DUMP_BUFFER ((char *) table_ptr, 48); 211 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
247 212
248 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
249 } 214 }
@@ -251,7 +216,6 @@ acpi_tb_validate_rsdt (
251 return (AE_OK); 216 return (AE_OK);
252} 217}
253 218
254
255/******************************************************************************* 219/*******************************************************************************
256 * 220 *
257 * FUNCTION: acpi_tb_get_table_rsdt 221 * FUNCTION: acpi_tb_get_table_rsdt
@@ -264,66 +228,61 @@ acpi_tb_validate_rsdt (
264 * 228 *
265 ******************************************************************************/ 229 ******************************************************************************/
266 230
267acpi_status 231acpi_status acpi_tb_get_table_rsdt(void)
268acpi_tb_get_table_rsdt (
269 void)
270{ 232{
271 struct acpi_table_desc table_info; 233 struct acpi_table_desc table_info;
272 acpi_status status; 234 acpi_status status;
273 struct acpi_pointer address; 235 struct acpi_pointer address;
274
275
276 ACPI_FUNCTION_TRACE ("tb_get_table_rsdt");
277 236
237 ACPI_FUNCTION_TRACE("tb_get_table_rsdt");
278 238
279 /* Get the RSDT/XSDT via the RSDP */ 239 /* Get the RSDT/XSDT via the RSDP */
280 240
281 acpi_tb_get_rsdt_address (&address); 241 acpi_tb_get_rsdt_address(&address);
282 242
283 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
284 status = acpi_tb_get_table (&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
285 if (ACPI_FAILURE (status)) { 245 if (ACPI_FAILURE(status)) {
286 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", 246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
287 acpi_format_exception (status))); 247 "Could not get the RSDT/XSDT, %s\n",
248 acpi_format_exception(status)));
288 249
289 return_ACPI_STATUS (status); 250 return_ACPI_STATUS(status);
290 } 251 }
291 252
292 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
293 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n",
294 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
295 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
296 257
297 /* Check the RSDT or XSDT signature */ 258 /* Check the RSDT or XSDT signature */
298 259
299 status = acpi_tb_validate_rsdt (table_info.pointer); 260 status = acpi_tb_validate_rsdt(table_info.pointer);
300 if (ACPI_FAILURE (status)) { 261 if (ACPI_FAILURE(status)) {
301 return_ACPI_STATUS (status); 262 return_ACPI_STATUS(status);
302 } 263 }
303 264
304 /* Get the number of tables defined in the RSDT or XSDT */ 265 /* Get the number of tables defined in the RSDT or XSDT */
305 266
306 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, 267 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count(acpi_gbl_RSDP,
307 table_info.pointer); 268 table_info.pointer);
308 269
309 /* Convert and/or copy to an XSDT structure */ 270 /* Convert and/or copy to an XSDT structure */
310 271
311 status = acpi_tb_convert_to_xsdt (&table_info); 272 status = acpi_tb_convert_to_xsdt(&table_info);
312 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE(status)) {
313 return_ACPI_STATUS (status); 274 return_ACPI_STATUS(status);
314 } 275 }
315 276
316 /* Save the table pointers and allocation info */ 277 /* Save the table pointers and allocation info */
317 278
318 status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); 279 status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info);
319 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
320 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
321 } 282 }
322 283
323 acpi_gbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info.pointer); 284 acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer);
324 285
325 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); 286 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
326 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
327} 288}
328
329
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index e69d01d443d2..4b2fbb592f49 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -41,23 +41,84 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbutils") 48ACPI_MODULE_NAME("tbutils")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54#ifdef ACPI_OBSOLETE_FUNCTIONS 51#ifdef ACPI_OBSOLETE_FUNCTIONS
55acpi_status 52acpi_status
56acpi_tb_handle_to_object ( 53acpi_tb_handle_to_object(u16 table_id, struct acpi_table_desc **table_desc);
57 u16 table_id,
58 struct acpi_table_desc **table_desc);
59#endif 54#endif
60 55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_tb_is_table_installed
59 *
60 * PARAMETERS: new_table_desc - Descriptor for new table being installed
61 *
62 * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed
63 *
64 * DESCRIPTION: Determine if an ACPI table is already installed
65 *
66 * MUTEX: Table data structures should be locked
67 *
68 ******************************************************************************/
69
70acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
71{
72 struct acpi_table_desc *table_desc;
73
74 ACPI_FUNCTION_TRACE("tb_is_table_installed");
75
76 /* Get the list descriptor and first table descriptor */
77
78 table_desc = acpi_gbl_table_lists[new_table_desc->type].next;
79
80 /* Examine all installed tables of this type */
81
82 while (table_desc) {
83 /*
84 * If the table lengths match, perform a full bytewise compare. This
85 * means that we will allow tables with duplicate oem_table_id(s), as
86 * long as the tables are different in some way.
87 *
88 * Checking if the table has been loaded into the namespace means that
89 * we don't check for duplicate tables during the initial installation
90 * of tables within the RSDT/XSDT.
91 */
92 if ((table_desc->loaded_into_namespace) &&
93 (table_desc->pointer->length ==
94 new_table_desc->pointer->length)
95 &&
96 (!ACPI_MEMCMP
97 ((const char *)table_desc->pointer,
98 (const char *)new_table_desc->pointer,
99 (acpi_size) new_table_desc->pointer->length))) {
100 /* Match: this table is already installed */
101
102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
103 "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n",
104 new_table_desc->pointer->signature,
105 new_table_desc->pointer->revision,
106 new_table_desc->pointer->
107 oem_table_id));
108
109 new_table_desc->owner_id = table_desc->owner_id;
110 new_table_desc->installed_desc = table_desc;
111
112 return_ACPI_STATUS(AE_ALREADY_EXISTS);
113 }
114
115 /* Get next table on the list */
116
117 table_desc = table_desc->next;
118 }
119
120 return_ACPI_STATUS(AE_OK);
121}
61 122
62/******************************************************************************* 123/*******************************************************************************
63 * 124 *
@@ -80,57 +141,55 @@ acpi_tb_handle_to_object (
80 ******************************************************************************/ 141 ******************************************************************************/
81 142
82acpi_status 143acpi_status
83acpi_tb_validate_table_header ( 144acpi_tb_validate_table_header(struct acpi_table_header *table_header)
84 struct acpi_table_header *table_header)
85{ 145{
86 acpi_name signature; 146 acpi_name signature;
87
88
89 ACPI_FUNCTION_NAME ("tb_validate_table_header");
90 147
148 ACPI_FUNCTION_NAME("tb_validate_table_header");
91 149
92 /* Verify that this is a valid address */ 150 /* Verify that this is a valid address */
93 151
94 if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) { 152 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
95 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
96 "Cannot read table header at %p\n", table_header)); 154 "Cannot read table header at %p\n",
155 table_header));
97 156
98 return (AE_BAD_ADDRESS); 157 return (AE_BAD_ADDRESS);
99 } 158 }
100 159
101 /* Ensure that the signature is 4 ASCII characters */ 160 /* Ensure that the signature is 4 ASCII characters */
102 161
103 ACPI_MOVE_32_TO_32 (&signature, table_header->signature); 162 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
104 if (!acpi_ut_valid_acpi_name (signature)) { 163 if (!acpi_ut_valid_acpi_name(signature)) {
105 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
106 "Table signature at %p [%p] has invalid characters\n", 165 "Table signature at %p [%p] has invalid characters\n",
107 table_header, &signature)); 166 table_header, &signature));
108 167
109 ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", 168 ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n",
110 (char *) &signature)); 169 (char *)&signature));
111 170
112 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 171 ACPI_DUMP_BUFFER(table_header,
172 sizeof(struct acpi_table_header));
113 return (AE_BAD_SIGNATURE); 173 return (AE_BAD_SIGNATURE);
114 } 174 }
115 175
116 /* Validate the table length */ 176 /* Validate the table length */
117 177
118 if (table_header->length < sizeof (struct acpi_table_header)) { 178 if (table_header->length < sizeof(struct acpi_table_header)) {
119 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
120 "Invalid length in table header %p name %4.4s\n", 180 "Invalid length in table header %p name %4.4s\n",
121 table_header, (char *) &signature)); 181 table_header, (char *)&signature));
122 182
123 ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", 183 ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length));
124 (u32) table_header->length));
125 184
126 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 185 ACPI_DUMP_BUFFER(table_header,
186 sizeof(struct acpi_table_header));
127 return (AE_BAD_HEADER); 187 return (AE_BAD_HEADER);
128 } 188 }
129 189
130 return (AE_OK); 190 return (AE_OK);
131} 191}
132 192
133
134/******************************************************************************* 193/*******************************************************************************
135 * 194 *
136 * FUNCTION: acpi_tb_verify_table_checksum 195 * FUNCTION: acpi_tb_verify_table_checksum
@@ -145,37 +204,31 @@ acpi_tb_validate_table_header (
145 ******************************************************************************/ 204 ******************************************************************************/
146 205
147acpi_status 206acpi_status
148acpi_tb_verify_table_checksum ( 207acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
149 struct acpi_table_header *table_header)
150{ 208{
151 u8 checksum; 209 u8 checksum;
152 acpi_status status = AE_OK; 210 acpi_status status = AE_OK;
153
154
155 ACPI_FUNCTION_TRACE ("tb_verify_table_checksum");
156 211
212 ACPI_FUNCTION_TRACE("tb_verify_table_checksum");
157 213
158 /* Compute the checksum on the table */ 214 /* Compute the checksum on the table */
159 215
160 checksum = acpi_tb_checksum (table_header, table_header->length); 216 checksum =
217 acpi_tb_generate_checksum(table_header, table_header->length);
161 218
162 /* Return the appropriate exception */ 219 /* Return the appropriate exception */
163 220
164 if (checksum) { 221 if (checksum) {
165 ACPI_REPORT_WARNING (( 222 ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum));
166 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
167 table_header->signature, (u32) table_header->checksum,
168 (u32) checksum));
169 223
170 status = AE_BAD_CHECKSUM; 224 status = AE_BAD_CHECKSUM;
171 } 225 }
172 return_ACPI_STATUS (status); 226 return_ACPI_STATUS(status);
173} 227}
174 228
175
176/******************************************************************************* 229/*******************************************************************************
177 * 230 *
178 * FUNCTION: acpi_tb_checksum 231 * FUNCTION: acpi_tb_generate_checksum
179 * 232 *
180 * PARAMETERS: Buffer - Buffer to checksum 233 * PARAMETERS: Buffer - Buffer to checksum
181 * Length - Size of the buffer 234 * Length - Size of the buffer
@@ -186,15 +239,11 @@ acpi_tb_verify_table_checksum (
186 * 239 *
187 ******************************************************************************/ 240 ******************************************************************************/
188 241
189u8 242u8 acpi_tb_generate_checksum(void *buffer, u32 length)
190acpi_tb_checksum (
191 void *buffer,
192 u32 length)
193{ 243{
194 const u8 *limit; 244 const u8 *limit;
195 const u8 *rover; 245 const u8 *rover;
196 u8 sum = 0; 246 u8 sum = 0;
197
198 247
199 if (buffer && length) { 248 if (buffer && length) {
200 /* Buffer and Length are valid */ 249 /* Buffer and Length are valid */
@@ -208,7 +257,6 @@ acpi_tb_checksum (
208 return (sum); 257 return (sum);
209} 258}
210 259
211
212#ifdef ACPI_OBSOLETE_FUNCTIONS 260#ifdef ACPI_OBSOLETE_FUNCTIONS
213/******************************************************************************* 261/*******************************************************************************
214 * 262 *
@@ -224,16 +272,13 @@ acpi_tb_checksum (
224 ******************************************************************************/ 272 ******************************************************************************/
225 273
226acpi_status 274acpi_status
227acpi_tb_handle_to_object ( 275acpi_tb_handle_to_object(u16 table_id,
228 u16 table_id, 276 struct acpi_table_desc ** return_table_desc)
229 struct acpi_table_desc **return_table_desc)
230{ 277{
231 u32 i; 278 u32 i;
232 struct acpi_table_desc *table_desc; 279 struct acpi_table_desc *table_desc;
233
234
235 ACPI_FUNCTION_NAME ("tb_handle_to_object");
236 280
281 ACPI_FUNCTION_NAME("tb_handle_to_object");
237 282
238 for (i = 0; i < ACPI_TABLE_MAX; i++) { 283 for (i = 0; i < ACPI_TABLE_MAX; i++) {
239 table_desc = acpi_gbl_table_lists[i].next; 284 table_desc = acpi_gbl_table_lists[i].next;
@@ -247,9 +292,8 @@ acpi_tb_handle_to_object (
247 } 292 }
248 } 293 }
249 294
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id)); 295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n",
296 table_id));
251 return (AE_BAD_PARAMETER); 297 return (AE_BAD_PARAMETER);
252} 298}
253#endif 299#endif
254
255
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 0c0b9085dbeb..3f96a4909aad 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -48,10 +48,8 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/actables.h> 49#include <acpi/actables.h>
50 50
51
52#define _COMPONENT ACPI_TABLES 51#define _COMPONENT ACPI_TABLES
53 ACPI_MODULE_NAME ("tbxface") 52ACPI_MODULE_NAME("tbxface")
54
55 53
56/******************************************************************************* 54/*******************************************************************************
57 * 55 *
@@ -65,25 +63,20 @@
65 * provided RSDT 63 * provided RSDT
66 * 64 *
67 ******************************************************************************/ 65 ******************************************************************************/
68 66acpi_status acpi_load_tables(void)
69acpi_status
70acpi_load_tables (
71 void)
72{ 67{
73 struct acpi_pointer rsdp_address; 68 struct acpi_pointer rsdp_address;
74 acpi_status status; 69 acpi_status status;
75
76
77 ACPI_FUNCTION_TRACE ("acpi_load_tables");
78 70
71 ACPI_FUNCTION_TRACE("acpi_load_tables");
79 72
80 /* Get the RSDP */ 73 /* Get the RSDP */
81 74
82 status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING, 75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING,
83 &rsdp_address); 76 &rsdp_address);
84 if (ACPI_FAILURE (status)) { 77 if (ACPI_FAILURE(status)) {
85 ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n", 78 ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n",
86 acpi_format_exception (status))); 79 acpi_format_exception(status)));
87 goto error_exit; 80 goto error_exit;
88 } 81 }
89 82
@@ -91,54 +84,47 @@ acpi_load_tables (
91 84
92 acpi_gbl_table_flags = rsdp_address.pointer_type; 85 acpi_gbl_table_flags = rsdp_address.pointer_type;
93 86
94 status = acpi_tb_verify_rsdp (&rsdp_address); 87 status = acpi_tb_verify_rsdp(&rsdp_address);
95 if (ACPI_FAILURE (status)) { 88 if (ACPI_FAILURE(status)) {
96 ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n", 89 ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status)));
97 acpi_format_exception (status)));
98 goto error_exit; 90 goto error_exit;
99 } 91 }
100 92
101 /* Get the RSDT via the RSDP */ 93 /* Get the RSDT via the RSDP */
102 94
103 status = acpi_tb_get_table_rsdt (); 95 status = acpi_tb_get_table_rsdt();
104 if (ACPI_FAILURE (status)) { 96 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n", 97 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status)));
106 acpi_format_exception (status)));
107 goto error_exit; 98 goto error_exit;
108 } 99 }
109 100
110 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */ 101 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
111 102
112 status = acpi_tb_get_required_tables (); 103 status = acpi_tb_get_required_tables();
113 if (ACPI_FAILURE (status)) { 104 if (ACPI_FAILURE(status)) {
114 ACPI_REPORT_ERROR (( 105 ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status)));
115 "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
116 acpi_format_exception (status)));
117 goto error_exit; 106 goto error_exit;
118 } 107 }
119 108
120 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 109 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
121 110
122 /* Load the namespace from the tables */ 111 /* Load the namespace from the tables */
123 112
124 status = acpi_ns_load_namespace (); 113 status = acpi_ns_load_namespace();
125 if (ACPI_FAILURE (status)) { 114 if (ACPI_FAILURE(status)) {
126 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n", 115 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status)));
127 acpi_format_exception (status)));
128 goto error_exit; 116 goto error_exit;
129 } 117 }
130 118
131 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
132 120
121 error_exit:
122 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n",
123 acpi_format_exception(status)));
133 124
134error_exit: 125 return_ACPI_STATUS(status);
135 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load tables: %s\n",
136 acpi_format_exception (status)));
137
138 return_ACPI_STATUS (status);
139} 126}
140 127
141
142#ifdef ACPI_FUTURE_USAGE 128#ifdef ACPI_FUTURE_USAGE
143/******************************************************************************* 129/*******************************************************************************
144 * 130 *
@@ -156,40 +142,49 @@ error_exit:
156 * 142 *
157 ******************************************************************************/ 143 ******************************************************************************/
158 144
159acpi_status 145acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
160acpi_load_table (
161 struct acpi_table_header *table_ptr)
162{ 146{
163 acpi_status status; 147 acpi_status status;
164 struct acpi_table_desc table_info; 148 struct acpi_table_desc table_info;
165 struct acpi_pointer address; 149 struct acpi_pointer address;
166
167
168 ACPI_FUNCTION_TRACE ("acpi_load_table");
169 150
151 ACPI_FUNCTION_TRACE("acpi_load_table");
170 152
171 if (!table_ptr) { 153 if (!table_ptr) {
172 return_ACPI_STATUS (AE_BAD_PARAMETER); 154 return_ACPI_STATUS(AE_BAD_PARAMETER);
173 } 155 }
174 156
175 /* Copy the table to a local buffer */ 157 /* Copy the table to a local buffer */
176 158
177 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; 159 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
178 address.pointer.logical = table_ptr; 160 address.pointer.logical = table_ptr;
179 161
180 status = acpi_tb_get_table_body (&address, table_ptr, &table_info); 162 status = acpi_tb_get_table_body(&address, table_ptr, &table_info);
181 if (ACPI_FAILURE (status)) { 163 if (ACPI_FAILURE(status)) {
182 return_ACPI_STATUS (status); 164 return_ACPI_STATUS(status);
165 }
166
167 /* Check signature for a valid table type */
168
169 status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL);
170 if (ACPI_FAILURE(status)) {
171 return_ACPI_STATUS(status);
183 } 172 }
184 173
185 /* Install the new table into the local data structures */ 174 /* Install the new table into the local data structures */
186 175
187 status = acpi_tb_install_table (&table_info); 176 status = acpi_tb_install_table(&table_info);
188 if (ACPI_FAILURE (status)) { 177 if (ACPI_FAILURE(status)) {
178 if (status == AE_ALREADY_EXISTS) {
179 /* Table already exists, no error */
180
181 status = AE_OK;
182 }
183
189 /* Free table allocated by acpi_tb_get_table_body */ 184 /* Free table allocated by acpi_tb_get_table_body */
190 185
191 acpi_tb_delete_single_table (&table_info); 186 acpi_tb_delete_single_table(&table_info);
192 return_ACPI_STATUS (status); 187 return_ACPI_STATUS(status);
193 } 188 }
194 189
195 /* Convert the table to common format if necessary */ 190 /* Convert the table to common format if necessary */
@@ -197,31 +192,32 @@ acpi_load_table (
197 switch (table_info.type) { 192 switch (table_info.type) {
198 case ACPI_TABLE_FADT: 193 case ACPI_TABLE_FADT:
199 194
200 status = acpi_tb_convert_table_fadt (); 195 status = acpi_tb_convert_table_fadt();
201 break; 196 break;
202 197
203 case ACPI_TABLE_FACS: 198 case ACPI_TABLE_FACS:
204 199
205 status = acpi_tb_build_common_facs (&table_info); 200 status = acpi_tb_build_common_facs(&table_info);
206 break; 201 break;
207 202
208 default: 203 default:
209 /* Load table into namespace if it contains executable AML */ 204 /* Load table into namespace if it contains executable AML */
210 205
211 status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node); 206 status =
207 acpi_ns_load_table(table_info.installed_desc,
208 acpi_gbl_root_node);
212 break; 209 break;
213 } 210 }
214 211
215 if (ACPI_FAILURE (status)) { 212 if (ACPI_FAILURE(status)) {
216 /* Uninstall table and free the buffer */ 213 /* Uninstall table and free the buffer */
217 214
218 (void) acpi_tb_uninstall_table (table_info.installed_desc); 215 (void)acpi_tb_uninstall_table(table_info.installed_desc);
219 } 216 }
220 217
221 return_ACPI_STATUS (status); 218 return_ACPI_STATUS(status);
222} 219}
223 220
224
225/******************************************************************************* 221/*******************************************************************************
226 * 222 *
227 * FUNCTION: acpi_unload_table 223 * FUNCTION: acpi_unload_table
@@ -234,20 +230,16 @@ acpi_load_table (
234 * 230 *
235 ******************************************************************************/ 231 ******************************************************************************/
236 232
237acpi_status 233acpi_status acpi_unload_table(acpi_table_type table_type)
238acpi_unload_table (
239 acpi_table_type table_type)
240{ 234{
241 struct acpi_table_desc *table_desc; 235 struct acpi_table_desc *table_desc;
242
243
244 ACPI_FUNCTION_TRACE ("acpi_unload_table");
245 236
237 ACPI_FUNCTION_TRACE("acpi_unload_table");
246 238
247 /* Parameter validation */ 239 /* Parameter validation */
248 240
249 if (table_type > ACPI_TABLE_MAX) { 241 if (table_type > ACPI_TABLE_MAX) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 242 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 243 }
252 244
253 /* Find all tables of the requested type */ 245 /* Find all tables of the requested type */
@@ -260,18 +252,17 @@ acpi_unload_table (
260 * "Scope" operator. Thus, we need to track ownership by an ID, not 252 * "Scope" operator. Thus, we need to track ownership by an ID, not
261 * simply a position within the hierarchy 253 * simply a position within the hierarchy
262 */ 254 */
263 acpi_ns_delete_namespace_by_owner (table_desc->table_id); 255 acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
264 256 acpi_ut_release_owner_id(&table_desc->owner_id);
265 table_desc = table_desc->next; 257 table_desc = table_desc->next;
266 } 258 }
267 259
268 /* Delete (or unmap) all tables of this type */ 260 /* Delete (or unmap) all tables of this type */
269 261
270 acpi_tb_delete_tables_by_type (table_type); 262 acpi_tb_delete_tables_by_type(table_type);
271 return_ACPI_STATUS (AE_OK); 263 return_ACPI_STATUS(AE_OK);
272} 264}
273 265
274
275/******************************************************************************* 266/*******************************************************************************
276 * 267 *
277 * FUNCTION: acpi_get_table_header 268 * FUNCTION: acpi_get_table_header
@@ -294,54 +285,49 @@ acpi_unload_table (
294 ******************************************************************************/ 285 ******************************************************************************/
295 286
296acpi_status 287acpi_status
297acpi_get_table_header ( 288acpi_get_table_header(acpi_table_type table_type,
298 acpi_table_type table_type, 289 u32 instance, struct acpi_table_header *out_table_header)
299 u32 instance,
300 struct acpi_table_header *out_table_header)
301{ 290{
302 struct acpi_table_header *tbl_ptr; 291 struct acpi_table_header *tbl_ptr;
303 acpi_status status; 292 acpi_status status;
304 293
294 ACPI_FUNCTION_TRACE("acpi_get_table_header");
305 295
306 ACPI_FUNCTION_TRACE ("acpi_get_table_header"); 296 if ((instance == 0) ||
307 297 (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) {
308 298 return_ACPI_STATUS(AE_BAD_PARAMETER);
309 if ((instance == 0) ||
310 (table_type == ACPI_TABLE_RSDP) ||
311 (!out_table_header)) {
312 return_ACPI_STATUS (AE_BAD_PARAMETER);
313 } 299 }
314 300
315 /* Check the table type and instance */ 301 /* Check the table type and instance */
316 302
317 if ((table_type > ACPI_TABLE_MAX) || 303 if ((table_type > ACPI_TABLE_MAX) ||
318 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 304 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
319 instance > 1)) { 305 instance > 1)) {
320 return_ACPI_STATUS (AE_BAD_PARAMETER); 306 return_ACPI_STATUS(AE_BAD_PARAMETER);
321 } 307 }
322 308
323 /* Get a pointer to the entire table */ 309 /* Get a pointer to the entire table */
324 310
325 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 311 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
326 if (ACPI_FAILURE (status)) { 312 if (ACPI_FAILURE(status)) {
327 return_ACPI_STATUS (status); 313 return_ACPI_STATUS(status);
328 } 314 }
329 315
330 /* The function will return a NULL pointer if the table is not loaded */ 316 /* The function will return a NULL pointer if the table is not loaded */
331 317
332 if (tbl_ptr == NULL) { 318 if (tbl_ptr == NULL) {
333 return_ACPI_STATUS (AE_NOT_EXIST); 319 return_ACPI_STATUS(AE_NOT_EXIST);
334 } 320 }
335 321
336 /* Copy the header to the caller's buffer */ 322 /* Copy the header to the caller's buffer */
337 323
338 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, 324 ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr,
339 sizeof (struct acpi_table_header)); 325 sizeof(struct acpi_table_header));
340 326
341 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
342} 328}
343 329
344#endif /* ACPI_FUTURE_USAGE */ 330#endif /* ACPI_FUTURE_USAGE */
345 331
346/******************************************************************************* 332/*******************************************************************************
347 * 333 *
@@ -367,43 +353,39 @@ acpi_get_table_header (
367 ******************************************************************************/ 353 ******************************************************************************/
368 354
369acpi_status 355acpi_status
370acpi_get_table ( 356acpi_get_table(acpi_table_type table_type,
371 acpi_table_type table_type, 357 u32 instance, struct acpi_buffer *ret_buffer)
372 u32 instance,
373 struct acpi_buffer *ret_buffer)
374{ 358{
375 struct acpi_table_header *tbl_ptr; 359 struct acpi_table_header *tbl_ptr;
376 acpi_status status; 360 acpi_status status;
377 acpi_size table_length; 361 acpi_size table_length;
378
379
380 ACPI_FUNCTION_TRACE ("acpi_get_table");
381 362
363 ACPI_FUNCTION_TRACE("acpi_get_table");
382 364
383 /* Parameter validation */ 365 /* Parameter validation */
384 366
385 if (instance == 0) { 367 if (instance == 0) {
386 return_ACPI_STATUS (AE_BAD_PARAMETER); 368 return_ACPI_STATUS(AE_BAD_PARAMETER);
387 } 369 }
388 370
389 status = acpi_ut_validate_buffer (ret_buffer); 371 status = acpi_ut_validate_buffer(ret_buffer);
390 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
391 return_ACPI_STATUS (status); 373 return_ACPI_STATUS(status);
392 } 374 }
393 375
394 /* Check the table type and instance */ 376 /* Check the table type and instance */
395 377
396 if ((table_type > ACPI_TABLE_MAX) || 378 if ((table_type > ACPI_TABLE_MAX) ||
397 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 379 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
398 instance > 1)) { 380 instance > 1)) {
399 return_ACPI_STATUS (AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
400 } 382 }
401 383
402 /* Get a pointer to the entire table */ 384 /* Get a pointer to the entire table */
403 385
404 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 386 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
405 if (ACPI_FAILURE (status)) { 387 if (ACPI_FAILURE(status)) {
406 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
407 } 389 }
408 390
409 /* 391 /*
@@ -411,7 +393,7 @@ acpi_get_table (
411 * table is not loaded. 393 * table is not loaded.
412 */ 394 */
413 if (tbl_ptr == NULL) { 395 if (tbl_ptr == NULL) {
414 return_ACPI_STATUS (AE_NOT_EXIST); 396 return_ACPI_STATUS(AE_NOT_EXIST);
415 } 397 }
416 398
417 /* Get the table length */ 399 /* Get the table length */
@@ -419,23 +401,22 @@ acpi_get_table (
419 if (table_type == ACPI_TABLE_RSDP) { 401 if (table_type == ACPI_TABLE_RSDP) {
420 /* RSD PTR is the only "table" without a header */ 402 /* RSD PTR is the only "table" without a header */
421 403
422 table_length = sizeof (struct rsdp_descriptor); 404 table_length = sizeof(struct rsdp_descriptor);
423 } 405 } else {
424 else {
425 table_length = (acpi_size) tbl_ptr->length; 406 table_length = (acpi_size) tbl_ptr->length;
426 } 407 }
427 408
428 /* Validate/Allocate/Clear caller buffer */ 409 /* Validate/Allocate/Clear caller buffer */
429 410
430 status = acpi_ut_initialize_buffer (ret_buffer, table_length); 411 status = acpi_ut_initialize_buffer(ret_buffer, table_length);
431 if (ACPI_FAILURE (status)) { 412 if (ACPI_FAILURE(status)) {
432 return_ACPI_STATUS (status); 413 return_ACPI_STATUS(status);
433 } 414 }
434 415
435 /* Copy the table to the buffer */ 416 /* Copy the table to the buffer */
436 417
437 ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); 418 ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length);
438 return_ACPI_STATUS (AE_OK); 419 return_ACPI_STATUS(AE_OK);
439} 420}
440EXPORT_SYMBOL(acpi_get_table);
441 421
422EXPORT_SYMBOL(acpi_get_table);
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index dc3c3f6a9f62..3b8a7e063e8a 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -46,22 +46,56 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/actables.h> 47#include <acpi/actables.h>
48 48
49
50#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbxfroot") 50ACPI_MODULE_NAME("tbxfroot")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static acpi_status 53static acpi_status
56acpi_tb_find_rsdp ( 54acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags);
57 struct acpi_table_desc *table_info,
58 u32 flags);
59 55
60static u8 * 56static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
61acpi_tb_scan_memory_for_rsdp (
62 u8 *start_address,
63 u32 length);
64 57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_tb_validate_rsdp
61 *
62 * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
63 *
64 * RETURN: Status
65 *
66 * DESCRIPTION: Validate the RSDP (ptr)
67 *
68 ******************************************************************************/
69
70acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
71{
72 ACPI_FUNCTION_ENTRY();
73
74 /*
75 * The signature and checksum must both be correct
76 */
77 if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) {
78 /* Nope, BAD Signature */
79
80 return (AE_BAD_SIGNATURE);
81 }
82
83 /* Check the standard checksum */
84
85 if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
86 return (AE_BAD_CHECKSUM);
87 }
88
89 /* Check extended checksum if table version >= 2 */
90
91 if ((rsdp->revision >= 2) &&
92 (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) !=
93 0)) {
94 return (AE_BAD_CHECKSUM);
95 }
96
97 return (AE_OK);
98}
65 99
66/******************************************************************************* 100/*******************************************************************************
67 * 101 *
@@ -80,28 +114,24 @@ acpi_tb_scan_memory_for_rsdp (
80 ******************************************************************************/ 114 ******************************************************************************/
81 115
82acpi_status 116acpi_status
83acpi_tb_find_table ( 117acpi_tb_find_table(char *signature,
84 char *signature, 118 char *oem_id,
85 char *oem_id, 119 char *oem_table_id, struct acpi_table_header ** table_ptr)
86 char *oem_table_id,
87 struct acpi_table_header **table_ptr)
88{ 120{
89 acpi_status status; 121 acpi_status status;
90 struct acpi_table_header *table; 122 struct acpi_table_header *table;
91
92
93 ACPI_FUNCTION_TRACE ("tb_find_table");
94 123
124 ACPI_FUNCTION_TRACE("tb_find_table");
95 125
96 /* Validate string lengths */ 126 /* Validate string lengths */
97 127
98 if ((ACPI_STRLEN (signature) > ACPI_NAME_SIZE) || 128 if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) ||
99 (ACPI_STRLEN (oem_id) > sizeof (table->oem_id)) || 129 (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) ||
100 (ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) { 130 (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) {
101 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 131 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
102 } 132 }
103 133
104 if (!ACPI_STRNCMP (signature, DSDT_SIG, ACPI_NAME_SIZE)) { 134 if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) {
105 /* 135 /*
106 * The DSDT pointer is contained in the FADT, not the RSDT. 136 * The DSDT pointer is contained in the FADT, not the RSDT.
107 * This code should suffice, because the only code that would perform 137 * This code should suffice, because the only code that would perform
@@ -110,40 +140,36 @@ acpi_tb_find_table (
110 * If this becomes insufficient, the FADT will have to be found first. 140 * If this becomes insufficient, the FADT will have to be found first.
111 */ 141 */
112 if (!acpi_gbl_DSDT) { 142 if (!acpi_gbl_DSDT) {
113 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 143 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
114 } 144 }
115 table = acpi_gbl_DSDT; 145 table = acpi_gbl_DSDT;
116 } 146 } else {
117 else {
118 /* Find the table */ 147 /* Find the table */
119 148
120 status = acpi_get_firmware_table (signature, 1, 149 status = acpi_get_firmware_table(signature, 1,
121 ACPI_LOGICAL_ADDRESSING, &table); 150 ACPI_LOGICAL_ADDRESSING,
122 if (ACPI_FAILURE (status)) { 151 &table);
123 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
124 } 154 }
125 } 155 }
126 156
127 /* Check oem_id and oem_table_id */ 157 /* Check oem_id and oem_table_id */
128 158
129 if ((oem_id[0] && ACPI_STRNCMP ( 159 if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id,
130 oem_id, table->oem_id, 160 sizeof(table->oem_id))) ||
131 sizeof (table->oem_id))) || 161 (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id,
132 162 sizeof(table->oem_table_id)))) {
133 (oem_table_id[0] && ACPI_STRNCMP ( 163 return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
134 oem_table_id, table->oem_table_id,
135 sizeof (table->oem_table_id)))) {
136 return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
137 } 164 }
138 165
139 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", 166 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n",
140 table->signature)); 167 table->signature));
141 168
142 *table_ptr = table; 169 *table_ptr = table;
143 return_ACPI_STATUS (AE_OK); 170 return_ACPI_STATUS(AE_OK);
144} 171}
145 172
146
147/******************************************************************************* 173/*******************************************************************************
148 * 174 *
149 * FUNCTION: acpi_get_firmware_table 175 * FUNCTION: acpi_get_firmware_table
@@ -164,34 +190,28 @@ acpi_tb_find_table (
164 ******************************************************************************/ 190 ******************************************************************************/
165 191
166acpi_status 192acpi_status
167acpi_get_firmware_table ( 193acpi_get_firmware_table(acpi_string signature,
168 acpi_string signature, 194 u32 instance,
169 u32 instance, 195 u32 flags, struct acpi_table_header **table_pointer)
170 u32 flags,
171 struct acpi_table_header **table_pointer)
172{ 196{
173 acpi_status status; 197 acpi_status status;
174 struct acpi_pointer address; 198 struct acpi_pointer address;
175 struct acpi_table_header *header = NULL; 199 struct acpi_table_header *header = NULL;
176 struct acpi_table_desc *table_info = NULL; 200 struct acpi_table_desc *table_info = NULL;
177 struct acpi_table_desc *rsdt_info; 201 struct acpi_table_desc *rsdt_info;
178 u32 table_count; 202 u32 table_count;
179 u32 i; 203 u32 i;
180 u32 j; 204 u32 j;
181
182
183 ACPI_FUNCTION_TRACE ("acpi_get_firmware_table");
184 205
206 ACPI_FUNCTION_TRACE("acpi_get_firmware_table");
185 207
186 /* 208 /*
187 * Ensure that at least the table manager is initialized. We don't 209 * Ensure that at least the table manager is initialized. We don't
188 * require that the entire ACPI subsystem is up for this interface. 210 * require that the entire ACPI subsystem is up for this interface.
189 * If we have a buffer, we must have a length too 211 * If we have a buffer, we must have a length too
190 */ 212 */
191 if ((instance == 0) || 213 if ((instance == 0) || (!signature) || (!table_pointer)) {
192 (!signature) || 214 return_ACPI_STATUS(AE_BAD_PARAMETER);
193 (!table_pointer)) {
194 return_ACPI_STATUS (AE_BAD_PARAMETER);
195 } 215 }
196 216
197 /* Ensure that we have a RSDP */ 217 /* Ensure that we have a RSDP */
@@ -199,48 +219,41 @@ acpi_get_firmware_table (
199 if (!acpi_gbl_RSDP) { 219 if (!acpi_gbl_RSDP) {
200 /* Get the RSDP */ 220 /* Get the RSDP */
201 221
202 status = acpi_os_get_root_pointer (flags, &address); 222 status = acpi_os_get_root_pointer(flags, &address);
203 if (ACPI_FAILURE (status)) { 223 if (ACPI_FAILURE(status)) {
204 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n"));
205 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 225 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
206 } 226 }
207 227
208 /* Map and validate the RSDP */ 228 /* Map and validate the RSDP */
209 229
210 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 230 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
211 status = acpi_os_map_memory (address.pointer.physical, 231 status = acpi_os_map_memory(address.pointer.physical,
212 sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP); 232 sizeof(struct
213 if (ACPI_FAILURE (status)) { 233 rsdp_descriptor),
214 return_ACPI_STATUS (status); 234 (void *)&acpi_gbl_RSDP);
235 if (ACPI_FAILURE(status)) {
236 return_ACPI_STATUS(status);
215 } 237 }
216 } 238 } else {
217 else {
218 acpi_gbl_RSDP = address.pointer.logical; 239 acpi_gbl_RSDP = address.pointer.logical;
219 } 240 }
220 241
221 /* The signature and checksum must both be correct */ 242 /* The RDSP signature and checksum must both be correct */
222
223 if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG,
224 sizeof (RSDP_SIG)-1) != 0) {
225 /* Nope, BAD Signature */
226 243
227 return_ACPI_STATUS (AE_BAD_SIGNATURE); 244 status = acpi_tb_validate_rsdp(acpi_gbl_RSDP);
228 } 245 if (ACPI_FAILURE(status)) {
229 246 return_ACPI_STATUS(status);
230 if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
231 /* Nope, BAD Checksum */
232
233 return_ACPI_STATUS (AE_BAD_CHECKSUM);
234 } 247 }
235 } 248 }
236 249
237 /* Get the RSDT address via the RSDP */ 250 /* Get the RSDT address via the RSDP */
238 251
239 acpi_tb_get_rsdt_address (&address); 252 acpi_tb_get_rsdt_address(&address);
240 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
241 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
242 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
243 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
244 257
245 /* Insert processor_mode flags */ 258 /* Insert processor_mode flags */
246 259
@@ -248,30 +261,30 @@ acpi_get_firmware_table (
248 261
249 /* Get and validate the RSDT */ 262 /* Get and validate the RSDT */
250 263
251 rsdt_info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 264 rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
252 if (!rsdt_info) { 265 if (!rsdt_info) {
253 return_ACPI_STATUS (AE_NO_MEMORY); 266 return_ACPI_STATUS(AE_NO_MEMORY);
254 } 267 }
255 268
256 status = acpi_tb_get_table (&address, rsdt_info); 269 status = acpi_tb_get_table(&address, rsdt_info);
257 if (ACPI_FAILURE (status)) { 270 if (ACPI_FAILURE(status)) {
258 goto cleanup; 271 goto cleanup;
259 } 272 }
260 273
261 status = acpi_tb_validate_rsdt (rsdt_info->pointer); 274 status = acpi_tb_validate_rsdt(rsdt_info->pointer);
262 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
263 goto cleanup; 276 goto cleanup;
264 } 277 }
265 278
266 /* Allocate a scratch table header and table descriptor */ 279 /* Allocate a scratch table header and table descriptor */
267 280
268 header = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_header)); 281 header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header));
269 if (!header) { 282 if (!header) {
270 status = AE_NO_MEMORY; 283 status = AE_NO_MEMORY;
271 goto cleanup; 284 goto cleanup;
272 } 285 }
273 286
274 table_info = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_desc)); 287 table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc));
275 if (!table_info) { 288 if (!table_info) {
276 status = AE_NO_MEMORY; 289 status = AE_NO_MEMORY;
277 goto cleanup; 290 goto cleanup;
@@ -279,7 +292,8 @@ acpi_get_firmware_table (
279 292
280 /* Get the number of table pointers within the RSDT */ 293 /* Get the number of table pointers within the RSDT */
281 294
282 table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_info->pointer); 295 table_count =
296 acpi_tb_get_table_count(acpi_gbl_RSDP, rsdt_info->pointer);
283 address.pointer_type = acpi_gbl_table_flags | flags; 297 address.pointer_type = acpi_gbl_table_flags | flags;
284 298
285 /* 299 /*
@@ -287,35 +301,42 @@ acpi_get_firmware_table (
287 * requested table 301 * requested table
288 */ 302 */
289 for (i = 0, j = 0; i < table_count; i++) { 303 for (i = 0, j = 0; i < table_count; i++) {
290 /* Get the next table pointer, handle RSDT vs. XSDT */ 304 /*
291 305 * Get the next table pointer, handle RSDT vs. XSDT
292 if (acpi_gbl_RSDP->revision < 2) { 306 * RSDT pointers are 32 bits, XSDT pointers are 64 bits
293 address.pointer.value = (ACPI_CAST_PTR ( 307 */
294 RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 308 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
295 } 309 address.pointer.value =
296 else { 310 (ACPI_CAST_PTR
297 address.pointer.value = (ACPI_CAST_PTR ( 311 (RSDT_DESCRIPTOR,
298 XSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 312 rsdt_info->pointer))->table_offset_entry[i];
313 } else {
314 address.pointer.value =
315 (ACPI_CAST_PTR
316 (XSDT_DESCRIPTOR,
317 rsdt_info->pointer))->table_offset_entry[i];
299 } 318 }
300 319
301 /* Get the table header */ 320 /* Get the table header */
302 321
303 status = acpi_tb_get_table_header (&address, header); 322 status = acpi_tb_get_table_header(&address, header);
304 if (ACPI_FAILURE (status)) { 323 if (ACPI_FAILURE(status)) {
305 goto cleanup; 324 goto cleanup;
306 } 325 }
307 326
308 /* Compare table signatures and table instance */ 327 /* Compare table signatures and table instance */
309 328
310 if (!ACPI_STRNCMP (header->signature, signature, ACPI_NAME_SIZE)) { 329 if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) {
311 /* An instance of the table was found */ 330 /* An instance of the table was found */
312 331
313 j++; 332 j++;
314 if (j >= instance) { 333 if (j >= instance) {
315 /* Found the correct instance, get the entire table */ 334 /* Found the correct instance, get the entire table */
316 335
317 status = acpi_tb_get_table_body (&address, header, table_info); 336 status =
318 if (ACPI_FAILURE (status)) { 337 acpi_tb_get_table_body(&address, header,
338 table_info);
339 if (ACPI_FAILURE(status)) {
319 goto cleanup; 340 goto cleanup;
320 } 341 }
321 342
@@ -329,22 +350,23 @@ acpi_get_firmware_table (
329 350
330 status = AE_NOT_EXIST; 351 status = AE_NOT_EXIST;
331 352
332 353 cleanup:
333cleanup: 354 if (rsdt_info->pointer) {
334 acpi_os_unmap_memory (rsdt_info->pointer, 355 acpi_os_unmap_memory(rsdt_info->pointer,
335 (acpi_size) rsdt_info->pointer->length); 356 (acpi_size) rsdt_info->pointer->length);
336 ACPI_MEM_FREE (rsdt_info); 357 }
358 ACPI_MEM_FREE(rsdt_info);
337 359
338 if (header) { 360 if (header) {
339 ACPI_MEM_FREE (header); 361 ACPI_MEM_FREE(header);
340 } 362 }
341 if (table_info) { 363 if (table_info) {
342 ACPI_MEM_FREE (table_info); 364 ACPI_MEM_FREE(table_info);
343 } 365 }
344 return_ACPI_STATUS (status); 366 return_ACPI_STATUS(status);
345} 367}
346EXPORT_SYMBOL(acpi_get_firmware_table);
347 368
369EXPORT_SYMBOL(acpi_get_firmware_table);
348 370
349/* TBD: Move to a new file */ 371/* TBD: Move to a new file */
350 372
@@ -363,35 +385,29 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
363 * 385 *
364 ******************************************************************************/ 386 ******************************************************************************/
365 387
366acpi_status 388acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
367acpi_find_root_pointer (
368 u32 flags,
369 struct acpi_pointer *rsdp_address)
370{ 389{
371 struct acpi_table_desc table_info; 390 struct acpi_table_desc table_info;
372 acpi_status status; 391 acpi_status status;
373
374
375 ACPI_FUNCTION_TRACE ("acpi_find_root_pointer");
376 392
393 ACPI_FUNCTION_TRACE("acpi_find_root_pointer");
377 394
378 /* Get the RSDP */ 395 /* Get the RSDP */
379 396
380 status = acpi_tb_find_rsdp (&table_info, flags); 397 status = acpi_tb_find_rsdp(&table_info, flags);
381 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 399 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
383 "RSDP structure not found, %s Flags=%X\n", 400 "RSDP structure not found, %s Flags=%X\n",
384 acpi_format_exception (status), flags)); 401 acpi_format_exception(status), flags));
385 402
386 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 403 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
387 } 404 }
388 405
389 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER; 406 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER;
390 rsdp_address->pointer.physical = table_info.physical_address; 407 rsdp_address->pointer.physical = table_info.physical_address;
391 return_ACPI_STATUS (AE_OK); 408 return_ACPI_STATUS(AE_OK);
392} 409}
393 410
394
395/******************************************************************************* 411/*******************************************************************************
396 * 412 *
397 * FUNCTION: acpi_tb_scan_memory_for_rsdp 413 * FUNCTION: acpi_tb_scan_memory_for_rsdp
@@ -405,68 +421,45 @@ acpi_find_root_pointer (
405 * 421 *
406 ******************************************************************************/ 422 ******************************************************************************/
407 423
408static u8 * 424static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
409acpi_tb_scan_memory_for_rsdp (
410 u8 *start_address,
411 u32 length)
412{ 425{
413 u8 *mem_rover; 426 acpi_status status;
414 u8 *end_address; 427 u8 *mem_rover;
415 u8 checksum; 428 u8 *end_address;
416
417
418 ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp");
419 429
430 ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp");
420 431
421 end_address = start_address + length; 432 end_address = start_address + length;
422 433
423 /* Search from given start address for the requested length */ 434 /* Search from given start address for the requested length */
424 435
425 for (mem_rover = start_address; mem_rover < end_address; 436 for (mem_rover = start_address; mem_rover < end_address;
426 mem_rover += ACPI_RSDP_SCAN_STEP) { 437 mem_rover += ACPI_RSDP_SCAN_STEP) {
427 /* The signature and checksum must both be correct */ 438 /* The RSDP signature and checksum must both be correct */
428 439
429 if (ACPI_STRNCMP ((char *) mem_rover, 440 status =
430 RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) { 441 acpi_tb_validate_rsdp(ACPI_CAST_PTR
431 /* No signature match, keep looking */ 442 (struct rsdp_descriptor, mem_rover));
432 443 if (ACPI_SUCCESS(status)) {
433 continue; 444 /* Sig and checksum valid, we have found a real RSDP */
434 } 445
435 446 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
436 /* Signature matches, check the appropriate checksum */ 447 "RSDP located at physical address %p\n",
437 448 mem_rover));
438 if ((ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover))->revision < 2) { 449 return_PTR(mem_rover);
439 /* ACPI version 1.0 */
440
441 checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH);
442 }
443 else {
444 /* Post ACPI 1.0, use extended_checksum */
445
446 checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_XCHECKSUM_LENGTH);
447 } 450 }
448 451
449 if (checksum == 0) { 452 /* No sig match or bad checksum, keep searching */
450 /* Checksum valid, we have found a valid RSDP */
451
452 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
453 "RSDP located at physical address %p\n", mem_rover));
454 return_PTR (mem_rover);
455 }
456
457 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
458 "Found an RSDP at physical address %p, but it has a bad checksum\n",
459 mem_rover));
460 } 453 }
461 454
462 /* Searched entire block, no RSDP was found */ 455 /* Searched entire block, no RSDP was found */
463 456
464 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 457 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
465 "Searched entire block, no valid RSDP was found.\n")); 458 "Searched entire block from %p, valid RSDP was not found\n",
466 return_PTR (NULL); 459 start_address));
460 return_PTR(NULL);
467} 461}
468 462
469
470/******************************************************************************* 463/*******************************************************************************
471 * 464 *
472 * FUNCTION: acpi_tb_find_rsdp 465 * FUNCTION: acpi_tb_find_rsdp
@@ -490,18 +483,14 @@ acpi_tb_scan_memory_for_rsdp (
490 ******************************************************************************/ 483 ******************************************************************************/
491 484
492static acpi_status 485static acpi_status
493acpi_tb_find_rsdp ( 486acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
494 struct acpi_table_desc *table_info,
495 u32 flags)
496{ 487{
497 u8 *table_ptr; 488 u8 *table_ptr;
498 u8 *mem_rover; 489 u8 *mem_rover;
499 u32 physical_address; 490 u32 physical_address;
500 acpi_status status; 491 acpi_status status;
501
502
503 ACPI_FUNCTION_TRACE ("tb_find_rsdp");
504 492
493 ACPI_FUNCTION_TRACE("tb_find_rsdp");
505 494
506 /* 495 /*
507 * Scan supports either logical addressing or physical addressing 496 * Scan supports either logical addressing or physical addressing
@@ -509,23 +498,25 @@ acpi_tb_find_rsdp (
509 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 498 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
510 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ 499 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
511 500
512 status = acpi_os_map_memory ( 501 status = acpi_os_map_memory((acpi_physical_address)
513 (acpi_physical_address) ACPI_EBDA_PTR_LOCATION, 502 ACPI_EBDA_PTR_LOCATION,
514 ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr); 503 ACPI_EBDA_PTR_LENGTH,
515 if (ACPI_FAILURE (status)) { 504 (void *)&table_ptr);
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 505 if (ACPI_FAILURE(status)) {
517 "Could not map memory at %8.8X for length %X\n", 506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
518 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); 507 "Could not map memory at %8.8X for length %X\n",
519 508 ACPI_EBDA_PTR_LOCATION,
520 return_ACPI_STATUS (status); 509 ACPI_EBDA_PTR_LENGTH));
510
511 return_ACPI_STATUS(status);
521 } 512 }
522 513
523 ACPI_MOVE_16_TO_32 (&physical_address, table_ptr); 514 ACPI_MOVE_16_TO_32(&physical_address, table_ptr);
524 515
525 /* Convert segment part to physical address */ 516 /* Convert segment part to physical address */
526 517
527 physical_address <<= 4; 518 physical_address <<= 4;
528 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH); 519 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH);
529 520
530 /* EBDA present? */ 521 /* EBDA present? */
531 522
@@ -534,59 +525,67 @@ acpi_tb_find_rsdp (
534 * 1b) Search EBDA paragraphs (EBDa is required to be a 525 * 1b) Search EBDA paragraphs (EBDa is required to be a
535 * minimum of 1_k length) 526 * minimum of 1_k length)
536 */ 527 */
537 status = acpi_os_map_memory ( 528 status = acpi_os_map_memory((acpi_physical_address)
538 (acpi_physical_address) physical_address, 529 physical_address,
539 ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr); 530 ACPI_EBDA_WINDOW_SIZE,
540 if (ACPI_FAILURE (status)) { 531 (void *)&table_ptr);
541 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 532 if (ACPI_FAILURE(status)) {
542 "Could not map memory at %8.8X for length %X\n", 533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
543 physical_address, ACPI_EBDA_WINDOW_SIZE)); 534 "Could not map memory at %8.8X for length %X\n",
544 535 physical_address,
545 return_ACPI_STATUS (status); 536 ACPI_EBDA_WINDOW_SIZE));
537
538 return_ACPI_STATUS(status);
546 } 539 }
547 540
548 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, 541 mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr,
549 ACPI_EBDA_WINDOW_SIZE); 542 ACPI_EBDA_WINDOW_SIZE);
550 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); 543 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
551 544
552 if (mem_rover) { 545 if (mem_rover) {
553 /* Found it, return the physical address */ 546 /* Return the physical address */
554 547
555 physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); 548 physical_address +=
549 ACPI_PTR_DIFF(mem_rover, table_ptr);
556 550
557 table_info->physical_address = 551 table_info->physical_address =
558 (acpi_physical_address) physical_address; 552 (acpi_physical_address) physical_address;
559 return_ACPI_STATUS (AE_OK); 553 return_ACPI_STATUS(AE_OK);
560 } 554 }
561 } 555 }
562 556
563 /* 557 /*
564 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 558 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
565 */ 559 */
566 status = acpi_os_map_memory ( 560 status = acpi_os_map_memory((acpi_physical_address)
567 (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE, 561 ACPI_HI_RSDP_WINDOW_BASE,
568 ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr); 562 ACPI_HI_RSDP_WINDOW_SIZE,
569 563 (void *)&table_ptr);
570 if (ACPI_FAILURE (status)) { 564
571 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 565 if (ACPI_FAILURE(status)) {
572 "Could not map memory at %8.8X for length %X\n", 566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
573 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); 567 "Could not map memory at %8.8X for length %X\n",
574 568 ACPI_HI_RSDP_WINDOW_BASE,
575 return_ACPI_STATUS (status); 569 ACPI_HI_RSDP_WINDOW_SIZE));
570
571 return_ACPI_STATUS(status);
576 } 572 }
577 573
578 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 574 mem_rover =
579 acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 575 acpi_tb_scan_memory_for_rsdp(table_ptr,
576 ACPI_HI_RSDP_WINDOW_SIZE);
577 acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
580 578
581 if (mem_rover) { 579 if (mem_rover) {
582 /* Found it, return the physical address */ 580 /* Return the physical address */
583 581
584 physical_address = 582 physical_address =
585 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); 583 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover,
584 table_ptr);
586 585
587 table_info->physical_address = 586 table_info->physical_address =
588 (acpi_physical_address) physical_address; 587 (acpi_physical_address) physical_address;
589 return_ACPI_STATUS (AE_OK); 588 return_ACPI_STATUS(AE_OK);
590 } 589 }
591 } 590 }
592 591
@@ -596,8 +595,8 @@ acpi_tb_find_rsdp (
596 else { 595 else {
597 /* 1a) Get the location of the EBDA */ 596 /* 1a) Get the location of the EBDA */
598 597
599 ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION); 598 ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION);
600 physical_address <<= 4; /* Convert segment to physical address */ 599 physical_address <<= 4; /* Convert segment to physical address */
601 600
602 /* EBDA present? */ 601 /* EBDA present? */
603 602
@@ -606,34 +605,38 @@ acpi_tb_find_rsdp (
606 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 605 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of
607 * 1_k length) 606 * 1_k length)
608 */ 607 */
609 mem_rover = acpi_tb_scan_memory_for_rsdp ( 608 mem_rover =
610 ACPI_PHYSADDR_TO_PTR (physical_address), 609 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
611 ACPI_EBDA_WINDOW_SIZE); 610 (physical_address),
611 ACPI_EBDA_WINDOW_SIZE);
612 if (mem_rover) { 612 if (mem_rover) {
613 /* Found it, return the physical address */ 613 /* Return the physical address */
614 614
615 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 615 table_info->physical_address =
616 return_ACPI_STATUS (AE_OK); 616 ACPI_TO_INTEGER(mem_rover);
617 return_ACPI_STATUS(AE_OK);
617 } 618 }
618 } 619 }
619 620
620 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ 621 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
621 622
622 mem_rover = acpi_tb_scan_memory_for_rsdp ( 623 mem_rover =
623 ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), 624 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
624 ACPI_HI_RSDP_WINDOW_SIZE); 625 (ACPI_HI_RSDP_WINDOW_BASE),
626 ACPI_HI_RSDP_WINDOW_SIZE);
625 if (mem_rover) { 627 if (mem_rover) {
626 /* Found it, return the physical address */ 628 /* Found it, return the physical address */
627 629
628 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 630 table_info->physical_address =
629 return_ACPI_STATUS (AE_OK); 631 ACPI_TO_INTEGER(mem_rover);
632 return_ACPI_STATUS(AE_OK);
630 } 633 }
631 } 634 }
632 635
633 /* RSDP signature was not found */ 636 /* A valid RSDP was not found */
634 637
635 return_ACPI_STATUS (AE_NOT_FOUND); 638 ACPI_REPORT_ERROR(("No valid RSDP was found\n"));
639 return_ACPI_STATUS(AE_NOT_FOUND);
636} 640}
637 641
638#endif 642#endif
639
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 79c3a686bc44..a24847c08f7f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -70,9 +70,9 @@
70#define CELSIUS_TO_KELVIN(t) ((t+273)*10) 70#define CELSIUS_TO_KELVIN(t) ((t+273)*10)
71 71
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME ("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75MODULE_AUTHOR("Paul Diefenbaugh"); 75 MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -80,143 +80,145 @@ static int tzp;
80module_param(tzp, int, 0); 80module_param(tzp, int, 0);
81MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); 81MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
82 82
83 83static int acpi_thermal_add(struct acpi_device *device);
84static int acpi_thermal_add (struct acpi_device *device); 84static int acpi_thermal_remove(struct acpi_device *device, int type);
85static int acpi_thermal_remove (struct acpi_device *device, int type);
86static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); 85static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
87static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); 86static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
88static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); 87static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
89static ssize_t acpi_thermal_write_trip_points (struct file*,const char __user *,size_t,loff_t *); 88static ssize_t acpi_thermal_write_trip_points(struct file *,
89 const char __user *, size_t,
90 loff_t *);
90static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); 91static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
91static ssize_t acpi_thermal_write_cooling_mode (struct file*,const char __user *,size_t,loff_t *); 92static ssize_t acpi_thermal_write_cooling_mode(struct file *,
93 const char __user *, size_t,
94 loff_t *);
92static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); 95static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
93static ssize_t acpi_thermal_write_polling(struct file*,const char __user *,size_t,loff_t *); 96static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
97 size_t, loff_t *);
94 98
95static struct acpi_driver acpi_thermal_driver = { 99static struct acpi_driver acpi_thermal_driver = {
96 .name = ACPI_THERMAL_DRIVER_NAME, 100 .name = ACPI_THERMAL_DRIVER_NAME,
97 .class = ACPI_THERMAL_CLASS, 101 .class = ACPI_THERMAL_CLASS,
98 .ids = ACPI_THERMAL_HID, 102 .ids = ACPI_THERMAL_HID,
99 .ops = { 103 .ops = {
100 .add = acpi_thermal_add, 104 .add = acpi_thermal_add,
101 .remove = acpi_thermal_remove, 105 .remove = acpi_thermal_remove,
102 }, 106 },
103}; 107};
104 108
105struct acpi_thermal_state { 109struct acpi_thermal_state {
106 u8 critical:1; 110 u8 critical:1;
107 u8 hot:1; 111 u8 hot:1;
108 u8 passive:1; 112 u8 passive:1;
109 u8 active:1; 113 u8 active:1;
110 u8 reserved:4; 114 u8 reserved:4;
111 int active_index; 115 int active_index;
112}; 116};
113 117
114struct acpi_thermal_state_flags { 118struct acpi_thermal_state_flags {
115 u8 valid:1; 119 u8 valid:1;
116 u8 enabled:1; 120 u8 enabled:1;
117 u8 reserved:6; 121 u8 reserved:6;
118}; 122};
119 123
120struct acpi_thermal_critical { 124struct acpi_thermal_critical {
121 struct acpi_thermal_state_flags flags; 125 struct acpi_thermal_state_flags flags;
122 unsigned long temperature; 126 unsigned long temperature;
123}; 127};
124 128
125struct acpi_thermal_hot { 129struct acpi_thermal_hot {
126 struct acpi_thermal_state_flags flags; 130 struct acpi_thermal_state_flags flags;
127 unsigned long temperature; 131 unsigned long temperature;
128}; 132};
129 133
130struct acpi_thermal_passive { 134struct acpi_thermal_passive {
131 struct acpi_thermal_state_flags flags; 135 struct acpi_thermal_state_flags flags;
132 unsigned long temperature; 136 unsigned long temperature;
133 unsigned long tc1; 137 unsigned long tc1;
134 unsigned long tc2; 138 unsigned long tc2;
135 unsigned long tsp; 139 unsigned long tsp;
136 struct acpi_handle_list devices; 140 struct acpi_handle_list devices;
137}; 141};
138 142
139struct acpi_thermal_active { 143struct acpi_thermal_active {
140 struct acpi_thermal_state_flags flags; 144 struct acpi_thermal_state_flags flags;
141 unsigned long temperature; 145 unsigned long temperature;
142 struct acpi_handle_list devices; 146 struct acpi_handle_list devices;
143}; 147};
144 148
145struct acpi_thermal_trips { 149struct acpi_thermal_trips {
146 struct acpi_thermal_critical critical; 150 struct acpi_thermal_critical critical;
147 struct acpi_thermal_hot hot; 151 struct acpi_thermal_hot hot;
148 struct acpi_thermal_passive passive; 152 struct acpi_thermal_passive passive;
149 struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; 153 struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
150}; 154};
151 155
152struct acpi_thermal_flags { 156struct acpi_thermal_flags {
153 u8 cooling_mode:1; /* _SCP */ 157 u8 cooling_mode:1; /* _SCP */
154 u8 devices:1; /* _TZD */ 158 u8 devices:1; /* _TZD */
155 u8 reserved:6; 159 u8 reserved:6;
156}; 160};
157 161
158struct acpi_thermal { 162struct acpi_thermal {
159 acpi_handle handle; 163 acpi_handle handle;
160 acpi_bus_id name; 164 acpi_bus_id name;
161 unsigned long temperature; 165 unsigned long temperature;
162 unsigned long last_temperature; 166 unsigned long last_temperature;
163 unsigned long polling_frequency; 167 unsigned long polling_frequency;
164 u8 cooling_mode; 168 u8 cooling_mode;
165 volatile u8 zombie; 169 volatile u8 zombie;
166 struct acpi_thermal_flags flags; 170 struct acpi_thermal_flags flags;
167 struct acpi_thermal_state state; 171 struct acpi_thermal_state state;
168 struct acpi_thermal_trips trips; 172 struct acpi_thermal_trips trips;
169 struct acpi_handle_list devices; 173 struct acpi_handle_list devices;
170 struct timer_list timer; 174 struct timer_list timer;
171}; 175};
172 176
173static struct file_operations acpi_thermal_state_fops = { 177static struct file_operations acpi_thermal_state_fops = {
174 .open = acpi_thermal_state_open_fs, 178 .open = acpi_thermal_state_open_fs,
175 .read = seq_read, 179 .read = seq_read,
176 .llseek = seq_lseek, 180 .llseek = seq_lseek,
177 .release = single_release, 181 .release = single_release,
178}; 182};
179 183
180static struct file_operations acpi_thermal_temp_fops = { 184static struct file_operations acpi_thermal_temp_fops = {
181 .open = acpi_thermal_temp_open_fs, 185 .open = acpi_thermal_temp_open_fs,
182 .read = seq_read, 186 .read = seq_read,
183 .llseek = seq_lseek, 187 .llseek = seq_lseek,
184 .release = single_release, 188 .release = single_release,
185}; 189};
186 190
187static struct file_operations acpi_thermal_trip_fops = { 191static struct file_operations acpi_thermal_trip_fops = {
188 .open = acpi_thermal_trip_open_fs, 192 .open = acpi_thermal_trip_open_fs,
189 .read = seq_read, 193 .read = seq_read,
190 .write = acpi_thermal_write_trip_points, 194 .write = acpi_thermal_write_trip_points,
191 .llseek = seq_lseek, 195 .llseek = seq_lseek,
192 .release = single_release, 196 .release = single_release,
193}; 197};
194 198
195static struct file_operations acpi_thermal_cooling_fops = { 199static struct file_operations acpi_thermal_cooling_fops = {
196 .open = acpi_thermal_cooling_open_fs, 200 .open = acpi_thermal_cooling_open_fs,
197 .read = seq_read, 201 .read = seq_read,
198 .write = acpi_thermal_write_cooling_mode, 202 .write = acpi_thermal_write_cooling_mode,
199 .llseek = seq_lseek, 203 .llseek = seq_lseek,
200 .release = single_release, 204 .release = single_release,
201}; 205};
202 206
203static struct file_operations acpi_thermal_polling_fops = { 207static struct file_operations acpi_thermal_polling_fops = {
204 .open = acpi_thermal_polling_open_fs, 208 .open = acpi_thermal_polling_open_fs,
205 .read = seq_read, 209 .read = seq_read,
206 .write = acpi_thermal_write_polling, 210 .write = acpi_thermal_write_polling,
207 .llseek = seq_lseek, 211 .llseek = seq_lseek,
208 .release = single_release, 212 .release = single_release,
209}; 213};
210 214
211/* -------------------------------------------------------------------------- 215/* --------------------------------------------------------------------------
212 Thermal Zone Management 216 Thermal Zone Management
213 -------------------------------------------------------------------------- */ 217 -------------------------------------------------------------------------- */
214 218
215static int 219static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
216acpi_thermal_get_temperature (
217 struct acpi_thermal *tz)
218{ 220{
219 acpi_status status = AE_OK; 221 acpi_status status = AE_OK;
220 222
221 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature"); 223 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
222 224
@@ -225,41 +227,39 @@ acpi_thermal_get_temperature (
225 227
226 tz->last_temperature = tz->temperature; 228 tz->last_temperature = tz->temperature;
227 229
228 status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); 230 status =
231 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
229 if (ACPI_FAILURE(status)) 232 if (ACPI_FAILURE(status))
230 return_VALUE(-ENODEV); 233 return_VALUE(-ENODEV);
231 234
232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature)); 235 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
236 tz->temperature));
233 237
234 return_VALUE(0); 238 return_VALUE(0);
235} 239}
236 240
237 241static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
238static int
239acpi_thermal_get_polling_frequency (
240 struct acpi_thermal *tz)
241{ 242{
242 acpi_status status = AE_OK; 243 acpi_status status = AE_OK;
243 244
244 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency"); 245 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
245 246
246 if (!tz) 247 if (!tz)
247 return_VALUE(-EINVAL); 248 return_VALUE(-EINVAL);
248 249
249 status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); 250 status =
251 acpi_evaluate_integer(tz->handle, "_TZP", NULL,
252 &tz->polling_frequency);
250 if (ACPI_FAILURE(status)) 253 if (ACPI_FAILURE(status))
251 return_VALUE(-ENODEV); 254 return_VALUE(-ENODEV);
252 255
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency)); 256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
257 tz->polling_frequency));
254 258
255 return_VALUE(0); 259 return_VALUE(0);
256} 260}
257 261
258 262static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
259static int
260acpi_thermal_set_polling (
261 struct acpi_thermal *tz,
262 int seconds)
263{ 263{
264 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling"); 264 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
265 265
@@ -268,21 +268,19 @@ acpi_thermal_set_polling (
268 268
269 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ 269 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
270 270
271 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency set to %lu seconds\n", tz->polling_frequency)); 271 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
272 "Polling frequency set to %lu seconds\n",
273 tz->polling_frequency));
272 274
273 return_VALUE(0); 275 return_VALUE(0);
274} 276}
275 277
276 278static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
277static int
278acpi_thermal_set_cooling_mode (
279 struct acpi_thermal *tz,
280 int mode)
281{ 279{
282 acpi_status status = AE_OK; 280 acpi_status status = AE_OK;
283 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 281 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
284 struct acpi_object_list arg_list = {1, &arg0}; 282 struct acpi_object_list arg_list = { 1, &arg0 };
285 acpi_handle handle = NULL; 283 acpi_handle handle = NULL;
286 284
287 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode"); 285 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
288 286
@@ -303,19 +301,16 @@ acpi_thermal_set_cooling_mode (
303 301
304 tz->cooling_mode = mode; 302 tz->cooling_mode = mode;
305 303
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", 304 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
307 mode?"passive":"active")); 305 mode ? "passive" : "active"));
308 306
309 return_VALUE(0); 307 return_VALUE(0);
310} 308}
311 309
312 310static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
313static int
314acpi_thermal_get_trip_points (
315 struct acpi_thermal *tz)
316{ 311{
317 acpi_status status = AE_OK; 312 acpi_status status = AE_OK;
318 int i = 0; 313 int i = 0;
319 314
320 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points"); 315 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
321 316
@@ -324,111 +319,128 @@ acpi_thermal_get_trip_points (
324 319
325 /* Critical Shutdown (required) */ 320 /* Critical Shutdown (required) */
326 321
327 status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, 322 status = acpi_evaluate_integer(tz->handle, "_CRT", NULL,
328 &tz->trips.critical.temperature); 323 &tz->trips.critical.temperature);
329 if (ACPI_FAILURE(status)) { 324 if (ACPI_FAILURE(status)) {
330 tz->trips.critical.flags.valid = 0; 325 tz->trips.critical.flags.valid = 0;
331 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); 326 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
332 return_VALUE(-ENODEV); 327 return_VALUE(-ENODEV);
333 } 328 } else {
334 else {
335 tz->trips.critical.flags.valid = 1; 329 tz->trips.critical.flags.valid = 1;
336 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%lu]\n", tz->trips.critical.temperature)); 330 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
331 "Found critical threshold [%lu]\n",
332 tz->trips.critical.temperature));
337 } 333 }
338 334
339 /* Critical Sleep (optional) */ 335 /* Critical Sleep (optional) */
340 336
341 status = acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature); 337 status =
338 acpi_evaluate_integer(tz->handle, "_HOT", NULL,
339 &tz->trips.hot.temperature);
342 if (ACPI_FAILURE(status)) { 340 if (ACPI_FAILURE(status)) {
343 tz->trips.hot.flags.valid = 0; 341 tz->trips.hot.flags.valid = 0;
344 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n")); 342 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
345 } 343 } else {
346 else {
347 tz->trips.hot.flags.valid = 1; 344 tz->trips.hot.flags.valid = 1;
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", tz->trips.hot.temperature)); 345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n",
346 tz->trips.hot.temperature));
349 } 347 }
350 348
351 /* Passive: Processors (optional) */ 349 /* Passive: Processors (optional) */
352 350
353 status = acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature); 351 status =
352 acpi_evaluate_integer(tz->handle, "_PSV", NULL,
353 &tz->trips.passive.temperature);
354 if (ACPI_FAILURE(status)) { 354 if (ACPI_FAILURE(status)) {
355 tz->trips.passive.flags.valid = 0; 355 tz->trips.passive.flags.valid = 0;
356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n")); 356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
357 } 357 } else {
358 else {
359 tz->trips.passive.flags.valid = 1; 358 tz->trips.passive.flags.valid = 1;
360 359
361 status = acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1); 360 status =
361 acpi_evaluate_integer(tz->handle, "_TC1", NULL,
362 &tz->trips.passive.tc1);
362 if (ACPI_FAILURE(status)) 363 if (ACPI_FAILURE(status))
363 tz->trips.passive.flags.valid = 0; 364 tz->trips.passive.flags.valid = 0;
364 365
365 status = acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2); 366 status =
367 acpi_evaluate_integer(tz->handle, "_TC2", NULL,
368 &tz->trips.passive.tc2);
366 if (ACPI_FAILURE(status)) 369 if (ACPI_FAILURE(status))
367 tz->trips.passive.flags.valid = 0; 370 tz->trips.passive.flags.valid = 0;
368 371
369 status = acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp); 372 status =
373 acpi_evaluate_integer(tz->handle, "_TSP", NULL,
374 &tz->trips.passive.tsp);
370 if (ACPI_FAILURE(status)) 375 if (ACPI_FAILURE(status))
371 tz->trips.passive.flags.valid = 0; 376 tz->trips.passive.flags.valid = 0;
372 377
373 status = acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices); 378 status =
379 acpi_evaluate_reference(tz->handle, "_PSL", NULL,
380 &tz->trips.passive.devices);
374 if (ACPI_FAILURE(status)) 381 if (ACPI_FAILURE(status))
375 tz->trips.passive.flags.valid = 0; 382 tz->trips.passive.flags.valid = 0;
376 383
377 if (!tz->trips.passive.flags.valid) 384 if (!tz->trips.passive.flags.valid)
378 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid passive threshold\n")); 385 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
386 "Invalid passive threshold\n"));
379 else 387 else
380 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", tz->trips.passive.temperature)); 388 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
389 "Found passive threshold [%lu]\n",
390 tz->trips.passive.temperature));
381 } 391 }
382 392
383 /* Active: Fans, etc. (optional) */ 393 /* Active: Fans, etc. (optional) */
384 394
385 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) { 395 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
386 396
387 char name[5] = {'_','A','C',('0'+i),'\0'}; 397 char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
388 398
389 status = acpi_evaluate_integer(tz->handle, name, NULL, &tz->trips.active[i].temperature); 399 status =
400 acpi_evaluate_integer(tz->handle, name, NULL,
401 &tz->trips.active[i].temperature);
390 if (ACPI_FAILURE(status)) 402 if (ACPI_FAILURE(status))
391 break; 403 break;
392 404
393 name[2] = 'L'; 405 name[2] = 'L';
394 status = acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices); 406 status =
407 acpi_evaluate_reference(tz->handle, name, NULL,
408 &tz->trips.active[i].devices);
395 if (ACPI_SUCCESS(status)) { 409 if (ACPI_SUCCESS(status)) {
396 tz->trips.active[i].flags.valid = 1; 410 tz->trips.active[i].flags.valid = 1;
397 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature)); 411 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
398 } 412 "Found active threshold [%d]:[%lu]\n",
399 else 413 i, tz->trips.active[i].temperature));
400 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i)); 414 } else
415 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
416 "Invalid active threshold [%d]\n",
417 i));
401 } 418 }
402 419
403 return_VALUE(0); 420 return_VALUE(0);
404} 421}
405 422
406 423static int acpi_thermal_get_devices(struct acpi_thermal *tz)
407static int
408acpi_thermal_get_devices (
409 struct acpi_thermal *tz)
410{ 424{
411 acpi_status status = AE_OK; 425 acpi_status status = AE_OK;
412 426
413 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices"); 427 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
414 428
415 if (!tz) 429 if (!tz)
416 return_VALUE(-EINVAL); 430 return_VALUE(-EINVAL);
417 431
418 status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); 432 status =
433 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
419 if (ACPI_FAILURE(status)) 434 if (ACPI_FAILURE(status))
420 return_VALUE(-ENODEV); 435 return_VALUE(-ENODEV);
421 436
422 return_VALUE(0); 437 return_VALUE(0);
423} 438}
424 439
425 440static int acpi_thermal_call_usermode(char *path)
426static int
427acpi_thermal_call_usermode (
428 char *path)
429{ 441{
430 char *argv[2] = {NULL, NULL}; 442 char *argv[2] = { NULL, NULL };
431 char *envp[3] = {NULL, NULL, NULL}; 443 char *envp[3] = { NULL, NULL, NULL };
432 444
433 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode"); 445 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
434 446
@@ -440,19 +452,16 @@ acpi_thermal_call_usermode (
440 /* minimal command environment */ 452 /* minimal command environment */
441 envp[0] = "HOME=/"; 453 envp[0] = "HOME=/";
442 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 454 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
443 455
444 call_usermodehelper(argv[0], argv, envp, 0); 456 call_usermodehelper(argv[0], argv, envp, 0);
445 457
446 return_VALUE(0); 458 return_VALUE(0);
447} 459}
448 460
449 461static int acpi_thermal_critical(struct acpi_thermal *tz)
450static int
451acpi_thermal_critical (
452 struct acpi_thermal *tz)
453{ 462{
454 int result = 0; 463 int result = 0;
455 struct acpi_device *device = NULL; 464 struct acpi_device *device = NULL;
456 465
457 ACPI_FUNCTION_TRACE("acpi_thermal_critical"); 466 ACPI_FUNCTION_TRACE("acpi_thermal_critical");
458 467
@@ -462,29 +471,28 @@ acpi_thermal_critical (
462 if (tz->temperature >= tz->trips.critical.temperature) { 471 if (tz->temperature >= tz->trips.critical.temperature) {
463 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); 472 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
464 tz->trips.critical.flags.enabled = 1; 473 tz->trips.critical.flags.enabled = 1;
465 } 474 } else if (tz->trips.critical.flags.enabled)
466 else if (tz->trips.critical.flags.enabled)
467 tz->trips.critical.flags.enabled = 0; 475 tz->trips.critical.flags.enabled = 0;
468 476
469 result = acpi_bus_get_device(tz->handle, &device); 477 result = acpi_bus_get_device(tz->handle, &device);
470 if (result) 478 if (result)
471 return_VALUE(result); 479 return_VALUE(result);
472 480
473 printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature)); 481 printk(KERN_EMERG
474 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); 482 "Critical temperature reached (%ld C), shutting down.\n",
483 KELVIN_TO_CELSIUS(tz->temperature));
484 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL,
485 tz->trips.critical.flags.enabled);
475 486
476 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); 487 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
477 488
478 return_VALUE(0); 489 return_VALUE(0);
479} 490}
480 491
481 492static int acpi_thermal_hot(struct acpi_thermal *tz)
482static int
483acpi_thermal_hot (
484 struct acpi_thermal *tz)
485{ 493{
486 int result = 0; 494 int result = 0;
487 struct acpi_device *device = NULL; 495 struct acpi_device *device = NULL;
488 496
489 ACPI_FUNCTION_TRACE("acpi_thermal_hot"); 497 ACPI_FUNCTION_TRACE("acpi_thermal_hot");
490 498
@@ -494,30 +502,27 @@ acpi_thermal_hot (
494 if (tz->temperature >= tz->trips.hot.temperature) { 502 if (tz->temperature >= tz->trips.hot.temperature) {
495 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); 503 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n"));
496 tz->trips.hot.flags.enabled = 1; 504 tz->trips.hot.flags.enabled = 1;
497 } 505 } else if (tz->trips.hot.flags.enabled)
498 else if (tz->trips.hot.flags.enabled)
499 tz->trips.hot.flags.enabled = 0; 506 tz->trips.hot.flags.enabled = 0;
500 507
501 result = acpi_bus_get_device(tz->handle, &device); 508 result = acpi_bus_get_device(tz->handle, &device);
502 if (result) 509 if (result)
503 return_VALUE(result); 510 return_VALUE(result);
504 511
505 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); 512 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
513 tz->trips.hot.flags.enabled);
506 514
507 /* TBD: Call user-mode "sleep(S4)" function */ 515 /* TBD: Call user-mode "sleep(S4)" function */
508 516
509 return_VALUE(0); 517 return_VALUE(0);
510} 518}
511 519
512 520static int acpi_thermal_passive(struct acpi_thermal *tz)
513static int
514acpi_thermal_passive (
515 struct acpi_thermal *tz)
516{ 521{
517 int result = 0; 522 int result = 0;
518 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
519 int trend = 0; 524 int trend = 0;
520 int i = 0; 525 int i = 0;
521 526
522 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
523 528
@@ -534,25 +539,29 @@ acpi_thermal_passive (
534 * accordingly. Note that we assume symmetry. 539 * accordingly. Note that we assume symmetry.
535 */ 540 */
536 if (tz->temperature >= passive->temperature) { 541 if (tz->temperature >= passive->temperature) {
537 trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature)); 542 trend =
538 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 543 (passive->tc1 * (tz->temperature - tz->last_temperature)) +
539 "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", 544 (passive->tc2 * (tz->temperature - passive->temperature));
540 trend, passive->tc1, tz->temperature, 545 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
541 tz->last_temperature, passive->tc2, 546 "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n",
542 tz->temperature, passive->temperature)); 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature));
543 tz->trips.passive.flags.enabled = 1; 550 tz->trips.passive.flags.enabled = 1;
544 /* Heating up? */ 551 /* Heating up? */
545 if (trend > 0) 552 if (trend > 0)
546 for (i=0; i<passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
547 acpi_processor_set_thermal_limit( 554 acpi_processor_set_thermal_limit(passive->
548 passive->devices.handles[i], 555 devices.
549 ACPI_PROCESSOR_LIMIT_INCREMENT); 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT);
550 /* Cooling off? */ 558 /* Cooling off? */
551 else if (trend < 0) 559 else if (trend < 0)
552 for (i=0; i<passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
553 acpi_processor_set_thermal_limit( 561 acpi_processor_set_thermal_limit(passive->
554 passive->devices.handles[i], 562 devices.
555 ACPI_PROCESSOR_LIMIT_DECREMENT); 563 handles[i],
564 ACPI_PROCESSOR_LIMIT_DECREMENT);
556 } 565 }
557 566
558 /* 567 /*
@@ -563,37 +572,35 @@ acpi_thermal_passive (
563 * assume symmetry. 572 * assume symmetry.
564 */ 573 */
565 else if (tz->trips.passive.flags.enabled) { 574 else if (tz->trips.passive.flags.enabled) {
566 for (i=0; i<passive->devices.count; i++) 575 for (i = 0; i < passive->devices.count; i++)
567 result = acpi_processor_set_thermal_limit( 576 result =
568 passive->devices.handles[i], 577 acpi_processor_set_thermal_limit(passive->devices.
569 ACPI_PROCESSOR_LIMIT_DECREMENT); 578 handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT);
570 if (result == 1) { 580 if (result == 1) {
571 tz->trips.passive.flags.enabled = 0; 581 tz->trips.passive.flags.enabled = 0;
572 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 582 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
573 "Disabling passive cooling (zone is cool)\n")); 583 "Disabling passive cooling (zone is cool)\n"));
574 } 584 }
575 } 585 }
576 586
577 return_VALUE(0); 587 return_VALUE(0);
578} 588}
579 589
580 590static int acpi_thermal_active(struct acpi_thermal *tz)
581static int
582acpi_thermal_active (
583 struct acpi_thermal *tz)
584{ 591{
585 int result = 0; 592 int result = 0;
586 struct acpi_thermal_active *active = NULL; 593 struct acpi_thermal_active *active = NULL;
587 int i = 0; 594 int i = 0;
588 int j = 0; 595 int j = 0;
589 unsigned long maxtemp = 0; 596 unsigned long maxtemp = 0;
590 597
591 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 598 ACPI_FUNCTION_TRACE("acpi_thermal_active");
592 599
593 if (!tz) 600 if (!tz)
594 return_VALUE(-EINVAL); 601 return_VALUE(-EINVAL);
595 602
596 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) { 603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
597 604
598 active = &(tz->trips.active[i]); 605 active = &(tz->trips.active[i]);
599 if (!active || !active->flags.valid) 606 if (!active || !active->flags.valid)
@@ -607,16 +614,27 @@ acpi_thermal_active (
607 */ 614 */
608 if (tz->temperature >= active->temperature) { 615 if (tz->temperature >= active->temperature) {
609 if (active->temperature > maxtemp) 616 if (active->temperature > maxtemp)
610 tz->state.active_index = i, maxtemp = active->temperature; 617 tz->state.active_index = i, maxtemp =
618 active->temperature;
611 if (!active->flags.enabled) { 619 if (!active->flags.enabled) {
612 for (j = 0; j < active->devices.count; j++) { 620 for (j = 0; j < active->devices.count; j++) {
613 result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0); 621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
614 if (result) { 625 if (result) {
615 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j])); 626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
616 continue; 631 continue;
617 } 632 }
618 active->flags.enabled = 1; 633 active->flags.enabled = 1;
619 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'on'\n", active->devices.handles[j])); 634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
620 } 638 }
621 } 639 }
622 } 640 }
@@ -628,13 +646,21 @@ acpi_thermal_active (
628 */ 646 */
629 else if (active->flags.enabled) { 647 else if (active->flags.enabled) {
630 for (j = 0; j < active->devices.count; j++) { 648 for (j = 0; j < active->devices.count; j++) {
631 result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); 649 result =
650 acpi_bus_set_power(active->devices.
651 handles[j],
652 ACPI_STATE_D3);
632 if (result) { 653 if (result) {
633 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j])); 654 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n",
656 active->devices.
657 handles[j]));
634 continue; 658 continue;
635 } 659 }
636 active->flags.enabled = 0; 660 active->flags.enabled = 0;
637 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'off'\n", active->devices.handles[j])); 661 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n",
663 active->devices.handles[j]));
638 } 664 }
639 } 665 }
640 } 666 }
@@ -642,28 +668,22 @@ acpi_thermal_active (
642 return_VALUE(0); 668 return_VALUE(0);
643} 669}
644 670
671static void acpi_thermal_check(void *context);
645 672
646static void acpi_thermal_check (void *context); 673static void acpi_thermal_run(unsigned long data)
647
648static void
649acpi_thermal_run (
650 unsigned long data)
651{ 674{
652 struct acpi_thermal *tz = (struct acpi_thermal *)data; 675 struct acpi_thermal *tz = (struct acpi_thermal *)data;
653 if (!tz->zombie) 676 if (!tz->zombie)
654 acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 677 acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
655 acpi_thermal_check, (void *) data); 678 acpi_thermal_check, (void *)data);
656} 679}
657 680
658 681static void acpi_thermal_check(void *data)
659static void
660acpi_thermal_check (
661 void *data)
662{ 682{
663 int result = 0; 683 int result = 0;
664 struct acpi_thermal *tz = (struct acpi_thermal *) data; 684 struct acpi_thermal *tz = (struct acpi_thermal *)data;
665 unsigned long sleep_time = 0; 685 unsigned long sleep_time = 0;
666 int i = 0; 686 int i = 0;
667 struct acpi_thermal_state state; 687 struct acpi_thermal_state state;
668 688
669 ACPI_FUNCTION_TRACE("acpi_thermal_check"); 689 ACPI_FUNCTION_TRACE("acpi_thermal_check");
@@ -678,9 +698,9 @@ acpi_thermal_check (
678 result = acpi_thermal_get_temperature(tz); 698 result = acpi_thermal_get_temperature(tz);
679 if (result) 699 if (result)
680 return_VOID; 700 return_VOID;
681 701
682 memset(&tz->state, 0, sizeof(tz->state)); 702 memset(&tz->state, 0, sizeof(tz->state));
683 703
684 /* 704 /*
685 * Check Trip Points 705 * Check Trip Points
686 * ----------------- 706 * -----------------
@@ -690,14 +710,18 @@ acpi_thermal_check (
690 * individual policy decides when it is exited (e.g. hysteresis). 710 * individual policy decides when it is exited (e.g. hysteresis).
691 */ 711 */
692 if (tz->trips.critical.flags.valid) 712 if (tz->trips.critical.flags.valid)
693 state.critical |= (tz->temperature >= tz->trips.critical.temperature); 713 state.critical |=
714 (tz->temperature >= tz->trips.critical.temperature);
694 if (tz->trips.hot.flags.valid) 715 if (tz->trips.hot.flags.valid)
695 state.hot |= (tz->temperature >= tz->trips.hot.temperature); 716 state.hot |= (tz->temperature >= tz->trips.hot.temperature);
696 if (tz->trips.passive.flags.valid) 717 if (tz->trips.passive.flags.valid)
697 state.passive |= (tz->temperature >= tz->trips.passive.temperature); 718 state.passive |=
698 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) 719 (tz->temperature >= tz->trips.passive.temperature);
720 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
699 if (tz->trips.active[i].flags.valid) 721 if (tz->trips.active[i].flags.valid)
700 state.active |= (tz->temperature >= tz->trips.active[i].temperature); 722 state.active |=
723 (tz->temperature >=
724 tz->trips.active[i].temperature);
701 725
702 /* 726 /*
703 * Invoke Policy 727 * Invoke Policy
@@ -726,7 +750,7 @@ acpi_thermal_check (
726 tz->state.hot = 1; 750 tz->state.hot = 1;
727 if (tz->trips.passive.flags.enabled) 751 if (tz->trips.passive.flags.enabled)
728 tz->state.passive = 1; 752 tz->state.passive = 1;
729 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) 753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
730 if (tz->trips.active[i].flags.enabled) 754 if (tz->trips.active[i].flags.enabled)
731 tz->state.active = 1; 755 tz->state.active = 1;
732 756
@@ -744,8 +768,8 @@ acpi_thermal_check (
744 else if (tz->polling_frequency > 0) 768 else if (tz->polling_frequency > 0)
745 sleep_time = tz->polling_frequency * 100; 769 sleep_time = tz->polling_frequency * 100;
746 770
747 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", 771 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n",
748 tz->name, tz->temperature, sleep_time)); 772 tz->name, tz->temperature, sleep_time));
749 773
750 /* 774 /*
751 * Schedule Next Poll 775 * Schedule Next Poll
@@ -754,12 +778,11 @@ acpi_thermal_check (
754 if (!sleep_time) { 778 if (!sleep_time) {
755 if (timer_pending(&(tz->timer))) 779 if (timer_pending(&(tz->timer)))
756 del_timer(&(tz->timer)); 780 del_timer(&(tz->timer));
757 } 781 } else {
758 else {
759 if (timer_pending(&(tz->timer))) 782 if (timer_pending(&(tz->timer)))
760 mod_timer(&(tz->timer), (HZ * sleep_time) / 1000); 783 mod_timer(&(tz->timer), (HZ * sleep_time) / 1000);
761 else { 784 else {
762 tz->timer.data = (unsigned long) tz; 785 tz->timer.data = (unsigned long)tz;
763 tz->timer.function = acpi_thermal_run; 786 tz->timer.function = acpi_thermal_run;
764 tz->timer.expires = jiffies + (HZ * sleep_time) / 1000; 787 tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
765 add_timer(&(tz->timer)); 788 add_timer(&(tz->timer));
@@ -769,16 +792,15 @@ acpi_thermal_check (
769 return_VOID; 792 return_VOID;
770} 793}
771 794
772
773/* -------------------------------------------------------------------------- 795/* --------------------------------------------------------------------------
774 FS Interface (/proc) 796 FS Interface (/proc)
775 -------------------------------------------------------------------------- */ 797 -------------------------------------------------------------------------- */
776 798
777static struct proc_dir_entry *acpi_thermal_dir; 799static struct proc_dir_entry *acpi_thermal_dir;
778 800
779static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) 801static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
780{ 802{
781 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 803 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
782 804
783 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show"); 805 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
784 806
@@ -787,7 +809,8 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
787 809
788 seq_puts(seq, "state: "); 810 seq_puts(seq, "state: ");
789 811
790 if (!tz->state.critical && !tz->state.hot && !tz->state.passive && !tz->state.active) 812 if (!tz->state.critical && !tz->state.hot && !tz->state.passive
813 && !tz->state.active)
791 seq_puts(seq, "ok\n"); 814 seq_puts(seq, "ok\n");
792 else { 815 else {
793 if (tz->state.critical) 816 if (tz->state.critical)
@@ -801,7 +824,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
801 seq_puts(seq, "\n"); 824 seq_puts(seq, "\n");
802 } 825 }
803 826
804end: 827 end:
805 return_VALUE(0); 828 return_VALUE(0);
806} 829}
807 830
@@ -810,11 +833,10 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
810 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data); 833 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
811} 834}
812 835
813
814static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) 836static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
815{ 837{
816 int result = 0; 838 int result = 0;
817 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 839 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
818 840
819 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show"); 841 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
820 842
@@ -825,10 +847,10 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
825 if (result) 847 if (result)
826 goto end; 848 goto end;
827 849
828 seq_printf(seq, "temperature: %ld C\n", 850 seq_printf(seq, "temperature: %ld C\n",
829 KELVIN_TO_CELSIUS(tz->temperature)); 851 KELVIN_TO_CELSIUS(tz->temperature));
830 852
831end: 853 end:
832 return_VALUE(0); 854 return_VALUE(0);
833} 855}
834 856
@@ -837,12 +859,11 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
837 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data); 859 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
838} 860}
839 861
840
841static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) 862static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
842{ 863{
843 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 864 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
844 int i = 0; 865 int i = 0;
845 int j = 0; 866 int j = 0;
846 867
847 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show"); 868 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
848 869
@@ -851,21 +872,22 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
851 872
852 if (tz->trips.critical.flags.valid) 873 if (tz->trips.critical.flags.valid)
853 seq_printf(seq, "critical (S5): %ld C\n", 874 seq_printf(seq, "critical (S5): %ld C\n",
854 KELVIN_TO_CELSIUS(tz->trips.critical.temperature)); 875 KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
855 876
856 if (tz->trips.hot.flags.valid) 877 if (tz->trips.hot.flags.valid)
857 seq_printf(seq, "hot (S4): %ld C\n", 878 seq_printf(seq, "hot (S4): %ld C\n",
858 KELVIN_TO_CELSIUS(tz->trips.hot.temperature)); 879 KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
859 880
860 if (tz->trips.passive.flags.valid) { 881 if (tz->trips.passive.flags.valid) {
861 seq_printf(seq, "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=", 882 seq_printf(seq,
862 KELVIN_TO_CELSIUS(tz->trips.passive.temperature), 883 "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
863 tz->trips.passive.tc1, 884 KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
864 tz->trips.passive.tc2, 885 tz->trips.passive.tc1, tz->trips.passive.tc2,
865 tz->trips.passive.tsp); 886 tz->trips.passive.tsp);
866 for (j=0; j<tz->trips.passive.devices.count; j++) { 887 for (j = 0; j < tz->trips.passive.devices.count; j++) {
867 888
868 seq_printf(seq, "0x%p ", tz->trips.passive.devices.handles[j]); 889 seq_printf(seq, "0x%p ",
890 tz->trips.passive.devices.handles[j]);
869 } 891 }
870 seq_puts(seq, "\n"); 892 seq_puts(seq, "\n");
871 } 893 }
@@ -874,14 +896,15 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
874 if (!(tz->trips.active[i].flags.valid)) 896 if (!(tz->trips.active[i].flags.valid))
875 break; 897 break;
876 seq_printf(seq, "active[%d]: %ld C: devices=", 898 seq_printf(seq, "active[%d]: %ld C: devices=",
877 i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature)); 899 i,
878 for (j = 0; j < tz->trips.active[i].devices.count; j++) 900 KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
901 for (j = 0; j < tz->trips.active[i].devices.count; j++)
879 seq_printf(seq, "0x%p ", 902 seq_printf(seq, "0x%p ",
880 tz->trips.active[i].devices.handles[j]); 903 tz->trips.active[i].devices.handles[j]);
881 seq_puts(seq, "\n"); 904 seq_puts(seq, "\n");
882 } 905 }
883 906
884end: 907 end:
885 return_VALUE(0); 908 return_VALUE(0);
886} 909}
887 910
@@ -891,30 +914,28 @@ static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
891} 914}
892 915
893static ssize_t 916static ssize_t
894acpi_thermal_write_trip_points ( 917acpi_thermal_write_trip_points(struct file *file,
895 struct file *file, 918 const char __user * buffer,
896 const char __user *buffer, 919 size_t count, loff_t * ppos)
897 size_t count,
898 loff_t *ppos)
899{ 920{
900 struct seq_file *m = (struct seq_file *)file->private_data; 921 struct seq_file *m = (struct seq_file *)file->private_data;
901 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 922 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
902 923
903 char *limit_string; 924 char *limit_string;
904 int num, critical, hot, passive; 925 int num, critical, hot, passive;
905 int *active; 926 int *active;
906 int i = 0; 927 int i = 0;
907 928
908 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points"); 929 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
909 930
910 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); 931 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
911 if(!limit_string) 932 if (!limit_string)
912 return_VALUE(-ENOMEM); 933 return_VALUE(-ENOMEM);
913 934
914 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); 935 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
915 936
916 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE *sizeof(int), GFP_KERNEL); 937 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
917 if(!active) 938 if (!active)
918 return_VALUE(-ENOMEM); 939 return_VALUE(-ENOMEM);
919 940
920 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { 941 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
@@ -922,20 +943,21 @@ acpi_thermal_write_trip_points (
922 count = -EINVAL; 943 count = -EINVAL;
923 goto end; 944 goto end;
924 } 945 }
925 946
926 if (copy_from_user(limit_string, buffer, count)) { 947 if (copy_from_user(limit_string, buffer, count)) {
927 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 948 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
928 count = -EFAULT; 949 count = -EFAULT;
929 goto end; 950 goto end;
930 } 951 }
931 952
932 limit_string[count] = '\0'; 953 limit_string[count] = '\0';
933 954
934 num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", 955 num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
935 &critical, &hot, &passive, 956 &critical, &hot, &passive,
936 &active[0], &active[1], &active[2], &active[3], &active[4], 957 &active[0], &active[1], &active[2], &active[3], &active[4],
937 &active[5], &active[6], &active[7], &active[8], &active[9]); 958 &active[5], &active[6], &active[7], &active[8],
938 if(!(num >=5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { 959 &active[9]);
960 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
939 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); 961 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
940 count = -EINVAL; 962 count = -EINVAL;
941 goto end; 963 goto end;
@@ -949,17 +971,16 @@ acpi_thermal_write_trip_points (
949 break; 971 break;
950 tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); 972 tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]);
951 } 973 }
952 974
953end: 975 end:
954 kfree(active); 976 kfree(active);
955 kfree(limit_string); 977 kfree(limit_string);
956 return_VALUE(count); 978 return_VALUE(count);
957} 979}
958 980
959
960static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) 981static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
961{ 982{
962 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 983 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
963 984
964 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show"); 985 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
965 986
@@ -970,33 +991,31 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
970 seq_puts(seq, "<setting not supported>\n"); 991 seq_puts(seq, "<setting not supported>\n");
971 } 992 }
972 993
973 if ( tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL ) 994 if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL)
974 seq_printf(seq, "cooling mode: critical\n"); 995 seq_printf(seq, "cooling mode: critical\n");
975 else 996 else
976 seq_printf(seq, "cooling mode: %s\n", 997 seq_printf(seq, "cooling mode: %s\n",
977 tz->cooling_mode?"passive":"active"); 998 tz->cooling_mode ? "passive" : "active");
978 999
979end: 1000 end:
980 return_VALUE(0); 1001 return_VALUE(0);
981} 1002}
982 1003
983static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) 1004static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
984{ 1005{
985 return single_open(file, acpi_thermal_cooling_seq_show, 1006 return single_open(file, acpi_thermal_cooling_seq_show,
986 PDE(inode)->data); 1007 PDE(inode)->data);
987} 1008}
988 1009
989static ssize_t 1010static ssize_t
990acpi_thermal_write_cooling_mode ( 1011acpi_thermal_write_cooling_mode(struct file *file,
991 struct file *file, 1012 const char __user * buffer,
992 const char __user *buffer, 1013 size_t count, loff_t * ppos)
993 size_t count,
994 loff_t *ppos)
995{ 1014{
996 struct seq_file *m = (struct seq_file *)file->private_data; 1015 struct seq_file *m = (struct seq_file *)file->private_data;
997 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 1016 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
998 int result = 0; 1017 int result = 0;
999 char mode_string[12] = {'\0'}; 1018 char mode_string[12] = { '\0' };
1000 1019
1001 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode"); 1020 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
1002 1021
@@ -1008,11 +1027,12 @@ acpi_thermal_write_cooling_mode (
1008 1027
1009 if (copy_from_user(mode_string, buffer, count)) 1028 if (copy_from_user(mode_string, buffer, count))
1010 return_VALUE(-EFAULT); 1029 return_VALUE(-EFAULT);
1011 1030
1012 mode_string[count] = '\0'; 1031 mode_string[count] = '\0';
1013 1032
1014 result = acpi_thermal_set_cooling_mode(tz, 1033 result = acpi_thermal_set_cooling_mode(tz,
1015 simple_strtoul(mode_string, NULL, 0)); 1034 simple_strtoul(mode_string, NULL,
1035 0));
1016 if (result) 1036 if (result)
1017 return_VALUE(result); 1037 return_VALUE(result);
1018 1038
@@ -1021,10 +1041,9 @@ acpi_thermal_write_cooling_mode (
1021 return_VALUE(count); 1041 return_VALUE(count);
1022} 1042}
1023 1043
1024
1025static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) 1044static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1026{ 1045{
1027 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 1046 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
1028 1047
1029 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show"); 1048 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
1030 1049
@@ -1037,43 +1056,41 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1037 } 1056 }
1038 1057
1039 seq_printf(seq, "polling frequency: %lu seconds\n", 1058 seq_printf(seq, "polling frequency: %lu seconds\n",
1040 (tz->polling_frequency / 10)); 1059 (tz->polling_frequency / 10));
1041 1060
1042end: 1061 end:
1043 return_VALUE(0); 1062 return_VALUE(0);
1044} 1063}
1045 1064
1046static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) 1065static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
1047{ 1066{
1048 return single_open(file, acpi_thermal_polling_seq_show, 1067 return single_open(file, acpi_thermal_polling_seq_show,
1049 PDE(inode)->data); 1068 PDE(inode)->data);
1050} 1069}
1051 1070
1052static ssize_t 1071static ssize_t
1053acpi_thermal_write_polling ( 1072acpi_thermal_write_polling(struct file *file,
1054 struct file *file, 1073 const char __user * buffer,
1055 const char __user *buffer, 1074 size_t count, loff_t * ppos)
1056 size_t count,
1057 loff_t *ppos)
1058{ 1075{
1059 struct seq_file *m = (struct seq_file *)file->private_data; 1076 struct seq_file *m = (struct seq_file *)file->private_data;
1060 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 1077 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
1061 int result = 0; 1078 int result = 0;
1062 char polling_string[12] = {'\0'}; 1079 char polling_string[12] = { '\0' };
1063 int seconds = 0; 1080 int seconds = 0;
1064 1081
1065 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); 1082 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
1066 1083
1067 if (!tz || (count > sizeof(polling_string) - 1)) 1084 if (!tz || (count > sizeof(polling_string) - 1))
1068 return_VALUE(-EINVAL); 1085 return_VALUE(-EINVAL);
1069 1086
1070 if (copy_from_user(polling_string, buffer, count)) 1087 if (copy_from_user(polling_string, buffer, count))
1071 return_VALUE(-EFAULT); 1088 return_VALUE(-EFAULT);
1072 1089
1073 polling_string[count] = '\0'; 1090 polling_string[count] = '\0';
1074 1091
1075 seconds = simple_strtoul(polling_string, NULL, 0); 1092 seconds = simple_strtoul(polling_string, NULL, 0);
1076 1093
1077 result = acpi_thermal_set_polling(tz, seconds); 1094 result = acpi_thermal_set_polling(tz, seconds);
1078 if (result) 1095 if (result)
1079 return_VALUE(result); 1096 return_VALUE(result);
@@ -1083,18 +1100,15 @@ acpi_thermal_write_polling (
1083 return_VALUE(count); 1100 return_VALUE(count);
1084} 1101}
1085 1102
1086 1103static int acpi_thermal_add_fs(struct acpi_device *device)
1087static int
1088acpi_thermal_add_fs (
1089 struct acpi_device *device)
1090{ 1104{
1091 struct proc_dir_entry *entry = NULL; 1105 struct proc_dir_entry *entry = NULL;
1092 1106
1093 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); 1107 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
1094 1108
1095 if (!acpi_device_dir(device)) { 1109 if (!acpi_device_dir(device)) {
1096 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1110 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1097 acpi_thermal_dir); 1111 acpi_thermal_dir);
1098 if (!acpi_device_dir(device)) 1112 if (!acpi_device_dir(device))
1099 return_VALUE(-ENODEV); 1113 return_VALUE(-ENODEV);
1100 acpi_device_dir(device)->owner = THIS_MODULE; 1114 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -1102,11 +1116,11 @@ acpi_thermal_add_fs (
1102 1116
1103 /* 'state' [R] */ 1117 /* 'state' [R] */
1104 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, 1118 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
1105 S_IRUGO, acpi_device_dir(device)); 1119 S_IRUGO, acpi_device_dir(device));
1106 if (!entry) 1120 if (!entry)
1107 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1108 "Unable to create '%s' fs entry\n", 1122 "Unable to create '%s' fs entry\n",
1109 ACPI_THERMAL_FILE_STATE)); 1123 ACPI_THERMAL_FILE_STATE));
1110 else { 1124 else {
1111 entry->proc_fops = &acpi_thermal_state_fops; 1125 entry->proc_fops = &acpi_thermal_state_fops;
1112 entry->data = acpi_driver_data(device); 1126 entry->data = acpi_driver_data(device);
@@ -1115,11 +1129,11 @@ acpi_thermal_add_fs (
1115 1129
1116 /* 'temperature' [R] */ 1130 /* 'temperature' [R] */
1117 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, 1131 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1118 S_IRUGO, acpi_device_dir(device)); 1132 S_IRUGO, acpi_device_dir(device));
1119 if (!entry) 1133 if (!entry)
1120 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1134 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1121 "Unable to create '%s' fs entry\n", 1135 "Unable to create '%s' fs entry\n",
1122 ACPI_THERMAL_FILE_TEMPERATURE)); 1136 ACPI_THERMAL_FILE_TEMPERATURE));
1123 else { 1137 else {
1124 entry->proc_fops = &acpi_thermal_temp_fops; 1138 entry->proc_fops = &acpi_thermal_temp_fops;
1125 entry->data = acpi_driver_data(device); 1139 entry->data = acpi_driver_data(device);
@@ -1128,11 +1142,12 @@ acpi_thermal_add_fs (
1128 1142
1129 /* 'trip_points' [R/W] */ 1143 /* 'trip_points' [R/W] */
1130 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, 1144 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
1131 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1145 S_IFREG | S_IRUGO | S_IWUSR,
1146 acpi_device_dir(device));
1132 if (!entry) 1147 if (!entry)
1133 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1148 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1134 "Unable to create '%s' fs entry\n", 1149 "Unable to create '%s' fs entry\n",
1135 ACPI_THERMAL_FILE_TRIP_POINTS)); 1150 ACPI_THERMAL_FILE_TRIP_POINTS));
1136 else { 1151 else {
1137 entry->proc_fops = &acpi_thermal_trip_fops; 1152 entry->proc_fops = &acpi_thermal_trip_fops;
1138 entry->data = acpi_driver_data(device); 1153 entry->data = acpi_driver_data(device);
@@ -1141,11 +1156,12 @@ acpi_thermal_add_fs (
1141 1156
1142 /* 'cooling_mode' [R/W] */ 1157 /* 'cooling_mode' [R/W] */
1143 entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, 1158 entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
1144 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1159 S_IFREG | S_IRUGO | S_IWUSR,
1160 acpi_device_dir(device));
1145 if (!entry) 1161 if (!entry)
1146 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1147 "Unable to create '%s' fs entry\n", 1163 "Unable to create '%s' fs entry\n",
1148 ACPI_THERMAL_FILE_COOLING_MODE)); 1164 ACPI_THERMAL_FILE_COOLING_MODE));
1149 else { 1165 else {
1150 entry->proc_fops = &acpi_thermal_cooling_fops; 1166 entry->proc_fops = &acpi_thermal_cooling_fops;
1151 entry->data = acpi_driver_data(device); 1167 entry->data = acpi_driver_data(device);
@@ -1154,11 +1170,12 @@ acpi_thermal_add_fs (
1154 1170
1155 /* 'polling_frequency' [R/W] */ 1171 /* 'polling_frequency' [R/W] */
1156 entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, 1172 entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
1157 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1173 S_IFREG | S_IRUGO | S_IWUSR,
1174 acpi_device_dir(device));
1158 if (!entry) 1175 if (!entry)
1159 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1176 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1160 "Unable to create '%s' fs entry\n", 1177 "Unable to create '%s' fs entry\n",
1161 ACPI_THERMAL_FILE_POLLING_FREQ)); 1178 ACPI_THERMAL_FILE_POLLING_FREQ));
1162 else { 1179 else {
1163 entry->proc_fops = &acpi_thermal_polling_fops; 1180 entry->proc_fops = &acpi_thermal_polling_fops;
1164 entry->data = acpi_driver_data(device); 1181 entry->data = acpi_driver_data(device);
@@ -1168,10 +1185,7 @@ acpi_thermal_add_fs (
1168 return_VALUE(0); 1185 return_VALUE(0);
1169} 1186}
1170 1187
1171 1188static int acpi_thermal_remove_fs(struct acpi_device *device)
1172static int
1173acpi_thermal_remove_fs (
1174 struct acpi_device *device)
1175{ 1189{
1176 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); 1190 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
1177 1191
@@ -1193,19 +1207,14 @@ acpi_thermal_remove_fs (
1193 return_VALUE(0); 1207 return_VALUE(0);
1194} 1208}
1195 1209
1196
1197/* -------------------------------------------------------------------------- 1210/* --------------------------------------------------------------------------
1198 Driver Interface 1211 Driver Interface
1199 -------------------------------------------------------------------------- */ 1212 -------------------------------------------------------------------------- */
1200 1213
1201static void 1214static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1202acpi_thermal_notify (
1203 acpi_handle handle,
1204 u32 event,
1205 void *data)
1206{ 1215{
1207 struct acpi_thermal *tz = (struct acpi_thermal *) data; 1216 struct acpi_thermal *tz = (struct acpi_thermal *)data;
1208 struct acpi_device *device = NULL; 1217 struct acpi_device *device = NULL;
1209 1218
1210 ACPI_FUNCTION_TRACE("acpi_thermal_notify"); 1219 ACPI_FUNCTION_TRACE("acpi_thermal_notify");
1211 1220
@@ -1231,19 +1240,16 @@ acpi_thermal_notify (
1231 break; 1240 break;
1232 default: 1241 default:
1233 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1242 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1234 "Unsupported event [0x%x]\n", event)); 1243 "Unsupported event [0x%x]\n", event));
1235 break; 1244 break;
1236 } 1245 }
1237 1246
1238 return_VOID; 1247 return_VOID;
1239} 1248}
1240 1249
1241 1250static int acpi_thermal_get_info(struct acpi_thermal *tz)
1242static int
1243acpi_thermal_get_info (
1244 struct acpi_thermal *tz)
1245{ 1251{
1246 int result = 0; 1252 int result = 0;
1247 1253
1248 ACPI_FUNCTION_TRACE("acpi_thermal_get_info"); 1254 ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
1249 1255
@@ -1262,20 +1268,24 @@ acpi_thermal_get_info (
1262 1268
1263 /* Set the cooling mode [_SCP] to active cooling (default) */ 1269 /* Set the cooling mode [_SCP] to active cooling (default) */
1264 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); 1270 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
1265 if (!result) 1271 if (!result)
1266 tz->flags.cooling_mode = 1; 1272 tz->flags.cooling_mode = 1;
1267 else { 1273 else {
1268 /* Oh,we have not _SCP method. 1274 /* Oh,we have not _SCP method.
1269 Generally show cooling_mode by _ACx, _PSV,spec 12.2*/ 1275 Generally show cooling_mode by _ACx, _PSV,spec 12.2 */
1270 tz->flags.cooling_mode = 0; 1276 tz->flags.cooling_mode = 0;
1271 if ( tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { 1277 if (tz->trips.active[0].flags.valid
1272 if ( tz->trips.passive.temperature > tz->trips.active[0].temperature ) 1278 && tz->trips.passive.flags.valid) {
1279 if (tz->trips.passive.temperature >
1280 tz->trips.active[0].temperature)
1273 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; 1281 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1274 else 1282 else
1275 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; 1283 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1276 } else if ( !tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { 1284 } else if (!tz->trips.active[0].flags.valid
1285 && tz->trips.passive.flags.valid) {
1277 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; 1286 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1278 } else if ( tz->trips.active[0].flags.valid && !tz->trips.passive.flags.valid ) { 1287 } else if (tz->trips.active[0].flags.valid
1288 && !tz->trips.passive.flags.valid) {
1279 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; 1289 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1280 } else { 1290 } else {
1281 /* _ACx and _PSV are optional, but _CRT is required */ 1291 /* _ACx and _PSV are optional, but _CRT is required */
@@ -1297,14 +1307,11 @@ acpi_thermal_get_info (
1297 return_VALUE(0); 1307 return_VALUE(0);
1298} 1308}
1299 1309
1300 1310static int acpi_thermal_add(struct acpi_device *device)
1301static int
1302acpi_thermal_add (
1303 struct acpi_device *device)
1304{ 1311{
1305 int result = 0; 1312 int result = 0;
1306 acpi_status status = AE_OK; 1313 acpi_status status = AE_OK;
1307 struct acpi_thermal *tz = NULL; 1314 struct acpi_thermal *tz = NULL;
1308 1315
1309 ACPI_FUNCTION_TRACE("acpi_thermal_add"); 1316 ACPI_FUNCTION_TRACE("acpi_thermal_add");
1310 1317
@@ -1335,19 +1342,20 @@ acpi_thermal_add (
1335 acpi_thermal_check(tz); 1342 acpi_thermal_check(tz);
1336 1343
1337 status = acpi_install_notify_handler(tz->handle, 1344 status = acpi_install_notify_handler(tz->handle,
1338 ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); 1345 ACPI_DEVICE_NOTIFY,
1346 acpi_thermal_notify, tz);
1339 if (ACPI_FAILURE(status)) { 1347 if (ACPI_FAILURE(status)) {
1340 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1341 "Error installing notify handler\n")); 1349 "Error installing notify handler\n"));
1342 result = -ENODEV; 1350 result = -ENODEV;
1343 goto end; 1351 goto end;
1344 } 1352 }
1345 1353
1346 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", 1354 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
1347 acpi_device_name(device), acpi_device_bid(device), 1355 acpi_device_name(device), acpi_device_bid(device),
1348 KELVIN_TO_CELSIUS(tz->temperature)); 1356 KELVIN_TO_CELSIUS(tz->temperature));
1349 1357
1350end: 1358 end:
1351 if (result) { 1359 if (result) {
1352 acpi_thermal_remove_fs(device); 1360 acpi_thermal_remove_fs(device);
1353 kfree(tz); 1361 kfree(tz);
@@ -1356,21 +1364,17 @@ end:
1356 return_VALUE(result); 1364 return_VALUE(result);
1357} 1365}
1358 1366
1359 1367static int acpi_thermal_remove(struct acpi_device *device, int type)
1360static int
1361acpi_thermal_remove (
1362 struct acpi_device *device,
1363 int type)
1364{ 1368{
1365 acpi_status status = AE_OK; 1369 acpi_status status = AE_OK;
1366 struct acpi_thermal *tz = NULL; 1370 struct acpi_thermal *tz = NULL;
1367 1371
1368 ACPI_FUNCTION_TRACE("acpi_thermal_remove"); 1372 ACPI_FUNCTION_TRACE("acpi_thermal_remove");
1369 1373
1370 if (!device || !acpi_driver_data(device)) 1374 if (!device || !acpi_driver_data(device))
1371 return_VALUE(-EINVAL); 1375 return_VALUE(-EINVAL);
1372 1376
1373 tz = (struct acpi_thermal *) acpi_driver_data(device); 1377 tz = (struct acpi_thermal *)acpi_driver_data(device);
1374 1378
1375 /* avoid timer adding new defer task */ 1379 /* avoid timer adding new defer task */
1376 tz->zombie = 1; 1380 tz->zombie = 1;
@@ -1382,19 +1386,19 @@ acpi_thermal_remove (
1382 del_timer_sync(&(tz->timer)); 1386 del_timer_sync(&(tz->timer));
1383 1387
1384 status = acpi_remove_notify_handler(tz->handle, 1388 status = acpi_remove_notify_handler(tz->handle,
1385 ACPI_DEVICE_NOTIFY, acpi_thermal_notify); 1389 ACPI_DEVICE_NOTIFY,
1390 acpi_thermal_notify);
1386 if (ACPI_FAILURE(status)) 1391 if (ACPI_FAILURE(status))
1387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1392 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1388 "Error removing notify handler\n")); 1393 "Error removing notify handler\n"));
1389 1394
1390 /* Terminate policy */ 1395 /* Terminate policy */
1391 if (tz->trips.passive.flags.valid 1396 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
1392 && tz->trips.passive.flags.enabled) {
1393 tz->trips.passive.flags.enabled = 0; 1397 tz->trips.passive.flags.enabled = 0;
1394 acpi_thermal_passive(tz); 1398 acpi_thermal_passive(tz);
1395 } 1399 }
1396 if (tz->trips.active[0].flags.valid 1400 if (tz->trips.active[0].flags.valid
1397 && tz->trips.active[0].flags.enabled) { 1401 && tz->trips.active[0].flags.enabled) {
1398 tz->trips.active[0].flags.enabled = 0; 1402 tz->trips.active[0].flags.enabled = 0;
1399 acpi_thermal_active(tz); 1403 acpi_thermal_active(tz);
1400 } 1404 }
@@ -1405,11 +1409,9 @@ acpi_thermal_remove (
1405 return_VALUE(0); 1409 return_VALUE(0);
1406} 1410}
1407 1411
1408 1412static int __init acpi_thermal_init(void)
1409static int __init
1410acpi_thermal_init (void)
1411{ 1413{
1412 int result = 0; 1414 int result = 0;
1413 1415
1414 ACPI_FUNCTION_TRACE("acpi_thermal_init"); 1416 ACPI_FUNCTION_TRACE("acpi_thermal_init");
1415 1417
@@ -1427,9 +1429,7 @@ acpi_thermal_init (void)
1427 return_VALUE(0); 1429 return_VALUE(0);
1428} 1430}
1429 1431
1430 1432static void __exit acpi_thermal_exit(void)
1431static void __exit
1432acpi_thermal_exit (void)
1433{ 1433{
1434 ACPI_FUNCTION_TRACE("acpi_thermal_exit"); 1434 ACPI_FUNCTION_TRACE("acpi_thermal_exit");
1435 1435
@@ -1440,6 +1440,5 @@ acpi_thermal_exit (void)
1440 return_VOID; 1440 return_VOID;
1441} 1441}
1442 1442
1443
1444module_init(acpi_thermal_init); 1443module_init(acpi_thermal_init);
1445module_exit(acpi_thermal_exit); 1444module_exit(acpi_thermal_exit);
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index 73b1d8aeae9d..7fe0b7ae9733 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -100,8 +100,7 @@ MODULE_LICENSE("GPL");
100/* utility 100/* utility
101 */ 101 */
102 102
103static __inline__ void 103static __inline__ void _set_bit(u32 * word, u32 mask, int value)
104_set_bit(u32* word, u32 mask, int value)
105{ 104{
106 *word = (*word & ~mask) | (mask * value); 105 *word = (*word & ~mask) | (mask * value);
107} 106}
@@ -109,35 +108,32 @@ _set_bit(u32* word, u32 mask, int value)
109/* acpi interface wrappers 108/* acpi interface wrappers
110 */ 109 */
111 110
112static int 111static int is_valid_acpi_path(const char *methodName)
113is_valid_acpi_path(const char* methodName)
114{ 112{
115 acpi_handle handle; 113 acpi_handle handle;
116 acpi_status status; 114 acpi_status status;
117 115
118 status = acpi_get_handle(NULL, (char*)methodName, &handle); 116 status = acpi_get_handle(NULL, (char *)methodName, &handle);
119 return !ACPI_FAILURE(status); 117 return !ACPI_FAILURE(status);
120} 118}
121 119
122static int 120static int write_acpi_int(const char *methodName, int val)
123write_acpi_int(const char* methodName, int val)
124{ 121{
125 struct acpi_object_list params; 122 struct acpi_object_list params;
126 union acpi_object in_objs[1]; 123 union acpi_object in_objs[1];
127 acpi_status status; 124 acpi_status status;
128 125
129 params.count = sizeof(in_objs)/sizeof(in_objs[0]); 126 params.count = sizeof(in_objs) / sizeof(in_objs[0]);
130 params.pointer = in_objs; 127 params.pointer = in_objs;
131 in_objs[0].type = ACPI_TYPE_INTEGER; 128 in_objs[0].type = ACPI_TYPE_INTEGER;
132 in_objs[0].integer.value = val; 129 in_objs[0].integer.value = val;
133 130
134 status = acpi_evaluate_object(NULL, (char*)methodName, &params, NULL); 131 status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
135 return (status == AE_OK); 132 return (status == AE_OK);
136} 133}
137 134
138#if 0 135#if 0
139static int 136static int read_acpi_int(const char *methodName, int *pVal)
140read_acpi_int(const char* methodName, int* pVal)
141{ 137{
142 struct acpi_buffer results; 138 struct acpi_buffer results;
143 union acpi_object out_objs[1]; 139 union acpi_object out_objs[1];
@@ -146,25 +142,24 @@ read_acpi_int(const char* methodName, int* pVal)
146 results.length = sizeof(out_objs); 142 results.length = sizeof(out_objs);
147 results.pointer = out_objs; 143 results.pointer = out_objs;
148 144
149 status = acpi_evaluate_object(0, (char*)methodName, 0, &results); 145 status = acpi_evaluate_object(0, (char *)methodName, 0, &results);
150 *pVal = out_objs[0].integer.value; 146 *pVal = out_objs[0].integer.value;
151 147
152 return (status == AE_OK) && (out_objs[0].type == ACPI_TYPE_INTEGER); 148 return (status == AE_OK) && (out_objs[0].type == ACPI_TYPE_INTEGER);
153} 149}
154#endif 150#endif
155 151
156static const char* method_hci /*= 0*/; 152static const char *method_hci /*= 0*/ ;
157 153
158/* Perform a raw HCI call. Here we don't care about input or output buffer 154/* Perform a raw HCI call. Here we don't care about input or output buffer
159 * format. 155 * format.
160 */ 156 */
161static acpi_status 157static acpi_status hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
162hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
163{ 158{
164 struct acpi_object_list params; 159 struct acpi_object_list params;
165 union acpi_object in_objs[HCI_WORDS]; 160 union acpi_object in_objs[HCI_WORDS];
166 struct acpi_buffer results; 161 struct acpi_buffer results;
167 union acpi_object out_objs[HCI_WORDS+1]; 162 union acpi_object out_objs[HCI_WORDS + 1];
168 acpi_status status; 163 acpi_status status;
169 int i; 164 int i;
170 165
@@ -178,8 +173,8 @@ hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
178 results.length = sizeof(out_objs); 173 results.length = sizeof(out_objs);
179 results.pointer = out_objs; 174 results.pointer = out_objs;
180 175
181 status = acpi_evaluate_object(NULL, (char*)method_hci, &params, 176 status = acpi_evaluate_object(NULL, (char *)method_hci, &params,
182 &results); 177 &results);
183 if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) { 178 if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) {
184 for (i = 0; i < out_objs->package.count; ++i) { 179 for (i = 0; i < out_objs->package.count; ++i) {
185 out[i] = out_objs->package.elements[i].integer.value; 180 out[i] = out_objs->package.elements[i].integer.value;
@@ -195,8 +190,7 @@ hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
195 * may be useful (such as "not supported"). 190 * may be useful (such as "not supported").
196 */ 191 */
197 192
198static acpi_status 193static acpi_status hci_write1(u32 reg, u32 in1, u32 * result)
199hci_write1(u32 reg, u32 in1, u32* result)
200{ 194{
201 u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 }; 195 u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 };
202 u32 out[HCI_WORDS]; 196 u32 out[HCI_WORDS];
@@ -205,8 +199,7 @@ hci_write1(u32 reg, u32 in1, u32* result)
205 return status; 199 return status;
206} 200}
207 201
208static acpi_status 202static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result)
209hci_read1(u32 reg, u32* out1, u32* result)
210{ 203{
211 u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 }; 204 u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 };
212 u32 out[HCI_WORDS]; 205 u32 out[HCI_WORDS];
@@ -216,26 +209,25 @@ hci_read1(u32 reg, u32* out1, u32* result)
216 return status; 209 return status;
217} 210}
218 211
219static struct proc_dir_entry* toshiba_proc_dir /*= 0*/; 212static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ;
220static int force_fan; 213static int force_fan;
221static int last_key_event; 214static int last_key_event;
222static int key_event_valid; 215static int key_event_valid;
223 216
224typedef struct _ProcItem 217typedef struct _ProcItem {
225{ 218 const char *name;
226 const char* name; 219 char *(*read_func) (char *);
227 char* (*read_func)(char*); 220 unsigned long (*write_func) (const char *, unsigned long);
228 unsigned long (*write_func)(const char*, unsigned long);
229} ProcItem; 221} ProcItem;
230 222
231/* proc file handlers 223/* proc file handlers
232 */ 224 */
233 225
234static int 226static int
235dispatch_read(char* page, char** start, off_t off, int count, int* eof, 227dispatch_read(char *page, char **start, off_t off, int count, int *eof,
236 ProcItem* item) 228 ProcItem * item)
237{ 229{
238 char* p = page; 230 char *p = page;
239 int len; 231 int len;
240 232
241 if (off == 0) 233 if (off == 0)
@@ -243,33 +235,35 @@ dispatch_read(char* page, char** start, off_t off, int count, int* eof,
243 235
244 /* ISSUE: I don't understand this code */ 236 /* ISSUE: I don't understand this code */
245 len = (p - page); 237 len = (p - page);
246 if (len <= off+count) *eof = 1; 238 if (len <= off + count)
239 *eof = 1;
247 *start = page + off; 240 *start = page + off;
248 len -= off; 241 len -= off;
249 if (len>count) len = count; 242 if (len > count)
250 if (len<0) len = 0; 243 len = count;
244 if (len < 0)
245 len = 0;
251 return len; 246 return len;
252} 247}
253 248
254static int 249static int
255dispatch_write(struct file* file, const char __user * buffer, 250dispatch_write(struct file *file, const char __user * buffer,
256 unsigned long count, ProcItem* item) 251 unsigned long count, ProcItem * item)
257{ 252{
258 int result; 253 int result;
259 char* tmp_buffer; 254 char *tmp_buffer;
260 255
261 /* Arg buffer points to userspace memory, which can't be accessed 256 /* Arg buffer points to userspace memory, which can't be accessed
262 * directly. Since we're making a copy, zero-terminate the 257 * directly. Since we're making a copy, zero-terminate the
263 * destination so that sscanf can be used on it safely. 258 * destination so that sscanf can be used on it safely.
264 */ 259 */
265 tmp_buffer = kmalloc(count + 1, GFP_KERNEL); 260 tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
266 if(!tmp_buffer) 261 if (!tmp_buffer)
267 return -ENOMEM; 262 return -ENOMEM;
268 263
269 if (copy_from_user(tmp_buffer, buffer, count)) { 264 if (copy_from_user(tmp_buffer, buffer, count)) {
270 result = -EFAULT; 265 result = -EFAULT;
271 } 266 } else {
272 else {
273 tmp_buffer[count] = 0; 267 tmp_buffer[count] = 0;
274 result = item->write_func(tmp_buffer, count); 268 result = item->write_func(tmp_buffer, count);
275 } 269 }
@@ -277,8 +271,7 @@ dispatch_write(struct file* file, const char __user * buffer,
277 return result; 271 return result;
278} 272}
279 273
280static char* 274static char *read_lcd(char *p)
281read_lcd(char* p)
282{ 275{
283 u32 hci_result; 276 u32 hci_result;
284 u32 value; 277 u32 value;
@@ -288,7 +281,7 @@ read_lcd(char* p)
288 value = value >> HCI_LCD_BRIGHTNESS_SHIFT; 281 value = value >> HCI_LCD_BRIGHTNESS_SHIFT;
289 p += sprintf(p, "brightness: %d\n", value); 282 p += sprintf(p, "brightness: %d\n", value);
290 p += sprintf(p, "brightness_levels: %d\n", 283 p += sprintf(p, "brightness_levels: %d\n",
291 HCI_LCD_BRIGHTNESS_LEVELS); 284 HCI_LCD_BRIGHTNESS_LEVELS);
292 } else { 285 } else {
293 printk(MY_ERR "Error reading LCD brightness\n"); 286 printk(MY_ERR "Error reading LCD brightness\n");
294 } 287 }
@@ -296,14 +289,13 @@ read_lcd(char* p)
296 return p; 289 return p;
297} 290}
298 291
299static unsigned long 292static unsigned long write_lcd(const char *buffer, unsigned long count)
300write_lcd(const char* buffer, unsigned long count)
301{ 293{
302 int value; 294 int value;
303 u32 hci_result; 295 u32 hci_result;
304 296
305 if (sscanf(buffer, " brightness : %i", &value) == 1 && 297 if (sscanf(buffer, " brightness : %i", &value) == 1 &&
306 value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { 298 value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) {
307 value = value << HCI_LCD_BRIGHTNESS_SHIFT; 299 value = value << HCI_LCD_BRIGHTNESS_SHIFT;
308 hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result); 300 hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result);
309 if (hci_result != HCI_SUCCESS) 301 if (hci_result != HCI_SUCCESS)
@@ -315,8 +307,7 @@ write_lcd(const char* buffer, unsigned long count)
315 return count; 307 return count;
316} 308}
317 309
318static char* 310static char *read_video(char *p)
319read_video(char* p)
320{ 311{
321 u32 hci_result; 312 u32 hci_result;
322 u32 value; 313 u32 value;
@@ -325,7 +316,7 @@ read_video(char* p)
325 if (hci_result == HCI_SUCCESS) { 316 if (hci_result == HCI_SUCCESS) {
326 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; 317 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
327 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; 318 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
328 int is_tv = (value & HCI_VIDEO_OUT_TV ) ? 1 : 0; 319 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0;
329 p += sprintf(p, "lcd_out: %d\n", is_lcd); 320 p += sprintf(p, "lcd_out: %d\n", is_lcd);
330 p += sprintf(p, "crt_out: %d\n", is_crt); 321 p += sprintf(p, "crt_out: %d\n", is_crt);
331 p += sprintf(p, "tv_out: %d\n", is_tv); 322 p += sprintf(p, "tv_out: %d\n", is_tv);
@@ -336,8 +327,7 @@ read_video(char* p)
336 return p; 327 return p;
337} 328}
338 329
339static unsigned long 330static unsigned long write_video(const char *buffer, unsigned long count)
340write_video(const char* buffer, unsigned long count)
341{ 331{
342 int value; 332 int value;
343 int remain = count; 333 int remain = count;
@@ -363,7 +353,7 @@ write_video(const char* buffer, unsigned long count)
363 ++buffer; 353 ++buffer;
364 --remain; 354 --remain;
365 } 355 }
366 while (remain && *(buffer-1) != ';'); 356 while (remain && *(buffer - 1) != ';');
367 } 357 }
368 358
369 hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result); 359 hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result);
@@ -386,8 +376,7 @@ write_video(const char* buffer, unsigned long count)
386 return count; 376 return count;
387} 377}
388 378
389static char* 379static char *read_fan(char *p)
390read_fan(char* p)
391{ 380{
392 u32 hci_result; 381 u32 hci_result;
393 u32 value; 382 u32 value;
@@ -403,14 +392,13 @@ read_fan(char* p)
403 return p; 392 return p;
404} 393}
405 394
406static unsigned long 395static unsigned long write_fan(const char *buffer, unsigned long count)
407write_fan(const char* buffer, unsigned long count)
408{ 396{
409 int value; 397 int value;
410 u32 hci_result; 398 u32 hci_result;
411 399
412 if (sscanf(buffer, " force_on : %i", &value) == 1 && 400 if (sscanf(buffer, " force_on : %i", &value) == 1 &&
413 value >= 0 && value <= 1) { 401 value >= 0 && value <= 1) {
414 hci_write1(HCI_FAN, value, &hci_result); 402 hci_write1(HCI_FAN, value, &hci_result);
415 if (hci_result != HCI_SUCCESS) 403 if (hci_result != HCI_SUCCESS)
416 return -EFAULT; 404 return -EFAULT;
@@ -423,8 +411,7 @@ write_fan(const char* buffer, unsigned long count)
423 return count; 411 return count;
424} 412}
425 413
426static char* 414static char *read_keys(char *p)
427read_keys(char* p)
428{ 415{
429 u32 hci_result; 416 u32 hci_result;
430 u32 value; 417 u32 value;
@@ -451,17 +438,15 @@ read_keys(char* p)
451 p += sprintf(p, "hotkey_ready: %d\n", key_event_valid); 438 p += sprintf(p, "hotkey_ready: %d\n", key_event_valid);
452 p += sprintf(p, "hotkey: 0x%04x\n", last_key_event); 439 p += sprintf(p, "hotkey: 0x%04x\n", last_key_event);
453 440
454end: 441 end:
455 return p; 442 return p;
456} 443}
457 444
458static unsigned long 445static unsigned long write_keys(const char *buffer, unsigned long count)
459write_keys(const char* buffer, unsigned long count)
460{ 446{
461 int value; 447 int value;
462 448
463 if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && 449 if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && value == 0) {
464 value == 0) {
465 key_event_valid = 0; 450 key_event_valid = 0;
466 } else { 451 } else {
467 return -EINVAL; 452 return -EINVAL;
@@ -470,12 +455,11 @@ write_keys(const char* buffer, unsigned long count)
470 return count; 455 return count;
471} 456}
472 457
473static char* 458static char *read_version(char *p)
474read_version(char* p)
475{ 459{
476 p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION); 460 p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION);
477 p += sprintf(p, "proc_interface: %d\n", 461 p += sprintf(p, "proc_interface: %d\n",
478 PROC_INTERFACE_VERSION); 462 PROC_INTERFACE_VERSION);
479 return p; 463 return p;
480} 464}
481 465
@@ -484,48 +468,45 @@ read_version(char* p)
484 468
485#define PROC_TOSHIBA "toshiba" 469#define PROC_TOSHIBA "toshiba"
486 470
487static ProcItem proc_items[] = 471static ProcItem proc_items[] = {
488{ 472 {"lcd", read_lcd, write_lcd},
489 { "lcd" , read_lcd , write_lcd }, 473 {"video", read_video, write_video},
490 { "video" , read_video , write_video }, 474 {"fan", read_fan, write_fan},
491 { "fan" , read_fan , write_fan }, 475 {"keys", read_keys, write_keys},
492 { "keys" , read_keys , write_keys }, 476 {"version", read_version, NULL},
493 { "version" , read_version , NULL }, 477 {NULL}
494 { NULL }
495}; 478};
496 479
497static acpi_status __init 480static acpi_status __init add_device(void)
498add_device(void)
499{ 481{
500 struct proc_dir_entry* proc; 482 struct proc_dir_entry *proc;
501 ProcItem* item; 483 ProcItem *item;
502 484
503 for (item = proc_items; item->name; ++item) 485 for (item = proc_items; item->name; ++item) {
504 {
505 proc = create_proc_read_entry(item->name, 486 proc = create_proc_read_entry(item->name,
506 S_IFREG | S_IRUGO | S_IWUSR, 487 S_IFREG | S_IRUGO | S_IWUSR,
507 toshiba_proc_dir, (read_proc_t*)dispatch_read, item); 488 toshiba_proc_dir,
489 (read_proc_t *) dispatch_read,
490 item);
508 if (proc) 491 if (proc)
509 proc->owner = THIS_MODULE; 492 proc->owner = THIS_MODULE;
510 if (proc && item->write_func) 493 if (proc && item->write_func)
511 proc->write_proc = (write_proc_t*)dispatch_write; 494 proc->write_proc = (write_proc_t *) dispatch_write;
512 } 495 }
513 496
514 return AE_OK; 497 return AE_OK;
515} 498}
516 499
517static acpi_status __exit 500static acpi_status __exit remove_device(void)
518remove_device(void)
519{ 501{
520 ProcItem* item; 502 ProcItem *item;
521 503
522 for (item = proc_items; item->name; ++item) 504 for (item = proc_items; item->name; ++item)
523 remove_proc_entry(item->name, toshiba_proc_dir); 505 remove_proc_entry(item->name, toshiba_proc_dir);
524 return AE_OK; 506 return AE_OK;
525} 507}
526 508
527static int __init 509static int __init toshiba_acpi_init(void)
528toshiba_acpi_init(void)
529{ 510{
530 acpi_status status = AE_OK; 511 acpi_status status = AE_OK;
531 u32 hci_result; 512 u32 hci_result;
@@ -533,9 +514,9 @@ toshiba_acpi_init(void)
533 if (acpi_disabled) 514 if (acpi_disabled)
534 return -ENODEV; 515 return -ENODEV;
535 516
536 if (!acpi_specific_hotkey_enabled){ 517 if (!acpi_specific_hotkey_enabled) {
537 printk(MY_INFO "Using generic hotkey driver\n"); 518 printk(MY_INFO "Using generic hotkey driver\n");
538 return -ENODEV; 519 return -ENODEV;
539 } 520 }
540 /* simple device detection: look for HCI method */ 521 /* simple device detection: look for HCI method */
541 if (is_valid_acpi_path(METHOD_HCI_1)) 522 if (is_valid_acpi_path(METHOD_HCI_1))
@@ -546,7 +527,7 @@ toshiba_acpi_init(void)
546 return -ENODEV; 527 return -ENODEV;
547 528
548 printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n", 529 printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n",
549 TOSHIBA_ACPI_VERSION); 530 TOSHIBA_ACPI_VERSION);
550 printk(MY_INFO " HCI method: %s\n", method_hci); 531 printk(MY_INFO " HCI method: %s\n", method_hci);
551 532
552 force_fan = 0; 533 force_fan = 0;
@@ -568,8 +549,7 @@ toshiba_acpi_init(void)
568 return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; 549 return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
569} 550}
570 551
571static void __exit 552static void __exit toshiba_acpi_exit(void)
572toshiba_acpi_exit(void)
573{ 553{
574 remove_device(); 554 remove_device();
575 555
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
index 939c447dd52a..e87108b7338a 100644
--- a/drivers/acpi/utilities/Makefile
+++ b/drivers/acpi/utilities/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o 6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o
7 7
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index c4e7f989a2bd..068450b36475 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utalloc - local cache and memory allocation routines 3 * Module Name: utalloc - local memory allocation routines
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -41,232 +41,134 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46 45
47#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utalloc") 47ACPI_MODULE_NAME("utalloc")
49 48
50/* Local prototypes */ 49/* Local prototypes */
51
52#ifdef ACPI_DBG_TRACK_ALLOCATIONS 50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
53static struct acpi_debug_mem_block * 51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
54acpi_ut_find_allocation (
55 u32 list_id,
56 void *allocation);
57 52
58static acpi_status 53static acpi_status
59acpi_ut_track_allocation ( 54acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
60 u32 list_id, 55 acpi_size size,
61 struct acpi_debug_mem_block *address, 56 u8 alloc_type, u32 component, char *module, u32 line);
62 acpi_size size,
63 u8 alloc_type,
64 u32 component,
65 char *module,
66 u32 line);
67 57
68static acpi_status 58static acpi_status
69acpi_ut_remove_allocation ( 59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
70 u32 list_id, 60 u32 component, char *module, u32 line);
71 struct acpi_debug_mem_block *address, 61#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
72 u32 component,
73 char *module,
74 u32 line);
75#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
76 62
63#ifdef ACPI_DBG_TRACK_ALLOCATIONS
64static acpi_status
65acpi_ut_create_list(char *list_name,
66 u16 object_size, struct acpi_memory_list **return_cache);
67#endif
77 68
78/******************************************************************************* 69/*******************************************************************************
79 * 70 *
80 * FUNCTION: acpi_ut_release_to_cache 71 * FUNCTION: acpi_ut_create_caches
81 * 72 *
82 * PARAMETERS: list_id - Memory list/cache ID 73 * PARAMETERS: None
83 * Object - The object to be released
84 * 74 *
85 * RETURN: None 75 * RETURN: Status
86 * 76 *
87 * DESCRIPTION: Release an object to the specified cache. If cache is full, 77 * DESCRIPTION: Create all local caches
88 * the object is deleted.
89 * 78 *
90 ******************************************************************************/ 79 ******************************************************************************/
91 80
92void 81acpi_status acpi_ut_create_caches(void)
93acpi_ut_release_to_cache (
94 u32 list_id,
95 void *object)
96{ 82{
97 struct acpi_memory_list *cache_info; 83 acpi_status status;
98
99 84
100 ACPI_FUNCTION_ENTRY (); 85#ifdef ACPI_DBG_TRACK_ALLOCATIONS
101
102
103 cache_info = &acpi_gbl_memory_lists[list_id];
104
105#ifdef ACPI_ENABLE_OBJECT_CACHE
106 86
107 /* If walk cache is full, just free this wallkstate object */ 87 /* Memory allocation lists */
108 88
109 if (cache_info->cache_depth >= cache_info->max_cache_depth) { 89 status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list);
110 ACPI_MEM_FREE (object); 90 if (ACPI_FAILURE(status)) {
111 ACPI_MEM_TRACKING (cache_info->total_freed++); 91 return (status);
112 } 92 }
113 93
114 /* Otherwise put this object back into the cache */ 94 status =
115 95 acpi_ut_create_list("Acpi-Namespace",
116 else { 96 sizeof(struct acpi_namespace_node),
117 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { 97 &acpi_gbl_ns_node_list);
118 return; 98 if (ACPI_FAILURE(status)) {
119 } 99 return (status);
120
121 /* Mark the object as cached */
122
123 ACPI_MEMSET (object, 0xCA, cache_info->object_size);
124 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
125
126 /* Put the object at the head of the cache list */
127
128 * (ACPI_CAST_INDIRECT_PTR (char,
129 &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
130 cache_info->list_head = object;
131 cache_info->cache_depth++;
132
133 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
134 } 100 }
135
136#else
137
138 /* Object cache is disabled; just free the object */
139
140 ACPI_MEM_FREE (object);
141 ACPI_MEM_TRACKING (cache_info->total_freed++);
142#endif 101#endif
143}
144
145
146/*******************************************************************************
147 *
148 * FUNCTION: acpi_ut_acquire_from_cache
149 *
150 * PARAMETERS: list_id - Memory list ID
151 *
152 * RETURN: A requested object. NULL if the object could not be
153 * allocated.
154 *
155 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
156 * the object is allocated.
157 *
158 ******************************************************************************/
159
160void *
161acpi_ut_acquire_from_cache (
162 u32 list_id)
163{
164 struct acpi_memory_list *cache_info;
165 void *object;
166 102
103 /* Object Caches, for frequently used objects */
167 104
168 ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); 105 status =
169 106 acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state),
170 107 ACPI_MAX_STATE_CACHE_DEPTH,
171 cache_info = &acpi_gbl_memory_lists[list_id]; 108 &acpi_gbl_state_cache);
172 109 if (ACPI_FAILURE(status)) {
173#ifdef ACPI_ENABLE_OBJECT_CACHE 110 return (status);
174
175 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
176 return (NULL);
177 } 111 }
178 112
179 ACPI_MEM_TRACKING (cache_info->cache_requests++); 113 status =
180 114 acpi_os_create_cache("acpi_parse",
181 /* Check the cache first */ 115 sizeof(struct acpi_parse_obj_common),
182 116 ACPI_MAX_PARSE_CACHE_DEPTH,
183 if (cache_info->list_head) { 117 &acpi_gbl_ps_node_cache);
184 /* There is an object available, use it */ 118 if (ACPI_FAILURE(status)) {
185 119 return (status);
186 object = cache_info->list_head;
187 cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
188 &(((char *) object)[cache_info->link_offset])));
189
190 ACPI_MEM_TRACKING (cache_info->cache_hits++);
191 cache_info->cache_depth--;
192
193#ifdef ACPI_DBG_TRACK_ALLOCATIONS
194 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
195 object, acpi_gbl_memory_lists[list_id].list_name));
196#endif
197
198 if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
199 return (NULL);
200 }
201
202 /* Clear (zero) the previously used Object */
203
204 ACPI_MEMSET (object, 0, cache_info->object_size);
205 } 120 }
206 121
207 else { 122 status =
208 /* The cache is empty, create a new object */ 123 acpi_os_create_cache("acpi_parse_ext",
209 124 sizeof(struct acpi_parse_obj_named),
210 /* Avoid deadlock with ACPI_MEM_CALLOCATE */ 125 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
211 126 &acpi_gbl_ps_node_ext_cache);
212 if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { 127 if (ACPI_FAILURE(status)) {
213 return (NULL); 128 return (status);
214 }
215
216 object = ACPI_MEM_CALLOCATE (cache_info->object_size);
217 ACPI_MEM_TRACKING (cache_info->total_allocated++);
218 } 129 }
219 130
220#else 131 status =
221 132 acpi_os_create_cache("acpi_operand",
222 /* Object cache is disabled; just allocate the object */ 133 sizeof(union acpi_operand_object),
223 134 ACPI_MAX_OBJECT_CACHE_DEPTH,
224 object = ACPI_MEM_CALLOCATE (cache_info->object_size); 135 &acpi_gbl_operand_cache);
225 ACPI_MEM_TRACKING (cache_info->total_allocated++); 136 if (ACPI_FAILURE(status)) {
226#endif 137 return (status);
138 }
227 139
228 return (object); 140 return (AE_OK);
229} 141}
230 142
231
232#ifdef ACPI_ENABLE_OBJECT_CACHE
233/******************************************************************************* 143/*******************************************************************************
234 * 144 *
235 * FUNCTION: acpi_ut_delete_generic_cache 145 * FUNCTION: acpi_ut_delete_caches
236 * 146 *
237 * PARAMETERS: list_id - Memory list ID 147 * PARAMETERS: None
238 * 148 *
239 * RETURN: None 149 * RETURN: Status
240 * 150 *
241 * DESCRIPTION: Free all objects within the requested cache. 151 * DESCRIPTION: Purge and delete all local caches
242 * 152 *
243 ******************************************************************************/ 153 ******************************************************************************/
244 154
245void 155acpi_status acpi_ut_delete_caches(void)
246acpi_ut_delete_generic_cache (
247 u32 list_id)
248{ 156{
249 struct acpi_memory_list *cache_info;
250 char *next;
251
252 157
253 ACPI_FUNCTION_ENTRY (); 158 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
159 acpi_gbl_state_cache = NULL;
254 160
161 (void)acpi_os_delete_cache(acpi_gbl_operand_cache);
162 acpi_gbl_operand_cache = NULL;
255 163
256 cache_info = &acpi_gbl_memory_lists[list_id]; 164 (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache);
257 while (cache_info->list_head) { 165 acpi_gbl_ps_node_cache = NULL;
258 /* Delete one cached state object */
259 166
260 next = *(ACPI_CAST_INDIRECT_PTR (char, 167 (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache);
261 &(((char *) cache_info->list_head)[cache_info->link_offset]))); 168 acpi_gbl_ps_node_ext_cache = NULL;
262 ACPI_MEM_FREE (cache_info->list_head);
263 169
264 cache_info->list_head = next; 170 return (AE_OK);
265 cache_info->cache_depth--;
266 }
267} 171}
268#endif
269
270 172
271/******************************************************************************* 173/*******************************************************************************
272 * 174 *
@@ -280,9 +182,7 @@ acpi_ut_delete_generic_cache (
280 * 182 *
281 ******************************************************************************/ 183 ******************************************************************************/
282 184
283acpi_status 185acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
284acpi_ut_validate_buffer (
285 struct acpi_buffer *buffer)
286{ 186{
287 187
288 /* Obviously, the structure pointer must be valid */ 188 /* Obviously, the structure pointer must be valid */
@@ -293,9 +193,9 @@ acpi_ut_validate_buffer (
293 193
294 /* Special semantics for the length */ 194 /* Special semantics for the length */
295 195
296 if ((buffer->length == ACPI_NO_BUFFER) || 196 if ((buffer->length == ACPI_NO_BUFFER) ||
297 (buffer->length == ACPI_ALLOCATE_BUFFER) || 197 (buffer->length == ACPI_ALLOCATE_BUFFER) ||
298 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { 198 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
299 return (AE_OK); 199 return (AE_OK);
300 } 200 }
301 201
@@ -308,7 +208,6 @@ acpi_ut_validate_buffer (
308 return (AE_OK); 208 return (AE_OK);
309} 209}
310 210
311
312/******************************************************************************* 211/*******************************************************************************
313 * 212 *
314 * FUNCTION: acpi_ut_initialize_buffer 213 * FUNCTION: acpi_ut_initialize_buffer
@@ -324,12 +223,10 @@ acpi_ut_validate_buffer (
324 ******************************************************************************/ 223 ******************************************************************************/
325 224
326acpi_status 225acpi_status
327acpi_ut_initialize_buffer ( 226acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
328 struct acpi_buffer *buffer, 227 acpi_size required_length)
329 acpi_size required_length)
330{ 228{
331 acpi_status status = AE_OK; 229 acpi_status status = AE_OK;
332
333 230
334 switch (buffer->length) { 231 switch (buffer->length) {
335 case ACPI_NO_BUFFER: 232 case ACPI_NO_BUFFER:
@@ -339,33 +236,30 @@ acpi_ut_initialize_buffer (
339 status = AE_BUFFER_OVERFLOW; 236 status = AE_BUFFER_OVERFLOW;
340 break; 237 break;
341 238
342
343 case ACPI_ALLOCATE_BUFFER: 239 case ACPI_ALLOCATE_BUFFER:
344 240
345 /* Allocate a new buffer */ 241 /* Allocate a new buffer */
346 242
347 buffer->pointer = acpi_os_allocate (required_length); 243 buffer->pointer = acpi_os_allocate(required_length);
348 if (!buffer->pointer) { 244 if (!buffer->pointer) {
349 return (AE_NO_MEMORY); 245 return (AE_NO_MEMORY);
350 } 246 }
351 247
352 /* Clear the buffer */ 248 /* Clear the buffer */
353 249
354 ACPI_MEMSET (buffer->pointer, 0, required_length); 250 ACPI_MEMSET(buffer->pointer, 0, required_length);
355 break; 251 break;
356 252
357
358 case ACPI_ALLOCATE_LOCAL_BUFFER: 253 case ACPI_ALLOCATE_LOCAL_BUFFER:
359 254
360 /* Allocate a new buffer with local interface to allow tracking */ 255 /* Allocate a new buffer with local interface to allow tracking */
361 256
362 buffer->pointer = ACPI_MEM_CALLOCATE (required_length); 257 buffer->pointer = ACPI_MEM_CALLOCATE(required_length);
363 if (!buffer->pointer) { 258 if (!buffer->pointer) {
364 return (AE_NO_MEMORY); 259 return (AE_NO_MEMORY);
365 } 260 }
366 break; 261 break;
367 262
368
369 default: 263 default:
370 264
371 /* Existing buffer: Validate the size of the buffer */ 265 /* Existing buffer: Validate the size of the buffer */
@@ -377,7 +271,7 @@ acpi_ut_initialize_buffer (
377 271
378 /* Clear the buffer */ 272 /* Clear the buffer */
379 273
380 ACPI_MEMSET (buffer->pointer, 0, required_length); 274 ACPI_MEMSET(buffer->pointer, 0, required_length);
381 break; 275 break;
382 } 276 }
383 277
@@ -385,7 +279,6 @@ acpi_ut_initialize_buffer (
385 return (status); 279 return (status);
386} 280}
387 281
388
389/******************************************************************************* 282/*******************************************************************************
390 * 283 *
391 * FUNCTION: acpi_ut_allocate 284 * FUNCTION: acpi_ut_allocate
@@ -401,41 +294,34 @@ acpi_ut_initialize_buffer (
401 * 294 *
402 ******************************************************************************/ 295 ******************************************************************************/
403 296
404void * 297void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
405acpi_ut_allocate (
406 acpi_size size,
407 u32 component,
408 char *module,
409 u32 line)
410{ 298{
411 void *allocation; 299 void *allocation;
412
413
414 ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size);
415 300
301 ACPI_FUNCTION_TRACE_U32("ut_allocate", size);
416 302
417 /* Check for an inadvertent size of zero bytes */ 303 /* Check for an inadvertent size of zero bytes */
418 304
419 if (!size) { 305 if (!size) {
420 _ACPI_REPORT_ERROR (module, line, component, 306 _ACPI_REPORT_ERROR(module, line, component,
421 ("ut_allocate: Attempt to allocate zero bytes\n")); 307 ("ut_allocate: Attempt to allocate zero bytes\n"));
422 size = 1; 308 size = 1;
423 } 309 }
424 310
425 allocation = acpi_os_allocate (size); 311 allocation = acpi_os_allocate(size);
426 if (!allocation) { 312 if (!allocation) {
427 /* Report allocation error */ 313 /* Report allocation error */
428 314
429 _ACPI_REPORT_ERROR (module, line, component, 315 _ACPI_REPORT_ERROR(module, line, component,
430 ("ut_allocate: Could not allocate size %X\n", (u32) size)); 316 ("ut_allocate: Could not allocate size %X\n",
317 (u32) size));
431 318
432 return_PTR (NULL); 319 return_PTR(NULL);
433 } 320 }
434 321
435 return_PTR (allocation); 322 return_PTR(allocation);
436} 323}
437 324
438
439/******************************************************************************* 325/*******************************************************************************
440 * 326 *
441 * FUNCTION: acpi_ut_callocate 327 * FUNCTION: acpi_ut_callocate
@@ -451,43 +337,36 @@ acpi_ut_allocate (
451 * 337 *
452 ******************************************************************************/ 338 ******************************************************************************/
453 339
454void * 340void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
455acpi_ut_callocate (
456 acpi_size size,
457 u32 component,
458 char *module,
459 u32 line)
460{ 341{
461 void *allocation; 342 void *allocation;
462
463
464 ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size);
465 343
344 ACPI_FUNCTION_TRACE_U32("ut_callocate", size);
466 345
467 /* Check for an inadvertent size of zero bytes */ 346 /* Check for an inadvertent size of zero bytes */
468 347
469 if (!size) { 348 if (!size) {
470 _ACPI_REPORT_ERROR (module, line, component, 349 _ACPI_REPORT_ERROR(module, line, component,
471 ("ut_callocate: Attempt to allocate zero bytes\n")); 350 ("ut_callocate: Attempt to allocate zero bytes\n"));
472 return_PTR (NULL); 351 return_PTR(NULL);
473 } 352 }
474 353
475 allocation = acpi_os_allocate (size); 354 allocation = acpi_os_allocate(size);
476 if (!allocation) { 355 if (!allocation) {
477 /* Report allocation error */ 356 /* Report allocation error */
478 357
479 _ACPI_REPORT_ERROR (module, line, component, 358 _ACPI_REPORT_ERROR(module, line, component,
480 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 359 ("ut_callocate: Could not allocate size %X\n",
481 return_PTR (NULL); 360 (u32) size));
361 return_PTR(NULL);
482 } 362 }
483 363
484 /* Clear the memory block */ 364 /* Clear the memory block */
485 365
486 ACPI_MEMSET (allocation, 0, size); 366 ACPI_MEMSET(allocation, 0, size);
487 return_PTR (allocation); 367 return_PTR(allocation);
488} 368}
489 369
490
491#ifdef ACPI_DBG_TRACK_ALLOCATIONS 370#ifdef ACPI_DBG_TRACK_ALLOCATIONS
492/* 371/*
493 * These procedures are used for tracking memory leaks in the subsystem, and 372 * These procedures are used for tracking memory leaks in the subsystem, and
@@ -500,6 +379,39 @@ acpi_ut_callocate (
500 * occurs in the body of acpi_ut_free. 379 * occurs in the body of acpi_ut_free.
501 */ 380 */
502 381
382/*******************************************************************************
383 *
384 * FUNCTION: acpi_ut_create_list
385 *
386 * PARAMETERS: cache_name - Ascii name for the cache
387 * object_size - Size of each cached object
388 * return_cache - Where the new cache object is returned
389 *
390 * RETURN: Status
391 *
392 * DESCRIPTION: Create a local memory list for tracking purposed
393 *
394 ******************************************************************************/
395
396static acpi_status
397acpi_ut_create_list(char *list_name,
398 u16 object_size, struct acpi_memory_list **return_cache)
399{
400 struct acpi_memory_list *cache;
401
402 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
403 if (!cache) {
404 return (AE_NO_MEMORY);
405 }
406
407 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
408
409 cache->list_name = list_name;
410 cache->object_size = object_size;
411
412 *return_cache = cache;
413 return (AE_OK);
414}
503 415
504/******************************************************************************* 416/*******************************************************************************
505 * 417 *
@@ -516,37 +428,33 @@ acpi_ut_callocate (
516 * 428 *
517 ******************************************************************************/ 429 ******************************************************************************/
518 430
519void * 431void *acpi_ut_allocate_and_track(acpi_size size,
520acpi_ut_allocate_and_track ( 432 u32 component, char *module, u32 line)
521 acpi_size size,
522 u32 component,
523 char *module,
524 u32 line)
525{ 433{
526 struct acpi_debug_mem_block *allocation; 434 struct acpi_debug_mem_block *allocation;
527 acpi_status status; 435 acpi_status status;
528
529 436
530 allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), 437 allocation =
531 component, module, line); 438 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
439 component, module, line);
532 if (!allocation) { 440 if (!allocation) {
533 return (NULL); 441 return (NULL);
534 } 442 }
535 443
536 status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, 444 status = acpi_ut_track_allocation(allocation, size,
537 ACPI_MEM_MALLOC, component, module, line); 445 ACPI_MEM_MALLOC, component, module,
538 if (ACPI_FAILURE (status)) { 446 line);
539 acpi_os_free (allocation); 447 if (ACPI_FAILURE(status)) {
448 acpi_os_free(allocation);
540 return (NULL); 449 return (NULL);
541 } 450 }
542 451
543 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; 452 acpi_gbl_global_list->total_allocated++;
544 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; 453 acpi_gbl_global_list->current_total_size += (u32) size;
545 454
546 return ((void *) &allocation->user_space); 455 return ((void *)&allocation->user_space);
547} 456}
548 457
549
550/******************************************************************************* 458/*******************************************************************************
551 * 459 *
552 * FUNCTION: acpi_ut_callocate_and_track 460 * FUNCTION: acpi_ut_callocate_and_track
@@ -562,41 +470,38 @@ acpi_ut_allocate_and_track (
562 * 470 *
563 ******************************************************************************/ 471 ******************************************************************************/
564 472
565void * 473void *acpi_ut_callocate_and_track(acpi_size size,
566acpi_ut_callocate_and_track ( 474 u32 component, char *module, u32 line)
567 acpi_size size,
568 u32 component,
569 char *module,
570 u32 line)
571{ 475{
572 struct acpi_debug_mem_block *allocation; 476 struct acpi_debug_mem_block *allocation;
573 acpi_status status; 477 acpi_status status;
574
575 478
576 allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), 479 allocation =
577 component, module, line); 480 acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header),
481 component, module, line);
578 if (!allocation) { 482 if (!allocation) {
579 /* Report allocation error */ 483 /* Report allocation error */
580 484
581 _ACPI_REPORT_ERROR (module, line, component, 485 _ACPI_REPORT_ERROR(module, line, component,
582 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 486 ("ut_callocate: Could not allocate size %X\n",
487 (u32) size));
583 return (NULL); 488 return (NULL);
584 } 489 }
585 490
586 status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, 491 status = acpi_ut_track_allocation(allocation, size,
587 ACPI_MEM_CALLOC, component, module, line); 492 ACPI_MEM_CALLOC, component, module,
588 if (ACPI_FAILURE (status)) { 493 line);
589 acpi_os_free (allocation); 494 if (ACPI_FAILURE(status)) {
495 acpi_os_free(allocation);
590 return (NULL); 496 return (NULL);
591 } 497 }
592 498
593 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; 499 acpi_gbl_global_list->total_allocated++;
594 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; 500 acpi_gbl_global_list->current_total_size += (u32) size;
595 501
596 return ((void *) &allocation->user_space); 502 return ((void *)&allocation->user_space);
597} 503}
598 504
599
600/******************************************************************************* 505/*******************************************************************************
601 * 506 *
602 * FUNCTION: acpi_ut_free_and_track 507 * FUNCTION: acpi_ut_free_and_track
@@ -613,53 +518,46 @@ acpi_ut_callocate_and_track (
613 ******************************************************************************/ 518 ******************************************************************************/
614 519
615void 520void
616acpi_ut_free_and_track ( 521acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
617 void *allocation,
618 u32 component,
619 char *module,
620 u32 line)
621{ 522{
622 struct acpi_debug_mem_block *debug_block; 523 struct acpi_debug_mem_block *debug_block;
623 acpi_status status; 524 acpi_status status;
624
625
626 ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation);
627 525
526 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
628 527
629 if (NULL == allocation) { 528 if (NULL == allocation) {
630 _ACPI_REPORT_ERROR (module, line, component, 529 _ACPI_REPORT_ERROR(module, line, component,
631 ("acpi_ut_free: Attempt to delete a NULL address\n")); 530 ("acpi_ut_free: Attempt to delete a NULL address\n"));
632 531
633 return_VOID; 532 return_VOID;
634 } 533 }
635 534
636 debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, 535 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
637 (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); 536 (((char *)allocation) -
537 sizeof(struct acpi_debug_mem_header)));
638 538
639 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; 539 acpi_gbl_global_list->total_freed++;
640 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; 540 acpi_gbl_global_list->current_total_size -= debug_block->size;
641 541
642 status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, 542 status = acpi_ut_remove_allocation(debug_block,
643 component, module, line); 543 component, module, line);
644 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
645 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", 545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n",
646 acpi_format_exception (status))); 546 acpi_format_exception(status)));
647 } 547 }
648 548
649 acpi_os_free (debug_block); 549 acpi_os_free(debug_block);
650 550
651 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 551 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
652 552
653 return_VOID; 553 return_VOID;
654} 554}
655 555
656
657/******************************************************************************* 556/*******************************************************************************
658 * 557 *
659 * FUNCTION: acpi_ut_find_allocation 558 * FUNCTION: acpi_ut_find_allocation
660 * 559 *
661 * PARAMETERS: list_id - Memory list to search 560 * PARAMETERS: Allocation - Address of allocated memory
662 * Allocation - Address of allocated memory
663 * 561 *
664 * RETURN: A list element if found; NULL otherwise. 562 * RETURN: A list element if found; NULL otherwise.
665 * 563 *
@@ -667,22 +565,13 @@ acpi_ut_free_and_track (
667 * 565 *
668 ******************************************************************************/ 566 ******************************************************************************/
669 567
670static struct acpi_debug_mem_block * 568static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation)
671acpi_ut_find_allocation (
672 u32 list_id,
673 void *allocation)
674{ 569{
675 struct acpi_debug_mem_block *element; 570 struct acpi_debug_mem_block *element;
676
677 571
678 ACPI_FUNCTION_ENTRY (); 572 ACPI_FUNCTION_ENTRY();
679
680
681 if (list_id > ACPI_MEM_LIST_MAX) {
682 return (NULL);
683 }
684 573
685 element = acpi_gbl_memory_lists[list_id].list_head; 574 element = acpi_gbl_global_list->list_head;
686 575
687 /* Search for the address. */ 576 /* Search for the address. */
688 577
@@ -697,13 +586,11 @@ acpi_ut_find_allocation (
697 return (NULL); 586 return (NULL);
698} 587}
699 588
700
701/******************************************************************************* 589/*******************************************************************************
702 * 590 *
703 * FUNCTION: acpi_ut_track_allocation 591 * FUNCTION: acpi_ut_track_allocation
704 * 592 *
705 * PARAMETERS: list_id - Memory list to search 593 * PARAMETERS: Allocation - Address of allocated memory
706 * Allocation - Address of allocated memory
707 * Size - Size of the allocation 594 * Size - Size of the allocation
708 * alloc_type - MEM_MALLOC or MEM_CALLOC 595 * alloc_type - MEM_MALLOC or MEM_CALLOC
709 * Component - Component type of caller 596 * Component - Component type of caller
@@ -717,64 +604,51 @@ acpi_ut_find_allocation (
717 ******************************************************************************/ 604 ******************************************************************************/
718 605
719static acpi_status 606static acpi_status
720acpi_ut_track_allocation ( 607acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
721 u32 list_id, 608 acpi_size size,
722 struct acpi_debug_mem_block *allocation, 609 u8 alloc_type, u32 component, char *module, u32 line)
723 acpi_size size,
724 u8 alloc_type,
725 u32 component,
726 char *module,
727 u32 line)
728{ 610{
729 struct acpi_memory_list *mem_list; 611 struct acpi_memory_list *mem_list;
730 struct acpi_debug_mem_block *element; 612 struct acpi_debug_mem_block *element;
731 acpi_status status = AE_OK; 613 acpi_status status = AE_OK;
732
733
734 ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
735 614
615 ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation);
736 616
737 if (list_id > ACPI_MEM_LIST_MAX) { 617 mem_list = acpi_gbl_global_list;
738 return_ACPI_STATUS (AE_BAD_PARAMETER); 618 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
739 } 619 if (ACPI_FAILURE(status)) {
740 620 return_ACPI_STATUS(status);
741 mem_list = &acpi_gbl_memory_lists[list_id];
742 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
743 if (ACPI_FAILURE (status)) {
744 return_ACPI_STATUS (status);
745 } 621 }
746 622
747 /* 623 /*
748 * Search list for this address to make sure it is not already on the list. 624 * Search list for this address to make sure it is not already on the list.
749 * This will catch several kinds of problems. 625 * This will catch several kinds of problems.
750 */ 626 */
751 627 element = acpi_ut_find_allocation(allocation);
752 element = acpi_ut_find_allocation (list_id, allocation);
753 if (element) { 628 if (element) {
754 ACPI_REPORT_ERROR (( 629 ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation));
755 "ut_track_allocation: Allocation already present in list! (%p)\n",
756 allocation));
757 630
758 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n",
759 element, allocation)); 632 element, allocation));
760 633
761 goto unlock_and_exit; 634 goto unlock_and_exit;
762 } 635 }
763 636
764 /* Fill in the instance data. */ 637 /* Fill in the instance data. */
765 638
766 allocation->size = (u32) size; 639 allocation->size = (u32) size;
767 allocation->alloc_type = alloc_type; 640 allocation->alloc_type = alloc_type;
768 allocation->component = component; 641 allocation->component = component;
769 allocation->line = line; 642 allocation->line = line;
770 643
771 ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME); 644 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
772 allocation->module[ACPI_MAX_MODULE_NAME-1] = 0; 645 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
773 646
774 /* Insert at list head */ 647 /* Insert at list head */
775 648
776 if (mem_list->list_head) { 649 if (mem_list->list_head) {
777 ((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation; 650 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
651 previous = allocation;
778 } 652 }
779 653
780 allocation->next = mem_list->list_head; 654 allocation->next = mem_list->list_head;
@@ -782,19 +656,16 @@ acpi_ut_track_allocation (
782 656
783 mem_list->list_head = allocation; 657 mem_list->list_head = allocation;
784 658
785 659 unlock_and_exit:
786unlock_and_exit: 660 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
787 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 661 return_ACPI_STATUS(status);
788 return_ACPI_STATUS (status);
789} 662}
790 663
791
792/******************************************************************************* 664/*******************************************************************************
793 * 665 *
794 * FUNCTION: acpi_ut_remove_allocation 666 * FUNCTION: acpi_ut_remove_allocation
795 * 667 *
796 * PARAMETERS: list_id - Memory list to search 668 * PARAMETERS: Allocation - Address of allocated memory
797 * Allocation - Address of allocated memory
798 * Component - Component type of caller 669 * Component - Component type of caller
799 * Module - Source file name of caller 670 * Module - Source file name of caller
800 * Line - Line number of caller 671 * Line - Line number of caller
@@ -806,45 +677,34 @@ unlock_and_exit:
806 ******************************************************************************/ 677 ******************************************************************************/
807 678
808static acpi_status 679static acpi_status
809acpi_ut_remove_allocation ( 680acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
810 u32 list_id, 681 u32 component, char *module, u32 line)
811 struct acpi_debug_mem_block *allocation,
812 u32 component,
813 char *module,
814 u32 line)
815{ 682{
816 struct acpi_memory_list *mem_list; 683 struct acpi_memory_list *mem_list;
817 acpi_status status; 684 acpi_status status;
818
819 685
820 ACPI_FUNCTION_TRACE ("ut_remove_allocation"); 686 ACPI_FUNCTION_TRACE("ut_remove_allocation");
821 687
822 688 mem_list = acpi_gbl_global_list;
823 if (list_id > ACPI_MEM_LIST_MAX) {
824 return_ACPI_STATUS (AE_BAD_PARAMETER);
825 }
826
827 mem_list = &acpi_gbl_memory_lists[list_id];
828 if (NULL == mem_list->list_head) { 689 if (NULL == mem_list->list_head) {
829 /* No allocations! */ 690 /* No allocations! */
830 691
831 _ACPI_REPORT_ERROR (module, line, component, 692 _ACPI_REPORT_ERROR(module, line, component,
832 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 693 ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
833 694
834 return_ACPI_STATUS (AE_OK); 695 return_ACPI_STATUS(AE_OK);
835 } 696 }
836 697
837 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 698 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
838 if (ACPI_FAILURE (status)) { 699 if (ACPI_FAILURE(status)) {
839 return_ACPI_STATUS (status); 700 return_ACPI_STATUS(status);
840 } 701 }
841 702
842 /* Unlink */ 703 /* Unlink */
843 704
844 if (allocation->previous) { 705 if (allocation->previous) {
845 (allocation->previous)->next = allocation->next; 706 (allocation->previous)->next = allocation->next;
846 } 707 } else {
847 else {
848 mem_list->list_head = allocation->next; 708 mem_list->list_head = allocation->next;
849 } 709 }
850 710
@@ -854,16 +714,15 @@ acpi_ut_remove_allocation (
854 714
855 /* Mark the segment as deleted */ 715 /* Mark the segment as deleted */
856 716
857 ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); 717 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
858 718
859 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", 719 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
860 allocation->size)); 720 allocation->size));
861 721
862 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 722 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
863 return_ACPI_STATUS (status); 723 return_ACPI_STATUS(status);
864} 724}
865 725
866
867/******************************************************************************* 726/*******************************************************************************
868 * 727 *
869 * FUNCTION: acpi_ut_dump_allocation_info 728 * FUNCTION: acpi_ut_dump_allocation_info
@@ -877,15 +736,13 @@ acpi_ut_remove_allocation (
877 ******************************************************************************/ 736 ******************************************************************************/
878 737
879#ifdef ACPI_FUTURE_USAGE 738#ifdef ACPI_FUTURE_USAGE
880void 739void acpi_ut_dump_allocation_info(void)
881acpi_ut_dump_allocation_info (
882 void)
883{ 740{
884/* 741/*
885 struct acpi_memory_list *mem_list; 742 struct acpi_memory_list *mem_list;
886*/ 743*/
887 744
888 ACPI_FUNCTION_TRACE ("ut_dump_allocation_info"); 745 ACPI_FUNCTION_TRACE("ut_dump_allocation_info");
889 746
890/* 747/*
891 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 748 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@@ -898,7 +755,6 @@ acpi_ut_dump_allocation_info (
898 mem_list->max_concurrent_count, 755 mem_list->max_concurrent_count,
899 ROUND_UP_TO_1K (mem_list->max_concurrent_size))); 756 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
900 757
901
902 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 758 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
903 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", 759 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
904 running_object_count, 760 running_object_count,
@@ -909,7 +765,6 @@ acpi_ut_dump_allocation_info (
909 running_alloc_count, 765 running_alloc_count,
910 ROUND_UP_TO_1K (running_alloc_size))); 766 ROUND_UP_TO_1K (running_alloc_size)));
911 767
912
913 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 768 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
914 ("%30s: %4d (%3d Kb)\n", "Current Nodes", 769 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
915 acpi_gbl_current_node_count, 770 acpi_gbl_current_node_count,
@@ -923,8 +778,7 @@ acpi_ut_dump_allocation_info (
923*/ 778*/
924 return_VOID; 779 return_VOID;
925} 780}
926#endif /* ACPI_FUTURE_USAGE */ 781#endif /* ACPI_FUTURE_USAGE */
927
928 782
929/******************************************************************************* 783/*******************************************************************************
930 * 784 *
@@ -939,84 +793,87 @@ acpi_ut_dump_allocation_info (
939 * 793 *
940 ******************************************************************************/ 794 ******************************************************************************/
941 795
942void 796void acpi_ut_dump_allocations(u32 component, char *module)
943acpi_ut_dump_allocations (
944 u32 component,
945 char *module)
946{ 797{
947 struct acpi_debug_mem_block *element; 798 struct acpi_debug_mem_block *element;
948 union acpi_descriptor *descriptor; 799 union acpi_descriptor *descriptor;
949 u32 num_outstanding = 0; 800 u32 num_outstanding = 0;
950
951
952 ACPI_FUNCTION_TRACE ("ut_dump_allocations");
953 801
802 ACPI_FUNCTION_TRACE("ut_dump_allocations");
954 803
955 /* 804 /*
956 * Walk the allocation list. 805 * Walk the allocation list.
957 */ 806 */
958 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) { 807 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
959 return; 808 return;
960 } 809 }
961 810
962 element = acpi_gbl_memory_lists[0].list_head; 811 element = acpi_gbl_global_list->list_head;
963 while (element) { 812 while (element) {
964 if ((element->component & component) && 813 if ((element->component & component) &&
965 ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { 814 ((module == NULL)
815 || (0 == ACPI_STRCMP(module, element->module)))) {
966 /* Ignore allocated objects that are in a cache */ 816 /* Ignore allocated objects that are in a cache */
967 817
968 descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); 818 descriptor =
819 ACPI_CAST_PTR(union acpi_descriptor,
820 &element->user_space);
969 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { 821 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
970 acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", 822 acpi_os_printf("%p Len %04X %9.9s-%d [%s] ",
971 descriptor, element->size, element->module, 823 descriptor, element->size,
972 element->line, acpi_ut_get_descriptor_name (descriptor)); 824 element->module, element->line,
825 acpi_ut_get_descriptor_name
826 (descriptor));
973 827
974 /* Most of the elements will be Operand objects. */ 828 /* Most of the elements will be Operand objects. */
975 829
976 switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { 830 switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) {
977 case ACPI_DESC_TYPE_OPERAND: 831 case ACPI_DESC_TYPE_OPERAND:
978 acpi_os_printf ("%12.12s R%hd", 832 acpi_os_printf("%12.12s R%hd",
979 acpi_ut_get_type_name (descriptor->object.common.type), 833 acpi_ut_get_type_name
980 descriptor->object.common.reference_count); 834 (descriptor->object.
835 common.type),
836 descriptor->object.
837 common.reference_count);
981 break; 838 break;
982 839
983 case ACPI_DESC_TYPE_PARSER: 840 case ACPI_DESC_TYPE_PARSER:
984 acpi_os_printf ("aml_opcode %04hX", 841 acpi_os_printf("aml_opcode %04hX",
985 descriptor->op.asl.aml_opcode); 842 descriptor->op.asl.
843 aml_opcode);
986 break; 844 break;
987 845
988 case ACPI_DESC_TYPE_NAMED: 846 case ACPI_DESC_TYPE_NAMED:
989 acpi_os_printf ("%4.4s", 847 acpi_os_printf("%4.4s",
990 acpi_ut_get_node_name (&descriptor->node)); 848 acpi_ut_get_node_name
849 (&descriptor->node));
991 break; 850 break;
992 851
993 default: 852 default:
994 break; 853 break;
995 } 854 }
996 855
997 acpi_os_printf ( "\n"); 856 acpi_os_printf("\n");
998 num_outstanding++; 857 num_outstanding++;
999 } 858 }
1000 } 859 }
1001 element = element->next; 860 element = element->next;
1002 } 861 }
1003 862
1004 (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY); 863 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
1005 864
1006 /* Print summary */ 865 /* Print summary */
1007 866
1008 if (!num_outstanding) { 867 if (!num_outstanding) {
1009 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1010 "No outstanding allocations.\n")); 869 "No outstanding allocations.\n"));
1011 } 870 } else {
1012 else { 871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1013 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 872 "%d(%X) Outstanding allocations\n",
1014 "%d(%X) Outstanding allocations\n", 873 num_outstanding, num_outstanding));
1015 num_outstanding, num_outstanding));
1016 } 874 }
1017 875
1018 return_VOID; 876 return_VOID;
1019} 877}
1020 878
1021#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ 879#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
1022
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
new file mode 100644
index 000000000000..93d48681d276
--- /dev/null
+++ b/drivers/acpi/utilities/utcache.c
@@ -0,0 +1,305 @@
1/******************************************************************************
2 *
3 * Module Name: utcache - local cache allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utcache")
48
49#ifdef ACPI_USE_LOCAL_CACHE
50/*******************************************************************************
51 *
52 * FUNCTION: acpi_os_create_cache
53 *
54 * PARAMETERS: cache_name - Ascii name for the cache
55 * object_size - Size of each cached object
56 * max_depth - Maximum depth of the cache (in objects)
57 * return_cache - Where the new cache object is returned
58 *
59 * RETURN: Status
60 *
61 * DESCRIPTION: Create a cache object
62 *
63 ******************************************************************************/
64acpi_status
65acpi_os_create_cache(char *cache_name,
66 u16 object_size,
67 u16 max_depth, struct acpi_memory_list **return_cache)
68{
69 struct acpi_memory_list *cache;
70
71 ACPI_FUNCTION_ENTRY();
72
73 if (!cache_name || !return_cache || (object_size < 16)) {
74 return (AE_BAD_PARAMETER);
75 }
76
77 /* Create the cache object */
78
79 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
80 if (!cache) {
81 return (AE_NO_MEMORY);
82 }
83
84 /* Populate the cache object and return it */
85
86 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
87 cache->link_offset = 8;
88 cache->list_name = cache_name;
89 cache->object_size = object_size;
90 cache->max_depth = max_depth;
91
92 *return_cache = cache;
93 return (AE_OK);
94}
95
96/*******************************************************************************
97 *
98 * FUNCTION: acpi_os_purge_cache
99 *
100 * PARAMETERS: Cache - Handle to cache object
101 *
102 * RETURN: Status
103 *
104 * DESCRIPTION: Free all objects within the requested cache.
105 *
106 ******************************************************************************/
107
108acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
109{
110 char *next;
111
112 ACPI_FUNCTION_ENTRY();
113
114 if (!cache) {
115 return (AE_BAD_PARAMETER);
116 }
117
118 /* Walk the list of objects in this cache */
119
120 while (cache->list_head) {
121 /* Delete and unlink one cached state object */
122
123 next = *(ACPI_CAST_INDIRECT_PTR(char,
124 &(((char *)cache->
125 list_head)[cache->
126 link_offset])));
127 ACPI_MEM_FREE(cache->list_head);
128
129 cache->list_head = next;
130 cache->current_depth--;
131 }
132
133 return (AE_OK);
134}
135
136/*******************************************************************************
137 *
138 * FUNCTION: acpi_os_delete_cache
139 *
140 * PARAMETERS: Cache - Handle to cache object
141 *
142 * RETURN: Status
143 *
144 * DESCRIPTION: Free all objects within the requested cache and delete the
145 * cache object.
146 *
147 ******************************************************************************/
148
149acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
150{
151 acpi_status status;
152
153 ACPI_FUNCTION_ENTRY();
154
155 /* Purge all objects in the cache */
156
157 status = acpi_os_purge_cache(cache);
158 if (ACPI_FAILURE(status)) {
159 return (status);
160 }
161
162 /* Now we can delete the cache object */
163
164 acpi_os_free(cache);
165 return (AE_OK);
166}
167
168/*******************************************************************************
169 *
170 * FUNCTION: acpi_os_release_object
171 *
172 * PARAMETERS: Cache - Handle to cache object
173 * Object - The object to be released
174 *
175 * RETURN: None
176 *
177 * DESCRIPTION: Release an object to the specified cache. If cache is full,
178 * the object is deleted.
179 *
180 ******************************************************************************/
181
182acpi_status
183acpi_os_release_object(struct acpi_memory_list * cache, void *object)
184{
185 acpi_status status;
186
187 ACPI_FUNCTION_ENTRY();
188
189 if (!cache || !object) {
190 return (AE_BAD_PARAMETER);
191 }
192
193 /* If cache is full, just free this object */
194
195 if (cache->current_depth >= cache->max_depth) {
196 ACPI_MEM_FREE(object);
197 ACPI_MEM_TRACKING(cache->total_freed++);
198 }
199
200 /* Otherwise put this object back into the cache */
201
202 else {
203 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
204 if (ACPI_FAILURE(status)) {
205 return (status);
206 }
207
208 /* Mark the object as cached */
209
210 ACPI_MEMSET(object, 0xCA, cache->object_size);
211 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
212
213 /* Put the object at the head of the cache list */
214
215 *(ACPI_CAST_INDIRECT_PTR(char,
216 &(((char *)object)[cache->
217 link_offset]))) =
218 cache->list_head;
219 cache->list_head = object;
220 cache->current_depth++;
221
222 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
223 }
224
225 return (AE_OK);
226}
227
228/*******************************************************************************
229 *
230 * FUNCTION: acpi_os_acquire_object
231 *
232 * PARAMETERS: Cache - Handle to cache object
233 *
234 * RETURN: the acquired object. NULL on error
235 *
236 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
237 * the object is allocated.
238 *
239 ******************************************************************************/
240
241void *acpi_os_acquire_object(struct acpi_memory_list *cache)
242{
243 acpi_status status;
244 void *object;
245
246 ACPI_FUNCTION_NAME("os_acquire_object");
247
248 if (!cache) {
249 return (NULL);
250 }
251
252 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
253 if (ACPI_FAILURE(status)) {
254 return (NULL);
255 }
256
257 ACPI_MEM_TRACKING(cache->requests++);
258
259 /* Check the cache first */
260
261 if (cache->list_head) {
262 /* There is an object available, use it */
263
264 object = cache->list_head;
265 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
266 &(((char *)
267 object)[cache->
268 link_offset])));
269
270 cache->current_depth--;
271
272 ACPI_MEM_TRACKING(cache->hits++);
273 ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
274 "Object %p from %s cache\n",
275 object, cache->list_name)));
276
277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
278 if (ACPI_FAILURE(status)) {
279 return (NULL);
280 }
281
282 /* Clear (zero) the previously used Object */
283
284 ACPI_MEMSET(object, 0, cache->object_size);
285 } else {
286 /* The cache is empty, create a new object */
287
288 ACPI_MEM_TRACKING(cache->total_allocated++);
289
290 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
291
292 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
293 if (ACPI_FAILURE(status)) {
294 return (NULL);
295 }
296
297 object = ACPI_MEM_CALLOCATE(cache->object_size);
298 if (!object) {
299 return (NULL);
300 }
301 }
302
303 return (object);
304}
305#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 11e884957162..5442b32de611 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -41,59 +41,46 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47 46
48
49#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy") 48ACPI_MODULE_NAME("utcopy")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_ut_copy_isimple_to_esimple ( 52acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
56 union acpi_operand_object *internal_object, 53 union acpi_object *external_object,
57 union acpi_object *external_object, 54 u8 * data_space, acpi_size * buffer_space_used);
58 u8 *data_space,
59 acpi_size *buffer_space_used);
60 55
61static acpi_status 56static acpi_status
62acpi_ut_copy_ielement_to_ielement ( 57acpi_ut_copy_ielement_to_ielement(u8 object_type,
63 u8 object_type, 58 union acpi_operand_object *source_object,
64 union acpi_operand_object *source_object, 59 union acpi_generic_state *state,
65 union acpi_generic_state *state, 60 void *context);
66 void *context);
67 61
68static acpi_status 62static acpi_status
69acpi_ut_copy_ipackage_to_epackage ( 63acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
70 union acpi_operand_object *internal_object, 64 u8 * buffer, acpi_size * space_used);
71 u8 *buffer,
72 acpi_size *space_used);
73 65
74static acpi_status 66static acpi_status
75acpi_ut_copy_esimple_to_isimple( 67acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
76 union acpi_object *user_obj, 68 union acpi_operand_object **return_obj);
77 union acpi_operand_object **return_obj);
78 69
79static acpi_status 70static acpi_status
80acpi_ut_copy_simple_object ( 71acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
81 union acpi_operand_object *source_desc, 72 union acpi_operand_object *dest_desc);
82 union acpi_operand_object *dest_desc);
83 73
84static acpi_status 74static acpi_status
85acpi_ut_copy_ielement_to_eelement ( 75acpi_ut_copy_ielement_to_eelement(u8 object_type,
86 u8 object_type, 76 union acpi_operand_object *source_object,
87 union acpi_operand_object *source_object, 77 union acpi_generic_state *state,
88 union acpi_generic_state *state, 78 void *context);
89 void *context);
90 79
91static acpi_status 80static acpi_status
92acpi_ut_copy_ipackage_to_ipackage ( 81acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
93 union acpi_operand_object *source_obj, 82 union acpi_operand_object *dest_obj,
94 union acpi_operand_object *dest_obj, 83 struct acpi_walk_state *walk_state);
95 struct acpi_walk_state *walk_state);
96
97 84
98/******************************************************************************* 85/*******************************************************************************
99 * 86 *
@@ -116,17 +103,13 @@ acpi_ut_copy_ipackage_to_ipackage (
116 ******************************************************************************/ 103 ******************************************************************************/
117 104
118static acpi_status 105static acpi_status
119acpi_ut_copy_isimple_to_esimple ( 106acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
120 union acpi_operand_object *internal_object, 107 union acpi_object *external_object,
121 union acpi_object *external_object, 108 u8 * data_space, acpi_size * buffer_space_used)
122 u8 *data_space,
123 acpi_size *buffer_space_used)
124{ 109{
125 acpi_status status = AE_OK; 110 acpi_status status = AE_OK;
126
127
128 ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple");
129 111
112 ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple");
130 113
131 *buffer_space_used = 0; 114 *buffer_space_used = 0;
132 115
@@ -135,54 +118,54 @@ acpi_ut_copy_isimple_to_esimple (
135 * package element) 118 * package element)
136 */ 119 */
137 if (!internal_object) { 120 if (!internal_object) {
138 return_ACPI_STATUS (AE_OK); 121 return_ACPI_STATUS(AE_OK);
139 } 122 }
140 123
141 /* Always clear the external object */ 124 /* Always clear the external object */
142 125
143 ACPI_MEMSET (external_object, 0, sizeof (union acpi_object)); 126 ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
144 127
145 /* 128 /*
146 * In general, the external object will be the same type as 129 * In general, the external object will be the same type as
147 * the internal object 130 * the internal object
148 */ 131 */
149 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 132 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
150 133
151 /* However, only a limited number of external types are supported */ 134 /* However, only a limited number of external types are supported */
152 135
153 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 136 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
154 case ACPI_TYPE_STRING: 137 case ACPI_TYPE_STRING:
155 138
156 external_object->string.pointer = (char *) data_space; 139 external_object->string.pointer = (char *)data_space;
157 external_object->string.length = internal_object->string.length; 140 external_object->string.length = internal_object->string.length;
158 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 141 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
159 (acpi_size) internal_object->string.length + 1); 142 internal_object->
160 143 string.
161 ACPI_MEMCPY ((void *) data_space, 144 length + 1);
162 (void *) internal_object->string.pointer, 145
163 (acpi_size) internal_object->string.length + 1); 146 ACPI_MEMCPY((void *)data_space,
147 (void *)internal_object->string.pointer,
148 (acpi_size) internal_object->string.length + 1);
164 break; 149 break;
165 150
166
167 case ACPI_TYPE_BUFFER: 151 case ACPI_TYPE_BUFFER:
168 152
169 external_object->buffer.pointer = data_space; 153 external_object->buffer.pointer = data_space;
170 external_object->buffer.length = internal_object->buffer.length; 154 external_object->buffer.length = internal_object->buffer.length;
171 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 155 *buffer_space_used =
172 internal_object->string.length); 156 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
157 length);
173 158
174 ACPI_MEMCPY ((void *) data_space, 159 ACPI_MEMCPY((void *)data_space,
175 (void *) internal_object->buffer.pointer, 160 (void *)internal_object->buffer.pointer,
176 internal_object->buffer.length); 161 internal_object->buffer.length);
177 break; 162 break;
178 163
179
180 case ACPI_TYPE_INTEGER: 164 case ACPI_TYPE_INTEGER:
181 165
182 external_object->integer.value = internal_object->integer.value; 166 external_object->integer.value = internal_object->integer.value;
183 break; 167 break;
184 168
185
186 case ACPI_TYPE_LOCAL_REFERENCE: 169 case ACPI_TYPE_LOCAL_REFERENCE:
187 170
188 /* 171 /*
@@ -199,41 +182,41 @@ acpi_ut_copy_isimple_to_esimple (
199 * to object containing a handle to an ACPI named object. 182 * to object containing a handle to an ACPI named object.
200 */ 183 */
201 external_object->type = ACPI_TYPE_ANY; 184 external_object->type = ACPI_TYPE_ANY;
202 external_object->reference.handle = internal_object->reference.node; 185 external_object->reference.handle =
186 internal_object->reference.node;
203 break; 187 break;
204 } 188 }
205 break; 189 break;
206 190
207
208 case ACPI_TYPE_PROCESSOR: 191 case ACPI_TYPE_PROCESSOR:
209 192
210 external_object->processor.proc_id = internal_object->processor.proc_id; 193 external_object->processor.proc_id =
211 external_object->processor.pblk_address = internal_object->processor.address; 194 internal_object->processor.proc_id;
212 external_object->processor.pblk_length = internal_object->processor.length; 195 external_object->processor.pblk_address =
196 internal_object->processor.address;
197 external_object->processor.pblk_length =
198 internal_object->processor.length;
213 break; 199 break;
214 200
215
216 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
217 202
218 external_object->power_resource.system_level = 203 external_object->power_resource.system_level =
219 internal_object->power_resource.system_level; 204 internal_object->power_resource.system_level;
220 205
221 external_object->power_resource.resource_order = 206 external_object->power_resource.resource_order =
222 internal_object->power_resource.resource_order; 207 internal_object->power_resource.resource_order;
223 break; 208 break;
224 209
225
226 default: 210 default:
227 /* 211 /*
228 * There is no corresponding external object type 212 * There is no corresponding external object type
229 */ 213 */
230 return_ACPI_STATUS (AE_SUPPORT); 214 return_ACPI_STATUS(AE_SUPPORT);
231 } 215 }
232 216
233 return_ACPI_STATUS (status); 217 return_ACPI_STATUS(status);
234} 218}
235 219
236
237/******************************************************************************* 220/*******************************************************************************
238 * 221 *
239 * FUNCTION: acpi_ut_copy_ielement_to_eelement 222 * FUNCTION: acpi_ut_copy_ielement_to_eelement
@@ -247,25 +230,23 @@ acpi_ut_copy_isimple_to_esimple (
247 ******************************************************************************/ 230 ******************************************************************************/
248 231
249static acpi_status 232static acpi_status
250acpi_ut_copy_ielement_to_eelement ( 233acpi_ut_copy_ielement_to_eelement(u8 object_type,
251 u8 object_type, 234 union acpi_operand_object *source_object,
252 union acpi_operand_object *source_object, 235 union acpi_generic_state *state,
253 union acpi_generic_state *state, 236 void *context)
254 void *context)
255{ 237{
256 acpi_status status = AE_OK; 238 acpi_status status = AE_OK;
257 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 239 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
258 acpi_size object_space; 240 acpi_size object_space;
259 u32 this_index; 241 u32 this_index;
260 union acpi_object *target_object; 242 union acpi_object *target_object;
261 243
244 ACPI_FUNCTION_ENTRY();
262 245
263 ACPI_FUNCTION_ENTRY (); 246 this_index = state->pkg.index;
264
265
266 this_index = state->pkg.index;
267 target_object = (union acpi_object *) 247 target_object = (union acpi_object *)
268 &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; 248 &((union acpi_object *)(state->pkg.dest_object))->package.
249 elements[this_index];
269 250
270 switch (object_type) { 251 switch (object_type) {
271 case ACPI_COPY_TYPE_SIMPLE: 252 case ACPI_COPY_TYPE_SIMPLE:
@@ -273,23 +254,24 @@ acpi_ut_copy_ielement_to_eelement (
273 /* 254 /*
274 * This is a simple or null object 255 * This is a simple or null object
275 */ 256 */
276 status = acpi_ut_copy_isimple_to_esimple (source_object, 257 status = acpi_ut_copy_isimple_to_esimple(source_object,
277 target_object, info->free_space, &object_space); 258 target_object,
278 if (ACPI_FAILURE (status)) { 259 info->free_space,
260 &object_space);
261 if (ACPI_FAILURE(status)) {
279 return (status); 262 return (status);
280 } 263 }
281 break; 264 break;
282 265
283
284 case ACPI_COPY_TYPE_PACKAGE: 266 case ACPI_COPY_TYPE_PACKAGE:
285 267
286 /* 268 /*
287 * Build the package object 269 * Build the package object
288 */ 270 */
289 target_object->type = ACPI_TYPE_PACKAGE; 271 target_object->type = ACPI_TYPE_PACKAGE;
290 target_object->package.count = source_object->package.count; 272 target_object->package.count = source_object->package.count;
291 target_object->package.elements = 273 target_object->package.elements =
292 ACPI_CAST_PTR (union acpi_object, info->free_space); 274 ACPI_CAST_PTR(union acpi_object, info->free_space);
293 275
294 /* 276 /*
295 * Pass the new package object back to the package walk routine 277 * Pass the new package object back to the package walk routine
@@ -300,22 +282,22 @@ acpi_ut_copy_ielement_to_eelement (
300 * Save space for the array of objects (Package elements) 282 * Save space for the array of objects (Package elements)
301 * update the buffer length counter 283 * update the buffer length counter
302 */ 284 */
303 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( 285 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
304 (acpi_size) target_object->package.count * 286 target_object->
305 sizeof (union acpi_object)); 287 package.count *
288 sizeof(union
289 acpi_object));
306 break; 290 break;
307 291
308
309 default: 292 default:
310 return (AE_BAD_PARAMETER); 293 return (AE_BAD_PARAMETER);
311 } 294 }
312 295
313 info->free_space += object_space; 296 info->free_space += object_space;
314 info->length += object_space; 297 info->length += object_space;
315 return (status); 298 return (status);
316} 299}
317 300
318
319/******************************************************************************* 301/*******************************************************************************
320 * 302 *
321 * FUNCTION: acpi_ut_copy_ipackage_to_epackage 303 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
@@ -336,55 +318,51 @@ acpi_ut_copy_ielement_to_eelement (
336 ******************************************************************************/ 318 ******************************************************************************/
337 319
338static acpi_status 320static acpi_status
339acpi_ut_copy_ipackage_to_epackage ( 321acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
340 union acpi_operand_object *internal_object, 322 u8 * buffer, acpi_size * space_used)
341 u8 *buffer,
342 acpi_size *space_used)
343{ 323{
344 union acpi_object *external_object; 324 union acpi_object *external_object;
345 acpi_status status; 325 acpi_status status;
346 struct acpi_pkg_info info; 326 struct acpi_pkg_info info;
347
348
349 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");
350 327
328 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage");
351 329
352 /* 330 /*
353 * First package at head of the buffer 331 * First package at head of the buffer
354 */ 332 */
355 external_object = ACPI_CAST_PTR (union acpi_object, buffer); 333 external_object = ACPI_CAST_PTR(union acpi_object, buffer);
356 334
357 /* 335 /*
358 * Free space begins right after the first package 336 * Free space begins right after the first package
359 */ 337 */
360 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 338 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
361 info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( 339 info.free_space =
362 sizeof (union acpi_object)); 340 buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
363 info.object_space = 0; 341 info.object_space = 0;
364 info.num_packages = 1; 342 info.num_packages = 1;
365 343
366 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 344 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
367 external_object->package.count = internal_object->package.count; 345 external_object->package.count = internal_object->package.count;
368 external_object->package.elements = ACPI_CAST_PTR (union acpi_object, 346 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
369 info.free_space); 347 info.free_space);
370 348
371 /* 349 /*
372 * Leave room for an array of ACPI_OBJECTS in the buffer 350 * Leave room for an array of ACPI_OBJECTS in the buffer
373 * and move the free space past it 351 * and move the free space past it
374 */ 352 */
375 info.length += (acpi_size) external_object->package.count * 353 info.length += (acpi_size) external_object->package.count *
376 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 354 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
377 info.free_space += external_object->package.count * 355 info.free_space += external_object->package.count *
378 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 356 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
379 357
380 status = acpi_ut_walk_package_tree (internal_object, external_object, 358 status = acpi_ut_walk_package_tree(internal_object, external_object,
381 acpi_ut_copy_ielement_to_eelement, &info); 359 acpi_ut_copy_ielement_to_eelement,
360 &info);
382 361
383 *space_used = info.length; 362 *space_used = info.length;
384 return_ACPI_STATUS (status); 363 return_ACPI_STATUS(status);
385} 364}
386 365
387
388/******************************************************************************* 366/*******************************************************************************
389 * 367 *
390 * FUNCTION: acpi_ut_copy_iobject_to_eobject 368 * FUNCTION: acpi_ut_copy_iobject_to_eobject
@@ -400,44 +378,45 @@ acpi_ut_copy_ipackage_to_epackage (
400 ******************************************************************************/ 378 ******************************************************************************/
401 379
402acpi_status 380acpi_status
403acpi_ut_copy_iobject_to_eobject ( 381acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
404 union acpi_operand_object *internal_object, 382 struct acpi_buffer *ret_buffer)
405 struct acpi_buffer *ret_buffer)
406{ 383{
407 acpi_status status; 384 acpi_status status;
408 385
386 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject");
409 387
410 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject"); 388 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
411
412
413 if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) {
414 /* 389 /*
415 * Package object: Copy all subobjects (including 390 * Package object: Copy all subobjects (including
416 * nested packages) 391 * nested packages)
417 */ 392 */
418 status = acpi_ut_copy_ipackage_to_epackage (internal_object, 393 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
419 ret_buffer->pointer, &ret_buffer->length); 394 ret_buffer->pointer,
420 } 395 &ret_buffer->length);
421 else { 396 } else {
422 /* 397 /*
423 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
424 */ 399 */
425 status = acpi_ut_copy_isimple_to_esimple (internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
426 (union acpi_object *) ret_buffer->pointer, 401 (union acpi_object *)
427 ((u8 *) ret_buffer->pointer + 402 ret_buffer->pointer,
428 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), 403 ((u8 *) ret_buffer->
429 &ret_buffer->length); 404 pointer +
405 ACPI_ROUND_UP_TO_NATIVE_WORD
406 (sizeof
407 (union
408 acpi_object))),
409 &ret_buffer->length);
430 /* 410 /*
431 * build simple does not include the object size in the length 411 * build simple does not include the object size in the length
432 * so we add it in here 412 * so we add it in here
433 */ 413 */
434 ret_buffer->length += sizeof (union acpi_object); 414 ret_buffer->length += sizeof(union acpi_object);
435 } 415 }
436 416
437 return_ACPI_STATUS (status); 417 return_ACPI_STATUS(status);
438} 418}
439 419
440
441/******************************************************************************* 420/*******************************************************************************
442 * 421 *
443 * FUNCTION: acpi_ut_copy_esimple_to_isimple 422 * FUNCTION: acpi_ut_copy_esimple_to_isimple
@@ -455,15 +434,12 @@ acpi_ut_copy_iobject_to_eobject (
455 ******************************************************************************/ 434 ******************************************************************************/
456 435
457static acpi_status 436static acpi_status
458acpi_ut_copy_esimple_to_isimple ( 437acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
459 union acpi_object *external_object, 438 union acpi_operand_object **ret_internal_object)
460 union acpi_operand_object **ret_internal_object)
461{ 439{
462 union acpi_operand_object *internal_object; 440 union acpi_operand_object *internal_object;
463
464
465 ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple");
466 441
442 ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple");
467 443
468 /* 444 /*
469 * Simple types supported are: String, Buffer, Integer 445 * Simple types supported are: String, Buffer, Integer
@@ -473,58 +449,57 @@ acpi_ut_copy_esimple_to_isimple (
473 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
474 case ACPI_TYPE_INTEGER: 450 case ACPI_TYPE_INTEGER:
475 451
476 internal_object = acpi_ut_create_internal_object ( 452 internal_object = acpi_ut_create_internal_object((u8)
477 (u8) external_object->type); 453 external_object->
454 type);
478 if (!internal_object) { 455 if (!internal_object) {
479 return_ACPI_STATUS (AE_NO_MEMORY); 456 return_ACPI_STATUS(AE_NO_MEMORY);
480 } 457 }
481 break; 458 break;
482 459
483 default: 460 default:
484 /* All other types are not supported */ 461 /* All other types are not supported */
485 462
486 return_ACPI_STATUS (AE_SUPPORT); 463 return_ACPI_STATUS(AE_SUPPORT);
487 } 464 }
488 465
489
490 /* Must COPY string and buffer contents */ 466 /* Must COPY string and buffer contents */
491 467
492 switch (external_object->type) { 468 switch (external_object->type) {
493 case ACPI_TYPE_STRING: 469 case ACPI_TYPE_STRING:
494 470
495 internal_object->string.pointer = 471 internal_object->string.pointer =
496 ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); 472 ACPI_MEM_CALLOCATE((acpi_size) external_object->string.
473 length + 1);
497 if (!internal_object->string.pointer) { 474 if (!internal_object->string.pointer) {
498 goto error_exit; 475 goto error_exit;
499 } 476 }
500 477
501 ACPI_MEMCPY (internal_object->string.pointer, 478 ACPI_MEMCPY(internal_object->string.pointer,
502 external_object->string.pointer, 479 external_object->string.pointer,
503 external_object->string.length); 480 external_object->string.length);
504 481
505 internal_object->string.length = external_object->string.length; 482 internal_object->string.length = external_object->string.length;
506 break; 483 break;
507 484
508
509 case ACPI_TYPE_BUFFER: 485 case ACPI_TYPE_BUFFER:
510 486
511 internal_object->buffer.pointer = 487 internal_object->buffer.pointer =
512 ACPI_MEM_CALLOCATE (external_object->buffer.length); 488 ACPI_MEM_CALLOCATE(external_object->buffer.length);
513 if (!internal_object->buffer.pointer) { 489 if (!internal_object->buffer.pointer) {
514 goto error_exit; 490 goto error_exit;
515 } 491 }
516 492
517 ACPI_MEMCPY (internal_object->buffer.pointer, 493 ACPI_MEMCPY(internal_object->buffer.pointer,
518 external_object->buffer.pointer, 494 external_object->buffer.pointer,
519 external_object->buffer.length); 495 external_object->buffer.length);
520 496
521 internal_object->buffer.length = external_object->buffer.length; 497 internal_object->buffer.length = external_object->buffer.length;
522 break; 498 break;
523 499
524
525 case ACPI_TYPE_INTEGER: 500 case ACPI_TYPE_INTEGER:
526 501
527 internal_object->integer.value = external_object->integer.value; 502 internal_object->integer.value = external_object->integer.value;
528 break; 503 break;
529 504
530 default: 505 default:
@@ -533,15 +508,13 @@ acpi_ut_copy_esimple_to_isimple (
533 } 508 }
534 509
535 *ret_internal_object = internal_object; 510 *ret_internal_object = internal_object;
536 return_ACPI_STATUS (AE_OK); 511 return_ACPI_STATUS(AE_OK);
537
538 512
539error_exit: 513 error_exit:
540 acpi_ut_remove_reference (internal_object); 514 acpi_ut_remove_reference(internal_object);
541 return_ACPI_STATUS (AE_NO_MEMORY); 515 return_ACPI_STATUS(AE_NO_MEMORY);
542} 516}
543 517
544
545#ifdef ACPI_FUTURE_IMPLEMENTATION 518#ifdef ACPI_FUTURE_IMPLEMENTATION
546/* Code to convert packages that are parameters to control methods */ 519/* Code to convert packages that are parameters to control methods */
547 520
@@ -565,22 +538,18 @@ error_exit:
565 ******************************************************************************/ 538 ******************************************************************************/
566 539
567static acpi_status 540static acpi_status
568acpi_ut_copy_epackage_to_ipackage ( 541acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object,
569 union acpi_operand_object *internal_object, 542 u8 * buffer, u32 * space_used)
570 u8 *buffer,
571 u32 *space_used)
572{ 543{
573 u8 *free_space; 544 u8 *free_space;
574 union acpi_object *external_object; 545 union acpi_object *external_object;
575 u32 length = 0; 546 u32 length = 0;
576 u32 this_index; 547 u32 this_index;
577 u32 object_space = 0; 548 u32 object_space = 0;
578 union acpi_operand_object *this_internal_obj; 549 union acpi_operand_object *this_internal_obj;
579 union acpi_object *this_external_obj; 550 union acpi_object *this_external_obj;
580
581
582 ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage");
583 551
552 ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage");
584 553
585 /* 554 /*
586 * First package at head of the buffer 555 * First package at head of the buffer
@@ -592,24 +561,22 @@ acpi_ut_copy_epackage_to_ipackage (
592 */ 561 */
593 free_space = buffer + sizeof(union acpi_object); 562 free_space = buffer + sizeof(union acpi_object);
594 563
595 564 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
596 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 565 external_object->package.count = internal_object->package.count;
597 external_object->package.count = internal_object->package.count; 566 external_object->package.elements = (union acpi_object *)free_space;
598 external_object->package.elements = (union acpi_object *)free_space;
599 567
600 /* 568 /*
601 * Build an array of ACPI_OBJECTS in the buffer 569 * Build an array of ACPI_OBJECTS in the buffer
602 * and move the free space past it 570 * and move the free space past it
603 */ 571 */
604 free_space += external_object->package.count * sizeof(union acpi_object); 572 free_space +=
605 573 external_object->package.count * sizeof(union acpi_object);
606 574
607 /* Call walk_package */ 575 /* Call walk_package */
608 576
609} 577}
610 578
611#endif /* Future implementation */ 579#endif /* Future implementation */
612
613 580
614/******************************************************************************* 581/*******************************************************************************
615 * 582 *
@@ -625,37 +592,35 @@ acpi_ut_copy_epackage_to_ipackage (
625 ******************************************************************************/ 592 ******************************************************************************/
626 593
627acpi_status 594acpi_status
628acpi_ut_copy_eobject_to_iobject ( 595acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
629 union acpi_object *external_object, 596 union acpi_operand_object **internal_object)
630 union acpi_operand_object **internal_object)
631{ 597{
632 acpi_status status; 598 acpi_status status;
633
634
635 ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject");
636 599
600 ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject");
637 601
638 if (external_object->type == ACPI_TYPE_PACKAGE) { 602 if (external_object->type == ACPI_TYPE_PACKAGE) {
639 /* 603 /*
640 * Packages as external input to control methods are not supported, 604 * Packages as external input to control methods are not supported,
641 */ 605 */
642 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 606 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "Packages as parameters not implemented!\n")); 607 "Packages as parameters not implemented!\n"));
644 608
645 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 609 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
646 } 610 }
647 611
648 else { 612 else {
649 /* 613 /*
650 * Build a simple object (no nested objects) 614 * Build a simple object (no nested objects)
651 */ 615 */
652 status = acpi_ut_copy_esimple_to_isimple (external_object, internal_object); 616 status =
617 acpi_ut_copy_esimple_to_isimple(external_object,
618 internal_object);
653 } 619 }
654 620
655 return_ACPI_STATUS (status); 621 return_ACPI_STATUS(status);
656} 622}
657 623
658
659/******************************************************************************* 624/*******************************************************************************
660 * 625 *
661 * FUNCTION: acpi_ut_copy_simple_object 626 * FUNCTION: acpi_ut_copy_simple_object
@@ -671,83 +636,75 @@ acpi_ut_copy_eobject_to_iobject (
671 ******************************************************************************/ 636 ******************************************************************************/
672 637
673static acpi_status 638static acpi_status
674acpi_ut_copy_simple_object ( 639acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
675 union acpi_operand_object *source_desc, 640 union acpi_operand_object *dest_desc)
676 union acpi_operand_object *dest_desc)
677{ 641{
678 u16 reference_count; 642 u16 reference_count;
679 union acpi_operand_object *next_object; 643 union acpi_operand_object *next_object;
680
681 644
682 /* Save fields from destination that we don't want to overwrite */ 645 /* Save fields from destination that we don't want to overwrite */
683 646
684 reference_count = dest_desc->common.reference_count; 647 reference_count = dest_desc->common.reference_count;
685 next_object = dest_desc->common.next_object; 648 next_object = dest_desc->common.next_object;
686 649
687 /* Copy the entire source object over the destination object*/ 650 /* Copy the entire source object over the destination object */
688 651
689 ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, 652 ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
690 sizeof (union acpi_operand_object)); 653 sizeof(union acpi_operand_object));
691 654
692 /* Restore the saved fields */ 655 /* Restore the saved fields */
693 656
694 dest_desc->common.reference_count = reference_count; 657 dest_desc->common.reference_count = reference_count;
695 dest_desc->common.next_object = next_object; 658 dest_desc->common.next_object = next_object;
696 659
697 /* Handle the objects with extra data */ 660 /* New object is not static, regardless of source */
698 661
699 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 662 dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
700 case ACPI_TYPE_BUFFER:
701 663
702 dest_desc->buffer.node = NULL; 664 /* Handle the objects with extra data */
703 dest_desc->common.flags = source_desc->common.flags;
704 665
666 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
667 case ACPI_TYPE_BUFFER:
705 /* 668 /*
706 * Allocate and copy the actual buffer if and only if: 669 * Allocate and copy the actual buffer if and only if:
707 * 1) There is a valid buffer pointer 670 * 1) There is a valid buffer pointer
708 * 2) The buffer is not static (not in an ACPI table) (in this case, 671 * 2) The buffer has a length > 0
709 * the actual pointer was already copied above)
710 */ 672 */
711 if ((source_desc->buffer.pointer) && 673 if ((source_desc->buffer.pointer) &&
712 (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { 674 (source_desc->buffer.length)) {
713 dest_desc->buffer.pointer = NULL; 675 dest_desc->buffer.pointer =
714 676 ACPI_MEM_ALLOCATE(source_desc->buffer.length);
715 /* Create an actual buffer only if length > 0 */ 677 if (!dest_desc->buffer.pointer) {
716 678 return (AE_NO_MEMORY);
717 if (source_desc->buffer.length) { 679 }
718 dest_desc->buffer.pointer =
719 ACPI_MEM_ALLOCATE (source_desc->buffer.length);
720 if (!dest_desc->buffer.pointer) {
721 return (AE_NO_MEMORY);
722 }
723 680
724 /* Copy the actual buffer data */ 681 /* Copy the actual buffer data */
725 682
726 ACPI_MEMCPY (dest_desc->buffer.pointer, 683 ACPI_MEMCPY(dest_desc->buffer.pointer,
727 source_desc->buffer.pointer, 684 source_desc->buffer.pointer,
728 source_desc->buffer.length); 685 source_desc->buffer.length);
729 }
730 } 686 }
731 break; 687 break;
732 688
733 case ACPI_TYPE_STRING: 689 case ACPI_TYPE_STRING:
734
735 /* 690 /*
736 * Allocate and copy the actual string if and only if: 691 * Allocate and copy the actual string if and only if:
737 * 1) There is a valid string pointer 692 * 1) There is a valid string pointer
738 * 2) The string is not static (not in an ACPI table) (in this case, 693 * (Pointer to a NULL string is allowed)
739 * the actual pointer was already copied above)
740 */ 694 */
741 if ((source_desc->string.pointer) && 695 if (source_desc->string.pointer) {
742 (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
743 dest_desc->string.pointer = 696 dest_desc->string.pointer =
744 ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); 697 ACPI_MEM_ALLOCATE((acpi_size) source_desc->string.
698 length + 1);
745 if (!dest_desc->string.pointer) { 699 if (!dest_desc->string.pointer) {
746 return (AE_NO_MEMORY); 700 return (AE_NO_MEMORY);
747 } 701 }
748 702
749 ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, 703 /* Copy the actual string data */
750 (acpi_size) source_desc->string.length + 1); 704
705 ACPI_MEMCPY(dest_desc->string.pointer,
706 source_desc->string.pointer,
707 (acpi_size) source_desc->string.length + 1);
751 } 708 }
752 break; 709 break;
753 710
@@ -756,7 +713,7 @@ acpi_ut_copy_simple_object (
756 * We copied the reference object, so we now must add a reference 713 * We copied the reference object, so we now must add a reference
757 * to the object pointed to by the reference 714 * to the object pointed to by the reference
758 */ 715 */
759 acpi_ut_add_reference (source_desc->reference.object); 716 acpi_ut_add_reference(source_desc->reference.object);
760 break; 717 break;
761 718
762 default: 719 default:
@@ -767,7 +724,6 @@ acpi_ut_copy_simple_object (
767 return (AE_OK); 724 return (AE_OK);
768} 725}
769 726
770
771/******************************************************************************* 727/*******************************************************************************
772 * 728 *
773 * FUNCTION: acpi_ut_copy_ielement_to_ielement 729 * FUNCTION: acpi_ut_copy_ielement_to_ielement
@@ -781,24 +737,21 @@ acpi_ut_copy_simple_object (
781 ******************************************************************************/ 737 ******************************************************************************/
782 738
783static acpi_status 739static acpi_status
784acpi_ut_copy_ielement_to_ielement ( 740acpi_ut_copy_ielement_to_ielement(u8 object_type,
785 u8 object_type, 741 union acpi_operand_object *source_object,
786 union acpi_operand_object *source_object, 742 union acpi_generic_state *state,
787 union acpi_generic_state *state, 743 void *context)
788 void *context)
789{ 744{
790 acpi_status status = AE_OK; 745 acpi_status status = AE_OK;
791 u32 this_index; 746 u32 this_index;
792 union acpi_operand_object **this_target_ptr; 747 union acpi_operand_object **this_target_ptr;
793 union acpi_operand_object *target_object; 748 union acpi_operand_object *target_object;
794
795 749
796 ACPI_FUNCTION_ENTRY (); 750 ACPI_FUNCTION_ENTRY();
797 751
798 752 this_index = state->pkg.index;
799 this_index = state->pkg.index;
800 this_target_ptr = (union acpi_operand_object **) 753 this_target_ptr = (union acpi_operand_object **)
801 &state->pkg.dest_object->package.elements[this_index]; 754 &state->pkg.dest_object->package.elements[this_index];
802 755
803 switch (object_type) { 756 switch (object_type) {
804 case ACPI_COPY_TYPE_SIMPLE: 757 case ACPI_COPY_TYPE_SIMPLE:
@@ -809,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement (
809 /* 762 /*
810 * This is a simple object, just copy it 763 * This is a simple object, just copy it
811 */ 764 */
812 target_object = acpi_ut_create_internal_object ( 765 target_object =
813 ACPI_GET_OBJECT_TYPE (source_object)); 766 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
767 (source_object));
814 if (!target_object) { 768 if (!target_object) {
815 return (AE_NO_MEMORY); 769 return (AE_NO_MEMORY);
816 } 770 }
817 771
818 status = acpi_ut_copy_simple_object (source_object, target_object); 772 status =
819 if (ACPI_FAILURE (status)) { 773 acpi_ut_copy_simple_object(source_object,
774 target_object);
775 if (ACPI_FAILURE(status)) {
820 goto error_exit; 776 goto error_exit;
821 } 777 }
822 778
823 *this_target_ptr = target_object; 779 *this_target_ptr = target_object;
824 } 780 } else {
825 else {
826 /* Pass through a null element */ 781 /* Pass through a null element */
827 782
828 *this_target_ptr = NULL; 783 *this_target_ptr = NULL;
829 } 784 }
830 break; 785 break;
831 786
832
833 case ACPI_COPY_TYPE_PACKAGE: 787 case ACPI_COPY_TYPE_PACKAGE:
834 788
835 /* 789 /*
836 * This object is a package - go down another nesting level 790 * This object is a package - go down another nesting level
837 * Create and build the package object 791 * Create and build the package object
838 */ 792 */
839 target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); 793 target_object =
794 acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
840 if (!target_object) { 795 if (!target_object) {
841 return (AE_NO_MEMORY); 796 return (AE_NO_MEMORY);
842 } 797 }
@@ -848,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement (
848 * Create the object array 803 * Create the object array
849 */ 804 */
850 target_object->package.elements = 805 target_object->package.elements =
851 ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * 806 ACPI_MEM_CALLOCATE(((acpi_size) source_object->package.
852 sizeof (void *)); 807 count + 1) * sizeof(void *));
853 if (!target_object->package.elements) { 808 if (!target_object->package.elements) {
854 status = AE_NO_MEMORY; 809 status = AE_NO_MEMORY;
855 goto error_exit; 810 goto error_exit;
@@ -866,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement (
866 *this_target_ptr = target_object; 821 *this_target_ptr = target_object;
867 break; 822 break;
868 823
869
870 default: 824 default:
871 return (AE_BAD_PARAMETER); 825 return (AE_BAD_PARAMETER);
872 } 826 }
873 827
874 return (status); 828 return (status);
875 829
876error_exit: 830 error_exit:
877 acpi_ut_remove_reference (target_object); 831 acpi_ut_remove_reference(target_object);
878 return (status); 832 return (status);
879} 833}
880 834
881
882/******************************************************************************* 835/*******************************************************************************
883 * 836 *
884 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 837 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
@@ -894,49 +847,46 @@ error_exit:
894 ******************************************************************************/ 847 ******************************************************************************/
895 848
896static acpi_status 849static acpi_status
897acpi_ut_copy_ipackage_to_ipackage ( 850acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
898 union acpi_operand_object *source_obj, 851 union acpi_operand_object *dest_obj,
899 union acpi_operand_object *dest_obj, 852 struct acpi_walk_state *walk_state)
900 struct acpi_walk_state *walk_state)
901{ 853{
902 acpi_status status = AE_OK; 854 acpi_status status = AE_OK;
903
904 855
905 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage"); 856 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage");
906 857
907 858 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
908 dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); 859 dest_obj->common.flags = source_obj->common.flags;
909 dest_obj->common.flags = source_obj->common.flags;
910 dest_obj->package.count = source_obj->package.count; 860 dest_obj->package.count = source_obj->package.count;
911 861
912 /* 862 /*
913 * Create the object array and walk the source package tree 863 * Create the object array and walk the source package tree
914 */ 864 */
915 dest_obj->package.elements = ACPI_MEM_CALLOCATE ( 865 dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size)
916 ((acpi_size) source_obj->package.count + 1) * 866 source_obj->package.
917 sizeof (void *)); 867 count +
868 1) * sizeof(void *));
918 if (!dest_obj->package.elements) { 869 if (!dest_obj->package.elements) {
919 ACPI_REPORT_ERROR ( 870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n"));
920 ("aml_build_copy_internal_package_object: Package allocation failure\n")); 871 return_ACPI_STATUS(AE_NO_MEMORY);
921 return_ACPI_STATUS (AE_NO_MEMORY);
922 } 872 }
923 873
924 /* 874 /*
925 * Copy the package element-by-element by walking the package "tree". 875 * Copy the package element-by-element by walking the package "tree".
926 * This handles nested packages of arbitrary depth. 876 * This handles nested packages of arbitrary depth.
927 */ 877 */
928 status = acpi_ut_walk_package_tree (source_obj, dest_obj, 878 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
929 acpi_ut_copy_ielement_to_ielement, walk_state); 879 acpi_ut_copy_ielement_to_ielement,
930 if (ACPI_FAILURE (status)) { 880 walk_state);
881 if (ACPI_FAILURE(status)) {
931 /* On failure, delete the destination package object */ 882 /* On failure, delete the destination package object */
932 883
933 acpi_ut_remove_reference (dest_obj); 884 acpi_ut_remove_reference(dest_obj);
934 } 885 }
935 886
936 return_ACPI_STATUS (status); 887 return_ACPI_STATUS(status);
937} 888}
938 889
939
940/******************************************************************************* 890/*******************************************************************************
941 * 891 *
942 * FUNCTION: acpi_ut_copy_iobject_to_iobject 892 * FUNCTION: acpi_ut_copy_iobject_to_iobject
@@ -952,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage (
952 ******************************************************************************/ 902 ******************************************************************************/
953 903
954acpi_status 904acpi_status
955acpi_ut_copy_iobject_to_iobject ( 905acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
956 union acpi_operand_object *source_desc, 906 union acpi_operand_object **dest_desc,
957 union acpi_operand_object **dest_desc, 907 struct acpi_walk_state *walk_state)
958 struct acpi_walk_state *walk_state)
959{ 908{
960 acpi_status status = AE_OK; 909 acpi_status status = AE_OK;
961
962
963 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
964 910
911 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject");
965 912
966 /* Create the top level object */ 913 /* Create the top level object */
967 914
968 *dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc)); 915 *dest_desc =
916 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
969 if (!*dest_desc) { 917 if (!*dest_desc) {
970 return_ACPI_STATUS (AE_NO_MEMORY); 918 return_ACPI_STATUS(AE_NO_MEMORY);
971 } 919 }
972 920
973 /* Copy the object and possible subobjects */ 921 /* Copy the object and possible subobjects */
974 922
975 if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { 923 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
976 status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, 924 status =
977 walk_state); 925 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
978 } 926 walk_state);
979 else { 927 } else {
980 status = acpi_ut_copy_simple_object (source_desc, *dest_desc); 928 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
981 } 929 }
982 930
983 return_ACPI_STATUS (status); 931 return_ACPI_STATUS(status);
984} 932}
985
986
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index 794c7df3f2ad..d80e92639932 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -46,15 +46,16 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utdebug") 49ACPI_MODULE_NAME("utdebug")
50
51 50
52#ifdef ACPI_DEBUG_OUTPUT 51#ifdef ACPI_DEBUG_OUTPUT
52static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
53static char *acpi_gbl_fn_entry_str = "----Entry";
54static char *acpi_gbl_fn_exit_str = "----Exit-";
53 55
54static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; 56/* Local prototypes */
55static char *acpi_gbl_fn_entry_str = "----Entry";
56static char *acpi_gbl_fn_exit_str = "----Exit-";
57 57
58static const char *acpi_ut_trim_function_name(const char *function_name);
58 59
59/******************************************************************************* 60/*******************************************************************************
60 * 61 *
@@ -68,17 +69,13 @@ static char *acpi_gbl_fn_exit_str = "----Exit-";
68 * 69 *
69 ******************************************************************************/ 70 ******************************************************************************/
70 71
71void 72void acpi_ut_init_stack_ptr_trace(void)
72acpi_ut_init_stack_ptr_trace (
73 void)
74{ 73{
75 u32 current_sp; 74 u32 current_sp;
76
77 75
78 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL); 76 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(&current_sp, NULL);
79} 77}
80 78
81
82/******************************************************************************* 79/*******************************************************************************
83 * 80 *
84 * FUNCTION: acpi_ut_track_stack_ptr 81 * FUNCTION: acpi_ut_track_stack_ptr
@@ -91,14 +88,11 @@ acpi_ut_init_stack_ptr_trace (
91 * 88 *
92 ******************************************************************************/ 89 ******************************************************************************/
93 90
94void 91void acpi_ut_track_stack_ptr(void)
95acpi_ut_track_stack_ptr (
96 void)
97{ 92{
98 acpi_size current_sp; 93 acpi_size current_sp;
99
100 94
101 current_sp = ACPI_PTR_DIFF (&current_sp, NULL); 95 current_sp = ACPI_PTR_DIFF(&current_sp, NULL);
102 96
103 if (current_sp < acpi_gbl_lowest_stack_pointer) { 97 if (current_sp < acpi_gbl_lowest_stack_pointer) {
104 acpi_gbl_lowest_stack_pointer = current_sp; 98 acpi_gbl_lowest_stack_pointer = current_sp;
@@ -109,6 +103,39 @@ acpi_ut_track_stack_ptr (
109 } 103 }
110} 104}
111 105
106/*******************************************************************************
107 *
108 * FUNCTION: acpi_ut_trim_function_name
109 *
110 * PARAMETERS: function_name - Ascii string containing a procedure name
111 *
112 * RETURN: Updated pointer to the function name
113 *
114 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
115 * This allows compiler macros such as __FUNCTION__ to be used
116 * with no change to the debug output.
117 *
118 ******************************************************************************/
119
120static const char *acpi_ut_trim_function_name(const char *function_name)
121{
122
123 /* All Function names are longer than 4 chars, check is safe */
124
125 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
126 /* This is the case where the original source has not been modified */
127
128 return (function_name + 4);
129 }
130
131 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
132 /* This is the case where the source has been 'linuxized' */
133
134 return (function_name + 5);
135 }
136
137 return (function_name);
138}
112 139
113/******************************************************************************* 140/*******************************************************************************
114 * 141 *
@@ -116,10 +143,9 @@ acpi_ut_track_stack_ptr (
116 * 143 *
117 * PARAMETERS: requested_debug_level - Requested debug print level 144 * PARAMETERS: requested_debug_level - Requested debug print level
118 * line_number - Caller's line number (for error output) 145 * line_number - Caller's line number (for error output)
119 * dbg_info - Contains: 146 * function_name - Caller's procedure name
120 * proc_name - Caller's procedure name 147 * module_name - Caller's module name
121 * module_name - Caller's module name 148 * component_id - Caller's component ID
122 * component_id - Caller's component ID
123 * Format - Printf format field 149 * Format - Printf format field
124 * ... - Optional printf arguments 150 * ... - Optional printf arguments
125 * 151 *
@@ -130,36 +156,33 @@ acpi_ut_track_stack_ptr (
130 * 156 *
131 ******************************************************************************/ 157 ******************************************************************************/
132 158
133void ACPI_INTERNAL_VAR_XFACE 159void ACPI_INTERNAL_VAR_XFACE
134acpi_ut_debug_print ( 160acpi_ut_debug_print(u32 requested_debug_level,
135 u32 requested_debug_level, 161 u32 line_number,
136 u32 line_number, 162 const char *function_name,
137 struct acpi_debug_print_info *dbg_info, 163 char *module_name, u32 component_id, char *format, ...)
138 char *format,
139 ...)
140{ 164{
141 u32 thread_id; 165 u32 thread_id;
142 va_list args; 166 va_list args;
143
144 167
145 /* 168 /*
146 * Stay silent if the debug level or component ID is disabled 169 * Stay silent if the debug level or component ID is disabled
147 */ 170 */
148 if (!(requested_debug_level & acpi_dbg_level) || 171 if (!(requested_debug_level & acpi_dbg_level) ||
149 !(dbg_info->component_id & acpi_dbg_layer)) { 172 !(component_id & acpi_dbg_layer)) {
150 return; 173 return;
151 } 174 }
152 175
153 /* 176 /*
154 * Thread tracking and context switch notification 177 * Thread tracking and context switch notification
155 */ 178 */
156 thread_id = acpi_os_get_thread_id (); 179 thread_id = acpi_os_get_thread_id();
157 180
158 if (thread_id != acpi_gbl_prev_thread_id) { 181 if (thread_id != acpi_gbl_prev_thread_id) {
159 if (ACPI_LV_THREADS & acpi_dbg_level) { 182 if (ACPI_LV_THREADS & acpi_dbg_level) {
160 acpi_os_printf ( 183 acpi_os_printf
161 "\n**** Context Switch from TID %X to TID %X ****\n\n", 184 ("\n**** Context Switch from TID %X to TID %X ****\n\n",
162 acpi_gbl_prev_thread_id, thread_id); 185 acpi_gbl_prev_thread_id, thread_id);
163 } 186 }
164 187
165 acpi_gbl_prev_thread_id = thread_id; 188 acpi_gbl_prev_thread_id = thread_id;
@@ -169,17 +192,18 @@ acpi_ut_debug_print (
169 * Display the module name, current line number, thread ID (if requested), 192 * Display the module name, current line number, thread ID (if requested),
170 * current procedure nesting level, and the current procedure name 193 * current procedure nesting level, and the current procedure name
171 */ 194 */
172 acpi_os_printf ("%8s-%04ld ", dbg_info->module_name, line_number); 195 acpi_os_printf("%8s-%04ld ", module_name, line_number);
173 196
174 if (ACPI_LV_THREADS & acpi_dbg_level) { 197 if (ACPI_LV_THREADS & acpi_dbg_level) {
175 acpi_os_printf ("[%04lX] ", thread_id); 198 acpi_os_printf("[%04lX] ", thread_id);
176 } 199 }
177 200
178 acpi_os_printf ("[%02ld] %-22.22s: ", 201 acpi_os_printf("[%02ld] %-22.22s: ",
179 acpi_gbl_nesting_level, dbg_info->proc_name); 202 acpi_gbl_nesting_level,
203 acpi_ut_trim_function_name(function_name));
180 204
181 va_start (args, format); 205 va_start(args, format);
182 acpi_os_vprintf (format, args); 206 acpi_os_vprintf(format, args);
183} 207}
184 208
185EXPORT_SYMBOL(acpi_ut_debug_print); 209EXPORT_SYMBOL(acpi_ut_debug_print);
@@ -190,10 +214,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
190 * 214 *
191 * PARAMETERS: requested_debug_level - Requested debug print level 215 * PARAMETERS: requested_debug_level - Requested debug print level
192 * line_number - Caller's line number 216 * line_number - Caller's line number
193 * dbg_info - Contains: 217 * function_name - Caller's procedure name
194 * proc_name - Caller's procedure name 218 * module_name - Caller's module name
195 * module_name - Caller's module name 219 * component_id - Caller's component ID
196 * component_id - Caller's component ID
197 * Format - Printf format field 220 * Format - Printf format field
198 * ... - Optional printf arguments 221 * ... - Optional printf arguments
199 * 222 *
@@ -204,37 +227,33 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
204 * 227 *
205 ******************************************************************************/ 228 ******************************************************************************/
206 229
207void ACPI_INTERNAL_VAR_XFACE 230void ACPI_INTERNAL_VAR_XFACE
208acpi_ut_debug_print_raw ( 231acpi_ut_debug_print_raw(u32 requested_debug_level,
209 u32 requested_debug_level, 232 u32 line_number,
210 u32 line_number, 233 const char *function_name,
211 struct acpi_debug_print_info *dbg_info, 234 char *module_name, u32 component_id, char *format, ...)
212 char *format,
213 ...)
214{ 235{
215 va_list args; 236 va_list args;
216
217 237
218 if (!(requested_debug_level & acpi_dbg_level) || 238 if (!(requested_debug_level & acpi_dbg_level) ||
219 !(dbg_info->component_id & acpi_dbg_layer)) { 239 !(component_id & acpi_dbg_layer)) {
220 return; 240 return;
221 } 241 }
222 242
223 va_start (args, format); 243 va_start(args, format);
224 acpi_os_vprintf (format, args); 244 acpi_os_vprintf(format, args);
225} 245}
226EXPORT_SYMBOL(acpi_ut_debug_print_raw);
227 246
247EXPORT_SYMBOL(acpi_ut_debug_print_raw);
228 248
229/******************************************************************************* 249/*******************************************************************************
230 * 250 *
231 * FUNCTION: acpi_ut_trace 251 * FUNCTION: acpi_ut_trace
232 * 252 *
233 * PARAMETERS: line_number - Caller's line number 253 * PARAMETERS: line_number - Caller's line number
234 * dbg_info - Contains: 254 * function_name - Caller's procedure name
235 * proc_name - Caller's procedure name 255 * module_name - Caller's module name
236 * module_name - Caller's module name 256 * component_id - Caller's component ID
237 * component_id - Caller's component ID
238 * 257 *
239 * RETURN: None 258 * RETURN: None
240 * 259 *
@@ -244,29 +263,28 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw);
244 ******************************************************************************/ 263 ******************************************************************************/
245 264
246void 265void
247acpi_ut_trace ( 266acpi_ut_trace(u32 line_number,
248 u32 line_number, 267 const char *function_name, char *module_name, u32 component_id)
249 struct acpi_debug_print_info *dbg_info)
250{ 268{
251 269
252 acpi_gbl_nesting_level++; 270 acpi_gbl_nesting_level++;
253 acpi_ut_track_stack_ptr (); 271 acpi_ut_track_stack_ptr();
254 272
255 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
256 "%s\n", acpi_gbl_fn_entry_str); 274 line_number, function_name, module_name,
275 component_id, "%s\n", acpi_gbl_fn_entry_str);
257} 276}
258EXPORT_SYMBOL(acpi_ut_trace);
259 277
278EXPORT_SYMBOL(acpi_ut_trace);
260 279
261/******************************************************************************* 280/*******************************************************************************
262 * 281 *
263 * FUNCTION: acpi_ut_trace_ptr 282 * FUNCTION: acpi_ut_trace_ptr
264 * 283 *
265 * PARAMETERS: line_number - Caller's line number 284 * PARAMETERS: line_number - Caller's line number
266 * dbg_info - Contains: 285 * function_name - Caller's procedure name
267 * proc_name - Caller's procedure name 286 * module_name - Caller's module name
268 * module_name - Caller's module name 287 * component_id - Caller's component ID
269 * component_id - Caller's component ID
270 * Pointer - Pointer to display 288 * Pointer - Pointer to display
271 * 289 *
272 * RETURN: None 290 * RETURN: None
@@ -277,28 +295,27 @@ EXPORT_SYMBOL(acpi_ut_trace);
277 ******************************************************************************/ 295 ******************************************************************************/
278 296
279void 297void
280acpi_ut_trace_ptr ( 298acpi_ut_trace_ptr(u32 line_number,
281 u32 line_number, 299 const char *function_name,
282 struct acpi_debug_print_info *dbg_info, 300 char *module_name, u32 component_id, void *pointer)
283 void *pointer)
284{ 301{
285 acpi_gbl_nesting_level++; 302 acpi_gbl_nesting_level++;
286 acpi_ut_track_stack_ptr (); 303 acpi_ut_track_stack_ptr();
287 304
288 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 305 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
289 "%s %p\n", acpi_gbl_fn_entry_str, pointer); 306 line_number, function_name, module_name,
307 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
308 pointer);
290} 309}
291 310
292
293/******************************************************************************* 311/*******************************************************************************
294 * 312 *
295 * FUNCTION: acpi_ut_trace_str 313 * FUNCTION: acpi_ut_trace_str
296 * 314 *
297 * PARAMETERS: line_number - Caller's line number 315 * PARAMETERS: line_number - Caller's line number
298 * dbg_info - Contains: 316 * function_name - Caller's procedure name
299 * proc_name - Caller's procedure name 317 * module_name - Caller's module name
300 * module_name - Caller's module name 318 * component_id - Caller's component ID
301 * component_id - Caller's component ID
302 * String - Additional string to display 319 * String - Additional string to display
303 * 320 *
304 * RETURN: None 321 * RETURN: None
@@ -309,29 +326,28 @@ acpi_ut_trace_ptr (
309 ******************************************************************************/ 326 ******************************************************************************/
310 327
311void 328void
312acpi_ut_trace_str ( 329acpi_ut_trace_str(u32 line_number,
313 u32 line_number, 330 const char *function_name,
314 struct acpi_debug_print_info *dbg_info, 331 char *module_name, u32 component_id, char *string)
315 char *string)
316{ 332{
317 333
318 acpi_gbl_nesting_level++; 334 acpi_gbl_nesting_level++;
319 acpi_ut_track_stack_ptr (); 335 acpi_ut_track_stack_ptr();
320 336
321 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 337 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
322 "%s %s\n", acpi_gbl_fn_entry_str, string); 338 line_number, function_name, module_name,
339 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
340 string);
323} 341}
324 342
325
326/******************************************************************************* 343/*******************************************************************************
327 * 344 *
328 * FUNCTION: acpi_ut_trace_u32 345 * FUNCTION: acpi_ut_trace_u32
329 * 346 *
330 * PARAMETERS: line_number - Caller's line number 347 * PARAMETERS: line_number - Caller's line number
331 * dbg_info - Contains: 348 * function_name - Caller's procedure name
332 * proc_name - Caller's procedure name 349 * module_name - Caller's module name
333 * module_name - Caller's module name 350 * component_id - Caller's component ID
334 * component_id - Caller's component ID
335 * Integer - Integer to display 351 * Integer - Integer to display
336 * 352 *
337 * RETURN: None 353 * RETURN: None
@@ -342,29 +358,28 @@ acpi_ut_trace_str (
342 ******************************************************************************/ 358 ******************************************************************************/
343 359
344void 360void
345acpi_ut_trace_u32 ( 361acpi_ut_trace_u32(u32 line_number,
346 u32 line_number, 362 const char *function_name,
347 struct acpi_debug_print_info *dbg_info, 363 char *module_name, u32 component_id, u32 integer)
348 u32 integer)
349{ 364{
350 365
351 acpi_gbl_nesting_level++; 366 acpi_gbl_nesting_level++;
352 acpi_ut_track_stack_ptr (); 367 acpi_ut_track_stack_ptr();
353 368
354 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 369 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
355 "%s %08X\n", acpi_gbl_fn_entry_str, integer); 370 line_number, function_name, module_name,
371 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
372 integer);
356} 373}
357 374
358
359/******************************************************************************* 375/*******************************************************************************
360 * 376 *
361 * FUNCTION: acpi_ut_exit 377 * FUNCTION: acpi_ut_exit
362 * 378 *
363 * PARAMETERS: line_number - Caller's line number 379 * PARAMETERS: line_number - Caller's line number
364 * dbg_info - Contains: 380 * function_name - Caller's procedure name
365 * proc_name - Caller's procedure name 381 * module_name - Caller's module name
366 * module_name - Caller's module name 382 * component_id - Caller's component ID
367 * component_id - Caller's component ID
368 * 383 *
369 * RETURN: None 384 * RETURN: None
370 * 385 *
@@ -374,28 +389,27 @@ acpi_ut_trace_u32 (
374 ******************************************************************************/ 389 ******************************************************************************/
375 390
376void 391void
377acpi_ut_exit ( 392acpi_ut_exit(u32 line_number,
378 u32 line_number, 393 const char *function_name, char *module_name, u32 component_id)
379 struct acpi_debug_print_info *dbg_info)
380{ 394{
381 395
382 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
383 "%s\n", acpi_gbl_fn_exit_str); 397 line_number, function_name, module_name,
398 component_id, "%s\n", acpi_gbl_fn_exit_str);
384 399
385 acpi_gbl_nesting_level--; 400 acpi_gbl_nesting_level--;
386} 401}
387EXPORT_SYMBOL(acpi_ut_exit);
388 402
403EXPORT_SYMBOL(acpi_ut_exit);
389 404
390/******************************************************************************* 405/*******************************************************************************
391 * 406 *
392 * FUNCTION: acpi_ut_status_exit 407 * FUNCTION: acpi_ut_status_exit
393 * 408 *
394 * PARAMETERS: line_number - Caller's line number 409 * PARAMETERS: line_number - Caller's line number
395 * dbg_info - Contains: 410 * function_name - Caller's procedure name
396 * proc_name - Caller's procedure name 411 * module_name - Caller's module name
397 * module_name - Caller's module name 412 * component_id - Caller's component ID
398 * component_id - Caller's component ID
399 * Status - Exit status code 413 * Status - Exit status code
400 * 414 *
401 * RETURN: None 415 * RETURN: None
@@ -406,37 +420,38 @@ EXPORT_SYMBOL(acpi_ut_exit);
406 ******************************************************************************/ 420 ******************************************************************************/
407 421
408void 422void
409acpi_ut_status_exit ( 423acpi_ut_status_exit(u32 line_number,
410 u32 line_number, 424 const char *function_name,
411 struct acpi_debug_print_info *dbg_info, 425 char *module_name, u32 component_id, acpi_status status)
412 acpi_status status)
413{ 426{
414 427
415 if (ACPI_SUCCESS (status)) { 428 if (ACPI_SUCCESS(status)) {
416 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
417 "%s %s\n", acpi_gbl_fn_exit_str, 430 line_number, function_name, module_name,
418 acpi_format_exception (status)); 431 component_id, "%s %s\n",
419 } 432 acpi_gbl_fn_exit_str,
420 else { 433 acpi_format_exception(status));
421 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 434 } else {
422 "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, 435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
423 acpi_format_exception (status)); 436 line_number, function_name, module_name,
437 component_id, "%s ****Exception****: %s\n",
438 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status));
424 } 440 }
425 441
426 acpi_gbl_nesting_level--; 442 acpi_gbl_nesting_level--;
427} 443}
428EXPORT_SYMBOL(acpi_ut_status_exit);
429 444
445EXPORT_SYMBOL(acpi_ut_status_exit);
430 446
431/******************************************************************************* 447/*******************************************************************************
432 * 448 *
433 * FUNCTION: acpi_ut_value_exit 449 * FUNCTION: acpi_ut_value_exit
434 * 450 *
435 * PARAMETERS: line_number - Caller's line number 451 * PARAMETERS: line_number - Caller's line number
436 * dbg_info - Contains: 452 * function_name - Caller's procedure name
437 * proc_name - Caller's procedure name 453 * module_name - Caller's module name
438 * module_name - Caller's module name 454 * component_id - Caller's component ID
439 * component_id - Caller's component ID
440 * Value - Value to be printed with exit msg 455 * Value - Value to be printed with exit msg
441 * 456 *
442 * RETURN: None 457 * RETURN: None
@@ -447,30 +462,29 @@ EXPORT_SYMBOL(acpi_ut_status_exit);
447 ******************************************************************************/ 462 ******************************************************************************/
448 463
449void 464void
450acpi_ut_value_exit ( 465acpi_ut_value_exit(u32 line_number,
451 u32 line_number, 466 const char *function_name,
452 struct acpi_debug_print_info *dbg_info, 467 char *module_name, u32 component_id, acpi_integer value)
453 acpi_integer value)
454{ 468{
455 469
456 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
457 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, 471 line_number, function_name, module_name,
458 ACPI_FORMAT_UINT64 (value)); 472 component_id, "%s %8.8X%8.8X\n",
473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
459 474
460 acpi_gbl_nesting_level--; 475 acpi_gbl_nesting_level--;
461} 476}
462EXPORT_SYMBOL(acpi_ut_value_exit);
463 477
478EXPORT_SYMBOL(acpi_ut_value_exit);
464 479
465/******************************************************************************* 480/*******************************************************************************
466 * 481 *
467 * FUNCTION: acpi_ut_ptr_exit 482 * FUNCTION: acpi_ut_ptr_exit
468 * 483 *
469 * PARAMETERS: line_number - Caller's line number 484 * PARAMETERS: line_number - Caller's line number
470 * dbg_info - Contains: 485 * function_name - Caller's procedure name
471 * proc_name - Caller's procedure name 486 * module_name - Caller's module name
472 * module_name - Caller's module name 487 * component_id - Caller's component ID
473 * component_id - Caller's component ID
474 * Ptr - Pointer to display 488 * Ptr - Pointer to display
475 * 489 *
476 * RETURN: None 490 * RETURN: None
@@ -481,21 +495,20 @@ EXPORT_SYMBOL(acpi_ut_value_exit);
481 ******************************************************************************/ 495 ******************************************************************************/
482 496
483void 497void
484acpi_ut_ptr_exit ( 498acpi_ut_ptr_exit(u32 line_number,
485 u32 line_number, 499 const char *function_name,
486 struct acpi_debug_print_info *dbg_info, 500 char *module_name, u32 component_id, u8 * ptr)
487 u8 *ptr)
488{ 501{
489 502
490 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, 503 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
491 "%s %p\n", acpi_gbl_fn_exit_str, ptr); 504 line_number, function_name, module_name,
505 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
492 506
493 acpi_gbl_nesting_level--; 507 acpi_gbl_nesting_level--;
494} 508}
495 509
496#endif 510#endif
497 511
498
499/******************************************************************************* 512/*******************************************************************************
500 * 513 *
501 * FUNCTION: acpi_ut_dump_buffer 514 * FUNCTION: acpi_ut_dump_buffer
@@ -511,23 +524,17 @@ acpi_ut_ptr_exit (
511 * 524 *
512 ******************************************************************************/ 525 ******************************************************************************/
513 526
514void 527void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
515acpi_ut_dump_buffer (
516 u8 *buffer,
517 u32 count,
518 u32 display,
519 u32 component_id)
520{ 528{
521 acpi_native_uint i = 0; 529 acpi_native_uint i = 0;
522 acpi_native_uint j; 530 acpi_native_uint j;
523 u32 temp32; 531 u32 temp32;
524 u8 buf_char; 532 u8 buf_char;
525
526 533
527 /* Only dump the buffer if tracing is enabled */ 534 /* Only dump the buffer if tracing is enabled */
528 535
529 if (!((ACPI_LV_TABLES & acpi_dbg_level) && 536 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
530 (component_id & acpi_dbg_layer))) { 537 (component_id & acpi_dbg_layer))) {
531 return; 538 return;
532 } 539 }
533 540
@@ -540,7 +547,7 @@ acpi_ut_dump_buffer (
540 while (i < count) { 547 while (i < count) {
541 /* Print current offset */ 548 /* Print current offset */
542 549
543 acpi_os_printf ("%6.4X: ", (u32) i); 550 acpi_os_printf("%6.4X: ", (u32) i);
544 551
545 /* Print 16 hex chars */ 552 /* Print 16 hex chars */
546 553
@@ -548,73 +555,66 @@ acpi_ut_dump_buffer (
548 if (i + j >= count) { 555 if (i + j >= count) {
549 /* Dump fill spaces */ 556 /* Dump fill spaces */
550 557
551 acpi_os_printf ("%*s", ((display * 2) + 1), " "); 558 acpi_os_printf("%*s", ((display * 2) + 1), " ");
552 j += display; 559 j += (acpi_native_uint) display;
553 continue; 560 continue;
554 } 561 }
555 562
556 switch (display) { 563 switch (display) {
557 default: /* Default is BYTE display */ 564 default: /* Default is BYTE display */
558 565
559 acpi_os_printf ("%02X ", buffer[i + j]); 566 acpi_os_printf("%02X ", buffer[i + j]);
560 break; 567 break;
561 568
562
563 case DB_WORD_DISPLAY: 569 case DB_WORD_DISPLAY:
564 570
565 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); 571 ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]);
566 acpi_os_printf ("%04X ", temp32); 572 acpi_os_printf("%04X ", temp32);
567 break; 573 break;
568 574
569
570 case DB_DWORD_DISPLAY: 575 case DB_DWORD_DISPLAY:
571 576
572 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 577 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
573 acpi_os_printf ("%08X ", temp32); 578 acpi_os_printf("%08X ", temp32);
574 break; 579 break;
575 580
576
577 case DB_QWORD_DISPLAY: 581 case DB_QWORD_DISPLAY:
578 582
579 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 583 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
580 acpi_os_printf ("%08X", temp32); 584 acpi_os_printf("%08X", temp32);
581 585
582 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); 586 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]);
583 acpi_os_printf ("%08X ", temp32); 587 acpi_os_printf("%08X ", temp32);
584 break; 588 break;
585 } 589 }
586 590
587 j += display; 591 j += (acpi_native_uint) display;
588 } 592 }
589 593
590 /* 594 /*
591 * Print the ASCII equivalent characters 595 * Print the ASCII equivalent characters but watch out for the bad
592 * But watch out for the bad unprintable ones... 596 * unprintable ones (printable chars are 0x20 through 0x7E)
593 */ 597 */
594 acpi_os_printf (" "); 598 acpi_os_printf(" ");
595 for (j = 0; j < 16; j++) { 599 for (j = 0; j < 16; j++) {
596 if (i + j >= count) { 600 if (i + j >= count) {
597 acpi_os_printf ("\n"); 601 acpi_os_printf("\n");
598 return; 602 return;
599 } 603 }
600 604
601 buf_char = buffer[i + j]; 605 buf_char = buffer[i + j];
602 if ((buf_char > 0x1F && buf_char < 0x2E) || 606 if (ACPI_IS_PRINT(buf_char)) {
603 (buf_char > 0x2F && buf_char < 0x61) || 607 acpi_os_printf("%c", buf_char);
604 (buf_char > 0x60 && buf_char < 0x7F)) { 608 } else {
605 acpi_os_printf ("%c", buf_char); 609 acpi_os_printf(".");
606 }
607 else {
608 acpi_os_printf (".");
609 } 610 }
610 } 611 }
611 612
612 /* Done with that line. */ 613 /* Done with that line. */
613 614
614 acpi_os_printf ("\n"); 615 acpi_os_printf("\n");
615 i += 16; 616 i += 16;
616 } 617 }
617 618
618 return; 619 return;
619} 620}
620
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index bc5403022681..2bc878f7a127 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
@@ -49,19 +48,13 @@
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utdelete") 51ACPI_MODULE_NAME("utdelete")
53 52
54/* Local prototypes */ 53/* Local prototypes */
54static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
55 55
56static void 56static void
57acpi_ut_delete_internal_obj ( 57acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
58 union acpi_operand_object *object);
59
60static void
61acpi_ut_update_ref_count (
62 union acpi_operand_object *object,
63 u32 action);
64
65 58
66/******************************************************************************* 59/*******************************************************************************
67 * 60 *
@@ -76,18 +69,14 @@ acpi_ut_update_ref_count (
76 * 69 *
77 ******************************************************************************/ 70 ******************************************************************************/
78 71
79static void 72static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
80acpi_ut_delete_internal_obj (
81 union acpi_operand_object *object)
82{ 73{
83 void *obj_pointer = NULL; 74 void *obj_pointer = NULL;
84 union acpi_operand_object *handler_desc; 75 union acpi_operand_object *handler_desc;
85 union acpi_operand_object *second_desc; 76 union acpi_operand_object *second_desc;
86 union acpi_operand_object *next_desc; 77 union acpi_operand_object *next_desc;
87
88
89 ACPI_FUNCTION_TRACE_PTR ("ut_delete_internal_obj", object);
90 78
79 ACPI_FUNCTION_TRACE_PTR("ut_delete_internal_obj", object);
91 80
92 if (!object) { 81 if (!object) {
93 return_VOID; 82 return_VOID;
@@ -97,11 +86,12 @@ acpi_ut_delete_internal_obj (
97 * Must delete or free any pointers within the object that are not 86 * Must delete or free any pointers within the object that are not
98 * actual ACPI objects (for example, a raw buffer pointer). 87 * actual ACPI objects (for example, a raw buffer pointer).
99 */ 88 */
100 switch (ACPI_GET_OBJECT_TYPE (object)) { 89 switch (ACPI_GET_OBJECT_TYPE(object)) {
101 case ACPI_TYPE_STRING: 90 case ACPI_TYPE_STRING:
102 91
103 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", 92 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
104 object, object->string.pointer)); 93 "**** String %p, ptr %p\n", object,
94 object->string.pointer));
105 95
106 /* Free the actual string buffer */ 96 /* Free the actual string buffer */
107 97
@@ -112,11 +102,11 @@ acpi_ut_delete_internal_obj (
112 } 102 }
113 break; 103 break;
114 104
115
116 case ACPI_TYPE_BUFFER: 105 case ACPI_TYPE_BUFFER:
117 106
118 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", 107 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
119 object, object->buffer.pointer)); 108 "**** Buffer %p, ptr %p\n", object,
109 object->buffer.pointer));
120 110
121 /* Free the actual buffer */ 111 /* Free the actual buffer */
122 112
@@ -127,11 +117,11 @@ acpi_ut_delete_internal_obj (
127 } 117 }
128 break; 118 break;
129 119
130
131 case ACPI_TYPE_PACKAGE: 120 case ACPI_TYPE_PACKAGE:
132 121
133 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", 122 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
134 object->package.count)); 123 " **** Package of count %X\n",
124 object->package.count));
135 125
136 /* 126 /*
137 * Elements of the package are not handled here, they are deleted 127 * Elements of the package are not handled here, they are deleted
@@ -143,11 +133,11 @@ acpi_ut_delete_internal_obj (
143 obj_pointer = object->package.elements; 133 obj_pointer = object->package.elements;
144 break; 134 break;
145 135
146
147 case ACPI_TYPE_DEVICE: 136 case ACPI_TYPE_DEVICE:
148 137
149 if (object->device.gpe_block) { 138 if (object->device.gpe_block) {
150 (void) acpi_ev_delete_gpe_block (object->device.gpe_block); 139 (void)acpi_ev_delete_gpe_block(object->device.
140 gpe_block);
151 } 141 }
152 142
153 /* Walk the handler list for this device */ 143 /* Walk the handler list for this device */
@@ -155,54 +145,51 @@ acpi_ut_delete_internal_obj (
155 handler_desc = object->device.handler; 145 handler_desc = object->device.handler;
156 while (handler_desc) { 146 while (handler_desc) {
157 next_desc = handler_desc->address_space.next; 147 next_desc = handler_desc->address_space.next;
158 acpi_ut_remove_reference (handler_desc); 148 acpi_ut_remove_reference(handler_desc);
159 handler_desc = next_desc; 149 handler_desc = next_desc;
160 } 150 }
161 break; 151 break;
162 152
163
164 case ACPI_TYPE_MUTEX: 153 case ACPI_TYPE_MUTEX:
165 154
166 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 155 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
167 "***** Mutex %p, Semaphore %p\n", 156 "***** Mutex %p, Semaphore %p\n",
168 object, object->mutex.semaphore)); 157 object, object->mutex.semaphore));
169 158
170 acpi_ex_unlink_mutex (object); 159 acpi_ex_unlink_mutex(object);
171 (void) acpi_os_delete_semaphore (object->mutex.semaphore); 160 (void)acpi_os_delete_semaphore(object->mutex.semaphore);
172 break; 161 break;
173 162
174
175 case ACPI_TYPE_EVENT: 163 case ACPI_TYPE_EVENT:
176 164
177 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 165 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
178 "***** Event %p, Semaphore %p\n", 166 "***** Event %p, Semaphore %p\n",
179 object, object->event.semaphore)); 167 object, object->event.semaphore));
180 168
181 (void) acpi_os_delete_semaphore (object->event.semaphore); 169 (void)acpi_os_delete_semaphore(object->event.semaphore);
182 object->event.semaphore = NULL; 170 object->event.semaphore = NULL;
183 break; 171 break;
184 172
185
186 case ACPI_TYPE_METHOD: 173 case ACPI_TYPE_METHOD:
187 174
188 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 175 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
189 "***** Method %p\n", object)); 176 "***** Method %p\n", object));
190 177
191 /* Delete the method semaphore if it exists */ 178 /* Delete the method semaphore if it exists */
192 179
193 if (object->method.semaphore) { 180 if (object->method.semaphore) {
194 (void) acpi_os_delete_semaphore (object->method.semaphore); 181 (void)acpi_os_delete_semaphore(object->method.
182 semaphore);
195 object->method.semaphore = NULL; 183 object->method.semaphore = NULL;
196 } 184 }
197 break; 185 break;
198 186
199
200 case ACPI_TYPE_REGION: 187 case ACPI_TYPE_REGION:
201 188
202 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 189 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
203 "***** Region %p\n", object)); 190 "***** Region %p\n", object));
204 191
205 second_desc = acpi_ns_get_secondary_object (object); 192 second_desc = acpi_ns_get_secondary_object(object);
206 if (second_desc) { 193 if (second_desc) {
207 /* 194 /*
208 * Free the region_context if and only if the handler is one of the 195 * Free the region_context if and only if the handler is one of the
@@ -211,32 +198,33 @@ acpi_ut_delete_internal_obj (
211 */ 198 */
212 handler_desc = object->region.handler; 199 handler_desc = object->region.handler;
213 if (handler_desc) { 200 if (handler_desc) {
214 if (handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { 201 if (handler_desc->address_space.
215 obj_pointer = second_desc->extra.region_context; 202 hflags &
203 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
204 obj_pointer =
205 second_desc->extra.region_context;
216 } 206 }
217 207
218 acpi_ut_remove_reference (handler_desc); 208 acpi_ut_remove_reference(handler_desc);
219 } 209 }
220 210
221 /* Now we can free the Extra object */ 211 /* Now we can free the Extra object */
222 212
223 acpi_ut_delete_object_desc (second_desc); 213 acpi_ut_delete_object_desc(second_desc);
224 } 214 }
225 break; 215 break;
226 216
227
228 case ACPI_TYPE_BUFFER_FIELD: 217 case ACPI_TYPE_BUFFER_FIELD:
229 218
230 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 219 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
231 "***** Buffer Field %p\n", object)); 220 "***** Buffer Field %p\n", object));
232 221
233 second_desc = acpi_ns_get_secondary_object (object); 222 second_desc = acpi_ns_get_secondary_object(object);
234 if (second_desc) { 223 if (second_desc) {
235 acpi_ut_delete_object_desc (second_desc); 224 acpi_ut_delete_object_desc(second_desc);
236 } 225 }
237 break; 226 break;
238 227
239
240 default: 228 default:
241 break; 229 break;
242 } 230 }
@@ -244,21 +232,20 @@ acpi_ut_delete_internal_obj (
244 /* Free any allocated memory (pointer within the object) found above */ 232 /* Free any allocated memory (pointer within the object) found above */
245 233
246 if (obj_pointer) { 234 if (obj_pointer) {
247 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", 235 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
248 obj_pointer)); 236 "Deleting Object Subptr %p\n", obj_pointer));
249 ACPI_MEM_FREE (obj_pointer); 237 ACPI_MEM_FREE(obj_pointer);
250 } 238 }
251 239
252 /* Now the object can be safely deleted */ 240 /* Now the object can be safely deleted */
253 241
254 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", 242 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
255 object, acpi_ut_get_object_type_name (object))); 243 object, acpi_ut_get_object_type_name(object)));
256 244
257 acpi_ut_delete_object_desc (object); 245 acpi_ut_delete_object_desc(object);
258 return_VOID; 246 return_VOID;
259} 247}
260 248
261
262/******************************************************************************* 249/*******************************************************************************
263 * 250 *
264 * FUNCTION: acpi_ut_delete_internal_object_list 251 * FUNCTION: acpi_ut_delete_internal_object_list
@@ -272,29 +259,24 @@ acpi_ut_delete_internal_obj (
272 * 259 *
273 ******************************************************************************/ 260 ******************************************************************************/
274 261
275void 262void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
276acpi_ut_delete_internal_object_list (
277 union acpi_operand_object **obj_list)
278{ 263{
279 union acpi_operand_object **internal_obj; 264 union acpi_operand_object **internal_obj;
280
281
282 ACPI_FUNCTION_TRACE ("ut_delete_internal_object_list");
283 265
266 ACPI_FUNCTION_TRACE("ut_delete_internal_object_list");
284 267
285 /* Walk the null-terminated internal list */ 268 /* Walk the null-terminated internal list */
286 269
287 for (internal_obj = obj_list; *internal_obj; internal_obj++) { 270 for (internal_obj = obj_list; *internal_obj; internal_obj++) {
288 acpi_ut_remove_reference (*internal_obj); 271 acpi_ut_remove_reference(*internal_obj);
289 } 272 }
290 273
291 /* Free the combined parameter pointer list and object array */ 274 /* Free the combined parameter pointer list and object array */
292 275
293 ACPI_MEM_FREE (obj_list); 276 ACPI_MEM_FREE(obj_list);
294 return_VOID; 277 return_VOID;
295} 278}
296 279
297
298/******************************************************************************* 280/*******************************************************************************
299 * 281 *
300 * FUNCTION: acpi_ut_update_ref_count 282 * FUNCTION: acpi_ut_update_ref_count
@@ -309,16 +291,12 @@ acpi_ut_delete_internal_object_list (
309 ******************************************************************************/ 291 ******************************************************************************/
310 292
311static void 293static void
312acpi_ut_update_ref_count ( 294acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
313 union acpi_operand_object *object,
314 u32 action)
315{ 295{
316 u16 count; 296 u16 count;
317 u16 new_count; 297 u16 new_count;
318
319
320 ACPI_FUNCTION_NAME ("ut_update_ref_count");
321 298
299 ACPI_FUNCTION_NAME("ut_update_ref_count");
322 300
323 if (!object) { 301 if (!object) {
324 return; 302 return;
@@ -338,58 +316,55 @@ acpi_ut_update_ref_count (
338 new_count++; 316 new_count++;
339 object->common.reference_count = new_count; 317 object->common.reference_count = new_count;
340 318
341 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 319 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
342 "Obj %p Refs=%X, [Incremented]\n", 320 "Obj %p Refs=%X, [Incremented]\n",
343 object, new_count)); 321 object, new_count));
344 break; 322 break;
345 323
346
347 case REF_DECREMENT: 324 case REF_DECREMENT:
348 325
349 if (count < 1) { 326 if (count < 1) {
350 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 327 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
351 "Obj %p Refs=%X, can't decrement! (Set to 0)\n", 328 "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
352 object, new_count)); 329 object, new_count));
353 330
354 new_count = 0; 331 new_count = 0;
355 } 332 } else {
356 else {
357 new_count--; 333 new_count--;
358 334
359 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 335 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
360 "Obj %p Refs=%X, [Decremented]\n", 336 "Obj %p Refs=%X, [Decremented]\n",
361 object, new_count)); 337 object, new_count));
362 } 338 }
363 339
364 if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) { 340 if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) {
365 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 341 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
366 "Method Obj %p Refs=%X, [Decremented]\n", 342 "Method Obj %p Refs=%X, [Decremented]\n",
367 object, new_count)); 343 object, new_count));
368 } 344 }
369 345
370 object->common.reference_count = new_count; 346 object->common.reference_count = new_count;
371 if (new_count == 0) { 347 if (new_count == 0) {
372 acpi_ut_delete_internal_obj (object); 348 acpi_ut_delete_internal_obj(object);
373 } 349 }
374 350
375 break; 351 break;
376 352
377
378 case REF_FORCE_DELETE: 353 case REF_FORCE_DELETE:
379 354
380 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 355 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
381 "Obj %p Refs=%X, Force delete! (Set to 0)\n", 356 "Obj %p Refs=%X, Force delete! (Set to 0)\n",
382 object, count)); 357 object, count));
383 358
384 new_count = 0; 359 new_count = 0;
385 object->common.reference_count = new_count; 360 object->common.reference_count = new_count;
386 acpi_ut_delete_internal_obj (object); 361 acpi_ut_delete_internal_obj(object);
387 break; 362 break;
388 363
389
390 default: 364 default:
391 365
392 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown action (%X)\n", action)); 366 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n",
367 action));
393 break; 368 break;
394 } 369 }
395 370
@@ -399,15 +374,14 @@ acpi_ut_update_ref_count (
399 */ 374 */
400 if (count > ACPI_MAX_REFERENCE_COUNT) { 375 if (count > ACPI_MAX_REFERENCE_COUNT) {
401 376
402 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 377 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
403 "**** Warning **** Large Reference Count (%X) in object %p\n\n", 378 "**** Warning **** Large Reference Count (%X) in object %p\n\n",
404 count, object)); 379 count, object));
405 } 380 }
406 381
407 return; 382 return;
408} 383}
409 384
410
411/******************************************************************************* 385/*******************************************************************************
412 * 386 *
413 * FUNCTION: acpi_ut_update_object_reference 387 * FUNCTION: acpi_ut_update_object_reference
@@ -431,65 +405,42 @@ acpi_ut_update_ref_count (
431 ******************************************************************************/ 405 ******************************************************************************/
432 406
433acpi_status 407acpi_status
434acpi_ut_update_object_reference ( 408acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action)
435 union acpi_operand_object *object,
436 u16 action)
437{ 409{
438 acpi_status status; 410 acpi_status status = AE_OK;
439 u32 i; 411 union acpi_generic_state *state_list = NULL;
440 union acpi_generic_state *state_list = NULL; 412 union acpi_operand_object *next_object = NULL;
441 union acpi_generic_state *state; 413 union acpi_generic_state *state;
442 union acpi_operand_object *tmp; 414 acpi_native_uint i;
443
444 ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
445 415
416 ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object);
446 417
447 /* Ignore a null object ptr */ 418 while (object) {
419 /* Make sure that this isn't a namespace handle */
448 420
449 if (!object) { 421 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
450 return_ACPI_STATUS (AE_OK); 422 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
451 } 423 "Object %p is NS handle\n", object));
452 424 return_ACPI_STATUS(AE_OK);
453 /* Make sure that this isn't a namespace handle */ 425 }
454
455 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
456 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
457 "Object %p is NS handle\n", object));
458 return_ACPI_STATUS (AE_OK);
459 }
460
461 state = acpi_ut_create_update_state (object, action);
462
463 while (state) {
464 object = state->update.object;
465 action = state->update.value;
466 acpi_ut_delete_generic_state (state);
467 426
468 /* 427 /*
469 * All sub-objects must have their reference count incremented also. 428 * All sub-objects must have their reference count incremented also.
470 * Different object types have different subobjects. 429 * Different object types have different subobjects.
471 */ 430 */
472 switch (ACPI_GET_OBJECT_TYPE (object)) { 431 switch (ACPI_GET_OBJECT_TYPE(object)) {
473 case ACPI_TYPE_DEVICE: 432 case ACPI_TYPE_DEVICE:
474 433
475 tmp = object->device.system_notify; 434 acpi_ut_update_ref_count(object->device.system_notify,
476 if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) 435 action);
477 object->device.system_notify = NULL; 436 acpi_ut_update_ref_count(object->device.device_notify,
478 acpi_ut_update_ref_count (tmp, action); 437 action);
479
480 tmp = object->device.device_notify;
481 if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
482 object->device.device_notify = NULL;
483 acpi_ut_update_ref_count (tmp, action);
484
485 break; 438 break;
486 439
487
488 case ACPI_TYPE_PACKAGE: 440 case ACPI_TYPE_PACKAGE:
489
490 /* 441 /*
491 * We must update all the sub-objects of the package 442 * We must update all the sub-objects of the package,
492 * (Each of whom may have their own sub-objects, etc. 443 * each of whom may have their own sub-objects.
493 */ 444 */
494 for (i = 0; i < object->package.count; i++) { 445 for (i = 0; i < object->package.count; i++) {
495 /* 446 /*
@@ -497,116 +448,67 @@ acpi_ut_update_object_reference (
497 * Note: There can be null elements within the package, 448 * Note: There can be null elements within the package,
498 * these are simply ignored 449 * these are simply ignored
499 */ 450 */
500 status = acpi_ut_create_update_state_and_push ( 451 status =
501 object->package.elements[i], action, &state_list); 452 acpi_ut_create_update_state_and_push
502 if (ACPI_FAILURE (status)) { 453 (object->package.elements[i], action,
454 &state_list);
455 if (ACPI_FAILURE(status)) {
503 goto error_exit; 456 goto error_exit;
504 } 457 }
505
506 tmp = object->package.elements[i];
507 if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
508 object->package.elements[i] = NULL;
509 } 458 }
510 break; 459 break;
511 460
512
513 case ACPI_TYPE_BUFFER_FIELD: 461 case ACPI_TYPE_BUFFER_FIELD:
514 462
515 status = acpi_ut_create_update_state_and_push ( 463 next_object = object->buffer_field.buffer_obj;
516 object->buffer_field.buffer_obj, action, &state_list);
517 if (ACPI_FAILURE (status)) {
518 goto error_exit;
519 }
520
521 tmp = object->buffer_field.buffer_obj;
522 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
523 object->buffer_field.buffer_obj = NULL;
524 break; 464 break;
525 465
526
527 case ACPI_TYPE_LOCAL_REGION_FIELD: 466 case ACPI_TYPE_LOCAL_REGION_FIELD:
528 467
529 status = acpi_ut_create_update_state_and_push ( 468 next_object = object->field.region_obj;
530 object->field.region_obj, action, &state_list); 469 break;
531 if (ACPI_FAILURE (status)) {
532 goto error_exit;
533 }
534
535 tmp = object->field.region_obj;
536 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
537 object->field.region_obj = NULL;
538 break;
539
540 470
541 case ACPI_TYPE_LOCAL_BANK_FIELD: 471 case ACPI_TYPE_LOCAL_BANK_FIELD:
542 472
543 status = acpi_ut_create_update_state_and_push ( 473 next_object = object->bank_field.bank_obj;
544 object->bank_field.bank_obj, action, &state_list); 474 status =
545 if (ACPI_FAILURE (status)) { 475 acpi_ut_create_update_state_and_push(object->
476 bank_field.
477 region_obj,
478 action,
479 &state_list);
480 if (ACPI_FAILURE(status)) {
546 goto error_exit; 481 goto error_exit;
547 } 482 }
548
549 tmp = object->bank_field.bank_obj;
550 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
551 object->bank_field.bank_obj = NULL;
552
553 status = acpi_ut_create_update_state_and_push (
554 object->bank_field.region_obj, action, &state_list);
555 if (ACPI_FAILURE (status)) {
556 goto error_exit;
557 }
558
559 tmp = object->bank_field.region_obj;
560 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
561 object->bank_field.region_obj = NULL;
562 break; 483 break;
563 484
564
565 case ACPI_TYPE_LOCAL_INDEX_FIELD: 485 case ACPI_TYPE_LOCAL_INDEX_FIELD:
566 486
567 status = acpi_ut_create_update_state_and_push ( 487 next_object = object->index_field.index_obj;
568 object->index_field.index_obj, action, &state_list); 488 status =
569 if (ACPI_FAILURE (status)) { 489 acpi_ut_create_update_state_and_push(object->
570 goto error_exit; 490 index_field.
571 } 491 data_obj,
572 492 action,
573 tmp = object->index_field.index_obj; 493 &state_list);
574 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) 494 if (ACPI_FAILURE(status)) {
575 object->index_field.index_obj = NULL;
576
577 status = acpi_ut_create_update_state_and_push (
578 object->index_field.data_obj, action, &state_list);
579 if (ACPI_FAILURE (status)) {
580 goto error_exit; 495 goto error_exit;
581 } 496 }
582
583 tmp = object->index_field.data_obj;
584 if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
585 object->index_field.data_obj = NULL;
586 break; 497 break;
587 498
588
589 case ACPI_TYPE_LOCAL_REFERENCE: 499 case ACPI_TYPE_LOCAL_REFERENCE:
590
591 /* 500 /*
592 * The target of an Index (a package, string, or buffer) must track 501 * The target of an Index (a package, string, or buffer) must track
593 * changes to the ref count of the index. 502 * changes to the ref count of the index.
594 */ 503 */
595 if (object->reference.opcode == AML_INDEX_OP) { 504 if (object->reference.opcode == AML_INDEX_OP) {
596 status = acpi_ut_create_update_state_and_push ( 505 next_object = object->reference.object;
597 object->reference.object, action, &state_list);
598 if (ACPI_FAILURE (status)) {
599 goto error_exit;
600 }
601 } 506 }
602 break; 507 break;
603 508
604
605 case ACPI_TYPE_REGION: 509 case ACPI_TYPE_REGION:
606 default: 510 default:
607 511 break; /* No subobjects */
608 /* No subobjects */
609 break;
610 } 512 }
611 513
612 /* 514 /*
@@ -614,25 +516,31 @@ acpi_ut_update_object_reference (
614 * happen after we update the sub-objects in case this causes the 516 * happen after we update the sub-objects in case this causes the
615 * main object to be deleted. 517 * main object to be deleted.
616 */ 518 */
617 acpi_ut_update_ref_count (object, action); 519 acpi_ut_update_ref_count(object, action);
520 object = NULL;
618 521
619 /* Move on to the next object to be updated */ 522 /* Move on to the next object to be updated */
620 523
621 state = acpi_ut_pop_generic_state (&state_list); 524 if (next_object) {
525 object = next_object;
526 next_object = NULL;
527 } else if (state_list) {
528 state = acpi_ut_pop_generic_state(&state_list);
529 object = state->update.object;
530 acpi_ut_delete_generic_state(state);
531 }
622 } 532 }
623 533
624 return_ACPI_STATUS (AE_OK); 534 return_ACPI_STATUS(AE_OK);
625
626 535
627error_exit: 536 error_exit:
628 537
629 ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", 538 ACPI_REPORT_ERROR(("Could not update object reference count, %s\n",
630 acpi_format_exception (status))); 539 acpi_format_exception(status)));
631 540
632 return_ACPI_STATUS (status); 541 return_ACPI_STATUS(status);
633} 542}
634 543
635
636/******************************************************************************* 544/*******************************************************************************
637 * 545 *
638 * FUNCTION: acpi_ut_add_reference 546 * FUNCTION: acpi_ut_add_reference
@@ -646,31 +554,27 @@ error_exit:
646 * 554 *
647 ******************************************************************************/ 555 ******************************************************************************/
648 556
649void 557void acpi_ut_add_reference(union acpi_operand_object *object)
650acpi_ut_add_reference (
651 union acpi_operand_object *object)
652{ 558{
653 559
654 ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object); 560 ACPI_FUNCTION_TRACE_PTR("ut_add_reference", object);
655
656 561
657 /* Ensure that we have a valid object */ 562 /* Ensure that we have a valid object */
658 563
659 if (!acpi_ut_valid_internal_object (object)) { 564 if (!acpi_ut_valid_internal_object(object)) {
660 return_VOID; 565 return_VOID;
661 } 566 }
662 567
663 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 568 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
664 "Obj %p Current Refs=%X [To Be Incremented]\n", 569 "Obj %p Current Refs=%X [To Be Incremented]\n",
665 object, object->common.reference_count)); 570 object, object->common.reference_count));
666 571
667 /* Increment the reference count */ 572 /* Increment the reference count */
668 573
669 (void) acpi_ut_update_object_reference (object, REF_INCREMENT); 574 (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
670 return_VOID; 575 return_VOID;
671} 576}
672 577
673
674/******************************************************************************* 578/*******************************************************************************
675 * 579 *
676 * FUNCTION: acpi_ut_remove_reference 580 * FUNCTION: acpi_ut_remove_reference
@@ -683,13 +587,10 @@ acpi_ut_add_reference (
683 * 587 *
684 ******************************************************************************/ 588 ******************************************************************************/
685 589
686void 590void acpi_ut_remove_reference(union acpi_operand_object *object)
687acpi_ut_remove_reference (
688 union acpi_operand_object *object)
689{ 591{
690 592
691 ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object); 593 ACPI_FUNCTION_TRACE_PTR("ut_remove_reference", object);
692
693 594
694 /* 595 /*
695 * Allow a NULL pointer to be passed in, just ignore it. This saves 596 * Allow a NULL pointer to be passed in, just ignore it. This saves
@@ -697,27 +598,25 @@ acpi_ut_remove_reference (
697 * 598 *
698 */ 599 */
699 if (!object || 600 if (!object ||
700 (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) { 601 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
701 return_VOID; 602 return_VOID;
702 } 603 }
703 604
704 /* Ensure that we have a valid object */ 605 /* Ensure that we have a valid object */
705 606
706 if (!acpi_ut_valid_internal_object (object)) { 607 if (!acpi_ut_valid_internal_object(object)) {
707 return_VOID; 608 return_VOID;
708 } 609 }
709 610
710 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 611 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
711 "Obj %p Current Refs=%X [To Be Decremented]\n", 612 "Obj %p Current Refs=%X [To Be Decremented]\n",
712 object, object->common.reference_count)); 613 object, object->common.reference_count));
713 614
714 /* 615 /*
715 * Decrement the reference count, and only actually delete the object 616 * Decrement the reference count, and only actually delete the object
716 * if the reference count becomes 0. (Must also decrement the ref count 617 * if the reference count becomes 0. (Must also decrement the ref count
717 * of all subobjects!) 618 * of all subobjects!)
718 */ 619 */
719 (void) acpi_ut_update_object_reference (object, REF_DECREMENT); 620 (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
720 return_VOID; 621 return_VOID;
721} 622}
722
723
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 00046dd5d925..7b81d5ef3c32 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -41,28 +41,20 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("uteval") 49ACPI_MODULE_NAME("uteval")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static void 52static void
56acpi_ut_copy_id_string ( 53acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length);
57 char *destination,
58 char *source,
59 acpi_size max_length);
60 54
61static acpi_status 55static acpi_status
62acpi_ut_translate_one_cid ( 56acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
63 union acpi_operand_object *obj_desc, 57 struct acpi_compatible_id *one_cid);
64 struct acpi_compatible_id *one_cid);
65
66 58
67/******************************************************************************* 59/*******************************************************************************
68 * 60 *
@@ -77,37 +69,33 @@ acpi_ut_translate_one_cid (
77 * 69 *
78 ******************************************************************************/ 70 ******************************************************************************/
79 71
80acpi_status 72acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
81acpi_ut_osi_implementation (
82 struct acpi_walk_state *walk_state)
83{ 73{
84 union acpi_operand_object *string_desc; 74 union acpi_operand_object *string_desc;
85 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
86 acpi_native_uint i; 76 acpi_native_uint i;
87
88
89 ACPI_FUNCTION_TRACE ("ut_osi_implementation");
90 77
78 ACPI_FUNCTION_TRACE("ut_osi_implementation");
91 79
92 /* Validate the string input argument */ 80 /* Validate the string input argument */
93 81
94 string_desc = walk_state->arguments[0].object; 82 string_desc = walk_state->arguments[0].object;
95 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { 83 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
96 return_ACPI_STATUS (AE_TYPE); 84 return_ACPI_STATUS(AE_TYPE);
97 } 85 }
98 86
99 /* Create a return object (Default value = 0) */ 87 /* Create a return object (Default value = 0) */
100 88
101 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 89 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
102 if (!return_desc) { 90 if (!return_desc) {
103 return_ACPI_STATUS (AE_NO_MEMORY); 91 return_ACPI_STATUS(AE_NO_MEMORY);
104 } 92 }
105 93
106 /* Compare input string to table of supported strings */ 94 /* Compare input string to table of supported strings */
107 95
108 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { 96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) {
109 if (!ACPI_STRCMP (string_desc->string.pointer, 97 if (!ACPI_STRCMP(string_desc->string.pointer,
110 (char *) acpi_gbl_valid_osi_strings[i])) { 98 (char *)acpi_gbl_valid_osi_strings[i])) {
111 /* This string is supported */ 99 /* This string is supported */
112 100
113 return_desc->integer.value = 0xFFFFFFFF; 101 return_desc->integer.value = 0xFFFFFFFF;
@@ -116,10 +104,9 @@ acpi_ut_osi_implementation (
116 } 104 }
117 105
118 walk_state->return_desc = return_desc; 106 walk_state->return_desc = return_desc;
119 return_ACPI_STATUS (AE_CTRL_TERMINATE); 107 return_ACPI_STATUS(AE_CTRL_TERMINATE);
120} 108}
121 109
122
123/******************************************************************************* 110/*******************************************************************************
124 * 111 *
125 * FUNCTION: acpi_ut_evaluate_object 112 * FUNCTION: acpi_ut_evaluate_object
@@ -140,19 +127,16 @@ acpi_ut_osi_implementation (
140 ******************************************************************************/ 127 ******************************************************************************/
141 128
142acpi_status 129acpi_status
143acpi_ut_evaluate_object ( 130acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
144 struct acpi_namespace_node *prefix_node, 131 char *path,
145 char *path, 132 u32 expected_return_btypes,
146 u32 expected_return_btypes, 133 union acpi_operand_object **return_desc)
147 union acpi_operand_object **return_desc)
148{ 134{
149 struct acpi_parameter_info info; 135 struct acpi_parameter_info info;
150 acpi_status status; 136 acpi_status status;
151 u32 return_btype; 137 u32 return_btype;
152
153
154 ACPI_FUNCTION_TRACE ("ut_evaluate_object");
155 138
139 ACPI_FUNCTION_TRACE("ut_evaluate_object");
156 140
157 info.node = prefix_node; 141 info.node = prefix_node;
158 info.parameters = NULL; 142 info.parameters = NULL;
@@ -160,36 +144,38 @@ acpi_ut_evaluate_object (
160 144
161 /* Evaluate the object/method */ 145 /* Evaluate the object/method */
162 146
163 status = acpi_ns_evaluate_relative (path, &info); 147 status = acpi_ns_evaluate_relative(path, &info);
164 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
165 if (status == AE_NOT_FOUND) { 149 if (status == AE_NOT_FOUND) {
166 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", 150 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
167 acpi_ut_get_node_name (prefix_node), path)); 151 "[%4.4s.%s] was not found\n",
168 } 152 acpi_ut_get_node_name(prefix_node),
169 else { 153 path));
170 ACPI_REPORT_METHOD_ERROR ("Method execution failed", 154 } else {
171 prefix_node, path, status); 155 ACPI_REPORT_METHOD_ERROR("Method execution failed",
156 prefix_node, path, status);
172 } 157 }
173 158
174 return_ACPI_STATUS (status); 159 return_ACPI_STATUS(status);
175 } 160 }
176 161
177 /* Did we get a return object? */ 162 /* Did we get a return object? */
178 163
179 if (!info.return_object) { 164 if (!info.return_object) {
180 if (expected_return_btypes) { 165 if (expected_return_btypes) {
181 ACPI_REPORT_METHOD_ERROR ("No object was returned from", 166 ACPI_REPORT_METHOD_ERROR("No object was returned from",
182 prefix_node, path, AE_NOT_EXIST); 167 prefix_node, path,
168 AE_NOT_EXIST);
183 169
184 return_ACPI_STATUS (AE_NOT_EXIST); 170 return_ACPI_STATUS(AE_NOT_EXIST);
185 } 171 }
186 172
187 return_ACPI_STATUS (AE_OK); 173 return_ACPI_STATUS(AE_OK);
188 } 174 }
189 175
190 /* Map the return object type to the bitmapped type */ 176 /* Map the return object type to the bitmapped type */
191 177
192 switch (ACPI_GET_OBJECT_TYPE (info.return_object)) { 178 switch (ACPI_GET_OBJECT_TYPE(info.return_object)) {
193 case ACPI_TYPE_INTEGER: 179 case ACPI_TYPE_INTEGER:
194 return_btype = ACPI_BTYPE_INTEGER; 180 return_btype = ACPI_BTYPE_INTEGER;
195 break; 181 break;
@@ -211,41 +197,41 @@ acpi_ut_evaluate_object (
211 break; 197 break;
212 } 198 }
213 199
214 if ((acpi_gbl_enable_interpreter_slack) && 200 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
215 (!expected_return_btypes)) {
216 /* 201 /*
217 * We received a return object, but one was not expected. This can 202 * We received a return object, but one was not expected. This can
218 * happen frequently if the "implicit return" feature is enabled. 203 * happen frequently if the "implicit return" feature is enabled.
219 * Just delete the return object and return AE_OK. 204 * Just delete the return object and return AE_OK.
220 */ 205 */
221 acpi_ut_remove_reference (info.return_object); 206 acpi_ut_remove_reference(info.return_object);
222 return_ACPI_STATUS (AE_OK); 207 return_ACPI_STATUS(AE_OK);
223 } 208 }
224 209
225 /* Is the return object one of the expected types? */ 210 /* Is the return object one of the expected types? */
226 211
227 if (!(expected_return_btypes & return_btype)) { 212 if (!(expected_return_btypes & return_btype)) {
228 ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect", 213 ACPI_REPORT_METHOD_ERROR("Return object type is incorrect",
229 prefix_node, path, AE_TYPE); 214 prefix_node, path, AE_TYPE);
230 215
231 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
232 "Type returned from %s was incorrect: %s, expected Btypes: %X\n", 217 "Type returned from %s was incorrect: %s, expected Btypes: %X\n",
233 path, acpi_ut_get_object_type_name (info.return_object), 218 path,
234 expected_return_btypes)); 219 acpi_ut_get_object_type_name(info.
220 return_object),
221 expected_return_btypes));
235 222
236 /* On error exit, we must delete the return object */ 223 /* On error exit, we must delete the return object */
237 224
238 acpi_ut_remove_reference (info.return_object); 225 acpi_ut_remove_reference(info.return_object);
239 return_ACPI_STATUS (AE_TYPE); 226 return_ACPI_STATUS(AE_TYPE);
240 } 227 }
241 228
242 /* Object type is OK, return it */ 229 /* Object type is OK, return it */
243 230
244 *return_desc = info.return_object; 231 *return_desc = info.return_object;
245 return_ACPI_STATUS (AE_OK); 232 return_ACPI_STATUS(AE_OK);
246} 233}
247 234
248
249/******************************************************************************* 235/*******************************************************************************
250 * 236 *
251 * FUNCTION: acpi_ut_evaluate_numeric_object 237 * FUNCTION: acpi_ut_evaluate_numeric_object
@@ -264,22 +250,19 @@ acpi_ut_evaluate_object (
264 ******************************************************************************/ 250 ******************************************************************************/
265 251
266acpi_status 252acpi_status
267acpi_ut_evaluate_numeric_object ( 253acpi_ut_evaluate_numeric_object(char *object_name,
268 char *object_name, 254 struct acpi_namespace_node *device_node,
269 struct acpi_namespace_node *device_node, 255 acpi_integer * address)
270 acpi_integer *address)
271{ 256{
272 union acpi_operand_object *obj_desc; 257 union acpi_operand_object *obj_desc;
273 acpi_status status; 258 acpi_status status;
274
275 259
276 ACPI_FUNCTION_TRACE ("ut_evaluate_numeric_object"); 260 ACPI_FUNCTION_TRACE("ut_evaluate_numeric_object");
277 261
278 262 status = acpi_ut_evaluate_object(device_node, object_name,
279 status = acpi_ut_evaluate_object (device_node, object_name, 263 ACPI_BTYPE_INTEGER, &obj_desc);
280 ACPI_BTYPE_INTEGER, &obj_desc); 264 if (ACPI_FAILURE(status)) {
281 if (ACPI_FAILURE (status)) { 265 return_ACPI_STATUS(status);
282 return_ACPI_STATUS (status);
283 } 266 }
284 267
285 /* Get the returned Integer */ 268 /* Get the returned Integer */
@@ -288,11 +271,10 @@ acpi_ut_evaluate_numeric_object (
288 271
289 /* On exit, we must delete the return object */ 272 /* On exit, we must delete the return object */
290 273
291 acpi_ut_remove_reference (obj_desc); 274 acpi_ut_remove_reference(obj_desc);
292 return_ACPI_STATUS (status); 275 return_ACPI_STATUS(status);
293} 276}
294 277
295
296/******************************************************************************* 278/*******************************************************************************
297 * 279 *
298 * FUNCTION: acpi_ut_copy_id_string 280 * FUNCTION: acpi_ut_copy_id_string
@@ -310,10 +292,7 @@ acpi_ut_evaluate_numeric_object (
310 ******************************************************************************/ 292 ******************************************************************************/
311 293
312static void 294static void
313acpi_ut_copy_id_string ( 295acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
314 char *destination,
315 char *source,
316 acpi_size max_length)
317{ 296{
318 297
319 /* 298 /*
@@ -328,10 +307,9 @@ acpi_ut_copy_id_string (
328 307
329 /* Do the actual copy */ 308 /* Do the actual copy */
330 309
331 ACPI_STRNCPY (destination, source, max_length); 310 ACPI_STRNCPY(destination, source, max_length);
332} 311}
333 312
334
335/******************************************************************************* 313/*******************************************************************************
336 * 314 *
337 * FUNCTION: acpi_ut_execute_HID 315 * FUNCTION: acpi_ut_execute_HID
@@ -349,42 +327,39 @@ acpi_ut_copy_id_string (
349 ******************************************************************************/ 327 ******************************************************************************/
350 328
351acpi_status 329acpi_status
352acpi_ut_execute_HID ( 330acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
353 struct acpi_namespace_node *device_node, 331 struct acpi_device_id *hid)
354 struct acpi_device_id *hid)
355{ 332{
356 union acpi_operand_object *obj_desc; 333 union acpi_operand_object *obj_desc;
357 acpi_status status; 334 acpi_status status;
358
359 335
360 ACPI_FUNCTION_TRACE ("ut_execute_HID"); 336 ACPI_FUNCTION_TRACE("ut_execute_HID");
361 337
362 338 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
363 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__HID, 339 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
364 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); 340 &obj_desc);
365 if (ACPI_FAILURE (status)) { 341 if (ACPI_FAILURE(status)) {
366 return_ACPI_STATUS (status); 342 return_ACPI_STATUS(status);
367 } 343 }
368 344
369 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 345 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
370 /* Convert the Numeric HID to string */ 346 /* Convert the Numeric HID to string */
371 347
372 acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->value); 348 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
373 } 349 hid->value);
374 else { 350 } else {
375 /* Copy the String HID from the returned object */ 351 /* Copy the String HID from the returned object */
376 352
377 acpi_ut_copy_id_string (hid->value, obj_desc->string.pointer, 353 acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer,
378 sizeof (hid->value)); 354 sizeof(hid->value));
379 } 355 }
380 356
381 /* On exit, we must delete the return object */ 357 /* On exit, we must delete the return object */
382 358
383 acpi_ut_remove_reference (obj_desc); 359 acpi_ut_remove_reference(obj_desc);
384 return_ACPI_STATUS (status); 360 return_ACPI_STATUS(status);
385} 361}
386 362
387
388/******************************************************************************* 363/*******************************************************************************
389 * 364 *
390 * FUNCTION: acpi_ut_translate_one_cid 365 * FUNCTION: acpi_ut_translate_one_cid
@@ -403,18 +378,17 @@ acpi_ut_execute_HID (
403 ******************************************************************************/ 378 ******************************************************************************/
404 379
405static acpi_status 380static acpi_status
406acpi_ut_translate_one_cid ( 381acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
407 union acpi_operand_object *obj_desc, 382 struct acpi_compatible_id *one_cid)
408 struct acpi_compatible_id *one_cid)
409{ 383{
410 384
411 385 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
412 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
413 case ACPI_TYPE_INTEGER: 386 case ACPI_TYPE_INTEGER:
414 387
415 /* Convert the Numeric CID to string */ 388 /* Convert the Numeric CID to string */
416 389
417 acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value); 390 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
391 one_cid->value);
418 return (AE_OK); 392 return (AE_OK);
419 393
420 case ACPI_TYPE_STRING: 394 case ACPI_TYPE_STRING:
@@ -425,8 +399,8 @@ acpi_ut_translate_one_cid (
425 399
426 /* Copy the String CID from the returned object */ 400 /* Copy the String CID from the returned object */
427 401
428 acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer, 402 acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer,
429 ACPI_MAX_CID_LENGTH); 403 ACPI_MAX_CID_LENGTH);
430 return (AE_OK); 404 return (AE_OK);
431 405
432 default: 406 default:
@@ -435,7 +409,6 @@ acpi_ut_translate_one_cid (
435 } 409 }
436} 410}
437 411
438
439/******************************************************************************* 412/*******************************************************************************
440 * 413 *
441 * FUNCTION: acpi_ut_execute_CID 414 * FUNCTION: acpi_ut_execute_CID
@@ -453,45 +426,42 @@ acpi_ut_translate_one_cid (
453 ******************************************************************************/ 426 ******************************************************************************/
454 427
455acpi_status 428acpi_status
456acpi_ut_execute_CID ( 429acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
457 struct acpi_namespace_node *device_node, 430 struct acpi_compatible_id_list ** return_cid_list)
458 struct acpi_compatible_id_list **return_cid_list)
459{ 431{
460 union acpi_operand_object *obj_desc; 432 union acpi_operand_object *obj_desc;
461 acpi_status status; 433 acpi_status status;
462 u32 count; 434 u32 count;
463 u32 size; 435 u32 size;
464 struct acpi_compatible_id_list *cid_list; 436 struct acpi_compatible_id_list *cid_list;
465 acpi_native_uint i; 437 acpi_native_uint i;
466
467
468 ACPI_FUNCTION_TRACE ("ut_execute_CID");
469 438
439 ACPI_FUNCTION_TRACE("ut_execute_CID");
470 440
471 /* Evaluate the _CID method for this device */ 441 /* Evaluate the _CID method for this device */
472 442
473 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__CID, 443 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
474 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, 444 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
475 &obj_desc); 445 | ACPI_BTYPE_PACKAGE, &obj_desc);
476 if (ACPI_FAILURE (status)) { 446 if (ACPI_FAILURE(status)) {
477 return_ACPI_STATUS (status); 447 return_ACPI_STATUS(status);
478 } 448 }
479 449
480 /* Get the number of _CIDs returned */ 450 /* Get the number of _CIDs returned */
481 451
482 count = 1; 452 count = 1;
483 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { 453 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
484 count = obj_desc->package.count; 454 count = obj_desc->package.count;
485 } 455 }
486 456
487 /* Allocate a worst-case buffer for the _CIDs */ 457 /* Allocate a worst-case buffer for the _CIDs */
488 458
489 size = (((count - 1) * sizeof (struct acpi_compatible_id)) + 459 size = (((count - 1) * sizeof(struct acpi_compatible_id)) +
490 sizeof (struct acpi_compatible_id_list)); 460 sizeof(struct acpi_compatible_id_list));
491 461
492 cid_list = ACPI_MEM_CALLOCATE ((acpi_size) size); 462 cid_list = ACPI_MEM_CALLOCATE((acpi_size) size);
493 if (!cid_list) { 463 if (!cid_list) {
494 return_ACPI_STATUS (AE_NO_MEMORY); 464 return_ACPI_STATUS(AE_NO_MEMORY);
495 } 465 }
496 466
497 /* Init CID list */ 467 /* Init CID list */
@@ -508,39 +478,38 @@ acpi_ut_execute_CID (
508 478
509 /* The _CID object can be either a single CID or a package (list) of CIDs */ 479 /* The _CID object can be either a single CID or a package (list) of CIDs */
510 480
511 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { 481 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
512 /* Translate each package element */ 482 /* Translate each package element */
513 483
514 for (i = 0; i < count; i++) { 484 for (i = 0; i < count; i++) {
515 status = acpi_ut_translate_one_cid (obj_desc->package.elements[i], 485 status =
516 &cid_list->id[i]); 486 acpi_ut_translate_one_cid(obj_desc->package.
517 if (ACPI_FAILURE (status)) { 487 elements[i],
488 &cid_list->id[i]);
489 if (ACPI_FAILURE(status)) {
518 break; 490 break;
519 } 491 }
520 } 492 }
521 } 493 } else {
522 else {
523 /* Only one CID, translate to a string */ 494 /* Only one CID, translate to a string */
524 495
525 status = acpi_ut_translate_one_cid (obj_desc, cid_list->id); 496 status = acpi_ut_translate_one_cid(obj_desc, cid_list->id);
526 } 497 }
527 498
528 /* Cleanup on error */ 499 /* Cleanup on error */
529 500
530 if (ACPI_FAILURE (status)) { 501 if (ACPI_FAILURE(status)) {
531 ACPI_MEM_FREE (cid_list); 502 ACPI_MEM_FREE(cid_list);
532 } 503 } else {
533 else {
534 *return_cid_list = cid_list; 504 *return_cid_list = cid_list;
535 } 505 }
536 506
537 /* On exit, we must delete the _CID return object */ 507 /* On exit, we must delete the _CID return object */
538 508
539 acpi_ut_remove_reference (obj_desc); 509 acpi_ut_remove_reference(obj_desc);
540 return_ACPI_STATUS (status); 510 return_ACPI_STATUS(status);
541} 511}
542 512
543
544/******************************************************************************* 513/*******************************************************************************
545 * 514 *
546 * FUNCTION: acpi_ut_execute_UID 515 * FUNCTION: acpi_ut_execute_UID
@@ -558,42 +527,39 @@ acpi_ut_execute_CID (
558 ******************************************************************************/ 527 ******************************************************************************/
559 528
560acpi_status 529acpi_status
561acpi_ut_execute_UID ( 530acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
562 struct acpi_namespace_node *device_node, 531 struct acpi_device_id *uid)
563 struct acpi_device_id *uid)
564{ 532{
565 union acpi_operand_object *obj_desc; 533 union acpi_operand_object *obj_desc;
566 acpi_status status; 534 acpi_status status;
567
568
569 ACPI_FUNCTION_TRACE ("ut_execute_UID");
570 535
536 ACPI_FUNCTION_TRACE("ut_execute_UID");
571 537
572 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID, 538 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
573 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); 539 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
574 if (ACPI_FAILURE (status)) { 540 &obj_desc);
575 return_ACPI_STATUS (status); 541 if (ACPI_FAILURE(status)) {
542 return_ACPI_STATUS(status);
576 } 543 }
577 544
578 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 545 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
579 /* Convert the Numeric UID to string */ 546 /* Convert the Numeric UID to string */
580 547
581 acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value); 548 acpi_ex_unsigned_integer_to_string(obj_desc->integer.value,
582 } 549 uid->value);
583 else { 550 } else {
584 /* Copy the String UID from the returned object */ 551 /* Copy the String UID from the returned object */
585 552
586 acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer, 553 acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer,
587 sizeof (uid->value)); 554 sizeof(uid->value));
588 } 555 }
589 556
590 /* On exit, we must delete the return object */ 557 /* On exit, we must delete the return object */
591 558
592 acpi_ut_remove_reference (obj_desc); 559 acpi_ut_remove_reference(obj_desc);
593 return_ACPI_STATUS (status); 560 return_ACPI_STATUS(status);
594} 561}
595 562
596
597/******************************************************************************* 563/*******************************************************************************
598 * 564 *
599 * FUNCTION: acpi_ut_execute_STA 565 * FUNCTION: acpi_ut_execute_STA
@@ -611,30 +577,26 @@ acpi_ut_execute_UID (
611 ******************************************************************************/ 577 ******************************************************************************/
612 578
613acpi_status 579acpi_status
614acpi_ut_execute_STA ( 580acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
615 struct acpi_namespace_node *device_node,
616 u32 *flags)
617{ 581{
618 union acpi_operand_object *obj_desc; 582 union acpi_operand_object *obj_desc;
619 acpi_status status; 583 acpi_status status;
620
621 584
622 ACPI_FUNCTION_TRACE ("ut_execute_STA"); 585 ACPI_FUNCTION_TRACE("ut_execute_STA");
623 586
624 587 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
625 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__STA, 588 ACPI_BTYPE_INTEGER, &obj_desc);
626 ACPI_BTYPE_INTEGER, &obj_desc); 589 if (ACPI_FAILURE(status)) {
627 if (ACPI_FAILURE (status)) {
628 if (AE_NOT_FOUND == status) { 590 if (AE_NOT_FOUND == status) {
629 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 591 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
630 "_STA on %4.4s was not found, assuming device is present\n", 592 "_STA on %4.4s was not found, assuming device is present\n",
631 acpi_ut_get_node_name (device_node))); 593 acpi_ut_get_node_name(device_node)));
632 594
633 *flags = 0x0F; 595 *flags = 0x0F;
634 status = AE_OK; 596 status = AE_OK;
635 } 597 }
636 598
637 return_ACPI_STATUS (status); 599 return_ACPI_STATUS(status);
638 } 600 }
639 601
640 /* Extract the status flags */ 602 /* Extract the status flags */
@@ -643,11 +605,10 @@ acpi_ut_execute_STA (
643 605
644 /* On exit, we must delete the return object */ 606 /* On exit, we must delete the return object */
645 607
646 acpi_ut_remove_reference (obj_desc); 608 acpi_ut_remove_reference(obj_desc);
647 return_ACPI_STATUS (status); 609 return_ACPI_STATUS(status);
648} 610}
649 611
650
651/******************************************************************************* 612/*******************************************************************************
652 * 613 *
653 * FUNCTION: acpi_ut_execute_Sxds 614 * FUNCTION: acpi_ut_execute_Sxds
@@ -665,44 +626,45 @@ acpi_ut_execute_STA (
665 ******************************************************************************/ 626 ******************************************************************************/
666 627
667acpi_status 628acpi_status
668acpi_ut_execute_sxds ( 629acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
669 struct acpi_namespace_node *device_node,
670 u8 *highest)
671{ 630{
672 union acpi_operand_object *obj_desc; 631 union acpi_operand_object *obj_desc;
673 acpi_status status; 632 acpi_status status;
674 u32 i; 633 u32 i;
675
676
677 ACPI_FUNCTION_TRACE ("ut_execute_Sxds");
678 634
635 ACPI_FUNCTION_TRACE("ut_execute_Sxds");
679 636
680 for (i = 0; i < 4; i++) { 637 for (i = 0; i < 4; i++) {
681 highest[i] = 0xFF; 638 highest[i] = 0xFF;
682 status = acpi_ut_evaluate_object (device_node, 639 status = acpi_ut_evaluate_object(device_node,
683 (char *) acpi_gbl_highest_dstate_names[i], 640 (char *)
684 ACPI_BTYPE_INTEGER, &obj_desc); 641 acpi_gbl_highest_dstate_names
685 if (ACPI_FAILURE (status)) { 642 [i], ACPI_BTYPE_INTEGER,
643 &obj_desc);
644 if (ACPI_FAILURE(status)) {
686 if (status != AE_NOT_FOUND) { 645 if (status != AE_NOT_FOUND) {
687 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
688 "%s on Device %4.4s, %s\n", 647 "%s on Device %4.4s, %s\n",
689 (char *) acpi_gbl_highest_dstate_names[i], 648 (char *)
690 acpi_ut_get_node_name (device_node), 649 acpi_gbl_highest_dstate_names
691 acpi_format_exception (status))); 650 [i],
692 651 acpi_ut_get_node_name
693 return_ACPI_STATUS (status); 652 (device_node),
653 acpi_format_exception
654 (status)));
655
656 return_ACPI_STATUS(status);
694 } 657 }
695 } 658 } else {
696 else {
697 /* Extract the Dstate value */ 659 /* Extract the Dstate value */
698 660
699 highest[i] = (u8) obj_desc->integer.value; 661 highest[i] = (u8) obj_desc->integer.value;
700 662
701 /* Delete the return object */ 663 /* Delete the return object */
702 664
703 acpi_ut_remove_reference (obj_desc); 665 acpi_ut_remove_reference(obj_desc);
704 } 666 }
705 } 667 }
706 668
707 return_ACPI_STATUS (AE_OK); 669 return_ACPI_STATUS(AE_OK);
708} 670}
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 4146019b543f..399e64b51886 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -48,8 +48,7 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utglobal") 51ACPI_MODULE_NAME("utglobal")
52
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -63,17 +62,12 @@
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string. 62 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
64 * 63 *
65 ******************************************************************************/ 64 ******************************************************************************/
66 65const char *acpi_format_exception(acpi_status status)
67const char *
68acpi_format_exception (
69 acpi_status status)
70{ 66{
71 acpi_status sub_status; 67 acpi_status sub_status;
72 const char *exception = NULL; 68 const char *exception = NULL;
73
74
75 ACPI_FUNCTION_NAME ("format_exception");
76 69
70 ACPI_FUNCTION_NAME("format_exception");
77 71
78 sub_status = (status & ~AE_CODE_MASK); 72 sub_status = (status & ~AE_CODE_MASK);
79 73
@@ -81,35 +75,39 @@ acpi_format_exception (
81 case AE_CODE_ENVIRONMENTAL: 75 case AE_CODE_ENVIRONMENTAL:
82 76
83 if (sub_status <= AE_CODE_ENV_MAX) { 77 if (sub_status <= AE_CODE_ENV_MAX) {
84 exception = acpi_gbl_exception_names_env [sub_status]; 78 exception = acpi_gbl_exception_names_env[sub_status];
85 } 79 }
86 break; 80 break;
87 81
88 case AE_CODE_PROGRAMMER: 82 case AE_CODE_PROGRAMMER:
89 83
90 if (sub_status <= AE_CODE_PGM_MAX) { 84 if (sub_status <= AE_CODE_PGM_MAX) {
91 exception = acpi_gbl_exception_names_pgm [sub_status -1]; 85 exception =
86 acpi_gbl_exception_names_pgm[sub_status - 1];
92 } 87 }
93 break; 88 break;
94 89
95 case AE_CODE_ACPI_TABLES: 90 case AE_CODE_ACPI_TABLES:
96 91
97 if (sub_status <= AE_CODE_TBL_MAX) { 92 if (sub_status <= AE_CODE_TBL_MAX) {
98 exception = acpi_gbl_exception_names_tbl [sub_status -1]; 93 exception =
94 acpi_gbl_exception_names_tbl[sub_status - 1];
99 } 95 }
100 break; 96 break;
101 97
102 case AE_CODE_AML: 98 case AE_CODE_AML:
103 99
104 if (sub_status <= AE_CODE_AML_MAX) { 100 if (sub_status <= AE_CODE_AML_MAX) {
105 exception = acpi_gbl_exception_names_aml [sub_status -1]; 101 exception =
102 acpi_gbl_exception_names_aml[sub_status - 1];
106 } 103 }
107 break; 104 break;
108 105
109 case AE_CODE_CONTROL: 106 case AE_CODE_CONTROL:
110 107
111 if (sub_status <= AE_CODE_CTRL_MAX) { 108 if (sub_status <= AE_CODE_CTRL_MAX) {
112 exception = acpi_gbl_exception_names_ctrl [sub_status -1]; 109 exception =
110 acpi_gbl_exception_names_ctrl[sub_status - 1];
113 } 111 }
114 break; 112 break;
115 113
@@ -120,16 +118,15 @@ acpi_format_exception (
120 if (!exception) { 118 if (!exception) {
121 /* Exception code was not recognized */ 119 /* Exception code was not recognized */
122 120
123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
124 "Unknown exception code: 0x%8.8X\n", status)); 122 "Unknown exception code: 0x%8.8X\n", status));
125 123
126 return ((const char *) "UNKNOWN_STATUS_CODE"); 124 return ((const char *)"UNKNOWN_STATUS_CODE");
127 } 125 }
128 126
129 return ((const char *) exception); 127 return ((const char *)exception);
130} 128}
131 129
132
133/******************************************************************************* 130/*******************************************************************************
134 * 131 *
135 * Static global variable initialization. 132 * Static global variable initialization.
@@ -142,34 +139,32 @@ acpi_format_exception (
142 */ 139 */
143 140
144/* Debug switch - level and trace mask */ 141/* Debug switch - level and trace mask */
145u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; 142u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
146EXPORT_SYMBOL(acpi_dbg_level); 143EXPORT_SYMBOL(acpi_dbg_level);
147 144
148/* Debug switch - layer (component) mask */ 145/* Debug switch - layer (component) mask */
149 146
150u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; 147u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
151EXPORT_SYMBOL(acpi_dbg_layer); 148EXPORT_SYMBOL(acpi_dbg_layer);
152u32 acpi_gbl_nesting_level = 0; 149u32 acpi_gbl_nesting_level = 0;
153
154 150
155/* Debugger globals */ 151/* Debugger globals */
156 152
157u8 acpi_gbl_db_terminate_threads = FALSE; 153u8 acpi_gbl_db_terminate_threads = FALSE;
158u8 acpi_gbl_abort_method = FALSE; 154u8 acpi_gbl_abort_method = FALSE;
159u8 acpi_gbl_method_executing = FALSE; 155u8 acpi_gbl_method_executing = FALSE;
160 156
161/* System flags */ 157/* System flags */
162 158
163u32 acpi_gbl_startup_flags = 0; 159u32 acpi_gbl_startup_flags = 0;
164 160
165/* System starts uninitialized */ 161/* System starts uninitialized */
166 162
167u8 acpi_gbl_shutdown = TRUE; 163u8 acpi_gbl_shutdown = TRUE;
168 164
169const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128}; 165const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
170 166
171const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = 167const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
172{
173 "\\_S0_", 168 "\\_S0_",
174 "\\_S1_", 169 "\\_S1_",
175 "\\_S2_", 170 "\\_S2_",
@@ -178,8 +173,7 @@ const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COU
178 "\\_S5_" 173 "\\_S5_"
179}; 174};
180 175
181const char *acpi_gbl_highest_dstate_names[4] = 176const char *acpi_gbl_highest_dstate_names[4] = {
182{
183 "_S1D", 177 "_S1D",
184 "_S2D", 178 "_S2D",
185 "_S3D", 179 "_S3D",
@@ -190,8 +184,7 @@ const char *acpi_gbl_highest_dstate_names[4] =
190 * Strings supported by the _OSI predefined (internal) method. 184 * Strings supported by the _OSI predefined (internal) method.
191 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. 185 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
192 */ 186 */
193const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = 187const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
194{
195 /* Operating System Vendor Strings */ 188 /* Operating System Vendor Strings */
196 189
197 "Linux", 190 "Linux",
@@ -209,7 +202,6 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
209 "Extended Address Space Descriptor" 202 "Extended Address Space Descriptor"
210}; 203};
211 204
212
213/******************************************************************************* 205/*******************************************************************************
214 * 206 *
215 * Namespace globals 207 * Namespace globals
@@ -225,74 +217,70 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
225 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
226 * perform a Notify() operation on it. 218 * perform a Notify() operation on it.
227 */ 219 */
228const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = 220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
229{ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 221 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
230 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 222{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
231 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 223{"_SB_", ACPI_TYPE_DEVICE, NULL},
232 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 224{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
233 {"_TZ_", ACPI_TYPE_THERMAL, NULL}, 225{"_TZ_", ACPI_TYPE_THERMAL, NULL},
234 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 226{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
235 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 227{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
236 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 228{"_GL_", ACPI_TYPE_MUTEX, (char *)1},
237 229
238#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
239 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 231{"_OSI", ACPI_TYPE_METHOD, (char *)1},
240#endif 232#endif
241 233
242 /* Table terminator */ 234 /* Table terminator */
243 235
244 {NULL, ACPI_TYPE_ANY, NULL} 236{NULL, ACPI_TYPE_ANY, NULL}
245}; 237};
246 238
247/* 239/*
248 * Properties of the ACPI Object Types, both internal and external. 240 * Properties of the ACPI Object Types, both internal and external.
249 * The table is indexed by values of acpi_object_type 241 * The table is indexed by values of acpi_object_type
250 */ 242 */
251const u8 acpi_gbl_ns_properties[] = 243const u8 acpi_gbl_ns_properties[] = {
252{ 244 ACPI_NS_NORMAL, /* 00 Any */
253 ACPI_NS_NORMAL, /* 00 Any */ 245 ACPI_NS_NORMAL, /* 01 Number */
254 ACPI_NS_NORMAL, /* 01 Number */ 246 ACPI_NS_NORMAL, /* 02 String */
255 ACPI_NS_NORMAL, /* 02 String */ 247 ACPI_NS_NORMAL, /* 03 Buffer */
256 ACPI_NS_NORMAL, /* 03 Buffer */ 248 ACPI_NS_NORMAL, /* 04 Package */
257 ACPI_NS_NORMAL, /* 04 Package */ 249 ACPI_NS_NORMAL, /* 05 field_unit */
258 ACPI_NS_NORMAL, /* 05 field_unit */ 250 ACPI_NS_NEWSCOPE, /* 06 Device */
259 ACPI_NS_NEWSCOPE, /* 06 Device */ 251 ACPI_NS_NORMAL, /* 07 Event */
260 ACPI_NS_NORMAL, /* 07 Event */ 252 ACPI_NS_NEWSCOPE, /* 08 Method */
261 ACPI_NS_NEWSCOPE, /* 08 Method */ 253 ACPI_NS_NORMAL, /* 09 Mutex */
262 ACPI_NS_NORMAL, /* 09 Mutex */ 254 ACPI_NS_NORMAL, /* 10 Region */
263 ACPI_NS_NORMAL, /* 10 Region */ 255 ACPI_NS_NEWSCOPE, /* 11 Power */
264 ACPI_NS_NEWSCOPE, /* 11 Power */ 256 ACPI_NS_NEWSCOPE, /* 12 Processor */
265 ACPI_NS_NEWSCOPE, /* 12 Processor */ 257 ACPI_NS_NEWSCOPE, /* 13 Thermal */
266 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 258 ACPI_NS_NORMAL, /* 14 buffer_field */
267 ACPI_NS_NORMAL, /* 14 buffer_field */ 259 ACPI_NS_NORMAL, /* 15 ddb_handle */
268 ACPI_NS_NORMAL, /* 15 ddb_handle */ 260 ACPI_NS_NORMAL, /* 16 Debug Object */
269 ACPI_NS_NORMAL, /* 16 Debug Object */ 261 ACPI_NS_NORMAL, /* 17 def_field */
270 ACPI_NS_NORMAL, /* 17 def_field */ 262 ACPI_NS_NORMAL, /* 18 bank_field */
271 ACPI_NS_NORMAL, /* 18 bank_field */ 263 ACPI_NS_NORMAL, /* 19 index_field */
272 ACPI_NS_NORMAL, /* 19 index_field */ 264 ACPI_NS_NORMAL, /* 20 Reference */
273 ACPI_NS_NORMAL, /* 20 Reference */ 265 ACPI_NS_NORMAL, /* 21 Alias */
274 ACPI_NS_NORMAL, /* 21 Alias */ 266 ACPI_NS_NORMAL, /* 22 method_alias */
275 ACPI_NS_NORMAL, /* 22 method_alias */ 267 ACPI_NS_NORMAL, /* 23 Notify */
276 ACPI_NS_NORMAL, /* 23 Notify */ 268 ACPI_NS_NORMAL, /* 24 Address Handler */
277 ACPI_NS_NORMAL, /* 24 Address Handler */ 269 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
278 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 270 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
279 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 271 ACPI_NS_NEWSCOPE, /* 27 Scope */
280 ACPI_NS_NEWSCOPE, /* 27 Scope */ 272 ACPI_NS_NORMAL, /* 28 Extra */
281 ACPI_NS_NORMAL, /* 28 Extra */ 273 ACPI_NS_NORMAL, /* 29 Data */
282 ACPI_NS_NORMAL, /* 29 Data */ 274 ACPI_NS_NORMAL /* 30 Invalid */
283 ACPI_NS_NORMAL /* 30 Invalid */
284}; 275};
285 276
286
287/* Hex to ASCII conversion table */ 277/* Hex to ASCII conversion table */
288 278
289static const char acpi_gbl_hex_to_ascii[] = 279static const char acpi_gbl_hex_to_ascii[] = {
290{ 280 '0', '1', '2', '3', '4', '5', '6', '7',
291 '0','1','2','3','4','5','6','7', 281 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
292 '8','9','A','B','C','D','E','F'
293}; 282};
294 283
295
296/******************************************************************************* 284/*******************************************************************************
297 * 285 *
298 * FUNCTION: acpi_ut_hex_to_ascii_char 286 * FUNCTION: acpi_ut_hex_to_ascii_char
@@ -307,16 +295,12 @@ static const char acpi_gbl_hex_to_ascii[] =
307 * 295 *
308 ******************************************************************************/ 296 ******************************************************************************/
309 297
310char 298char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
311acpi_ut_hex_to_ascii_char (
312 acpi_integer integer,
313 u32 position)
314{ 299{
315 300
316 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 301 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
317} 302}
318 303
319
320/******************************************************************************* 304/*******************************************************************************
321 * 305 *
322 * Table name globals 306 * Table name globals
@@ -330,67 +314,139 @@ acpi_ut_hex_to_ascii_char (
330 * 314 *
331 ******************************************************************************/ 315 ******************************************************************************/
332 316
333struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; 317struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
334 318
335struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = 319struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = {
336{
337 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ 320 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
338 321
339 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 322 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
340 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, 323 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
341 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, 324 ,
342 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, 325 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
343 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 326 sizeof(DSDT_SIG) - 1,
344 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 327 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
345 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 328 ACPI_TABLE_EXECUTABLE}
329 ,
330 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
331 sizeof(FADT_SIG) - 1,
332 ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
333 ,
334 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
335 sizeof(FACS_SIG) - 1,
336 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
337 ,
338 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
339 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
340 ACPI_TABLE_EXECUTABLE}
341 ,
342 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
343 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
344 ACPI_TABLE_EXECUTABLE}
345 ,
346 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
347 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
348 ,
346}; 349};
347 350
348
349/****************************************************************************** 351/******************************************************************************
350 * 352 *
351 * Event and Hardware globals 353 * Event and Hardware globals
352 * 354 *
353 ******************************************************************************/ 355 ******************************************************************************/
354 356
355struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = 357struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
356{
357 /* Name Parent Register Register Bit Position Register Bit Mask */ 358 /* Name Parent Register Register Bit Position Register Bit Mask */
358 359
359 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 360 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
360 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 361 ACPI_BITPOSITION_TIMER_STATUS,
361 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 362 ACPI_BITMASK_TIMER_STATUS},
362 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 363 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
363 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 364 ACPI_BITPOSITION_BUS_MASTER_STATUS,
364 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 365 ACPI_BITMASK_BUS_MASTER_STATUS},
365 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 366 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
366 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 367 ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
367 368 ACPI_BITMASK_GLOBAL_LOCK_STATUS},
368 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 369 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
369 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 370 ACPI_BITPOSITION_POWER_BUTTON_STATUS,
370 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 371 ACPI_BITMASK_POWER_BUTTON_STATUS},
371 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 372 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
372 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 373 ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
373 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 374 ACPI_BITMASK_SLEEP_BUTTON_STATUS},
374 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 375 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
375 376 ACPI_BITPOSITION_RT_CLOCK_STATUS,
376 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 377 ACPI_BITMASK_RT_CLOCK_STATUS},
377 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 378 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
378 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 379 ACPI_BITPOSITION_WAKE_STATUS,
379 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 380 ACPI_BITMASK_WAKE_STATUS},
380 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 381 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
381 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 382 ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
382 383 ACPI_BITMASK_PCIEXP_WAKE_STATUS},
383 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 384
385 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
386 ACPI_BITPOSITION_TIMER_ENABLE,
387 ACPI_BITMASK_TIMER_ENABLE},
388 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
389 ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
390 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
391 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
392 ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
393 ACPI_BITMASK_POWER_BUTTON_ENABLE},
394 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
395 ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
396 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
397 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
398 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
399 ACPI_BITMASK_RT_CLOCK_ENABLE},
400 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
401 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
402 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
403 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
404
405 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
406 ACPI_BITPOSITION_SCI_ENABLE,
407 ACPI_BITMASK_SCI_ENABLE},
408 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
409 ACPI_BITPOSITION_BUS_MASTER_RLD,
410 ACPI_BITMASK_BUS_MASTER_RLD},
411 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
412 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
413 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
414 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
415 ACPI_BITPOSITION_SLEEP_TYPE_X,
416 ACPI_BITMASK_SLEEP_TYPE_X},
417 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
418 ACPI_BITPOSITION_SLEEP_TYPE_X,
419 ACPI_BITMASK_SLEEP_TYPE_X},
420 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
421 ACPI_BITPOSITION_SLEEP_ENABLE,
422 ACPI_BITMASK_SLEEP_ENABLE},
423
424 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
425 ACPI_BITPOSITION_ARB_DISABLE,
426 ACPI_BITMASK_ARB_DISABLE}
384}; 427};
385 428
386 429struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
387struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = 430 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
388{ 431 ACPI_BITREG_TIMER_ENABLE,
389 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 432 ACPI_BITMASK_TIMER_STATUS,
390 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 433 ACPI_BITMASK_TIMER_ENABLE},
391 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 434 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
392 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 435 ACPI_BITREG_GLOBAL_LOCK_ENABLE,
393 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 436 ACPI_BITMASK_GLOBAL_LOCK_STATUS,
437 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
438 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
439 ACPI_BITREG_POWER_BUTTON_ENABLE,
440 ACPI_BITMASK_POWER_BUTTON_STATUS,
441 ACPI_BITMASK_POWER_BUTTON_ENABLE},
442 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
443 ACPI_BITREG_SLEEP_BUTTON_ENABLE,
444 ACPI_BITMASK_SLEEP_BUTTON_STATUS,
445 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
446 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
447 ACPI_BITREG_RT_CLOCK_ENABLE,
448 ACPI_BITMASK_RT_CLOCK_STATUS,
449 ACPI_BITMASK_RT_CLOCK_ENABLE},
394}; 450};
395 451
396/******************************************************************************* 452/*******************************************************************************
@@ -407,8 +463,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
407 463
408/* Region type decoding */ 464/* Region type decoding */
409 465
410const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = 466const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
411{
412/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ 467/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
413 "SystemMemory", 468 "SystemMemory",
414 "SystemIO", 469 "SystemIO",
@@ -421,25 +476,18 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
421/*! [End] no source code translation !*/ 476/*! [End] no source code translation !*/
422}; 477};
423 478
424 479char *acpi_ut_get_region_name(u8 space_id)
425char *
426acpi_ut_get_region_name (
427 u8 space_id)
428{ 480{
429 481
430 if (space_id >= ACPI_USER_REGION_BEGIN) 482 if (space_id >= ACPI_USER_REGION_BEGIN) {
431 {
432 return ("user_defined_region"); 483 return ("user_defined_region");
433 } 484 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
434 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
435 {
436 return ("invalid_space_id"); 485 return ("invalid_space_id");
437 } 486 }
438 487
439 return ((char *) acpi_gbl_region_types[space_id]); 488 return ((char *)acpi_gbl_region_types[space_id]);
440} 489}
441 490
442
443/******************************************************************************* 491/*******************************************************************************
444 * 492 *
445 * FUNCTION: acpi_ut_get_event_name 493 * FUNCTION: acpi_ut_get_event_name
@@ -454,8 +502,7 @@ acpi_ut_get_region_name (
454 502
455/* Event type decoding */ 503/* Event type decoding */
456 504
457static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = 505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
458{
459 "PM_Timer", 506 "PM_Timer",
460 "global_lock", 507 "global_lock",
461 "power_button", 508 "power_button",
@@ -463,21 +510,16 @@ static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
463 "real_time_clock", 510 "real_time_clock",
464}; 511};
465 512
466 513char *acpi_ut_get_event_name(u32 event_id)
467char *
468acpi_ut_get_event_name (
469 u32 event_id)
470{ 514{
471 515
472 if (event_id > ACPI_EVENT_MAX) 516 if (event_id > ACPI_EVENT_MAX) {
473 {
474 return ("invalid_event_iD"); 517 return ("invalid_event_iD");
475 } 518 }
476 519
477 return ((char *) acpi_gbl_event_types[event_id]); 520 return ((char *)acpi_gbl_event_types[event_id]);
478} 521}
479 522
480
481/******************************************************************************* 523/*******************************************************************************
482 * 524 *
483 * FUNCTION: acpi_ut_get_type_name 525 * FUNCTION: acpi_ut_get_type_name
@@ -498,12 +540,11 @@ acpi_ut_get_event_name (
498 * when stored in a table it really means that we have thus far seen no 540 * when stored in a table it really means that we have thus far seen no
499 * evidence to indicate what type is actually going to be stored for this entry. 541 * evidence to indicate what type is actually going to be stored for this entry.
500 */ 542 */
501static const char acpi_gbl_bad_type[] = "UNDEFINED"; 543static const char acpi_gbl_bad_type[] = "UNDEFINED";
502 544
503/* Printable names of the ACPI object types */ 545/* Printable names of the ACPI object types */
504 546
505static const char *acpi_gbl_ns_type_names[] = 547static const char *acpi_gbl_ns_type_names[] = {
506{
507 /* 00 */ "Untyped", 548 /* 00 */ "Untyped",
508 /* 01 */ "Integer", 549 /* 01 */ "Integer",
509 /* 02 */ "String", 550 /* 02 */ "String",
@@ -537,35 +578,26 @@ static const char *acpi_gbl_ns_type_names[] =
537 /* 30 */ "Invalid" 578 /* 30 */ "Invalid"
538}; 579};
539 580
540 581char *acpi_ut_get_type_name(acpi_object_type type)
541char *
542acpi_ut_get_type_name (
543 acpi_object_type type)
544{ 582{
545 583
546 if (type > ACPI_TYPE_INVALID) 584 if (type > ACPI_TYPE_INVALID) {
547 { 585 return ((char *)acpi_gbl_bad_type);
548 return ((char *) acpi_gbl_bad_type);
549 } 586 }
550 587
551 return ((char *) acpi_gbl_ns_type_names[type]); 588 return ((char *)acpi_gbl_ns_type_names[type]);
552} 589}
553 590
554 591char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
555char *
556acpi_ut_get_object_type_name (
557 union acpi_operand_object *obj_desc)
558{ 592{
559 593
560 if (!obj_desc) 594 if (!obj_desc) {
561 {
562 return ("[NULL Object Descriptor]"); 595 return ("[NULL Object Descriptor]");
563 } 596 }
564 597
565 return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc))); 598 return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
566} 599}
567 600
568
569/******************************************************************************* 601/*******************************************************************************
570 * 602 *
571 * FUNCTION: acpi_ut_get_node_name 603 * FUNCTION: acpi_ut_get_node_name
@@ -578,39 +610,31 @@ acpi_ut_get_object_type_name (
578 * 610 *
579 ******************************************************************************/ 611 ******************************************************************************/
580 612
581char * 613char *acpi_ut_get_node_name(void *object)
582acpi_ut_get_node_name (
583 void *object)
584{ 614{
585 struct acpi_namespace_node *node = (struct acpi_namespace_node *) object; 615 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
586
587 616
588 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 617 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
589 618
590 if (!object) 619 if (!object) {
591 {
592 return ("NULL"); 620 return ("NULL");
593 } 621 }
594 622
595 /* Check for Root node */ 623 /* Check for Root node */
596 624
597 if ((object == ACPI_ROOT_OBJECT) || 625 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
598 (object == acpi_gbl_root_node))
599 {
600 return ("\"\\\" "); 626 return ("\"\\\" ");
601 } 627 }
602 628
603 /* Descriptor must be a namespace node */ 629 /* Descriptor must be a namespace node */
604 630
605 if (node->descriptor != ACPI_DESC_TYPE_NAMED) 631 if (node->descriptor != ACPI_DESC_TYPE_NAMED) {
606 {
607 return ("####"); 632 return ("####");
608 } 633 }
609 634
610 /* Name must be a valid ACPI name */ 635 /* Name must be a valid ACPI name */
611 636
612 if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii)) 637 if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) {
613 {
614 return ("????"); 638 return ("????");
615 } 639 }
616 640
@@ -619,7 +643,6 @@ acpi_ut_get_node_name (
619 return (node->name.ascii); 643 return (node->name.ascii);
620} 644}
621 645
622
623/******************************************************************************* 646/*******************************************************************************
624 * 647 *
625 * FUNCTION: acpi_ut_get_descriptor_name 648 * FUNCTION: acpi_ut_get_descriptor_name
@@ -634,8 +657,7 @@ acpi_ut_get_node_name (
634 657
635/* Printable names of object descriptor types */ 658/* Printable names of object descriptor types */
636 659
637static const char *acpi_gbl_desc_type_names[] = 660static const char *acpi_gbl_desc_type_names[] = {
638{
639 /* 00 */ "Invalid", 661 /* 00 */ "Invalid",
640 /* 01 */ "Cached", 662 /* 01 */ "Cached",
641 /* 02 */ "State-Generic", 663 /* 02 */ "State-Generic",
@@ -654,27 +676,22 @@ static const char *acpi_gbl_desc_type_names[] =
654 /* 15 */ "Node" 676 /* 15 */ "Node"
655}; 677};
656 678
657 679char *acpi_ut_get_descriptor_name(void *object)
658char *
659acpi_ut_get_descriptor_name (
660 void *object)
661{ 680{
662 681
663 if (!object) 682 if (!object) {
664 {
665 return ("NULL OBJECT"); 683 return ("NULL OBJECT");
666 } 684 }
667 685
668 if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX) 686 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
669 { 687 return ((char *)acpi_gbl_bad_type);
670 return ((char *) acpi_gbl_bad_type);
671 } 688 }
672 689
673 return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]); 690 return ((char *)
691 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]);
674 692
675} 693}
676 694
677
678#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 695#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
679/* 696/*
680 * Strings and procedures used for debug only 697 * Strings and procedures used for debug only
@@ -693,13 +710,10 @@ acpi_ut_get_descriptor_name (
693 * 710 *
694 ******************************************************************************/ 711 ******************************************************************************/
695 712
696char * 713char *acpi_ut_get_mutex_name(u32 mutex_id)
697acpi_ut_get_mutex_name (
698 u32 mutex_id)
699{ 714{
700 715
701 if (mutex_id > MAX_MUTEX) 716 if (mutex_id > MAX_MUTEX) {
702 {
703 return ("Invalid Mutex ID"); 717 return ("Invalid Mutex ID");
704 } 718 }
705 719
@@ -707,7 +721,6 @@ acpi_ut_get_mutex_name (
707} 721}
708#endif 722#endif
709 723
710
711/******************************************************************************* 724/*******************************************************************************
712 * 725 *
713 * FUNCTION: acpi_ut_valid_object_type 726 * FUNCTION: acpi_ut_valid_object_type
@@ -720,13 +733,10 @@ acpi_ut_get_mutex_name (
720 * 733 *
721 ******************************************************************************/ 734 ******************************************************************************/
722 735
723u8 736u8 acpi_ut_valid_object_type(acpi_object_type type)
724acpi_ut_valid_object_type (
725 acpi_object_type type)
726{ 737{
727 738
728 if (type > ACPI_TYPE_LOCAL_MAX) 739 if (type > ACPI_TYPE_LOCAL_MAX) {
729 {
730 /* Note: Assumes all TYPEs are contiguous (external/local) */ 740 /* Note: Assumes all TYPEs are contiguous (external/local) */
731 741
732 return (FALSE); 742 return (FALSE);
@@ -735,74 +745,6 @@ acpi_ut_valid_object_type (
735 return (TRUE); 745 return (TRUE);
736} 746}
737 747
738
739/*******************************************************************************
740 *
741 * FUNCTION: acpi_ut_allocate_owner_id
742 *
743 * PARAMETERS: id_type - Type of ID (method or table)
744 *
745 * DESCRIPTION: Allocate a table or method owner id
746 *
747 * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and
748 * should be revisited (TBD)
749 *
750 ******************************************************************************/
751
752acpi_owner_id
753acpi_ut_allocate_owner_id (
754 u32 id_type)
755{
756 acpi_owner_id owner_id = 0xFFFF;
757
758
759 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
760
761
762 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
763 {
764 return (0);
765 }
766
767 switch (id_type)
768 {
769 case ACPI_OWNER_TYPE_TABLE:
770
771 owner_id = acpi_gbl_next_table_owner_id;
772 acpi_gbl_next_table_owner_id++;
773
774 /* Check for wraparound */
775
776 if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
777 {
778 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
779 ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
780 }
781 break;
782
783
784 case ACPI_OWNER_TYPE_METHOD:
785
786 owner_id = acpi_gbl_next_method_owner_id;
787 acpi_gbl_next_method_owner_id++;
788
789 if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
790 {
791 /* Check for wraparound */
792
793 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
794 }
795 break;
796
797 default:
798 break;
799 }
800
801 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
802 return_VALUE (owner_id);
803}
804
805
806/******************************************************************************* 748/*******************************************************************************
807 * 749 *
808 * FUNCTION: acpi_ut_init_globals 750 * FUNCTION: acpi_ut_init_globals
@@ -816,129 +758,96 @@ acpi_ut_allocate_owner_id (
816 * 758 *
817 ******************************************************************************/ 759 ******************************************************************************/
818 760
819void 761void acpi_ut_init_globals(void)
820acpi_ut_init_globals (
821 void)
822{ 762{
823 u32 i; 763 acpi_status status;
764 u32 i;
824 765
766 ACPI_FUNCTION_TRACE("ut_init_globals");
825 767
826 ACPI_FUNCTION_TRACE ("ut_init_globals"); 768 /* Create all memory caches */
827 769
828 770 status = acpi_ut_create_caches();
829 /* Memory allocation and cache lists */ 771 if (ACPI_FAILURE(status)) {
830 772 return;
831 ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); 773 }
832
833 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL);
834 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
835 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
836 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
837 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
838
839 acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node);
840 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state);
841 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common);
842 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
843 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object);
844 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state);
845
846 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH;
847 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
848 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
849 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
850 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH;
851
852 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation");
853 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes");
854 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache");
855 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache");
856 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache");
857 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache");
858 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache");
859 774
860 /* ACPI table structure */ 775 /* ACPI table structure */
861 776
862 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 777 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
863 { 778 acpi_gbl_table_lists[i].next = NULL;
864 acpi_gbl_table_lists[i].next = NULL; 779 acpi_gbl_table_lists[i].count = 0;
865 acpi_gbl_table_lists[i].count = 0;
866 } 780 }
867 781
868 /* Mutex locked flags */ 782 /* Mutex locked flags */
869 783
870 for (i = 0; i < NUM_MUTEX; i++) 784 for (i = 0; i < NUM_MUTEX; i++) {
871 { 785 acpi_gbl_mutex_info[i].mutex = NULL;
872 acpi_gbl_mutex_info[i].mutex = NULL; 786 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
873 acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED; 787 acpi_gbl_mutex_info[i].use_count = 0;
874 acpi_gbl_mutex_info[i].use_count = 0;
875 } 788 }
876 789
877 /* GPE support */ 790 /* GPE support */
878 791
879 acpi_gbl_gpe_xrupt_list_head = NULL; 792 acpi_gbl_gpe_xrupt_list_head = NULL;
880 acpi_gbl_gpe_fadt_blocks[0] = NULL; 793 acpi_gbl_gpe_fadt_blocks[0] = NULL;
881 acpi_gbl_gpe_fadt_blocks[1] = NULL; 794 acpi_gbl_gpe_fadt_blocks[1] = NULL;
882 795
883 /* Global notify handlers */ 796 /* Global notify handlers */
884 797
885 acpi_gbl_system_notify.handler = NULL; 798 acpi_gbl_system_notify.handler = NULL;
886 acpi_gbl_device_notify.handler = NULL; 799 acpi_gbl_device_notify.handler = NULL;
887 acpi_gbl_exception_handler = NULL; 800 acpi_gbl_exception_handler = NULL;
888 acpi_gbl_init_handler = NULL; 801 acpi_gbl_init_handler = NULL;
889 802
890 /* Global "typed" ACPI table pointers */ 803 /* Global "typed" ACPI table pointers */
891 804
892 acpi_gbl_RSDP = NULL; 805 acpi_gbl_RSDP = NULL;
893 acpi_gbl_XSDT = NULL; 806 acpi_gbl_XSDT = NULL;
894 acpi_gbl_FACS = NULL; 807 acpi_gbl_FACS = NULL;
895 acpi_gbl_FADT = NULL; 808 acpi_gbl_FADT = NULL;
896 acpi_gbl_DSDT = NULL; 809 acpi_gbl_DSDT = NULL;
897 810
898 /* Global Lock support */ 811 /* Global Lock support */
899 812
900 acpi_gbl_global_lock_acquired = FALSE; 813 acpi_gbl_global_lock_acquired = FALSE;
901 acpi_gbl_global_lock_thread_count = 0; 814 acpi_gbl_global_lock_thread_count = 0;
902 acpi_gbl_global_lock_handle = 0; 815 acpi_gbl_global_lock_handle = 0;
903 816
904 /* Miscellaneous variables */ 817 /* Miscellaneous variables */
905 818
906 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; 819 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
907 acpi_gbl_rsdp_original_location = 0; 820 acpi_gbl_rsdp_original_location = 0;
908 acpi_gbl_cm_single_step = FALSE; 821 acpi_gbl_cm_single_step = FALSE;
909 acpi_gbl_db_terminate_threads = FALSE; 822 acpi_gbl_db_terminate_threads = FALSE;
910 acpi_gbl_shutdown = FALSE; 823 acpi_gbl_shutdown = FALSE;
911 acpi_gbl_ns_lookup_count = 0; 824 acpi_gbl_ns_lookup_count = 0;
912 acpi_gbl_ps_find_count = 0; 825 acpi_gbl_ps_find_count = 0;
913 acpi_gbl_acpi_hardware_present = TRUE; 826 acpi_gbl_acpi_hardware_present = TRUE;
914 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; 827 acpi_gbl_owner_id_mask = 0;
915 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; 828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
916 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
917 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
918 830
919 /* Hardware oriented */ 831 /* Hardware oriented */
920 832
921 acpi_gbl_events_initialized = FALSE; 833 acpi_gbl_events_initialized = FALSE;
922 acpi_gbl_system_awake_and_running = TRUE; 834 acpi_gbl_system_awake_and_running = TRUE;
923 835
924 /* Namespace */ 836 /* Namespace */
925 837
926 acpi_gbl_root_node = NULL; 838 acpi_gbl_root_node = NULL;
927 839
928 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 840 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
929 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 841 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
930 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 842 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
931 acpi_gbl_root_node_struct.child = NULL; 843 acpi_gbl_root_node_struct.child = NULL;
932 acpi_gbl_root_node_struct.peer = NULL; 844 acpi_gbl_root_node_struct.peer = NULL;
933 acpi_gbl_root_node_struct.object = NULL; 845 acpi_gbl_root_node_struct.object = NULL;
934 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; 846 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
935
936 847
937#ifdef ACPI_DEBUG_OUTPUT 848#ifdef ACPI_DEBUG_OUTPUT
938 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; 849 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
939#endif 850#endif
940 851
941 return_VOID; 852 return_VOID;
942} 853}
943
944
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index 7f3713889ff0..9dde82b0beaf 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -41,25 +41,18 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acevents.h> 46#include <acpi/acevents.h>
48 47
49#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utinit") 49ACPI_MODULE_NAME("utinit")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54static void 52static void
55acpi_ut_fadt_register_error ( 53acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset);
56 char *register_name,
57 u32 value,
58 acpi_size offset);
59
60static void acpi_ut_terminate (
61 void);
62 54
55static void acpi_ut_terminate(void);
63 56
64/******************************************************************************* 57/*******************************************************************************
65 * 58 *
@@ -76,18 +69,14 @@ static void acpi_ut_terminate (
76 ******************************************************************************/ 69 ******************************************************************************/
77 70
78static void 71static void
79acpi_ut_fadt_register_error ( 72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset)
80 char *register_name,
81 u32 value,
82 acpi_size offset)
83{ 73{
84 74
85 ACPI_REPORT_WARNING ( 75 ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n",
86 ("Invalid FADT value %s=%X at offset %X FADT=%p\n", 76 register_name, value, (u32) offset,
87 register_name, value, (u32) offset, acpi_gbl_FADT)); 77 acpi_gbl_FADT));
88} 78}
89 79
90
91/****************************************************************************** 80/******************************************************************************
92 * 81 *
93 * FUNCTION: acpi_ut_validate_fadt 82 * FUNCTION: acpi_ut_validate_fadt
@@ -100,9 +89,7 @@ acpi_ut_fadt_register_error (
100 * 89 *
101 ******************************************************************************/ 90 ******************************************************************************/
102 91
103acpi_status 92acpi_status acpi_ut_validate_fadt(void)
104acpi_ut_validate_fadt (
105 void)
106{ 93{
107 94
108 /* 95 /*
@@ -110,64 +97,66 @@ acpi_ut_validate_fadt (
110 * but don't abort on any problems, just display error 97 * but don't abort on any problems, just display error
111 */ 98 */
112 if (acpi_gbl_FADT->pm1_evt_len < 4) { 99 if (acpi_gbl_FADT->pm1_evt_len < 4) {
113 acpi_ut_fadt_register_error ("PM1_EVT_LEN", 100 acpi_ut_fadt_register_error("PM1_EVT_LEN",
114 (u32) acpi_gbl_FADT->pm1_evt_len, 101 (u32) acpi_gbl_FADT->pm1_evt_len,
115 ACPI_FADT_OFFSET (pm1_evt_len)); 102 ACPI_FADT_OFFSET(pm1_evt_len));
116 } 103 }
117 104
118 if (!acpi_gbl_FADT->pm1_cnt_len) { 105 if (!acpi_gbl_FADT->pm1_cnt_len) {
119 acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0, 106 acpi_ut_fadt_register_error("PM1_CNT_LEN", 0,
120 ACPI_FADT_OFFSET (pm1_cnt_len)); 107 ACPI_FADT_OFFSET(pm1_cnt_len));
121 } 108 }
122 109
123 if (!acpi_gbl_FADT->xpm1a_evt_blk.address) { 110 if (!acpi_gbl_FADT->xpm1a_evt_blk.address) {
124 acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0, 111 acpi_ut_fadt_register_error("X_PM1a_EVT_BLK", 0,
125 ACPI_FADT_OFFSET (xpm1a_evt_blk.address)); 112 ACPI_FADT_OFFSET(xpm1a_evt_blk.
113 address));
126 } 114 }
127 115
128 if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) { 116 if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) {
129 acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0, 117 acpi_ut_fadt_register_error("X_PM1a_CNT_BLK", 0,
130 ACPI_FADT_OFFSET (xpm1a_cnt_blk.address)); 118 ACPI_FADT_OFFSET(xpm1a_cnt_blk.
119 address));
131 } 120 }
132 121
133 if (!acpi_gbl_FADT->xpm_tmr_blk.address) { 122 if (!acpi_gbl_FADT->xpm_tmr_blk.address) {
134 acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0, 123 acpi_ut_fadt_register_error("X_PM_TMR_BLK", 0,
135 ACPI_FADT_OFFSET (xpm_tmr_blk.address)); 124 ACPI_FADT_OFFSET(xpm_tmr_blk.
125 address));
136 } 126 }
137 127
138 if ((acpi_gbl_FADT->xpm2_cnt_blk.address && 128 if ((acpi_gbl_FADT->xpm2_cnt_blk.address &&
139 !acpi_gbl_FADT->pm2_cnt_len)) { 129 !acpi_gbl_FADT->pm2_cnt_len)) {
140 acpi_ut_fadt_register_error ("PM2_CNT_LEN", 130 acpi_ut_fadt_register_error("PM2_CNT_LEN",
141 (u32) acpi_gbl_FADT->pm2_cnt_len, 131 (u32) acpi_gbl_FADT->pm2_cnt_len,
142 ACPI_FADT_OFFSET (pm2_cnt_len)); 132 ACPI_FADT_OFFSET(pm2_cnt_len));
143 } 133 }
144 134
145 if (acpi_gbl_FADT->pm_tm_len < 4) { 135 if (acpi_gbl_FADT->pm_tm_len < 4) {
146 acpi_ut_fadt_register_error ("PM_TM_LEN", 136 acpi_ut_fadt_register_error("PM_TM_LEN",
147 (u32) acpi_gbl_FADT->pm_tm_len, 137 (u32) acpi_gbl_FADT->pm_tm_len,
148 ACPI_FADT_OFFSET (pm_tm_len)); 138 ACPI_FADT_OFFSET(pm_tm_len));
149 } 139 }
150 140
151 /* Length of GPE blocks must be a multiple of 2 */ 141 /* Length of GPE blocks must be a multiple of 2 */
152 142
153 if (acpi_gbl_FADT->xgpe0_blk.address && 143 if (acpi_gbl_FADT->xgpe0_blk.address &&
154 (acpi_gbl_FADT->gpe0_blk_len & 1)) { 144 (acpi_gbl_FADT->gpe0_blk_len & 1)) {
155 acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN", 145 acpi_ut_fadt_register_error("(x)GPE0_BLK_LEN",
156 (u32) acpi_gbl_FADT->gpe0_blk_len, 146 (u32) acpi_gbl_FADT->gpe0_blk_len,
157 ACPI_FADT_OFFSET (gpe0_blk_len)); 147 ACPI_FADT_OFFSET(gpe0_blk_len));
158 } 148 }
159 149
160 if (acpi_gbl_FADT->xgpe1_blk.address && 150 if (acpi_gbl_FADT->xgpe1_blk.address &&
161 (acpi_gbl_FADT->gpe1_blk_len & 1)) { 151 (acpi_gbl_FADT->gpe1_blk_len & 1)) {
162 acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN", 152 acpi_ut_fadt_register_error("(x)GPE1_BLK_LEN",
163 (u32) acpi_gbl_FADT->gpe1_blk_len, 153 (u32) acpi_gbl_FADT->gpe1_blk_len,
164 ACPI_FADT_OFFSET (gpe1_blk_len)); 154 ACPI_FADT_OFFSET(gpe1_blk_len));
165 } 155 }
166 156
167 return (AE_OK); 157 return (AE_OK);
168} 158}
169 159
170
171/****************************************************************************** 160/******************************************************************************
172 * 161 *
173 * FUNCTION: acpi_ut_terminate 162 * FUNCTION: acpi_ut_terminate
@@ -180,18 +169,14 @@ acpi_ut_validate_fadt (
180 * 169 *
181 ******************************************************************************/ 170 ******************************************************************************/
182 171
183static void 172static void acpi_ut_terminate(void)
184acpi_ut_terminate (
185 void)
186{ 173{
187 struct acpi_gpe_block_info *gpe_block; 174 struct acpi_gpe_block_info *gpe_block;
188 struct acpi_gpe_block_info *next_gpe_block; 175 struct acpi_gpe_block_info *next_gpe_block;
189 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 176 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
190 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; 177 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
191
192
193 ACPI_FUNCTION_TRACE ("ut_terminate");
194 178
179 ACPI_FUNCTION_TRACE("ut_terminate");
195 180
196 /* Free global tables, etc. */ 181 /* Free global tables, etc. */
197 /* Free global GPE blocks and related info structures */ 182 /* Free global GPE blocks and related info structures */
@@ -201,21 +186,20 @@ acpi_ut_terminate (
201 gpe_block = gpe_xrupt_info->gpe_block_list_head; 186 gpe_block = gpe_xrupt_info->gpe_block_list_head;
202 while (gpe_block) { 187 while (gpe_block) {
203 next_gpe_block = gpe_block->next; 188 next_gpe_block = gpe_block->next;
204 ACPI_MEM_FREE (gpe_block->event_info); 189 ACPI_MEM_FREE(gpe_block->event_info);
205 ACPI_MEM_FREE (gpe_block->register_info); 190 ACPI_MEM_FREE(gpe_block->register_info);
206 ACPI_MEM_FREE (gpe_block); 191 ACPI_MEM_FREE(gpe_block);
207 192
208 gpe_block = next_gpe_block; 193 gpe_block = next_gpe_block;
209 } 194 }
210 next_gpe_xrupt_info = gpe_xrupt_info->next; 195 next_gpe_xrupt_info = gpe_xrupt_info->next;
211 ACPI_MEM_FREE (gpe_xrupt_info); 196 ACPI_MEM_FREE(gpe_xrupt_info);
212 gpe_xrupt_info = next_gpe_xrupt_info; 197 gpe_xrupt_info = next_gpe_xrupt_info;
213 } 198 }
214 199
215 return_VOID; 200 return_VOID;
216} 201}
217 202
218
219/******************************************************************************* 203/*******************************************************************************
220 * 204 *
221 * FUNCTION: acpi_ut_subsystem_shutdown 205 * FUNCTION: acpi_ut_subsystem_shutdown
@@ -229,50 +213,45 @@ acpi_ut_terminate (
229 * 213 *
230 ******************************************************************************/ 214 ******************************************************************************/
231 215
232void 216void acpi_ut_subsystem_shutdown(void)
233acpi_ut_subsystem_shutdown (
234 void)
235{ 217{
236 218
237 ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown"); 219 ACPI_FUNCTION_TRACE("ut_subsystem_shutdown");
238 220
239 /* Just exit if subsystem is already shutdown */ 221 /* Just exit if subsystem is already shutdown */
240 222
241 if (acpi_gbl_shutdown) { 223 if (acpi_gbl_shutdown) {
242 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
243 "ACPI Subsystem is already terminated\n")); 225 "ACPI Subsystem is already terminated\n"));
244 return_VOID; 226 return_VOID;
245 } 227 }
246 228
247 /* Subsystem appears active, go ahead and shut it down */ 229 /* Subsystem appears active, go ahead and shut it down */
248 230
249 acpi_gbl_shutdown = TRUE; 231 acpi_gbl_shutdown = TRUE;
250 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
251 "Shutting down ACPI Subsystem...\n"));
252 233
253 /* Close the acpi_event Handling */ 234 /* Close the acpi_event Handling */
254 235
255 acpi_ev_terminate (); 236 acpi_ev_terminate();
256 237
257 /* Close the Namespace */ 238 /* Close the Namespace */
258 239
259 acpi_ns_terminate (); 240 acpi_ns_terminate();
260 241
261 /* Close the globals */ 242 /* Close the globals */
262 243
263 acpi_ut_terminate (); 244 acpi_ut_terminate();
264 245
265 /* Purge the local caches */ 246 /* Purge the local caches */
266 247
267 (void) acpi_purge_cached_objects (); 248 (void)acpi_ut_delete_caches();
268 249
269 /* Debug only - display leftover memory allocation, if any */ 250 /* Debug only - display leftover memory allocation, if any */
270 251
271#ifdef ACPI_DBG_TRACK_ALLOCATIONS 252#ifdef ACPI_DBG_TRACK_ALLOCATIONS
272 acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL); 253 acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL);
273#endif 254#endif
274 255
275 return_VOID; 256 return_VOID;
276} 257}
277
278
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 0d527c91543c..68a0a6f94129 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -41,19 +41,16 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46 45
47
48#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utmath") 47ACPI_MODULE_NAME("utmath")
50 48
51/* 49/*
52 * Support for double-precision integer divide. This code is included here 50 * Support for double-precision integer divide. This code is included here
53 * in order to support kernel environments where the double-precision math 51 * in order to support kernel environments where the double-precision math
54 * library is not available. 52 * library is not available.
55 */ 53 */
56
57#ifndef ACPI_USE_NATIVE_DIVIDE 54#ifndef ACPI_USE_NATIVE_DIVIDE
58/******************************************************************************* 55/*******************************************************************************
59 * 56 *
@@ -71,27 +68,22 @@
71 * 32-bit remainder. 68 * 32-bit remainder.
72 * 69 *
73 ******************************************************************************/ 70 ******************************************************************************/
74
75acpi_status 71acpi_status
76acpi_ut_short_divide ( 72acpi_ut_short_divide(acpi_integer dividend,
77 acpi_integer dividend, 73 u32 divisor,
78 u32 divisor, 74 acpi_integer * out_quotient, u32 * out_remainder)
79 acpi_integer *out_quotient,
80 u32 *out_remainder)
81{ 75{
82 union uint64_overlay dividend_ovl; 76 union uint64_overlay dividend_ovl;
83 union uint64_overlay quotient; 77 union uint64_overlay quotient;
84 u32 remainder32; 78 u32 remainder32;
85
86
87 ACPI_FUNCTION_TRACE ("ut_short_divide");
88 79
80 ACPI_FUNCTION_TRACE("ut_short_divide");
89 81
90 /* Always check for a zero divisor */ 82 /* Always check for a zero divisor */
91 83
92 if (divisor == 0) { 84 if (divisor == 0) {
93 ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); 85 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n"));
94 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
95 } 87 }
96 88
97 dividend_ovl.full = dividend; 89 dividend_ovl.full = dividend;
@@ -100,9 +92,9 @@ acpi_ut_short_divide (
100 * The quotient is 64 bits, the remainder is always 32 bits, 92 * The quotient is 64 bits, the remainder is always 32 bits,
101 * and is generated by the second divide. 93 * and is generated by the second divide.
102 */ 94 */
103 ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor, 95 ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor,
104 quotient.part.hi, remainder32); 96 quotient.part.hi, remainder32);
105 ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor, 97 ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor,
106 quotient.part.lo, remainder32); 98 quotient.part.lo, remainder32);
107 99
108 /* Return only what was requested */ 100 /* Return only what was requested */
@@ -114,10 +106,9 @@ acpi_ut_short_divide (
114 *out_remainder = remainder32; 106 *out_remainder = remainder32;
115 } 107 }
116 108
117 return_ACPI_STATUS (AE_OK); 109 return_ACPI_STATUS(AE_OK);
118} 110}
119 111
120
121/******************************************************************************* 112/*******************************************************************************
122 * 113 *
123 * FUNCTION: acpi_ut_divide 114 * FUNCTION: acpi_ut_divide
@@ -134,34 +125,30 @@ acpi_ut_short_divide (
134 ******************************************************************************/ 125 ******************************************************************************/
135 126
136acpi_status 127acpi_status
137acpi_ut_divide ( 128acpi_ut_divide(acpi_integer in_dividend,
138 acpi_integer in_dividend, 129 acpi_integer in_divisor,
139 acpi_integer in_divisor, 130 acpi_integer * out_quotient, acpi_integer * out_remainder)
140 acpi_integer *out_quotient,
141 acpi_integer *out_remainder)
142{ 131{
143 union uint64_overlay dividend; 132 union uint64_overlay dividend;
144 union uint64_overlay divisor; 133 union uint64_overlay divisor;
145 union uint64_overlay quotient; 134 union uint64_overlay quotient;
146 union uint64_overlay remainder; 135 union uint64_overlay remainder;
147 union uint64_overlay normalized_dividend; 136 union uint64_overlay normalized_dividend;
148 union uint64_overlay normalized_divisor; 137 union uint64_overlay normalized_divisor;
149 u32 partial1; 138 u32 partial1;
150 union uint64_overlay partial2; 139 union uint64_overlay partial2;
151 union uint64_overlay partial3; 140 union uint64_overlay partial3;
152 141
153 142 ACPI_FUNCTION_TRACE("ut_divide");
154 ACPI_FUNCTION_TRACE ("ut_divide");
155
156 143
157 /* Always check for a zero divisor */ 144 /* Always check for a zero divisor */
158 145
159 if (in_divisor == 0) { 146 if (in_divisor == 0) {
160 ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); 147 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n"));
161 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
162 } 149 }
163 150
164 divisor.full = in_divisor; 151 divisor.full = in_divisor;
165 dividend.full = in_dividend; 152 dividend.full = in_dividend;
166 if (divisor.part.hi == 0) { 153 if (divisor.part.hi == 0) {
167 /* 154 /*
@@ -174,9 +161,9 @@ acpi_ut_divide (
174 * The quotient is 64 bits, the remainder is always 32 bits, 161 * The quotient is 64 bits, the remainder is always 32 bits,
175 * and is generated by the second divide. 162 * and is generated by the second divide.
176 */ 163 */
177 ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor.part.lo, 164 ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo,
178 quotient.part.hi, partial1); 165 quotient.part.hi, partial1);
179 ACPI_DIV_64_BY_32 (partial1, dividend.part.lo, divisor.part.lo, 166 ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo,
180 quotient.part.lo, remainder.part.lo); 167 quotient.part.lo, remainder.part.lo);
181 } 168 }
182 169
@@ -185,23 +172,23 @@ acpi_ut_divide (
185 * 2) The general case where the divisor is a full 64 bits 172 * 2) The general case where the divisor is a full 64 bits
186 * is more difficult 173 * is more difficult
187 */ 174 */
188 quotient.part.hi = 0; 175 quotient.part.hi = 0;
189 normalized_dividend = dividend; 176 normalized_dividend = dividend;
190 normalized_divisor = divisor; 177 normalized_divisor = divisor;
191 178
192 /* Normalize the operands (shift until the divisor is < 32 bits) */ 179 /* Normalize the operands (shift until the divisor is < 32 bits) */
193 180
194 do { 181 do {
195 ACPI_SHIFT_RIGHT_64 (normalized_divisor.part.hi, 182 ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi,
196 normalized_divisor.part.lo); 183 normalized_divisor.part.lo);
197 ACPI_SHIFT_RIGHT_64 (normalized_dividend.part.hi, 184 ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi,
198 normalized_dividend.part.lo); 185 normalized_dividend.part.lo);
199 186
200 } while (normalized_divisor.part.hi != 0); 187 } while (normalized_divisor.part.hi != 0);
201 188
202 /* Partial divide */ 189 /* Partial divide */
203 190
204 ACPI_DIV_64_BY_32 (normalized_dividend.part.hi, 191 ACPI_DIV_64_BY_32(normalized_dividend.part.hi,
205 normalized_dividend.part.lo, 192 normalized_dividend.part.lo,
206 normalized_divisor.part.lo, 193 normalized_divisor.part.lo,
207 quotient.part.lo, partial1); 194 quotient.part.lo, partial1);
@@ -210,8 +197,9 @@ acpi_ut_divide (
210 * The quotient is always 32 bits, and simply requires adjustment. 197 * The quotient is always 32 bits, and simply requires adjustment.
211 * The 64-bit remainder must be generated. 198 * The 64-bit remainder must be generated.
212 */ 199 */
213 partial1 = quotient.part.lo * divisor.part.hi; 200 partial1 = quotient.part.lo * divisor.part.hi;
214 partial2.full = (acpi_integer) quotient.part.lo * divisor.part.lo; 201 partial2.full =
202 (acpi_integer) quotient.part.lo * divisor.part.lo;
215 partial3.full = (acpi_integer) partial2.part.hi + partial1; 203 partial3.full = (acpi_integer) partial2.part.hi + partial1;
216 204
217 remainder.part.hi = partial3.part.lo; 205 remainder.part.hi = partial3.part.lo;
@@ -224,16 +212,15 @@ acpi_ut_divide (
224 quotient.part.lo--; 212 quotient.part.lo--;
225 remainder.full -= divisor.full; 213 remainder.full -= divisor.full;
226 } 214 }
227 } 215 } else {
228 else {
229 quotient.part.lo--; 216 quotient.part.lo--;
230 remainder.full -= divisor.full; 217 remainder.full -= divisor.full;
231 } 218 }
232 } 219 }
233 220
234 remainder.full = remainder.full - dividend.full; 221 remainder.full = remainder.full - dividend.full;
235 remainder.part.hi = (u32) -((s32) remainder.part.hi); 222 remainder.part.hi = (u32) - ((s32) remainder.part.hi);
236 remainder.part.lo = (u32) -((s32) remainder.part.lo); 223 remainder.part.lo = (u32) - ((s32) remainder.part.lo);
237 224
238 if (remainder.part.lo) { 225 if (remainder.part.lo) {
239 remainder.part.hi--; 226 remainder.part.hi--;
@@ -250,11 +237,10 @@ acpi_ut_divide (
250 *out_remainder = remainder.full; 237 *out_remainder = remainder.full;
251 } 238 }
252 239
253 return_ACPI_STATUS (AE_OK); 240 return_ACPI_STATUS(AE_OK);
254} 241}
255 242
256#else 243#else
257
258/******************************************************************************* 244/*******************************************************************************
259 * 245 *
260 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide 246 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide
@@ -269,23 +255,19 @@ acpi_ut_divide (
269 * perform the divide. 255 * perform the divide.
270 * 256 *
271 ******************************************************************************/ 257 ******************************************************************************/
272
273acpi_status 258acpi_status
274acpi_ut_short_divide ( 259acpi_ut_short_divide(acpi_integer in_dividend,
275 acpi_integer in_dividend, 260 u32 divisor,
276 u32 divisor, 261 acpi_integer * out_quotient, u32 * out_remainder)
277 acpi_integer *out_quotient,
278 u32 *out_remainder)
279{ 262{
280 263
281 ACPI_FUNCTION_TRACE ("ut_short_divide"); 264 ACPI_FUNCTION_TRACE("ut_short_divide");
282
283 265
284 /* Always check for a zero divisor */ 266 /* Always check for a zero divisor */
285 267
286 if (divisor == 0) { 268 if (divisor == 0) {
287 ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); 269 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n"));
288 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
289 } 271 }
290 272
291 /* Return only what was requested */ 273 /* Return only what was requested */
@@ -297,27 +279,23 @@ acpi_ut_short_divide (
297 *out_remainder = (u32) in_dividend % divisor; 279 *out_remainder = (u32) in_dividend % divisor;
298 } 280 }
299 281
300 return_ACPI_STATUS (AE_OK); 282 return_ACPI_STATUS(AE_OK);
301} 283}
302 284
303acpi_status 285acpi_status
304acpi_ut_divide ( 286acpi_ut_divide(acpi_integer in_dividend,
305 acpi_integer in_dividend, 287 acpi_integer in_divisor,
306 acpi_integer in_divisor, 288 acpi_integer * out_quotient, acpi_integer * out_remainder)
307 acpi_integer *out_quotient,
308 acpi_integer *out_remainder)
309{ 289{
310 ACPI_FUNCTION_TRACE ("ut_divide"); 290 ACPI_FUNCTION_TRACE("ut_divide");
311
312 291
313 /* Always check for a zero divisor */ 292 /* Always check for a zero divisor */
314 293
315 if (in_divisor == 0) { 294 if (in_divisor == 0) {
316 ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); 295 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n"));
317 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
318 } 297 }
319 298
320
321 /* Return only what was requested */ 299 /* Return only what was requested */
322 300
323 if (out_quotient) { 301 if (out_quotient) {
@@ -327,9 +305,7 @@ acpi_ut_divide (
327 *out_remainder = in_dividend % in_divisor; 305 *out_remainder = in_dividend % in_divisor;
328 } 306 }
329 307
330 return_ACPI_STATUS (AE_OK); 308 return_ACPI_STATUS(AE_OK);
331} 309}
332 310
333#endif 311#endif
334
335
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f6de4ed3d527..0c5abc536c7a 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -41,24 +41,130 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 48ACPI_MODULE_NAME("utmisc")
49
50/*******************************************************************************
51 *
52 * FUNCTION: acpi_ut_allocate_owner_id
53 *
54 * PARAMETERS: owner_id - Where the new owner ID is returned
55 *
56 * RETURN: Status
57 *
58 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
59 * track objects created by the table or method, to be deleted
60 * when the method exits or the table is unloaded.
61 *
62 ******************************************************************************/
63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
64{
65 acpi_native_uint i;
66 acpi_status status;
67
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
69
70 /* Guard against multiple allocations of ID to the same location */
71
72 if (*owner_id) {
73 ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n",
74 *owner_id));
75 return_ACPI_STATUS(AE_ALREADY_EXISTS);
76 }
77
78 /* Mutex for the global ID mask */
79
80 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
81 if (ACPI_FAILURE(status)) {
82 return_ACPI_STATUS(status);
83 }
51 84
52/* Local prototypes */ 85 /* Find a free owner ID */
53 86
54static acpi_status 87 for (i = 0; i < 32; i++) {
55acpi_ut_create_mutex ( 88 if (!(acpi_gbl_owner_id_mask & (1 << i))) {
56 acpi_mutex_handle mutex_id); 89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
90 "Current owner_id mask: %8.8X New ID: %2.2X\n",
91 acpi_gbl_owner_id_mask,
92 (unsigned int)(i + 1)));
57 93
58static acpi_status 94 acpi_gbl_owner_id_mask |= (1 << i);
59acpi_ut_delete_mutex ( 95 *owner_id = (acpi_owner_id) (i + 1);
60 acpi_mutex_handle mutex_id); 96 goto exit;
97 }
98 }
61 99
100 /*
101 * If we are here, all owner_ids have been allocated. This probably should
102 * not happen since the IDs are reused after deallocation. The IDs are
103 * allocated upon table load (one per table) and method execution, and
104 * they are released when a table is unloaded or a method completes
105 * execution.
106 */
107 *owner_id = 0;
108 status = AE_OWNER_ID_LIMIT;
109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
110
111 exit:
112 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
113 return_ACPI_STATUS(status);
114}
115
116/*******************************************************************************
117 *
118 * FUNCTION: acpi_ut_release_owner_id
119 *
120 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD
121 *
122 * RETURN: None. No error is returned because we are either exiting a
123 * control method or unloading a table. Either way, we would
124 * ignore any error anyway.
125 *
126 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32
127 *
128 ******************************************************************************/
129
130void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
131{
132 acpi_owner_id owner_id = *owner_id_ptr;
133 acpi_status status;
134
135 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id);
136
137 /* Always clear the input owner_id (zero is an invalid ID) */
138
139 *owner_id_ptr = 0;
140
141 /* Zero is not a valid owner_iD */
142
143 if ((owner_id == 0) || (owner_id > 32)) {
144 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
145 return_VOID;
146 }
147
148 /* Mutex for the global ID mask */
149
150 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
151 if (ACPI_FAILURE(status)) {
152 return_VOID;
153 }
154
155 /* Normalize the ID to zero */
156
157 owner_id--;
158
159 /* Free the owner ID only if it is valid */
160
161 if (acpi_gbl_owner_id_mask & (1 << owner_id)) {
162 acpi_gbl_owner_id_mask ^= (1 << owner_id);
163 }
164
165 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
166 return_VOID;
167}
62 168
63/******************************************************************************* 169/*******************************************************************************
64 * 170 *
@@ -66,7 +172,7 @@ acpi_ut_delete_mutex (
66 * 172 *
67 * PARAMETERS: src_string - The source string to convert 173 * PARAMETERS: src_string - The source string to convert
68 * 174 *
69 * RETURN: Converted src_string (same as input pointer) 175 * RETURN: None
70 * 176 *
71 * DESCRIPTION: Convert string to uppercase 177 * DESCRIPTION: Convert string to uppercase
72 * 178 *
@@ -74,26 +180,25 @@ acpi_ut_delete_mutex (
74 * 180 *
75 ******************************************************************************/ 181 ******************************************************************************/
76 182
77char * 183void acpi_ut_strupr(char *src_string)
78acpi_ut_strupr (
79 char *src_string)
80{ 184{
81 char *string; 185 char *string;
82
83 186
84 ACPI_FUNCTION_ENTRY (); 187 ACPI_FUNCTION_ENTRY();
85 188
189 if (!src_string) {
190 return;
191 }
86 192
87 /* Walk entire string, uppercasing the letters */ 193 /* Walk entire string, uppercasing the letters */
88 194
89 for (string = src_string; *string; string++) { 195 for (string = src_string; *string; string++) {
90 *string = (char) ACPI_TOUPPER (*string); 196 *string = (char)ACPI_TOUPPER(*string);
91 } 197 }
92 198
93 return (src_string); 199 return;
94} 200}
95 201
96
97/******************************************************************************* 202/*******************************************************************************
98 * 203 *
99 * FUNCTION: acpi_ut_print_string 204 * FUNCTION: acpi_ut_print_string
@@ -108,85 +213,77 @@ acpi_ut_strupr (
108 * 213 *
109 ******************************************************************************/ 214 ******************************************************************************/
110 215
111void 216void acpi_ut_print_string(char *string, u8 max_length)
112acpi_ut_print_string (
113 char *string,
114 u8 max_length)
115{ 217{
116 u32 i; 218 u32 i;
117
118 219
119 if (!string) { 220 if (!string) {
120 acpi_os_printf ("<\"NULL STRING PTR\">"); 221 acpi_os_printf("<\"NULL STRING PTR\">");
121 return; 222 return;
122 } 223 }
123 224
124 acpi_os_printf ("\""); 225 acpi_os_printf("\"");
125 for (i = 0; string[i] && (i < max_length); i++) { 226 for (i = 0; string[i] && (i < max_length); i++) {
126 /* Escape sequences */ 227 /* Escape sequences */
127 228
128 switch (string[i]) { 229 switch (string[i]) {
129 case 0x07: 230 case 0x07:
130 acpi_os_printf ("\\a"); /* BELL */ 231 acpi_os_printf("\\a"); /* BELL */
131 break; 232 break;
132 233
133 case 0x08: 234 case 0x08:
134 acpi_os_printf ("\\b"); /* BACKSPACE */ 235 acpi_os_printf("\\b"); /* BACKSPACE */
135 break; 236 break;
136 237
137 case 0x0C: 238 case 0x0C:
138 acpi_os_printf ("\\f"); /* FORMFEED */ 239 acpi_os_printf("\\f"); /* FORMFEED */
139 break; 240 break;
140 241
141 case 0x0A: 242 case 0x0A:
142 acpi_os_printf ("\\n"); /* LINEFEED */ 243 acpi_os_printf("\\n"); /* LINEFEED */
143 break; 244 break;
144 245
145 case 0x0D: 246 case 0x0D:
146 acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ 247 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
147 break; 248 break;
148 249
149 case 0x09: 250 case 0x09:
150 acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ 251 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
151 break; 252 break;
152 253
153 case 0x0B: 254 case 0x0B:
154 acpi_os_printf ("\\v"); /* VERTICAL TAB */ 255 acpi_os_printf("\\v"); /* VERTICAL TAB */
155 break; 256 break;
156 257
157 case '\'': /* Single Quote */ 258 case '\'': /* Single Quote */
158 case '\"': /* Double Quote */ 259 case '\"': /* Double Quote */
159 case '\\': /* Backslash */ 260 case '\\': /* Backslash */
160 acpi_os_printf ("\\%c", (int) string[i]); 261 acpi_os_printf("\\%c", (int)string[i]);
161 break; 262 break;
162 263
163 default: 264 default:
164 265
165 /* Check for printable character or hex escape */ 266 /* Check for printable character or hex escape */
166 267
167 if (ACPI_IS_PRINT (string[i])) 268 if (ACPI_IS_PRINT(string[i])) {
168 {
169 /* This is a normal character */ 269 /* This is a normal character */
170 270
171 acpi_os_printf ("%c", (int) string[i]); 271 acpi_os_printf("%c", (int)string[i]);
172 } 272 } else {
173 else
174 {
175 /* All others will be Hex escapes */ 273 /* All others will be Hex escapes */
176 274
177 acpi_os_printf ("\\x%2.2X", (s32) string[i]); 275 acpi_os_printf("\\x%2.2X", (s32) string[i]);
178 } 276 }
179 break; 277 break;
180 } 278 }
181 } 279 }
182 acpi_os_printf ("\""); 280 acpi_os_printf("\"");
183 281
184 if (i == max_length && string[i]) { 282 if (i == max_length && string[i]) {
185 acpi_os_printf ("..."); 283 acpi_os_printf("...");
186 } 284 }
187} 285}
188 286
189
190/******************************************************************************* 287/*******************************************************************************
191 * 288 *
192 * FUNCTION: acpi_ut_dword_byte_swap 289 * FUNCTION: acpi_ut_dword_byte_swap
@@ -199,22 +296,18 @@ acpi_ut_print_string (
199 * 296 *
200 ******************************************************************************/ 297 ******************************************************************************/
201 298
202u32 299u32 acpi_ut_dword_byte_swap(u32 value)
203acpi_ut_dword_byte_swap (
204 u32 value)
205{ 300{
206 union { 301 union {
207 u32 value; 302 u32 value;
208 u8 bytes[4]; 303 u8 bytes[4];
209 } out; 304 } out;
210 union { 305 union {
211 u32 value; 306 u32 value;
212 u8 bytes[4]; 307 u8 bytes[4];
213 } in; 308 } in;
214 309
215 310 ACPI_FUNCTION_ENTRY();
216 ACPI_FUNCTION_ENTRY ();
217
218 311
219 in.value = value; 312 in.value = value;
220 313
@@ -226,7 +319,6 @@ acpi_ut_dword_byte_swap (
226 return (out.value); 319 return (out.value);
227} 320}
228 321
229
230/******************************************************************************* 322/*******************************************************************************
231 * 323 *
232 * FUNCTION: acpi_ut_set_integer_width 324 * FUNCTION: acpi_ut_set_integer_width
@@ -242,24 +334,20 @@ acpi_ut_dword_byte_swap (
242 * 334 *
243 ******************************************************************************/ 335 ******************************************************************************/
244 336
245void 337void acpi_ut_set_integer_width(u8 revision)
246acpi_ut_set_integer_width (
247 u8 revision)
248{ 338{
249 339
250 if (revision <= 1) { 340 if (revision <= 1) {
251 acpi_gbl_integer_bit_width = 32; 341 acpi_gbl_integer_bit_width = 32;
252 acpi_gbl_integer_nybble_width = 8; 342 acpi_gbl_integer_nybble_width = 8;
253 acpi_gbl_integer_byte_width = 4; 343 acpi_gbl_integer_byte_width = 4;
254 } 344 } else {
255 else {
256 acpi_gbl_integer_bit_width = 64; 345 acpi_gbl_integer_bit_width = 64;
257 acpi_gbl_integer_nybble_width = 16; 346 acpi_gbl_integer_nybble_width = 16;
258 acpi_gbl_integer_byte_width = 8; 347 acpi_gbl_integer_byte_width = 8;
259 } 348 }
260} 349}
261 350
262
263#ifdef ACPI_DEBUG_OUTPUT 351#ifdef ACPI_DEBUG_OUTPUT
264/******************************************************************************* 352/*******************************************************************************
265 * 353 *
@@ -277,17 +365,14 @@ acpi_ut_set_integer_width (
277 ******************************************************************************/ 365 ******************************************************************************/
278 366
279void 367void
280acpi_ut_display_init_pathname ( 368acpi_ut_display_init_pathname(u8 type,
281 u8 type, 369 struct acpi_namespace_node *obj_handle,
282 struct acpi_namespace_node *obj_handle, 370 char *path)
283 char *path)
284{ 371{
285 acpi_status status; 372 acpi_status status;
286 struct acpi_buffer buffer; 373 struct acpi_buffer buffer;
287
288
289 ACPI_FUNCTION_ENTRY ();
290 374
375 ACPI_FUNCTION_ENTRY();
291 376
292 /* Only print the path if the appropriate debug level is enabled */ 377 /* Only print the path if the appropriate debug level is enabled */
293 378
@@ -298,8 +383,8 @@ acpi_ut_display_init_pathname (
298 /* Get the full pathname to the node */ 383 /* Get the full pathname to the node */
299 384
300 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 385 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
301 status = acpi_ns_handle_to_pathname (obj_handle, &buffer); 386 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
302 if (ACPI_FAILURE (status)) { 387 if (ACPI_FAILURE(status)) {
303 return; 388 return;
304 } 389 }
305 390
@@ -307,31 +392,30 @@ acpi_ut_display_init_pathname (
307 392
308 switch (type) { 393 switch (type) {
309 case ACPI_TYPE_METHOD: 394 case ACPI_TYPE_METHOD:
310 acpi_os_printf ("Executing "); 395 acpi_os_printf("Executing ");
311 break; 396 break;
312 397
313 default: 398 default:
314 acpi_os_printf ("Initializing "); 399 acpi_os_printf("Initializing ");
315 break; 400 break;
316 } 401 }
317 402
318 /* Print the object type and pathname */ 403 /* Print the object type and pathname */
319 404
320 acpi_os_printf ("%-12s %s", 405 acpi_os_printf("%-12s %s",
321 acpi_ut_get_type_name (type), (char *) buffer.pointer); 406 acpi_ut_get_type_name(type), (char *)buffer.pointer);
322 407
323 /* Extra path is used to append names like _STA, _INI, etc. */ 408 /* Extra path is used to append names like _STA, _INI, etc. */
324 409
325 if (path) { 410 if (path) {
326 acpi_os_printf (".%s", path); 411 acpi_os_printf(".%s", path);
327 } 412 }
328 acpi_os_printf ("\n"); 413 acpi_os_printf("\n");
329 414
330 ACPI_MEM_FREE (buffer.pointer); 415 ACPI_MEM_FREE(buffer.pointer);
331} 416}
332#endif 417#endif
333 418
334
335/******************************************************************************* 419/*******************************************************************************
336 * 420 *
337 * FUNCTION: acpi_ut_valid_acpi_name 421 * FUNCTION: acpi_ut_valid_acpi_name
@@ -347,25 +431,21 @@ acpi_ut_display_init_pathname (
347 * 431 *
348 ******************************************************************************/ 432 ******************************************************************************/
349 433
350u8 434u8 acpi_ut_valid_acpi_name(u32 name)
351acpi_ut_valid_acpi_name (
352 u32 name)
353{ 435{
354 char *name_ptr = (char *) &name; 436 char *name_ptr = (char *)&name;
355 char character; 437 char character;
356 acpi_native_uint i; 438 acpi_native_uint i;
357
358
359 ACPI_FUNCTION_ENTRY ();
360 439
440 ACPI_FUNCTION_ENTRY();
361 441
362 for (i = 0; i < ACPI_NAME_SIZE; i++) { 442 for (i = 0; i < ACPI_NAME_SIZE; i++) {
363 character = *name_ptr; 443 character = *name_ptr;
364 name_ptr++; 444 name_ptr++;
365 445
366 if (!((character == '_') || 446 if (!((character == '_') ||
367 (character >= 'A' && character <= 'Z') || 447 (character >= 'A' && character <= 'Z') ||
368 (character >= '0' && character <= '9'))) { 448 (character >= '0' && character <= '9'))) {
369 return (FALSE); 449 return (FALSE);
370 } 450 }
371 } 451 }
@@ -373,7 +453,6 @@ acpi_ut_valid_acpi_name (
373 return (TRUE); 453 return (TRUE);
374} 454}
375 455
376
377/******************************************************************************* 456/*******************************************************************************
378 * 457 *
379 * FUNCTION: acpi_ut_valid_acpi_character 458 * FUNCTION: acpi_ut_valid_acpi_character
@@ -386,19 +465,16 @@ acpi_ut_valid_acpi_name (
386 * 465 *
387 ******************************************************************************/ 466 ******************************************************************************/
388 467
389u8 468u8 acpi_ut_valid_acpi_character(char character)
390acpi_ut_valid_acpi_character (
391 char character)
392{ 469{
393 470
394 ACPI_FUNCTION_ENTRY (); 471 ACPI_FUNCTION_ENTRY();
395 472
396 return ((u8) ((character == '_') || 473 return ((u8) ((character == '_') ||
397 (character >= 'A' && character <= 'Z') || 474 (character >= 'A' && character <= 'Z') ||
398 (character >= '0' && character <= '9'))); 475 (character >= '0' && character <= '9')));
399} 476}
400 477
401
402/******************************************************************************* 478/*******************************************************************************
403 * 479 *
404 * FUNCTION: acpi_ut_strtoul64 480 * FUNCTION: acpi_ut_strtoul64
@@ -415,18 +491,13 @@ acpi_ut_valid_acpi_character (
415 ******************************************************************************/ 491 ******************************************************************************/
416 492
417acpi_status 493acpi_status
418acpi_ut_strtoul64 ( 494acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
419 char *string,
420 u32 base,
421 acpi_integer *ret_integer)
422{ 495{
423 u32 this_digit = 0; 496 u32 this_digit = 0;
424 acpi_integer return_value = 0; 497 acpi_integer return_value = 0;
425 acpi_integer quotient; 498 acpi_integer quotient;
426
427
428 ACPI_FUNCTION_TRACE ("ut_stroul64");
429 499
500 ACPI_FUNCTION_TRACE("ut_stroul64");
430 501
431 if ((!string) || !(*string)) { 502 if ((!string) || !(*string)) {
432 goto error_exit; 503 goto error_exit;
@@ -440,12 +511,12 @@ acpi_ut_strtoul64 (
440 511
441 default: 512 default:
442 /* Invalid Base */ 513 /* Invalid Base */
443 return_ACPI_STATUS (AE_BAD_PARAMETER); 514 return_ACPI_STATUS(AE_BAD_PARAMETER);
444 } 515 }
445 516
446 /* Skip over any white space in the buffer */ 517 /* Skip over any white space in the buffer */
447 518
448 while (ACPI_IS_SPACE (*string) || *string == '\t') { 519 while (ACPI_IS_SPACE(*string) || *string == '\t') {
449 string++; 520 string++;
450 } 521 }
451 522
@@ -454,12 +525,10 @@ acpi_ut_strtoul64 (
454 * determine if it is decimal or hexadecimal: 525 * determine if it is decimal or hexadecimal:
455 */ 526 */
456 if (base == 0) { 527 if (base == 0) {
457 if ((*string == '0') && 528 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
458 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
459 base = 16; 529 base = 16;
460 string += 2; 530 string += 2;
461 } 531 } else {
462 else {
463 base = 10; 532 base = 10;
464 } 533 }
465 } 534 }
@@ -469,8 +538,7 @@ acpi_ut_strtoul64 (
469 * 0 or 0x, if they are present. 538 * 0 or 0x, if they are present.
470 */ 539 */
471 if ((base == 16) && 540 if ((base == 16) &&
472 (*string == '0') && 541 (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
473 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
474 string += 2; 542 string += 2;
475 } 543 }
476 544
@@ -483,25 +551,23 @@ acpi_ut_strtoul64 (
483 /* Main loop: convert the string to a 64-bit integer */ 551 /* Main loop: convert the string to a 64-bit integer */
484 552
485 while (*string) { 553 while (*string) {
486 if (ACPI_IS_DIGIT (*string)) { 554 if (ACPI_IS_DIGIT(*string)) {
487 /* Convert ASCII 0-9 to Decimal value */ 555 /* Convert ASCII 0-9 to Decimal value */
488 556
489 this_digit = ((u8) *string) - '0'; 557 this_digit = ((u8) * string) - '0';
490 } 558 } else {
491 else {
492 if (base == 10) { 559 if (base == 10) {
493 /* Digit is out of range */ 560 /* Digit is out of range */
494 561
495 goto error_exit; 562 goto error_exit;
496 } 563 }
497 564
498 this_digit = (u8) ACPI_TOUPPER (*string); 565 this_digit = (u8) ACPI_TOUPPER(*string);
499 if (ACPI_IS_XDIGIT ((char) this_digit)) { 566 if (ACPI_IS_XDIGIT((char)this_digit)) {
500 /* Convert ASCII Hex char to value */ 567 /* Convert ASCII Hex char to value */
501 568
502 this_digit = this_digit - 'A' + 10; 569 this_digit = this_digit - 'A' + 10;
503 } 570 } else {
504 else {
505 /* 571 /*
506 * We allow non-hex chars, just stop now, same as end-of-string. 572 * We allow non-hex chars, just stop now, same as end-of-string.
507 * See ACPI spec, string-to-integer conversion. 573 * See ACPI spec, string-to-integer conversion.
@@ -512,8 +578,10 @@ acpi_ut_strtoul64 (
512 578
513 /* Divide the digit into the correct position */ 579 /* Divide the digit into the correct position */
514 580
515 (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), 581 (void)
516 base, &quotient, NULL); 582 acpi_ut_short_divide((ACPI_INTEGER_MAX -
583 (acpi_integer) this_digit), base,
584 &quotient, NULL);
517 if (return_value > quotient) { 585 if (return_value > quotient) {
518 goto error_exit; 586 goto error_exit;
519 } 587 }
@@ -526,335 +594,18 @@ acpi_ut_strtoul64 (
526 /* All done, normal exit */ 594 /* All done, normal exit */
527 595
528 *ret_integer = return_value; 596 *ret_integer = return_value;
529 return_ACPI_STATUS (AE_OK); 597 return_ACPI_STATUS(AE_OK);
530
531 598
532error_exit: 599 error_exit:
533 /* Base was set/validated above */ 600 /* Base was set/validated above */
534 601
535 if (base == 10) { 602 if (base == 10) {
536 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); 603 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
537 } 604 } else {
538 else { 605 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
539 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
540 }
541}
542
543
544/*******************************************************************************
545 *
546 * FUNCTION: acpi_ut_mutex_initialize
547 *
548 * PARAMETERS: None.
549 *
550 * RETURN: Status
551 *
552 * DESCRIPTION: Create the system mutex objects.
553 *
554 ******************************************************************************/
555
556acpi_status
557acpi_ut_mutex_initialize (
558 void)
559{
560 u32 i;
561 acpi_status status;
562
563
564 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
565
566
567 /*
568 * Create each of the predefined mutex objects
569 */
570 for (i = 0; i < NUM_MUTEX; i++) {
571 status = acpi_ut_create_mutex (i);
572 if (ACPI_FAILURE (status)) {
573 return_ACPI_STATUS (status);
574 }
575 }
576
577 status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
578 return_ACPI_STATUS (status);
579}
580
581
582/*******************************************************************************
583 *
584 * FUNCTION: acpi_ut_mutex_terminate
585 *
586 * PARAMETERS: None.
587 *
588 * RETURN: None.
589 *
590 * DESCRIPTION: Delete all of the system mutex objects.
591 *
592 ******************************************************************************/
593
594void
595acpi_ut_mutex_terminate (
596 void)
597{
598 u32 i;
599
600
601 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
602
603
604 /*
605 * Delete each predefined mutex object
606 */
607 for (i = 0; i < NUM_MUTEX; i++) {
608 (void) acpi_ut_delete_mutex (i);
609 }
610
611 acpi_os_delete_lock (acpi_gbl_gpe_lock);
612 return_VOID;
613}
614
615
616/*******************************************************************************
617 *
618 * FUNCTION: acpi_ut_create_mutex
619 *
620 * PARAMETERS: mutex_iD - ID of the mutex to be created
621 *
622 * RETURN: Status
623 *
624 * DESCRIPTION: Create a mutex object.
625 *
626 ******************************************************************************/
627
628static acpi_status
629acpi_ut_create_mutex (
630 acpi_mutex_handle mutex_id)
631{
632 acpi_status status = AE_OK;
633
634
635 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
636
637
638 if (mutex_id > MAX_MUTEX) {
639 return_ACPI_STATUS (AE_BAD_PARAMETER);
640 }
641
642 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
643 status = acpi_os_create_semaphore (1, 1,
644 &acpi_gbl_mutex_info[mutex_id].mutex);
645 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
646 acpi_gbl_mutex_info[mutex_id].use_count = 0;
647 }
648
649 return_ACPI_STATUS (status);
650}
651
652
653/*******************************************************************************
654 *
655 * FUNCTION: acpi_ut_delete_mutex
656 *
657 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
658 *
659 * RETURN: Status
660 *
661 * DESCRIPTION: Delete a mutex object.
662 *
663 ******************************************************************************/
664
665static acpi_status
666acpi_ut_delete_mutex (
667 acpi_mutex_handle mutex_id)
668{
669 acpi_status status;
670
671
672 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
673
674
675 if (mutex_id > MAX_MUTEX) {
676 return_ACPI_STATUS (AE_BAD_PARAMETER);
677 }
678
679 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
680
681 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
682 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
683
684 return_ACPI_STATUS (status);
685}
686
687
688/*******************************************************************************
689 *
690 * FUNCTION: acpi_ut_acquire_mutex
691 *
692 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
693 *
694 * RETURN: Status
695 *
696 * DESCRIPTION: Acquire a mutex object.
697 *
698 ******************************************************************************/
699
700acpi_status
701acpi_ut_acquire_mutex (
702 acpi_mutex_handle mutex_id)
703{
704 acpi_status status;
705 u32 this_thread_id;
706
707
708 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
709
710
711 if (mutex_id > MAX_MUTEX) {
712 return (AE_BAD_PARAMETER);
713 }
714
715 this_thread_id = acpi_os_get_thread_id ();
716
717#ifdef ACPI_MUTEX_DEBUG
718 {
719 u32 i;
720 /*
721 * Mutex debug code, for internal debugging only.
722 *
723 * Deadlock prevention. Check if this thread owns any mutexes of value
724 * greater than or equal to this one. If so, the thread has violated
725 * the mutex ordering rule. This indicates a coding error somewhere in
726 * the ACPI subsystem code.
727 */
728 for (i = mutex_id; i < MAX_MUTEX; i++) {
729 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
730 if (i == mutex_id) {
731 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
732 "Mutex [%s] already acquired by this thread [%X]\n",
733 acpi_ut_get_mutex_name (mutex_id), this_thread_id));
734
735 return (AE_ALREADY_ACQUIRED);
736 }
737
738 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
739 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
740 this_thread_id, acpi_ut_get_mutex_name (i),
741 acpi_ut_get_mutex_name (mutex_id)));
742
743 return (AE_ACQUIRE_DEADLOCK);
744 }
745 }
746 }
747#endif
748
749 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
750 "Thread %X attempting to acquire Mutex [%s]\n",
751 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
752
753 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
754 1, ACPI_WAIT_FOREVER);
755 if (ACPI_SUCCESS (status)) {
756 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
757 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
758
759 acpi_gbl_mutex_info[mutex_id].use_count++;
760 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
761 }
762 else {
763 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
764 "Thread %X could not acquire Mutex [%s] %s\n",
765 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
766 acpi_format_exception (status)));
767 }
768
769 return (status);
770}
771
772
773/*******************************************************************************
774 *
775 * FUNCTION: acpi_ut_release_mutex
776 *
777 * PARAMETERS: mutex_iD - ID of the mutex to be released
778 *
779 * RETURN: Status
780 *
781 * DESCRIPTION: Release a mutex object.
782 *
783 ******************************************************************************/
784
785acpi_status
786acpi_ut_release_mutex (
787 acpi_mutex_handle mutex_id)
788{
789 acpi_status status;
790 u32 i;
791 u32 this_thread_id;
792
793
794 ACPI_FUNCTION_NAME ("ut_release_mutex");
795
796
797 this_thread_id = acpi_os_get_thread_id ();
798 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
799 "Thread %X releasing Mutex [%s]\n", this_thread_id,
800 acpi_ut_get_mutex_name (mutex_id)));
801
802 if (mutex_id > MAX_MUTEX) {
803 return (AE_BAD_PARAMETER);
804 }
805
806 /*
807 * Mutex must be acquired in order to release it!
808 */
809 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
810 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
811 "Mutex [%s] is not acquired, cannot release\n",
812 acpi_ut_get_mutex_name (mutex_id)));
813
814 return (AE_NOT_ACQUIRED);
815 }
816
817 /*
818 * Deadlock prevention. Check if this thread owns any mutexes of value
819 * greater than this one. If so, the thread has violated the mutex
820 * ordering rule. This indicates a coding error somewhere in
821 * the ACPI subsystem code.
822 */
823 for (i = mutex_id; i < MAX_MUTEX; i++) {
824 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
825 if (i == mutex_id) {
826 continue;
827 }
828
829 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
830 "Invalid release order: owns [%s], releasing [%s]\n",
831 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
832
833 return (AE_RELEASE_DEADLOCK);
834 }
835 }
836
837 /* Mark unlocked FIRST */
838
839 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
840
841 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
842
843 if (ACPI_FAILURE (status)) {
844 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
845 "Thread %X could not release Mutex [%s] %s\n",
846 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
847 acpi_format_exception (status)));
848 } 606 }
849 else {
850 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
851 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
852 }
853
854 return (status);
855} 607}
856 608
857
858/******************************************************************************* 609/*******************************************************************************
859 * 610 *
860 * FUNCTION: acpi_ut_create_update_state_and_push 611 * FUNCTION: acpi_ut_create_update_state_and_push
@@ -870,16 +621,13 @@ acpi_ut_release_mutex (
870 ******************************************************************************/ 621 ******************************************************************************/
871 622
872acpi_status 623acpi_status
873acpi_ut_create_update_state_and_push ( 624acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
874 union acpi_operand_object *object, 625 u16 action,
875 u16 action, 626 union acpi_generic_state **state_list)
876 union acpi_generic_state **state_list)
877{ 627{
878 union acpi_generic_state *state; 628 union acpi_generic_state *state;
879
880
881 ACPI_FUNCTION_ENTRY ();
882 629
630 ACPI_FUNCTION_ENTRY();
883 631
884 /* Ignore null objects; these are expected */ 632 /* Ignore null objects; these are expected */
885 633
@@ -887,371 +635,15 @@ acpi_ut_create_update_state_and_push (
887 return (AE_OK); 635 return (AE_OK);
888 } 636 }
889 637
890 state = acpi_ut_create_update_state (object, action); 638 state = acpi_ut_create_update_state(object, action);
891 if (!state) { 639 if (!state) {
892 return (AE_NO_MEMORY); 640 return (AE_NO_MEMORY);
893 } 641 }
894 642
895 acpi_ut_push_generic_state (state_list, state); 643 acpi_ut_push_generic_state(state_list, state);
896 return (AE_OK); 644 return (AE_OK);
897} 645}
898 646
899
900/*******************************************************************************
901 *
902 * FUNCTION: acpi_ut_create_pkg_state_and_push
903 *
904 * PARAMETERS: Object - Object to be added to the new state
905 * Action - Increment/Decrement
906 * state_list - List the state will be added to
907 *
908 * RETURN: Status
909 *
910 * DESCRIPTION: Create a new state and push it
911 *
912 ******************************************************************************/
913
914#ifdef ACPI_FUTURE_USAGE
915acpi_status
916acpi_ut_create_pkg_state_and_push (
917 void *internal_object,
918 void *external_object,
919 u16 index,
920 union acpi_generic_state **state_list)
921{
922 union acpi_generic_state *state;
923
924
925 ACPI_FUNCTION_ENTRY ();
926
927
928 state = acpi_ut_create_pkg_state (internal_object, external_object, index);
929 if (!state) {
930 return (AE_NO_MEMORY);
931 }
932
933 acpi_ut_push_generic_state (state_list, state);
934 return (AE_OK);
935}
936#endif /* ACPI_FUTURE_USAGE */
937
938/*******************************************************************************
939 *
940 * FUNCTION: acpi_ut_push_generic_state
941 *
942 * PARAMETERS: list_head - Head of the state stack
943 * State - State object to push
944 *
945 * RETURN: None
946 *
947 * DESCRIPTION: Push a state object onto a state stack
948 *
949 ******************************************************************************/
950
951void
952acpi_ut_push_generic_state (
953 union acpi_generic_state **list_head,
954 union acpi_generic_state *state)
955{
956 ACPI_FUNCTION_TRACE ("ut_push_generic_state");
957
958
959 /* Push the state object onto the front of the list (stack) */
960
961 state->common.next = *list_head;
962 *list_head = state;
963
964 return_VOID;
965}
966
967
968/*******************************************************************************
969 *
970 * FUNCTION: acpi_ut_pop_generic_state
971 *
972 * PARAMETERS: list_head - Head of the state stack
973 *
974 * RETURN: The popped state object
975 *
976 * DESCRIPTION: Pop a state object from a state stack
977 *
978 ******************************************************************************/
979
980union acpi_generic_state *
981acpi_ut_pop_generic_state (
982 union acpi_generic_state **list_head)
983{
984 union acpi_generic_state *state;
985
986
987 ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
988
989
990 /* Remove the state object at the head of the list (stack) */
991
992 state = *list_head;
993 if (state) {
994 /* Update the list head */
995
996 *list_head = state->common.next;
997 }
998
999 return_PTR (state);
1000}
1001
1002
1003/*******************************************************************************
1004 *
1005 * FUNCTION: acpi_ut_create_generic_state
1006 *
1007 * PARAMETERS: None
1008 *
1009 * RETURN: The new state object. NULL on failure.
1010 *
1011 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
1012 * the global state cache; If none available, create a new one.
1013 *
1014 ******************************************************************************/
1015
1016union acpi_generic_state *
1017acpi_ut_create_generic_state (
1018 void)
1019{
1020 union acpi_generic_state *state;
1021
1022
1023 ACPI_FUNCTION_ENTRY ();
1024
1025
1026 state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE);
1027
1028 /* Initialize */
1029
1030 if (state) {
1031 state->common.data_type = ACPI_DESC_TYPE_STATE;
1032 }
1033
1034 return (state);
1035}
1036
1037
1038/*******************************************************************************
1039 *
1040 * FUNCTION: acpi_ut_create_thread_state
1041 *
1042 * PARAMETERS: None
1043 *
1044 * RETURN: New Thread State. NULL on failure
1045 *
1046 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
1047 * to track per-thread info during method execution
1048 *
1049 ******************************************************************************/
1050
1051struct acpi_thread_state *
1052acpi_ut_create_thread_state (
1053 void)
1054{
1055 union acpi_generic_state *state;
1056
1057
1058 ACPI_FUNCTION_TRACE ("ut_create_thread_state");
1059
1060
1061 /* Create the generic state object */
1062
1063 state = acpi_ut_create_generic_state ();
1064 if (!state) {
1065 return_PTR (NULL);
1066 }
1067
1068 /* Init fields specific to the update struct */
1069
1070 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
1071 state->thread.thread_id = acpi_os_get_thread_id ();
1072
1073 return_PTR ((struct acpi_thread_state *) state);
1074}
1075
1076
1077/*******************************************************************************
1078 *
1079 * FUNCTION: acpi_ut_create_update_state
1080 *
1081 * PARAMETERS: Object - Initial Object to be installed in the state
1082 * Action - Update action to be performed
1083 *
1084 * RETURN: New state object, null on failure
1085 *
1086 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
1087 * to update reference counts and delete complex objects such
1088 * as packages.
1089 *
1090 ******************************************************************************/
1091
1092union acpi_generic_state *
1093acpi_ut_create_update_state (
1094 union acpi_operand_object *object,
1095 u16 action)
1096{
1097 union acpi_generic_state *state;
1098
1099
1100 ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
1101
1102
1103 /* Create the generic state object */
1104
1105 state = acpi_ut_create_generic_state ();
1106 if (!state) {
1107 return_PTR (NULL);
1108 }
1109
1110 /* Init fields specific to the update struct */
1111
1112 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
1113 state->update.object = object;
1114 state->update.value = action;
1115
1116 return_PTR (state);
1117}
1118
1119
1120/*******************************************************************************
1121 *
1122 * FUNCTION: acpi_ut_create_pkg_state
1123 *
1124 * PARAMETERS: Object - Initial Object to be installed in the state
1125 * Action - Update action to be performed
1126 *
1127 * RETURN: New state object, null on failure
1128 *
1129 * DESCRIPTION: Create a "Package State"
1130 *
1131 ******************************************************************************/
1132
1133union acpi_generic_state *
1134acpi_ut_create_pkg_state (
1135 void *internal_object,
1136 void *external_object,
1137 u16 index)
1138{
1139 union acpi_generic_state *state;
1140
1141
1142 ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
1143
1144
1145 /* Create the generic state object */
1146
1147 state = acpi_ut_create_generic_state ();
1148 if (!state) {
1149 return_PTR (NULL);
1150 }
1151
1152 /* Init fields specific to the update struct */
1153
1154 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
1155 state->pkg.source_object = (union acpi_operand_object *) internal_object;
1156 state->pkg.dest_object = external_object;
1157 state->pkg.index = index;
1158 state->pkg.num_packages = 1;
1159
1160 return_PTR (state);
1161}
1162
1163
1164/*******************************************************************************
1165 *
1166 * FUNCTION: acpi_ut_create_control_state
1167 *
1168 * PARAMETERS: None
1169 *
1170 * RETURN: New state object, null on failure
1171 *
1172 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
1173 * to support nested IF/WHILE constructs in the AML.
1174 *
1175 ******************************************************************************/
1176
1177union acpi_generic_state *
1178acpi_ut_create_control_state (
1179 void)
1180{
1181 union acpi_generic_state *state;
1182
1183
1184 ACPI_FUNCTION_TRACE ("ut_create_control_state");
1185
1186
1187 /* Create the generic state object */
1188
1189 state = acpi_ut_create_generic_state ();
1190 if (!state) {
1191 return_PTR (NULL);
1192 }
1193
1194 /* Init fields specific to the control struct */
1195
1196 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
1197 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
1198
1199 return_PTR (state);
1200}
1201
1202
1203/*******************************************************************************
1204 *
1205 * FUNCTION: acpi_ut_delete_generic_state
1206 *
1207 * PARAMETERS: State - The state object to be deleted
1208 *
1209 * RETURN: None
1210 *
1211 * DESCRIPTION: Put a state object back into the global state cache. The object
1212 * is not actually freed at this time.
1213 *
1214 ******************************************************************************/
1215
1216void
1217acpi_ut_delete_generic_state (
1218 union acpi_generic_state *state)
1219{
1220 ACPI_FUNCTION_TRACE ("ut_delete_generic_state");
1221
1222
1223 acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);
1224 return_VOID;
1225}
1226
1227
1228#ifdef ACPI_ENABLE_OBJECT_CACHE
1229/*******************************************************************************
1230 *
1231 * FUNCTION: acpi_ut_delete_generic_state_cache
1232 *
1233 * PARAMETERS: None
1234 *
1235 * RETURN: None
1236 *
1237 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1238 * termination.
1239 *
1240 ******************************************************************************/
1241
1242void
1243acpi_ut_delete_generic_state_cache (
1244 void)
1245{
1246 ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache");
1247
1248
1249 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE);
1250 return_VOID;
1251}
1252#endif
1253
1254
1255/******************************************************************************* 647/*******************************************************************************
1256 * 648 *
1257 * FUNCTION: acpi_ut_walk_package_tree 649 * FUNCTION: acpi_ut_walk_package_tree
@@ -1268,33 +660,29 @@ acpi_ut_delete_generic_state_cache (
1268 ******************************************************************************/ 660 ******************************************************************************/
1269 661
1270acpi_status 662acpi_status
1271acpi_ut_walk_package_tree ( 663acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
1272 union acpi_operand_object *source_object, 664 void *target_object,
1273 void *target_object, 665 acpi_pkg_callback walk_callback, void *context)
1274 acpi_pkg_callback walk_callback,
1275 void *context)
1276{ 666{
1277 acpi_status status = AE_OK; 667 acpi_status status = AE_OK;
1278 union acpi_generic_state *state_list = NULL; 668 union acpi_generic_state *state_list = NULL;
1279 union acpi_generic_state *state; 669 union acpi_generic_state *state;
1280 u32 this_index; 670 u32 this_index;
1281 union acpi_operand_object *this_source_obj; 671 union acpi_operand_object *this_source_obj;
1282
1283
1284 ACPI_FUNCTION_TRACE ("ut_walk_package_tree");
1285 672
673 ACPI_FUNCTION_TRACE("ut_walk_package_tree");
1286 674
1287 state = acpi_ut_create_pkg_state (source_object, target_object, 0); 675 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
1288 if (!state) { 676 if (!state) {
1289 return_ACPI_STATUS (AE_NO_MEMORY); 677 return_ACPI_STATUS(AE_NO_MEMORY);
1290 } 678 }
1291 679
1292 while (state) { 680 while (state) {
1293 /* Get one element of the package */ 681 /* Get one element of the package */
1294 682
1295 this_index = state->pkg.index; 683 this_index = state->pkg.index;
1296 this_source_obj = (union acpi_operand_object *) 684 this_source_obj = (union acpi_operand_object *)
1297 state->pkg.source_object->package.elements[this_index]; 685 state->pkg.source_object->package.elements[this_index];
1298 686
1299 /* 687 /*
1300 * Check for: 688 * Check for:
@@ -1305,16 +693,20 @@ acpi_ut_walk_package_tree (
1305 * case below. 693 * case below.
1306 */ 694 */
1307 if ((!this_source_obj) || 695 if ((!this_source_obj) ||
1308 (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || 696 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
1309 (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { 697 ACPI_DESC_TYPE_OPERAND)
1310 status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, 698 || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
1311 state, context); 699 ACPI_TYPE_PACKAGE)) {
1312 if (ACPI_FAILURE (status)) { 700 status =
1313 return_ACPI_STATUS (status); 701 walk_callback(ACPI_COPY_TYPE_SIMPLE,
702 this_source_obj, state, context);
703 if (ACPI_FAILURE(status)) {
704 return_ACPI_STATUS(status);
1314 } 705 }
1315 706
1316 state->pkg.index++; 707 state->pkg.index++;
1317 while (state->pkg.index >= state->pkg.source_object->package.count) { 708 while (state->pkg.index >=
709 state->pkg.source_object->package.count) {
1318 /* 710 /*
1319 * We've handled all of the objects at this level, This means 711 * We've handled all of the objects at this level, This means
1320 * that we have just completed a package. That package may 712 * that we have just completed a package. That package may
@@ -1322,8 +714,8 @@ acpi_ut_walk_package_tree (
1322 * 714 *
1323 * Delete this state and pop the previous state (package). 715 * Delete this state and pop the previous state (package).
1324 */ 716 */
1325 acpi_ut_delete_generic_state (state); 717 acpi_ut_delete_generic_state(state);
1326 state = acpi_ut_pop_generic_state (&state_list); 718 state = acpi_ut_pop_generic_state(&state_list);
1327 719
1328 /* Finished when there are no more states */ 720 /* Finished when there are no more states */
1329 721
@@ -1333,7 +725,7 @@ acpi_ut_walk_package_tree (
1333 * package just add the length of the package objects 725 * package just add the length of the package objects
1334 * and exit 726 * and exit
1335 */ 727 */
1336 return_ACPI_STATUS (AE_OK); 728 return_ACPI_STATUS(AE_OK);
1337 } 729 }
1338 730
1339 /* 731 /*
@@ -1342,35 +734,35 @@ acpi_ut_walk_package_tree (
1342 */ 734 */
1343 state->pkg.index++; 735 state->pkg.index++;
1344 } 736 }
1345 } 737 } else {
1346 else {
1347 /* This is a subobject of type package */ 738 /* This is a subobject of type package */
1348 739
1349 status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, 740 status =
1350 state, context); 741 walk_callback(ACPI_COPY_TYPE_PACKAGE,
1351 if (ACPI_FAILURE (status)) { 742 this_source_obj, state, context);
1352 return_ACPI_STATUS (status); 743 if (ACPI_FAILURE(status)) {
744 return_ACPI_STATUS(status);
1353 } 745 }
1354 746
1355 /* 747 /*
1356 * Push the current state and create a new one 748 * Push the current state and create a new one
1357 * The callback above returned a new target package object. 749 * The callback above returned a new target package object.
1358 */ 750 */
1359 acpi_ut_push_generic_state (&state_list, state); 751 acpi_ut_push_generic_state(&state_list, state);
1360 state = acpi_ut_create_pkg_state (this_source_obj, 752 state = acpi_ut_create_pkg_state(this_source_obj,
1361 state->pkg.this_target_obj, 0); 753 state->pkg.
754 this_target_obj, 0);
1362 if (!state) { 755 if (!state) {
1363 return_ACPI_STATUS (AE_NO_MEMORY); 756 return_ACPI_STATUS(AE_NO_MEMORY);
1364 } 757 }
1365 } 758 }
1366 } 759 }
1367 760
1368 /* We should never get here */ 761 /* We should never get here */
1369 762
1370 return_ACPI_STATUS (AE_AML_INTERNAL); 763 return_ACPI_STATUS(AE_AML_INTERNAL);
1371} 764}
1372 765
1373
1374/******************************************************************************* 766/*******************************************************************************
1375 * 767 *
1376 * FUNCTION: acpi_ut_generate_checksum 768 * FUNCTION: acpi_ut_generate_checksum
@@ -1384,23 +776,18 @@ acpi_ut_walk_package_tree (
1384 * 776 *
1385 ******************************************************************************/ 777 ******************************************************************************/
1386 778
1387u8 779u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
1388acpi_ut_generate_checksum (
1389 u8 *buffer,
1390 u32 length)
1391{ 780{
1392 u32 i; 781 u32 i;
1393 signed char sum = 0; 782 signed char sum = 0;
1394
1395 783
1396 for (i = 0; i < length; i++) { 784 for (i = 0; i < length; i++) {
1397 sum = (signed char) (sum + buffer[i]); 785 sum = (signed char)(sum + buffer[i]);
1398 } 786 }
1399 787
1400 return ((u8) (0 - sum)); 788 return ((u8) (0 - sum));
1401} 789}
1402 790
1403
1404/******************************************************************************* 791/*******************************************************************************
1405 * 792 *
1406 * FUNCTION: acpi_ut_get_resource_end_tag 793 * FUNCTION: acpi_ut_get_resource_end_tag
@@ -1413,17 +800,13 @@ acpi_ut_generate_checksum (
1413 * 800 *
1414 ******************************************************************************/ 801 ******************************************************************************/
1415 802
1416 803u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
1417u8 *
1418acpi_ut_get_resource_end_tag (
1419 union acpi_operand_object *obj_desc)
1420{ 804{
1421 u8 buffer_byte; 805 u8 buffer_byte;
1422 u8 *buffer; 806 u8 *buffer;
1423 u8 *end_buffer; 807 u8 *end_buffer;
1424
1425 808
1426 buffer = obj_desc->buffer.pointer; 809 buffer = obj_desc->buffer.pointer;
1427 end_buffer = buffer + obj_desc->buffer.length; 810 end_buffer = buffer + obj_desc->buffer.length;
1428 811
1429 while (buffer < end_buffer) { 812 while (buffer < end_buffer) {
@@ -1431,12 +814,12 @@ acpi_ut_get_resource_end_tag (
1431 if (buffer_byte & ACPI_RDESC_TYPE_MASK) { 814 if (buffer_byte & ACPI_RDESC_TYPE_MASK) {
1432 /* Large Descriptor - Length is next 2 bytes */ 815 /* Large Descriptor - Length is next 2 bytes */
1433 816
1434 buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); 817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3);
1435 } 818 } else {
1436 else {
1437 /* Small Descriptor. End Tag will be found here */ 819 /* Small Descriptor. End Tag will be found here */
1438 820
1439 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { 821 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) ==
822 ACPI_RDESC_TYPE_END_TAG) {
1440 /* Found the end tag descriptor, all done. */ 823 /* Found the end tag descriptor, all done. */
1441 824
1442 return (buffer); 825 return (buffer);
@@ -1453,7 +836,6 @@ acpi_ut_get_resource_end_tag (
1453 return (NULL); 836 return (NULL);
1454} 837}
1455 838
1456
1457/******************************************************************************* 839/*******************************************************************************
1458 * 840 *
1459 * FUNCTION: acpi_ut_report_error 841 * FUNCTION: acpi_ut_report_error
@@ -1468,17 +850,12 @@ acpi_ut_get_resource_end_tag (
1468 * 850 *
1469 ******************************************************************************/ 851 ******************************************************************************/
1470 852
1471void 853void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id)
1472acpi_ut_report_error (
1473 char *module_name,
1474 u32 line_number,
1475 u32 component_id)
1476{ 854{
1477 855
1478 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 856 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
1479} 857}
1480 858
1481
1482/******************************************************************************* 859/*******************************************************************************
1483 * 860 *
1484 * FUNCTION: acpi_ut_report_warning 861 * FUNCTION: acpi_ut_report_warning
@@ -1494,16 +871,12 @@ acpi_ut_report_error (
1494 ******************************************************************************/ 871 ******************************************************************************/
1495 872
1496void 873void
1497acpi_ut_report_warning ( 874acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
1498 char *module_name,
1499 u32 line_number,
1500 u32 component_id)
1501{ 875{
1502 876
1503 acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); 877 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number);
1504} 878}
1505 879
1506
1507/******************************************************************************* 880/*******************************************************************************
1508 * 881 *
1509 * FUNCTION: acpi_ut_report_info 882 * FUNCTION: acpi_ut_report_info
@@ -1518,14 +891,8 @@ acpi_ut_report_warning (
1518 * 891 *
1519 ******************************************************************************/ 892 ******************************************************************************/
1520 893
1521void 894void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
1522acpi_ut_report_info (
1523 char *module_name,
1524 u32 line_number,
1525 u32 component_id)
1526{ 895{
1527 896
1528 acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); 897 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number);
1529} 898}
1530
1531
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
new file mode 100644
index 000000000000..90134c56ece9
--- /dev/null
+++ b/drivers/acpi/utilities/utmutex.c
@@ -0,0 +1,354 @@
1/*******************************************************************************
2 *
3 * Module Name: utmutex - local mutex support
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utmutex")
48
49/* Local prototypes */
50static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
51
52static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ut_mutex_initialize
57 *
58 * PARAMETERS: None.
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Create the system mutex objects.
63 *
64 ******************************************************************************/
65
66acpi_status acpi_ut_mutex_initialize(void)
67{
68 u32 i;
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE("ut_mutex_initialize");
72
73 /*
74 * Create each of the predefined mutex objects
75 */
76 for (i = 0; i < NUM_MUTEX; i++) {
77 status = acpi_ut_create_mutex(i);
78 if (ACPI_FAILURE(status)) {
79 return_ACPI_STATUS(status);
80 }
81 }
82
83 status = acpi_os_create_lock(&acpi_gbl_gpe_lock);
84 return_ACPI_STATUS(status);
85}
86
87/*******************************************************************************
88 *
89 * FUNCTION: acpi_ut_mutex_terminate
90 *
91 * PARAMETERS: None.
92 *
93 * RETURN: None.
94 *
95 * DESCRIPTION: Delete all of the system mutex objects.
96 *
97 ******************************************************************************/
98
99void acpi_ut_mutex_terminate(void)
100{
101 u32 i;
102
103 ACPI_FUNCTION_TRACE("ut_mutex_terminate");
104
105 /*
106 * Delete each predefined mutex object
107 */
108 for (i = 0; i < NUM_MUTEX; i++) {
109 (void)acpi_ut_delete_mutex(i);
110 }
111
112 acpi_os_delete_lock(acpi_gbl_gpe_lock);
113 return_VOID;
114}
115
116/*******************************************************************************
117 *
118 * FUNCTION: acpi_ut_create_mutex
119 *
120 * PARAMETERS: mutex_iD - ID of the mutex to be created
121 *
122 * RETURN: Status
123 *
124 * DESCRIPTION: Create a mutex object.
125 *
126 ******************************************************************************/
127
128static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
129{
130 acpi_status status = AE_OK;
131
132 ACPI_FUNCTION_TRACE_U32("ut_create_mutex", mutex_id);
133
134 if (mutex_id > MAX_MUTEX) {
135 return_ACPI_STATUS(AE_BAD_PARAMETER);
136 }
137
138 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
139 status = acpi_os_create_semaphore(1, 1,
140 &acpi_gbl_mutex_info
141 [mutex_id].mutex);
142 acpi_gbl_mutex_info[mutex_id].thread_id =
143 ACPI_MUTEX_NOT_ACQUIRED;
144 acpi_gbl_mutex_info[mutex_id].use_count = 0;
145 }
146
147 return_ACPI_STATUS(status);
148}
149
150/*******************************************************************************
151 *
152 * FUNCTION: acpi_ut_delete_mutex
153 *
154 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
155 *
156 * RETURN: Status
157 *
158 * DESCRIPTION: Delete a mutex object.
159 *
160 ******************************************************************************/
161
162static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
163{
164 acpi_status status;
165
166 ACPI_FUNCTION_TRACE_U32("ut_delete_mutex", mutex_id);
167
168 if (mutex_id > MAX_MUTEX) {
169 return_ACPI_STATUS(AE_BAD_PARAMETER);
170 }
171
172 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);
173
174 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
175 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
176
177 return_ACPI_STATUS(status);
178}
179
180/*******************************************************************************
181 *
182 * FUNCTION: acpi_ut_acquire_mutex
183 *
184 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
185 *
186 * RETURN: Status
187 *
188 * DESCRIPTION: Acquire a mutex object.
189 *
190 ******************************************************************************/
191
192acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
193{
194 acpi_status status;
195 u32 this_thread_id;
196
197 ACPI_FUNCTION_NAME("ut_acquire_mutex");
198
199 if (mutex_id > MAX_MUTEX) {
200 return (AE_BAD_PARAMETER);
201 }
202
203 this_thread_id = acpi_os_get_thread_id();
204
205#ifdef ACPI_MUTEX_DEBUG
206 {
207 u32 i;
208 /*
209 * Mutex debug code, for internal debugging only.
210 *
211 * Deadlock prevention. Check if this thread owns any mutexes of value
212 * greater than or equal to this one. If so, the thread has violated
213 * the mutex ordering rule. This indicates a coding error somewhere in
214 * the ACPI subsystem code.
215 */
216 for (i = mutex_id; i < MAX_MUTEX; i++) {
217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
218 if (i == mutex_id) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
220 "Mutex [%s] already acquired by this thread [%X]\n",
221 acpi_ut_get_mutex_name
222 (mutex_id),
223 this_thread_id));
224
225 return (AE_ALREADY_ACQUIRED);
226 }
227
228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
230 this_thread_id,
231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name
233 (mutex_id)));
234
235 return (AE_ACQUIRE_DEADLOCK);
236 }
237 }
238 }
239#endif
240
241 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
242 "Thread %X attempting to acquire Mutex [%s]\n",
243 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
244
245 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,
246 1, ACPI_WAIT_FOREVER);
247 if (ACPI_SUCCESS(status)) {
248 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
249 "Thread %X acquired Mutex [%s]\n",
250 this_thread_id,
251 acpi_ut_get_mutex_name(mutex_id)));
252
253 acpi_gbl_mutex_info[mutex_id].use_count++;
254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
255 } else {
256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
257 "Thread %X could not acquire Mutex [%s] %s\n",
258 this_thread_id,
259 acpi_ut_get_mutex_name(mutex_id),
260 acpi_format_exception(status)));
261 }
262
263 return (status);
264}
265
266/*******************************************************************************
267 *
268 * FUNCTION: acpi_ut_release_mutex
269 *
270 * PARAMETERS: mutex_iD - ID of the mutex to be released
271 *
272 * RETURN: Status
273 *
274 * DESCRIPTION: Release a mutex object.
275 *
276 ******************************************************************************/
277
278acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
279{
280 acpi_status status;
281 u32 this_thread_id;
282
283 ACPI_FUNCTION_NAME("ut_release_mutex");
284
285 this_thread_id = acpi_os_get_thread_id();
286 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
287 "Thread %X releasing Mutex [%s]\n", this_thread_id,
288 acpi_ut_get_mutex_name(mutex_id)));
289
290 if (mutex_id > MAX_MUTEX) {
291 return (AE_BAD_PARAMETER);
292 }
293
294 /*
295 * Mutex must be acquired in order to release it!
296 */
297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
299 "Mutex [%s] is not acquired, cannot release\n",
300 acpi_ut_get_mutex_name(mutex_id)));
301
302 return (AE_NOT_ACQUIRED);
303 }
304#ifdef ACPI_MUTEX_DEBUG
305 {
306 u32 i;
307 /*
308 * Mutex debug code, for internal debugging only.
309 *
310 * Deadlock prevention. Check if this thread owns any mutexes of value
311 * greater than this one. If so, the thread has violated the mutex
312 * ordering rule. This indicates a coding error somewhere in
313 * the ACPI subsystem code.
314 */
315 for (i = mutex_id; i < MAX_MUTEX; i++) {
316 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
317 if (i == mutex_id) {
318 continue;
319 }
320
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
322 "Invalid release order: owns [%s], releasing [%s]\n",
323 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name
325 (mutex_id)));
326
327 return (AE_RELEASE_DEADLOCK);
328 }
329 }
330 }
331#endif
332
333 /* Mark unlocked FIRST */
334
335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
336
337 status =
338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
339
340 if (ACPI_FAILURE(status)) {
341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
342 "Thread %X could not release Mutex [%s] %s\n",
343 this_thread_id,
344 acpi_ut_get_mutex_name(mutex_id),
345 acpi_format_exception(status)));
346 } else {
347 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
348 "Thread %X released Mutex [%s]\n",
349 this_thread_id,
350 acpi_ut_get_mutex_name(mutex_id)));
351 }
352
353 return (status);
354}
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index cd3899b9cc5a..3015e1540053 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -41,34 +41,26 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
48 47
49
50#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utobject") 49ACPI_MODULE_NAME("utobject")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static acpi_status 52static acpi_status
56acpi_ut_get_simple_object_size ( 53acpi_ut_get_simple_object_size(union acpi_operand_object *obj,
57 union acpi_operand_object *obj, 54 acpi_size * obj_length);
58 acpi_size *obj_length);
59 55
60static acpi_status 56static acpi_status
61acpi_ut_get_package_object_size ( 57acpi_ut_get_package_object_size(union acpi_operand_object *obj,
62 union acpi_operand_object *obj, 58 acpi_size * obj_length);
63 acpi_size *obj_length);
64 59
65static acpi_status 60static acpi_status
66acpi_ut_get_element_length ( 61acpi_ut_get_element_length(u8 object_type,
67 u8 object_type, 62 union acpi_operand_object *source_object,
68 union acpi_operand_object *source_object, 63 union acpi_generic_state *state, void *context);
69 union acpi_generic_state *state,
70 void *context);
71
72 64
73/******************************************************************************* 65/*******************************************************************************
74 * 66 *
@@ -91,26 +83,25 @@ acpi_ut_get_element_length (
91 * 83 *
92 ******************************************************************************/ 84 ******************************************************************************/
93 85
94union acpi_operand_object * 86union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name,
95acpi_ut_create_internal_object_dbg ( 87 u32 line_number,
96 char *module_name, 88 u32 component_id,
97 u32 line_number, 89 acpi_object_type
98 u32 component_id, 90 type)
99 acpi_object_type type)
100{ 91{
101 union acpi_operand_object *object; 92 union acpi_operand_object *object;
102 union acpi_operand_object *second_object; 93 union acpi_operand_object *second_object;
103
104
105 ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg",
106 acpi_ut_get_type_name (type));
107 94
95 ACPI_FUNCTION_TRACE_STR("ut_create_internal_object_dbg",
96 acpi_ut_get_type_name(type));
108 97
109 /* Allocate the raw object descriptor */ 98 /* Allocate the raw object descriptor */
110 99
111 object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id); 100 object =
101 acpi_ut_allocate_object_desc_dbg(module_name, line_number,
102 component_id);
112 if (!object) { 103 if (!object) {
113 return_PTR (NULL); 104 return_PTR(NULL);
114 } 105 }
115 106
116 switch (type) { 107 switch (type) {
@@ -119,11 +110,12 @@ acpi_ut_create_internal_object_dbg (
119 110
120 /* These types require a secondary object */ 111 /* These types require a secondary object */
121 112
122 second_object = acpi_ut_allocate_object_desc_dbg (module_name, 113 second_object = acpi_ut_allocate_object_desc_dbg(module_name,
123 line_number, component_id); 114 line_number,
115 component_id);
124 if (!second_object) { 116 if (!second_object) {
125 acpi_ut_delete_object_desc (object); 117 acpi_ut_delete_object_desc(object);
126 return_PTR (NULL); 118 return_PTR(NULL);
127 } 119 }
128 120
129 second_object->common.type = ACPI_TYPE_LOCAL_EXTRA; 121 second_object->common.type = ACPI_TYPE_LOCAL_EXTRA;
@@ -149,10 +141,9 @@ acpi_ut_create_internal_object_dbg (
149 141
150 /* Any per-type initialization should go here */ 142 /* Any per-type initialization should go here */
151 143
152 return_PTR (object); 144 return_PTR(object);
153} 145}
154 146
155
156/******************************************************************************* 147/*******************************************************************************
157 * 148 *
158 * FUNCTION: acpi_ut_create_buffer_object 149 * FUNCTION: acpi_ut_create_buffer_object
@@ -165,22 +156,18 @@ acpi_ut_create_internal_object_dbg (
165 * 156 *
166 ******************************************************************************/ 157 ******************************************************************************/
167 158
168union acpi_operand_object * 159union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size)
169acpi_ut_create_buffer_object (
170 acpi_size buffer_size)
171{ 160{
172 union acpi_operand_object *buffer_desc; 161 union acpi_operand_object *buffer_desc;
173 u8 *buffer = NULL; 162 u8 *buffer = NULL;
174
175
176 ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size);
177 163
164 ACPI_FUNCTION_TRACE_U32("ut_create_buffer_object", buffer_size);
178 165
179 /* Create a new Buffer object */ 166 /* Create a new Buffer object */
180 167
181 buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); 168 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
182 if (!buffer_desc) { 169 if (!buffer_desc) {
183 return_PTR (NULL); 170 return_PTR(NULL);
184 } 171 }
185 172
186 /* Create an actual buffer only if size > 0 */ 173 /* Create an actual buffer only if size > 0 */
@@ -188,12 +175,11 @@ acpi_ut_create_buffer_object (
188 if (buffer_size > 0) { 175 if (buffer_size > 0) {
189 /* Allocate the actual buffer */ 176 /* Allocate the actual buffer */
190 177
191 buffer = ACPI_MEM_CALLOCATE (buffer_size); 178 buffer = ACPI_MEM_CALLOCATE(buffer_size);
192 if (!buffer) { 179 if (!buffer) {
193 ACPI_REPORT_ERROR (("create_buffer: could not allocate size %X\n", 180 ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size));
194 (u32) buffer_size)); 181 acpi_ut_remove_reference(buffer_desc);
195 acpi_ut_remove_reference (buffer_desc); 182 return_PTR(NULL);
196 return_PTR (NULL);
197 } 183 }
198 } 184 }
199 185
@@ -205,10 +191,9 @@ acpi_ut_create_buffer_object (
205 191
206 /* Return the new buffer descriptor */ 192 /* Return the new buffer descriptor */
207 193
208 return_PTR (buffer_desc); 194 return_PTR(buffer_desc);
209} 195}
210 196
211
212/******************************************************************************* 197/*******************************************************************************
213 * 198 *
214 * FUNCTION: acpi_ut_create_string_object 199 * FUNCTION: acpi_ut_create_string_object
@@ -223,34 +208,29 @@ acpi_ut_create_buffer_object (
223 * 208 *
224 ******************************************************************************/ 209 ******************************************************************************/
225 210
226union acpi_operand_object * 211union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
227acpi_ut_create_string_object (
228 acpi_size string_size)
229{ 212{
230 union acpi_operand_object *string_desc; 213 union acpi_operand_object *string_desc;
231 char *string; 214 char *string;
232
233
234 ACPI_FUNCTION_TRACE_U32 ("ut_create_string_object", string_size);
235 215
216 ACPI_FUNCTION_TRACE_U32("ut_create_string_object", string_size);
236 217
237 /* Create a new String object */ 218 /* Create a new String object */
238 219
239 string_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING); 220 string_desc = acpi_ut_create_internal_object(ACPI_TYPE_STRING);
240 if (!string_desc) { 221 if (!string_desc) {
241 return_PTR (NULL); 222 return_PTR(NULL);
242 } 223 }
243 224
244 /* 225 /*
245 * Allocate the actual string buffer -- (Size + 1) for NULL terminator. 226 * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
246 * NOTE: Zero-length strings are NULL terminated 227 * NOTE: Zero-length strings are NULL terminated
247 */ 228 */
248 string = ACPI_MEM_CALLOCATE (string_size + 1); 229 string = ACPI_MEM_CALLOCATE(string_size + 1);
249 if (!string) { 230 if (!string) {
250 ACPI_REPORT_ERROR (("create_string: could not allocate size %X\n", 231 ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size));
251 (u32) string_size)); 232 acpi_ut_remove_reference(string_desc);
252 acpi_ut_remove_reference (string_desc); 233 return_PTR(NULL);
253 return_PTR (NULL);
254 } 234 }
255 235
256 /* Complete string object initialization */ 236 /* Complete string object initialization */
@@ -260,10 +240,9 @@ acpi_ut_create_string_object (
260 240
261 /* Return the new string descriptor */ 241 /* Return the new string descriptor */
262 242
263 return_PTR (string_desc); 243 return_PTR(string_desc);
264} 244}
265 245
266
267/******************************************************************************* 246/*******************************************************************************
268 * 247 *
269 * FUNCTION: acpi_ut_valid_internal_object 248 * FUNCTION: acpi_ut_valid_internal_object
@@ -276,24 +255,21 @@ acpi_ut_create_string_object (
276 * 255 *
277 ******************************************************************************/ 256 ******************************************************************************/
278 257
279u8 258u8 acpi_ut_valid_internal_object(void *object)
280acpi_ut_valid_internal_object (
281 void *object)
282{ 259{
283 260
284 ACPI_FUNCTION_NAME ("ut_valid_internal_object"); 261 ACPI_FUNCTION_NAME("ut_valid_internal_object");
285
286 262
287 /* Check for a null pointer */ 263 /* Check for a null pointer */
288 264
289 if (!object) { 265 if (!object) {
290 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n"));
291 return (FALSE); 267 return (FALSE);
292 } 268 }
293 269
294 /* Check the descriptor type field */ 270 /* Check the descriptor type field */
295 271
296 switch (ACPI_GET_DESCRIPTOR_TYPE (object)) { 272 switch (ACPI_GET_DESCRIPTOR_TYPE(object)) {
297 case ACPI_DESC_TYPE_OPERAND: 273 case ACPI_DESC_TYPE_OPERAND:
298 274
299 /* The object appears to be a valid union acpi_operand_object */ 275 /* The object appears to be a valid union acpi_operand_object */
@@ -301,16 +277,15 @@ acpi_ut_valid_internal_object (
301 return (TRUE); 277 return (TRUE);
302 278
303 default: 279 default:
304 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 280 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
305 "%p is not not an ACPI operand obj [%s]\n", 281 "%p is not not an ACPI operand obj [%s]\n",
306 object, acpi_ut_get_descriptor_name (object))); 282 object, acpi_ut_get_descriptor_name(object)));
307 break; 283 break;
308 } 284 }
309 285
310 return (FALSE); 286 return (FALSE);
311} 287}
312 288
313
314/******************************************************************************* 289/*******************************************************************************
315 * 290 *
316 * FUNCTION: acpi_ut_allocate_object_desc_dbg 291 * FUNCTION: acpi_ut_allocate_object_desc_dbg
@@ -326,37 +301,31 @@ acpi_ut_valid_internal_object (
326 * 301 *
327 ******************************************************************************/ 302 ******************************************************************************/
328 303
329void * 304void *acpi_ut_allocate_object_desc_dbg(char *module_name,
330acpi_ut_allocate_object_desc_dbg ( 305 u32 line_number, u32 component_id)
331 char *module_name,
332 u32 line_number,
333 u32 component_id)
334{ 306{
335 union acpi_operand_object *object; 307 union acpi_operand_object *object;
336 308
309 ACPI_FUNCTION_TRACE("ut_allocate_object_desc_dbg");
337 310
338 ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); 311 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
339
340
341 object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND);
342 if (!object) { 312 if (!object) {
343 _ACPI_REPORT_ERROR (module_name, line_number, component_id, 313 _ACPI_REPORT_ERROR(module_name, line_number, component_id,
344 ("Could not allocate an object descriptor\n")); 314 ("Could not allocate an object descriptor\n"));
345 315
346 return_PTR (NULL); 316 return_PTR(NULL);
347 } 317 }
348 318
349 /* Mark the descriptor type */ 319 /* Mark the descriptor type */
320 memset(object, 0, sizeof(union acpi_operand_object));
321 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND);
350 322
351 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); 323 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
324 object, (u32) sizeof(union acpi_operand_object)));
352 325
353 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", 326 return_PTR(object);
354 object, (u32) sizeof (union acpi_operand_object)));
355
356 return_PTR (object);
357} 327}
358 328
359
360/******************************************************************************* 329/*******************************************************************************
361 * 330 *
362 * FUNCTION: acpi_ut_delete_object_desc 331 * FUNCTION: acpi_ut_delete_object_desc
@@ -369,54 +338,22 @@ acpi_ut_allocate_object_desc_dbg (
369 * 338 *
370 ******************************************************************************/ 339 ******************************************************************************/
371 340
372void 341void acpi_ut_delete_object_desc(union acpi_operand_object *object)
373acpi_ut_delete_object_desc (
374 union acpi_operand_object *object)
375{ 342{
376 ACPI_FUNCTION_TRACE_PTR ("ut_delete_object_desc", object); 343 ACPI_FUNCTION_TRACE_PTR("ut_delete_object_desc", object);
377
378 344
379 /* Object must be an union acpi_operand_object */ 345 /* Object must be an union acpi_operand_object */
380 346
381 if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_OPERAND) { 347 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
383 "%p is not an ACPI Operand object [%s]\n", object, 349 "%p is not an ACPI Operand object [%s]\n",
384 acpi_ut_get_descriptor_name (object))); 350 object, acpi_ut_get_descriptor_name(object)));
385 return_VOID; 351 return_VOID;
386 } 352 }
387 353
388 acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); 354 (void)acpi_os_release_object(acpi_gbl_operand_cache, object);
389
390 return_VOID;
391}
392
393
394#ifdef ACPI_ENABLE_OBJECT_CACHE
395/*******************************************************************************
396 *
397 * FUNCTION: acpi_ut_delete_object_cache
398 *
399 * PARAMETERS: None
400 *
401 * RETURN: None
402 *
403 * DESCRIPTION: Purge the global state object cache. Used during subsystem
404 * termination.
405 *
406 ******************************************************************************/
407
408void
409acpi_ut_delete_object_cache (
410 void)
411{
412 ACPI_FUNCTION_TRACE ("ut_delete_object_cache");
413
414
415 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND);
416 return_VOID; 355 return_VOID;
417} 356}
418#endif
419
420 357
421/******************************************************************************* 358/*******************************************************************************
422 * 359 *
@@ -436,16 +373,13 @@ acpi_ut_delete_object_cache (
436 ******************************************************************************/ 373 ******************************************************************************/
437 374
438static acpi_status 375static acpi_status
439acpi_ut_get_simple_object_size ( 376acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
440 union acpi_operand_object *internal_object, 377 acpi_size * obj_length)
441 acpi_size *obj_length)
442{ 378{
443 acpi_size length; 379 acpi_size length;
444 acpi_status status = AE_OK; 380 acpi_status status = AE_OK;
445
446
447 ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
448 381
382 ACPI_FUNCTION_TRACE_PTR("ut_get_simple_object_size", internal_object);
449 383
450 /* 384 /*
451 * Handle a null object (Could be a uninitialized package 385 * Handle a null object (Could be a uninitialized package
@@ -453,18 +387,18 @@ acpi_ut_get_simple_object_size (
453 */ 387 */
454 if (!internal_object) { 388 if (!internal_object) {
455 *obj_length = 0; 389 *obj_length = 0;
456 return_ACPI_STATUS (AE_OK); 390 return_ACPI_STATUS(AE_OK);
457 } 391 }
458 392
459 /* Start with the length of the Acpi object */ 393 /* Start with the length of the Acpi object */
460 394
461 length = sizeof (union acpi_object); 395 length = sizeof(union acpi_object);
462 396
463 if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) { 397 if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) {
464 /* Object is a named object (reference), just return the length */ 398 /* Object is a named object (reference), just return the length */
465 399
466 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 400 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
467 return_ACPI_STATUS (status); 401 return_ACPI_STATUS(status);
468 } 402 }
469 403
470 /* 404 /*
@@ -473,19 +407,17 @@ acpi_ut_get_simple_object_size (
473 * must be accessed bytewise or there may be alignment problems on 407 * must be accessed bytewise or there may be alignment problems on
474 * certain processors 408 * certain processors
475 */ 409 */
476 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 410 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
477 case ACPI_TYPE_STRING: 411 case ACPI_TYPE_STRING:
478 412
479 length += (acpi_size) internal_object->string.length + 1; 413 length += (acpi_size) internal_object->string.length + 1;
480 break; 414 break;
481 415
482
483 case ACPI_TYPE_BUFFER: 416 case ACPI_TYPE_BUFFER:
484 417
485 length += (acpi_size) internal_object->buffer.length; 418 length += (acpi_size) internal_object->buffer.length;
486 break; 419 break;
487 420
488
489 case ACPI_TYPE_INTEGER: 421 case ACPI_TYPE_INTEGER:
490 case ACPI_TYPE_PROCESSOR: 422 case ACPI_TYPE_PROCESSOR:
491 case ACPI_TYPE_POWER: 423 case ACPI_TYPE_POWER:
@@ -495,7 +427,6 @@ acpi_ut_get_simple_object_size (
495 */ 427 */
496 break; 428 break;
497 429
498
499 case ACPI_TYPE_LOCAL_REFERENCE: 430 case ACPI_TYPE_LOCAL_REFERENCE:
500 431
501 switch (internal_object->reference.opcode) { 432 switch (internal_object->reference.opcode) {
@@ -505,8 +436,10 @@ acpi_ut_get_simple_object_size (
505 * Get the actual length of the full pathname to this object. 436 * Get the actual length of the full pathname to this object.
506 * The reference will be converted to the pathname to the object 437 * The reference will be converted to the pathname to the object
507 */ 438 */
508 length += ACPI_ROUND_UP_TO_NATIVE_WORD ( 439 length +=
509 acpi_ns_get_pathname_length (internal_object->reference.node)); 440 ACPI_ROUND_UP_TO_NATIVE_WORD
441 (acpi_ns_get_pathname_length
442 (internal_object->reference.node));
510 break; 443 break;
511 444
512 default: 445 default:
@@ -516,19 +449,21 @@ acpi_ut_get_simple_object_size (
516 * Notably, Locals and Args are not supported, but this may be 449 * Notably, Locals and Args are not supported, but this may be
517 * required eventually. 450 * required eventually.
518 */ 451 */
519 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
520 "Unsupported Reference opcode=%X in object %p\n", 453 "Unsupported Reference opcode=%X in object %p\n",
521 internal_object->reference.opcode, internal_object)); 454 internal_object->reference.opcode,
455 internal_object));
522 status = AE_TYPE; 456 status = AE_TYPE;
523 break; 457 break;
524 } 458 }
525 break; 459 break;
526 460
527
528 default: 461 default:
529 462
530 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", 463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
531 ACPI_GET_OBJECT_TYPE (internal_object), internal_object)); 464 "Unsupported type=%X in object %p\n",
465 ACPI_GET_OBJECT_TYPE(internal_object),
466 internal_object));
532 status = AE_TYPE; 467 status = AE_TYPE;
533 break; 468 break;
534 } 469 }
@@ -539,11 +474,10 @@ acpi_ut_get_simple_object_size (
539 * on a machine word boundary. (preventing alignment faults on some 474 * on a machine word boundary. (preventing alignment faults on some
540 * machines.) 475 * machines.)
541 */ 476 */
542 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 477 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
543 return_ACPI_STATUS (status); 478 return_ACPI_STATUS(status);
544} 479}
545 480
546
547/******************************************************************************* 481/*******************************************************************************
548 * 482 *
549 * FUNCTION: acpi_ut_get_element_length 483 * FUNCTION: acpi_ut_get_element_length
@@ -557,16 +491,13 @@ acpi_ut_get_simple_object_size (
557 ******************************************************************************/ 491 ******************************************************************************/
558 492
559static acpi_status 493static acpi_status
560acpi_ut_get_element_length ( 494acpi_ut_get_element_length(u8 object_type,
561 u8 object_type, 495 union acpi_operand_object *source_object,
562 union acpi_operand_object *source_object, 496 union acpi_generic_state *state, void *context)
563 union acpi_generic_state *state,
564 void *context)
565{ 497{
566 acpi_status status = AE_OK; 498 acpi_status status = AE_OK;
567 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 499 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
568 acpi_size object_space; 500 acpi_size object_space;
569
570 501
571 switch (object_type) { 502 switch (object_type) {
572 case ACPI_COPY_TYPE_SIMPLE: 503 case ACPI_COPY_TYPE_SIMPLE:
@@ -575,15 +506,16 @@ acpi_ut_get_element_length (
575 * Simple object - just get the size (Null object/entry is handled 506 * Simple object - just get the size (Null object/entry is handled
576 * here also) and sum it into the running package length 507 * here also) and sum it into the running package length
577 */ 508 */
578 status = acpi_ut_get_simple_object_size (source_object, &object_space); 509 status =
579 if (ACPI_FAILURE (status)) { 510 acpi_ut_get_simple_object_size(source_object,
511 &object_space);
512 if (ACPI_FAILURE(status)) {
580 return (status); 513 return (status);
581 } 514 }
582 515
583 info->length += object_space; 516 info->length += object_space;
584 break; 517 break;
585 518
586
587 case ACPI_COPY_TYPE_PACKAGE: 519 case ACPI_COPY_TYPE_PACKAGE:
588 520
589 /* Package object - nothing much to do here, let the walk handle it */ 521 /* Package object - nothing much to do here, let the walk handle it */
@@ -592,7 +524,6 @@ acpi_ut_get_element_length (
592 state->pkg.this_target_obj = NULL; 524 state->pkg.this_target_obj = NULL;
593 break; 525 break;
594 526
595
596 default: 527 default:
597 528
598 /* No other types allowed */ 529 /* No other types allowed */
@@ -603,7 +534,6 @@ acpi_ut_get_element_length (
603 return (status); 534 return (status);
604} 535}
605 536
606
607/******************************************************************************* 537/*******************************************************************************
608 * 538 *
609 * FUNCTION: acpi_ut_get_package_object_size 539 * FUNCTION: acpi_ut_get_package_object_size
@@ -622,25 +552,22 @@ acpi_ut_get_element_length (
622 ******************************************************************************/ 552 ******************************************************************************/
623 553
624static acpi_status 554static acpi_status
625acpi_ut_get_package_object_size ( 555acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
626 union acpi_operand_object *internal_object, 556 acpi_size * obj_length)
627 acpi_size *obj_length)
628{ 557{
629 acpi_status status; 558 acpi_status status;
630 struct acpi_pkg_info info; 559 struct acpi_pkg_info info;
631 560
561 ACPI_FUNCTION_TRACE_PTR("ut_get_package_object_size", internal_object);
632 562
633 ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object); 563 info.length = 0;
634
635
636 info.length = 0;
637 info.object_space = 0; 564 info.object_space = 0;
638 info.num_packages = 1; 565 info.num_packages = 1;
639 566
640 status = acpi_ut_walk_package_tree (internal_object, NULL, 567 status = acpi_ut_walk_package_tree(internal_object, NULL,
641 acpi_ut_get_element_length, &info); 568 acpi_ut_get_element_length, &info);
642 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
643 return_ACPI_STATUS (status); 570 return_ACPI_STATUS(status);
644 } 571 }
645 572
646 /* 573 /*
@@ -648,16 +575,15 @@ acpi_ut_get_package_object_size (
648 * just add the length of the package objects themselves. 575 * just add the length of the package objects themselves.
649 * Round up to the next machine word. 576 * Round up to the next machine word.
650 */ 577 */
651 info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)) * 578 info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) *
652 (acpi_size) info.num_packages; 579 (acpi_size) info.num_packages;
653 580
654 /* Return the total package length */ 581 /* Return the total package length */
655 582
656 *obj_length = info.length; 583 *obj_length = info.length;
657 return_ACPI_STATUS (status); 584 return_ACPI_STATUS(status);
658} 585}
659 586
660
661/******************************************************************************* 587/*******************************************************************************
662 * 588 *
663 * FUNCTION: acpi_ut_get_object_size 589 * FUNCTION: acpi_ut_get_object_size
@@ -673,25 +599,23 @@ acpi_ut_get_package_object_size (
673 ******************************************************************************/ 599 ******************************************************************************/
674 600
675acpi_status 601acpi_status
676acpi_ut_get_object_size ( 602acpi_ut_get_object_size(union acpi_operand_object *internal_object,
677 union acpi_operand_object *internal_object, 603 acpi_size * obj_length)
678 acpi_size *obj_length)
679{ 604{
680 acpi_status status; 605 acpi_status status;
681 606
682 607 ACPI_FUNCTION_ENTRY();
683 ACPI_FUNCTION_ENTRY (); 608
684 609 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
685 610 ACPI_DESC_TYPE_OPERAND)
686 if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) && 611 && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) {
687 (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) { 612 status =
688 status = acpi_ut_get_package_object_size (internal_object, obj_length); 613 acpi_ut_get_package_object_size(internal_object,
689 } 614 obj_length);
690 else { 615 } else {
691 status = acpi_ut_get_simple_object_size (internal_object, obj_length); 616 status =
617 acpi_ut_get_simple_object_size(internal_object, obj_length);
692 } 618 }
693 619
694 return (status); 620 return (status);
695} 621}
696
697
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
new file mode 100644
index 000000000000..c1cb27583be8
--- /dev/null
+++ b/drivers/acpi/utilities/utstate.c
@@ -0,0 +1,333 @@
1/*******************************************************************************
2 *
3 * Module Name: utstate - state object support procedures
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utstate")
48
49/*******************************************************************************
50 *
51 * FUNCTION: acpi_ut_create_pkg_state_and_push
52 *
53 * PARAMETERS: Object - Object to be added to the new state
54 * Action - Increment/Decrement
55 * state_list - List the state will be added to
56 *
57 * RETURN: Status
58 *
59 * DESCRIPTION: Create a new state and push it
60 *
61 ******************************************************************************/
62acpi_status
63acpi_ut_create_pkg_state_and_push(void *internal_object,
64 void *external_object,
65 u16 index,
66 union acpi_generic_state ** state_list)
67{
68 union acpi_generic_state *state;
69
70 ACPI_FUNCTION_ENTRY();
71
72 state =
73 acpi_ut_create_pkg_state(internal_object, external_object, index);
74 if (!state) {
75 return (AE_NO_MEMORY);
76 }
77
78 acpi_ut_push_generic_state(state_list, state);
79 return (AE_OK);
80}
81
82/*******************************************************************************
83 *
84 * FUNCTION: acpi_ut_push_generic_state
85 *
86 * PARAMETERS: list_head - Head of the state stack
87 * State - State object to push
88 *
89 * RETURN: None
90 *
91 * DESCRIPTION: Push a state object onto a state stack
92 *
93 ******************************************************************************/
94
95void
96acpi_ut_push_generic_state(union acpi_generic_state **list_head,
97 union acpi_generic_state *state)
98{
99 ACPI_FUNCTION_TRACE("ut_push_generic_state");
100
101 /* Push the state object onto the front of the list (stack) */
102
103 state->common.next = *list_head;
104 *list_head = state;
105
106 return_VOID;
107}
108
109/*******************************************************************************
110 *
111 * FUNCTION: acpi_ut_pop_generic_state
112 *
113 * PARAMETERS: list_head - Head of the state stack
114 *
115 * RETURN: The popped state object
116 *
117 * DESCRIPTION: Pop a state object from a state stack
118 *
119 ******************************************************************************/
120
121union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
122 **list_head)
123{
124 union acpi_generic_state *state;
125
126 ACPI_FUNCTION_TRACE("ut_pop_generic_state");
127
128 /* Remove the state object at the head of the list (stack) */
129
130 state = *list_head;
131 if (state) {
132 /* Update the list head */
133
134 *list_head = state->common.next;
135 }
136
137 return_PTR(state);
138}
139
140/*******************************************************************************
141 *
142 * FUNCTION: acpi_ut_create_generic_state
143 *
144 * PARAMETERS: None
145 *
146 * RETURN: The new state object. NULL on failure.
147 *
148 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
149 * the global state cache; If none available, create a new one.
150 *
151 ******************************************************************************/
152
153union acpi_generic_state *acpi_ut_create_generic_state(void)
154{
155 union acpi_generic_state *state;
156
157 ACPI_FUNCTION_ENTRY();
158
159 state = acpi_os_acquire_object(acpi_gbl_state_cache);
160 if (state) {
161 /* Initialize */
162 memset(state, 0, sizeof(union acpi_generic_state));
163 state->common.data_type = ACPI_DESC_TYPE_STATE;
164 }
165
166 return (state);
167}
168
169/*******************************************************************************
170 *
171 * FUNCTION: acpi_ut_create_thread_state
172 *
173 * PARAMETERS: None
174 *
175 * RETURN: New Thread State. NULL on failure
176 *
177 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
178 * to track per-thread info during method execution
179 *
180 ******************************************************************************/
181
182struct acpi_thread_state *acpi_ut_create_thread_state(void)
183{
184 union acpi_generic_state *state;
185
186 ACPI_FUNCTION_TRACE("ut_create_thread_state");
187
188 /* Create the generic state object */
189
190 state = acpi_ut_create_generic_state();
191 if (!state) {
192 return_PTR(NULL);
193 }
194
195 /* Init fields specific to the update struct */
196
197 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
198 state->thread.thread_id = acpi_os_get_thread_id();
199
200 return_PTR((struct acpi_thread_state *)state);
201}
202
203/*******************************************************************************
204 *
205 * FUNCTION: acpi_ut_create_update_state
206 *
207 * PARAMETERS: Object - Initial Object to be installed in the state
208 * Action - Update action to be performed
209 *
210 * RETURN: New state object, null on failure
211 *
212 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
213 * to update reference counts and delete complex objects such
214 * as packages.
215 *
216 ******************************************************************************/
217
218union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
219 *object, u16 action)
220{
221 union acpi_generic_state *state;
222
223 ACPI_FUNCTION_TRACE_PTR("ut_create_update_state", object);
224
225 /* Create the generic state object */
226
227 state = acpi_ut_create_generic_state();
228 if (!state) {
229 return_PTR(NULL);
230 }
231
232 /* Init fields specific to the update struct */
233
234 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
235 state->update.object = object;
236 state->update.value = action;
237
238 return_PTR(state);
239}
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_ut_create_pkg_state
244 *
245 * PARAMETERS: Object - Initial Object to be installed in the state
246 * Action - Update action to be performed
247 *
248 * RETURN: New state object, null on failure
249 *
250 * DESCRIPTION: Create a "Package State"
251 *
252 ******************************************************************************/
253
254union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
255 void *external_object,
256 u16 index)
257{
258 union acpi_generic_state *state;
259
260 ACPI_FUNCTION_TRACE_PTR("ut_create_pkg_state", internal_object);
261
262 /* Create the generic state object */
263
264 state = acpi_ut_create_generic_state();
265 if (!state) {
266 return_PTR(NULL);
267 }
268
269 /* Init fields specific to the update struct */
270
271 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
272 state->pkg.source_object = (union acpi_operand_object *)internal_object;
273 state->pkg.dest_object = external_object;
274 state->pkg.index = index;
275 state->pkg.num_packages = 1;
276
277 return_PTR(state);
278}
279
280/*******************************************************************************
281 *
282 * FUNCTION: acpi_ut_create_control_state
283 *
284 * PARAMETERS: None
285 *
286 * RETURN: New state object, null on failure
287 *
288 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
289 * to support nested IF/WHILE constructs in the AML.
290 *
291 ******************************************************************************/
292
293union acpi_generic_state *acpi_ut_create_control_state(void)
294{
295 union acpi_generic_state *state;
296
297 ACPI_FUNCTION_TRACE("ut_create_control_state");
298
299 /* Create the generic state object */
300
301 state = acpi_ut_create_generic_state();
302 if (!state) {
303 return_PTR(NULL);
304 }
305
306 /* Init fields specific to the control struct */
307
308 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
309 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
310
311 return_PTR(state);
312}
313
314/*******************************************************************************
315 *
316 * FUNCTION: acpi_ut_delete_generic_state
317 *
318 * PARAMETERS: State - The state object to be deleted
319 *
320 * RETURN: None
321 *
322 * DESCRIPTION: Put a state object back into the global state cache. The object
323 * is not actually freed at this time.
324 *
325 ******************************************************************************/
326
327void acpi_ut_delete_generic_state(union acpi_generic_state *state)
328{
329 ACPI_FUNCTION_TRACE("ut_delete_generic_state");
330
331 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
332 return_VOID;
333}
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index e8803d810656..f06bd5e5e9d1 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -46,13 +46,10 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acevents.h> 47#include <acpi/acevents.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/acparser.h>
50#include <acpi/acdispat.h>
51#include <acpi/acdebug.h> 49#include <acpi/acdebug.h>
52 50
53#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
54 ACPI_MODULE_NAME ("utxface") 52ACPI_MODULE_NAME("utxface")
55
56 53
57/******************************************************************************* 54/*******************************************************************************
58 * 55 *
@@ -66,61 +63,54 @@
66 * called, so any early initialization belongs here. 63 * called, so any early initialization belongs here.
67 * 64 *
68 ******************************************************************************/ 65 ******************************************************************************/
69 66acpi_status acpi_initialize_subsystem(void)
70acpi_status
71acpi_initialize_subsystem (
72 void)
73{ 67{
74 acpi_status status; 68 acpi_status status;
75 69
70 ACPI_FUNCTION_TRACE("acpi_initialize_subsystem");
76 71
77 ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); 72 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
78 73
74 /* Initialize the OS-Dependent layer */
79 75
80 ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); 76 status = acpi_os_initialize();
81 77 if (ACPI_FAILURE(status)) {
78 ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n",
79 acpi_format_exception(status)));
80 return_ACPI_STATUS(status);
81 }
82 82
83 /* Initialize all globals used by the subsystem */ 83 /* Initialize all globals used by the subsystem */
84 84
85 acpi_ut_init_globals (); 85 acpi_ut_init_globals();
86
87 /* Initialize the OS-Dependent layer */
88
89 status = acpi_os_initialize ();
90 if (ACPI_FAILURE (status)) {
91 ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n",
92 acpi_format_exception (status)));
93 return_ACPI_STATUS (status);
94 }
95 86
96 /* Create the default mutex objects */ 87 /* Create the default mutex objects */
97 88
98 status = acpi_ut_mutex_initialize (); 89 status = acpi_ut_mutex_initialize();
99 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE(status)) {
100 ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n", 91 ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n",
101 acpi_format_exception (status))); 92 acpi_format_exception(status)));
102 return_ACPI_STATUS (status); 93 return_ACPI_STATUS(status);
103 } 94 }
104 95
105 /* 96 /*
106 * Initialize the namespace manager and 97 * Initialize the namespace manager and
107 * the root of the namespace tree 98 * the root of the namespace tree
108 */ 99 */
109 status = acpi_ns_root_initialize (); 100 status = acpi_ns_root_initialize();
110 if (ACPI_FAILURE (status)) { 101 if (ACPI_FAILURE(status)) {
111 ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", 102 ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n",
112 acpi_format_exception (status))); 103 acpi_format_exception(status)));
113 return_ACPI_STATUS (status); 104 return_ACPI_STATUS(status);
114 } 105 }
115 106
116 /* If configured, initialize the AML debugger */ 107 /* If configured, initialize the AML debugger */
117 108
118 ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); 109 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
119 110
120 return_ACPI_STATUS (status); 111 return_ACPI_STATUS(status);
121} 112}
122 113
123
124/******************************************************************************* 114/*******************************************************************************
125 * 115 *
126 * FUNCTION: acpi_enable_subsystem 116 * FUNCTION: acpi_enable_subsystem
@@ -134,41 +124,39 @@ acpi_initialize_subsystem (
134 * 124 *
135 ******************************************************************************/ 125 ******************************************************************************/
136 126
137acpi_status 127acpi_status acpi_enable_subsystem(u32 flags)
138acpi_enable_subsystem (
139 u32 flags)
140{ 128{
141 acpi_status status = AE_OK; 129 acpi_status status = AE_OK;
142
143
144 ACPI_FUNCTION_TRACE ("acpi_enable_subsystem");
145 130
131 ACPI_FUNCTION_TRACE("acpi_enable_subsystem");
146 132
147 /* 133 /*
148 * We must initialize the hardware before we can enable ACPI. 134 * We must initialize the hardware before we can enable ACPI.
149 * The values from the FADT are validated here. 135 * The values from the FADT are validated here.
150 */ 136 */
151 if (!(flags & ACPI_NO_HARDWARE_INIT)) { 137 if (!(flags & ACPI_NO_HARDWARE_INIT)) {
152 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 138 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
153 "[Init] Initializing ACPI hardware\n")); 139 "[Init] Initializing ACPI hardware\n"));
154 140
155 status = acpi_hw_initialize (); 141 status = acpi_hw_initialize();
156 if (ACPI_FAILURE (status)) { 142 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS (status); 143 return_ACPI_STATUS(status);
158 } 144 }
159 } 145 }
160 146
161 /* Enable ACPI mode */ 147 /* Enable ACPI mode */
162 148
163 if (!(flags & ACPI_NO_ACPI_ENABLE)) { 149 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
164 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); 150 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
151 "[Init] Going into ACPI mode\n"));
165 152
166 acpi_gbl_original_mode = acpi_hw_get_mode(); 153 acpi_gbl_original_mode = acpi_hw_get_mode();
167 154
168 status = acpi_enable (); 155 status = acpi_enable();
169 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
170 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n")); 157 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
171 return_ACPI_STATUS (status); 158 "acpi_enable failed.\n"));
159 return_ACPI_STATUS(status);
172 } 160 }
173 } 161 }
174 162
@@ -178,12 +166,12 @@ acpi_enable_subsystem (
178 * install_address_space_handler interface. 166 * install_address_space_handler interface.
179 */ 167 */
180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 168 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
181 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 169 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
182 "[Init] Installing default address space handlers\n")); 170 "[Init] Installing default address space handlers\n"));
183 171
184 status = acpi_ev_install_region_handlers (); 172 status = acpi_ev_install_region_handlers();
185 if (ACPI_FAILURE (status)) { 173 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS (status); 174 return_ACPI_STATUS(status);
187 } 175 }
188 } 176 }
189 177
@@ -196,28 +184,28 @@ acpi_enable_subsystem (
196 * execution! 184 * execution!
197 */ 185 */
198 if (!(flags & ACPI_NO_EVENT_INIT)) { 186 if (!(flags & ACPI_NO_EVENT_INIT)) {
199 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
200 "[Init] Initializing ACPI events\n")); 188 "[Init] Initializing ACPI events\n"));
201 189
202 status = acpi_ev_initialize_events (); 190 status = acpi_ev_initialize_events();
203 if (ACPI_FAILURE (status)) { 191 if (ACPI_FAILURE(status)) {
204 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
205 } 193 }
206 } 194 }
207 195
208 /* Install the SCI handler and Global Lock handler */ 196 /* Install the SCI handler and Global Lock handler */
209 197
210 if (!(flags & ACPI_NO_HANDLER_INIT)) { 198 if (!(flags & ACPI_NO_HANDLER_INIT)) {
211 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
212 "[Init] Installing SCI/GL handlers\n")); 200 "[Init] Installing SCI/GL handlers\n"));
213 201
214 status = acpi_ev_install_xrupt_handlers (); 202 status = acpi_ev_install_xrupt_handlers();
215 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE(status)) {
216 return_ACPI_STATUS (status); 204 return_ACPI_STATUS(status);
217 } 205 }
218 } 206 }
219 207
220 return_ACPI_STATUS (status); 208 return_ACPI_STATUS(status);
221} 209}
222 210
223/******************************************************************************* 211/*******************************************************************************
@@ -233,15 +221,11 @@ acpi_enable_subsystem (
233 * 221 *
234 ******************************************************************************/ 222 ******************************************************************************/
235 223
236acpi_status 224acpi_status acpi_initialize_objects(u32 flags)
237acpi_initialize_objects (
238 u32 flags)
239{ 225{
240 acpi_status status = AE_OK; 226 acpi_status status = AE_OK;
241
242
243 ACPI_FUNCTION_TRACE ("acpi_initialize_objects");
244 227
228 ACPI_FUNCTION_TRACE("acpi_initialize_objects");
245 229
246 /* 230 /*
247 * Run all _REG methods 231 * Run all _REG methods
@@ -251,12 +235,12 @@ acpi_initialize_objects (
251 * contain executable AML (see call to acpi_ns_initialize_objects below). 235 * contain executable AML (see call to acpi_ns_initialize_objects below).
252 */ 236 */
253 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
254 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
255 "[Init] Executing _REG op_region methods\n")); 239 "[Init] Executing _REG op_region methods\n"));
256 240
257 status = acpi_ev_initialize_op_regions (); 241 status = acpi_ev_initialize_op_regions();
258 if (ACPI_FAILURE (status)) { 242 if (ACPI_FAILURE(status)) {
259 return_ACPI_STATUS (status); 243 return_ACPI_STATUS(status);
260 } 244 }
261 } 245 }
262 246
@@ -266,12 +250,12 @@ acpi_initialize_objects (
266 * objects: operation_regions, buffer_fields, Buffers, and Packages. 250 * objects: operation_regions, buffer_fields, Buffers, and Packages.
267 */ 251 */
268 if (!(flags & ACPI_NO_OBJECT_INIT)) { 252 if (!(flags & ACPI_NO_OBJECT_INIT)) {
269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
270 "[Init] Completing Initialization of ACPI Objects\n")); 254 "[Init] Completing Initialization of ACPI Objects\n"));
271 255
272 status = acpi_ns_initialize_objects (); 256 status = acpi_ns_initialize_objects();
273 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
274 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
275 } 259 }
276 } 260 }
277 261
@@ -280,12 +264,12 @@ acpi_initialize_objects (
280 * This runs the _STA and _INI methods. 264 * This runs the _STA and _INI methods.
281 */ 265 */
282 if (!(flags & ACPI_NO_DEVICE_INIT)) { 266 if (!(flags & ACPI_NO_DEVICE_INIT)) {
283 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
284 "[Init] Initializing ACPI Devices\n")); 268 "[Init] Initializing ACPI Devices\n"));
285 269
286 status = acpi_ns_initialize_devices (); 270 status = acpi_ns_initialize_devices();
287 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
288 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
289 } 273 }
290 } 274 }
291 275
@@ -294,13 +278,12 @@ acpi_initialize_objects (
294 * the table load filled them up more than they will be at runtime -- 278 * the table load filled them up more than they will be at runtime --
295 * thus wasting non-paged memory. 279 * thus wasting non-paged memory.
296 */ 280 */
297 status = acpi_purge_cached_objects (); 281 status = acpi_purge_cached_objects();
298 282
299 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; 283 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
300 return_ACPI_STATUS (status); 284 return_ACPI_STATUS(status);
301} 285}
302 286
303
304/******************************************************************************* 287/*******************************************************************************
305 * 288 *
306 * FUNCTION: acpi_terminate 289 * FUNCTION: acpi_terminate
@@ -313,15 +296,11 @@ acpi_initialize_objects (
313 * 296 *
314 ******************************************************************************/ 297 ******************************************************************************/
315 298
316acpi_status 299acpi_status acpi_terminate(void)
317acpi_terminate (
318 void)
319{ 300{
320 acpi_status status; 301 acpi_status status;
321
322
323 ACPI_FUNCTION_TRACE ("acpi_terminate");
324 302
303 ACPI_FUNCTION_TRACE("acpi_terminate");
325 304
326 /* Terminate the AML Debugger if present */ 305 /* Terminate the AML Debugger if present */
327 306
@@ -329,28 +308,25 @@ acpi_terminate (
329 308
330 /* Shutdown and free all resources */ 309 /* Shutdown and free all resources */
331 310
332 acpi_ut_subsystem_shutdown (); 311 acpi_ut_subsystem_shutdown();
333
334 312
335 /* Free the mutex objects */ 313 /* Free the mutex objects */
336 314
337 acpi_ut_mutex_terminate (); 315 acpi_ut_mutex_terminate();
338
339 316
340#ifdef ACPI_DEBUGGER 317#ifdef ACPI_DEBUGGER
341 318
342 /* Shut down the debugger */ 319 /* Shut down the debugger */
343 320
344 acpi_db_terminate (); 321 acpi_db_terminate();
345#endif 322#endif
346 323
347 /* Now we can shutdown the OS-dependent layer */ 324 /* Now we can shutdown the OS-dependent layer */
348 325
349 status = acpi_os_terminate (); 326 status = acpi_os_terminate();
350 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
351} 328}
352 329
353
354#ifdef ACPI_FUTURE_USAGE 330#ifdef ACPI_FUTURE_USAGE
355/******************************************************************************* 331/*******************************************************************************
356 * 332 *
@@ -366,20 +342,16 @@ acpi_terminate (
366 * 342 *
367 ******************************************************************************/ 343 ******************************************************************************/
368 344
369acpi_status 345acpi_status acpi_subsystem_status(void)
370acpi_subsystem_status (
371 void)
372{ 346{
373 347
374 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { 348 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
375 return (AE_OK); 349 return (AE_OK);
376 } 350 } else {
377 else {
378 return (AE_ERROR); 351 return (AE_ERROR);
379 } 352 }
380} 353}
381 354
382
383/******************************************************************************* 355/*******************************************************************************
384 * 356 *
385 * FUNCTION: acpi_get_system_info 357 * FUNCTION: acpi_get_system_info
@@ -398,64 +370,60 @@ acpi_subsystem_status (
398 * 370 *
399 ******************************************************************************/ 371 ******************************************************************************/
400 372
401acpi_status 373acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
402acpi_get_system_info (
403 struct acpi_buffer *out_buffer)
404{ 374{
405 struct acpi_system_info *info_ptr; 375 struct acpi_system_info *info_ptr;
406 acpi_status status; 376 acpi_status status;
407 u32 i; 377 u32 i;
408
409
410 ACPI_FUNCTION_TRACE ("acpi_get_system_info");
411 378
379 ACPI_FUNCTION_TRACE("acpi_get_system_info");
412 380
413 /* Parameter validation */ 381 /* Parameter validation */
414 382
415 status = acpi_ut_validate_buffer (out_buffer); 383 status = acpi_ut_validate_buffer(out_buffer);
416 if (ACPI_FAILURE (status)) { 384 if (ACPI_FAILURE(status)) {
417 return_ACPI_STATUS (status); 385 return_ACPI_STATUS(status);
418 } 386 }
419 387
420 /* Validate/Allocate/Clear caller buffer */ 388 /* Validate/Allocate/Clear caller buffer */
421 389
422 status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info)); 390 status =
423 if (ACPI_FAILURE (status)) { 391 acpi_ut_initialize_buffer(out_buffer,
424 return_ACPI_STATUS (status); 392 sizeof(struct acpi_system_info));
393 if (ACPI_FAILURE(status)) {
394 return_ACPI_STATUS(status);
425 } 395 }
426 396
427 /* 397 /*
428 * Populate the return buffer 398 * Populate the return buffer
429 */ 399 */
430 info_ptr = (struct acpi_system_info *) out_buffer->pointer; 400 info_ptr = (struct acpi_system_info *)out_buffer->pointer;
431 401
432 info_ptr->acpi_ca_version = ACPI_CA_VERSION; 402 info_ptr->acpi_ca_version = ACPI_CA_VERSION;
433 403
434 /* System flags (ACPI capabilities) */ 404 /* System flags (ACPI capabilities) */
435 405
436 info_ptr->flags = ACPI_SYS_MODE_ACPI; 406 info_ptr->flags = ACPI_SYS_MODE_ACPI;
437 407
438 /* Timer resolution - 24 or 32 bits */ 408 /* Timer resolution - 24 or 32 bits */
439 409
440 if (!acpi_gbl_FADT) { 410 if (!acpi_gbl_FADT) {
441 info_ptr->timer_resolution = 0; 411 info_ptr->timer_resolution = 0;
442 } 412 } else if (acpi_gbl_FADT->tmr_val_ext == 0) {
443 else if (acpi_gbl_FADT->tmr_val_ext == 0) {
444 info_ptr->timer_resolution = 24; 413 info_ptr->timer_resolution = 24;
445 } 414 } else {
446 else {
447 info_ptr->timer_resolution = 32; 415 info_ptr->timer_resolution = 32;
448 } 416 }
449 417
450 /* Clear the reserved fields */ 418 /* Clear the reserved fields */
451 419
452 info_ptr->reserved1 = 0; 420 info_ptr->reserved1 = 0;
453 info_ptr->reserved2 = 0; 421 info_ptr->reserved2 = 0;
454 422
455 /* Current debug levels */ 423 /* Current debug levels */
456 424
457 info_ptr->debug_layer = acpi_dbg_layer; 425 info_ptr->debug_layer = acpi_dbg_layer;
458 info_ptr->debug_level = acpi_dbg_level; 426 info_ptr->debug_level = acpi_dbg_level;
459 427
460 /* Current status of the ACPI tables, per table type */ 428 /* Current status of the ACPI tables, per table type */
461 429
@@ -464,10 +432,10 @@ acpi_get_system_info (
464 info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count; 432 info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count;
465 } 433 }
466 434
467 return_ACPI_STATUS (AE_OK); 435 return_ACPI_STATUS(AE_OK);
468} 436}
469EXPORT_SYMBOL(acpi_get_system_info);
470 437
438EXPORT_SYMBOL(acpi_get_system_info);
471 439
472/***************************************************************************** 440/*****************************************************************************
473 * 441 *
@@ -485,9 +453,7 @@ EXPORT_SYMBOL(acpi_get_system_info);
485 ****************************************************************************/ 453 ****************************************************************************/
486 454
487acpi_status 455acpi_status
488acpi_install_initialization_handler ( 456acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
489 acpi_init_handler handler,
490 u32 function)
491{ 457{
492 458
493 if (!handler) { 459 if (!handler) {
@@ -502,7 +468,7 @@ acpi_install_initialization_handler (
502 return AE_OK; 468 return AE_OK;
503} 469}
504 470
505#endif /* ACPI_FUTURE_USAGE */ 471#endif /* ACPI_FUTURE_USAGE */
506 472
507/***************************************************************************** 473/*****************************************************************************
508 * 474 *
@@ -516,19 +482,13 @@ acpi_install_initialization_handler (
516 * 482 *
517 ****************************************************************************/ 483 ****************************************************************************/
518 484
519acpi_status 485acpi_status acpi_purge_cached_objects(void)
520acpi_purge_cached_objects (
521 void)
522{ 486{
523 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); 487 ACPI_FUNCTION_TRACE("acpi_purge_cached_objects");
524
525
526#ifdef ACPI_ENABLE_OBJECT_CACHE
527 acpi_ut_delete_generic_state_cache ();
528 acpi_ut_delete_object_cache ();
529 acpi_ds_delete_walk_state_cache ();
530 acpi_ps_delete_parse_cache ();
531#endif
532 488
533 return_ACPI_STATUS (AE_OK); 489 (void)acpi_os_purge_cache(acpi_gbl_state_cache);
490 (void)acpi_os_purge_cache(acpi_gbl_operand_cache);
491 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
492 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
493 return_ACPI_STATUS(AE_OK);
534} 494}
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 1ce2047c3804..6458c47f7ac2 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -30,15 +30,12 @@
30#include <acpi/acpi_bus.h> 30#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 31#include <acpi/acpi_drivers.h>
32 32
33
34#define _COMPONENT ACPI_BUS_COMPONENT 33#define _COMPONENT ACPI_BUS_COMPONENT
35ACPI_MODULE_NAME ("acpi_utils") 34ACPI_MODULE_NAME("acpi_utils")
36
37 35
38/* -------------------------------------------------------------------------- 36/* --------------------------------------------------------------------------
39 Object Evaluation Helpers 37 Object Evaluation Helpers
40 -------------------------------------------------------------------------- */ 38 -------------------------------------------------------------------------- */
41
42#ifdef ACPI_DEBUG_OUTPUT 39#ifdef ACPI_DEBUG_OUTPUT
43#define acpi_util_eval_error(h,p,s) {\ 40#define acpi_util_eval_error(h,p,s) {\
44 char prefix[80] = {'\0'};\ 41 char prefix[80] = {'\0'};\
@@ -49,26 +46,24 @@ ACPI_MODULE_NAME ("acpi_utils")
49#else 46#else
50#define acpi_util_eval_error(h,p,s) 47#define acpi_util_eval_error(h,p,s)
51#endif 48#endif
52
53
54acpi_status 49acpi_status
55acpi_extract_package ( 50acpi_extract_package(union acpi_object *package,
56 union acpi_object *package, 51 struct acpi_buffer *format, struct acpi_buffer *buffer)
57 struct acpi_buffer *format,
58 struct acpi_buffer *buffer)
59{ 52{
60 u32 size_required = 0; 53 u32 size_required = 0;
61 u32 tail_offset = 0; 54 u32 tail_offset = 0;
62 char *format_string = NULL; 55 char *format_string = NULL;
63 u32 format_count = 0; 56 u32 format_count = 0;
64 u32 i = 0; 57 u32 i = 0;
65 u8 *head = NULL; 58 u8 *head = NULL;
66 u8 *tail = NULL; 59 u8 *tail = NULL;
67 60
68 ACPI_FUNCTION_TRACE("acpi_extract_package"); 61 ACPI_FUNCTION_TRACE("acpi_extract_package");
69 62
70 if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { 63 if (!package || (package->type != ACPI_TYPE_PACKAGE)
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); 64 || (package->package.count < 1)) {
65 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
66 "Invalid 'package' argument\n"));
72 return_ACPI_STATUS(AE_BAD_PARAMETER); 67 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 } 68 }
74 69
@@ -82,18 +77,20 @@ acpi_extract_package (
82 return_ACPI_STATUS(AE_BAD_PARAMETER); 77 return_ACPI_STATUS(AE_BAD_PARAMETER);
83 } 78 }
84 79
85 format_count = (format->length/sizeof(char)) - 1; 80 format_count = (format->length / sizeof(char)) - 1;
86 if (format_count > package->package.count) { 81 if (format_count > package->package.count) {
87 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); 82 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
83 "Format specifies more objects [%d] than exist in package [%d].",
84 format_count, package->package.count));
88 return_ACPI_STATUS(AE_BAD_DATA); 85 return_ACPI_STATUS(AE_BAD_DATA);
89 } 86 }
90 87
91 format_string = (char*)format->pointer; 88 format_string = (char *)format->pointer;
92 89
93 /* 90 /*
94 * Calculate size_required. 91 * Calculate size_required.
95 */ 92 */
96 for (i=0; i<format_count; i++) { 93 for (i = 0; i < format_count; i++) {
97 94
98 union acpi_object *element = &(package->package.elements[i]); 95 union acpi_object *element = &(package->package.elements[i]);
99 96
@@ -110,11 +107,15 @@ acpi_extract_package (
110 tail_offset += sizeof(acpi_integer); 107 tail_offset += sizeof(acpi_integer);
111 break; 108 break;
112 case 'S': 109 case 'S':
113 size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char); 110 size_required +=
114 tail_offset += sizeof(char*); 111 sizeof(char *) + sizeof(acpi_integer) +
112 sizeof(char);
113 tail_offset += sizeof(char *);
115 break; 114 break;
116 default: 115 default:
117 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); 116 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
117 "Invalid package element [%d]: got number, expecing [%c].\n",
118 i, format_string[i]));
118 return_ACPI_STATUS(AE_BAD_DATA); 119 return_ACPI_STATUS(AE_BAD_DATA);
119 break; 120 break;
120 } 121 }
@@ -124,15 +125,22 @@ acpi_extract_package (
124 case ACPI_TYPE_BUFFER: 125 case ACPI_TYPE_BUFFER:
125 switch (format_string[i]) { 126 switch (format_string[i]) {
126 case 'S': 127 case 'S':
127 size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char); 128 size_required +=
128 tail_offset += sizeof(char*); 129 sizeof(char *) +
130 (element->string.length * sizeof(char)) +
131 sizeof(char);
132 tail_offset += sizeof(char *);
129 break; 133 break;
130 case 'B': 134 case 'B':
131 size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8)); 135 size_required +=
132 tail_offset += sizeof(u8*); 136 sizeof(u8 *) +
137 (element->buffer.length * sizeof(u8));
138 tail_offset += sizeof(u8 *);
133 break; 139 break;
134 default: 140 default:
135 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); 141 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
142 "Invalid package element [%d] got string/buffer, expecing [%c].\n",
143 i, format_string[i]));
136 return_ACPI_STATUS(AE_BAD_DATA); 144 return_ACPI_STATUS(AE_BAD_DATA);
137 break; 145 break;
138 } 146 }
@@ -140,7 +148,9 @@ acpi_extract_package (
140 148
141 case ACPI_TYPE_PACKAGE: 149 case ACPI_TYPE_PACKAGE:
142 default: 150 default:
143 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); 151 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "Found unsupported element at index=%d\n",
153 i));
144 /* TBD: handle nested packages... */ 154 /* TBD: handle nested packages... */
145 return_ACPI_STATUS(AE_SUPPORT); 155 return_ACPI_STATUS(AE_SUPPORT);
146 break; 156 break;
@@ -153,8 +163,7 @@ acpi_extract_package (
153 if (buffer->length < size_required) { 163 if (buffer->length < size_required) {
154 buffer->length = size_required; 164 buffer->length = size_required;
155 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 165 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
156 } 166 } else if (buffer->length != size_required || !buffer->pointer) {
157 else if (buffer->length != size_required || !buffer->pointer) {
158 return_ACPI_STATUS(AE_BAD_PARAMETER); 167 return_ACPI_STATUS(AE_BAD_PARAMETER);
159 } 168 }
160 169
@@ -164,7 +173,7 @@ acpi_extract_package (
164 /* 173 /*
165 * Extract package data. 174 * Extract package data.
166 */ 175 */
167 for (i=0; i<format_count; i++) { 176 for (i = 0; i < format_count; i++) {
168 177
169 u8 **pointer = NULL; 178 u8 **pointer = NULL;
170 union acpi_object *element = &(package->package.elements[i]); 179 union acpi_object *element = &(package->package.elements[i]);
@@ -178,14 +187,16 @@ acpi_extract_package (
178 case ACPI_TYPE_INTEGER: 187 case ACPI_TYPE_INTEGER:
179 switch (format_string[i]) { 188 switch (format_string[i]) {
180 case 'N': 189 case 'N':
181 *((acpi_integer*)head) = element->integer.value; 190 *((acpi_integer *) head) =
191 element->integer.value;
182 head += sizeof(acpi_integer); 192 head += sizeof(acpi_integer);
183 break; 193 break;
184 case 'S': 194 case 'S':
185 pointer = (u8**)head; 195 pointer = (u8 **) head;
186 *pointer = tail; 196 *pointer = tail;
187 *((acpi_integer*)tail) = element->integer.value; 197 *((acpi_integer *) tail) =
188 head += sizeof(acpi_integer*); 198 element->integer.value;
199 head += sizeof(acpi_integer *);
189 tail += sizeof(acpi_integer); 200 tail += sizeof(acpi_integer);
190 /* NULL terminate string */ 201 /* NULL terminate string */
191 *tail = (char)0; 202 *tail = (char)0;
@@ -201,20 +212,22 @@ acpi_extract_package (
201 case ACPI_TYPE_BUFFER: 212 case ACPI_TYPE_BUFFER:
202 switch (format_string[i]) { 213 switch (format_string[i]) {
203 case 'S': 214 case 'S':
204 pointer = (u8**)head; 215 pointer = (u8 **) head;
205 *pointer = tail; 216 *pointer = tail;
206 memcpy(tail, element->string.pointer, element->string.length); 217 memcpy(tail, element->string.pointer,
207 head += sizeof(char*); 218 element->string.length);
219 head += sizeof(char *);
208 tail += element->string.length * sizeof(char); 220 tail += element->string.length * sizeof(char);
209 /* NULL terminate string */ 221 /* NULL terminate string */
210 *tail = (char)0; 222 *tail = (char)0;
211 tail += sizeof(char); 223 tail += sizeof(char);
212 break; 224 break;
213 case 'B': 225 case 'B':
214 pointer = (u8**)head; 226 pointer = (u8 **) head;
215 *pointer = tail; 227 *pointer = tail;
216 memcpy(tail, element->buffer.pointer, element->buffer.length); 228 memcpy(tail, element->buffer.pointer,
217 head += sizeof(u8*); 229 element->buffer.length);
230 head += sizeof(u8 *);
218 tail += element->buffer.length * sizeof(u8); 231 tail += element->buffer.length * sizeof(u8);
219 break; 232 break;
220 default: 233 default:
@@ -233,19 +246,17 @@ acpi_extract_package (
233 246
234 return_ACPI_STATUS(AE_OK); 247 return_ACPI_STATUS(AE_OK);
235} 248}
236EXPORT_SYMBOL(acpi_extract_package);
237 249
250EXPORT_SYMBOL(acpi_extract_package);
238 251
239acpi_status 252acpi_status
240acpi_evaluate_integer ( 253acpi_evaluate_integer(acpi_handle handle,
241 acpi_handle handle, 254 acpi_string pathname,
242 acpi_string pathname, 255 struct acpi_object_list *arguments, unsigned long *data)
243 struct acpi_object_list *arguments,
244 unsigned long *data)
245{ 256{
246 acpi_status status = AE_OK; 257 acpi_status status = AE_OK;
247 union acpi_object *element; 258 union acpi_object *element;
248 struct acpi_buffer buffer = {0,NULL}; 259 struct acpi_buffer buffer = { 0, NULL };
249 260
250 ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); 261 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
251 262
@@ -253,7 +264,7 @@ acpi_evaluate_integer (
253 return_ACPI_STATUS(AE_BAD_PARAMETER); 264 return_ACPI_STATUS(AE_BAD_PARAMETER);
254 265
255 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 266 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
256 if(!element) 267 if (!element)
257 return_ACPI_STATUS(AE_NO_MEMORY); 268 return_ACPI_STATUS(AE_NO_MEMORY);
258 269
259 memset(element, 0, sizeof(union acpi_object)); 270 memset(element, 0, sizeof(union acpi_object));
@@ -277,20 +288,18 @@ acpi_evaluate_integer (
277 288
278 return_ACPI_STATUS(AE_OK); 289 return_ACPI_STATUS(AE_OK);
279} 290}
280EXPORT_SYMBOL(acpi_evaluate_integer);
281 291
292EXPORT_SYMBOL(acpi_evaluate_integer);
282 293
283#if 0 294#if 0
284acpi_status 295acpi_status
285acpi_evaluate_string ( 296acpi_evaluate_string(acpi_handle handle,
286 acpi_handle handle, 297 acpi_string pathname,
287 acpi_string pathname, 298 acpi_object_list * arguments, acpi_string * data)
288 acpi_object_list *arguments,
289 acpi_string *data)
290{ 299{
291 acpi_status status = AE_OK; 300 acpi_status status = AE_OK;
292 acpi_object *element = NULL; 301 acpi_object *element = NULL;
293 acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 302 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
294 303
295 ACPI_FUNCTION_TRACE("acpi_evaluate_string"); 304 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
296 305
@@ -305,9 +314,9 @@ acpi_evaluate_string (
305 314
306 element = (acpi_object *) buffer.pointer; 315 element = (acpi_object *) buffer.pointer;
307 316
308 if ((element->type != ACPI_TYPE_STRING) 317 if ((element->type != ACPI_TYPE_STRING)
309 || (element->type != ACPI_TYPE_BUFFER) 318 || (element->type != ACPI_TYPE_BUFFER)
310 || !element->string.length) { 319 || !element->string.length) {
311 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
312 return_ACPI_STATUS(AE_BAD_DATA); 321 return_ACPI_STATUS(AE_BAD_DATA);
313 } 322 }
@@ -329,19 +338,17 @@ acpi_evaluate_string (
329} 338}
330#endif 339#endif
331 340
332
333acpi_status 341acpi_status
334acpi_evaluate_reference ( 342acpi_evaluate_reference(acpi_handle handle,
335 acpi_handle handle, 343 acpi_string pathname,
336 acpi_string pathname, 344 struct acpi_object_list *arguments,
337 struct acpi_object_list *arguments, 345 struct acpi_handle_list *list)
338 struct acpi_handle_list *list)
339{ 346{
340 acpi_status status = AE_OK; 347 acpi_status status = AE_OK;
341 union acpi_object *package = NULL; 348 union acpi_object *package = NULL;
342 union acpi_object *element = NULL; 349 union acpi_object *element = NULL;
343 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
344 u32 i = 0; 351 u32 i = 0;
345 352
346 ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); 353 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
347 354
@@ -355,28 +362,28 @@ acpi_evaluate_reference (
355 if (ACPI_FAILURE(status)) 362 if (ACPI_FAILURE(status))
356 goto end; 363 goto end;
357 364
358 package = (union acpi_object *) buffer.pointer; 365 package = (union acpi_object *)buffer.pointer;
359 366
360 if ((buffer.length == 0) || !package) { 367 if ((buffer.length == 0) || !package) {
361 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 368 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
362 "No return object (len %X ptr %p)\n", 369 "No return object (len %X ptr %p)\n",
363 (unsigned)buffer.length, package)); 370 (unsigned)buffer.length, package));
364 status = AE_BAD_DATA; 371 status = AE_BAD_DATA;
365 acpi_util_eval_error(handle, pathname, status); 372 acpi_util_eval_error(handle, pathname, status);
366 goto end; 373 goto end;
367 } 374 }
368 if (package->type != ACPI_TYPE_PACKAGE) { 375 if (package->type != ACPI_TYPE_PACKAGE) {
369 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
370 "Expecting a [Package], found type %X\n", 377 "Expecting a [Package], found type %X\n",
371 package->type)); 378 package->type));
372 status = AE_BAD_DATA; 379 status = AE_BAD_DATA;
373 acpi_util_eval_error(handle, pathname, status); 380 acpi_util_eval_error(handle, pathname, status);
374 goto end; 381 goto end;
375 } 382 }
376 if (!package->package.count) { 383 if (!package->package.count) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
378 "[Package] has zero elements (%p)\n", 385 "[Package] has zero elements (%p)\n",
379 package)); 386 package));
380 status = AE_BAD_DATA; 387 status = AE_BAD_DATA;
381 acpi_util_eval_error(handle, pathname, status); 388 acpi_util_eval_error(handle, pathname, status);
382 goto end; 389 goto end;
@@ -395,9 +402,9 @@ acpi_evaluate_reference (
395 402
396 if (element->type != ACPI_TYPE_ANY) { 403 if (element->type != ACPI_TYPE_ANY) {
397 status = AE_BAD_DATA; 404 status = AE_BAD_DATA;
398 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 405 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
399 "Expecting a [Reference] package element, found type %X\n", 406 "Expecting a [Reference] package element, found type %X\n",
400 element->type)); 407 element->type));
401 acpi_util_eval_error(handle, pathname, status); 408 acpi_util_eval_error(handle, pathname, status);
402 break; 409 break;
403 } 410 }
@@ -406,10 +413,10 @@ acpi_evaluate_reference (
406 413
407 list->handles[i] = element->reference.handle; 414 list->handles[i] = element->reference.handle;
408 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", 415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
409 list->handles[i])); 416 list->handles[i]));
410 } 417 }
411 418
412end: 419 end:
413 if (ACPI_FAILURE(status)) { 420 if (ACPI_FAILURE(status)) {
414 list->count = 0; 421 list->count = 0;
415 //kfree(list->handles); 422 //kfree(list->handles);
@@ -419,5 +426,5 @@ end:
419 426
420 return_ACPI_STATUS(status); 427 return_ACPI_STATUS(status);
421} 428}
422EXPORT_SYMBOL(acpi_evaluate_reference);
423 429
430EXPORT_SYMBOL(acpi_evaluate_reference);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 2cf264fd52e0..e383d6109ae1 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -53,21 +53,20 @@
53#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 53#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
54#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 54#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
55 55
56
57#define ACPI_VIDEO_HEAD_INVALID (~0u - 1) 56#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
58#define ACPI_VIDEO_HEAD_END (~0u) 57#define ACPI_VIDEO_HEAD_END (~0u)
59 58
60
61#define _COMPONENT ACPI_VIDEO_COMPONENT 59#define _COMPONENT ACPI_VIDEO_COMPONENT
62ACPI_MODULE_NAME ("acpi_video") 60ACPI_MODULE_NAME("acpi_video")
63 61
64MODULE_AUTHOR("Bruno Ducrot"); 62 MODULE_AUTHOR("Bruno Ducrot");
65MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME); 63MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
66MODULE_LICENSE("GPL"); 64MODULE_LICENSE("GPL");
67 65
68static int acpi_video_bus_add (struct acpi_device *device); 66static int acpi_video_bus_add(struct acpi_device *device);
69static int acpi_video_bus_remove (struct acpi_device *device, int type); 67static int acpi_video_bus_remove(struct acpi_device *device, int type);
70static int acpi_video_bus_match (struct acpi_device *device, struct acpi_driver *driver); 68static int acpi_video_bus_match(struct acpi_device *device,
69 struct acpi_driver *driver);
71 70
72static struct acpi_driver acpi_video_bus = { 71static struct acpi_driver acpi_video_bus = {
73 .name = ACPI_VIDEO_DRIVER_NAME, 72 .name = ACPI_VIDEO_DRIVER_NAME,
@@ -76,187 +75,192 @@ static struct acpi_driver acpi_video_bus = {
76 .add = acpi_video_bus_add, 75 .add = acpi_video_bus_add,
77 .remove = acpi_video_bus_remove, 76 .remove = acpi_video_bus_remove,
78 .match = acpi_video_bus_match, 77 .match = acpi_video_bus_match,
79 }, 78 },
80}; 79};
81 80
82struct acpi_video_bus_flags { 81struct acpi_video_bus_flags {
83 u8 multihead:1; /* can switch video heads */ 82 u8 multihead:1; /* can switch video heads */
84 u8 rom:1; /* can retrieve a video rom */ 83 u8 rom:1; /* can retrieve a video rom */
85 u8 post:1; /* can configure the head to */ 84 u8 post:1; /* can configure the head to */
86 u8 reserved:5; 85 u8 reserved:5;
87}; 86};
88 87
89struct acpi_video_bus_cap { 88struct acpi_video_bus_cap {
90 u8 _DOS:1; /*Enable/Disable output switching*/ 89 u8 _DOS:1; /*Enable/Disable output switching */
91 u8 _DOD:1; /*Enumerate all devices attached to display adapter*/ 90 u8 _DOD:1; /*Enumerate all devices attached to display adapter */
92 u8 _ROM:1; /*Get ROM Data*/ 91 u8 _ROM:1; /*Get ROM Data */
93 u8 _GPD:1; /*Get POST Device*/ 92 u8 _GPD:1; /*Get POST Device */
94 u8 _SPD:1; /*Set POST Device*/ 93 u8 _SPD:1; /*Set POST Device */
95 u8 _VPO:1; /*Video POST Options*/ 94 u8 _VPO:1; /*Video POST Options */
96 u8 reserved:2; 95 u8 reserved:2;
97}; 96};
98 97
99struct acpi_video_device_attrib{ 98struct acpi_video_device_attrib {
100 u32 display_index:4; /* A zero-based instance of the Display*/ 99 u32 display_index:4; /* A zero-based instance of the Display */
101 u32 display_port_attachment:4; /*This field differenates displays type*/ 100 u32 display_port_attachment:4; /*This field differenates displays type */
102 u32 display_type:4; /*Describe the specific type in use*/ 101 u32 display_type:4; /*Describe the specific type in use */
103 u32 vendor_specific:4; /*Chipset Vendor Specifi*/ 102 u32 vendor_specific:4; /*Chipset Vendor Specifi */
104 u32 bios_can_detect:1; /*BIOS can detect the device*/ 103 u32 bios_can_detect:1; /*BIOS can detect the device */
105 u32 depend_on_vga:1; /*Non-VGA output device whose power is related to 104 u32 depend_on_vga:1; /*Non-VGA output device whose power is related to
106 the VGA device.*/ 105 the VGA device. */
107 u32 pipe_id:3; /*For VGA multiple-head devices.*/ 106 u32 pipe_id:3; /*For VGA multiple-head devices. */
108 u32 reserved:10; /*Must be 0*/ 107 u32 reserved:10; /*Must be 0 */
109 u32 device_id_scheme:1; /*Device ID Scheme*/ 108 u32 device_id_scheme:1; /*Device ID Scheme */
110}; 109};
111 110
112struct acpi_video_enumerated_device { 111struct acpi_video_enumerated_device {
113 union { 112 union {
114 u32 int_val; 113 u32 int_val;
115 struct acpi_video_device_attrib attrib; 114 struct acpi_video_device_attrib attrib;
116 } value; 115 } value;
117 struct acpi_video_device *bind_info; 116 struct acpi_video_device *bind_info;
118}; 117};
119 118
120struct acpi_video_bus { 119struct acpi_video_bus {
121 acpi_handle handle; 120 acpi_handle handle;
122 u8 dos_setting; 121 u8 dos_setting;
123 struct acpi_video_enumerated_device *attached_array; 122 struct acpi_video_enumerated_device *attached_array;
124 u8 attached_count; 123 u8 attached_count;
125 struct acpi_video_bus_cap cap; 124 struct acpi_video_bus_cap cap;
126 struct acpi_video_bus_flags flags; 125 struct acpi_video_bus_flags flags;
127 struct semaphore sem; 126 struct semaphore sem;
128 struct list_head video_device_list; 127 struct list_head video_device_list;
129 struct proc_dir_entry *dir; 128 struct proc_dir_entry *dir;
130}; 129};
131 130
132struct acpi_video_device_flags { 131struct acpi_video_device_flags {
133 u8 crt:1; 132 u8 crt:1;
134 u8 lcd:1; 133 u8 lcd:1;
135 u8 tvout:1; 134 u8 tvout:1;
136 u8 bios:1; 135 u8 bios:1;
137 u8 unknown:1; 136 u8 unknown:1;
138 u8 reserved:3; 137 u8 reserved:3;
139}; 138};
140 139
141struct acpi_video_device_cap { 140struct acpi_video_device_cap {
142 u8 _ADR:1; /*Return the unique ID */ 141 u8 _ADR:1; /*Return the unique ID */
143 u8 _BCL:1; /*Query list of brightness control levels supported*/ 142 u8 _BCL:1; /*Query list of brightness control levels supported */
144 u8 _BCM:1; /*Set the brightness level*/ 143 u8 _BCM:1; /*Set the brightness level */
145 u8 _DDC:1; /*Return the EDID for this device*/ 144 u8 _DDC:1; /*Return the EDID for this device */
146 u8 _DCS:1; /*Return status of output device*/ 145 u8 _DCS:1; /*Return status of output device */
147 u8 _DGS:1; /*Query graphics state*/ 146 u8 _DGS:1; /*Query graphics state */
148 u8 _DSS:1; /*Device state set*/ 147 u8 _DSS:1; /*Device state set */
149 u8 _reserved:1; 148 u8 _reserved:1;
150}; 149};
151 150
152struct acpi_video_device_brightness { 151struct acpi_video_device_brightness {
153 int curr; 152 int curr;
154 int count; 153 int count;
155 int *levels; 154 int *levels;
156}; 155};
157 156
158struct acpi_video_device { 157struct acpi_video_device {
159 acpi_handle handle; 158 acpi_handle handle;
160 unsigned long device_id; 159 unsigned long device_id;
161 struct acpi_video_device_flags flags; 160 struct acpi_video_device_flags flags;
162 struct acpi_video_device_cap cap; 161 struct acpi_video_device_cap cap;
163 struct list_head entry; 162 struct list_head entry;
164 struct acpi_video_bus *video; 163 struct acpi_video_bus *video;
165 struct acpi_device *dev; 164 struct acpi_device *dev;
166 struct acpi_video_device_brightness *brightness; 165 struct acpi_video_device_brightness *brightness;
167}; 166};
168 167
169
170/* bus */ 168/* bus */
171static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); 169static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
172static struct file_operations acpi_video_bus_info_fops = { 170static struct file_operations acpi_video_bus_info_fops = {
173 .open = acpi_video_bus_info_open_fs, 171 .open = acpi_video_bus_info_open_fs,
174 .read = seq_read, 172 .read = seq_read,
175 .llseek = seq_lseek, 173 .llseek = seq_lseek,
176 .release = single_release, 174 .release = single_release,
177}; 175};
178 176
179static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); 177static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
180static struct file_operations acpi_video_bus_ROM_fops = { 178static struct file_operations acpi_video_bus_ROM_fops = {
181 .open = acpi_video_bus_ROM_open_fs, 179 .open = acpi_video_bus_ROM_open_fs,
182 .read = seq_read, 180 .read = seq_read,
183 .llseek = seq_lseek, 181 .llseek = seq_lseek,
184 .release = single_release, 182 .release = single_release,
185}; 183};
186 184
187static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file); 185static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
186 struct file *file);
188static struct file_operations acpi_video_bus_POST_info_fops = { 187static struct file_operations acpi_video_bus_POST_info_fops = {
189 .open = acpi_video_bus_POST_info_open_fs, 188 .open = acpi_video_bus_POST_info_open_fs,
190 .read = seq_read, 189 .read = seq_read,
191 .llseek = seq_lseek, 190 .llseek = seq_lseek,
192 .release = single_release, 191 .release = single_release,
193}; 192};
194 193
195static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); 194static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
196static struct file_operations acpi_video_bus_POST_fops = { 195static struct file_operations acpi_video_bus_POST_fops = {
197 .open = acpi_video_bus_POST_open_fs, 196 .open = acpi_video_bus_POST_open_fs,
198 .read = seq_read, 197 .read = seq_read,
199 .llseek = seq_lseek, 198 .llseek = seq_lseek,
200 .release = single_release, 199 .release = single_release,
201}; 200};
202 201
203
204static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); 202static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
205static struct file_operations acpi_video_bus_DOS_fops = { 203static struct file_operations acpi_video_bus_DOS_fops = {
206 .open = acpi_video_bus_DOS_open_fs, 204 .open = acpi_video_bus_DOS_open_fs,
207 .read = seq_read, 205 .read = seq_read,
208 .llseek = seq_lseek, 206 .llseek = seq_lseek,
209 .release = single_release, 207 .release = single_release,
210}; 208};
211 209
212/* device */ 210/* device */
213static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file); 211static int acpi_video_device_info_open_fs(struct inode *inode,
212 struct file *file);
214static struct file_operations acpi_video_device_info_fops = { 213static struct file_operations acpi_video_device_info_fops = {
215 .open = acpi_video_device_info_open_fs, 214 .open = acpi_video_device_info_open_fs,
216 .read = seq_read, 215 .read = seq_read,
217 .llseek = seq_lseek, 216 .llseek = seq_lseek,
218 .release = single_release, 217 .release = single_release,
219}; 218};
220 219
221static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file); 220static int acpi_video_device_state_open_fs(struct inode *inode,
221 struct file *file);
222static struct file_operations acpi_video_device_state_fops = { 222static struct file_operations acpi_video_device_state_fops = {
223 .open = acpi_video_device_state_open_fs, 223 .open = acpi_video_device_state_open_fs,
224 .read = seq_read, 224 .read = seq_read,
225 .llseek = seq_lseek, 225 .llseek = seq_lseek,
226 .release = single_release, 226 .release = single_release,
227}; 227};
228 228
229static int acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file); 229static int acpi_video_device_brightness_open_fs(struct inode *inode,
230 struct file *file);
230static struct file_operations acpi_video_device_brightness_fops = { 231static struct file_operations acpi_video_device_brightness_fops = {
231 .open = acpi_video_device_brightness_open_fs, 232 .open = acpi_video_device_brightness_open_fs,
232 .read = seq_read, 233 .read = seq_read,
233 .llseek = seq_lseek, 234 .llseek = seq_lseek,
234 .release = single_release, 235 .release = single_release,
235}; 236};
236 237
237static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file); 238static int acpi_video_device_EDID_open_fs(struct inode *inode,
239 struct file *file);
238static struct file_operations acpi_video_device_EDID_fops = { 240static struct file_operations acpi_video_device_EDID_fops = {
239 .open = acpi_video_device_EDID_open_fs, 241 .open = acpi_video_device_EDID_open_fs,
240 .read = seq_read, 242 .read = seq_read,
241 .llseek = seq_lseek, 243 .llseek = seq_lseek,
242 .release = single_release, 244 .release = single_release,
243}; 245};
244 246
245static char device_decode[][30] = { 247static char device_decode[][30] = {
246 "motherboard VGA device", 248 "motherboard VGA device",
247 "PCI VGA device", 249 "PCI VGA device",
248 "AGP VGA device", 250 "AGP VGA device",
249 "UNKNOWN", 251 "UNKNOWN",
250}; 252};
251 253
252static void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data); 254static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data);
253static void acpi_video_device_rebind( struct acpi_video_bus *video); 255static void acpi_video_device_rebind(struct acpi_video_bus *video);
254static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device); 256static void acpi_video_device_bind(struct acpi_video_bus *video,
257 struct acpi_video_device *device);
255static int acpi_video_device_enumerate(struct acpi_video_bus *video); 258static int acpi_video_device_enumerate(struct acpi_video_bus *video);
256static int acpi_video_switch_output( struct acpi_video_bus *video, int event); 259static int acpi_video_switch_output(struct acpi_video_bus *video, int event);
257static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event); 260static int acpi_video_get_next_level(struct acpi_video_device *device,
258static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event); 261 u32 level_current, u32 event);
259 262static void acpi_video_switch_brightness(struct acpi_video_device *device,
263 int event);
260 264
261/* -------------------------------------------------------------------------- 265/* --------------------------------------------------------------------------
262 Video Management 266 Video Management
@@ -265,11 +269,9 @@ static void acpi_video_switch_brightness ( struct acpi_video_device *device, int
265/* device */ 269/* device */
266 270
267static int 271static int
268acpi_video_device_query ( 272acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
269 struct acpi_video_device *device,
270 unsigned long *state)
271{ 273{
272 int status; 274 int status;
273 ACPI_FUNCTION_TRACE("acpi_video_device_query"); 275 ACPI_FUNCTION_TRACE("acpi_video_device_query");
274 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); 276 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
275 277
@@ -277,11 +279,10 @@ acpi_video_device_query (
277} 279}
278 280
279static int 281static int
280acpi_video_device_get_state ( 282acpi_video_device_get_state(struct acpi_video_device *device,
281 struct acpi_video_device *device, 283 unsigned long *state)
282 unsigned long *state)
283{ 284{
284 int status; 285 int status;
285 286
286 ACPI_FUNCTION_TRACE("acpi_video_device_get_state"); 287 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
287 288
@@ -291,31 +292,28 @@ acpi_video_device_get_state (
291} 292}
292 293
293static int 294static int
294acpi_video_device_set_state ( 295acpi_video_device_set_state(struct acpi_video_device *device, int state)
295 struct acpi_video_device *device,
296 int state)
297{ 296{
298 int status; 297 int status;
299 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 298 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
300 struct acpi_object_list args = {1, &arg0}; 299 struct acpi_object_list args = { 1, &arg0 };
300 unsigned long ret;
301 301
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); 302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
303 303
304 arg0.integer.value = state; 304 arg0.integer.value = state;
305 status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL); 305 status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret);
306 306
307 return_VALUE(status); 307 return_VALUE(status);
308} 308}
309 309
310static int 310static int
311acpi_video_device_lcd_query_levels ( 311acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
312 struct acpi_video_device *device, 312 union acpi_object **levels)
313 union acpi_object **levels)
314{ 313{
315 int status; 314 int status;
316 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 315 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
317 union acpi_object *obj; 316 union acpi_object *obj;
318
319 317
320 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels"); 318 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
321 319
@@ -324,7 +322,7 @@ acpi_video_device_lcd_query_levels (
324 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); 322 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
325 if (!ACPI_SUCCESS(status)) 323 if (!ACPI_SUCCESS(status))
326 return_VALUE(status); 324 return_VALUE(status);
327 obj = (union acpi_object *) buffer.pointer; 325 obj = (union acpi_object *)buffer.pointer;
328 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) { 326 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
329 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); 327 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
330 status = -EFAULT; 328 status = -EFAULT;
@@ -335,7 +333,7 @@ acpi_video_device_lcd_query_levels (
335 333
336 return_VALUE(0); 334 return_VALUE(0);
337 335
338err: 336 err:
339 if (buffer.pointer) 337 if (buffer.pointer)
340 kfree(buffer.pointer); 338 kfree(buffer.pointer);
341 339
@@ -343,13 +341,11 @@ err:
343} 341}
344 342
345static int 343static int
346acpi_video_device_lcd_set_level ( 344acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
347 struct acpi_video_device *device,
348 int level)
349{ 345{
350 int status; 346 int status;
351 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 347 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
352 struct acpi_object_list args = {1, &arg0}; 348 struct acpi_object_list args = { 1, &arg0 };
353 349
354 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level"); 350 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
355 351
@@ -361,11 +357,10 @@ acpi_video_device_lcd_set_level (
361} 357}
362 358
363static int 359static int
364acpi_video_device_lcd_get_level_current ( 360acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
365 struct acpi_video_device *device, 361 unsigned long *level)
366 unsigned long *level)
367{ 362{
368 int status; 363 int status;
369 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current"); 364 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
370 365
371 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); 366 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
@@ -374,16 +369,14 @@ acpi_video_device_lcd_get_level_current (
374} 369}
375 370
376static int 371static int
377acpi_video_device_EDID ( 372acpi_video_device_EDID(struct acpi_video_device *device,
378 struct acpi_video_device *device, 373 union acpi_object **edid, ssize_t length)
379 union acpi_object **edid,
380 ssize_t length)
381{ 374{
382 int status; 375 int status;
383 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 376 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
384 union acpi_object *obj; 377 union acpi_object *obj;
385 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 378 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
386 struct acpi_object_list args = {1, &arg0}; 379 struct acpi_object_list args = { 1, &arg0 };
387 380
388 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID"); 381 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
389 382
@@ -402,7 +395,7 @@ acpi_video_device_EDID (
402 if (ACPI_FAILURE(status)) 395 if (ACPI_FAILURE(status))
403 return_VALUE(-ENODEV); 396 return_VALUE(-ENODEV);
404 397
405 obj = (union acpi_object *) buffer.pointer; 398 obj = (union acpi_object *)buffer.pointer;
406 399
407 if (obj && obj->type == ACPI_TYPE_BUFFER) 400 if (obj && obj->type == ACPI_TYPE_BUFFER)
408 *edid = obj; 401 *edid = obj;
@@ -415,18 +408,15 @@ acpi_video_device_EDID (
415 return_VALUE(status); 408 return_VALUE(status);
416} 409}
417 410
418
419/* bus */ 411/* bus */
420 412
421static int 413static int
422acpi_video_bus_set_POST ( 414acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
423 struct acpi_video_bus *video,
424 unsigned long option)
425{ 415{
426 int status; 416 int status;
427 unsigned long tmp; 417 unsigned long tmp;
428 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 418 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
429 struct acpi_object_list args = {1, &arg0}; 419 struct acpi_object_list args = { 1, &arg0 };
430 420
431 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST"); 421 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
432 422
@@ -434,15 +424,13 @@ acpi_video_bus_set_POST (
434 424
435 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp); 425 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
436 if (ACPI_SUCCESS(status)) 426 if (ACPI_SUCCESS(status))
437 status = tmp ? (-EINVAL):(AE_OK); 427 status = tmp ? (-EINVAL) : (AE_OK);
438 428
439 return_VALUE(status); 429 return_VALUE(status);
440} 430}
441 431
442static int 432static int
443acpi_video_bus_get_POST ( 433acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
444 struct acpi_video_bus *video,
445 unsigned long *id)
446{ 434{
447 int status; 435 int status;
448 436
@@ -454,11 +442,10 @@ acpi_video_bus_get_POST (
454} 442}
455 443
456static int 444static int
457acpi_video_bus_POST_options ( 445acpi_video_bus_POST_options(struct acpi_video_bus *video,
458 struct acpi_video_bus *video, 446 unsigned long *options)
459 unsigned long *options)
460{ 447{
461 int status; 448 int status;
462 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options"); 449 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
463 450
464 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); 451 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
@@ -489,18 +476,15 @@ acpi_video_bus_POST_options (
489 */ 476 */
490 477
491static int 478static int
492acpi_video_bus_DOS( 479acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
493 struct acpi_video_bus *video,
494 int bios_flag,
495 int lcd_flag)
496{ 480{
497 acpi_integer status = 0; 481 acpi_integer status = 0;
498 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 482 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
499 struct acpi_object_list args = {1, &arg0}; 483 struct acpi_object_list args = { 1, &arg0 };
500 484
501 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS"); 485 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
502 486
503 if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){ 487 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
504 status = -1; 488 status = -1;
505 goto Failed; 489 goto Failed;
506 } 490 }
@@ -508,7 +492,7 @@ acpi_video_bus_DOS(
508 video->dos_setting = arg0.integer.value; 492 video->dos_setting = arg0.integer.value;
509 acpi_evaluate_object(video->handle, "_DOS", &args, NULL); 493 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
510 494
511Failed: 495 Failed:
512 return_VALUE(status); 496 return_VALUE(status);
513} 497}
514 498
@@ -523,10 +507,9 @@ Failed:
523 * device. 507 * device.
524 */ 508 */
525 509
526static void 510static void acpi_video_device_find_cap(struct acpi_video_device *device)
527acpi_video_device_find_cap (struct acpi_video_device *device)
528{ 511{
529 acpi_integer status; 512 acpi_integer status;
530 acpi_handle h_dummy1; 513 acpi_handle h_dummy1;
531 int i; 514 int i;
532 union acpi_object *obj = NULL; 515 union acpi_object *obj = NULL;
@@ -534,27 +517,27 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
534 517
535 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap"); 518 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
536 519
537 memset( &device->cap, 0, 4); 520 memset(&device->cap, 0, 4);
538 521
539 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { 522 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
540 device->cap._ADR = 1; 523 device->cap._ADR = 1;
541 } 524 }
542 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) { 525 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
543 device->cap._BCL= 1; 526 device->cap._BCL = 1;
544 } 527 }
545 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) { 528 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
546 device->cap._BCM= 1; 529 device->cap._BCM = 1;
547 } 530 }
548 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) { 531 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
549 device->cap._DDC= 1; 532 device->cap._DDC = 1;
550 } 533 }
551 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) { 534 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
552 device->cap._DCS = 1; 535 device->cap._DCS = 1;
553 } 536 }
554 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) { 537 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
555 device->cap._DGS = 1; 538 device->cap._DGS = 1;
556 } 539 }
557 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) { 540 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
558 device->cap._DSS = 1; 541 device->cap._DSS = 1;
559 } 542 }
560 543
@@ -563,34 +546,38 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
563 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) { 546 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
564 int count = 0; 547 int count = 0;
565 union acpi_object *o; 548 union acpi_object *o;
566 549
567 br = kmalloc(sizeof(*br), GFP_KERNEL); 550 br = kmalloc(sizeof(*br), GFP_KERNEL);
568 if (!br) { 551 if (!br) {
569 printk(KERN_ERR "can't allocate memory\n"); 552 printk(KERN_ERR "can't allocate memory\n");
570 } else { 553 } else {
571 memset(br, 0, sizeof(*br)); 554 memset(br, 0, sizeof(*br));
572 br->levels = kmalloc(obj->package.count * 555 br->levels = kmalloc(obj->package.count *
573 sizeof *(br->levels), GFP_KERNEL); 556 sizeof *(br->levels), GFP_KERNEL);
574 if (!br->levels) 557 if (!br->levels)
575 goto out; 558 goto out;
576 559
577 for (i = 0; i < obj->package.count; i++) { 560 for (i = 0; i < obj->package.count; i++) {
578 o = (union acpi_object *) &obj->package.elements[i]; 561 o = (union acpi_object *)&obj->package.
562 elements[i];
579 if (o->type != ACPI_TYPE_INTEGER) { 563 if (o->type != ACPI_TYPE_INTEGER) {
580 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 564 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
565 "Invalid data\n"));
581 continue; 566 continue;
582 } 567 }
583 br->levels[count] = (u32) o->integer.value; 568 br->levels[count] = (u32) o->integer.value;
584 count++; 569 count++;
585 } 570 }
586out: 571 out:
587 if (count < 2) { 572 if (count < 2) {
588 kfree(br->levels); 573 kfree(br->levels);
589 kfree(br); 574 kfree(br);
590 } else { 575 } else {
591 br->count = count; 576 br->count = count;
592 device->brightness = br; 577 device->brightness = br;
593 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count)); 578 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
579 "found %d brightness levels\n",
580 count));
594 } 581 }
595 } 582 }
596 } 583 }
@@ -610,28 +597,27 @@ out:
610 * Find out all required AML method defined under the video bus device. 597 * Find out all required AML method defined under the video bus device.
611 */ 598 */
612 599
613static void 600static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
614acpi_video_bus_find_cap (struct acpi_video_bus *video)
615{ 601{
616 acpi_handle h_dummy1; 602 acpi_handle h_dummy1;
617 603
618 memset(&video->cap ,0, 4); 604 memset(&video->cap, 0, 4);
619 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) { 605 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
620 video->cap._DOS = 1; 606 video->cap._DOS = 1;
621 } 607 }
622 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) { 608 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
623 video->cap._DOD = 1; 609 video->cap._DOD = 1;
624 } 610 }
625 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) { 611 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
626 video->cap._ROM = 1; 612 video->cap._ROM = 1;
627 } 613 }
628 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) { 614 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
629 video->cap._GPD = 1; 615 video->cap._GPD = 1;
630 } 616 }
631 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) { 617 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
632 video->cap._SPD = 1; 618 video->cap._SPD = 1;
633 } 619 }
634 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) { 620 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
635 video->cap._VPO = 1; 621 video->cap._VPO = 1;
636 } 622 }
637} 623}
@@ -641,12 +627,9 @@ acpi_video_bus_find_cap (struct acpi_video_bus *video)
641 * support the desired features 627 * support the desired features
642 */ 628 */
643 629
644static int 630static int acpi_video_bus_check(struct acpi_video_bus *video)
645acpi_video_bus_check (
646 struct acpi_video_bus *video)
647{ 631{
648 acpi_status status = -ENOENT; 632 acpi_status status = -ENOENT;
649
650 633
651 ACPI_FUNCTION_TRACE("acpi_video_bus_check"); 634 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
652 635
@@ -658,19 +641,19 @@ acpi_video_bus_check (
658 */ 641 */
659 642
660 /* Does this device able to support video switching ? */ 643 /* Does this device able to support video switching ? */
661 if(video->cap._DOS){ 644 if (video->cap._DOS) {
662 video->flags.multihead = 1; 645 video->flags.multihead = 1;
663 status = 0; 646 status = 0;
664 } 647 }
665 648
666 /* Does this device able to retrieve a retrieve a video ROM ? */ 649 /* Does this device able to retrieve a retrieve a video ROM ? */
667 if(video->cap._ROM){ 650 if (video->cap._ROM) {
668 video->flags.rom = 1; 651 video->flags.rom = 1;
669 status = 0; 652 status = 0;
670 } 653 }
671 654
672 /* Does this device able to configure which video device to POST ? */ 655 /* Does this device able to configure which video device to POST ? */
673 if(video->cap._GPD && video->cap._SPD && video->cap._VPO){ 656 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) {
674 video->flags.post = 1; 657 video->flags.post = 1;
675 status = 0; 658 status = 0;
676 } 659 }
@@ -682,16 +665,14 @@ acpi_video_bus_check (
682 FS Interface (/proc) 665 FS Interface (/proc)
683 -------------------------------------------------------------------------- */ 666 -------------------------------------------------------------------------- */
684 667
685static struct proc_dir_entry *acpi_video_dir; 668static struct proc_dir_entry *acpi_video_dir;
686 669
687/* video devices */ 670/* video devices */
688 671
689static int 672static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
690acpi_video_device_info_seq_show (
691 struct seq_file *seq,
692 void *offset)
693{ 673{
694 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 674 struct acpi_video_device *dev =
675 (struct acpi_video_device *)seq->private;
695 676
696 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show"); 677 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
697 678
@@ -709,30 +690,25 @@ acpi_video_device_info_seq_show (
709 else 690 else
710 seq_printf(seq, "UNKNOWN\n"); 691 seq_printf(seq, "UNKNOWN\n");
711 692
712 seq_printf(seq,"known by bios: %s\n", 693 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
713 dev->flags.bios ? "yes":"no");
714 694
715end: 695 end:
716 return_VALUE(0); 696 return_VALUE(0);
717} 697}
718 698
719static int 699static int
720acpi_video_device_info_open_fs ( 700acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
721 struct inode *inode,
722 struct file *file)
723{ 701{
724 return single_open(file, acpi_video_device_info_seq_show, 702 return single_open(file, acpi_video_device_info_seq_show,
725 PDE(inode)->data); 703 PDE(inode)->data);
726} 704}
727 705
728static int 706static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
729acpi_video_device_state_seq_show (
730 struct seq_file *seq,
731 void *offset)
732{ 707{
733 int status; 708 int status;
734 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 709 struct acpi_video_device *dev =
735 unsigned long state; 710 (struct acpi_video_device *)seq->private;
711 unsigned long state;
736 712
737 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show"); 713 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
738 714
@@ -753,31 +729,27 @@ acpi_video_device_state_seq_show (
753 else 729 else
754 seq_printf(seq, "<not supported>\n"); 730 seq_printf(seq, "<not supported>\n");
755 731
756end: 732 end:
757 return_VALUE(0); 733 return_VALUE(0);
758} 734}
759 735
760static int 736static int
761acpi_video_device_state_open_fs ( 737acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
762 struct inode *inode,
763 struct file *file)
764{ 738{
765 return single_open(file, acpi_video_device_state_seq_show, 739 return single_open(file, acpi_video_device_state_seq_show,
766 PDE(inode)->data); 740 PDE(inode)->data);
767} 741}
768 742
769static ssize_t 743static ssize_t
770acpi_video_device_write_state ( 744acpi_video_device_write_state(struct file *file,
771 struct file *file, 745 const char __user * buffer,
772 const char __user *buffer, 746 size_t count, loff_t * data)
773 size_t count,
774 loff_t *data)
775{ 747{
776 int status; 748 int status;
777 struct seq_file *m = (struct seq_file *) file->private_data; 749 struct seq_file *m = (struct seq_file *)file->private_data;
778 struct acpi_video_device *dev = (struct acpi_video_device *) m->private; 750 struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
779 char str[12] = {0}; 751 char str[12] = { 0 };
780 u32 state = 0; 752 u32 state = 0;
781 753
782 ACPI_FUNCTION_TRACE("acpi_video_device_write_state"); 754 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
783 755
@@ -789,7 +761,7 @@ acpi_video_device_write_state (
789 761
790 str[count] = 0; 762 str[count] = 0;
791 state = simple_strtoul(str, NULL, 0); 763 state = simple_strtoul(str, NULL, 0);
792 state &= ((1ul<<31) | (1ul<<30) | (1ul<<0)); 764 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
793 765
794 status = acpi_video_device_set_state(dev, state); 766 status = acpi_video_device_set_state(dev, state);
795 767
@@ -800,12 +772,11 @@ acpi_video_device_write_state (
800} 772}
801 773
802static int 774static int
803acpi_video_device_brightness_seq_show ( 775acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
804 struct seq_file *seq,
805 void *offset)
806{ 776{
807 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 777 struct acpi_video_device *dev =
808 int i; 778 (struct acpi_video_device *)seq->private;
779 int i;
809 780
810 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show"); 781 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
811 782
@@ -823,26 +794,22 @@ acpi_video_device_brightness_seq_show (
823} 794}
824 795
825static int 796static int
826acpi_video_device_brightness_open_fs ( 797acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
827 struct inode *inode,
828 struct file *file)
829{ 798{
830 return single_open(file, acpi_video_device_brightness_seq_show, 799 return single_open(file, acpi_video_device_brightness_seq_show,
831 PDE(inode)->data); 800 PDE(inode)->data);
832} 801}
833 802
834static ssize_t 803static ssize_t
835acpi_video_device_write_brightness ( 804acpi_video_device_write_brightness(struct file *file,
836 struct file *file, 805 const char __user * buffer,
837 const char __user *buffer, 806 size_t count, loff_t * data)
838 size_t count,
839 loff_t *data)
840{ 807{
841 struct seq_file *m = (struct seq_file *) file->private_data; 808 struct seq_file *m = (struct seq_file *)file->private_data;
842 struct acpi_video_device *dev = (struct acpi_video_device *) m->private; 809 struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
843 char str[4] = {0}; 810 char str[4] = { 0 };
844 unsigned int level = 0; 811 unsigned int level = 0;
845 int i; 812 int i;
846 813
847 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 814 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
848 815
@@ -854,14 +821,15 @@ acpi_video_device_write_brightness (
854 821
855 str[count] = 0; 822 str[count] = 0;
856 level = simple_strtoul(str, NULL, 0); 823 level = simple_strtoul(str, NULL, 0);
857 824
858 if (level > 100) 825 if (level > 100)
859 return_VALUE(-EFAULT); 826 return_VALUE(-EFAULT);
860 827
861 /* validate though the list of available levels */ 828 /* validate though the list of available levels */
862 for (i = 0; i < dev->brightness->count; i++) 829 for (i = 0; i < dev->brightness->count; i++)
863 if (level == dev->brightness->levels[i]) { 830 if (level == dev->brightness->levels[i]) {
864 if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level))) 831 if (ACPI_SUCCESS
832 (acpi_video_device_lcd_set_level(dev, level)))
865 dev->brightness->curr = level; 833 dev->brightness->curr = level;
866 break; 834 break;
867 } 835 }
@@ -869,24 +837,22 @@ acpi_video_device_write_brightness (
869 return_VALUE(count); 837 return_VALUE(count);
870} 838}
871 839
872static int 840static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
873acpi_video_device_EDID_seq_show (
874 struct seq_file *seq,
875 void *offset)
876{ 841{
877 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 842 struct acpi_video_device *dev =
878 int status; 843 (struct acpi_video_device *)seq->private;
879 int i; 844 int status;
880 union acpi_object *edid = NULL; 845 int i;
846 union acpi_object *edid = NULL;
881 847
882 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show"); 848 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
883 849
884 if (!dev) 850 if (!dev)
885 goto out; 851 goto out;
886 852
887 status = acpi_video_device_EDID (dev, &edid, 128); 853 status = acpi_video_device_EDID(dev, &edid, 128);
888 if (ACPI_FAILURE(status)) { 854 if (ACPI_FAILURE(status)) {
889 status = acpi_video_device_EDID (dev, &edid, 256); 855 status = acpi_video_device_EDID(dev, &edid, 256);
890 } 856 }
891 857
892 if (ACPI_FAILURE(status)) { 858 if (ACPI_FAILURE(status)) {
@@ -898,7 +864,7 @@ acpi_video_device_EDID_seq_show (
898 seq_putc(seq, edid->buffer.pointer[i]); 864 seq_putc(seq, edid->buffer.pointer[i]);
899 } 865 }
900 866
901out: 867 out:
902 if (!edid) 868 if (!edid)
903 seq_printf(seq, "<not supported>\n"); 869 seq_printf(seq, "<not supported>\n");
904 else 870 else
@@ -908,20 +874,15 @@ out:
908} 874}
909 875
910static int 876static int
911acpi_video_device_EDID_open_fs ( 877acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
912 struct inode *inode,
913 struct file *file)
914{ 878{
915 return single_open(file, acpi_video_device_EDID_seq_show, 879 return single_open(file, acpi_video_device_EDID_seq_show,
916 PDE(inode)->data); 880 PDE(inode)->data);
917} 881}
918 882
919 883static int acpi_video_device_add_fs(struct acpi_device *device)
920static int
921acpi_video_device_add_fs (
922 struct acpi_device *device)
923{ 884{
924 struct proc_dir_entry *entry = NULL; 885 struct proc_dir_entry *entry = NULL;
925 struct acpi_video_device *vid_dev; 886 struct acpi_video_device *vid_dev;
926 887
927 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs"); 888 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
@@ -929,13 +890,13 @@ acpi_video_device_add_fs (
929 if (!device) 890 if (!device)
930 return_VALUE(-ENODEV); 891 return_VALUE(-ENODEV);
931 892
932 vid_dev = (struct acpi_video_device *) acpi_driver_data(device); 893 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
933 if (!vid_dev) 894 if (!vid_dev)
934 return_VALUE(-ENODEV); 895 return_VALUE(-ENODEV);
935 896
936 if (!acpi_device_dir(device)) { 897 if (!acpi_device_dir(device)) {
937 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 898 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
938 vid_dev->video->dir); 899 vid_dev->video->dir);
939 if (!acpi_device_dir(device)) 900 if (!acpi_device_dir(device))
940 return_VALUE(-ENODEV); 901 return_VALUE(-ENODEV);
941 acpi_device_dir(device)->owner = THIS_MODULE; 902 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -945,7 +906,7 @@ acpi_video_device_add_fs (
945 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 906 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
946 if (!entry) 907 if (!entry)
947 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 908 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
948 "Unable to create 'info' fs entry\n")); 909 "Unable to create 'info' fs entry\n"));
949 else { 910 else {
950 entry->proc_fops = &acpi_video_device_info_fops; 911 entry->proc_fops = &acpi_video_device_info_fops;
951 entry->data = acpi_driver_data(device); 912 entry->data = acpi_driver_data(device);
@@ -953,10 +914,12 @@ acpi_video_device_add_fs (
953 } 914 }
954 915
955 /* 'state' [R/W] */ 916 /* 'state' [R/W] */
956 entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 917 entry =
918 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
919 acpi_device_dir(device));
957 if (!entry) 920 if (!entry)
958 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 921 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
959 "Unable to create 'state' fs entry\n")); 922 "Unable to create 'state' fs entry\n"));
960 else { 923 else {
961 entry->proc_fops = &acpi_video_device_state_fops; 924 entry->proc_fops = &acpi_video_device_state_fops;
962 entry->proc_fops->write = acpi_video_device_write_state; 925 entry->proc_fops->write = acpi_video_device_write_state;
@@ -965,10 +928,12 @@ acpi_video_device_add_fs (
965 } 928 }
966 929
967 /* 'brightness' [R/W] */ 930 /* 'brightness' [R/W] */
968 entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 931 entry =
932 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
933 acpi_device_dir(device));
969 if (!entry) 934 if (!entry)
970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 935 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
971 "Unable to create 'brightness' fs entry\n")); 936 "Unable to create 'brightness' fs entry\n"));
972 else { 937 else {
973 entry->proc_fops = &acpi_video_device_brightness_fops; 938 entry->proc_fops = &acpi_video_device_brightness_fops;
974 entry->proc_fops->write = acpi_video_device_write_brightness; 939 entry->proc_fops->write = acpi_video_device_write_brightness;
@@ -980,7 +945,7 @@ acpi_video_device_add_fs (
980 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); 945 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
981 if (!entry) 946 if (!entry)
982 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 947 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
983 "Unable to create 'brightness' fs entry\n")); 948 "Unable to create 'brightness' fs entry\n"));
984 else { 949 else {
985 entry->proc_fops = &acpi_video_device_EDID_fops; 950 entry->proc_fops = &acpi_video_device_EDID_fops;
986 entry->data = acpi_driver_data(device); 951 entry->data = acpi_driver_data(device);
@@ -990,14 +955,12 @@ acpi_video_device_add_fs (
990 return_VALUE(0); 955 return_VALUE(0);
991} 956}
992 957
993static int 958static int acpi_video_device_remove_fs(struct acpi_device *device)
994acpi_video_device_remove_fs (
995 struct acpi_device *device)
996{ 959{
997 struct acpi_video_device *vid_dev; 960 struct acpi_video_device *vid_dev;
998 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs"); 961 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
999 962
1000 vid_dev = (struct acpi_video_device *) acpi_driver_data(device); 963 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
1001 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) 964 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1002 return_VALUE(-ENODEV); 965 return_VALUE(-ENODEV);
1003 966
@@ -1006,22 +969,17 @@ acpi_video_device_remove_fs (
1006 remove_proc_entry("state", acpi_device_dir(device)); 969 remove_proc_entry("state", acpi_device_dir(device));
1007 remove_proc_entry("brightness", acpi_device_dir(device)); 970 remove_proc_entry("brightness", acpi_device_dir(device));
1008 remove_proc_entry("EDID", acpi_device_dir(device)); 971 remove_proc_entry("EDID", acpi_device_dir(device));
1009 remove_proc_entry(acpi_device_bid(device), 972 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1010 vid_dev->video->dir);
1011 acpi_device_dir(device) = NULL; 973 acpi_device_dir(device) = NULL;
1012 } 974 }
1013 975
1014 return_VALUE(0); 976 return_VALUE(0);
1015} 977}
1016 978
1017
1018/* video bus */ 979/* video bus */
1019static int 980static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
1020acpi_video_bus_info_seq_show (
1021 struct seq_file *seq,
1022 void *offset)
1023{ 981{
1024 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 982 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1025 983
1026 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show"); 984 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
1027 985
@@ -1029,30 +987,25 @@ acpi_video_bus_info_seq_show (
1029 goto end; 987 goto end;
1030 988
1031 seq_printf(seq, "Switching heads: %s\n", 989 seq_printf(seq, "Switching heads: %s\n",
1032 video->flags.multihead ? "yes":"no"); 990 video->flags.multihead ? "yes" : "no");
1033 seq_printf(seq, "Video ROM: %s\n", 991 seq_printf(seq, "Video ROM: %s\n",
1034 video->flags.rom ? "yes":"no"); 992 video->flags.rom ? "yes" : "no");
1035 seq_printf(seq, "Device to be POSTed on boot: %s\n", 993 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1036 video->flags.post ? "yes":"no"); 994 video->flags.post ? "yes" : "no");
1037 995
1038end: 996 end:
1039 return_VALUE(0); 997 return_VALUE(0);
1040} 998}
1041 999
1042static int 1000static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
1043acpi_video_bus_info_open_fs (
1044 struct inode *inode,
1045 struct file *file)
1046{ 1001{
1047 return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data); 1002 return single_open(file, acpi_video_bus_info_seq_show,
1003 PDE(inode)->data);
1048} 1004}
1049 1005
1050static int 1006static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1051acpi_video_bus_ROM_seq_show (
1052 struct seq_file *seq,
1053 void *offset)
1054{ 1007{
1055 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1008 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1056 1009
1057 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show"); 1010 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1058 1011
@@ -1062,26 +1015,20 @@ acpi_video_bus_ROM_seq_show (
1062 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__); 1015 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1063 seq_printf(seq, "<TODO>\n"); 1016 seq_printf(seq, "<TODO>\n");
1064 1017
1065end: 1018 end:
1066 return_VALUE(0); 1019 return_VALUE(0);
1067} 1020}
1068 1021
1069static int 1022static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
1070acpi_video_bus_ROM_open_fs (
1071 struct inode *inode,
1072 struct file *file)
1073{ 1023{
1074 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data); 1024 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1075} 1025}
1076 1026
1077static int 1027static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1078acpi_video_bus_POST_info_seq_show (
1079 struct seq_file *seq,
1080 void *offset)
1081{ 1028{
1082 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1029 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1083 unsigned long options; 1030 unsigned long options;
1084 int status; 1031 int status;
1085 1032
1086 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show"); 1033 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1087 1034
@@ -1091,8 +1038,10 @@ acpi_video_bus_POST_info_seq_show (
1091 status = acpi_video_bus_POST_options(video, &options); 1038 status = acpi_video_bus_POST_options(video, &options);
1092 if (ACPI_SUCCESS(status)) { 1039 if (ACPI_SUCCESS(status)) {
1093 if (!(options & 1)) { 1040 if (!(options & 1)) {
1094 printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n"); 1041 printk(KERN_WARNING PREFIX
1095 printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n"); 1042 "The motherboard VGA device is not listed as a possible POST device.\n");
1043 printk(KERN_WARNING PREFIX
1044 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1096 } 1045 }
1097 printk("%lx\n", options); 1046 printk("%lx\n", options);
1098 seq_printf(seq, "can POST: <intgrated video>"); 1047 seq_printf(seq, "can POST: <intgrated video>");
@@ -1103,89 +1052,74 @@ acpi_video_bus_POST_info_seq_show (
1103 seq_putc(seq, '\n'); 1052 seq_putc(seq, '\n');
1104 } else 1053 } else
1105 seq_printf(seq, "<not supported>\n"); 1054 seq_printf(seq, "<not supported>\n");
1106end: 1055 end:
1107 return_VALUE(0); 1056 return_VALUE(0);
1108} 1057}
1109 1058
1110static int 1059static int
1111acpi_video_bus_POST_info_open_fs ( 1060acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1112 struct inode *inode,
1113 struct file *file)
1114{ 1061{
1115 return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data); 1062 return single_open(file, acpi_video_bus_POST_info_seq_show,
1063 PDE(inode)->data);
1116} 1064}
1117 1065
1118static int 1066static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1119acpi_video_bus_POST_seq_show (
1120 struct seq_file *seq,
1121 void *offset)
1122{ 1067{
1123 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1068 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1124 int status; 1069 int status;
1125 unsigned long id; 1070 unsigned long id;
1126 1071
1127 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show"); 1072 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1128 1073
1129 if (!video) 1074 if (!video)
1130 goto end; 1075 goto end;
1131 1076
1132 status = acpi_video_bus_get_POST (video, &id); 1077 status = acpi_video_bus_get_POST(video, &id);
1133 if (!ACPI_SUCCESS(status)) { 1078 if (!ACPI_SUCCESS(status)) {
1134 seq_printf(seq, "<not supported>\n"); 1079 seq_printf(seq, "<not supported>\n");
1135 goto end; 1080 goto end;
1136 } 1081 }
1137 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); 1082 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1138 1083
1139end: 1084 end:
1140 return_VALUE(0); 1085 return_VALUE(0);
1141} 1086}
1142 1087
1143static int 1088static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1144acpi_video_bus_DOS_seq_show (
1145 struct seq_file *seq,
1146 void *offset)
1147{ 1089{
1148 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1090 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1149 1091
1150 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show"); 1092 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1151 1093
1152 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting ); 1094 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1153 1095
1154 return_VALUE(0); 1096 return_VALUE(0);
1155} 1097}
1156 1098
1157static int 1099static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
1158acpi_video_bus_POST_open_fs (
1159 struct inode *inode,
1160 struct file *file)
1161{ 1100{
1162 return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data); 1101 return single_open(file, acpi_video_bus_POST_seq_show,
1102 PDE(inode)->data);
1163} 1103}
1164 1104
1165static int 1105static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file)
1166acpi_video_bus_DOS_open_fs (
1167 struct inode *inode,
1168 struct file *file)
1169{ 1106{
1170 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data); 1107 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1171} 1108}
1172 1109
1173static ssize_t 1110static ssize_t
1174acpi_video_bus_write_POST ( 1111acpi_video_bus_write_POST(struct file *file,
1175 struct file *file, 1112 const char __user * buffer,
1176 const char __user *buffer, 1113 size_t count, loff_t * data)
1177 size_t count,
1178 loff_t *data)
1179{ 1114{
1180 int status; 1115 int status;
1181 struct seq_file *m = (struct seq_file *) file->private_data; 1116 struct seq_file *m = (struct seq_file *)file->private_data;
1182 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; 1117 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
1183 char str[12] = {0}; 1118 char str[12] = { 0 };
1184 unsigned long opt, options; 1119 unsigned long opt, options;
1185 1120
1186 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST"); 1121 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1187 1122
1188
1189 if (!video || count + 1 > sizeof str) 1123 if (!video || count + 1 > sizeof str)
1190 return_VALUE(-EINVAL); 1124 return_VALUE(-EINVAL);
1191 1125
@@ -1205,32 +1139,28 @@ acpi_video_bus_write_POST (
1205 options |= 1; 1139 options |= 1;
1206 1140
1207 if (options & (1ul << opt)) { 1141 if (options & (1ul << opt)) {
1208 status = acpi_video_bus_set_POST (video, opt); 1142 status = acpi_video_bus_set_POST(video, opt);
1209 if (!ACPI_SUCCESS(status)) 1143 if (!ACPI_SUCCESS(status))
1210 return_VALUE(-EFAULT); 1144 return_VALUE(-EFAULT);
1211 1145
1212 } 1146 }
1213 1147
1214
1215 return_VALUE(count); 1148 return_VALUE(count);
1216} 1149}
1217 1150
1218static ssize_t 1151static ssize_t
1219acpi_video_bus_write_DOS ( 1152acpi_video_bus_write_DOS(struct file *file,
1220 struct file *file, 1153 const char __user * buffer,
1221 const char __user *buffer, 1154 size_t count, loff_t * data)
1222 size_t count,
1223 loff_t *data)
1224{ 1155{
1225 int status; 1156 int status;
1226 struct seq_file *m = (struct seq_file *) file->private_data; 1157 struct seq_file *m = (struct seq_file *)file->private_data;
1227 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; 1158 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
1228 char str[12] = {0}; 1159 char str[12] = { 0 };
1229 unsigned long opt; 1160 unsigned long opt;
1230 1161
1231 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS"); 1162 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1232 1163
1233
1234 if (!video || count + 1 > sizeof str) 1164 if (!video || count + 1 > sizeof str)
1235 return_VALUE(-EINVAL); 1165 return_VALUE(-EINVAL);
1236 1166
@@ -1242,7 +1172,7 @@ acpi_video_bus_write_DOS (
1242 if (opt > 7) 1172 if (opt > 7)
1243 return_VALUE(-EFAULT); 1173 return_VALUE(-EFAULT);
1244 1174
1245 status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2); 1175 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1246 1176
1247 if (!ACPI_SUCCESS(status)) 1177 if (!ACPI_SUCCESS(status))
1248 return_VALUE(-EFAULT); 1178 return_VALUE(-EFAULT);
@@ -1250,20 +1180,18 @@ acpi_video_bus_write_DOS (
1250 return_VALUE(count); 1180 return_VALUE(count);
1251} 1181}
1252 1182
1253static int 1183static int acpi_video_bus_add_fs(struct acpi_device *device)
1254acpi_video_bus_add_fs (
1255 struct acpi_device *device)
1256{ 1184{
1257 struct proc_dir_entry *entry = NULL; 1185 struct proc_dir_entry *entry = NULL;
1258 struct acpi_video_bus *video; 1186 struct acpi_video_bus *video;
1259 1187
1260 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs"); 1188 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1261 1189
1262 video = (struct acpi_video_bus *) acpi_driver_data(device); 1190 video = (struct acpi_video_bus *)acpi_driver_data(device);
1263 1191
1264 if (!acpi_device_dir(device)) { 1192 if (!acpi_device_dir(device)) {
1265 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1193 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1266 acpi_video_dir); 1194 acpi_video_dir);
1267 if (!acpi_device_dir(device)) 1195 if (!acpi_device_dir(device))
1268 return_VALUE(-ENODEV); 1196 return_VALUE(-ENODEV);
1269 video->dir = acpi_device_dir(device); 1197 video->dir = acpi_device_dir(device);
@@ -1273,7 +1201,8 @@ acpi_video_bus_add_fs (
1273 /* 'info' [R] */ 1201 /* 'info' [R] */
1274 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 1202 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1275 if (!entry) 1203 if (!entry)
1276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n")); 1204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1205 "Unable to create 'info' fs entry\n"));
1277 else { 1206 else {
1278 entry->proc_fops = &acpi_video_bus_info_fops; 1207 entry->proc_fops = &acpi_video_bus_info_fops;
1279 entry->data = acpi_driver_data(device); 1208 entry->data = acpi_driver_data(device);
@@ -1283,7 +1212,8 @@ acpi_video_bus_add_fs (
1283 /* 'ROM' [R] */ 1212 /* 'ROM' [R] */
1284 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); 1213 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1285 if (!entry) 1214 if (!entry)
1286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n")); 1215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1216 "Unable to create 'ROM' fs entry\n"));
1287 else { 1217 else {
1288 entry->proc_fops = &acpi_video_bus_ROM_fops; 1218 entry->proc_fops = &acpi_video_bus_ROM_fops;
1289 entry->data = acpi_driver_data(device); 1219 entry->data = acpi_driver_data(device);
@@ -1291,9 +1221,11 @@ acpi_video_bus_add_fs (
1291 } 1221 }
1292 1222
1293 /* 'POST_info' [R] */ 1223 /* 'POST_info' [R] */
1294 entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); 1224 entry =
1225 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1295 if (!entry) 1226 if (!entry)
1296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n")); 1227 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1228 "Unable to create 'POST_info' fs entry\n"));
1297 else { 1229 else {
1298 entry->proc_fops = &acpi_video_bus_POST_info_fops; 1230 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1299 entry->data = acpi_driver_data(device); 1231 entry->data = acpi_driver_data(device);
@@ -1301,9 +1233,12 @@ acpi_video_bus_add_fs (
1301 } 1233 }
1302 1234
1303 /* 'POST' [R/W] */ 1235 /* 'POST' [R/W] */
1304 entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); 1236 entry =
1237 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1238 acpi_device_dir(device));
1305 if (!entry) 1239 if (!entry)
1306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n")); 1240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1241 "Unable to create 'POST' fs entry\n"));
1307 else { 1242 else {
1308 entry->proc_fops = &acpi_video_bus_POST_fops; 1243 entry->proc_fops = &acpi_video_bus_POST_fops;
1309 entry->proc_fops->write = acpi_video_bus_write_POST; 1244 entry->proc_fops->write = acpi_video_bus_write_POST;
@@ -1312,9 +1247,12 @@ acpi_video_bus_add_fs (
1312 } 1247 }
1313 1248
1314 /* 'DOS' [R/W] */ 1249 /* 'DOS' [R/W] */
1315 entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); 1250 entry =
1251 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1252 acpi_device_dir(device));
1316 if (!entry) 1253 if (!entry)
1317 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n")); 1254 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1255 "Unable to create 'DOS' fs entry\n"));
1318 else { 1256 else {
1319 entry->proc_fops = &acpi_video_bus_DOS_fops; 1257 entry->proc_fops = &acpi_video_bus_DOS_fops;
1320 entry->proc_fops->write = acpi_video_bus_write_DOS; 1258 entry->proc_fops->write = acpi_video_bus_write_DOS;
@@ -1325,15 +1263,13 @@ acpi_video_bus_add_fs (
1325 return_VALUE(0); 1263 return_VALUE(0);
1326} 1264}
1327 1265
1328static int 1266static int acpi_video_bus_remove_fs(struct acpi_device *device)
1329acpi_video_bus_remove_fs (
1330 struct acpi_device *device)
1331{ 1267{
1332 struct acpi_video_bus *video; 1268 struct acpi_video_bus *video;
1333 1269
1334 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs"); 1270 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1335 1271
1336 video = (struct acpi_video_bus *) acpi_driver_data(device); 1272 video = (struct acpi_video_bus *)acpi_driver_data(device);
1337 1273
1338 if (acpi_device_dir(device)) { 1274 if (acpi_device_dir(device)) {
1339 remove_proc_entry("info", acpi_device_dir(device)); 1275 remove_proc_entry("info", acpi_device_dir(device));
@@ -1341,8 +1277,7 @@ acpi_video_bus_remove_fs (
1341 remove_proc_entry("POST_info", acpi_device_dir(device)); 1277 remove_proc_entry("POST_info", acpi_device_dir(device));
1342 remove_proc_entry("POST", acpi_device_dir(device)); 1278 remove_proc_entry("POST", acpi_device_dir(device));
1343 remove_proc_entry("DOS", acpi_device_dir(device)); 1279 remove_proc_entry("DOS", acpi_device_dir(device));
1344 remove_proc_entry(acpi_device_bid(device), 1280 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1345 acpi_video_dir);
1346 acpi_device_dir(device) = NULL; 1281 acpi_device_dir(device) = NULL;
1347 } 1282 }
1348 1283
@@ -1356,20 +1291,20 @@ acpi_video_bus_remove_fs (
1356/* device interface */ 1291/* device interface */
1357 1292
1358static int 1293static int
1359acpi_video_bus_get_one_device ( 1294acpi_video_bus_get_one_device(struct acpi_device *device,
1360 struct acpi_device *device, 1295 struct acpi_video_bus *video)
1361 struct acpi_video_bus *video)
1362{ 1296{
1363 unsigned long device_id; 1297 unsigned long device_id;
1364 int status, result; 1298 int status, result;
1365 struct acpi_video_device *data; 1299 struct acpi_video_device *data;
1366 1300
1367 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); 1301 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1368 1302
1369 if (!device || !video) 1303 if (!device || !video)
1370 return_VALUE(-EINVAL); 1304 return_VALUE(-EINVAL);
1371 1305
1372 status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); 1306 status =
1307 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1373 if (ACPI_SUCCESS(status)) { 1308 if (ACPI_SUCCESS(status)) {
1374 1309
1375 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); 1310 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
@@ -1401,15 +1336,17 @@ acpi_video_bus_get_one_device (
1401 data->flags.unknown = 1; 1336 data->flags.unknown = 1;
1402 break; 1337 break;
1403 } 1338 }
1404 1339
1405 acpi_video_device_bind(video, data); 1340 acpi_video_device_bind(video, data);
1406 acpi_video_device_find_cap(data); 1341 acpi_video_device_find_cap(data);
1407 1342
1408 status = acpi_install_notify_handler(data->handle, 1343 status = acpi_install_notify_handler(data->handle,
1409 ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data); 1344 ACPI_DEVICE_NOTIFY,
1345 acpi_video_device_notify,
1346 data);
1410 if (ACPI_FAILURE(status)) { 1347 if (ACPI_FAILURE(status)) {
1411 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1412 "Error installing notify handler\n")); 1349 "Error installing notify handler\n"));
1413 result = -ENODEV; 1350 result = -ENODEV;
1414 goto end; 1351 goto end;
1415 } 1352 }
@@ -1423,7 +1360,7 @@ acpi_video_bus_get_one_device (
1423 return_VALUE(0); 1360 return_VALUE(0);
1424 } 1361 }
1425 1362
1426end: 1363 end:
1427 return_VALUE(-ENOENT); 1364 return_VALUE(-ENOENT);
1428} 1365}
1429 1366
@@ -1437,15 +1374,15 @@ end:
1437 * Enumerate the video device list of the video bus, 1374 * Enumerate the video device list of the video bus,
1438 * bind the ids with the corresponding video devices 1375 * bind the ids with the corresponding video devices
1439 * under the video bus. 1376 * under the video bus.
1440 */ 1377 */
1441 1378
1442static void 1379static void acpi_video_device_rebind(struct acpi_video_bus *video)
1443acpi_video_device_rebind( struct acpi_video_bus *video)
1444{ 1380{
1445 struct list_head * node, * next; 1381 struct list_head *node, *next;
1446 list_for_each_safe(node, next, &video->video_device_list) { 1382 list_for_each_safe(node, next, &video->video_device_list) {
1447 struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry); 1383 struct acpi_video_device *dev =
1448 acpi_video_device_bind( video, dev); 1384 container_of(node, struct acpi_video_device, entry);
1385 acpi_video_device_bind(video, dev);
1449 } 1386 }
1450} 1387}
1451 1388
@@ -1460,21 +1397,21 @@ acpi_video_device_rebind( struct acpi_video_bus *video)
1460 * 1397 *
1461 * Bind the ids with the corresponding video devices 1398 * Bind the ids with the corresponding video devices
1462 * under the video bus. 1399 * under the video bus.
1463 */ 1400 */
1464 1401
1465static void 1402static void
1466acpi_video_device_bind( struct acpi_video_bus *video, 1403acpi_video_device_bind(struct acpi_video_bus *video,
1467 struct acpi_video_device *device) 1404 struct acpi_video_device *device)
1468{ 1405{
1469 int i; 1406 int i;
1470 ACPI_FUNCTION_TRACE("acpi_video_device_bind"); 1407 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1471 1408
1472#define IDS_VAL(i) video->attached_array[i].value.int_val 1409#define IDS_VAL(i) video->attached_array[i].value.int_val
1473#define IDS_BIND(i) video->attached_array[i].bind_info 1410#define IDS_BIND(i) video->attached_array[i].bind_info
1474 1411
1475 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && 1412 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1476 i < video->attached_count; i++) { 1413 i < video->attached_count; i++) {
1477 if (device->device_id == (IDS_VAL(i)& 0xffff)) { 1414 if (device->device_id == (IDS_VAL(i) & 0xffff)) {
1478 IDS_BIND(i) = device; 1415 IDS_BIND(i) = device;
1479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i)); 1416 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1480 } 1417 }
@@ -1492,17 +1429,17 @@ acpi_video_device_bind( struct acpi_video_bus *video,
1492 * 1429 *
1493 * Call _DOD to enumerate all devices attached to display adapter 1430 * Call _DOD to enumerate all devices attached to display adapter
1494 * 1431 *
1495 */ 1432 */
1496 1433
1497static int acpi_video_device_enumerate(struct acpi_video_bus *video) 1434static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1498{ 1435{
1499 int status; 1436 int status;
1500 int count; 1437 int count;
1501 int i; 1438 int i;
1502 struct acpi_video_enumerated_device *active_device_list; 1439 struct acpi_video_enumerated_device *active_device_list;
1503 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 1440 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1504 union acpi_object *dod = NULL; 1441 union acpi_object *dod = NULL;
1505 union acpi_object *obj; 1442 union acpi_object *obj;
1506 1443
1507 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate"); 1444 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1508 1445
@@ -1512,7 +1449,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1512 return_VALUE(status); 1449 return_VALUE(status);
1513 } 1450 }
1514 1451
1515 dod = (union acpi_object *) buffer.pointer; 1452 dod = (union acpi_object *)buffer.pointer;
1516 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { 1453 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1517 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1454 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
1518 status = -EFAULT; 1455 status = -EFAULT;
@@ -1520,11 +1457,13 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1520 } 1457 }
1521 1458
1522 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n", 1459 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1523 dod->package.count)); 1460 dod->package.count));
1524 1461
1525 active_device_list= kmalloc( 1462 active_device_list = kmalloc((1 +
1526 (1+dod->package.count)*sizeof(struct acpi_video_enumerated_device), 1463 dod->package.count) *
1527 GFP_KERNEL); 1464 sizeof(struct
1465 acpi_video_enumerated_device),
1466 GFP_KERNEL);
1528 1467
1529 if (!active_device_list) { 1468 if (!active_device_list) {
1530 status = -ENOMEM; 1469 status = -ENOMEM;
@@ -1533,25 +1472,28 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1533 1472
1534 count = 0; 1473 count = 0;
1535 for (i = 0; i < dod->package.count; i++) { 1474 for (i = 0; i < dod->package.count; i++) {
1536 obj = (union acpi_object *) &dod->package.elements[i]; 1475 obj = (union acpi_object *)&dod->package.elements[i];
1537 1476
1538 if (obj->type != ACPI_TYPE_INTEGER) { 1477 if (obj->type != ACPI_TYPE_INTEGER) {
1539 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1478 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1540 active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID; 1479 "Invalid _DOD data\n"));
1480 active_device_list[i].value.int_val =
1481 ACPI_VIDEO_HEAD_INVALID;
1541 } 1482 }
1542 active_device_list[i].value.int_val = obj->integer.value; 1483 active_device_list[i].value.int_val = obj->integer.value;
1543 active_device_list[i].bind_info = NULL; 1484 active_device_list[i].bind_info = NULL;
1544 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value)); 1485 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
1486 (int)obj->integer.value));
1545 count++; 1487 count++;
1546 } 1488 }
1547 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; 1489 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1548 1490
1549 if(video->attached_array) 1491 if (video->attached_array)
1550 kfree(video->attached_array); 1492 kfree(video->attached_array);
1551 1493
1552 video->attached_array = active_device_list; 1494 video->attached_array = active_device_list;
1553 video->attached_count = count; 1495 video->attached_count = count;
1554out: 1496 out:
1555 acpi_os_free(buffer.pointer); 1497 acpi_os_free(buffer.pointer);
1556 return_VALUE(status); 1498 return_VALUE(status);
1557} 1499}
@@ -1567,17 +1509,14 @@ out:
1567 * 1. Find out the current active output device. 1509 * 1. Find out the current active output device.
1568 * 2. Identify the next output device to switch 1510 * 2. Identify the next output device to switch
1569 * 3. call _DSS to do actual switch. 1511 * 3. call _DSS to do actual switch.
1570 */ 1512 */
1571 1513
1572static int 1514static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1573acpi_video_switch_output(
1574 struct acpi_video_bus *video,
1575 int event)
1576{ 1515{
1577 struct list_head * node, * next; 1516 struct list_head *node, *next;
1578 struct acpi_video_device *dev=NULL; 1517 struct acpi_video_device *dev = NULL;
1579 struct acpi_video_device *dev_next=NULL; 1518 struct acpi_video_device *dev_next = NULL;
1580 struct acpi_video_device *dev_prev=NULL; 1519 struct acpi_video_device *dev_prev = NULL;
1581 unsigned long state; 1520 unsigned long state;
1582 int status = 0; 1521 int status = 0;
1583 1522
@@ -1586,15 +1525,19 @@ acpi_video_switch_output(
1586 list_for_each_safe(node, next, &video->video_device_list) { 1525 list_for_each_safe(node, next, &video->video_device_list) {
1587 dev = container_of(node, struct acpi_video_device, entry); 1526 dev = container_of(node, struct acpi_video_device, entry);
1588 status = acpi_video_device_get_state(dev, &state); 1527 status = acpi_video_device_get_state(dev, &state);
1589 if (state & 0x2){ 1528 if (state & 0x2) {
1590 dev_next = container_of(node->next, struct acpi_video_device, entry); 1529 dev_next =
1591 dev_prev = container_of(node->prev, struct acpi_video_device, entry); 1530 container_of(node->next, struct acpi_video_device,
1531 entry);
1532 dev_prev =
1533 container_of(node->prev, struct acpi_video_device,
1534 entry);
1592 goto out; 1535 goto out;
1593 } 1536 }
1594 } 1537 }
1595 dev_next = container_of(node->next, struct acpi_video_device, entry); 1538 dev_next = container_of(node->next, struct acpi_video_device, entry);
1596 dev_prev = container_of(node->prev, struct acpi_video_device, entry); 1539 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1597out: 1540 out:
1598 switch (event) { 1541 switch (event) {
1599 case ACPI_VIDEO_NOTIFY_CYCLE: 1542 case ACPI_VIDEO_NOTIFY_CYCLE:
1600 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: 1543 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
@@ -1611,21 +1554,16 @@ out:
1611 return_VALUE(status); 1554 return_VALUE(status);
1612} 1555}
1613 1556
1614static int 1557static int
1615acpi_video_get_next_level( 1558acpi_video_get_next_level(struct acpi_video_device *device,
1616 struct acpi_video_device *device, 1559 u32 level_current, u32 event)
1617 u32 level_current,
1618 u32 event)
1619{ 1560{
1620 /*Fix me*/ 1561 /*Fix me */
1621 return level_current; 1562 return level_current;
1622} 1563}
1623 1564
1624
1625static void 1565static void
1626acpi_video_switch_brightness ( 1566acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1627 struct acpi_video_device *device,
1628 int event)
1629{ 1567{
1630 unsigned long level_current, level_next; 1568 unsigned long level_current, level_next;
1631 acpi_video_device_lcd_get_level_current(device, &level_current); 1569 acpi_video_device_lcd_get_level_current(device, &level_current);
@@ -1634,26 +1572,27 @@ acpi_video_switch_brightness (
1634} 1572}
1635 1573
1636static int 1574static int
1637acpi_video_bus_get_devices ( 1575acpi_video_bus_get_devices(struct acpi_video_bus *video,
1638 struct acpi_video_bus *video, 1576 struct acpi_device *device)
1639 struct acpi_device *device)
1640{ 1577{
1641 int status = 0; 1578 int status = 0;
1642 struct list_head *node, *next; 1579 struct list_head *node, *next;
1643 1580
1644 ACPI_FUNCTION_TRACE("acpi_video_get_devices"); 1581 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1645 1582
1646 acpi_video_device_enumerate(video); 1583 acpi_video_device_enumerate(video);
1647 1584
1648 list_for_each_safe(node, next, &device->children) { 1585 list_for_each_safe(node, next, &device->children) {
1649 struct acpi_device *dev = list_entry(node, struct acpi_device, node); 1586 struct acpi_device *dev =
1587 list_entry(node, struct acpi_device, node);
1650 1588
1651 if (!dev) 1589 if (!dev)
1652 continue; 1590 continue;
1653 1591
1654 status = acpi_video_bus_get_one_device(dev, video); 1592 status = acpi_video_bus_get_one_device(dev, video);
1655 if (ACPI_FAILURE(status)) { 1593 if (ACPI_FAILURE(status)) {
1656 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n")); 1594 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1595 "Cant attach device\n"));
1657 continue; 1596 continue;
1658 } 1597 }
1659 1598
@@ -1661,10 +1600,9 @@ acpi_video_bus_get_devices (
1661 return_VALUE(status); 1600 return_VALUE(status);
1662} 1601}
1663 1602
1664static int 1603static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1665acpi_video_bus_put_one_device(
1666 struct acpi_video_device *device)
1667{ 1604{
1605 acpi_status status;
1668 struct acpi_video_bus *video; 1606 struct acpi_video_bus *video;
1669 1607
1670 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device"); 1608 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
@@ -1679,26 +1617,33 @@ acpi_video_bus_put_one_device(
1679 up(&video->sem); 1617 up(&video->sem);
1680 acpi_video_device_remove_fs(device->dev); 1618 acpi_video_device_remove_fs(device->dev);
1681 1619
1620 status = acpi_remove_notify_handler(device->handle,
1621 ACPI_DEVICE_NOTIFY,
1622 acpi_video_device_notify);
1623 if (ACPI_FAILURE(status))
1624 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1625 "Error removing notify handler\n"));
1626
1682 return_VALUE(0); 1627 return_VALUE(0);
1683} 1628}
1684 1629
1685static int 1630static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1686acpi_video_bus_put_devices (
1687 struct acpi_video_bus *video)
1688{ 1631{
1689 int status; 1632 int status;
1690 struct list_head *node, *next; 1633 struct list_head *node, *next;
1691 1634
1692 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices"); 1635 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1693 1636
1694 list_for_each_safe(node, next, &video->video_device_list) { 1637 list_for_each_safe(node, next, &video->video_device_list) {
1695 struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry); 1638 struct acpi_video_device *data =
1639 list_entry(node, struct acpi_video_device, entry);
1696 if (!data) 1640 if (!data)
1697 continue; 1641 continue;
1698 1642
1699 status = acpi_video_bus_put_one_device(data); 1643 status = acpi_video_bus_put_one_device(data);
1700 if(ACPI_FAILURE(status)) 1644 if (ACPI_FAILURE(status))
1701 printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); 1645 printk(KERN_WARNING PREFIX
1646 "hhuuhhuu bug in acpi video driver.\n");
1702 1647
1703 if (data->brightness) 1648 if (data->brightness)
1704 kfree(data->brightness); 1649 kfree(data->brightness);
@@ -1711,28 +1656,20 @@ acpi_video_bus_put_devices (
1711 1656
1712/* acpi_video interface */ 1657/* acpi_video interface */
1713 1658
1714static int 1659static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1715acpi_video_bus_start_devices(
1716 struct acpi_video_bus *video)
1717{ 1660{
1718 return acpi_video_bus_DOS(video, 1, 0); 1661 return acpi_video_bus_DOS(video, 1, 0);
1719} 1662}
1720 1663
1721static int 1664static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1722acpi_video_bus_stop_devices(
1723 struct acpi_video_bus *video)
1724{ 1665{
1725 return acpi_video_bus_DOS(video, 0, 1); 1666 return acpi_video_bus_DOS(video, 0, 1);
1726} 1667}
1727 1668
1728static void 1669static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1729acpi_video_bus_notify (
1730 acpi_handle handle,
1731 u32 event,
1732 void *data)
1733{ 1670{
1734 struct acpi_video_bus *video = (struct acpi_video_bus *) data; 1671 struct acpi_video_bus *video = (struct acpi_video_bus *)data;
1735 struct acpi_device *device = NULL; 1672 struct acpi_device *device = NULL;
1736 1673
1737 ACPI_FUNCTION_TRACE("acpi_video_bus_notify"); 1674 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1738 printk("video bus notify\n"); 1675 printk("video bus notify\n");
@@ -1757,30 +1694,27 @@ acpi_video_bus_notify (
1757 acpi_bus_generate_event(device, event, 0); 1694 acpi_bus_generate_event(device, event, 0);
1758 break; 1695 break;
1759 1696
1760 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/ 1697 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1761 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ 1698 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1762 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ 1699 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1763 acpi_video_switch_output(video, event); 1700 acpi_video_switch_output(video, event);
1764 acpi_bus_generate_event(device, event, 0); 1701 acpi_bus_generate_event(device, event, 0);
1765 break; 1702 break;
1766 1703
1767 default: 1704 default:
1768 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1705 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1769 "Unsupported event [0x%x]\n", event)); 1706 "Unsupported event [0x%x]\n", event));
1770 break; 1707 break;
1771 } 1708 }
1772 1709
1773 return_VOID; 1710 return_VOID;
1774} 1711}
1775 1712
1776static void 1713static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1777acpi_video_device_notify (
1778 acpi_handle handle,
1779 u32 event,
1780 void *data)
1781{ 1714{
1782 struct acpi_video_device *video_device = (struct acpi_video_device *) data; 1715 struct acpi_video_device *video_device =
1783 struct acpi_device *device = NULL; 1716 (struct acpi_video_device *)data;
1717 struct acpi_device *device = NULL;
1784 1718
1785 ACPI_FUNCTION_TRACE("acpi_video_device_notify"); 1719 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1786 1720
@@ -1792,36 +1726,34 @@ acpi_video_device_notify (
1792 return_VOID; 1726 return_VOID;
1793 1727
1794 switch (event) { 1728 switch (event) {
1795 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ 1729 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1796 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */ 1730 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1797 acpi_bus_generate_event(device, event, 0); 1731 acpi_bus_generate_event(device, event, 0);
1798 break; 1732 break;
1799 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ 1733 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1800 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ 1734 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1801 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ 1735 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1802 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ 1736 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1803 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ 1737 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1804 acpi_video_switch_brightness (video_device, event); 1738 acpi_video_switch_brightness(video_device, event);
1805 acpi_bus_generate_event(device, event, 0); 1739 acpi_bus_generate_event(device, event, 0);
1806 break; 1740 break;
1807 default: 1741 default:
1808 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1742 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1809 "Unsupported event [0x%x]\n", event)); 1743 "Unsupported event [0x%x]\n", event));
1810 break; 1744 break;
1811 } 1745 }
1812 return_VOID; 1746 return_VOID;
1813} 1747}
1814 1748
1815static int 1749static int acpi_video_bus_add(struct acpi_device *device)
1816acpi_video_bus_add (
1817 struct acpi_device *device)
1818{ 1750{
1819 int result = 0; 1751 int result = 0;
1820 acpi_status status = 0; 1752 acpi_status status = 0;
1821 struct acpi_video_bus *video = NULL; 1753 struct acpi_video_bus *video = NULL;
1822 1754
1823 ACPI_FUNCTION_TRACE("acpi_video_bus_add"); 1755 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1824 1756
1825 if (!device) 1757 if (!device)
1826 return_VALUE(-EINVAL); 1758 return_VALUE(-EINVAL);
1827 1759
@@ -1851,21 +1783,22 @@ acpi_video_bus_add (
1851 acpi_video_bus_start_devices(video); 1783 acpi_video_bus_start_devices(video);
1852 1784
1853 status = acpi_install_notify_handler(video->handle, 1785 status = acpi_install_notify_handler(video->handle,
1854 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video); 1786 ACPI_DEVICE_NOTIFY,
1787 acpi_video_bus_notify, video);
1855 if (ACPI_FAILURE(status)) { 1788 if (ACPI_FAILURE(status)) {
1856 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1789 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1857 "Error installing notify handler\n")); 1790 "Error installing notify handler\n"));
1858 result = -ENODEV; 1791 result = -ENODEV;
1859 goto end; 1792 goto end;
1860 } 1793 }
1861 1794
1862 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1795 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1863 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1796 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1864 video->flags.multihead ? "yes":"no", 1797 video->flags.multihead ? "yes" : "no",
1865 video->flags.rom ? "yes":"no", 1798 video->flags.rom ? "yes" : "no",
1866 video->flags.post ? "yes":"no"); 1799 video->flags.post ? "yes" : "no");
1867 1800
1868end: 1801 end:
1869 if (result) { 1802 if (result) {
1870 acpi_video_bus_remove_fs(device); 1803 acpi_video_bus_remove_fs(device);
1871 kfree(video); 1804 kfree(video);
@@ -1874,28 +1807,26 @@ end:
1874 return_VALUE(result); 1807 return_VALUE(result);
1875} 1808}
1876 1809
1877static int 1810static int acpi_video_bus_remove(struct acpi_device *device, int type)
1878acpi_video_bus_remove (
1879 struct acpi_device *device,
1880 int type)
1881{ 1811{
1882 acpi_status status = 0; 1812 acpi_status status = 0;
1883 struct acpi_video_bus *video = NULL; 1813 struct acpi_video_bus *video = NULL;
1884 1814
1885 ACPI_FUNCTION_TRACE("acpi_video_bus_remove"); 1815 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1886 1816
1887 if (!device || !acpi_driver_data(device)) 1817 if (!device || !acpi_driver_data(device))
1888 return_VALUE(-EINVAL); 1818 return_VALUE(-EINVAL);
1889 1819
1890 video = (struct acpi_video_bus *) acpi_driver_data(device); 1820 video = (struct acpi_video_bus *)acpi_driver_data(device);
1891 1821
1892 acpi_video_bus_stop_devices(video); 1822 acpi_video_bus_stop_devices(video);
1893 1823
1894 status = acpi_remove_notify_handler(video->handle, 1824 status = acpi_remove_notify_handler(video->handle,
1895 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); 1825 ACPI_DEVICE_NOTIFY,
1826 acpi_video_bus_notify);
1896 if (ACPI_FAILURE(status)) 1827 if (ACPI_FAILURE(status))
1897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1828 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1898 "Error removing notify handler\n")); 1829 "Error removing notify handler\n"));
1899 1830
1900 acpi_video_bus_put_devices(video); 1831 acpi_video_bus_put_devices(video);
1901 acpi_video_bus_remove_fs(device); 1832 acpi_video_bus_remove_fs(device);
@@ -1907,15 +1838,12 @@ acpi_video_bus_remove (
1907 return_VALUE(0); 1838 return_VALUE(0);
1908} 1839}
1909 1840
1910
1911static int 1841static int
1912acpi_video_bus_match ( 1842acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1913 struct acpi_device *device,
1914 struct acpi_driver *driver)
1915{ 1843{
1916 acpi_handle h_dummy1; 1844 acpi_handle h_dummy1;
1917 acpi_handle h_dummy2; 1845 acpi_handle h_dummy2;
1918 acpi_handle h_dummy3; 1846 acpi_handle h_dummy3;
1919 1847
1920 ACPI_FUNCTION_TRACE("acpi_video_bus_match"); 1848 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1921 1849
@@ -1941,22 +1869,19 @@ acpi_video_bus_match (
1941 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) 1869 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1942 return_VALUE(0); 1870 return_VALUE(0);
1943 1871
1944
1945 return_VALUE(-ENODEV); 1872 return_VALUE(-ENODEV);
1946} 1873}
1947 1874
1948 1875static int __init acpi_video_init(void)
1949static int __init
1950acpi_video_init (void)
1951{ 1876{
1952 int result = 0; 1877 int result = 0;
1953 1878
1954 ACPI_FUNCTION_TRACE("acpi_video_init"); 1879 ACPI_FUNCTION_TRACE("acpi_video_init");
1955 1880
1956 /* 1881 /*
1957 acpi_dbg_level = 0xFFFFFFFF; 1882 acpi_dbg_level = 0xFFFFFFFF;
1958 acpi_dbg_layer = 0x08000000; 1883 acpi_dbg_layer = 0x08000000;
1959 */ 1884 */
1960 1885
1961 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 1886 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1962 if (!acpi_video_dir) 1887 if (!acpi_video_dir)
@@ -1972,8 +1897,7 @@ acpi_video_init (void)
1972 return_VALUE(0); 1897 return_VALUE(0);
1973} 1898}
1974 1899
1975static void __exit 1900static void __exit acpi_video_exit(void)
1976acpi_video_exit (void)
1977{ 1901{
1978 ACPI_FUNCTION_TRACE("acpi_video_exit"); 1902 ACPI_FUNCTION_TRACE("acpi_video_exit");
1979 1903
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 762fa430fb5b..97feb7f7024d 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -906,11 +906,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
906 if (irqp->number_of_interrupts > 0) { 906 if (irqp->number_of_interrupts > 0) {
907 hdp->hd_nirqs = irqp->number_of_interrupts; 907 hdp->hd_nirqs = irqp->number_of_interrupts;
908 908
909 for (i = 0; i < hdp->hd_nirqs; i++) 909 for (i = 0; i < hdp->hd_nirqs; i++) {
910 hdp->hd_irq[i] = 910 int rc =
911 acpi_register_gsi(irqp->interrupts[i], 911 acpi_register_gsi(irqp->interrupts[i],
912 irqp->edge_level, 912 irqp->edge_level,
913 irqp->active_high_low); 913 irqp->active_high_low);
914 if (rc < 0)
915 return AE_ERROR;
916 hdp->hd_irq[i] = rc;
917 }
914 } 918 }
915 } 919 }
916 920
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index a44b97304e95..adbec73b80a6 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -986,7 +986,7 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for"
986#define IPMI_MEM_ADDR_SPACE 1 986#define IPMI_MEM_ADDR_SPACE 1
987#define IPMI_IO_ADDR_SPACE 2 987#define IPMI_IO_ADDR_SPACE 2
988 988
989#if defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_X86) || defined(CONFIG_PCI) 989#if defined(CONFIG_ACPI) || defined(CONFIG_X86) || defined(CONFIG_PCI)
990static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr) 990static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr)
991{ 991{
992 int i; 992 int i;
@@ -1362,7 +1362,7 @@ static int try_init_mem(int intf_num, struct smi_info **new_info)
1362} 1362}
1363 1363
1364 1364
1365#ifdef CONFIG_ACPI_INTERPRETER 1365#ifdef CONFIG_ACPI
1366 1366
1367#include <linux/acpi.h> 1367#include <linux/acpi.h>
1368 1368
@@ -1484,6 +1484,9 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1484 char *io_type; 1484 char *io_type;
1485 u8 addr_space; 1485 u8 addr_space;
1486 1486
1487 if (acpi_disabled)
1488 return -ENODEV;
1489
1487 if (acpi_failure) 1490 if (acpi_failure)
1488 return -ENODEV; 1491 return -ENODEV;
1489 1492
@@ -2067,7 +2070,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2067 rv = try_init_mem(intf_num, &new_smi); 2070 rv = try_init_mem(intf_num, &new_smi);
2068 if (rv) 2071 if (rv)
2069 rv = try_init_port(intf_num, &new_smi); 2072 rv = try_init_port(intf_num, &new_smi);
2070#ifdef CONFIG_ACPI_INTERPRETER 2073#ifdef CONFIG_ACPI
2071 if ((rv) && (si_trydefaults)) { 2074 if ((rv) && (si_trydefaults)) {
2072 rv = try_init_acpi(intf_num, &new_smi); 2075 rv = try_init_acpi(intf_num, &new_smi);
2073 } 2076 }
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index 79e9832ef1f3..b58adfe3ed19 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -17,7 +17,7 @@ config TCG_TPM
17 obtained at: <http://sourceforge.net/projects/trousers>. To 17 obtained at: <http://sourceforge.net/projects/trousers>. To
18 compile this driver as a module, choose M here; the module 18 compile this driver as a module, choose M here; the module
19 will be called tpm. If unsure, say N. 19 will be called tpm. If unsure, say N.
20 Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI_BUS 20 Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI
21 and CONFIG_PNPACPI. 21 and CONFIG_PNPACPI.
22 22
23config TCG_NSC 23config TCG_NSC
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index 9c4a39ee89b5..2f1289eebb3c 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -78,7 +78,7 @@ config HOTPLUG_PCI_IBM
78 78
79config HOTPLUG_PCI_ACPI 79config HOTPLUG_PCI_ACPI
80 tristate "ACPI PCI Hotplug driver" 80 tristate "ACPI PCI Hotplug driver"
81 depends on ACPI_BUS && HOTPLUG_PCI 81 depends on ACPI && HOTPLUG_PCI
82 help 82 help
83 Say Y here if you have a system that supports PCI Hotplug using 83 Say Y here if you have a system that supports PCI Hotplug using
84 ACPI. 84 ACPI.
@@ -157,7 +157,7 @@ config HOTPLUG_PCI_SHPC_POLL_EVENT_MODE
157 157
158config HOTPLUG_PCI_SHPC_PHPRM_LEGACY 158config HOTPLUG_PCI_SHPC_PHPRM_LEGACY
159 bool "For AMD SHPC only: Use $HRT for resource/configuration" 159 bool "For AMD SHPC only: Use $HRT for resource/configuration"
160 depends on HOTPLUG_PCI_SHPC && !ACPI_BUS 160 depends on HOTPLUG_PCI_SHPC && !ACPI
161 help 161 help
162 Say Y here for AMD SHPC. You have to select this option if you are 162 Say Y here for AMD SHPC. You have to select this option if you are
163 using this driver on platform with AMD SHPC. 163 using this driver on platform with AMD SHPC.
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 31a307004b94..246586a3d91a 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -51,7 +51,7 @@ pciehp-objs := pciehp_core.o \
51 pciehp_ctrl.o \ 51 pciehp_ctrl.o \
52 pciehp_pci.o \ 52 pciehp_pci.o \
53 pciehp_hpc.o 53 pciehp_hpc.o
54ifdef CONFIG_ACPI_BUS 54ifdef CONFIG_ACPI
55 pciehp-objs += pciehprm_acpi.o 55 pciehp-objs += pciehprm_acpi.o
56else 56else
57 pciehp-objs += pciehprm_nonacpi.o 57 pciehp-objs += pciehprm_nonacpi.o
@@ -62,7 +62,7 @@ shpchp-objs := shpchp_core.o \
62 shpchp_pci.o \ 62 shpchp_pci.o \
63 shpchp_sysfs.o \ 63 shpchp_sysfs.o \
64 shpchp_hpc.o 64 shpchp_hpc.o
65ifdef CONFIG_ACPI_BUS 65ifdef CONFIG_ACPI
66 shpchp-objs += shpchprm_acpi.o 66 shpchp-objs += shpchprm_acpi.o
67else 67else
68 ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY 68 ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY
diff --git a/drivers/pnp/Kconfig b/drivers/pnp/Kconfig
index 6776308a1fe5..c5143201419a 100644
--- a/drivers/pnp/Kconfig
+++ b/drivers/pnp/Kconfig
@@ -6,7 +6,7 @@ menu "Plug and Play support"
6 6
7config PNP 7config PNP
8 bool "Plug and Play support" 8 bool "Plug and Play support"
9 depends on ISA || ACPI_BUS 9 depends on ISA || ACPI
10 ---help--- 10 ---help---
11 Plug and Play (PnP) is a standard for peripherals which allows those 11 Plug and Play (PnP) is a standard for peripherals which allows those
12 peripherals to be configured by software, e.g. assign IRQ's or other 12 peripherals to be configured by software, e.g. assign IRQ's or other
diff --git a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig
index 0782cdc5009f..b1854171b963 100644
--- a/drivers/pnp/pnpacpi/Kconfig
+++ b/drivers/pnp/pnpacpi/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config PNPACPI 4config PNPACPI
5 bool "Plug and Play ACPI support (EXPERIMENTAL)" 5 bool "Plug and Play ACPI support (EXPERIMENTAL)"
6 depends on PNP && ACPI_BUS && EXPERIMENTAL 6 depends on PNP && ACPI && EXPERIMENTAL
7 default y 7 default y
8 ---help--- 8 ---help---
9 Linux uses the PNPACPI to autodetect built-in 9 Linux uses the PNPACPI to autodetect built-in
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 75575f6c349c..6db549c9480c 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -73,25 +73,35 @@ static void decode_irq_flags(int flag, int *edge_level, int *active_high_low)
73} 73}
74 74
75static void 75static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) 76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
77 int edge_level, int active_high_low)
77{ 78{
78 int i = 0; 79 int i = 0;
80 int irq;
81
82 if (!valid_IRQ(gsi))
83 return;
84
79 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && 85 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
80 i < PNP_MAX_IRQ) 86 i < PNP_MAX_IRQ)
81 i++; 87 i++;
82 if (i < PNP_MAX_IRQ) { 88 if (i >= PNP_MAX_IRQ)
83 res->irq_resource[i].flags = IORESOURCE_IRQ; //Also clears _UNSET flag 89 return;
84 if (irq == -1) { 90
85 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
86 return; 92 irq = acpi_register_gsi(gsi, edge_level, active_high_low);
87 } 93 if (irq < 0) {
88 res->irq_resource[i].start =(unsigned long) irq; 94 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
89 res->irq_resource[i].end = (unsigned long) irq; 95 return;
90 } 96 }
97
98 res->irq_resource[i].start = irq;
99 res->irq_resource[i].end = irq;
100 pcibios_penalize_isa_irq(irq, 1);
91} 101}
92 102
93static void 103static void
94pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 104pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma)
95{ 105{
96 int i = 0; 106 int i = 0;
97 while (i < PNP_MAX_DMA && 107 while (i < PNP_MAX_DMA &&
@@ -103,14 +113,14 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
103 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 113 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
104 return; 114 return;
105 } 115 }
106 res->dma_resource[i].start =(unsigned long) dma; 116 res->dma_resource[i].start = dma;
107 res->dma_resource[i].end = (unsigned long) dma; 117 res->dma_resource[i].end = dma;
108 } 118 }
109} 119}
110 120
111static void 121static void
112pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, 122pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
113 int io, int len) 123 u32 io, u32 len)
114{ 124{
115 int i = 0; 125 int i = 0;
116 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && 126 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
@@ -122,14 +132,14 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
122 res->port_resource[i].flags |= IORESOURCE_DISABLED; 132 res->port_resource[i].flags |= IORESOURCE_DISABLED;
123 return; 133 return;
124 } 134 }
125 res->port_resource[i].start = (unsigned long) io; 135 res->port_resource[i].start = io;
126 res->port_resource[i].end = (unsigned long)(io + len - 1); 136 res->port_resource[i].end = io + len - 1;
127 } 137 }
128} 138}
129 139
130static void 140static void
131pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, 141pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res,
132 int mem, int len) 142 u64 mem, u64 len)
133{ 143{
134 int i = 0; 144 int i = 0;
135 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && 145 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
@@ -141,8 +151,8 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res,
141 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 151 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
142 return; 152 return;
143 } 153 }
144 res->mem_resource[i].start = (unsigned long) mem; 154 res->mem_resource[i].start = mem;
145 res->mem_resource[i].end = (unsigned long)(mem + len - 1); 155 res->mem_resource[i].end = mem + len - 1;
146 } 156 }
147} 157}
148 158
@@ -151,27 +161,28 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
151 void *data) 161 void *data)
152{ 162{
153 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; 163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
164 int i;
154 165
155 switch (res->id) { 166 switch (res->id) {
156 case ACPI_RSTYPE_IRQ: 167 case ACPI_RSTYPE_IRQ:
157 if ((res->data.irq.number_of_interrupts > 0) && 168 /*
158 valid_IRQ(res->data.irq.interrupts[0])) { 169 * Per spec, only one interrupt per descriptor is allowed in
159 pnpacpi_parse_allocated_irqresource(res_table, 170 * _CRS, but some firmware violates this, so parse them all.
160 acpi_register_gsi(res->data.irq.interrupts[0], 171 */
161 res->data.irq.edge_level, 172 for (i = 0; i < res->data.irq.number_of_interrupts; i++) {
162 res->data.irq.active_high_low)); 173 pnpacpi_parse_allocated_irqresource(res_table,
163 pcibios_penalize_isa_irq(res->data.irq.interrupts[0], 1); 174 res->data.irq.interrupts[i],
175 res->data.irq.edge_level,
176 res->data.irq.active_high_low);
164 } 177 }
165 break; 178 break;
166 179
167 case ACPI_RSTYPE_EXT_IRQ: 180 case ACPI_RSTYPE_EXT_IRQ:
168 if ((res->data.extended_irq.number_of_interrupts > 0) && 181 for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) {
169 valid_IRQ(res->data.extended_irq.interrupts[0])) { 182 pnpacpi_parse_allocated_irqresource(res_table,
170 pnpacpi_parse_allocated_irqresource(res_table, 183 res->data.extended_irq.interrupts[i],
171 acpi_register_gsi(res->data.extended_irq.interrupts[0], 184 res->data.extended_irq.edge_level,
172 res->data.extended_irq.edge_level, 185 res->data.extended_irq.active_high_low);
173 res->data.extended_irq.active_high_low));
174 pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0], 1);
175 } 186 }
176 break; 187 break;
177 case ACPI_RSTYPE_DMA: 188 case ACPI_RSTYPE_DMA:
diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
index 6b9ead288517..a802bdce6e5d 100644
--- a/drivers/serial/8250_acpi.c
+++ b/drivers/serial/8250_acpi.c
@@ -47,18 +47,30 @@ static acpi_status acpi_serial_port(struct uart_port *port,
47static acpi_status acpi_serial_ext_irq(struct uart_port *port, 47static acpi_status acpi_serial_ext_irq(struct uart_port *port,
48 struct acpi_resource_ext_irq *ext_irq) 48 struct acpi_resource_ext_irq *ext_irq)
49{ 49{
50 if (ext_irq->number_of_interrupts > 0) 50 int rc;
51 port->irq = acpi_register_gsi(ext_irq->interrupts[0], 51
52 if (ext_irq->number_of_interrupts > 0) {
53 rc = acpi_register_gsi(ext_irq->interrupts[0],
52 ext_irq->edge_level, ext_irq->active_high_low); 54 ext_irq->edge_level, ext_irq->active_high_low);
55 if (rc < 0)
56 return AE_ERROR;
57 port->irq = rc;
58 }
53 return AE_OK; 59 return AE_OK;
54} 60}
55 61
56static acpi_status acpi_serial_irq(struct uart_port *port, 62static acpi_status acpi_serial_irq(struct uart_port *port,
57 struct acpi_resource_irq *irq) 63 struct acpi_resource_irq *irq)
58{ 64{
59 if (irq->number_of_interrupts > 0) 65 int rc;
60 port->irq = acpi_register_gsi(irq->interrupts[0], 66
67 if (irq->number_of_interrupts > 0) {
68 rc = acpi_register_gsi(irq->interrupts[0],
61 irq->edge_level, irq->active_high_low); 69 irq->edge_level, irq->active_high_low);
70 if (rc < 0)
71 return AE_ERROR;
72 port->irq = rc;
73 }
62 return AE_OK; 74 return AE_OK;
63} 75}
64 76
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 74b80f7c062d..db8f39c30096 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -80,7 +80,7 @@ config SERIAL_8250_CS
80config SERIAL_8250_ACPI 80config SERIAL_8250_ACPI
81 bool "8250/16550 device discovery via ACPI namespace" 81 bool "8250/16550 device discovery via ACPI namespace"
82 default y if IA64 82 default y if IA64
83 depends on ACPI_BUS && SERIAL_8250 83 depends on ACPI && SERIAL_8250
84 ---help--- 84 ---help---
85 If you wish to enable serial port discovery via the ACPI 85 If you wish to enable serial port discovery via the ACPI
86 namespace, say Y here. If unsure, say N. 86 namespace, say Y here. If unsure, say N.
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 2f6ab189fc6f..427cff1a3f83 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -44,7 +44,6 @@
44#ifndef _ACCONFIG_H 44#ifndef _ACCONFIG_H
45#define _ACCONFIG_H 45#define _ACCONFIG_H
46 46
47
48/****************************************************************************** 47/******************************************************************************
49 * 48 *
50 * Configuration options 49 * Configuration options
@@ -64,7 +63,7 @@
64 63
65/* Version string */ 64/* Version string */
66 65
67#define ACPI_CA_VERSION 0x20050408 66#define ACPI_CA_VERSION 0x20050902
68 67
69/* 68/*
70 * OS name, used for the _OS object. The _OS object is essentially obsolete, 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
@@ -78,11 +77,10 @@
78 77
79/* Maximum objects in the various object caches */ 78/* Maximum objects in the various object caches */
80 79
81#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects */ 80#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */
82#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ 81#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
83#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ 82#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
84#define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ 83#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
85#define ACPI_MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */
86 84
87/* 85/*
88 * Should the subystem abort the loading of an ACPI table if the 86 * Should the subystem abort the loading of an ACPI table if the
@@ -90,7 +88,6 @@
90 */ 88 */
91#define ACPI_CHECKSUM_ABORT FALSE 89#define ACPI_CHECKSUM_ABORT FALSE
92 90
93
94/****************************************************************************** 91/******************************************************************************
95 * 92 *
96 * Subsystem Constants 93 * Subsystem Constants
@@ -104,7 +101,7 @@
104/* String size constants */ 101/* String size constants */
105 102
106#define ACPI_MAX_STRING_LENGTH 512 103#define ACPI_MAX_STRING_LENGTH 512
107#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */ 104#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */
108 105
109/* Maximum count for a semaphore object */ 106/* Maximum count for a semaphore object */
110 107
@@ -118,7 +115,6 @@
118 115
119#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 116#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
120 117
121
122/****************************************************************************** 118/******************************************************************************
123 * 119 *
124 * ACPI Specification constants (Do not change unless the specification changes) 120 * ACPI Specification constants (Do not change unless the specification changes)
@@ -156,15 +152,15 @@
156/* Names within the namespace are 4 bytes long */ 152/* Names within the namespace are 4 bytes long */
157 153
158#define ACPI_NAME_SIZE 4 154#define ACPI_NAME_SIZE 4
159#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ 155#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
160#define ACPI_PATH_SEPARATOR '.' 156#define ACPI_PATH_SEPARATOR '.'
161 157
162/* Constants used in searching for the RSDP in low memory */ 158/* Constants used in searching for the RSDP in low memory */
163 159
164#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ 160#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
165#define ACPI_EBDA_PTR_LENGTH 2 161#define ACPI_EBDA_PTR_LENGTH 2
166#define ACPI_EBDA_WINDOW_SIZE 1024 162#define ACPI_EBDA_WINDOW_SIZE 1024
167#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ 163#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */
168#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 164#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000
169#define ACPI_RSDP_SCAN_STEP 16 165#define ACPI_RSDP_SCAN_STEP 16
170 166
@@ -199,18 +195,15 @@
199 195
200#define ACPI_NUM_OSI_STRINGS 10 196#define ACPI_NUM_OSI_STRINGS 10
201 197
202
203/****************************************************************************** 198/******************************************************************************
204 * 199 *
205 * ACPI AML Debugger 200 * ACPI AML Debugger
206 * 201 *
207 *****************************************************************************/ 202 *****************************************************************************/
208 203
209#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ 204#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */
210 205
211#define ACPI_DEBUGGER_COMMAND_PROMPT '-' 206#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
212#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' 207#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
213 208
214 209#endif /* _ACCONFIG_H */
215#endif /* _ACCONFIG_H */
216
diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h
index 8ba372b0f245..70ce3b4d006e 100644
--- a/include/acpi/acdebug.h
+++ b/include/acpi/acdebug.h
@@ -44,22 +44,17 @@
44#ifndef __ACDEBUG_H__ 44#ifndef __ACDEBUG_H__
45#define __ACDEBUG_H__ 45#define __ACDEBUG_H__
46 46
47
48#define ACPI_DEBUG_BUFFER_SIZE 4196 47#define ACPI_DEBUG_BUFFER_SIZE 4196
49 48
50struct command_info 49struct command_info {
51{ 50 char *name; /* Command Name */
52 char *name; /* Command Name */ 51 u8 min_args; /* Minimum arguments required */
53 u8 min_args; /* Minimum arguments required */
54}; 52};
55 53
56 54struct argument_info {
57struct argument_info 55 char *name; /* Argument Name */
58{
59 char *name; /* Argument Name */
60}; 56};
61 57
62
63#define PARAM_LIST(pl) pl 58#define PARAM_LIST(pl) pl
64#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose) 59#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose)
65#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ 60#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
@@ -68,275 +63,155 @@ struct argument_info
68#define EX_NO_SINGLE_STEP 1 63#define EX_NO_SINGLE_STEP 1
69#define EX_SINGLE_STEP 2 64#define EX_SINGLE_STEP 2
70 65
71
72/* 66/*
73 * dbxface - external debugger interfaces 67 * dbxface - external debugger interfaces
74 */ 68 */
75acpi_status 69acpi_status acpi_db_initialize(void);
76acpi_db_initialize (
77 void);
78 70
79void 71void acpi_db_terminate(void);
80acpi_db_terminate (
81 void);
82 72
83acpi_status 73acpi_status
84acpi_db_single_step ( 74acpi_db_single_step(struct acpi_walk_state *walk_state,
85 struct acpi_walk_state *walk_state, 75 union acpi_parse_object *op, u32 op_type);
86 union acpi_parse_object *op,
87 u32 op_type);
88
89 76
90/* 77/*
91 * dbcmds - debug commands and output routines 78 * dbcmds - debug commands and output routines
92 */ 79 */
93acpi_status 80acpi_status acpi_db_disassemble_method(char *name);
94acpi_db_disassemble_method (
95 char *name);
96 81
97void 82void acpi_db_display_table_info(char *table_arg);
98acpi_db_display_table_info (
99 char *table_arg);
100 83
101void 84void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg);
102acpi_db_unload_acpi_table (
103 char *table_arg,
104 char *instance_arg);
105 85
106void 86void
107acpi_db_set_method_breakpoint ( 87acpi_db_set_method_breakpoint(char *location,
108 char *location, 88 struct acpi_walk_state *walk_state,
109 struct acpi_walk_state *walk_state, 89 union acpi_parse_object *op);
110 union acpi_parse_object *op);
111 90
112void 91void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
113acpi_db_set_method_call_breakpoint (
114 union acpi_parse_object *op);
115 92
116void 93void acpi_db_get_bus_info(void);
117acpi_db_disassemble_aml (
118 char *statements,
119 union acpi_parse_object *op);
120 94
121void 95void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
122acpi_db_dump_namespace (
123 char *start_arg,
124 char *depth_arg);
125 96
126void 97void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
127acpi_db_dump_namespace_by_owner (
128 char *owner_arg,
129 char *depth_arg);
130 98
131void 99void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
132acpi_db_send_notify (
133 char *name,
134 u32 value);
135 100
136void 101void acpi_db_send_notify(char *name, u32 value);
137acpi_db_set_method_data (
138 char *type_arg,
139 char *index_arg,
140 char *value_arg);
141 102
142acpi_status 103void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
143acpi_db_display_objects (
144 char *obj_type_arg,
145 char *display_count_arg);
146 104
147acpi_status 105acpi_status
148acpi_db_find_name_in_namespace ( 106acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
149 char *name_arg);
150 107
151void 108acpi_status acpi_db_find_name_in_namespace(char *name_arg);
152acpi_db_set_scope (
153 char *name);
154 109
155acpi_status 110void acpi_db_set_scope(char *name);
156acpi_db_sleep (
157 char *object_arg);
158 111
159void 112acpi_status acpi_db_sleep(char *object_arg);
160acpi_db_find_references (
161 char *object_arg);
162 113
163void 114void acpi_db_find_references(char *object_arg);
164acpi_db_display_locks (
165 void);
166 115
167void 116void acpi_db_display_locks(void);
168acpi_db_display_resources (
169 char *object_arg);
170 117
171void 118void acpi_db_display_resources(char *object_arg);
172acpi_db_display_gpes (
173 void);
174 119
175void 120void acpi_db_display_gpes(void);
176acpi_db_check_integrity (
177 void);
178 121
179void 122void acpi_db_check_integrity(void);
180acpi_db_generate_gpe (
181 char *gpe_arg,
182 char *block_arg);
183 123
124void acpi_db_generate_gpe(char *gpe_arg, char *block_arg);
184 125
185/* 126/*
186 * dbdisply - debug display commands 127 * dbdisply - debug display commands
187 */ 128 */
188void 129void acpi_db_display_method_info(union acpi_parse_object *op);
189acpi_db_display_method_info (
190 union acpi_parse_object *op);
191 130
192void 131void acpi_db_decode_and_display_object(char *target, char *output_type);
193acpi_db_decode_and_display_object (
194 char *target,
195 char *output_type);
196 132
197void 133void
198acpi_db_display_result_object ( 134acpi_db_display_result_object(union acpi_operand_object *obj_desc,
199 union acpi_operand_object *obj_desc, 135 struct acpi_walk_state *walk_state);
200 struct acpi_walk_state *walk_state);
201 136
202acpi_status 137acpi_status acpi_db_display_all_methods(char *display_count_arg);
203acpi_db_display_all_methods (
204 char *display_count_arg);
205 138
206void 139void acpi_db_display_arguments(void);
207acpi_db_display_arguments (
208 void);
209 140
210void 141void acpi_db_display_locals(void);
211acpi_db_display_locals (
212 void);
213 142
214void 143void acpi_db_display_results(void);
215acpi_db_display_results (
216 void);
217 144
218void 145void acpi_db_display_calling_tree(void);
219acpi_db_display_calling_tree (
220 void);
221 146
222void 147void acpi_db_display_object_type(char *object_arg);
223acpi_db_display_object_type (
224 char *object_arg);
225 148
226void 149void
227acpi_db_display_argument_object ( 150acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
228 union acpi_operand_object *obj_desc, 151 struct acpi_walk_state *walk_state);
229 struct acpi_walk_state *walk_state);
230
231 152
232/* 153/*
233 * dbexec - debugger control method execution 154 * dbexec - debugger control method execution
234 */ 155 */
235void 156void acpi_db_execute(char *name, char **args, u32 flags);
236acpi_db_execute (
237 char *name,
238 char **args,
239 u32 flags);
240 157
241void 158void
242acpi_db_create_execution_threads ( 159acpi_db_create_execution_threads(char *num_threads_arg,
243 char *num_threads_arg, 160 char *num_loops_arg, char *method_name_arg);
244 char *num_loops_arg,
245 char *method_name_arg);
246
247 161
248/* 162/*
249 * dbfileio - Debugger file I/O commands 163 * dbfileio - Debugger file I/O commands
250 */ 164 */
251acpi_object_type 165acpi_object_type
252acpi_db_match_argument ( 166acpi_db_match_argument(char *user_argument, struct argument_info *arguments);
253 char *user_argument,
254 struct argument_info *arguments);
255 167
256void 168void acpi_db_close_debug_file(void);
257acpi_db_close_debug_file (
258 void);
259 169
260void 170void acpi_db_open_debug_file(char *name);
261acpi_db_open_debug_file (
262 char *name);
263 171
264acpi_status 172acpi_status acpi_db_load_acpi_table(char *filename);
265acpi_db_load_acpi_table (
266 char *filename);
267 173
268acpi_status 174acpi_status
269acpi_db_get_table_from_file ( 175acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
270 char *filename,
271 struct acpi_table_header **table);
272 176
273acpi_status 177acpi_status
274acpi_db_read_table_from_file ( 178acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
275 char *filename,
276 struct acpi_table_header **table);
277
278 179
279/* 180/*
280 * dbhistry - debugger HISTORY command 181 * dbhistry - debugger HISTORY command
281 */ 182 */
282void 183void acpi_db_add_to_history(char *command_line);
283acpi_db_add_to_history (
284 char *command_line);
285 184
286void 185void acpi_db_display_history(void);
287acpi_db_display_history (
288 void);
289
290char *
291acpi_db_get_from_history (
292 char *command_num_arg);
293 186
187char *acpi_db_get_from_history(char *command_num_arg);
294 188
295/* 189/*
296 * dbinput - user front-end to the AML debugger 190 * dbinput - user front-end to the AML debugger
297 */ 191 */
298acpi_status 192acpi_status
299acpi_db_command_dispatch ( 193acpi_db_command_dispatch(char *input_buffer,
300 char *input_buffer, 194 struct acpi_walk_state *walk_state,
301 struct acpi_walk_state *walk_state, 195 union acpi_parse_object *op);
302 union acpi_parse_object *op);
303
304void ACPI_SYSTEM_XFACE
305acpi_db_execute_thread (
306 void *context);
307 196
197void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
308 198
309/* 199/*
310 * dbstats - Generation and display of ACPI table statistics 200 * dbstats - Generation and display of ACPI table statistics
311 */ 201 */
312void 202void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method);
313acpi_db_generate_statistics (
314 union acpi_parse_object *root,
315 u8 is_method);
316
317acpi_status
318acpi_db_display_statistics (
319 char *type_arg);
320 203
204acpi_status acpi_db_display_statistics(char *type_arg);
321 205
322/* 206/*
323 * dbutils - AML debugger utilities 207 * dbutils - AML debugger utilities
324 */ 208 */
325void 209void acpi_db_set_output_destination(u32 where);
326acpi_db_set_output_destination (
327 u32 where);
328 210
329void 211void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level);
330acpi_db_dump_object (
331 union acpi_object *obj_desc,
332 u32 level);
333 212
334void 213void acpi_db_prep_namestring(char *name);
335acpi_db_prep_namestring (
336 char *name);
337 214
338struct acpi_namespace_node * 215struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name);
339acpi_db_local_ns_lookup (
340 char *name);
341 216
342#endif /* __ACDEBUG_H__ */ 217#endif /* __ACDEBUG_H__ */
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
index dbfa877121ba..3d96dcb1bb4b 100644
--- a/include/acpi/acdisasm.h
+++ b/include/acpi/acdisasm.h
@@ -46,327 +46,219 @@
46 46
47#include "amlresrc.h" 47#include "amlresrc.h"
48 48
49
50#define BLOCK_NONE 0 49#define BLOCK_NONE 0
51#define BLOCK_PAREN 1 50#define BLOCK_PAREN 1
52#define BLOCK_BRACE 2 51#define BLOCK_BRACE 2
53#define BLOCK_COMMA_LIST 4 52#define BLOCK_COMMA_LIST 4
54 53
55struct acpi_external_list 54struct acpi_external_list {
56{ 55 char *path;
57 char *path; 56 struct acpi_external_list *next;
58 struct acpi_external_list *next;
59}; 57};
60 58
61extern struct acpi_external_list *acpi_gbl_external_list; 59extern struct acpi_external_list *acpi_gbl_external_list;
62extern const char *acpi_gbl_io_decode[2]; 60extern const char *acpi_gbl_io_decode[2];
63extern const char *acpi_gbl_word_decode[4]; 61extern const char *acpi_gbl_word_decode[4];
64extern const char *acpi_gbl_consume_decode[2]; 62extern const char *acpi_gbl_consume_decode[2];
65extern const char *acpi_gbl_min_decode[2]; 63extern const char *acpi_gbl_min_decode[2];
66extern const char *acpi_gbl_max_decode[2]; 64extern const char *acpi_gbl_max_decode[2];
67extern const char *acpi_gbl_DECdecode[2]; 65extern const char *acpi_gbl_DECdecode[2];
68extern const char *acpi_gbl_RNGdecode[4]; 66extern const char *acpi_gbl_RNGdecode[4];
69extern const char *acpi_gbl_MEMdecode[4]; 67extern const char *acpi_gbl_MEMdecode[4];
70extern const char *acpi_gbl_RWdecode[2]; 68extern const char *acpi_gbl_RWdecode[2];
71extern const char *acpi_gbl_irq_decode[2]; 69extern const char *acpi_gbl_irq_decode[2];
72extern const char *acpi_gbl_HEdecode[2]; 70extern const char *acpi_gbl_HEdecode[2];
73extern const char *acpi_gbl_LLdecode[2]; 71extern const char *acpi_gbl_LLdecode[2];
74extern const char *acpi_gbl_SHRdecode[2]; 72extern const char *acpi_gbl_SHRdecode[2];
75extern const char *acpi_gbl_TYPdecode[4]; 73extern const char *acpi_gbl_TYPdecode[4];
76extern const char *acpi_gbl_BMdecode[2]; 74extern const char *acpi_gbl_BMdecode[2];
77extern const char *acpi_gbl_SIZdecode[4]; 75extern const char *acpi_gbl_SIZdecode[4];
78extern const char *acpi_gbl_TTPdecode[2]; 76extern const char *acpi_gbl_TTPdecode[2];
79extern const char *acpi_gbl_MTPdecode[4]; 77extern const char *acpi_gbl_MTPdecode[4];
80extern const char *acpi_gbl_TRSdecode[2]; 78extern const char *acpi_gbl_TRSdecode[2];
81 79
82 80extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES];
83extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES]; 81extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES];
84extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES]; 82extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES];
85extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES]; 83extern const char *acpi_gbl_match_ops[ACPI_NUM_MATCH_OPS];
86extern const char *acpi_gbl_match_ops[ACPI_NUM_MATCH_OPS]; 84
87 85struct acpi_op_walk_info {
88 86 u32 level;
89struct acpi_op_walk_info 87 u32 bit_offset;
90{ 88 struct acpi_walk_state *walk_state;
91 u32 level;
92 u32 bit_offset;
93}; 89};
94 90
95typedef 91typedef
96acpi_status (*asl_walk_callback) ( 92acpi_status(*asl_walk_callback) (union acpi_parse_object * op,
97 union acpi_parse_object *op, 93 u32 level, void *context);
98 u32 level,
99 void *context);
100
101 94
102/* 95/*
103 * dmwalk 96 * dmwalk
104 */ 97 */
105void 98void
106acpi_dm_disassemble ( 99acpi_dm_disassemble(struct acpi_walk_state *walk_state,
107 struct acpi_walk_state *walk_state, 100 union acpi_parse_object *origin, u32 num_opcodes);
108 union acpi_parse_object *origin,
109 u32 num_opcodes);
110
111 101
112/* 102/*
113 * dmopcode 103 * dmopcode
114 */ 104 */
115void 105void
116acpi_dm_disassemble_one_op ( 106acpi_dm_disassemble_one_op(struct acpi_walk_state *walk_state,
117 struct acpi_walk_state *walk_state, 107 struct acpi_op_walk_info *info,
118 struct acpi_op_walk_info *info, 108 union acpi_parse_object *op);
119 union acpi_parse_object *op);
120 109
121void 110void acpi_dm_decode_internal_object(union acpi_operand_object *obj_desc);
122acpi_dm_decode_internal_object (
123 union acpi_operand_object *obj_desc);
124 111
125u32 112u32 acpi_dm_list_type(union acpi_parse_object *op);
126acpi_dm_list_type (
127 union acpi_parse_object *op);
128 113
129void 114void acpi_dm_method_flags(union acpi_parse_object *op);
130acpi_dm_method_flags (
131 union acpi_parse_object *op);
132
133void
134acpi_dm_field_flags (
135 union acpi_parse_object *op);
136 115
137void 116void acpi_dm_field_flags(union acpi_parse_object *op);
138acpi_dm_address_space (
139 u8 space_id);
140 117
141void 118void acpi_dm_address_space(u8 space_id);
142acpi_dm_region_flags (
143 union acpi_parse_object *op);
144 119
145void 120void acpi_dm_region_flags(union acpi_parse_object *op);
146acpi_dm_match_op (
147 union acpi_parse_object *op);
148 121
149u8 122void acpi_dm_match_op(union acpi_parse_object *op);
150acpi_dm_comma_if_list_member (
151 union acpi_parse_object *op);
152 123
153void 124u8 acpi_dm_comma_if_list_member(union acpi_parse_object *op);
154acpi_dm_comma_if_field_member (
155 union acpi_parse_object *op);
156 125
126void acpi_dm_comma_if_field_member(union acpi_parse_object *op);
157 127
158/* 128/*
159 * dmnames 129 * dmnames
160 */ 130 */
161u32 131u32 acpi_dm_dump_name(char *name);
162acpi_dm_dump_name (
163 char *name);
164 132
165acpi_status 133acpi_status
166acpi_ps_display_object_pathname ( 134acpi_ps_display_object_pathname(struct acpi_walk_state *walk_state,
167 struct acpi_walk_state *walk_state, 135 union acpi_parse_object *op);
168 union acpi_parse_object *op);
169
170void
171acpi_dm_namestring (
172 char *name);
173 136
137void acpi_dm_namestring(char *name);
174 138
175/* 139/*
176 * dmobject 140 * dmobject
177 */ 141 */
178void 142void
179acpi_dm_display_internal_object ( 143acpi_dm_display_internal_object(union acpi_operand_object *obj_desc,
180 union acpi_operand_object *obj_desc, 144 struct acpi_walk_state *walk_state);
181 struct acpi_walk_state *walk_state);
182 145
183void 146void acpi_dm_display_arguments(struct acpi_walk_state *walk_state);
184acpi_dm_display_arguments (
185 struct acpi_walk_state *walk_state);
186 147
187void 148void acpi_dm_display_locals(struct acpi_walk_state *walk_state);
188acpi_dm_display_locals (
189 struct acpi_walk_state *walk_state);
190 149
191void 150void
192acpi_dm_dump_method_info ( 151acpi_dm_dump_method_info(acpi_status status,
193 acpi_status status, 152 struct acpi_walk_state *walk_state,
194 struct acpi_walk_state *walk_state, 153 union acpi_parse_object *op);
195 union acpi_parse_object *op);
196
197 154
198/* 155/*
199 * dmbuffer 156 * dmbuffer
200 */ 157 */
201void 158void acpi_dm_disasm_byte_list(u32 level, u8 * byte_data, u32 byte_count);
202acpi_dm_disasm_byte_list (
203 u32 level,
204 u8 *byte_data,
205 u32 byte_count);
206 159
207void 160void
208acpi_dm_byte_list ( 161acpi_dm_byte_list(struct acpi_op_walk_info *info, union acpi_parse_object *op);
209 struct acpi_op_walk_info *info,
210 union acpi_parse_object *op);
211 162
212void 163void acpi_dm_is_eisa_id(union acpi_parse_object *op);
213acpi_is_eisa_id (
214 union acpi_parse_object *op);
215 164
216void 165void acpi_dm_eisa_id(u32 encoded_id);
217acpi_dm_eisa_id (
218 u32 encoded_id);
219
220u8
221acpi_dm_is_unicode_buffer (
222 union acpi_parse_object *op);
223 166
224u8 167u8 acpi_dm_is_unicode_buffer(union acpi_parse_object *op);
225acpi_dm_is_string_buffer (
226 union acpi_parse_object *op);
227 168
169u8 acpi_dm_is_string_buffer(union acpi_parse_object *op);
228 170
229/* 171/*
230 * dmresrc 172 * dmresrc
231 */ 173 */
232void 174void
233acpi_dm_resource_descriptor ( 175acpi_dm_resource_descriptor(struct acpi_op_walk_info *info,
234 struct acpi_op_walk_info *info, 176 u8 * byte_data, u32 byte_count);
235 u8 *byte_data,
236 u32 byte_count);
237 177
238u8 178u8 acpi_dm_is_resource_descriptor(union acpi_parse_object *op);
239acpi_dm_is_resource_descriptor (
240 union acpi_parse_object *op);
241 179
242void 180void acpi_dm_indent(u32 level);
243acpi_dm_indent (
244 u32 level);
245 181
246void 182void acpi_dm_bit_list(u16 mask);
247acpi_dm_bit_list (
248 u16 mask);
249
250void
251acpi_dm_decode_attribute (
252 u8 attribute);
253 183
184void acpi_dm_decode_attribute(u8 attribute);
254 185
255/* 186/*
256 * dmresrcl 187 * dmresrcl
257 */ 188 */
258void 189void
259acpi_dm_word_descriptor ( 190acpi_dm_word_descriptor(struct asl_word_address_desc *resource,
260 struct asl_word_address_desc *resource, 191 u32 length, u32 level);
261 u32 length,
262 u32 level);
263 192
264void 193void
265acpi_dm_dword_descriptor ( 194acpi_dm_dword_descriptor(struct asl_dword_address_desc *resource,
266 struct asl_dword_address_desc *resource, 195 u32 length, u32 level);
267 u32 length,
268 u32 level);
269 196
270void 197void
271acpi_dm_extended_descriptor ( 198acpi_dm_extended_descriptor(struct asl_extended_address_desc *resource,
272 struct asl_extended_address_desc *resource, 199 u32 length, u32 level);
273 u32 length,
274 u32 level);
275 200
276void 201void
277acpi_dm_qword_descriptor ( 202acpi_dm_qword_descriptor(struct asl_qword_address_desc *resource,
278 struct asl_qword_address_desc *resource, 203 u32 length, u32 level);
279 u32 length,
280 u32 level);
281 204
282void 205void
283acpi_dm_memory24_descriptor ( 206acpi_dm_memory24_descriptor(struct asl_memory_24_desc *resource,
284 struct asl_memory_24_desc *resource, 207 u32 length, u32 level);
285 u32 length,
286 u32 level);
287 208
288void 209void
289acpi_dm_memory32_descriptor ( 210acpi_dm_memory32_descriptor(struct asl_memory_32_desc *resource,
290 struct asl_memory_32_desc *resource, 211 u32 length, u32 level);
291 u32 length,
292 u32 level);
293 212
294void 213void
295acpi_dm_fixed_mem32_descriptor ( 214acpi_dm_fixed_mem32_descriptor(struct asl_fixed_memory_32_desc *resource,
296 struct asl_fixed_memory_32_desc *resource, 215 u32 length, u32 level);
297 u32 length,
298 u32 level);
299 216
300void 217void
301acpi_dm_generic_register_descriptor ( 218acpi_dm_generic_register_descriptor(struct asl_general_register_desc *resource,
302 struct asl_general_register_desc *resource, 219 u32 length, u32 level);
303 u32 length,
304 u32 level);
305 220
306void 221void
307acpi_dm_interrupt_descriptor ( 222acpi_dm_interrupt_descriptor(struct asl_extended_xrupt_desc *resource,
308 struct asl_extended_xrupt_desc *resource, 223 u32 length, u32 level);
309 u32 length,
310 u32 level);
311 224
312void 225void
313acpi_dm_vendor_large_descriptor ( 226acpi_dm_vendor_large_descriptor(struct asl_large_vendor_desc *resource,
314 struct asl_large_vendor_desc *resource, 227 u32 length, u32 level);
315 u32 length,
316 u32 level);
317
318 228
319/* 229/*
320 * dmresrcs 230 * dmresrcs
321 */ 231 */
322void 232void
323acpi_dm_irq_descriptor ( 233acpi_dm_irq_descriptor(struct asl_irq_format_desc *resource,
324 struct asl_irq_format_desc *resource, 234 u32 length, u32 level);
325 u32 length,
326 u32 level);
327 235
328void 236void
329acpi_dm_dma_descriptor ( 237acpi_dm_dma_descriptor(struct asl_dma_format_desc *resource,
330 struct asl_dma_format_desc *resource, 238 u32 length, u32 level);
331 u32 length,
332 u32 level);
333 239
334void 240void
335acpi_dm_io_descriptor ( 241acpi_dm_io_descriptor(struct asl_io_port_desc *resource, u32 length, u32 level);
336 struct asl_io_port_desc *resource,
337 u32 length,
338 u32 level);
339 242
340void 243void
341acpi_dm_fixed_io_descriptor ( 244acpi_dm_fixed_io_descriptor(struct asl_fixed_io_port_desc *resource,
342 struct asl_fixed_io_port_desc *resource, 245 u32 length, u32 level);
343 u32 length,
344 u32 level);
345 246
346void 247void
347acpi_dm_start_dependent_descriptor ( 248acpi_dm_start_dependent_descriptor(struct asl_start_dependent_desc *resource,
348 struct asl_start_dependent_desc *resource, 249 u32 length, u32 level);
349 u32 length,
350 u32 level);
351 250
352void 251void
353acpi_dm_end_dependent_descriptor ( 252acpi_dm_end_dependent_descriptor(struct asl_start_dependent_desc *resource,
354 struct asl_start_dependent_desc *resource, 253 u32 length, u32 level);
355 u32 length,
356 u32 level);
357 254
358void 255void
359acpi_dm_vendor_small_descriptor ( 256acpi_dm_vendor_small_descriptor(struct asl_small_vendor_desc *resource,
360 struct asl_small_vendor_desc *resource, 257 u32 length, u32 level);
361 u32 length,
362 u32 level);
363
364 258
365/* 259/*
366 * dmutils 260 * dmutils
367 */ 261 */
368void 262void acpi_dm_add_to_external_list(char *path);
369acpi_dm_add_to_external_list (
370 char *path);
371 263
372#endif /* __ACDISASM_H__ */ 264#endif /* __ACDISASM_H__ */
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 8f5f2f71b1de..065f24a77cfc 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -41,419 +41,304 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#ifndef _ACDISPAT_H_ 44#ifndef _ACDISPAT_H_
46#define _ACDISPAT_H_ 45#define _ACDISPAT_H_
47 46
48
49#define NAMEOF_LOCAL_NTE "__L0" 47#define NAMEOF_LOCAL_NTE "__L0"
50#define NAMEOF_ARG_NTE "__A0" 48#define NAMEOF_ARG_NTE "__A0"
51 49
52
53/* 50/*
54 * dsopcode - support for late evaluation 51 * dsopcode - support for late evaluation
55 */ 52 */
56acpi_status 53acpi_status
57acpi_ds_get_buffer_field_arguments ( 54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
58 union acpi_operand_object *obj_desc);
59
60acpi_status
61acpi_ds_get_region_arguments (
62 union acpi_operand_object *rgn_desc);
63 55
64acpi_status 56acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc);
65acpi_ds_get_buffer_arguments (
66 union acpi_operand_object *obj_desc);
67 57
68acpi_status 58acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
69acpi_ds_get_package_arguments (
70 union acpi_operand_object *obj_desc);
71 59
72acpi_status 60acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
73acpi_ds_eval_buffer_field_operands (
74 struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op);
76 61
77acpi_status 62acpi_status
78acpi_ds_eval_region_operands ( 63acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
79 struct acpi_walk_state *walk_state, 64 union acpi_parse_object *op);
80 union acpi_parse_object *op);
81 65
82acpi_status 66acpi_status
83acpi_ds_eval_data_object_operands ( 67acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
84 struct acpi_walk_state *walk_state, 68 union acpi_parse_object *op);
85 union acpi_parse_object *op,
86 union acpi_operand_object *obj_desc);
87 69
88acpi_status 70acpi_status
89acpi_ds_initialize_region ( 71acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
90 acpi_handle obj_handle); 72 union acpi_parse_object *op,
73 union acpi_operand_object *obj_desc);
91 74
75acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
92 76
93/* 77/*
94 * dsctrl - Parser/Interpreter interface, control stack routines 78 * dsctrl - Parser/Interpreter interface, control stack routines
95 */ 79 */
96acpi_status 80acpi_status
97acpi_ds_exec_begin_control_op ( 81acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
98 struct acpi_walk_state *walk_state, 82 union acpi_parse_object *op);
99 union acpi_parse_object *op);
100 83
101acpi_status 84acpi_status
102acpi_ds_exec_end_control_op ( 85acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
103 struct acpi_walk_state *walk_state, 86 union acpi_parse_object *op);
104 union acpi_parse_object *op);
105
106 87
107/* 88/*
108 * dsexec - Parser/Interpreter interface, method execution callbacks 89 * dsexec - Parser/Interpreter interface, method execution callbacks
109 */ 90 */
110acpi_status 91acpi_status
111acpi_ds_get_predicate_value ( 92acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
112 struct acpi_walk_state *walk_state, 93 union acpi_operand_object *result_obj);
113 union acpi_operand_object *result_obj);
114
115acpi_status
116acpi_ds_exec_begin_op (
117 struct acpi_walk_state *walk_state,
118 union acpi_parse_object **out_op);
119 94
120acpi_status 95acpi_status
121acpi_ds_exec_end_op ( 96acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
122 struct acpi_walk_state *state); 97 union acpi_parse_object **out_op);
123 98
99acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *state);
124 100
125/* 101/*
126 * dsfield - Parser/Interpreter interface for AML fields 102 * dsfield - Parser/Interpreter interface for AML fields
127 */ 103 */
128acpi_status 104acpi_status
129acpi_ds_create_field ( 105acpi_ds_create_field(union acpi_parse_object *op,
130 union acpi_parse_object *op, 106 struct acpi_namespace_node *region_node,
131 struct acpi_namespace_node *region_node, 107 struct acpi_walk_state *walk_state);
132 struct acpi_walk_state *walk_state);
133 108
134acpi_status 109acpi_status
135acpi_ds_create_bank_field ( 110acpi_ds_create_bank_field(union acpi_parse_object *op,
136 union acpi_parse_object *op, 111 struct acpi_namespace_node *region_node,
137 struct acpi_namespace_node *region_node, 112 struct acpi_walk_state *walk_state);
138 struct acpi_walk_state *walk_state);
139 113
140acpi_status 114acpi_status
141acpi_ds_create_index_field ( 115acpi_ds_create_index_field(union acpi_parse_object *op,
142 union acpi_parse_object *op, 116 struct acpi_namespace_node *region_node,
143 struct acpi_namespace_node *region_node, 117 struct acpi_walk_state *walk_state);
144 struct acpi_walk_state *walk_state);
145 118
146acpi_status 119acpi_status
147acpi_ds_create_buffer_field ( 120acpi_ds_create_buffer_field(union acpi_parse_object *op,
148 union acpi_parse_object *op, 121 struct acpi_walk_state *walk_state);
149 struct acpi_walk_state *walk_state);
150 122
151acpi_status 123acpi_status
152acpi_ds_init_field_objects ( 124acpi_ds_init_field_objects(union acpi_parse_object *op,
153 union acpi_parse_object *op, 125 struct acpi_walk_state *walk_state);
154 struct acpi_walk_state *walk_state);
155
156 126
157/* 127/*
158 * dsload - Parser/Interpreter interface, namespace load callbacks 128 * dsload - Parser/Interpreter interface, namespace load callbacks
159 */ 129 */
160acpi_status 130acpi_status
161acpi_ds_load1_begin_op ( 131acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
162 struct acpi_walk_state *walk_state, 132 union acpi_parse_object **out_op);
163 union acpi_parse_object **out_op);
164 133
165acpi_status 134acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
166acpi_ds_load1_end_op (
167 struct acpi_walk_state *walk_state);
168 135
169acpi_status 136acpi_status
170acpi_ds_load2_begin_op ( 137acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
171 struct acpi_walk_state *walk_state, 138 union acpi_parse_object **out_op);
172 union acpi_parse_object **out_op);
173 139
174acpi_status 140acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state);
175acpi_ds_load2_end_op (
176 struct acpi_walk_state *walk_state);
177 141
178acpi_status 142acpi_status
179acpi_ds_init_callbacks ( 143acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
180 struct acpi_walk_state *walk_state,
181 u32 pass_number);
182
183 144
184/* 145/*
185 * dsmthdat - method data (locals/args) 146 * dsmthdat - method data (locals/args)
186 */ 147 */
187acpi_status 148acpi_status
188acpi_ds_store_object_to_local ( 149acpi_ds_store_object_to_local(u16 opcode,
189 u16 opcode, 150 u32 index,
190 u32 index, 151 union acpi_operand_object *src_desc,
191 union acpi_operand_object *src_desc, 152 struct acpi_walk_state *walk_state);
192 struct acpi_walk_state *walk_state);
193 153
194acpi_status 154acpi_status
195acpi_ds_method_data_get_entry ( 155acpi_ds_method_data_get_entry(u16 opcode,
196 u16 opcode, 156 u32 index,
197 u32 index, 157 struct acpi_walk_state *walk_state,
198 struct acpi_walk_state *walk_state, 158 union acpi_operand_object ***node);
199 union acpi_operand_object ***node);
200 159
201void 160void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state);
202acpi_ds_method_data_delete_all (
203 struct acpi_walk_state *walk_state);
204 161
205u8 162u8 acpi_ds_is_method_value(union acpi_operand_object *obj_desc);
206acpi_ds_is_method_value (
207 union acpi_operand_object *obj_desc);
208 163
209acpi_status 164acpi_status
210acpi_ds_method_data_get_value ( 165acpi_ds_method_data_get_value(u16 opcode,
211 u16 opcode, 166 u32 index,
212 u32 index, 167 struct acpi_walk_state *walk_state,
213 struct acpi_walk_state *walk_state, 168 union acpi_operand_object **dest_desc);
214 union acpi_operand_object **dest_desc);
215 169
216acpi_status 170acpi_status
217acpi_ds_method_data_init_args ( 171acpi_ds_method_data_init_args(union acpi_operand_object **params,
218 union acpi_operand_object **params, 172 u32 max_param_count,
219 u32 max_param_count, 173 struct acpi_walk_state *walk_state);
220 struct acpi_walk_state *walk_state);
221 174
222acpi_status 175acpi_status
223acpi_ds_method_data_get_node ( 176acpi_ds_method_data_get_node(u16 opcode,
224 u16 opcode, 177 u32 index,
225 u32 index, 178 struct acpi_walk_state *walk_state,
226 struct acpi_walk_state *walk_state, 179 struct acpi_namespace_node **node);
227 struct acpi_namespace_node **node);
228
229void
230acpi_ds_method_data_init (
231 struct acpi_walk_state *walk_state);
232 180
181void acpi_ds_method_data_init(struct acpi_walk_state *walk_state);
233 182
234/* 183/*
235 * dsmethod - Parser/Interpreter interface - control method parsing 184 * dsmethod - Parser/Interpreter interface - control method parsing
236 */ 185 */
237acpi_status 186acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node);
238acpi_ds_parse_method (
239 acpi_handle obj_handle);
240 187
241acpi_status 188acpi_status
242acpi_ds_call_control_method ( 189acpi_ds_call_control_method(struct acpi_thread_state *thread,
243 struct acpi_thread_state *thread, 190 struct acpi_walk_state *walk_state,
244 struct acpi_walk_state *walk_state, 191 union acpi_parse_object *op);
245 union acpi_parse_object *op);
246 192
247acpi_status 193acpi_status
248acpi_ds_restart_control_method ( 194acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
249 struct acpi_walk_state *walk_state, 195 union acpi_operand_object *return_desc);
250 union acpi_operand_object *return_desc);
251 196
252acpi_status 197void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state);
253acpi_ds_terminate_control_method (
254 struct acpi_walk_state *walk_state);
255 198
256acpi_status 199acpi_status
257acpi_ds_begin_method_execution ( 200acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
258 struct acpi_namespace_node *method_node, 201 union acpi_operand_object *obj_desc,
259 union acpi_operand_object *obj_desc, 202 struct acpi_namespace_node *calling_method_node);
260 struct acpi_namespace_node *calling_method_node);
261
262 203
263/* 204/*
264 * dsinit 205 * dsinit
265 */ 206 */
266acpi_status 207acpi_status
267acpi_ds_initialize_objects ( 208acpi_ds_initialize_objects(struct acpi_table_desc *table_desc,
268 struct acpi_table_desc *table_desc, 209 struct acpi_namespace_node *start_node);
269 struct acpi_namespace_node *start_node);
270
271 210
272/* 211/*
273 * dsobject - Parser/Interpreter interface - object initialization and conversion 212 * dsobject - Parser/Interpreter interface - object initialization and conversion
274 */ 213 */
275acpi_status 214acpi_status
276acpi_ds_build_internal_buffer_obj ( 215acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
277 struct acpi_walk_state *walk_state, 216 union acpi_parse_object *op,
278 union acpi_parse_object *op, 217 u32 buffer_length,
279 u32 buffer_length, 218 union acpi_operand_object **obj_desc_ptr);
280 union acpi_operand_object **obj_desc_ptr);
281 219
282acpi_status 220acpi_status
283acpi_ds_build_internal_package_obj ( 221acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
284 struct acpi_walk_state *walk_state, 222 union acpi_parse_object *op,
285 union acpi_parse_object *op, 223 u32 package_length,
286 u32 package_length, 224 union acpi_operand_object **obj_desc);
287 union acpi_operand_object **obj_desc);
288 225
289acpi_status 226acpi_status
290acpi_ds_init_object_from_op ( 227acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
291 struct acpi_walk_state *walk_state, 228 union acpi_parse_object *op,
292 union acpi_parse_object *op, 229 u16 opcode, union acpi_operand_object **obj_desc);
293 u16 opcode,
294 union acpi_operand_object **obj_desc);
295 230
296acpi_status 231acpi_status
297acpi_ds_create_node ( 232acpi_ds_create_node(struct acpi_walk_state *walk_state,
298 struct acpi_walk_state *walk_state, 233 struct acpi_namespace_node *node,
299 struct acpi_namespace_node *node, 234 union acpi_parse_object *op);
300 union acpi_parse_object *op);
301
302 235
303/* 236/*
304 * dsutils - Parser/Interpreter interface utility routines 237 * dsutils - Parser/Interpreter interface utility routines
305 */ 238 */
306void 239void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state);
307acpi_ds_clear_implicit_return (
308 struct acpi_walk_state *walk_state);
309 240
310u8 241u8
311acpi_ds_do_implicit_return ( 242acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
312 union acpi_operand_object *return_desc, 243 struct acpi_walk_state *walk_state,
313 struct acpi_walk_state *walk_state, 244 u8 add_reference);
314 u8 add_reference);
315 245
316u8 246u8
317acpi_ds_is_result_used ( 247acpi_ds_is_result_used(union acpi_parse_object *op,
318 union acpi_parse_object *op, 248 struct acpi_walk_state *walk_state);
319 struct acpi_walk_state *walk_state);
320 249
321void 250void
322acpi_ds_delete_result_if_not_used ( 251acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
323 union acpi_parse_object *op, 252 union acpi_operand_object *result_obj,
324 union acpi_operand_object *result_obj, 253 struct acpi_walk_state *walk_state);
325 struct acpi_walk_state *walk_state);
326 254
327acpi_status 255acpi_status
328acpi_ds_create_operand ( 256acpi_ds_create_operand(struct acpi_walk_state *walk_state,
329 struct acpi_walk_state *walk_state, 257 union acpi_parse_object *arg, u32 args_remaining);
330 union acpi_parse_object *arg,
331 u32 args_remaining);
332 258
333acpi_status 259acpi_status
334acpi_ds_create_operands ( 260acpi_ds_create_operands(struct acpi_walk_state *walk_state,
335 struct acpi_walk_state *walk_state, 261 union acpi_parse_object *first_arg);
336 union acpi_parse_object *first_arg);
337 262
338acpi_status 263acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state);
339acpi_ds_resolve_operands (
340 struct acpi_walk_state *walk_state);
341
342void
343acpi_ds_clear_operands (
344 struct acpi_walk_state *walk_state);
345 264
265void acpi_ds_clear_operands(struct acpi_walk_state *walk_state);
346 266
347/* 267/*
348 * dswscope - Scope Stack manipulation 268 * dswscope - Scope Stack manipulation
349 */ 269 */
350acpi_status 270acpi_status
351acpi_ds_scope_stack_push ( 271acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
352 struct acpi_namespace_node *node, 272 acpi_object_type type,
353 acpi_object_type type, 273 struct acpi_walk_state *walk_state);
354 struct acpi_walk_state *walk_state);
355 274
275acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state);
356 276
357acpi_status 277void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state);
358acpi_ds_scope_stack_pop (
359 struct acpi_walk_state *walk_state);
360
361void
362acpi_ds_scope_stack_clear (
363 struct acpi_walk_state *walk_state);
364
365 278
366/* 279/*
367 * dswstate - parser WALK_STATE management routines 280 * dswstate - parser WALK_STATE management routines
368 */ 281 */
369acpi_status 282acpi_status
370acpi_ds_obj_stack_push ( 283acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state);
371 void *object,
372 struct acpi_walk_state *walk_state);
373 284
374acpi_status 285acpi_status
375acpi_ds_obj_stack_pop ( 286acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state);
376 u32 pop_count,
377 struct acpi_walk_state *walk_state);
378 287
379struct acpi_walk_state * 288struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
380acpi_ds_create_walk_state ( 289 union acpi_parse_object
381 acpi_owner_id owner_id, 290 *origin,
382 union acpi_parse_object *origin, 291 union acpi_operand_object
383 union acpi_operand_object *mth_desc, 292 *mth_desc,
384 struct acpi_thread_state *thread); 293 struct acpi_thread_state
294 *thread);
385 295
386acpi_status 296acpi_status
387acpi_ds_init_aml_walk ( 297acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
388 struct acpi_walk_state *walk_state, 298 union acpi_parse_object *op,
389 union acpi_parse_object *op, 299 struct acpi_namespace_node *method_node,
390 struct acpi_namespace_node *method_node, 300 u8 * aml_start,
391 u8 *aml_start, 301 u32 aml_length,
392 u32 aml_length, 302 struct acpi_parameter_info *info, u8 pass_number);
393 struct acpi_parameter_info *info,
394 u32 pass_number);
395 303
396acpi_status 304acpi_status
397acpi_ds_obj_stack_pop_and_delete ( 305acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
398 u32 pop_count, 306 struct acpi_walk_state *walk_state);
399 struct acpi_walk_state *walk_state);
400 307
401void 308void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state);
402acpi_ds_delete_walk_state (
403 struct acpi_walk_state *walk_state);
404 309
405struct acpi_walk_state * 310struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state
406acpi_ds_pop_walk_state ( 311 *thread);
407 struct acpi_thread_state *thread);
408 312
409void 313void
410acpi_ds_push_walk_state ( 314acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
411 struct acpi_walk_state *walk_state, 315 struct acpi_thread_state *thread);
412 struct acpi_thread_state *thread);
413 316
414acpi_status 317acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state);
415acpi_ds_result_stack_pop (
416 struct acpi_walk_state *walk_state);
417 318
418acpi_status 319acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *walk_state);
419acpi_ds_result_stack_push (
420 struct acpi_walk_state *walk_state);
421 320
422acpi_status 321acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state);
423acpi_ds_result_stack_clear (
424 struct acpi_walk_state *walk_state);
425 322
426struct acpi_walk_state * 323struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
427acpi_ds_get_current_walk_state ( 324 *thread);
428 struct acpi_thread_state *thread);
429 325
430#ifdef ACPI_FUTURE_USAGE 326#ifdef ACPI_FUTURE_USAGE
431acpi_status 327acpi_status
432acpi_ds_result_remove ( 328acpi_ds_result_remove(union acpi_operand_object **object,
433 union acpi_operand_object **object, 329 u32 index, struct acpi_walk_state *walk_state);
434 u32 index,
435 struct acpi_walk_state *walk_state);
436#endif 330#endif
437 331
438acpi_status 332acpi_status
439acpi_ds_result_pop ( 333acpi_ds_result_pop(union acpi_operand_object **object,
440 union acpi_operand_object **object, 334 struct acpi_walk_state *walk_state);
441 struct acpi_walk_state *walk_state);
442 335
443acpi_status 336acpi_status
444acpi_ds_result_push ( 337acpi_ds_result_push(union acpi_operand_object *object,
445 union acpi_operand_object *object, 338 struct acpi_walk_state *walk_state);
446 struct acpi_walk_state *walk_state);
447 339
448acpi_status 340acpi_status
449acpi_ds_result_pop_from_bottom ( 341acpi_ds_result_pop_from_bottom(union acpi_operand_object **object,
450 union acpi_operand_object **object, 342 struct acpi_walk_state *walk_state);
451 struct acpi_walk_state *walk_state);
452
453#ifdef ACPI_ENABLE_OBJECT_CACHE
454void
455acpi_ds_delete_walk_state_cache (
456 void);
457#endif
458 343
459#endif /* _ACDISPAT_H_ */ 344#endif /* _ACDISPAT_H_ */
diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h
index 61a27c8c5079..bfa54600ecd9 100644
--- a/include/acpi/acevents.h
+++ b/include/acpi/acevents.h
@@ -44,250 +44,167 @@
44#ifndef __ACEVENTS_H__ 44#ifndef __ACEVENTS_H__
45#define __ACEVENTS_H__ 45#define __ACEVENTS_H__
46 46
47
48/* 47/*
49 * evevent 48 * evevent
50 */ 49 */
51acpi_status 50acpi_status acpi_ev_initialize_events(void);
52acpi_ev_initialize_events (
53 void);
54 51
55acpi_status 52acpi_status acpi_ev_install_xrupt_handlers(void);
56acpi_ev_install_xrupt_handlers (
57 void);
58
59u32
60acpi_ev_fixed_event_detect (
61 void);
62 53
54u32 acpi_ev_fixed_event_detect(void);
63 55
64/* 56/*
65 * evmisc 57 * evmisc
66 */ 58 */
67u8 59u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node);
68acpi_ev_is_notify_object (
69 struct acpi_namespace_node *node);
70 60
71acpi_status 61acpi_status acpi_ev_acquire_global_lock(u16 timeout);
72acpi_ev_acquire_global_lock(
73 u16 timeout);
74 62
75acpi_status 63acpi_status acpi_ev_release_global_lock(void);
76acpi_ev_release_global_lock(
77 void);
78 64
79acpi_status 65acpi_status acpi_ev_init_global_lock_handler(void);
80acpi_ev_init_global_lock_handler (
81 void);
82 66
83u32 67u32 acpi_ev_get_gpe_number_index(u32 gpe_number);
84acpi_ev_get_gpe_number_index (
85 u32 gpe_number);
86 68
87acpi_status 69acpi_status
88acpi_ev_queue_notify_request ( 70acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
89 struct acpi_namespace_node *node, 71 u32 notify_value);
90 u32 notify_value);
91
92 72
93/* 73/*
94 * evgpe - GPE handling and dispatch 74 * evgpe - GPE handling and dispatch
95 */ 75 */
96acpi_status 76acpi_status
97acpi_ev_update_gpe_enable_masks ( 77acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
98 struct acpi_gpe_event_info *gpe_event_info, 78 u8 type);
99 u8 type);
100 79
101acpi_status 80acpi_status
102acpi_ev_enable_gpe ( 81acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
103 struct acpi_gpe_event_info *gpe_event_info, 82 u8 write_to_hardware);
104 u8 write_to_hardware);
105 83
106acpi_status 84acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
107acpi_ev_disable_gpe (
108 struct acpi_gpe_event_info *gpe_event_info);
109
110struct acpi_gpe_event_info *
111acpi_ev_get_gpe_event_info (
112 acpi_handle gpe_device,
113 u32 gpe_number);
114 85
86struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
87 u32 gpe_number);
115 88
116/* 89/*
117 * evgpeblk 90 * evgpeblk
118 */ 91 */
119u8 92u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info);
120acpi_ev_valid_gpe_event (
121 struct acpi_gpe_event_info *gpe_event_info);
122
123acpi_status
124acpi_ev_walk_gpe_list (
125 ACPI_GPE_CALLBACK gpe_walk_callback,
126 u32 flags);
127 93
128acpi_status 94acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback);
129acpi_ev_delete_gpe_handlers (
130 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
131 struct acpi_gpe_block_info *gpe_block);
132 95
133acpi_status 96acpi_status
134acpi_ev_create_gpe_block ( 97acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
135 struct acpi_namespace_node *gpe_device, 98 struct acpi_gpe_block_info *gpe_block);
136 struct acpi_generic_address *gpe_block_address,
137 u32 register_count,
138 u8 gpe_block_base_number,
139 u32 interrupt_level,
140 struct acpi_gpe_block_info **return_gpe_block);
141 99
142acpi_status 100acpi_status
143acpi_ev_delete_gpe_block ( 101acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
144 struct acpi_gpe_block_info *gpe_block); 102 struct acpi_generic_address *gpe_block_address,
103 u32 register_count,
104 u8 gpe_block_base_number,
105 u32 interrupt_number,
106 struct acpi_gpe_block_info **return_gpe_block);
145 107
146u32 108acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
147acpi_ev_gpe_dispatch (
148 struct acpi_gpe_event_info *gpe_event_info,
149 u32 gpe_number);
150 109
151u32 110u32
152acpi_ev_gpe_detect ( 111acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info,
153 struct acpi_gpe_xrupt_info *gpe_xrupt_list); 112 u32 gpe_number);
154 113
155acpi_status 114u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
156acpi_ev_set_gpe_type (
157 struct acpi_gpe_event_info *gpe_event_info,
158 u8 type);
159 115
160acpi_status 116acpi_status
161acpi_ev_check_for_wake_only_gpe ( 117acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type);
162 struct acpi_gpe_event_info *gpe_event_info);
163 118
164acpi_status 119acpi_status
165acpi_ev_gpe_initialize ( 120acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info);
166 void);
167 121
122acpi_status acpi_ev_gpe_initialize(void);
168 123
169/* 124/*
170 * evregion - Address Space handling 125 * evregion - Address Space handling
171 */ 126 */
172acpi_status 127acpi_status acpi_ev_install_region_handlers(void);
173acpi_ev_install_region_handlers (
174 void);
175 128
176acpi_status 129acpi_status acpi_ev_initialize_op_regions(void);
177acpi_ev_initialize_op_regions (
178 void);
179 130
180acpi_status 131acpi_status
181acpi_ev_address_space_dispatch ( 132acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
182 union acpi_operand_object *region_obj, 133 u32 function,
183 u32 function, 134 acpi_physical_address address,
184 acpi_physical_address address, 135 u32 bit_width, void *value);
185 u32 bit_width,
186 void *value);
187 136
188acpi_status 137acpi_status
189acpi_ev_attach_region ( 138acpi_ev_attach_region(union acpi_operand_object *handler_obj,
190 union acpi_operand_object *handler_obj, 139 union acpi_operand_object *region_obj,
191 union acpi_operand_object *region_obj, 140 u8 acpi_ns_is_locked);
192 u8 acpi_ns_is_locked);
193 141
194void 142void
195acpi_ev_detach_region ( 143acpi_ev_detach_region(union acpi_operand_object *region_obj,
196 union acpi_operand_object *region_obj, 144 u8 acpi_ns_is_locked);
197 u8 acpi_ns_is_locked);
198 145
199acpi_status 146acpi_status
200acpi_ev_install_space_handler ( 147acpi_ev_install_space_handler(struct acpi_namespace_node *node,
201 struct acpi_namespace_node *node, 148 acpi_adr_space_type space_id,
202 acpi_adr_space_type space_id, 149 acpi_adr_space_handler handler,
203 acpi_adr_space_handler handler, 150 acpi_adr_space_setup setup, void *context);
204 acpi_adr_space_setup setup,
205 void *context);
206 151
207acpi_status 152acpi_status
208acpi_ev_execute_reg_methods ( 153acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
209 struct acpi_namespace_node *node, 154 acpi_adr_space_type space_id);
210 acpi_adr_space_type space_id);
211 155
212acpi_status 156acpi_status
213acpi_ev_execute_reg_method ( 157acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function);
214 union acpi_operand_object *region_obj,
215 u32 function);
216
217 158
218/* 159/*
219 * evregini - Region initialization and setup 160 * evregini - Region initialization and setup
220 */ 161 */
221acpi_status 162acpi_status
222acpi_ev_system_memory_region_setup ( 163acpi_ev_system_memory_region_setup(acpi_handle handle,
223 acpi_handle handle, 164 u32 function,
224 u32 function, 165 void *handler_context,
225 void *handler_context, 166 void **region_context);
226 void **region_context);
227 167
228acpi_status 168acpi_status
229acpi_ev_io_space_region_setup ( 169acpi_ev_io_space_region_setup(acpi_handle handle,
230 acpi_handle handle, 170 u32 function,
231 u32 function, 171 void *handler_context, void **region_context);
232 void *handler_context,
233 void **region_context);
234 172
235acpi_status 173acpi_status
236acpi_ev_pci_config_region_setup ( 174acpi_ev_pci_config_region_setup(acpi_handle handle,
237 acpi_handle handle, 175 u32 function,
238 u32 function, 176 void *handler_context, void **region_context);
239 void *handler_context,
240 void **region_context);
241 177
242acpi_status 178acpi_status
243acpi_ev_cmos_region_setup ( 179acpi_ev_cmos_region_setup(acpi_handle handle,
244 acpi_handle handle, 180 u32 function,
245 u32 function, 181 void *handler_context, void **region_context);
246 void *handler_context,
247 void **region_context);
248 182
249acpi_status 183acpi_status
250acpi_ev_pci_bar_region_setup ( 184acpi_ev_pci_bar_region_setup(acpi_handle handle,
251 acpi_handle handle, 185 u32 function,
252 u32 function, 186 void *handler_context, void **region_context);
253 void *handler_context,
254 void **region_context);
255 187
256acpi_status 188acpi_status
257acpi_ev_default_region_setup ( 189acpi_ev_default_region_setup(acpi_handle handle,
258 acpi_handle handle, 190 u32 function,
259 u32 function, 191 void *handler_context, void **region_context);
260 void *handler_context,
261 void **region_context);
262 192
263acpi_status 193acpi_status
264acpi_ev_initialize_region ( 194acpi_ev_initialize_region(union acpi_operand_object *region_obj,
265 union acpi_operand_object *region_obj, 195 u8 acpi_ns_locked);
266 u8 acpi_ns_locked);
267
268 196
269/* 197/*
270 * evsci - SCI (System Control Interrupt) handling/dispatch 198 * evsci - SCI (System Control Interrupt) handling/dispatch
271 */ 199 */
272u32 ACPI_SYSTEM_XFACE 200u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context);
273acpi_ev_gpe_xrupt_handler (
274 void *context);
275
276u32
277acpi_ev_install_sci_handler (
278 void);
279 201
280acpi_status 202u32 acpi_ev_install_sci_handler(void);
281acpi_ev_remove_sci_handler (
282 void);
283 203
284u32 204acpi_status acpi_ev_remove_sci_handler(void);
285acpi_ev_initialize_sCI (
286 u32 program_sCI);
287 205
288void 206u32 acpi_ev_initialize_sCI(u32 program_sCI);
289acpi_ev_terminate (
290 void);
291 207
208void acpi_ev_terminate(void);
292 209
293#endif /* __ACEVENTS_H__ */ 210#endif /* __ACEVENTS_H__ */
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 60d737b2d70f..4f005eb65928 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -44,7 +44,6 @@
44#ifndef __ACEXCEP_H__ 44#ifndef __ACEXCEP_H__
45#define __ACEXCEP_H__ 45#define __ACEXCEP_H__
46 46
47
48/* 47/*
49 * Exceptions returned by external ACPI interfaces 48 * Exceptions returned by external ACPI interfaces
50 */ 49 */
@@ -55,11 +54,9 @@
55#define AE_CODE_CONTROL 0x4000 54#define AE_CODE_CONTROL 0x4000
56#define AE_CODE_MASK 0xF000 55#define AE_CODE_MASK 0xF000
57 56
58
59#define ACPI_SUCCESS(a) (!(a)) 57#define ACPI_SUCCESS(a) (!(a))
60#define ACPI_FAILURE(a) (a) 58#define ACPI_FAILURE(a) (a)
61 59
62
63#define AE_OK (acpi_status) 0x0000 60#define AE_OK (acpi_status) 0x0000
64 61
65/* 62/*
@@ -95,9 +92,9 @@
95#define AE_ABORT_METHOD (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL) 92#define AE_ABORT_METHOD (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL)
96#define AE_SAME_HANDLER (acpi_status) (0x001D | AE_CODE_ENVIRONMENTAL) 93#define AE_SAME_HANDLER (acpi_status) (0x001D | AE_CODE_ENVIRONMENTAL)
97#define AE_WAKE_ONLY_GPE (acpi_status) (0x001E | AE_CODE_ENVIRONMENTAL) 94#define AE_WAKE_ONLY_GPE (acpi_status) (0x001E | AE_CODE_ENVIRONMENTAL)
95#define AE_OWNER_ID_LIMIT (acpi_status) (0x001F | AE_CODE_ENVIRONMENTAL)
98 96
99#define AE_CODE_ENV_MAX 0x001E 97#define AE_CODE_ENV_MAX 0x001F
100
101 98
102/* 99/*
103 * Programmer exceptions 100 * Programmer exceptions
@@ -114,7 +111,6 @@
114 111
115#define AE_CODE_PGM_MAX 0x0009 112#define AE_CODE_PGM_MAX 0x0009
116 113
117
118/* 114/*
119 * Acpi table exceptions 115 * Acpi table exceptions
120 */ 116 */
@@ -127,7 +123,6 @@
127 123
128#define AE_CODE_TBL_MAX 0x0006 124#define AE_CODE_TBL_MAX 0x0006
129 125
130
131/* 126/*
132 * AML exceptions. These are caused by problems with 127 * AML exceptions. These are caused by problems with
133 * the actual AML byte stream 128 * the actual AML byte stream
@@ -168,7 +163,6 @@
168 163
169#define AE_CODE_AML_MAX 0x0021 164#define AE_CODE_AML_MAX 0x0021
170 165
171
172/* 166/*
173 * Internal exceptions used for control 167 * Internal exceptions used for control
174 */ 168 */
@@ -186,16 +180,13 @@
186 180
187#define AE_CODE_CTRL_MAX 0x000B 181#define AE_CODE_CTRL_MAX 0x000B
188 182
189
190#ifdef DEFINE_ACPI_GLOBALS 183#ifdef DEFINE_ACPI_GLOBALS
191 184
192
193/* 185/*
194 * String versions of the exception codes above 186 * String versions of the exception codes above
195 * These strings must match the corresponding defines exactly 187 * These strings must match the corresponding defines exactly
196 */ 188 */
197char const *acpi_gbl_exception_names_env[] = 189char const *acpi_gbl_exception_names_env[] = {
198{
199 "AE_OK", 190 "AE_OK",
200 "AE_ERROR", 191 "AE_ERROR",
201 "AE_NO_ACPI_TABLES", 192 "AE_NO_ACPI_TABLES",
@@ -226,11 +217,11 @@ char const *acpi_gbl_exception_names_env[] =
226 "AE_LOGICAL_ADDRESS", 217 "AE_LOGICAL_ADDRESS",
227 "AE_ABORT_METHOD", 218 "AE_ABORT_METHOD",
228 "AE_SAME_HANDLER", 219 "AE_SAME_HANDLER",
229 "AE_WAKE_ONLY_GPE" 220 "AE_WAKE_ONLY_GPE",
221 "AE_OWNER_ID_LIMIT"
230}; 222};
231 223
232char const *acpi_gbl_exception_names_pgm[] = 224char const *acpi_gbl_exception_names_pgm[] = {
233{
234 "AE_BAD_PARAMETER", 225 "AE_BAD_PARAMETER",
235 "AE_BAD_CHARACTER", 226 "AE_BAD_CHARACTER",
236 "AE_BAD_PATHNAME", 227 "AE_BAD_PATHNAME",
@@ -242,8 +233,7 @@ char const *acpi_gbl_exception_names_pgm[] =
242 "AE_BAD_DECIMAL_CONSTANT" 233 "AE_BAD_DECIMAL_CONSTANT"
243}; 234};
244 235
245char const *acpi_gbl_exception_names_tbl[] = 236char const *acpi_gbl_exception_names_tbl[] = {
246{
247 "AE_BAD_SIGNATURE", 237 "AE_BAD_SIGNATURE",
248 "AE_BAD_HEADER", 238 "AE_BAD_HEADER",
249 "AE_BAD_CHECKSUM", 239 "AE_BAD_CHECKSUM",
@@ -252,8 +242,7 @@ char const *acpi_gbl_exception_names_tbl[] =
252 "AE_INVALID_TABLE_LENGTH" 242 "AE_INVALID_TABLE_LENGTH"
253}; 243};
254 244
255char const *acpi_gbl_exception_names_aml[] = 245char const *acpi_gbl_exception_names_aml[] = {
256{
257 "AE_AML_ERROR", 246 "AE_AML_ERROR",
258 "AE_AML_PARSE", 247 "AE_AML_PARSE",
259 "AE_AML_BAD_OPCODE", 248 "AE_AML_BAD_OPCODE",
@@ -289,8 +278,7 @@ char const *acpi_gbl_exception_names_aml[] =
289 "AE_AML_BAD_RESOURCE_LENGTH" 278 "AE_AML_BAD_RESOURCE_LENGTH"
290}; 279};
291 280
292char const *acpi_gbl_exception_names_ctrl[] = 281char const *acpi_gbl_exception_names_ctrl[] = {
293{
294 "AE_CTRL_RETURN_VALUE", 282 "AE_CTRL_RETURN_VALUE",
295 "AE_CTRL_PENDING", 283 "AE_CTRL_PENDING",
296 "AE_CTRL_TERMINATE", 284 "AE_CTRL_TERMINATE",
@@ -304,6 +292,6 @@ char const *acpi_gbl_exception_names_ctrl[] =
304 "AE_CTRL_SKIP" 292 "AE_CTRL_SKIP"
305}; 293};
306 294
307#endif /* ACPI GLOBALS */ 295#endif /* ACPI GLOBALS */
308 296
309#endif /* __ACEXCEP_H__ */ 297#endif /* __ACEXCEP_H__ */
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index 4946696088c3..e9c2790139ec 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -44,7 +44,6 @@
44#ifndef __ACGLOBAL_H__ 44#ifndef __ACGLOBAL_H__
45#define __ACGLOBAL_H__ 45#define __ACGLOBAL_H__
46 46
47
48/* 47/*
49 * Ensure that the globals are actually defined and initialized only once. 48 * Ensure that the globals are actually defined and initialized only once.
50 * 49 *
@@ -63,9 +62,8 @@
63 * Keep local copies of these FADT-based registers. NOTE: These globals 62 * Keep local copies of these FADT-based registers. NOTE: These globals
64 * are first in this file for alignment reasons on 64-bit systems. 63 * are first in this file for alignment reasons on 64-bit systems.
65 */ 64 */
66ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; 65ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable;
67ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; 66ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
68
69 67
70/***************************************************************************** 68/*****************************************************************************
71 * 69 *
@@ -75,13 +73,12 @@ ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
75 73
76/* Runtime configuration of debug print levels */ 74/* Runtime configuration of debug print levels */
77 75
78extern u32 acpi_dbg_level; 76extern u32 acpi_dbg_level;
79extern u32 acpi_dbg_layer; 77extern u32 acpi_dbg_layer;
80 78
81/* Procedure nesting level for debug output */ 79/* Procedure nesting level for debug output */
82 80
83extern u32 acpi_gbl_nesting_level; 81extern u32 acpi_gbl_nesting_level;
84
85 82
86/***************************************************************************** 83/*****************************************************************************
87 * 84 *
@@ -98,7 +95,7 @@ extern u32 acpi_gbl_nesting_level;
98 * 3) Allow access to uninitialized locals/args (auto-init to integer 0) 95 * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
99 * 4) Allow ANY object type to be a source operand for the Store() operator 96 * 4) Allow ANY object type to be a source operand for the Store() operator
100 */ 97 */
101ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_enable_interpreter_slack, FALSE); 98ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
102 99
103/* 100/*
104 * Automatically serialize ALL control methods? Default is FALSE, meaning 101 * Automatically serialize ALL control methods? Default is FALSE, meaning
@@ -106,22 +103,21 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_enable_interpreter_slack, FALSE)
106 * Only change this if the ASL code is poorly written and cannot handle 103 * Only change this if the ASL code is poorly written and cannot handle
107 * reentrancy even though methods are marked "not_serialized". 104 * reentrancy even though methods are marked "not_serialized".
108 */ 105 */
109ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_all_methods_serialized, FALSE); 106ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
110 107
111/* 108/*
112 * Create the predefined _OSI method in the namespace? Default is TRUE 109 * Create the predefined _OSI method in the namespace? Default is TRUE
113 * because ACPI CA is fully compatible with other ACPI implementations. 110 * because ACPI CA is fully compatible with other ACPI implementations.
114 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. 111 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
115 */ 112 */
116ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_create_osi_method, TRUE); 113ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
117 114
118/* 115/*
119 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and 116 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
120 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only 117 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
121 * be enabled just before going to sleep. 118 * be enabled just before going to sleep.
122 */ 119 */
123ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_leave_wake_gpes_disabled, TRUE); 120ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
124
125 121
126/***************************************************************************** 122/*****************************************************************************
127 * 123 *
@@ -137,42 +133,46 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_leave_wake_gpes_disabled, TRUE);
137 * These tables are single-table only; meaning that there can be at most one 133 * These tables are single-table only; meaning that there can be at most one
138 * of each in the system. Each global points to the actual table. 134 * of each in the system. Each global points to the actual table.
139 */ 135 */
140ACPI_EXTERN u32 acpi_gbl_table_flags; 136ACPI_EXTERN u32 acpi_gbl_table_flags;
141ACPI_EXTERN u32 acpi_gbl_rsdt_table_count; 137ACPI_EXTERN u32 acpi_gbl_rsdt_table_count;
142ACPI_EXTERN struct rsdp_descriptor *acpi_gbl_RSDP; 138ACPI_EXTERN struct rsdp_descriptor *acpi_gbl_RSDP;
143ACPI_EXTERN XSDT_DESCRIPTOR *acpi_gbl_XSDT; 139ACPI_EXTERN XSDT_DESCRIPTOR *acpi_gbl_XSDT;
144ACPI_EXTERN FADT_DESCRIPTOR *acpi_gbl_FADT; 140ACPI_EXTERN FADT_DESCRIPTOR *acpi_gbl_FADT;
145ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT; 141ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT;
146ACPI_EXTERN FACS_DESCRIPTOR *acpi_gbl_FACS; 142ACPI_EXTERN FACS_DESCRIPTOR *acpi_gbl_FACS;
147ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS; 143ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS;
148/* 144/*
149 * Since there may be multiple SSDTs and PSDTs, a single pointer is not 145 * Since there may be multiple SSDTs and PSDTs, a single pointer is not
150 * sufficient; Therefore, there isn't one! 146 * sufficient; Therefore, there isn't one!
151 */ 147 */
152 148
149/* The root table can be either an RSDT or an XSDT */
150
151ACPI_EXTERN u8 acpi_gbl_root_table_type;
152#define ACPI_TABLE_TYPE_RSDT 'R'
153#define ACPI_TABLE_TYPE_XSDT 'X'
153 154
154/* 155/*
155 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: 156 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths:
156 * If we are executing a method that exists in a 32-bit ACPI table, 157 * If we are executing a method that exists in a 32-bit ACPI table,
157 * use only the lower 32 bits of the (internal) 64-bit Integer. 158 * use only the lower 32 bits of the (internal) 64-bit Integer.
158 */ 159 */
159ACPI_EXTERN u8 acpi_gbl_integer_bit_width; 160ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
160ACPI_EXTERN u8 acpi_gbl_integer_byte_width; 161ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
161ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; 162ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
162 163
163/* 164/*
164 * ACPI Table info arrays 165 * ACPI Table info arrays
165 */ 166 */
166extern struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; 167extern struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
167extern struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES]; 168extern struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES];
168 169
169/* 170/*
170 * Predefined mutex objects. This array contains the 171 * Predefined mutex objects. This array contains the
171 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. 172 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
172 * (The table maps local handles to the real OS handles) 173 * (The table maps local handles to the real OS handles)
173 */ 174 */
174ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; 175ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX];
175
176 176
177/***************************************************************************** 177/*****************************************************************************
178 * 178 *
@@ -180,41 +180,56 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX];
180 * 180 *
181 ****************************************************************************/ 181 ****************************************************************************/
182 182
183#ifdef ACPI_DBG_TRACK_ALLOCATIONS
184
185/* Lists for tracking memory allocations */
183 186
184ACPI_EXTERN struct acpi_memory_list acpi_gbl_memory_lists[ACPI_NUM_MEM_LISTS]; 187ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
185ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify; 188ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
186ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; 189#endif
187ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
188ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
189ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
190ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;
191
192ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count;
193ACPI_EXTERN u32 acpi_gbl_original_mode;
194ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
195ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
196ACPI_EXTERN u32 acpi_gbl_ps_find_count;
197ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
198ACPI_EXTERN u16 acpi_gbl_next_table_owner_id;
199ACPI_EXTERN u16 acpi_gbl_next_method_owner_id;
200ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
201ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
202ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
203ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
204ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
205ACPI_EXTERN u8 acpi_gbl_global_lock_present;
206ACPI_EXTERN u8 acpi_gbl_events_initialized;
207ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
208
209extern u8 acpi_gbl_shutdown;
210extern u32 acpi_gbl_startup_flags;
211extern const u8 acpi_gbl_decode_to8bit[8];
212extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
213extern const char *acpi_gbl_highest_dstate_names[4];
214extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
215extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
216extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS];
217 190
191/* Object caches */
192
193ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache;
194ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache;
195ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache;
196ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
197
198/* Global handlers */
199
200ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
201ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
202ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
203ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
204ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
205ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;
206
207/* Misc */
208
209ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count;
210ACPI_EXTERN u32 acpi_gbl_original_mode;
211ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
212ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
213ACPI_EXTERN u32 acpi_gbl_ps_find_count;
214ACPI_EXTERN u32 acpi_gbl_owner_id_mask;
215ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
216ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
217ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
218ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
219ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
220ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
221ACPI_EXTERN u8 acpi_gbl_global_lock_present;
222ACPI_EXTERN u8 acpi_gbl_events_initialized;
223ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
224
225extern u8 acpi_gbl_shutdown;
226extern u32 acpi_gbl_startup_flags;
227extern const u8 acpi_gbl_decode_to8bit[8];
228extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
229extern const char *acpi_gbl_highest_dstate_names[4];
230extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
231extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
232extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS];
218 233
219/***************************************************************************** 234/*****************************************************************************
220 * 235 *
@@ -230,36 +245,34 @@ extern const char *acpi_gbl_valid_osi_strings[ACPI_
230#define NUM_PREDEFINED_NAMES 9 245#define NUM_PREDEFINED_NAMES 9
231#endif 246#endif
232 247
233ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; 248ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
234ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; 249ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
235ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; 250ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
236 251
237extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; 252extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES];
238extern const struct acpi_predefined_names acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; 253extern const struct acpi_predefined_names
254 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
239 255
240#ifdef ACPI_DEBUG_OUTPUT 256#ifdef ACPI_DEBUG_OUTPUT
241ACPI_EXTERN u32 acpi_gbl_current_node_count; 257ACPI_EXTERN u32 acpi_gbl_current_node_count;
242ACPI_EXTERN u32 acpi_gbl_current_node_size; 258ACPI_EXTERN u32 acpi_gbl_current_node_size;
243ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; 259ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
244ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer; 260ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer;
245ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer; 261ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer;
246ACPI_EXTERN u32 acpi_gbl_deepest_nesting; 262ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
247#endif 263#endif
248 264
249
250/***************************************************************************** 265/*****************************************************************************
251 * 266 *
252 * Interpreter globals 267 * Interpreter globals
253 * 268 *
254 ****************************************************************************/ 269 ****************************************************************************/
255 270
256 271ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
257ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
258 272
259/* Control method single step flag */ 273/* Control method single step flag */
260 274
261ACPI_EXTERN u8 acpi_gbl_cm_single_step; 275ACPI_EXTERN u8 acpi_gbl_cm_single_step;
262
263 276
264/***************************************************************************** 277/*****************************************************************************
265 * 278 *
@@ -267,8 +280,7 @@ ACPI_EXTERN u8 acpi_gbl_cm_single_step;
267 * 280 *
268 ****************************************************************************/ 281 ****************************************************************************/
269 282
270ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root; 283ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root;
271
272 284
273/***************************************************************************** 285/*****************************************************************************
274 * 286 *
@@ -276,10 +288,10 @@ ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root;
276 * 288 *
277 ****************************************************************************/ 289 ****************************************************************************/
278 290
279extern struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG]; 291extern struct acpi_bit_register_info
280ACPI_EXTERN u8 acpi_gbl_sleep_type_a; 292 acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
281ACPI_EXTERN u8 acpi_gbl_sleep_type_b; 293ACPI_EXTERN u8 acpi_gbl_sleep_type_a;
282 294ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
283 295
284/***************************************************************************** 296/*****************************************************************************
285 * 297 *
@@ -287,12 +299,14 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
287 * 299 *
288 ****************************************************************************/ 300 ****************************************************************************/
289 301
290extern struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS]; 302extern struct acpi_fixed_event_info
291ACPI_EXTERN struct acpi_fixed_event_handler acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS]; 303 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
292ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 304ACPI_EXTERN struct acpi_fixed_event_handler
293ACPI_EXTERN struct acpi_gpe_block_info *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 305 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
294ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; 306ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
295 307ACPI_EXTERN struct acpi_gpe_block_info
308 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
309ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
296 310
297/***************************************************************************** 311/*****************************************************************************
298 * 312 *
@@ -300,58 +314,55 @@ ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
300 * 314 *
301 ****************************************************************************/ 315 ****************************************************************************/
302 316
303ACPI_EXTERN u8 acpi_gbl_db_output_flags; 317ACPI_EXTERN u8 acpi_gbl_db_output_flags;
304 318
305#ifdef ACPI_DISASSEMBLER 319#ifdef ACPI_DISASSEMBLER
306 320
307ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; 321ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
308ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; 322ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
309#endif 323#endif
310 324
311
312#ifdef ACPI_DEBUGGER 325#ifdef ACPI_DEBUGGER
313 326
314extern u8 acpi_gbl_method_executing; 327extern u8 acpi_gbl_method_executing;
315extern u8 acpi_gbl_abort_method; 328extern u8 acpi_gbl_abort_method;
316extern u8 acpi_gbl_db_terminate_threads; 329extern u8 acpi_gbl_db_terminate_threads;
317 330
318ACPI_EXTERN int optind; 331ACPI_EXTERN int optind;
319ACPI_EXTERN char *optarg; 332ACPI_EXTERN char *optarg;
320 333
321ACPI_EXTERN u8 acpi_gbl_db_opt_tables; 334ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
322ACPI_EXTERN u8 acpi_gbl_db_opt_stats; 335ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
323ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; 336ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
324 337
325 338ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
326ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; 339ACPI_EXTERN char acpi_gbl_db_line_buf[80];
327ACPI_EXTERN char acpi_gbl_db_line_buf[80]; 340ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
328ACPI_EXTERN char acpi_gbl_db_parsed_buf[80]; 341ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
329ACPI_EXTERN char acpi_gbl_db_scope_buf[40]; 342ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
330ACPI_EXTERN char acpi_gbl_db_debug_filename[40]; 343ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
331ACPI_EXTERN u8 acpi_gbl_db_output_to_file; 344ACPI_EXTERN char *acpi_gbl_db_buffer;
332ACPI_EXTERN char *acpi_gbl_db_buffer; 345ACPI_EXTERN char *acpi_gbl_db_filename;
333ACPI_EXTERN char *acpi_gbl_db_filename; 346ACPI_EXTERN u32 acpi_gbl_db_debug_level;
334ACPI_EXTERN u32 acpi_gbl_db_debug_level; 347ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
335ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; 348ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr;
336ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr; 349ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
337ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
338 350
339/* 351/*
340 * Statistic globals 352 * Statistic globals
341 */ 353 */
342ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX+1]; 354ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
343ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX+1]; 355ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
344ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc; 356ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc;
345ACPI_EXTERN u16 acpi_gbl_node_type_count_misc; 357ACPI_EXTERN u16 acpi_gbl_node_type_count_misc;
346ACPI_EXTERN u32 acpi_gbl_num_nodes; 358ACPI_EXTERN u32 acpi_gbl_num_nodes;
347ACPI_EXTERN u32 acpi_gbl_num_objects; 359ACPI_EXTERN u32 acpi_gbl_num_objects;
348
349 360
350ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree; 361ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree;
351ACPI_EXTERN u32 acpi_gbl_size_of_method_trees; 362ACPI_EXTERN u32 acpi_gbl_size_of_method_trees;
352ACPI_EXTERN u32 acpi_gbl_size_of_node_entries; 363ACPI_EXTERN u32 acpi_gbl_size_of_node_entries;
353ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; 364ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
354 365
355#endif /* ACPI_DEBUGGER */ 366#endif /* ACPI_DEBUGGER */
356 367
357#endif /* __ACGLOBAL_H__ */ 368#endif /* __ACGLOBAL_H__ */
diff --git a/include/acpi/achware.h b/include/acpi/achware.h
index 9d63641b8e7d..3644d7248e7e 100644
--- a/include/acpi/achware.h
+++ b/include/acpi/achware.h
@@ -44,7 +44,6 @@
44#ifndef __ACHWARE_H__ 44#ifndef __ACHWARE_H__
45#define __ACHWARE_H__ 45#define __ACHWARE_H__
46 46
47
48/* PM Timer ticks per second (HZ) */ 47/* PM Timer ticks per second (HZ) */
49 48
50#define PM_TIMER_FREQUENCY 3579545 49#define PM_TIMER_FREQUENCY 3579545
@@ -57,126 +56,78 @@
57#define ACPI_SST_SLEEPING 3 56#define ACPI_SST_SLEEPING 3
58#define ACPI_SST_SLEEP_CONTEXT 4 57#define ACPI_SST_SLEEP_CONTEXT 4
59 58
60
61/* Prototypes */ 59/* Prototypes */
62 60
63
64/* 61/*
65 * hwacpi - high level functions 62 * hwacpi - high level functions
66 */ 63 */
67acpi_status 64acpi_status acpi_hw_initialize(void);
68acpi_hw_initialize (
69 void);
70 65
71acpi_status 66acpi_status acpi_hw_set_mode(u32 mode);
72acpi_hw_set_mode (
73 u32 mode);
74
75u32
76acpi_hw_get_mode (
77 void);
78 67
68u32 acpi_hw_get_mode(void);
79 69
80/* 70/*
81 * hwregs - ACPI Register I/O 71 * hwregs - ACPI Register I/O
82 */ 72 */
83struct acpi_bit_register_info * 73struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
84acpi_hw_get_bit_register_info (
85 u32 register_id);
86
87acpi_status
88acpi_hw_register_read (
89 u8 use_lock,
90 u32 register_id,
91 u32 *return_value);
92 74
93acpi_status 75acpi_status
94acpi_hw_register_write ( 76acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value);
95 u8 use_lock,
96 u32 register_id,
97 u32 value);
98 77
99acpi_status 78acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value);
100acpi_hw_low_level_read (
101 u32 width,
102 u32 *value,
103 struct acpi_generic_address *reg);
104 79
105acpi_status 80acpi_status
106acpi_hw_low_level_write ( 81acpi_hw_low_level_read(u32 width,
107 u32 width, 82 u32 * value, struct acpi_generic_address *reg);
108 u32 value,
109 struct acpi_generic_address *reg);
110 83
111acpi_status 84acpi_status
112acpi_hw_clear_acpi_status ( 85acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address *reg);
113 u32 flags);
114 86
87acpi_status acpi_hw_clear_acpi_status(u32 flags);
115 88
116/* 89/*
117 * hwgpe - GPE support 90 * hwgpe - GPE support
118 */ 91 */
119acpi_status 92acpi_status
120acpi_hw_write_gpe_enable_reg ( 93acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
121 struct acpi_gpe_event_info *gpe_event_info);
122 94
123acpi_status 95acpi_status
124acpi_hw_disable_gpe_block ( 96acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
125 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 97 struct acpi_gpe_block_info *gpe_block);
126 struct acpi_gpe_block_info *gpe_block);
127 98
128acpi_status 99acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info);
129acpi_hw_clear_gpe (
130 struct acpi_gpe_event_info *gpe_event_info);
131 100
132acpi_status 101acpi_status
133acpi_hw_clear_gpe_block ( 102acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
134 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 103 struct acpi_gpe_block_info *gpe_block);
135 struct acpi_gpe_block_info *gpe_block);
136 104
137#ifdef ACPI_FUTURE_USAGE 105#ifdef ACPI_FUTURE_USAGE
138acpi_status 106acpi_status
139acpi_hw_get_gpe_status ( 107acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
140 struct acpi_gpe_event_info *gpe_event_info, 108 acpi_event_status * event_status);
141 acpi_event_status *event_status); 109#endif /* ACPI_FUTURE_USAGE */
142#endif /* ACPI_FUTURE_USAGE */
143 110
144acpi_status 111acpi_status acpi_hw_disable_all_gpes(void);
145acpi_hw_disable_all_gpes (
146 u32 flags);
147 112
148acpi_status 113acpi_status acpi_hw_enable_all_runtime_gpes(void);
149acpi_hw_enable_all_runtime_gpes (
150 u32 flags);
151 114
152acpi_status 115acpi_status acpi_hw_enable_all_wakeup_gpes(void);
153acpi_hw_enable_all_wakeup_gpes (
154 u32 flags);
155 116
156acpi_status 117acpi_status
157acpi_hw_enable_runtime_gpe_block ( 118acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
158 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 119 struct acpi_gpe_block_info *gpe_block);
159 struct acpi_gpe_block_info *gpe_block);
160
161 120
162#ifdef ACPI_FUTURE_USAGE 121#ifdef ACPI_FUTURE_USAGE
163/* 122/*
164 * hwtimer - ACPI Timer prototypes 123 * hwtimer - ACPI Timer prototypes
165 */ 124 */
166acpi_status 125acpi_status acpi_get_timer_resolution(u32 * resolution);
167acpi_get_timer_resolution (
168 u32 *resolution);
169 126
170acpi_status 127acpi_status acpi_get_timer(u32 * ticks);
171acpi_get_timer (
172 u32 *ticks);
173 128
174acpi_status 129acpi_status
175acpi_get_timer_duration ( 130acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed);
176 u32 start_ticks, 131#endif /* ACPI_FUTURE_USAGE */
177 u32 end_ticks,
178 u32 *time_elapsed);
179#endif /* ACPI_FUTURE_USAGE */
180
181 132
182#endif /* __ACHWARE_H__ */ 133#endif /* __ACHWARE_H__ */
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index 5c7172477a0f..2c9c1a1d1b7f 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -44,29 +44,22 @@
44#ifndef __ACINTERP_H__ 44#ifndef __ACINTERP_H__
45#define __ACINTERP_H__ 45#define __ACINTERP_H__
46 46
47
48#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) 47#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
49 48
50
51/* 49/*
52 * exconvrt - object conversion 50 * exconvrt - object conversion
53 */ 51 */
54acpi_status 52acpi_status
55acpi_ex_convert_to_integer ( 53acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
56 union acpi_operand_object *obj_desc, 54 union acpi_operand_object **result_desc, u32 flags);
57 union acpi_operand_object **result_desc,
58 u32 flags);
59 55
60acpi_status 56acpi_status
61acpi_ex_convert_to_buffer ( 57acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
62 union acpi_operand_object *obj_desc, 58 union acpi_operand_object **result_desc);
63 union acpi_operand_object **result_desc);
64 59
65acpi_status 60acpi_status
66acpi_ex_convert_to_string ( 61acpi_ex_convert_to_string(union acpi_operand_object *obj_desc,
67 union acpi_operand_object *obj_desc, 62 union acpi_operand_object **result_desc, u32 type);
68 union acpi_operand_object **result_desc,
69 u32 type);
70 63
71/* Types for ->String conversion */ 64/* Types for ->String conversion */
72 65
@@ -76,587 +69,412 @@ acpi_ex_convert_to_string (
76#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 69#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003
77 70
78acpi_status 71acpi_status
79acpi_ex_convert_to_target_type ( 72acpi_ex_convert_to_target_type(acpi_object_type destination_type,
80 acpi_object_type destination_type, 73 union acpi_operand_object *source_desc,
81 union acpi_operand_object *source_desc, 74 union acpi_operand_object **result_desc,
82 union acpi_operand_object **result_desc, 75 struct acpi_walk_state *walk_state);
83 struct acpi_walk_state *walk_state);
84
85 76
86/* 77/*
87 * exfield - ACPI AML (p-code) execution - field manipulation 78 * exfield - ACPI AML (p-code) execution - field manipulation
88 */ 79 */
89acpi_status 80acpi_status
90acpi_ex_common_buffer_setup ( 81acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
91 union acpi_operand_object *obj_desc, 82 u32 buffer_length, u32 * datum_count);
92 u32 buffer_length,
93 u32 *datum_count);
94 83
95acpi_status 84acpi_status
96acpi_ex_write_with_update_rule ( 85acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
97 union acpi_operand_object *obj_desc, 86 acpi_integer mask,
98 acpi_integer mask, 87 acpi_integer field_value,
99 acpi_integer field_value, 88 u32 field_datum_byte_offset);
100 u32 field_datum_byte_offset);
101 89
102void 90void
103acpi_ex_get_buffer_datum( 91acpi_ex_get_buffer_datum(acpi_integer * datum,
104 acpi_integer *datum, 92 void *buffer,
105 void *buffer, 93 u32 buffer_length,
106 u32 buffer_length, 94 u32 byte_granularity, u32 buffer_offset);
107 u32 byte_granularity,
108 u32 buffer_offset);
109 95
110void 96void
111acpi_ex_set_buffer_datum ( 97acpi_ex_set_buffer_datum(acpi_integer merged_datum,
112 acpi_integer merged_datum, 98 void *buffer,
113 void *buffer, 99 u32 buffer_length,
114 u32 buffer_length, 100 u32 byte_granularity, u32 buffer_offset);
115 u32 byte_granularity,
116 u32 buffer_offset);
117 101
118acpi_status 102acpi_status
119acpi_ex_read_data_from_field ( 103acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
120 struct acpi_walk_state *walk_state, 104 union acpi_operand_object *obj_desc,
121 union acpi_operand_object *obj_desc, 105 union acpi_operand_object **ret_buffer_desc);
122 union acpi_operand_object **ret_buffer_desc);
123 106
124acpi_status 107acpi_status
125acpi_ex_write_data_to_field ( 108acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
126 union acpi_operand_object *source_desc, 109 union acpi_operand_object *obj_desc,
127 union acpi_operand_object *obj_desc, 110 union acpi_operand_object **result_desc);
128 union acpi_operand_object **result_desc);
129
130 111
131/* 112/*
132 * exfldio - low level field I/O 113 * exfldio - low level field I/O
133 */ 114 */
134acpi_status 115acpi_status
135acpi_ex_extract_from_field ( 116acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
136 union acpi_operand_object *obj_desc, 117 void *buffer, u32 buffer_length);
137 void *buffer,
138 u32 buffer_length);
139 118
140acpi_status 119acpi_status
141acpi_ex_insert_into_field ( 120acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
142 union acpi_operand_object *obj_desc, 121 void *buffer, u32 buffer_length);
143 void *buffer,
144 u32 buffer_length);
145 122
146acpi_status 123acpi_status
147acpi_ex_access_region ( 124acpi_ex_access_region(union acpi_operand_object *obj_desc,
148 union acpi_operand_object *obj_desc, 125 u32 field_datum_byte_offset,
149 u32 field_datum_byte_offset, 126 acpi_integer * value, u32 read_write);
150 acpi_integer *value,
151 u32 read_write);
152
153 127
154/* 128/*
155 * exmisc - misc support routines 129 * exmisc - misc support routines
156 */ 130 */
157acpi_status 131acpi_status
158acpi_ex_get_object_reference ( 132acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
159 union acpi_operand_object *obj_desc, 133 union acpi_operand_object **return_desc,
160 union acpi_operand_object **return_desc, 134 struct acpi_walk_state *walk_state);
161 struct acpi_walk_state *walk_state);
162 135
163acpi_status 136acpi_status
164acpi_ex_concat_template ( 137acpi_ex_concat_template(union acpi_operand_object *obj_desc,
165 union acpi_operand_object *obj_desc, 138 union acpi_operand_object *obj_desc2,
166 union acpi_operand_object *obj_desc2, 139 union acpi_operand_object **actual_return_desc,
167 union acpi_operand_object **actual_return_desc, 140 struct acpi_walk_state *walk_state);
168 struct acpi_walk_state *walk_state);
169 141
170acpi_status 142acpi_status
171acpi_ex_do_concatenate ( 143acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
172 union acpi_operand_object *obj_desc, 144 union acpi_operand_object *obj_desc2,
173 union acpi_operand_object *obj_desc2, 145 union acpi_operand_object **actual_return_desc,
174 union acpi_operand_object **actual_return_desc, 146 struct acpi_walk_state *walk_state);
175 struct acpi_walk_state *walk_state);
176 147
177acpi_status 148acpi_status
178acpi_ex_do_logical_numeric_op ( 149acpi_ex_do_logical_numeric_op(u16 opcode,
179 u16 opcode, 150 acpi_integer integer0,
180 acpi_integer integer0, 151 acpi_integer integer1, u8 * logical_result);
181 acpi_integer integer1,
182 u8 *logical_result);
183 152
184acpi_status 153acpi_status
185acpi_ex_do_logical_op ( 154acpi_ex_do_logical_op(u16 opcode,
186 u16 opcode, 155 union acpi_operand_object *operand0,
187 union acpi_operand_object *operand0, 156 union acpi_operand_object *operand1, u8 * logical_result);
188 union acpi_operand_object *operand1,
189 u8 *logical_result);
190 157
191acpi_integer 158acpi_integer
192acpi_ex_do_math_op ( 159acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
193 u16 opcode,
194 acpi_integer operand0,
195 acpi_integer operand1);
196 160
197acpi_status 161acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
198acpi_ex_create_mutex (
199 struct acpi_walk_state *walk_state);
200 162
201acpi_status 163acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state);
202acpi_ex_create_processor (
203 struct acpi_walk_state *walk_state);
204 164
205acpi_status 165acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state);
206acpi_ex_create_power_resource (
207 struct acpi_walk_state *walk_state);
208 166
209acpi_status 167acpi_status
210acpi_ex_create_region ( 168acpi_ex_create_region(u8 * aml_start,
211 u8 *aml_start, 169 u32 aml_length,
212 u32 aml_length, 170 u8 region_space, struct acpi_walk_state *walk_state);
213 u8 region_space,
214 struct acpi_walk_state *walk_state);
215 171
216acpi_status 172acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state);
217acpi_ex_create_table_region (
218 struct acpi_walk_state *walk_state);
219 173
220acpi_status 174acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
221acpi_ex_create_event (
222 struct acpi_walk_state *walk_state);
223 175
224acpi_status 176acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
225acpi_ex_create_alias (
226 struct acpi_walk_state *walk_state);
227 177
228acpi_status 178acpi_status
229acpi_ex_create_method ( 179acpi_ex_create_method(u8 * aml_start,
230 u8 *aml_start, 180 u32 aml_length, struct acpi_walk_state *walk_state);
231 u32 aml_length,
232 struct acpi_walk_state *walk_state);
233
234 181
235/* 182/*
236 * exconfig - dynamic table load/unload 183 * exconfig - dynamic table load/unload
237 */ 184 */
238acpi_status 185acpi_status
239acpi_ex_load_op ( 186acpi_ex_load_op(union acpi_operand_object *obj_desc,
240 union acpi_operand_object *obj_desc, 187 union acpi_operand_object *target,
241 union acpi_operand_object *target, 188 struct acpi_walk_state *walk_state);
242 struct acpi_walk_state *walk_state);
243 189
244acpi_status 190acpi_status
245acpi_ex_load_table_op ( 191acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
246 struct acpi_walk_state *walk_state, 192 union acpi_operand_object **return_desc);
247 union acpi_operand_object **return_desc);
248
249acpi_status
250acpi_ex_unload_table (
251 union acpi_operand_object *ddb_handle);
252 193
194acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle);
253 195
254/* 196/*
255 * exmutex - mutex support 197 * exmutex - mutex support
256 */ 198 */
257acpi_status 199acpi_status
258acpi_ex_acquire_mutex ( 200acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
259 union acpi_operand_object *time_desc, 201 union acpi_operand_object *obj_desc,
260 union acpi_operand_object *obj_desc, 202 struct acpi_walk_state *walk_state);
261 struct acpi_walk_state *walk_state);
262 203
263acpi_status 204acpi_status
264acpi_ex_release_mutex ( 205acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
265 union acpi_operand_object *obj_desc, 206 struct acpi_walk_state *walk_state);
266 struct acpi_walk_state *walk_state);
267 207
268void 208void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
269acpi_ex_release_all_mutexes (
270 struct acpi_thread_state *thread);
271
272void
273acpi_ex_unlink_mutex (
274 union acpi_operand_object *obj_desc);
275 209
210void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
276 211
277/* 212/*
278 * exprep - ACPI AML execution - prep utilities 213 * exprep - ACPI AML execution - prep utilities
279 */ 214 */
280acpi_status 215acpi_status
281acpi_ex_prep_common_field_object ( 216acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
282 union acpi_operand_object *obj_desc, 217 u8 field_flags,
283 u8 field_flags, 218 u8 field_attribute,
284 u8 field_attribute, 219 u32 field_bit_position, u32 field_bit_length);
285 u32 field_bit_position,
286 u32 field_bit_length);
287
288acpi_status
289acpi_ex_prep_field_value (
290 struct acpi_create_field_info *info);
291 220
221acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info);
292 222
293/* 223/*
294 * exsystem - Interface to OS services 224 * exsystem - Interface to OS services
295 */ 225 */
296acpi_status 226acpi_status
297acpi_ex_system_do_notify_op ( 227acpi_ex_system_do_notify_op(union acpi_operand_object *value,
298 union acpi_operand_object *value, 228 union acpi_operand_object *obj_desc);
299 union acpi_operand_object *obj_desc);
300 229
301acpi_status 230acpi_status acpi_ex_system_do_suspend(acpi_integer time);
302acpi_ex_system_do_suspend(
303 acpi_integer time);
304 231
305acpi_status 232acpi_status acpi_ex_system_do_stall(u32 time);
306acpi_ex_system_do_stall (
307 u32 time);
308 233
309acpi_status 234acpi_status
310acpi_ex_system_acquire_mutex( 235acpi_ex_system_acquire_mutex(union acpi_operand_object *time,
311 union acpi_operand_object *time, 236 union acpi_operand_object *obj_desc);
312 union acpi_operand_object *obj_desc);
313 237
314acpi_status 238acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc);
315acpi_ex_system_release_mutex(
316 union acpi_operand_object *obj_desc);
317 239
318acpi_status 240acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc);
319acpi_ex_system_signal_event(
320 union acpi_operand_object *obj_desc);
321 241
322acpi_status 242acpi_status
323acpi_ex_system_wait_event( 243acpi_ex_system_wait_event(union acpi_operand_object *time,
324 union acpi_operand_object *time, 244 union acpi_operand_object *obj_desc);
325 union acpi_operand_object *obj_desc);
326 245
327acpi_status 246acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
328acpi_ex_system_reset_event(
329 union acpi_operand_object *obj_desc);
330
331acpi_status
332acpi_ex_system_wait_semaphore (
333 acpi_handle semaphore,
334 u16 timeout);
335 247
248acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout);
336 249
337/* 250/*
338 * exoparg1 - ACPI AML execution, 1 operand 251 * exoparg1 - ACPI AML execution, 1 operand
339 */ 252 */
340acpi_status 253acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state);
341acpi_ex_opcode_0A_0T_1R (
342 struct acpi_walk_state *walk_state);
343 254
344acpi_status 255acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state);
345acpi_ex_opcode_1A_0T_0R (
346 struct acpi_walk_state *walk_state);
347 256
348acpi_status 257acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state);
349acpi_ex_opcode_1A_0T_1R (
350 struct acpi_walk_state *walk_state);
351 258
352acpi_status 259acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state);
353acpi_ex_opcode_1A_1T_1R (
354 struct acpi_walk_state *walk_state);
355 260
356acpi_status 261acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state);
357acpi_ex_opcode_1A_1T_0R (
358 struct acpi_walk_state *walk_state);
359 262
360/* 263/*
361 * exoparg2 - ACPI AML execution, 2 operands 264 * exoparg2 - ACPI AML execution, 2 operands
362 */ 265 */
363acpi_status 266acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state);
364acpi_ex_opcode_2A_0T_0R (
365 struct acpi_walk_state *walk_state);
366 267
367acpi_status 268acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state);
368acpi_ex_opcode_2A_0T_1R (
369 struct acpi_walk_state *walk_state);
370 269
371acpi_status 270acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state);
372acpi_ex_opcode_2A_1T_1R (
373 struct acpi_walk_state *walk_state);
374
375acpi_status
376acpi_ex_opcode_2A_2T_1R (
377 struct acpi_walk_state *walk_state);
378 271
272acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state);
379 273
380/* 274/*
381 * exoparg3 - ACPI AML execution, 3 operands 275 * exoparg3 - ACPI AML execution, 3 operands
382 */ 276 */
383acpi_status 277acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state);
384acpi_ex_opcode_3A_0T_0R (
385 struct acpi_walk_state *walk_state);
386
387acpi_status
388acpi_ex_opcode_3A_1T_1R (
389 struct acpi_walk_state *walk_state);
390 278
279acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state);
391 280
392/* 281/*
393 * exoparg6 - ACPI AML execution, 6 operands 282 * exoparg6 - ACPI AML execution, 6 operands
394 */ 283 */
395acpi_status 284acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state);
396acpi_ex_opcode_6A_0T_1R (
397 struct acpi_walk_state *walk_state);
398
399 285
400/* 286/*
401 * exresolv - Object resolution and get value functions 287 * exresolv - Object resolution and get value functions
402 */ 288 */
403acpi_status 289acpi_status
404acpi_ex_resolve_to_value ( 290acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
405 union acpi_operand_object **stack_ptr, 291 struct acpi_walk_state *walk_state);
406 struct acpi_walk_state *walk_state);
407 292
408acpi_status 293acpi_status
409acpi_ex_resolve_multiple ( 294acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
410 struct acpi_walk_state *walk_state, 295 union acpi_operand_object *operand,
411 union acpi_operand_object *operand, 296 acpi_object_type * return_type,
412 acpi_object_type *return_type, 297 union acpi_operand_object **return_desc);
413 union acpi_operand_object **return_desc);
414
415 298
416/* 299/*
417 * exresnte - resolve namespace node 300 * exresnte - resolve namespace node
418 */ 301 */
419acpi_status 302acpi_status
420acpi_ex_resolve_node_to_value ( 303acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr,
421 struct acpi_namespace_node **stack_ptr, 304 struct acpi_walk_state *walk_state);
422 struct acpi_walk_state *walk_state);
423
424 305
425/* 306/*
426 * exresop - resolve operand to value 307 * exresop - resolve operand to value
427 */ 308 */
428acpi_status 309acpi_status
429acpi_ex_resolve_operands ( 310acpi_ex_resolve_operands(u16 opcode,
430 u16 opcode, 311 union acpi_operand_object **stack_ptr,
431 union acpi_operand_object **stack_ptr, 312 struct acpi_walk_state *walk_state);
432 struct acpi_walk_state *walk_state);
433
434 313
435/* 314/*
436 * exdump - Interpreter debug output routines 315 * exdump - Interpreter debug output routines
437 */ 316 */
438void 317void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth);
439acpi_ex_dump_operand (
440 union acpi_operand_object *obj_desc,
441 u32 depth);
442 318
443void 319void
444acpi_ex_dump_operands ( 320acpi_ex_dump_operands(union acpi_operand_object **operands,
445 union acpi_operand_object **operands, 321 acpi_interpreter_mode interpreter_mode,
446 acpi_interpreter_mode interpreter_mode, 322 char *ident,
447 char *ident, 323 u32 num_levels,
448 u32 num_levels, 324 char *note, char *module_name, u32 line_number);
449 char *note,
450 char *module_name,
451 u32 line_number);
452 325
453#ifdef ACPI_FUTURE_USAGE 326#ifdef ACPI_FUTURE_USAGE
454void 327void
455acpi_ex_dump_object_descriptor ( 328acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
456 union acpi_operand_object *object,
457 u32 flags);
458
459void
460acpi_ex_dump_node (
461 struct acpi_namespace_node *node,
462 u32 flags);
463#endif /* ACPI_FUTURE_USAGE */
464 329
330void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags);
331#endif /* ACPI_FUTURE_USAGE */
465 332
466/* 333/*
467 * exnames - AML namestring support 334 * exnames - AML namestring support
468 */ 335 */
469acpi_status 336acpi_status
470acpi_ex_get_name_string ( 337acpi_ex_get_name_string(acpi_object_type data_type,
471 acpi_object_type data_type, 338 u8 * in_aml_address,
472 u8 *in_aml_address, 339 char **out_name_string, u32 * out_name_length);
473 char **out_name_string,
474 u32 *out_name_length);
475
476 340
477/* 341/*
478 * exstore - Object store support 342 * exstore - Object store support
479 */ 343 */
480acpi_status 344acpi_status
481acpi_ex_store ( 345acpi_ex_store(union acpi_operand_object *val_desc,
482 union acpi_operand_object *val_desc, 346 union acpi_operand_object *dest_desc,
483 union acpi_operand_object *dest_desc, 347 struct acpi_walk_state *walk_state);
484 struct acpi_walk_state *walk_state);
485 348
486acpi_status 349acpi_status
487acpi_ex_store_object_to_node ( 350acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
488 union acpi_operand_object *source_desc, 351 struct acpi_namespace_node *node,
489 struct acpi_namespace_node *node, 352 struct acpi_walk_state *walk_state,
490 struct acpi_walk_state *walk_state, 353 u8 implicit_conversion);
491 u8 implicit_conversion);
492 354
493#define ACPI_IMPLICIT_CONVERSION TRUE 355#define ACPI_IMPLICIT_CONVERSION TRUE
494#define ACPI_NO_IMPLICIT_CONVERSION FALSE 356#define ACPI_NO_IMPLICIT_CONVERSION FALSE
495 357
496
497/* 358/*
498 * exstoren - resolve/store object 359 * exstoren - resolve/store object
499 */ 360 */
500acpi_status 361acpi_status
501acpi_ex_resolve_object ( 362acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
502 union acpi_operand_object **source_desc_ptr, 363 acpi_object_type target_type,
503 acpi_object_type target_type, 364 struct acpi_walk_state *walk_state);
504 struct acpi_walk_state *walk_state);
505 365
506acpi_status 366acpi_status
507acpi_ex_store_object_to_object ( 367acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
508 union acpi_operand_object *source_desc, 368 union acpi_operand_object *dest_desc,
509 union acpi_operand_object *dest_desc, 369 union acpi_operand_object **new_desc,
510 union acpi_operand_object **new_desc, 370 struct acpi_walk_state *walk_state);
511 struct acpi_walk_state *walk_state);
512
513 371
514/* 372/*
515 * exstorob - store object - buffer/string 373 * exstorob - store object - buffer/string
516 */ 374 */
517acpi_status 375acpi_status
518acpi_ex_store_buffer_to_buffer ( 376acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
519 union acpi_operand_object *source_desc, 377 union acpi_operand_object *target_desc);
520 union acpi_operand_object *target_desc);
521 378
522acpi_status 379acpi_status
523acpi_ex_store_string_to_string ( 380acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
524 union acpi_operand_object *source_desc, 381 union acpi_operand_object *target_desc);
525 union acpi_operand_object *target_desc);
526
527 382
528/* 383/*
529 * excopy - object copy 384 * excopy - object copy
530 */ 385 */
531acpi_status 386acpi_status
532acpi_ex_copy_integer_to_index_field ( 387acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc,
533 union acpi_operand_object *source_desc, 388 union acpi_operand_object *target_desc);
534 union acpi_operand_object *target_desc);
535 389
536acpi_status 390acpi_status
537acpi_ex_copy_integer_to_bank_field ( 391acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc,
538 union acpi_operand_object *source_desc, 392 union acpi_operand_object *target_desc);
539 union acpi_operand_object *target_desc);
540 393
541acpi_status 394acpi_status
542acpi_ex_copy_data_to_named_field ( 395acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc,
543 union acpi_operand_object *source_desc, 396 struct acpi_namespace_node *node);
544 struct acpi_namespace_node *node);
545 397
546acpi_status 398acpi_status
547acpi_ex_copy_integer_to_buffer_field ( 399acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc,
548 union acpi_operand_object *source_desc, 400 union acpi_operand_object *target_desc);
549 union acpi_operand_object *target_desc);
550
551 401
552/* 402/*
553 * exutils - interpreter/scanner utilities 403 * exutils - interpreter/scanner utilities
554 */ 404 */
555acpi_status 405acpi_status acpi_ex_enter_interpreter(void);
556acpi_ex_enter_interpreter (
557 void);
558 406
559void 407void acpi_ex_exit_interpreter(void);
560acpi_ex_exit_interpreter (
561 void);
562 408
563void 409void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
564acpi_ex_truncate_for32bit_table (
565 union acpi_operand_object *obj_desc);
566 410
567u8 411u8 acpi_ex_acquire_global_lock(u32 rule);
568acpi_ex_acquire_global_lock (
569 u32 rule);
570 412
571void 413void acpi_ex_release_global_lock(u8 locked);
572acpi_ex_release_global_lock (
573 u8 locked);
574 414
575void 415void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string);
576acpi_ex_eisa_id_to_string (
577 u32 numeric_id,
578 char *out_string);
579
580void
581acpi_ex_unsigned_integer_to_string (
582 acpi_integer value,
583 char *out_string);
584 416
417void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string);
585 418
586/* 419/*
587 * exregion - default op_region handlers 420 * exregion - default op_region handlers
588 */ 421 */
589acpi_status 422acpi_status
590acpi_ex_system_memory_space_handler ( 423acpi_ex_system_memory_space_handler(u32 function,
591 u32 function, 424 acpi_physical_address address,
592 acpi_physical_address address, 425 u32 bit_width,
593 u32 bit_width, 426 acpi_integer * value,
594 acpi_integer *value, 427 void *handler_context,
595 void *handler_context, 428 void *region_context);
596 void *region_context); 429
597 430acpi_status
598acpi_status 431acpi_ex_system_io_space_handler(u32 function,
599acpi_ex_system_io_space_handler ( 432 acpi_physical_address address,
600 u32 function, 433 u32 bit_width,
601 acpi_physical_address address, 434 acpi_integer * value,
602 u32 bit_width, 435 void *handler_context, void *region_context);
603 acpi_integer *value, 436
604 void *handler_context, 437acpi_status
605 void *region_context); 438acpi_ex_pci_config_space_handler(u32 function,
606 439 acpi_physical_address address,
607acpi_status 440 u32 bit_width,
608acpi_ex_pci_config_space_handler ( 441 acpi_integer * value,
609 u32 function, 442 void *handler_context, void *region_context);
610 acpi_physical_address address, 443
611 u32 bit_width, 444acpi_status
612 acpi_integer *value, 445acpi_ex_cmos_space_handler(u32 function,
613 void *handler_context, 446 acpi_physical_address address,
614 void *region_context); 447 u32 bit_width,
615 448 acpi_integer * value,
616acpi_status 449 void *handler_context, void *region_context);
617acpi_ex_cmos_space_handler ( 450
618 u32 function, 451acpi_status
619 acpi_physical_address address, 452acpi_ex_pci_bar_space_handler(u32 function,
620 u32 bit_width, 453 acpi_physical_address address,
621 acpi_integer *value, 454 u32 bit_width,
622 void *handler_context, 455 acpi_integer * value,
623 void *region_context); 456 void *handler_context, void *region_context);
624 457
625acpi_status 458acpi_status
626acpi_ex_pci_bar_space_handler ( 459acpi_ex_embedded_controller_space_handler(u32 function,
627 u32 function, 460 acpi_physical_address address,
628 acpi_physical_address address, 461 u32 bit_width,
629 u32 bit_width, 462 acpi_integer * value,
630 acpi_integer *value, 463 void *handler_context,
631 void *handler_context, 464 void *region_context);
632 void *region_context); 465
633 466acpi_status
634acpi_status 467acpi_ex_sm_bus_space_handler(u32 function,
635acpi_ex_embedded_controller_space_handler ( 468 acpi_physical_address address,
636 u32 function, 469 u32 bit_width,
637 acpi_physical_address address, 470 acpi_integer * value,
638 u32 bit_width, 471 void *handler_context, void *region_context);
639 acpi_integer *value, 472
640 void *handler_context, 473acpi_status
641 void *region_context); 474acpi_ex_data_table_space_handler(u32 function,
642 475 acpi_physical_address address,
643acpi_status 476 u32 bit_width,
644acpi_ex_sm_bus_space_handler ( 477 acpi_integer * value,
645 u32 function, 478 void *handler_context, void *region_context);
646 acpi_physical_address address, 479
647 u32 bit_width, 480#endif /* __INTERP_H__ */
648 acpi_integer *value,
649 void *handler_context,
650 void *region_context);
651
652
653acpi_status
654acpi_ex_data_table_space_handler (
655 u32 function,
656 acpi_physical_address address,
657 u32 bit_width,
658 acpi_integer *value,
659 void *handler_context,
660 void *region_context);
661
662#endif /* __INTERP_H__ */
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index 030e641115cb..9fba0fddda90 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -44,17 +44,20 @@
44#ifndef __ACLOCAL_H__ 44#ifndef __ACLOCAL_H__
45#define __ACLOCAL_H__ 45#define __ACLOCAL_H__
46 46
47#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
47 48
48#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ 49typedef void *acpi_mutex;
49 50typedef u32 acpi_mutex_handle;
50typedef void * acpi_mutex;
51typedef u32 acpi_mutex_handle;
52
53 51
54/* Total number of aml opcodes defined */ 52/* Total number of aml opcodes defined */
55 53
56#define AML_NUM_OPCODES 0x7F 54#define AML_NUM_OPCODES 0x7F
57 55
56/* Forward declarations */
57
58struct acpi_walk_state;
59struct acpi_obj_mutex;
60union acpi_parse_object;
58 61
59/***************************************************************************** 62/*****************************************************************************
60 * 63 *
@@ -62,7 +65,6 @@ typedef u32 acpi_mutex_handle;
62 * 65 *
63 ****************************************************************************/ 66 ****************************************************************************/
64 67
65
66/* 68/*
67 * Predefined handles for the mutex objects used within the subsystem 69 * Predefined handles for the mutex objects used within the subsystem
68 * All mutex objects are automatically created by acpi_ut_mutex_initialize. 70 * All mutex objects are automatically created by acpi_ut_mutex_initialize.
@@ -89,14 +91,12 @@ typedef u32 acpi_mutex_handle;
89#define MAX_MUTEX 12 91#define MAX_MUTEX 12
90#define NUM_MUTEX MAX_MUTEX+1 92#define NUM_MUTEX MAX_MUTEX+1
91 93
92
93#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 94#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
94#ifdef DEFINE_ACPI_GLOBALS 95#ifdef DEFINE_ACPI_GLOBALS
95 96
96/* Names for the mutexes used in the subsystem */ 97/* Names for the mutexes used in the subsystem */
97 98
98static char *acpi_gbl_mutex_names[] = 99static char *acpi_gbl_mutex_names[] = {
99{
100 "ACPI_MTX_Execute", 100 "ACPI_MTX_Execute",
101 "ACPI_MTX_Interpreter", 101 "ACPI_MTX_Interpreter",
102 "ACPI_MTX_Parser", 102 "ACPI_MTX_Parser",
@@ -115,34 +115,28 @@ static char *acpi_gbl_mutex_names[] =
115#endif 115#endif
116#endif 116#endif
117 117
118/* Owner IDs are used to track namespace nodes for selective deletion */
118 119
119/* Table for the global mutexes */ 120typedef u8 acpi_owner_id;
121#define ACPI_OWNER_ID_MAX 0xFF
120 122
121struct acpi_mutex_info 123/* This Thread ID means that the mutex is not in use (unlocked) */
122{
123 acpi_mutex mutex;
124 u32 use_count;
125 u32 owner_id;
126};
127 124
128/* This owner ID means that the mutex is not in use (unlocked) */ 125#define ACPI_MUTEX_NOT_ACQUIRED (u32) -1
129 126
130#define ACPI_MUTEX_NOT_ACQUIRED (u32) (-1) 127/* Table for the global mutexes */
131 128
129struct acpi_mutex_info {
130 acpi_mutex mutex;
131 u32 use_count;
132 u32 thread_id;
133};
132 134
133/* Lock flag parameter for various interfaces */ 135/* Lock flag parameter for various interfaces */
134 136
135#define ACPI_MTX_DO_NOT_LOCK 0 137#define ACPI_MTX_DO_NOT_LOCK 0
136#define ACPI_MTX_LOCK 1 138#define ACPI_MTX_LOCK 1
137 139
138
139typedef u16 acpi_owner_id;
140#define ACPI_OWNER_TYPE_TABLE 0x0
141#define ACPI_OWNER_TYPE_METHOD 0x1
142#define ACPI_FIRST_METHOD_ID 0x0001
143#define ACPI_FIRST_TABLE_ID 0xF000
144
145
146/* Field access granularities */ 140/* Field access granularities */
147 141
148#define ACPI_FIELD_BYTE_GRANULARITY 1 142#define ACPI_FIELD_BYTE_GRANULARITY 1
@@ -150,7 +144,6 @@ typedef u16 acpi_owner_id;
150#define ACPI_FIELD_DWORD_GRANULARITY 4 144#define ACPI_FIELD_DWORD_GRANULARITY 4
151#define ACPI_FIELD_QWORD_GRANULARITY 8 145#define ACPI_FIELD_QWORD_GRANULARITY 8
152 146
153
154/***************************************************************************** 147/*****************************************************************************
155 * 148 *
156 * Namespace typedefs and structs 149 * Namespace typedefs and structs
@@ -159,15 +152,12 @@ typedef u16 acpi_owner_id;
159 152
160/* Operational modes of the AML interpreter/scanner */ 153/* Operational modes of the AML interpreter/scanner */
161 154
162typedef enum 155typedef enum {
163{ 156 ACPI_IMODE_LOAD_PASS1 = 0x01,
164 ACPI_IMODE_LOAD_PASS1 = 0x01, 157 ACPI_IMODE_LOAD_PASS2 = 0x02,
165 ACPI_IMODE_LOAD_PASS2 = 0x02, 158 ACPI_IMODE_EXECUTE = 0x0E
166 ACPI_IMODE_EXECUTE = 0x0E
167
168} acpi_interpreter_mode; 159} acpi_interpreter_mode;
169 160
170
171/* 161/*
172 * The Node describes a named object that appears in the AML 162 * The Node describes a named object that appears in the AML
173 * An acpi_node is used to store Nodes. 163 * An acpi_node is used to store Nodes.
@@ -175,34 +165,37 @@ typedef enum
175 * data_type is used to differentiate between internal descriptors, and MUST 165 * data_type is used to differentiate between internal descriptors, and MUST
176 * be the first byte in this structure. 166 * be the first byte in this structure.
177 */ 167 */
178union acpi_name_union 168union acpi_name_union {
179{ 169 u32 integer;
180 u32 integer; 170 char ascii[4];
181 char ascii[4]; 171};
182}; 172
183 173struct acpi_namespace_node {
184struct acpi_namespace_node 174 u8 descriptor; /* Used to differentiate object descriptor types */
185{ 175 u8 type; /* Type associated with this name */
186 u8 descriptor; /* Used to differentiate object descriptor types */ 176 u16 reference_count; /* Current count of references and children */
187 u8 type; /* Type associated with this name */ 177 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
188 u16 owner_id; 178 union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */
189 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ 179 struct acpi_namespace_node *child; /* First child */
190 union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */ 180 struct acpi_namespace_node *peer; /* Next peer */
191 struct acpi_namespace_node *child; /* First child */ 181 u8 owner_id; /* Who created this node */
192 struct acpi_namespace_node *peer; /* Next peer*/ 182 u8 flags;
193 u16 reference_count; /* Current count of references and children */ 183
194 u8 flags; 184 /* Fields used by the ASL compiler only */
185
186#ifdef ACPI_ASL_COMPILER
187 u32 value;
188 union acpi_parse_object *op;
189#endif
195}; 190};
196 191
197
198#define ACPI_ENTRY_NOT_FOUND NULL 192#define ACPI_ENTRY_NOT_FOUND NULL
199 193
200
201/* Node flags */ 194/* Node flags */
202 195
203#define ANOBJ_RESERVED 0x01 196#define ANOBJ_RESERVED 0x01
204#define ANOBJ_END_OF_PEER_LIST 0x02 197#define ANOBJ_END_OF_PEER_LIST 0x02
205#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ 198#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */
206#define ANOBJ_METHOD_ARG 0x08 199#define ANOBJ_METHOD_ARG 0x08
207#define ANOBJ_METHOD_LOCAL 0x10 200#define ANOBJ_METHOD_LOCAL 0x10
208#define ANOBJ_METHOD_NO_RETVAL 0x20 201#define ANOBJ_METHOD_NO_RETVAL 0x20
@@ -212,91 +205,77 @@ struct acpi_namespace_node
212/* 205/*
213 * ACPI Table Descriptor. One per ACPI table 206 * ACPI Table Descriptor. One per ACPI table
214 */ 207 */
215struct acpi_table_desc 208struct acpi_table_desc {
216{ 209 struct acpi_table_desc *prev;
217 struct acpi_table_desc *prev; 210 struct acpi_table_desc *next;
218 struct acpi_table_desc *next; 211 struct acpi_table_desc *installed_desc;
219 struct acpi_table_desc *installed_desc; 212 struct acpi_table_header *pointer;
220 struct acpi_table_header *pointer; 213 u8 *aml_start;
221 u8 *aml_start; 214 u64 physical_address;
222 u64 physical_address; 215 u32 aml_length;
223 u32 aml_length; 216 acpi_size length;
224 acpi_size length; 217 acpi_owner_id owner_id;
225 acpi_owner_id table_id; 218 u8 type;
226 u8 type; 219 u8 allocation;
227 u8 allocation; 220 u8 loaded_into_namespace;
228 u8 loaded_into_namespace;
229}; 221};
230 222
231struct acpi_table_list 223struct acpi_table_list {
232{ 224 struct acpi_table_desc *next;
233 struct acpi_table_desc *next; 225 u32 count;
234 u32 count;
235}; 226};
236 227
237 228struct acpi_find_context {
238struct acpi_find_context 229 char *search_for;
239{ 230 acpi_handle *list;
240 char *search_for; 231 u32 *count;
241 acpi_handle *list;
242 u32 *count;
243}; 232};
244 233
245 234struct acpi_ns_search_data {
246struct acpi_ns_search_data 235 struct acpi_namespace_node *node;
247{
248 struct acpi_namespace_node *node;
249}; 236};
250 237
251
252/* 238/*
253 * Predefined Namespace items 239 * Predefined Namespace items
254 */ 240 */
255struct acpi_predefined_names 241struct acpi_predefined_names {
256{ 242 char *name;
257 char *name; 243 u8 type;
258 u8 type; 244 char *val;
259 char *val;
260}; 245};
261 246
262
263/* Object types used during package copies */ 247/* Object types used during package copies */
264 248
265
266#define ACPI_COPY_TYPE_SIMPLE 0 249#define ACPI_COPY_TYPE_SIMPLE 0
267#define ACPI_COPY_TYPE_PACKAGE 1 250#define ACPI_COPY_TYPE_PACKAGE 1
268 251
269/* Info structure used to convert external<->internal namestrings */ 252/* Info structure used to convert external<->internal namestrings */
270 253
271struct acpi_namestring_info 254struct acpi_namestring_info {
272{ 255 char *external_name;
273 char *external_name; 256 char *next_external_char;
274 char *next_external_char; 257 char *internal_name;
275 char *internal_name; 258 u32 length;
276 u32 length; 259 u32 num_segments;
277 u32 num_segments; 260 u32 num_carats;
278 u32 num_carats; 261 u8 fully_qualified;
279 u8 fully_qualified;
280}; 262};
281 263
282
283/* Field creation info */ 264/* Field creation info */
284 265
285struct acpi_create_field_info 266struct acpi_create_field_info {
286{ 267 struct acpi_namespace_node *region_node;
287 struct acpi_namespace_node *region_node; 268 struct acpi_namespace_node *field_node;
288 struct acpi_namespace_node *field_node; 269 struct acpi_namespace_node *register_node;
289 struct acpi_namespace_node *register_node; 270 struct acpi_namespace_node *data_register_node;
290 struct acpi_namespace_node *data_register_node; 271 u32 bank_value;
291 u32 bank_value; 272 u32 field_bit_position;
292 u32 field_bit_position; 273 u32 field_bit_length;
293 u32 field_bit_length; 274 u8 field_flags;
294 u8 field_flags; 275 u8 attribute;
295 u8 attribute; 276 u8 field_type;
296 u8 field_type;
297}; 277};
298 278
299
300/***************************************************************************** 279/*****************************************************************************
301 * 280 *
302 * Event typedefs and structs 281 * Event typedefs and structs
@@ -305,108 +284,95 @@ struct acpi_create_field_info
305 284
306/* Dispatch info for each GPE -- either a method or handler, cannot be both */ 285/* Dispatch info for each GPE -- either a method or handler, cannot be both */
307 286
308struct acpi_handler_info 287struct acpi_handler_info {
309{ 288 acpi_event_handler address; /* Address of handler, if any */
310 acpi_event_handler address; /* Address of handler, if any */ 289 void *context; /* Context to be passed to handler */
311 void *context; /* Context to be passed to handler */ 290 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
312 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
313}; 291};
314 292
315union acpi_gpe_dispatch_info 293union acpi_gpe_dispatch_info {
316{ 294 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
317 struct acpi_namespace_node *method_node; /* Method node for this GPE level */ 295 struct acpi_handler_info *handler;
318 struct acpi_handler_info *handler;
319}; 296};
320 297
321/* 298/*
322 * Information about a GPE, one per each GPE in an array. 299 * Information about a GPE, one per each GPE in an array.
323 * NOTE: Important to keep this struct as small as possible. 300 * NOTE: Important to keep this struct as small as possible.
324 */ 301 */
325struct acpi_gpe_event_info 302struct acpi_gpe_event_info {
326{ 303 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
327 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ 304 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
328 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ 305 u8 flags; /* Misc info about this GPE */
329 u8 flags; /* Misc info about this GPE */ 306 u8 register_bit; /* This GPE bit within the register */
330 u8 register_bit; /* This GPE bit within the register */
331}; 307};
332 308
333/* Information about a GPE register pair, one per each status/enable pair in an array */ 309/* Information about a GPE register pair, one per each status/enable pair in an array */
334 310
335struct acpi_gpe_register_info 311struct acpi_gpe_register_info {
336{ 312 struct acpi_generic_address status_address; /* Address of status reg */
337 struct acpi_generic_address status_address; /* Address of status reg */ 313 struct acpi_generic_address enable_address; /* Address of enable reg */
338 struct acpi_generic_address enable_address; /* Address of enable reg */ 314 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
339 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ 315 u8 enable_for_run; /* GPEs to keep enabled when running */
340 u8 enable_for_run; /* GPEs to keep enabled when running */ 316 u8 base_gpe_number; /* Base GPE number for this register */
341 u8 base_gpe_number; /* Base GPE number for this register */
342}; 317};
343 318
344/* 319/*
345 * Information about a GPE register block, one per each installed block -- 320 * Information about a GPE register block, one per each installed block --
346 * GPE0, GPE1, and one per each installed GPE Block Device. 321 * GPE0, GPE1, and one per each installed GPE Block Device.
347 */ 322 */
348struct acpi_gpe_block_info 323struct acpi_gpe_block_info {
349{ 324 struct acpi_namespace_node *node;
350 struct acpi_namespace_node *node; 325 struct acpi_gpe_block_info *previous;
351 struct acpi_gpe_block_info *previous; 326 struct acpi_gpe_block_info *next;
352 struct acpi_gpe_block_info *next; 327 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
353 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ 328 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
354 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ 329 struct acpi_gpe_event_info *event_info; /* One for each GPE */
355 struct acpi_gpe_event_info *event_info; /* One for each GPE */ 330 struct acpi_generic_address block_address; /* Base address of the block */
356 struct acpi_generic_address block_address; /* Base address of the block */ 331 u32 register_count; /* Number of register pairs in block */
357 u32 register_count; /* Number of register pairs in block */ 332 u8 block_base_number; /* Base GPE number for this block */
358 u8 block_base_number;/* Base GPE number for this block */
359}; 333};
360 334
361/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ 335/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
362 336
363struct acpi_gpe_xrupt_info 337struct acpi_gpe_xrupt_info {
364{ 338 struct acpi_gpe_xrupt_info *previous;
365 struct acpi_gpe_xrupt_info *previous; 339 struct acpi_gpe_xrupt_info *next;
366 struct acpi_gpe_xrupt_info *next; 340 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
367 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ 341 u32 interrupt_number; /* System interrupt number */
368 u32 interrupt_level; /* System interrupt level */
369}; 342};
370 343
371 344struct acpi_gpe_walk_info {
372struct acpi_gpe_walk_info 345 struct acpi_namespace_node *gpe_device;
373{ 346 struct acpi_gpe_block_info *gpe_block;
374 struct acpi_namespace_node *gpe_device;
375 struct acpi_gpe_block_info *gpe_block;
376}; 347};
377 348
378 349typedef acpi_status(*ACPI_GPE_CALLBACK) (struct acpi_gpe_xrupt_info *
379typedef acpi_status (*ACPI_GPE_CALLBACK) ( 350 gpe_xrupt_info,
380 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 351 struct acpi_gpe_block_info *
381 struct acpi_gpe_block_info *gpe_block); 352 gpe_block);
382
383 353
384/* Information about each particular fixed event */ 354/* Information about each particular fixed event */
385 355
386struct acpi_fixed_event_handler 356struct acpi_fixed_event_handler {
387{ 357 acpi_event_handler handler; /* Address of handler. */
388 acpi_event_handler handler; /* Address of handler. */ 358 void *context; /* Context to be passed to handler */
389 void *context; /* Context to be passed to handler */
390}; 359};
391 360
392struct acpi_fixed_event_info 361struct acpi_fixed_event_info {
393{ 362 u8 status_register_id;
394 u8 status_register_id; 363 u8 enable_register_id;
395 u8 enable_register_id; 364 u16 status_bit_mask;
396 u16 status_bit_mask; 365 u16 enable_bit_mask;
397 u16 enable_bit_mask;
398}; 366};
399 367
400/* Information used during field processing */ 368/* Information used during field processing */
401 369
402struct acpi_field_info 370struct acpi_field_info {
403{ 371 u8 skip_field;
404 u8 skip_field; 372 u8 field_flag;
405 u8 field_flag; 373 u32 pkg_length;
406 u32 pkg_length;
407}; 374};
408 375
409
410/***************************************************************************** 376/*****************************************************************************
411 * 377 *
412 * Generic "state" object for stacks 378 * Generic "state" object for stacks
@@ -419,14 +385,6 @@ struct acpi_field_info
419#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 385#define ACPI_CONTROL_PREDICATE_FALSE 0xC3
420#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 386#define ACPI_CONTROL_PREDICATE_TRUE 0xC4
421 387
422
423/* Forward declarations */
424
425struct acpi_walk_state ;
426struct acpi_obj_mutex;
427union acpi_parse_object ;
428
429
430#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ 388#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\
431 u8 data_type; /* To differentiate various internal objs */\ 389 u8 data_type; /* To differentiate various internal objs */\
432 u8 flags; \ 390 u8 flags; \
@@ -435,147 +393,112 @@ union acpi_parse_object ;
435 u16 reserved; \ 393 u16 reserved; \
436 void *next; \ 394 void *next; \
437 395
438struct acpi_common_state 396struct acpi_common_state {
439{ 397ACPI_STATE_COMMON};
440 ACPI_STATE_COMMON
441};
442
443 398
444/* 399/*
445 * Update state - used to traverse complex objects such as packages 400 * Update state - used to traverse complex objects such as packages
446 */ 401 */
447struct acpi_update_state 402struct acpi_update_state {
448{ 403 ACPI_STATE_COMMON union acpi_operand_object *object;
449 ACPI_STATE_COMMON
450 union acpi_operand_object *object;
451}; 404};
452 405
453
454/* 406/*
455 * Pkg state - used to traverse nested package structures 407 * Pkg state - used to traverse nested package structures
456 */ 408 */
457struct acpi_pkg_state 409struct acpi_pkg_state {
458{ 410 ACPI_STATE_COMMON union acpi_operand_object *source_object;
459 ACPI_STATE_COMMON 411 union acpi_operand_object *dest_object;
460 union acpi_operand_object *source_object; 412 struct acpi_walk_state *walk_state;
461 union acpi_operand_object *dest_object; 413 void *this_target_obj;
462 struct acpi_walk_state *walk_state; 414 u32 num_packages;
463 void *this_target_obj; 415 u16 index;
464 u32 num_packages;
465 u16 index;
466}; 416};
467 417
468
469/* 418/*
470 * Control state - one per if/else and while constructs. 419 * Control state - one per if/else and while constructs.
471 * Allows nesting of these constructs 420 * Allows nesting of these constructs
472 */ 421 */
473struct acpi_control_state 422struct acpi_control_state {
474{ 423 ACPI_STATE_COMMON union acpi_parse_object *predicate_op;
475 ACPI_STATE_COMMON 424 u8 *aml_predicate_start; /* Start of if/while predicate */
476 union acpi_parse_object *predicate_op; 425 u8 *package_end; /* End of if/while block */
477 u8 *aml_predicate_start; /* Start of if/while predicate */ 426 u16 opcode;
478 u8 *package_end; /* End of if/while block */
479 u16 opcode;
480}; 427};
481 428
482
483/* 429/*
484 * Scope state - current scope during namespace lookups 430 * Scope state - current scope during namespace lookups
485 */ 431 */
486struct acpi_scope_state 432struct acpi_scope_state {
487{ 433 ACPI_STATE_COMMON struct acpi_namespace_node *node;
488 ACPI_STATE_COMMON
489 struct acpi_namespace_node *node;
490}; 434};
491 435
492 436struct acpi_pscope_state {
493struct acpi_pscope_state 437 ACPI_STATE_COMMON union acpi_parse_object *op; /* Current op being parsed */
494{ 438 u8 *arg_end; /* Current argument end */
495 ACPI_STATE_COMMON 439 u8 *pkg_end; /* Current package end */
496 union acpi_parse_object *op; /* Current op being parsed */ 440 u32 arg_list; /* Next argument to parse */
497 u8 *arg_end; /* Current argument end */ 441 u32 arg_count; /* Number of fixed arguments */
498 u8 *pkg_end; /* Current package end */
499 u32 arg_list; /* Next argument to parse */
500 u32 arg_count; /* Number of fixed arguments */
501}; 442};
502 443
503
504/* 444/*
505 * Thread state - one per thread across multiple walk states. Multiple walk 445 * Thread state - one per thread across multiple walk states. Multiple walk
506 * states are created when there are nested control methods executing. 446 * states are created when there are nested control methods executing.
507 */ 447 */
508struct acpi_thread_state 448struct acpi_thread_state {
509{ 449 ACPI_STATE_COMMON struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
510 ACPI_STATE_COMMON 450 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
511 struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ 451 u32 thread_id; /* Running thread ID */
512 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ 452 u8 current_sync_level; /* Mutex Sync (nested acquire) level */
513 u32 thread_id; /* Running thread ID */
514 u8 current_sync_level; /* Mutex Sync (nested acquire) level */
515}; 453};
516 454
517
518/* 455/*
519 * Result values - used to accumulate the results of nested 456 * Result values - used to accumulate the results of nested
520 * AML arguments 457 * AML arguments
521 */ 458 */
522struct acpi_result_values 459struct acpi_result_values {
523{
524 ACPI_STATE_COMMON 460 ACPI_STATE_COMMON
525 union acpi_operand_object *obj_desc [ACPI_OBJ_NUM_OPERANDS]; 461 union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS];
526 u8 num_results; 462 u8 num_results;
527 u8 last_insert; 463 u8 last_insert;
528}; 464};
529 465
530
531typedef
532acpi_status (*acpi_parse_downwards) (
533 struct acpi_walk_state *walk_state,
534 union acpi_parse_object **out_op);
535
536typedef 466typedef
537acpi_status (*acpi_parse_upwards) ( 467acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
538 struct acpi_walk_state *walk_state); 468 union acpi_parse_object ** out_op);
539 469
470typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
540 471
541/* 472/*
542 * Notify info - used to pass info to the deferred notify 473 * Notify info - used to pass info to the deferred notify
543 * handler/dispatcher. 474 * handler/dispatcher.
544 */ 475 */
545struct acpi_notify_info 476struct acpi_notify_info {
546{ 477 ACPI_STATE_COMMON struct acpi_namespace_node *node;
547 ACPI_STATE_COMMON 478 union acpi_operand_object *handler_obj;
548 struct acpi_namespace_node *node;
549 union acpi_operand_object *handler_obj;
550}; 479};
551 480
552
553/* Generic state is union of structs above */ 481/* Generic state is union of structs above */
554 482
555union acpi_generic_state 483union acpi_generic_state {
556{ 484 struct acpi_common_state common;
557 struct acpi_common_state common; 485 struct acpi_control_state control;
558 struct acpi_control_state control; 486 struct acpi_update_state update;
559 struct acpi_update_state update; 487 struct acpi_scope_state scope;
560 struct acpi_scope_state scope; 488 struct acpi_pscope_state parse_scope;
561 struct acpi_pscope_state parse_scope; 489 struct acpi_pkg_state pkg;
562 struct acpi_pkg_state pkg; 490 struct acpi_thread_state thread;
563 struct acpi_thread_state thread; 491 struct acpi_result_values results;
564 struct acpi_result_values results; 492 struct acpi_notify_info notify;
565 struct acpi_notify_info notify;
566}; 493};
567 494
568
569/***************************************************************************** 495/*****************************************************************************
570 * 496 *
571 * Interpreter typedefs and structs 497 * Interpreter typedefs and structs
572 * 498 *
573 ****************************************************************************/ 499 ****************************************************************************/
574 500
575typedef 501typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
576acpi_status (*ACPI_EXECUTE_OP) (
577 struct acpi_walk_state *walk_state);
578
579 502
580/***************************************************************************** 503/*****************************************************************************
581 * 504 *
@@ -586,28 +509,26 @@ acpi_status (*ACPI_EXECUTE_OP) (
586/* 509/*
587 * AML opcode, name, and argument layout 510 * AML opcode, name, and argument layout
588 */ 511 */
589struct acpi_opcode_info 512struct acpi_opcode_info {
590{
591#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) 513#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
592 char *name; /* Opcode name (disassembler/debug only) */ 514 char *name; /* Opcode name (disassembler/debug only) */
593#endif 515#endif
594 u32 parse_args; /* Grammar/Parse time arguments */ 516 u32 parse_args; /* Grammar/Parse time arguments */
595 u32 runtime_args; /* Interpret time arguments */ 517 u32 runtime_args; /* Interpret time arguments */
596 u32 flags; /* Misc flags */ 518 u32 flags; /* Misc flags */
597 u8 object_type; /* Corresponding internal object type */ 519 u8 object_type; /* Corresponding internal object type */
598 u8 class; /* Opcode class */ 520 u8 class; /* Opcode class */
599 u8 type; /* Opcode type */ 521 u8 type; /* Opcode type */
600}; 522};
601 523
602union acpi_parse_value 524union acpi_parse_value {
603{ 525 acpi_integer integer; /* Integer constant (Up to 64 bits) */
604 acpi_integer integer; /* Integer constant (Up to 64 bits) */ 526 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
605 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ 527 u32 size; /* bytelist or field size */
606 u32 size; /* bytelist or field size */ 528 char *string; /* NULL terminated string */
607 char *string; /* NULL terminated string */ 529 u8 *buffer; /* buffer or string */
608 u8 *buffer; /* buffer or string */ 530 char *name; /* NULL terminated string */
609 char *name; /* NULL terminated string */ 531 union acpi_parse_object *arg; /* arguments and contained ops */
610 union acpi_parse_object *arg; /* arguments and contained ops */
611}; 532};
612 533
613#define ACPI_PARSE_COMMON \ 534#define ACPI_PARSE_COMMON \
@@ -636,84 +557,72 @@ union acpi_parse_value
636/* 557/*
637 * generic operation (for example: If, While, Store) 558 * generic operation (for example: If, While, Store)
638 */ 559 */
639struct acpi_parse_obj_common 560struct acpi_parse_obj_common {
640{ 561ACPI_PARSE_COMMON};
641 ACPI_PARSE_COMMON
642};
643
644 562
645/* 563/*
646 * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions), 564 * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
647 * and bytelists. 565 * and bytelists.
648 */ 566 */
649struct acpi_parse_obj_named 567struct acpi_parse_obj_named {
650{ 568 ACPI_PARSE_COMMON u8 * path;
651 ACPI_PARSE_COMMON 569 u8 *data; /* AML body or bytelist data */
652 u8 *path; 570 u32 length; /* AML length */
653 u8 *data; /* AML body or bytelist data */ 571 u32 name; /* 4-byte name or zero if no name */
654 u32 length; /* AML length */
655 u32 name; /* 4-byte name or zero if no name */
656}; 572};
657 573
658
659/* The parse node is the fundamental element of the parse tree */ 574/* The parse node is the fundamental element of the parse tree */
660 575
661struct acpi_parse_obj_asl 576struct acpi_parse_obj_asl {
662{ 577 ACPI_PARSE_COMMON union acpi_parse_object *child;
663 ACPI_PARSE_COMMON 578 union acpi_parse_object *parent_method;
664 union acpi_parse_object *child; 579 char *filename;
665 union acpi_parse_object *parent_method; 580 char *external_name;
666 char *filename; 581 char *namepath;
667 char *external_name; 582 char name_seg[4];
668 char *namepath; 583 u32 extra_value;
669 char name_seg[4]; 584 u32 column;
670 u32 extra_value; 585 u32 line_number;
671 u32 column; 586 u32 logical_line_number;
672 u32 line_number; 587 u32 logical_byte_offset;
673 u32 logical_line_number; 588 u32 end_line;
674 u32 logical_byte_offset; 589 u32 end_logical_line;
675 u32 end_line; 590 u32 acpi_btype;
676 u32 end_logical_line; 591 u32 aml_length;
677 u32 acpi_btype; 592 u32 aml_subtree_length;
678 u32 aml_length; 593 u32 final_aml_length;
679 u32 aml_subtree_length; 594 u32 final_aml_offset;
680 u32 final_aml_length; 595 u32 compile_flags;
681 u32 final_aml_offset; 596 u16 parse_opcode;
682 u32 compile_flags; 597 u8 aml_opcode_length;
683 u16 parse_opcode; 598 u8 aml_pkg_len_bytes;
684 u8 aml_opcode_length; 599 u8 extra;
685 u8 aml_pkg_len_bytes; 600 char parse_op_name[12];
686 u8 extra; 601};
687 char parse_op_name[12]; 602
688}; 603union acpi_parse_object {
689 604 struct acpi_parse_obj_common common;
690union acpi_parse_object 605 struct acpi_parse_obj_named named;
691{ 606 struct acpi_parse_obj_asl asl;
692 struct acpi_parse_obj_common common;
693 struct acpi_parse_obj_named named;
694 struct acpi_parse_obj_asl asl;
695}; 607};
696 608
697
698/* 609/*
699 * Parse state - one state per parser invocation and each control 610 * Parse state - one state per parser invocation and each control
700 * method. 611 * method.
701 */ 612 */
702struct acpi_parse_state 613struct acpi_parse_state {
703{ 614 u32 aml_size;
704 u32 aml_size; 615 u8 *aml_start; /* First AML byte */
705 u8 *aml_start; /* First AML byte */ 616 u8 *aml; /* Next AML byte */
706 u8 *aml; /* Next AML byte */ 617 u8 *aml_end; /* (last + 1) AML byte */
707 u8 *aml_end; /* (last + 1) AML byte */ 618 u8 *pkg_start; /* Current package begin */
708 u8 *pkg_start; /* Current package begin */ 619 u8 *pkg_end; /* Current package end */
709 u8 *pkg_end; /* Current package end */ 620 union acpi_parse_object *start_op; /* Root of parse tree */
710 union acpi_parse_object *start_op; /* Root of parse tree */ 621 struct acpi_namespace_node *start_node;
711 struct acpi_namespace_node *start_node; 622 union acpi_generic_state *scope; /* Current scope */
712 union acpi_generic_state *scope; /* Current scope */ 623 union acpi_parse_object *start_scope;
713 union acpi_parse_object *start_scope;
714}; 624};
715 625
716
717/* Parse object flags */ 626/* Parse object flags */
718 627
719#define ACPI_PARSEOP_GENERIC 0x01 628#define ACPI_PARSEOP_GENERIC 0x01
@@ -729,7 +638,6 @@ struct acpi_parse_state
729#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 638#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
730#define ACPI_PARSEOP_SPECIAL 0x10 639#define ACPI_PARSEOP_SPECIAL 0x10
731 640
732
733/***************************************************************************** 641/*****************************************************************************
734 * 642 *
735 * Hardware (ACPI registers) and PNP 643 * Hardware (ACPI registers) and PNP
@@ -737,15 +645,14 @@ struct acpi_parse_state
737 ****************************************************************************/ 645 ****************************************************************************/
738 646
739#define PCI_ROOT_HID_STRING "PNP0A03" 647#define PCI_ROOT_HID_STRING "PNP0A03"
648#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
740 649
741struct acpi_bit_register_info 650struct acpi_bit_register_info {
742{ 651 u8 parent_register;
743 u8 parent_register; 652 u8 bit_position;
744 u8 bit_position; 653 u16 access_bit_mask;
745 u16 access_bit_mask;
746}; 654};
747 655
748
749/* 656/*
750 * Register IDs 657 * Register IDs
751 * These are the full ACPI registers 658 * These are the full ACPI registers
@@ -760,7 +667,6 @@ struct acpi_bit_register_info
760#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 667#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
761#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 668#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
762 669
763
764/* Masks used to access the bit_registers */ 670/* Masks used to access the bit_registers */
765 671
766#define ACPI_BITMASK_TIMER_STATUS 0x0001 672#define ACPI_BITMASK_TIMER_STATUS 0x0001
@@ -769,7 +675,7 @@ struct acpi_bit_register_info
769#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 675#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
770#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 676#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
771#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 677#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
772#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ 678#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
773#define ACPI_BITMASK_WAKE_STATUS 0x8000 679#define ACPI_BITMASK_WAKE_STATUS 0x8000
774 680
775#define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ 681#define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \
@@ -785,7 +691,7 @@ struct acpi_bit_register_info
785#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 691#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
786#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 692#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
787#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 693#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
788#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ 694#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
789 695
790#define ACPI_BITMASK_SCI_ENABLE 0x0001 696#define ACPI_BITMASK_SCI_ENABLE 0x0001
791#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 697#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
@@ -795,7 +701,6 @@ struct acpi_bit_register_info
795 701
796#define ACPI_BITMASK_ARB_DISABLE 0x0001 702#define ACPI_BITMASK_ARB_DISABLE 0x0001
797 703
798
799/* Raw bit position of each bit_register */ 704/* Raw bit position of each bit_register */
800 705
801#define ACPI_BITPOSITION_TIMER_STATUS 0x00 706#define ACPI_BITPOSITION_TIMER_STATUS 0x00
@@ -804,7 +709,7 @@ struct acpi_bit_register_info
804#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 709#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
805#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 710#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
806#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A 711#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
807#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ 712#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
808#define ACPI_BITPOSITION_WAKE_STATUS 0x0F 713#define ACPI_BITPOSITION_WAKE_STATUS 0x0F
809 714
810#define ACPI_BITPOSITION_TIMER_ENABLE 0x00 715#define ACPI_BITPOSITION_TIMER_ENABLE 0x00
@@ -812,7 +717,7 @@ struct acpi_bit_register_info
812#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 717#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
813#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 718#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
814#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A 719#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
815#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ 720#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
816 721
817#define ACPI_BITPOSITION_SCI_ENABLE 0x00 722#define ACPI_BITPOSITION_SCI_ENABLE 0x00
818#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 723#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
@@ -822,7 +727,6 @@ struct acpi_bit_register_info
822 727
823#define ACPI_BITPOSITION_ARB_DISABLE 0x00 728#define ACPI_BITPOSITION_ARB_DISABLE 0x00
824 729
825
826/***************************************************************************** 730/*****************************************************************************
827 * 731 *
828 * Resource descriptors 732 * Resource descriptors
@@ -841,8 +745,7 @@ struct acpi_bit_register_info
841#define ACPI_RDESC_TYPE_SMALL 0x00 745#define ACPI_RDESC_TYPE_SMALL 0x00
842 746
843#define ACPI_RDESC_TYPE_MASK 0x80 747#define ACPI_RDESC_TYPE_MASK 0x80
844#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ 748#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */
845
846 749
847/* 750/*
848 * Small resource descriptor types 751 * Small resource descriptor types
@@ -871,7 +774,6 @@ struct acpi_bit_register_info
871#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A 774#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A
872#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B 775#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B
873 776
874
875/***************************************************************************** 777/*****************************************************************************
876 * 778 *
877 * Miscellaneous 779 * Miscellaneous
@@ -880,49 +782,36 @@ struct acpi_bit_register_info
880 782
881#define ACPI_ASCII_ZERO 0x30 783#define ACPI_ASCII_ZERO 0x30
882 784
883
884/***************************************************************************** 785/*****************************************************************************
885 * 786 *
886 * Debugger 787 * Debugger
887 * 788 *
888 ****************************************************************************/ 789 ****************************************************************************/
889 790
890struct acpi_db_method_info 791struct acpi_db_method_info {
891{ 792 acpi_handle thread_gate;
892 acpi_handle thread_gate; 793 char *name;
893 char *name; 794 char **args;
894 char **args; 795 u32 flags;
895 u32 flags; 796 u32 num_loops;
896 u32 num_loops; 797 char pathname[128];
897 char pathname[128];
898}; 798};
899 799
900struct acpi_integrity_info 800struct acpi_integrity_info {
901{ 801 u32 nodes;
902 u32 nodes; 802 u32 objects;
903 u32 objects;
904}; 803};
905 804
906
907#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 805#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
908#define ACPI_DB_CONSOLE_OUTPUT 0x02 806#define ACPI_DB_CONSOLE_OUTPUT 0x02
909#define ACPI_DB_DUPLICATE_OUTPUT 0x03 807#define ACPI_DB_DUPLICATE_OUTPUT 0x03
910 808
911
912/***************************************************************************** 809/*****************************************************************************
913 * 810 *
914 * Debug 811 * Debug
915 * 812 *
916 ****************************************************************************/ 813 ****************************************************************************/
917 814
918struct acpi_debug_print_info
919{
920 u32 component_id;
921 char *proc_name;
922 char *module_name;
923};
924
925
926/* Entry for a memory allocation (debug only) */ 815/* Entry for a memory allocation (debug only) */
927 816
928#define ACPI_MEM_MALLOC 0 817#define ACPI_MEM_MALLOC 0
@@ -938,51 +827,36 @@ struct acpi_debug_print_info
938 char module[ACPI_MAX_MODULE_NAME]; \ 827 char module[ACPI_MAX_MODULE_NAME]; \
939 u8 alloc_type; 828 u8 alloc_type;
940 829
941struct acpi_debug_mem_header 830struct acpi_debug_mem_header {
942{ 831ACPI_COMMON_DEBUG_MEM_HEADER};
943 ACPI_COMMON_DEBUG_MEM_HEADER
944};
945 832
946struct acpi_debug_mem_block 833struct acpi_debug_mem_block {
947{ 834 ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
948 ACPI_COMMON_DEBUG_MEM_HEADER
949 u64 user_space;
950}; 835};
951 836
952
953#define ACPI_MEM_LIST_GLOBAL 0 837#define ACPI_MEM_LIST_GLOBAL 0
954#define ACPI_MEM_LIST_NSNODE 1 838#define ACPI_MEM_LIST_NSNODE 1
839#define ACPI_MEM_LIST_MAX 1
840#define ACPI_NUM_MEM_LISTS 2
955 841
956#define ACPI_MEM_LIST_FIRST_CACHE_LIST 2 842struct acpi_memory_list {
957#define ACPI_MEM_LIST_STATE 2 843 char *list_name;
958#define ACPI_MEM_LIST_PSNODE 3 844 void *list_head;
959#define ACPI_MEM_LIST_PSNODE_EXT 4 845 u16 object_size;
960#define ACPI_MEM_LIST_OPERAND 5 846 u16 max_depth;
961#define ACPI_MEM_LIST_WALK 6 847 u16 current_depth;
962#define ACPI_MEM_LIST_MAX 6 848 u16 link_offset;
963#define ACPI_NUM_MEM_LISTS 7
964
965
966struct acpi_memory_list
967{
968 void *list_head;
969 u16 link_offset;
970 u16 max_cache_depth;
971 u16 cache_depth;
972 u16 object_size;
973 849
974#ifdef ACPI_DBG_TRACK_ALLOCATIONS 850#ifdef ACPI_DBG_TRACK_ALLOCATIONS
975 851
976 /* Statistics for debug memory tracking only */ 852 /* Statistics for debug memory tracking only */
977 853
978 u32 total_allocated; 854 u32 total_allocated;
979 u32 total_freed; 855 u32 total_freed;
980 u32 current_total_size; 856 u32 current_total_size;
981 u32 cache_requests; 857 u32 requests;
982 u32 cache_hits; 858 u32 hits;
983 char *list_name;
984#endif 859#endif
985}; 860};
986 861
987 862#endif /* __ACLOCAL_H__ */
988#endif /* __ACLOCAL_H__ */
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 09be937d2c39..702cc4e57f5f 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -44,7 +44,6 @@
44#ifndef __ACMACROS_H__ 44#ifndef __ACMACROS_H__
45#define __ACMACROS_H__ 45#define __ACMACROS_H__
46 46
47
48/* 47/*
49 * Data manipulation macros 48 * Data manipulation macros
50 */ 49 */
@@ -57,7 +56,6 @@
57#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) 56#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit))
58#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) 57#define ACPI_MIN(a,b) (((a)<(b))?(a):(b))
59 58
60
61#if ACPI_MACHINE_WIDTH == 16 59#if ACPI_MACHINE_WIDTH == 16
62 60
63/* 61/*
@@ -168,7 +166,7 @@
168 166
169/* 32-bit source, 16/32/64 destination */ 167/* 32-bit source, 16/32/64 destination */
170 168
171#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 169#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
172 170
173#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ 171#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
174 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ 172 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
@@ -183,9 +181,9 @@
183 181
184/* 64-bit source, 16/32/64 destination */ 182/* 64-bit source, 16/32/64 destination */
185 183
186#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 184#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
187 185
188#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 186#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */
189 187
190#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\ 188#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
191 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\ 189 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
@@ -219,14 +217,14 @@
219 217
220/* 32-bit source, 16/32/64 destination */ 218/* 32-bit source, 16/32/64 destination */
221 219
222#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 220#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
223#define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s) 221#define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
224#define ACPI_MOVE_32_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) 222#define ACPI_MOVE_32_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s)
225 223
226/* 64-bit source, 16/32/64 destination */ 224/* 64-bit source, 16/32/64 destination */
227 225
228#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 226#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
229#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 227#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */
230#define ACPI_MOVE_64_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) 228#define ACPI_MOVE_64_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s)
231 229
232#else 230#else
@@ -238,14 +236,14 @@
238 236
239/* 32-bit source, 16/32/64 destination */ 237/* 32-bit source, 16/32/64 destination */
240 238
241#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 239#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
242#define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s) 240#define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
243#define ACPI_MOVE_32_TO_64(d,s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s) 241#define ACPI_MOVE_32_TO_64(d,s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
244 242
245/* 64-bit source, 16/32/64 destination */ 243/* 64-bit source, 16/32/64 destination */
246 244
247#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 245#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
248#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 246#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */
249#define ACPI_MOVE_64_TO_64(d,s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s) 247#define ACPI_MOVE_64_TO_64(d,s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
250#endif 248#endif
251 249
@@ -266,7 +264,7 @@
266 264
267/* 32-bit source, 16/32/64 destination */ 265/* 32-bit source, 16/32/64 destination */
268 266
269#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 267#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
270 268
271#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ 269#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
272 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ 270 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
@@ -277,8 +275,8 @@
277 275
278/* 64-bit source, 16/32/64 destination */ 276/* 64-bit source, 16/32/64 destination */
279 277
280#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 278#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
281#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 279#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */
282#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ 280#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
283 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ 281 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
284 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\ 282 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
@@ -305,7 +303,6 @@
305#error unknown ACPI_MACHINE_WIDTH 303#error unknown ACPI_MACHINE_WIDTH
306#endif 304#endif
307 305
308
309/* 306/*
310 * Fast power-of-two math macros for non-optimized compilers 307 * Fast power-of-two math macros for non-optimized compilers
311 */ 308 */
@@ -329,7 +326,6 @@
329#define ACPI_MUL_16(a) _ACPI_MUL(a,4) 326#define ACPI_MUL_16(a) _ACPI_MUL(a,4)
330#define ACPI_MOD_16(a) _ACPI_MOD(a,16) 327#define ACPI_MOD_16(a) _ACPI_MOD(a,16)
331 328
332
333/* 329/*
334 * Rounding macros (Power of two boundaries only) 330 * Rounding macros (Power of two boundaries only)
335 */ 331 */
@@ -344,7 +340,6 @@
344#define ACPI_ROUND_UP_to_64_bITS(a) ACPI_ROUND_UP(a,8) 340#define ACPI_ROUND_UP_to_64_bITS(a) ACPI_ROUND_UP(a,8)
345#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) 341#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
346 342
347
348#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) 343#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
349#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) 344#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
350 345
@@ -365,7 +360,6 @@
365 360
366#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) 361#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
367 362
368
369/* Bitfields within ACPI registers */ 363/* Bitfields within ACPI registers */
370 364
371#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 365#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
@@ -381,7 +375,6 @@
381#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->descriptor_id) 375#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->descriptor_id)
382#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->descriptor_id = t) 376#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->descriptor_id = t)
383 377
384
385/* Macro to test the object type */ 378/* Macro to test the object type */
386 379
387#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type) 380#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type)
@@ -430,28 +423,28 @@
430#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) 423#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
431#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) 424#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
432 425
433
434/* 426/*
435 * Reporting macros that are never compiled out 427 * Reporting macros that are never compiled out
436 */ 428 */
437#define ACPI_PARAM_LIST(pl) pl 429#define ACPI_PARAM_LIST(pl) pl
438 430
439/* 431/*
440 * Error reporting. These versions add callers module and line#. Since 432 * Error reporting. These versions add callers module and line#.
441 * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only 433 *
442 * use it in debug mode. 434 * Since _acpi_module_name gets compiled out when ACPI_DEBUG_OUTPUT
435 * isn't defined, only use it in debug mode.
443 */ 436 */
444#ifdef ACPI_DEBUG_OUTPUT 437#ifdef ACPI_DEBUG_OUTPUT
445 438
446#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \ 439#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_acpi_module_name,__LINE__,_COMPONENT); \
447 acpi_os_printf ACPI_PARAM_LIST(fp);} 440 acpi_os_printf ACPI_PARAM_LIST(fp);}
448#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \ 441#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_acpi_module_name,__LINE__,_COMPONENT); \
449 acpi_os_printf ACPI_PARAM_LIST(fp);} 442 acpi_os_printf ACPI_PARAM_LIST(fp);}
450#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \ 443#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_acpi_module_name,__LINE__,_COMPONENT); \
451 acpi_os_printf ACPI_PARAM_LIST(fp);} 444 acpi_os_printf ACPI_PARAM_LIST(fp);}
452#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_THIS_MODULE,__LINE__,_COMPONENT, s, e); 445#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_acpi_module_name,__LINE__,_COMPONENT, s, e);
453 446
454#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e); 447#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_acpi_module_name,__LINE__,_COMPONENT, s, n, p, e);
455 448
456#else 449#else
457 450
@@ -480,36 +473,58 @@
480 * Debug macros that are conditionally compiled 473 * Debug macros that are conditionally compiled
481 */ 474 */
482#ifdef ACPI_DEBUG_OUTPUT 475#ifdef ACPI_DEBUG_OUTPUT
476#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name;
483 477
484#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_THIS_MODULE = name; 478/*
479 * Common parameters used for debug output functions:
480 * line number, function name, module(file) name, component ID
481 */
482#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
485 483
486/* 484/*
487 * Function entry tracing. 485 * Function entry tracing
488 * The first parameter should be the procedure name as a quoted string. This is declared 486 */
489 * as a local string ("_proc_name) so that it can be also used by the function exit macros below. 487
488/*
489 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
490 * define it now. This is the case where there the compiler does not support
491 * a __FUNCTION__ macro or equivalent. We save the function name on the
492 * local stack.
493 */
494#ifndef ACPI_GET_FUNCTION_NAME
495#define ACPI_GET_FUNCTION_NAME _acpi_function_name
496/*
497 * The Name parameter should be the procedure name as a quoted string.
498 * This is declared as a local string ("my_function_name") so that it can
499 * be also used by the function exit macros below.
500 * Note: (const char) is used to be compatible with the debug interfaces
501 * and macros such as __FUNCTION__.
490 */ 502 */
491#define ACPI_FUNCTION_NAME(a) struct acpi_debug_print_info _debug_info; \ 503#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = name;
492 _debug_info.component_id = _COMPONENT; \ 504
493 _debug_info.proc_name = a; \ 505#else
494 _debug_info.module_name = _THIS_MODULE; 506/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
495 507
496#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 508#define ACPI_FUNCTION_NAME(name)
497 acpi_ut_trace(__LINE__,&_debug_info) 509#endif
498#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 510
499 acpi_ut_trace_ptr(__LINE__,&_debug_info,(void *)b) 511#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
500#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 512 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
501 acpi_ut_trace_u32(__LINE__,&_debug_info,(u32)b) 513#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
502#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ 514 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b)
503 acpi_ut_trace_str(__LINE__,&_debug_info,(char *)b) 515#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \
504 516 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b)
505#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() 517#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \
518 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b)
519
520#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
506 521
507/* 522/*
508 * Function exit tracing. 523 * Function exit tracing.
509 * WARNING: These macros include a return statement. This is usually considered 524 * WARNING: These macros include a return statement. This is usually considered
510 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 525 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
511 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 526 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
512 * so that "_proc_name" is defined. 527 * so that "_acpi_function_name" is defined.
513 */ 528 */
514#ifdef ACPI_USE_DO_WHILE_0 529#ifdef ACPI_USE_DO_WHILE_0
515#define ACPI_DO_WHILE0(a) do a while(0) 530#define ACPI_DO_WHILE0(a) do a while(0)
@@ -517,10 +532,10 @@
517#define ACPI_DO_WHILE0(a) a 532#define ACPI_DO_WHILE0(a) a
518#endif 533#endif
519 534
520#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(__LINE__,&_debug_info);return;}) 535#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;})
521#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(__LINE__,&_debug_info,(s));return((s));}) 536#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));})
522#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(__LINE__,&_debug_info,(acpi_integer)(s));return((s));}) 537#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));})
523#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(__LINE__,&_debug_info,(u8 *)(s));return((s));}) 538#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));})
524 539
525/* Conditional execution */ 540/* Conditional execution */
526 541
@@ -531,12 +546,10 @@
531#define ACPI_DEBUG_ONLY_MEMBERS(a) a; 546#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
532#define _VERBOSE_STRUCTURES 547#define _VERBOSE_STRUCTURES
533 548
534
535/* Stack and buffer dumping */ 549/* Stack and buffer dumping */
536 550
537#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0) 551#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0)
538#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) 552#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__)
539
540 553
541#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) 554#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b)
542#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) 555#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d)
@@ -544,7 +557,6 @@
544#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) 557#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
545#define ACPI_BREAK_MSG(a) acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a)) 558#define ACPI_BREAK_MSG(a) acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
546 559
547
548/* 560/*
549 * Generate INT3 on ACPI_ERROR (Debug only!) 561 * Generate INT3 on ACPI_ERROR (Debug only!)
550 */ 562 */
@@ -565,14 +577,13 @@
565#define ACPI_DEBUG_PRINT(pl) acpi_ut_debug_print ACPI_PARAM_LIST(pl) 577#define ACPI_DEBUG_PRINT(pl) acpi_ut_debug_print ACPI_PARAM_LIST(pl)
566#define ACPI_DEBUG_PRINT_RAW(pl) acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl) 578#define ACPI_DEBUG_PRINT_RAW(pl) acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl)
567 579
568
569#else 580#else
570/* 581/*
571 * This is the non-debug case -- make everything go away, 582 * This is the non-debug case -- make everything go away,
572 * leaving no executable debug code! 583 * leaving no executable debug code!
573 */ 584 */
574#define ACPI_MODULE_NAME(name) 585#define ACPI_MODULE_NAME(name)
575#define _THIS_MODULE "" 586#define _acpi_module_name ""
576 587
577#define ACPI_DEBUG_EXEC(a) 588#define ACPI_DEBUG_EXEC(a)
578#define ACPI_NORMAL_EXEC(a) a; 589#define ACPI_NORMAL_EXEC(a) a;
@@ -616,7 +627,6 @@
616#define ACPI_DEBUGGER_EXEC(a) 627#define ACPI_DEBUGGER_EXEC(a)
617#endif 628#endif
618 629
619
620/* 630/*
621 * For 16-bit code, we want to shrink some things even though 631 * For 16-bit code, we want to shrink some things even though
622 * we are using ACPI_DEBUG_OUTPUT to get the debug output 632 * we are using ACPI_DEBUG_OUTPUT to get the debug output
@@ -627,7 +637,6 @@
627#define ACPI_DEBUG_ONLY_MEMBERS(a) 637#define ACPI_DEBUG_ONLY_MEMBERS(a)
628#endif 638#endif
629 639
630
631#ifdef ACPI_DEBUG_OUTPUT 640#ifdef ACPI_DEBUG_OUTPUT
632/* 641/*
633 * 1) Set name to blanks 642 * 1) Set name to blanks
@@ -640,7 +649,6 @@
640#define ACPI_ADD_OBJECT_NAME(a,b) 649#define ACPI_ADD_OBJECT_NAME(a,b)
641#endif 650#endif
642 651
643
644/* 652/*
645 * Memory allocation tracking (DEBUG ONLY) 653 * Memory allocation tracking (DEBUG ONLY)
646 */ 654 */
@@ -648,21 +656,20 @@
648 656
649/* Memory allocation */ 657/* Memory allocation */
650 658
651#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) 659#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
652#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) 660#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
653#define ACPI_MEM_FREE(a) acpi_os_free(a) 661#define ACPI_MEM_FREE(a) acpi_os_free(a)
654#define ACPI_MEM_TRACKING(a) 662#define ACPI_MEM_TRACKING(a)
655 663
656
657#else 664#else
658 665
659/* Memory allocation */ 666/* Memory allocation */
660 667
661#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) 668#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
662#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) 669#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
663#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__) 670#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__)
664#define ACPI_MEM_TRACKING(a) a 671#define ACPI_MEM_TRACKING(a) a
665 672
666#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 673#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
667 674
668#endif /* ACMACROS_H */ 675#endif /* ACMACROS_H */
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index deb7cb06f5f0..4f9063f3e951 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -71,14 +71,13 @@
71 71
72/* Definitions of the predefined namespace names */ 72/* Definitions of the predefined namespace names */
73 73
74#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ 74#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */
75#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */ 75#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */
76#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ 76
77#define ACPI_PREFIX_MIXED (u32) 0x69706341 /* "Acpi" */
78#define ACPI_PREFIX_LOWER (u32) 0x69706361 /* "acpi" */
77 79
78#define ACPI_NS_ROOT_PATH "\\" 80#define ACPI_NS_ROOT_PATH "\\"
79#define ACPI_NS_SYSTEM_BUS "_SB_" 81#define ACPI_NS_SYSTEM_BUS "_SB_"
80 82
81 83#endif /* __ACNAMES_H__ */
82#endif /* __ACNAMES_H__ */
83
84
diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
index d1b3ce80056f..dd3501f7e5d6 100644
--- a/include/acpi/acnamesp.h
+++ b/include/acpi/acnamesp.h
@@ -44,7 +44,6 @@
44#ifndef __ACNAMESP_H__ 44#ifndef __ACNAMESP_H__
45#define __ACNAMESP_H__ 45#define __ACNAMESP_H__
46 46
47
48/* To search the entire name space, pass this as search_base */ 47/* To search the entire name space, pass this as search_base */
49 48
50#define ACPI_NS_ALL ((acpi_handle)0) 49#define ACPI_NS_ALL ((acpi_handle)0)
@@ -54,8 +53,8 @@
54 * and should be one-to-one with values of acpi_object_type 53 * and should be one-to-one with values of acpi_object_type
55 */ 54 */
56#define ACPI_NS_NORMAL 0 55#define ACPI_NS_NORMAL 0
57#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ 56#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */
58#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ 57#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */
59 58
60/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */ 59/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
61 60
@@ -68,357 +67,237 @@
68#define ACPI_NS_WALK_UNLOCK TRUE 67#define ACPI_NS_WALK_UNLOCK TRUE
69#define ACPI_NS_WALK_NO_UNLOCK FALSE 68#define ACPI_NS_WALK_NO_UNLOCK FALSE
70 69
71
72/* 70/*
73 * nsinit - Namespace initialization 71 * nsinit - Namespace initialization
74 */ 72 */
75acpi_status 73acpi_status acpi_ns_initialize_objects(void);
76acpi_ns_initialize_objects (
77 void);
78
79acpi_status
80acpi_ns_initialize_devices (
81 void);
82 74
75acpi_status acpi_ns_initialize_devices(void);
83 76
84/* 77/*
85 * nsload - Namespace loading 78 * nsload - Namespace loading
86 */ 79 */
87acpi_status 80acpi_status acpi_ns_load_namespace(void);
88acpi_ns_load_namespace (
89 void);
90 81
91acpi_status 82acpi_status
92acpi_ns_load_table ( 83acpi_ns_load_table(struct acpi_table_desc *table_desc,
93 struct acpi_table_desc *table_desc, 84 struct acpi_namespace_node *node);
94 struct acpi_namespace_node *node);
95
96 85
97/* 86/*
98 * nswalk - walk the namespace 87 * nswalk - walk the namespace
99 */ 88 */
100acpi_status 89acpi_status
101acpi_ns_walk_namespace ( 90acpi_ns_walk_namespace(acpi_object_type type,
102 acpi_object_type type, 91 acpi_handle start_object,
103 acpi_handle start_object, 92 u32 max_depth,
104 u32 max_depth, 93 u8 unlock_before_callback,
105 u8 unlock_before_callback, 94 acpi_walk_callback user_function,
106 acpi_walk_callback user_function, 95 void *context, void **return_value);
107 void *context, 96
108 void **return_value); 97struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type,
109 98 struct acpi_namespace_node
110struct acpi_namespace_node * 99 *parent,
111acpi_ns_get_next_node ( 100 struct acpi_namespace_node
112 acpi_object_type type, 101 *child);
113 struct acpi_namespace_node *parent,
114 struct acpi_namespace_node *child);
115
116 102
117/* 103/*
118 * nsparse - table parsing 104 * nsparse - table parsing
119 */ 105 */
120acpi_status 106acpi_status
121acpi_ns_parse_table ( 107acpi_ns_parse_table(struct acpi_table_desc *table_desc,
122 struct acpi_table_desc *table_desc, 108 struct acpi_namespace_node *scope);
123 struct acpi_namespace_node *scope);
124 109
125acpi_status 110acpi_status
126acpi_ns_one_complete_parse ( 111acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc);
127 u32 pass_number,
128 struct acpi_table_desc *table_desc);
129
130 112
131/* 113/*
132 * nsaccess - Top-level namespace access 114 * nsaccess - Top-level namespace access
133 */ 115 */
134acpi_status 116acpi_status acpi_ns_root_initialize(void);
135acpi_ns_root_initialize (
136 void);
137 117
138acpi_status 118acpi_status
139acpi_ns_lookup ( 119acpi_ns_lookup(union acpi_generic_state *scope_info,
140 union acpi_generic_state *scope_info, 120 char *name,
141 char *name, 121 acpi_object_type type,
142 acpi_object_type type, 122 acpi_interpreter_mode interpreter_mode,
143 acpi_interpreter_mode interpreter_mode, 123 u32 flags,
144 u32 flags, 124 struct acpi_walk_state *walk_state,
145 struct acpi_walk_state *walk_state, 125 struct acpi_namespace_node **ret_node);
146 struct acpi_namespace_node **ret_node);
147
148 126
149/* 127/*
150 * nsalloc - Named object allocation/deallocation 128 * nsalloc - Named object allocation/deallocation
151 */ 129 */
152struct acpi_namespace_node * 130struct acpi_namespace_node *acpi_ns_create_node(u32 name);
153acpi_ns_create_node (
154 u32 name);
155
156void
157acpi_ns_delete_node (
158 struct acpi_namespace_node *node);
159 131
160void 132void acpi_ns_delete_node(struct acpi_namespace_node *node);
161acpi_ns_delete_namespace_subtree (
162 struct acpi_namespace_node *parent_handle);
163 133
164void 134void
165acpi_ns_delete_namespace_by_owner ( 135acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
166 u16 table_id);
167 136
168void 137void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id);
169acpi_ns_detach_object (
170 struct acpi_namespace_node *node);
171 138
172void 139void acpi_ns_detach_object(struct acpi_namespace_node *node);
173acpi_ns_delete_children (
174 struct acpi_namespace_node *parent);
175 140
176int 141void acpi_ns_delete_children(struct acpi_namespace_node *parent);
177acpi_ns_compare_names (
178 char *name1,
179 char *name2);
180 142
143int acpi_ns_compare_names(char *name1, char *name2);
181 144
182/* 145/*
183 * nsdump - Namespace dump/print utilities 146 * nsdump - Namespace dump/print utilities
184 */ 147 */
185#ifdef ACPI_FUTURE_USAGE 148#ifdef ACPI_FUTURE_USAGE
186void 149void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth);
187acpi_ns_dump_tables ( 150#endif /* ACPI_FUTURE_USAGE */
188 acpi_handle search_base,
189 u32 max_depth);
190#endif /* ACPI_FUTURE_USAGE */
191 151
192void 152void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level);
193acpi_ns_dump_entry (
194 acpi_handle handle,
195 u32 debug_level);
196 153
197void 154void
198acpi_ns_dump_pathname ( 155acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component);
199 acpi_handle handle,
200 char *msg,
201 u32 level,
202 u32 component);
203 156
204void 157void acpi_ns_print_pathname(u32 num_segments, char *pathname);
205acpi_ns_print_pathname (
206 u32 num_segments,
207 char *pathname);
208 158
209acpi_status 159acpi_status
210acpi_ns_dump_one_object ( 160acpi_ns_dump_one_object(acpi_handle obj_handle,
211 acpi_handle obj_handle, 161 u32 level, void *context, void **return_value);
212 u32 level,
213 void *context,
214 void **return_value);
215 162
216#ifdef ACPI_FUTURE_USAGE 163#ifdef ACPI_FUTURE_USAGE
217void 164void
218acpi_ns_dump_objects ( 165acpi_ns_dump_objects(acpi_object_type type,
219 acpi_object_type type, 166 u8 display_type,
220 u8 display_type, 167 u32 max_depth,
221 u32 max_depth, 168 acpi_owner_id owner_id, acpi_handle start_handle);
222 u32 ownder_id, 169#endif /* ACPI_FUTURE_USAGE */
223 acpi_handle start_handle);
224#endif /* ACPI_FUTURE_USAGE */
225
226 170
227/* 171/*
228 * nseval - Namespace evaluation functions 172 * nseval - Namespace evaluation functions
229 */ 173 */
230acpi_status 174acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info);
231acpi_ns_evaluate_by_handle (
232 struct acpi_parameter_info *info);
233 175
234acpi_status 176acpi_status
235acpi_ns_evaluate_by_name ( 177acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info);
236 char *pathname,
237 struct acpi_parameter_info *info);
238 178
239acpi_status 179acpi_status
240acpi_ns_evaluate_relative ( 180acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info);
241 char *pathname,
242 struct acpi_parameter_info *info);
243
244 181
245/* 182/*
246 * nsnames - Name and Scope manipulation 183 * nsnames - Name and Scope manipulation
247 */ 184 */
248u32 185u32 acpi_ns_opens_scope(acpi_object_type type);
249acpi_ns_opens_scope (
250 acpi_object_type type);
251 186
252char * 187char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node);
253acpi_ns_get_external_pathname (
254 struct acpi_namespace_node *node);
255 188
256char * 189char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
257acpi_ns_name_of_current_scope (
258 struct acpi_walk_state *walk_state);
259 190
260acpi_status 191acpi_status
261acpi_ns_handle_to_pathname ( 192acpi_ns_handle_to_pathname(acpi_handle target_handle,
262 acpi_handle target_handle, 193 struct acpi_buffer *buffer);
263 struct acpi_buffer *buffer);
264 194
265u8 195u8
266acpi_ns_pattern_match ( 196acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);
267 struct acpi_namespace_node *obj_node,
268 char *search_for);
269 197
270acpi_status 198acpi_status
271acpi_ns_get_node_by_path ( 199acpi_ns_get_node_by_path(char *external_pathname,
272 char *external_pathname, 200 struct acpi_namespace_node *in_prefix_node,
273 struct acpi_namespace_node *in_prefix_node, 201 u32 flags, struct acpi_namespace_node **out_node);
274 u32 flags,
275 struct acpi_namespace_node **out_node);
276
277acpi_size
278acpi_ns_get_pathname_length (
279 struct acpi_namespace_node *node);
280 202
203acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node);
281 204
282/* 205/*
283 * nsobject - Object management for namespace nodes 206 * nsobject - Object management for namespace nodes
284 */ 207 */
285acpi_status 208acpi_status
286acpi_ns_attach_object ( 209acpi_ns_attach_object(struct acpi_namespace_node *node,
287 struct acpi_namespace_node *node, 210 union acpi_operand_object *object, acpi_object_type type);
288 union acpi_operand_object *object,
289 acpi_object_type type);
290 211
291union acpi_operand_object * 212union acpi_operand_object *acpi_ns_get_attached_object(struct
292acpi_ns_get_attached_object ( 213 acpi_namespace_node
293 struct acpi_namespace_node *node); 214 *node);
294 215
295union acpi_operand_object * 216union acpi_operand_object *acpi_ns_get_secondary_object(union
296acpi_ns_get_secondary_object ( 217 acpi_operand_object
297 union acpi_operand_object *obj_desc); 218 *obj_desc);
298 219
299acpi_status 220acpi_status
300acpi_ns_attach_data ( 221acpi_ns_attach_data(struct acpi_namespace_node *node,
301 struct acpi_namespace_node *node, 222 acpi_object_handler handler, void *data);
302 acpi_object_handler handler,
303 void *data);
304 223
305acpi_status 224acpi_status
306acpi_ns_detach_data ( 225acpi_ns_detach_data(struct acpi_namespace_node *node,
307 struct acpi_namespace_node *node, 226 acpi_object_handler handler);
308 acpi_object_handler handler);
309 227
310acpi_status 228acpi_status
311acpi_ns_get_attached_data ( 229acpi_ns_get_attached_data(struct acpi_namespace_node *node,
312 struct acpi_namespace_node *node, 230 acpi_object_handler handler, void **data);
313 acpi_object_handler handler,
314 void **data);
315
316 231
317/* 232/*
318 * nssearch - Namespace searching and entry 233 * nssearch - Namespace searching and entry
319 */ 234 */
320acpi_status 235acpi_status
321acpi_ns_search_and_enter ( 236acpi_ns_search_and_enter(u32 entry_name,
322 u32 entry_name, 237 struct acpi_walk_state *walk_state,
323 struct acpi_walk_state *walk_state, 238 struct acpi_namespace_node *node,
324 struct acpi_namespace_node *node, 239 acpi_interpreter_mode interpreter_mode,
325 acpi_interpreter_mode interpreter_mode, 240 acpi_object_type type,
326 acpi_object_type type, 241 u32 flags, struct acpi_namespace_node **ret_node);
327 u32 flags,
328 struct acpi_namespace_node **ret_node);
329 242
330acpi_status 243acpi_status
331acpi_ns_search_node ( 244acpi_ns_search_node(u32 entry_name,
332 u32 entry_name, 245 struct acpi_namespace_node *node,
333 struct acpi_namespace_node *node, 246 acpi_object_type type,
334 acpi_object_type type, 247 struct acpi_namespace_node **ret_node);
335 struct acpi_namespace_node **ret_node);
336 248
337void 249void
338acpi_ns_install_node ( 250acpi_ns_install_node(struct acpi_walk_state *walk_state,
339 struct acpi_walk_state *walk_state, 251 struct acpi_namespace_node *parent_node,
340 struct acpi_namespace_node *parent_node, 252 struct acpi_namespace_node *node, acpi_object_type type);
341 struct acpi_namespace_node *node,
342 acpi_object_type type);
343
344 253
345/* 254/*
346 * nsutils - Utility functions 255 * nsutils - Utility functions
347 */ 256 */
348u8 257u8 acpi_ns_valid_root_prefix(char prefix);
349acpi_ns_valid_root_prefix (
350 char prefix);
351 258
352acpi_object_type 259acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
353acpi_ns_get_type (
354 struct acpi_namespace_node *node);
355 260
356u32 261u32 acpi_ns_local(acpi_object_type type);
357acpi_ns_local (
358 acpi_object_type type);
359 262
360void 263void
361acpi_ns_report_error ( 264acpi_ns_report_error(char *module_name,
362 char *module_name, 265 u32 line_number,
363 u32 line_number, 266 u32 component_id,
364 u32 component_id, 267 char *internal_name, acpi_status lookup_status);
365 char *internal_name,
366 acpi_status lookup_status);
367 268
368void 269void
369acpi_ns_report_method_error ( 270acpi_ns_report_method_error(char *module_name,
370 char *module_name, 271 u32 line_number,
371 u32 line_number, 272 u32 component_id,
372 u32 component_id, 273 char *message,
373 char *message, 274 struct acpi_namespace_node *node,
374 struct acpi_namespace_node *node, 275 char *path, acpi_status lookup_status);
375 char *path,
376 acpi_status lookup_status);
377 276
378void 277void acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *msg);
379acpi_ns_print_node_pathname (
380 struct acpi_namespace_node *node,
381 char *msg);
382 278
383acpi_status 279acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info);
384acpi_ns_build_internal_name (
385 struct acpi_namestring_info *info);
386 280
387void 281void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info);
388acpi_ns_get_internal_name_length (
389 struct acpi_namestring_info *info);
390 282
391acpi_status 283acpi_status acpi_ns_internalize_name(char *dotted_name, char **converted_name);
392acpi_ns_internalize_name (
393 char *dotted_name,
394 char **converted_name);
395 284
396acpi_status 285acpi_status
397acpi_ns_externalize_name ( 286acpi_ns_externalize_name(u32 internal_name_length,
398 u32 internal_name_length, 287 char *internal_name,
399 char *internal_name, 288 u32 * converted_name_length, char **converted_name);
400 u32 *converted_name_length,
401 char **converted_name);
402 289
403struct acpi_namespace_node * 290struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle);
404acpi_ns_map_handle_to_node (
405 acpi_handle handle);
406 291
407acpi_handle 292acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
408acpi_ns_convert_entry_to_handle(
409 struct acpi_namespace_node *node);
410
411void
412acpi_ns_terminate (
413 void);
414 293
415struct acpi_namespace_node * 294void acpi_ns_terminate(void);
416acpi_ns_get_parent_node (
417 struct acpi_namespace_node *node);
418 295
296struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
297 *node);
419 298
420struct acpi_namespace_node * 299struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
421acpi_ns_get_next_valid_node ( 300 acpi_namespace_node
422 struct acpi_namespace_node *node); 301 *node);
423 302
424#endif /* __ACNAMESP_H__ */ 303#endif /* __ACNAMESP_H__ */
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index e079b94e4fce..4a326ba6d482 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -45,7 +45,6 @@
45#ifndef _ACOBJECT_H 45#ifndef _ACOBJECT_H
46#define _ACOBJECT_H 46#define _ACOBJECT_H
47 47
48
49/* 48/*
50 * The union acpi_operand_object is used to pass AML operands from the dispatcher 49 * The union acpi_operand_object is used to pass AML operands from the dispatcher
51 * to the interpreter, and to keep track of the various handlers such as 50 * to the interpreter, and to keep track of the various handlers such as
@@ -81,7 +80,6 @@
81#define AOPOBJ_SETUP_COMPLETE 0x10 80#define AOPOBJ_SETUP_COMPLETE 0x10
82#define AOPOBJ_SINGLE_DATUM 0x20 81#define AOPOBJ_SINGLE_DATUM 0x20
83 82
84
85/* 83/*
86 * Common bitfield for the field objects 84 * Common bitfield for the field objects
87 * "Field Datum" -- a datum from the actual field object 85 * "Field Datum" -- a datum from the actual field object
@@ -96,8 +94,7 @@
96 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\ 94 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
97 u8 access_bit_width; /* Read/Write size in bits (8-64) */\ 95 u8 access_bit_width; /* Read/Write size in bits (8-64) */\
98 u32 value; /* Value to store into the Bank or Index register */\ 96 u32 value; /* Value to store into the Bank or Index register */\
99 struct acpi_namespace_node *node; /* Link back to parent node */ 97 struct acpi_namespace_node *node; /* Link back to parent node */
100
101 98
102/* 99/*
103 * Fields common to both Strings and Buffers 100 * Fields common to both Strings and Buffers
@@ -105,15 +102,13 @@
105#define ACPI_COMMON_BUFFER_INFO \ 102#define ACPI_COMMON_BUFFER_INFO \
106 u32 length; 103 u32 length;
107 104
108
109/* 105/*
110 * Common fields for objects that support ASL notifications 106 * Common fields for objects that support ASL notifications
111 */ 107 */
112#define ACPI_COMMON_NOTIFY_INFO \ 108#define ACPI_COMMON_NOTIFY_INFO \
113 union acpi_operand_object *system_notify; /* Handler for system notifies */\ 109 union acpi_operand_object *system_notify; /* Handler for system notifies */\
114 union acpi_operand_object *device_notify; /* Handler for driver notifies */\ 110 union acpi_operand_object *device_notify; /* Handler for driver notifies */\
115 union acpi_operand_object *handler; /* Handler for Address space */ 111 union acpi_operand_object *handler; /* Handler for Address space */
116
117 112
118/****************************************************************************** 113/******************************************************************************
119 * 114 *
@@ -121,161 +116,110 @@
121 * 116 *
122 *****************************************************************************/ 117 *****************************************************************************/
123 118
124struct acpi_object_common 119struct acpi_object_common {
125{ 120ACPI_OBJECT_COMMON_HEADER};
126 ACPI_OBJECT_COMMON_HEADER
127};
128 121
129 122struct acpi_object_integer {
130struct acpi_object_integer 123 ACPI_OBJECT_COMMON_HEADER acpi_integer value;
131{
132 ACPI_OBJECT_COMMON_HEADER
133 acpi_integer value;
134}; 124};
135 125
136
137/* 126/*
138 * Note: The String and Buffer object must be identical through the Pointer 127 * Note: The String and Buffer object must be identical through the Pointer
139 * element. There is code that depends on this. 128 * element. There is code that depends on this.
140 */ 129 */
141struct acpi_object_string /* Null terminated, ASCII characters only */ 130struct acpi_object_string { /* Null terminated, ASCII characters only */
142{ 131 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO char *pointer; /* String in AML stream or allocated string */
143 ACPI_OBJECT_COMMON_HEADER
144 ACPI_COMMON_BUFFER_INFO
145 char *pointer; /* String in AML stream or allocated string */
146}; 132};
147 133
148 134struct acpi_object_buffer {
149struct acpi_object_buffer 135 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO u8 * pointer; /* Buffer in AML stream or allocated buffer */
150{ 136 struct acpi_namespace_node *node; /* Link back to parent node */
151 ACPI_OBJECT_COMMON_HEADER 137 u8 *aml_start;
152 ACPI_COMMON_BUFFER_INFO 138 u32 aml_length;
153 u8 *pointer; /* Buffer in AML stream or allocated buffer */
154 struct acpi_namespace_node *node; /* Link back to parent node */
155 u8 *aml_start;
156 u32 aml_length;
157}; 139};
158 140
159 141struct acpi_object_package {
160struct acpi_object_package 142 ACPI_OBJECT_COMMON_HEADER u32 count; /* # of elements in package */
161{ 143 u32 aml_length;
162 ACPI_OBJECT_COMMON_HEADER 144 u8 *aml_start;
163 145 struct acpi_namespace_node *node; /* Link back to parent node */
164 u32 count; /* # of elements in package */ 146 union acpi_operand_object **elements; /* Array of pointers to acpi_objects */
165 u32 aml_length;
166 u8 *aml_start;
167 struct acpi_namespace_node *node; /* Link back to parent node */
168 union acpi_operand_object **elements; /* Array of pointers to acpi_objects */
169}; 147};
170 148
171
172/****************************************************************************** 149/******************************************************************************
173 * 150 *
174 * Complex data types 151 * Complex data types
175 * 152 *
176 *****************************************************************************/ 153 *****************************************************************************/
177 154
178struct acpi_object_event 155struct acpi_object_event {
179{ 156 ACPI_OBJECT_COMMON_HEADER void *semaphore;
180 ACPI_OBJECT_COMMON_HEADER
181 void *semaphore;
182}; 157};
183 158
184
185#define ACPI_INFINITE_CONCURRENCY 0xFF 159#define ACPI_INFINITE_CONCURRENCY 0xFF
186 160
187typedef 161typedef
188acpi_status (*ACPI_INTERNAL_METHOD) ( 162acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
189 struct acpi_walk_state *walk_state); 163
190 164struct acpi_object_method {
191struct acpi_object_method 165 ACPI_OBJECT_COMMON_HEADER u8 method_flags;
192{ 166 u8 param_count;
193 ACPI_OBJECT_COMMON_HEADER 167 u32 aml_length;
194 u8 method_flags; 168 void *semaphore;
195 u8 param_count; 169 u8 *aml_start;
196 u32 aml_length; 170 ACPI_INTERNAL_METHOD implementation;
197 void *semaphore; 171 u8 concurrency;
198 u8 *aml_start; 172 u8 thread_count;
199 ACPI_INTERNAL_METHOD implementation; 173 acpi_owner_id owner_id;
200 u8 concurrency;
201 u8 thread_count;
202 acpi_owner_id owning_id;
203}; 174};
204 175
205 176struct acpi_object_mutex {
206struct acpi_object_mutex 177 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
207{ 178 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
208 ACPI_OBJECT_COMMON_HEADER 179 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
209 u8 sync_level; /* 0-15, specified in Mutex() call */ 180 void *semaphore; /* Actual OS synchronization object */
210 u16 acquisition_depth; /* Allow multiple Acquires, same thread */ 181 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
211 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */ 182 union acpi_operand_object *next; /* Link for list of acquired mutexes */
212 void *semaphore; /* Actual OS synchronization object */ 183 struct acpi_namespace_node *node; /* Containing namespace node */
213 union acpi_operand_object *prev; /* Link for list of acquired mutexes */ 184 u8 original_sync_level; /* Owner's original sync level (0-15) */
214 union acpi_operand_object *next; /* Link for list of acquired mutexes */
215 struct acpi_namespace_node *node; /* Containing namespace node */
216 u8 original_sync_level; /* Owner's original sync level (0-15) */
217}; 185};
218 186
219 187struct acpi_object_region {
220struct acpi_object_region 188 ACPI_OBJECT_COMMON_HEADER u8 space_id;
221{ 189 union acpi_operand_object *handler; /* Handler for region access */
222 ACPI_OBJECT_COMMON_HEADER 190 struct acpi_namespace_node *node; /* Containing namespace node */
223 191 union acpi_operand_object *next;
224 u8 space_id; 192 u32 length;
225 union acpi_operand_object *handler; /* Handler for region access */ 193 acpi_physical_address address;
226 struct acpi_namespace_node *node; /* Containing namespace node */
227 union acpi_operand_object *next;
228 u32 length;
229 acpi_physical_address address;
230}; 194};
231 195
232
233/****************************************************************************** 196/******************************************************************************
234 * 197 *
235 * Objects that can be notified. All share a common notify_info area. 198 * Objects that can be notified. All share a common notify_info area.
236 * 199 *
237 *****************************************************************************/ 200 *****************************************************************************/
238 201
239struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ 202struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
240{ 203ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
241 ACPI_OBJECT_COMMON_HEADER
242 ACPI_COMMON_NOTIFY_INFO
243};
244
245
246struct acpi_object_device
247{
248 ACPI_OBJECT_COMMON_HEADER
249 ACPI_COMMON_NOTIFY_INFO
250 struct acpi_gpe_block_info *gpe_block;
251};
252
253 204
254struct acpi_object_power_resource 205struct acpi_object_device {
255{
256 ACPI_OBJECT_COMMON_HEADER 206 ACPI_OBJECT_COMMON_HEADER
257 ACPI_COMMON_NOTIFY_INFO 207 ACPI_COMMON_NOTIFY_INFO struct acpi_gpe_block_info *gpe_block;
258 u32 system_level;
259 u32 resource_order;
260}; 208};
261 209
262 210struct acpi_object_power_resource {
263struct acpi_object_processor 211 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 system_level;
264{ 212 u32 resource_order;
265 ACPI_OBJECT_COMMON_HEADER
266 ACPI_COMMON_NOTIFY_INFO
267 u32 proc_id;
268 u32 length;
269 acpi_io_address address;
270}; 213};
271 214
272 215struct acpi_object_processor {
273struct acpi_object_thermal_zone 216 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 proc_id;
274{ 217 u32 length;
275 ACPI_OBJECT_COMMON_HEADER 218 acpi_io_address address;
276 ACPI_COMMON_NOTIFY_INFO
277}; 219};
278 220
221struct acpi_object_thermal_zone {
222ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
279 223
280/****************************************************************************** 224/******************************************************************************
281 * 225 *
@@ -283,90 +227,63 @@ struct acpi_object_thermal_zone
283 * 227 *
284 *****************************************************************************/ 228 *****************************************************************************/
285 229
286struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ 230struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
287{ 231 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing Operation Region object */
288 ACPI_OBJECT_COMMON_HEADER 232 /* (REGION/BANK fields only) */
289 ACPI_COMMON_FIELD_INFO
290 union acpi_operand_object *region_obj; /* Containing Operation Region object */
291 /* (REGION/BANK fields only) */
292}; 233};
293 234
294 235struct acpi_object_region_field {
295struct acpi_object_region_field 236 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
296{
297 ACPI_OBJECT_COMMON_HEADER
298 ACPI_COMMON_FIELD_INFO
299 union acpi_operand_object *region_obj; /* Containing op_region object */
300}; 237};
301 238
302 239struct acpi_object_bank_field {
303struct acpi_object_bank_field 240 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
304{ 241 union acpi_operand_object *bank_obj; /* bank_select Register object */
305 ACPI_OBJECT_COMMON_HEADER
306 ACPI_COMMON_FIELD_INFO
307 union acpi_operand_object *region_obj; /* Containing op_region object */
308 union acpi_operand_object *bank_obj; /* bank_select Register object */
309}; 242};
310 243
311 244struct acpi_object_index_field {
312struct acpi_object_index_field 245 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO
313{ 246 /*
314 ACPI_OBJECT_COMMON_HEADER 247 * No "region_obj" pointer needed since the Index and Data registers
315 ACPI_COMMON_FIELD_INFO 248 * are each field definitions unto themselves.
316 249 */
317 /* 250 union acpi_operand_object *index_obj; /* Index register */
318 * No "region_obj" pointer needed since the Index and Data registers 251 union acpi_operand_object *data_obj; /* Data register */
319 * are each field definitions unto themselves.
320 */
321 union acpi_operand_object *index_obj; /* Index register */
322 union acpi_operand_object *data_obj; /* Data register */
323}; 252};
324 253
325
326/* The buffer_field is different in that it is part of a Buffer, not an op_region */ 254/* The buffer_field is different in that it is part of a Buffer, not an op_region */
327 255
328struct acpi_object_buffer_field 256struct acpi_object_buffer_field {
329{ 257 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *buffer_obj; /* Containing Buffer object */
330 ACPI_OBJECT_COMMON_HEADER
331 ACPI_COMMON_FIELD_INFO
332 union acpi_operand_object *buffer_obj; /* Containing Buffer object */
333}; 258};
334 259
335
336/****************************************************************************** 260/******************************************************************************
337 * 261 *
338 * Objects for handlers 262 * Objects for handlers
339 * 263 *
340 *****************************************************************************/ 264 *****************************************************************************/
341 265
342struct acpi_object_notify_handler 266struct acpi_object_notify_handler {
343{ 267 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */
344 ACPI_OBJECT_COMMON_HEADER 268 acpi_notify_handler handler;
345 struct acpi_namespace_node *node; /* Parent device */ 269 void *context;
346 acpi_notify_handler handler;
347 void *context;
348}; 270};
349 271
350
351/* Flags for address handler */ 272/* Flags for address handler */
352 273
353#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x1 274#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x1
354 275
355 276struct acpi_object_addr_handler {
356struct acpi_object_addr_handler 277 ACPI_OBJECT_COMMON_HEADER u8 space_id;
357{ 278 u16 hflags;
358 ACPI_OBJECT_COMMON_HEADER 279 acpi_adr_space_handler handler;
359 u8 space_id; 280 struct acpi_namespace_node *node; /* Parent device */
360 u16 hflags; 281 void *context;
361 acpi_adr_space_handler handler; 282 acpi_adr_space_setup setup;
362 struct acpi_namespace_node *node; /* Parent device */ 283 union acpi_operand_object *region_list; /* regions using this handler */
363 void *context; 284 union acpi_operand_object *next;
364 acpi_adr_space_setup setup;
365 union acpi_operand_object *region_list; /* regions using this handler */
366 union acpi_operand_object *next;
367}; 285};
368 286
369
370/****************************************************************************** 287/******************************************************************************
371 * 288 *
372 * Special internal objects 289 * Special internal objects
@@ -377,18 +294,15 @@ struct acpi_object_addr_handler
377 * The Reference object type is used for these opcodes: 294 * The Reference object type is used for these opcodes:
378 * Arg[0-6], Local[0-7], index_op, name_op, zero_op, one_op, ones_op, debug_op 295 * Arg[0-6], Local[0-7], index_op, name_op, zero_op, one_op, ones_op, debug_op
379 */ 296 */
380struct acpi_object_reference 297struct acpi_object_reference {
381{ 298 ACPI_OBJECT_COMMON_HEADER u8 target_type; /* Used for index_op */
382 ACPI_OBJECT_COMMON_HEADER 299 u16 opcode;
383 u8 target_type; /* Used for index_op */ 300 u32 offset; /* Used for arg_op, local_op, and index_op */
384 u16 opcode; 301 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */
385 u32 offset; /* Used for arg_op, local_op, and index_op */ 302 struct acpi_namespace_node *node;
386 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */ 303 union acpi_operand_object **where;
387 struct acpi_namespace_node *node;
388 union acpi_operand_object **where;
389}; 304};
390 305
391
392/* 306/*
393 * Extra object is used as additional storage for types that 307 * Extra object is used as additional storage for types that
394 * have AML code in their declarations (term_args) that must be 308 * have AML code in their declarations (term_args) that must be
@@ -396,73 +310,62 @@ struct acpi_object_reference
396 * 310 *
397 * Currently: Region and field_unit types 311 * Currently: Region and field_unit types
398 */ 312 */
399struct acpi_object_extra 313struct acpi_object_extra {
400{ 314 ACPI_OBJECT_COMMON_HEADER u8 byte_fill1;
401 ACPI_OBJECT_COMMON_HEADER 315 u16 word_fill1;
402 u8 byte_fill1; 316 u32 aml_length;
403 u16 word_fill1; 317 u8 *aml_start;
404 u32 aml_length; 318 struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */
405 u8 *aml_start; 319 void *region_context; /* Region-specific data */
406 struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */
407 void *region_context; /* Region-specific data */
408}; 320};
409 321
410
411/* Additional data that can be attached to namespace nodes */ 322/* Additional data that can be attached to namespace nodes */
412 323
413struct acpi_object_data 324struct acpi_object_data {
414{ 325 ACPI_OBJECT_COMMON_HEADER acpi_object_handler handler;
415 ACPI_OBJECT_COMMON_HEADER 326 void *pointer;
416 acpi_object_handler handler;
417 void *pointer;
418}; 327};
419 328
420
421/* Structure used when objects are cached for reuse */ 329/* Structure used when objects are cached for reuse */
422 330
423struct acpi_object_cache_list 331struct acpi_object_cache_list {
424{ 332 ACPI_OBJECT_COMMON_HEADER union acpi_operand_object *next; /* Link for object cache and internal lists */
425 ACPI_OBJECT_COMMON_HEADER
426 union acpi_operand_object *next; /* Link for object cache and internal lists*/
427}; 333};
428 334
429
430/****************************************************************************** 335/******************************************************************************
431 * 336 *
432 * union acpi_operand_object Descriptor - a giant union of all of the above 337 * union acpi_operand_object Descriptor - a giant union of all of the above
433 * 338 *
434 *****************************************************************************/ 339 *****************************************************************************/
435 340
436union acpi_operand_object 341union acpi_operand_object {
437{ 342 struct acpi_object_common common;
438 struct acpi_object_common common; 343 struct acpi_object_integer integer;
439 struct acpi_object_integer integer; 344 struct acpi_object_string string;
440 struct acpi_object_string string; 345 struct acpi_object_buffer buffer;
441 struct acpi_object_buffer buffer; 346 struct acpi_object_package package;
442 struct acpi_object_package package; 347 struct acpi_object_event event;
443 struct acpi_object_event event; 348 struct acpi_object_method method;
444 struct acpi_object_method method; 349 struct acpi_object_mutex mutex;
445 struct acpi_object_mutex mutex; 350 struct acpi_object_region region;
446 struct acpi_object_region region; 351 struct acpi_object_notify_common common_notify;
447 struct acpi_object_notify_common common_notify; 352 struct acpi_object_device device;
448 struct acpi_object_device device; 353 struct acpi_object_power_resource power_resource;
449 struct acpi_object_power_resource power_resource; 354 struct acpi_object_processor processor;
450 struct acpi_object_processor processor; 355 struct acpi_object_thermal_zone thermal_zone;
451 struct acpi_object_thermal_zone thermal_zone; 356 struct acpi_object_field_common common_field;
452 struct acpi_object_field_common common_field; 357 struct acpi_object_region_field field;
453 struct acpi_object_region_field field; 358 struct acpi_object_buffer_field buffer_field;
454 struct acpi_object_buffer_field buffer_field; 359 struct acpi_object_bank_field bank_field;
455 struct acpi_object_bank_field bank_field; 360 struct acpi_object_index_field index_field;
456 struct acpi_object_index_field index_field; 361 struct acpi_object_notify_handler notify;
457 struct acpi_object_notify_handler notify; 362 struct acpi_object_addr_handler address_space;
458 struct acpi_object_addr_handler address_space; 363 struct acpi_object_reference reference;
459 struct acpi_object_reference reference; 364 struct acpi_object_extra extra;
460 struct acpi_object_extra extra; 365 struct acpi_object_data data;
461 struct acpi_object_data data; 366 struct acpi_object_cache_list cache;
462 struct acpi_object_cache_list cache;
463}; 367};
464 368
465
466/****************************************************************************** 369/******************************************************************************
467 * 370 *
468 * union acpi_descriptor - objects that share a common descriptor identifier 371 * union acpi_descriptor - objects that share a common descriptor identifier
@@ -471,7 +374,7 @@ union acpi_operand_object
471 374
472/* Object descriptor types */ 375/* Object descriptor types */
473 376
474#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ 377#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */
475#define ACPI_DESC_TYPE_STATE 0x02 378#define ACPI_DESC_TYPE_STATE 0x02
476#define ACPI_DESC_TYPE_STATE_UPDATE 0x03 379#define ACPI_DESC_TYPE_STATE_UPDATE 0x03
477#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04 380#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04
@@ -488,14 +391,11 @@ union acpi_operand_object
488#define ACPI_DESC_TYPE_NAMED 0x0F 391#define ACPI_DESC_TYPE_NAMED 0x0F
489#define ACPI_DESC_TYPE_MAX 0x0F 392#define ACPI_DESC_TYPE_MAX 0x0F
490 393
491 394union acpi_descriptor {
492union acpi_descriptor 395 u8 descriptor_id; /* To differentiate various internal objs */
493{ 396 union acpi_operand_object object;
494 u8 descriptor_id; /* To differentiate various internal objs */\ 397 struct acpi_namespace_node node;
495 union acpi_operand_object object; 398 union acpi_parse_object op;
496 struct acpi_namespace_node node;
497 union acpi_parse_object op;
498}; 399};
499 400
500 401#endif /* _ACOBJECT_H */
501#endif /* _ACOBJECT_H */
diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h
index 118ecba4cf05..64da42992199 100644
--- a/include/acpi/acopcode.h
+++ b/include/acpi/acopcode.h
@@ -62,7 +62,6 @@
62#define _NAM 0x6C 62#define _NAM 0x6C
63#define _PFX 0x6D 63#define _PFX 0x6D
64 64
65
66/* 65/*
67 * 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
68 * 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
@@ -191,7 +190,6 @@
191#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) 190#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
192#define ARGP_ZERO_OP ARG_NONE 191#define ARGP_ZERO_OP ARG_NONE
193 192
194
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
@@ -246,7 +244,7 @@
246#define ARGI_FIELD_OP ARGI_INVALID_OPCODE 244#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
247#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) 245#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
248#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) 246#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
249#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) 247#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
250#define ARGI_IF_OP ARGI_INVALID_OPCODE 248#define ARGI_IF_OP ARGI_INVALID_OPCODE
251#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) 249#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
252#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE 250#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
@@ -322,4 +320,4 @@
322#define ARGI_WORD_OP ARGI_INVALID_OPCODE 320#define ARGI_WORD_OP ARGI_INVALID_OPCODE
323#define ARGI_ZERO_OP ARG_NONE 321#define ARGI_ZERO_OP ARG_NONE
324 322
325#endif /* __ACOPCODE_H__ */ 323#endif /* __ACOPCODE_H__ */
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index 2fbe180fee6b..68d7edf0f697 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -73,12 +73,10 @@
73#define ACPI_ALL_COMPONENTS 0x00003FFF 73#define ACPI_ALL_COMPONENTS 0x00003FFF
74#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) 74#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS)
75 75
76
77/* Component IDs reserved for ACPI drivers */ 76/* Component IDs reserved for ACPI drivers */
78 77
79#define ACPI_ALL_DRIVERS 0xFFFF0000 78#define ACPI_ALL_DRIVERS 0xFFFF0000
80 79
81
82/* 80/*
83 * Raw debug output levels, do not use these in the DEBUG_PRINT macros 81 * Raw debug output levels, do not use these in the DEBUG_PRINT macros
84 */ 82 */
@@ -132,11 +130,10 @@
132 130
133#define ACPI_LV_VERBOSE 0xF0000000 131#define ACPI_LV_VERBOSE 0xF0000000
134 132
135
136/* 133/*
137 * Debug level macros that are used in the DEBUG_PRINT macros 134 * Debug level macros that are used in the DEBUG_PRINT macros
138 */ 135 */
139#define ACPI_DEBUG_LEVEL(dl) (u32) dl,__LINE__,&_debug_info 136#define ACPI_DEBUG_LEVEL(dl) (u32) dl,ACPI_DEBUG_PARAMETERS
140 137
141/* Exception level -- used in the global "debug_level" */ 138/* Exception level -- used in the global "debug_level" */
142 139
@@ -147,7 +144,6 @@
147#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) 144#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
148#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) 145#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
149 146
150
151/* Trace level -- also used in the global "debug_level" */ 147/* Trace level -- also used in the global "debug_level" */
152 148
153#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) 149#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
@@ -174,12 +170,10 @@
174 170
175#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) 171#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL)
176 172
177
178/* Defaults for debug_level, debug and normal */ 173/* Defaults for debug_level, debug and normal */
179 174
180#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) 175#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
181#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) 176#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
182#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) 177#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
183 178
184 179#endif /* __ACOUTPUT_H__ */
185#endif /* __ACOUTPUT_H__ */
diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h
index 698276571818..d352d40de1f3 100644
--- a/include/acpi/acparser.h
+++ b/include/acpi/acparser.h
@@ -41,18 +41,15 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#ifndef __ACPARSER_H__ 44#ifndef __ACPARSER_H__
46#define __ACPARSER_H__ 45#define __ACPARSER_H__
47 46
48
49#define OP_HAS_RETURN_VALUE 1 47#define OP_HAS_RETURN_VALUE 1
50 48
51/* variable # arguments */ 49/* variable # arguments */
52 50
53#define ACPI_VAR_ARGS ACPI_UINT32_MAX 51#define ACPI_VAR_ARGS ACPI_UINT32_MAX
54 52
55
56#define ACPI_PARSE_DELETE_TREE 0x0001 53#define ACPI_PARSE_DELETE_TREE 0x0001
57#define ACPI_PARSE_NO_TREE_DELETE 0x0000 54#define ACPI_PARSE_NO_TREE_DELETE 0x0000
58#define ACPI_PARSE_TREE_MASK 0x0001 55#define ACPI_PARSE_TREE_MASK 0x0001
@@ -63,7 +60,7 @@
63#define ACPI_PARSE_MODE_MASK 0x0030 60#define ACPI_PARSE_MODE_MASK 0x0030
64 61
65#define ACPI_PARSE_DEFERRED_OP 0x0100 62#define ACPI_PARSE_DEFERRED_OP 0x0100
66 63#define ACPI_PARSE_DISASSEMBLE 0x0200
67 64
68/****************************************************************************** 65/******************************************************************************
69 * 66 *
@@ -71,251 +68,165 @@
71 * 68 *
72 *****************************************************************************/ 69 *****************************************************************************/
73 70
74
75/* 71/*
76 * psxface - Parser external interfaces 72 * psxface - Parser external interfaces
77 */ 73 */
78acpi_status 74acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info);
79acpi_psx_load_table (
80 u8 *pcode_addr,
81 u32 pcode_length);
82
83acpi_status
84acpi_psx_execute (
85 struct acpi_parameter_info *info);
86
87 75
88/* 76/*
89 * psargs - Parse AML opcode arguments 77 * psargs - Parse AML opcode arguments
90 */ 78 */
91u8 * 79u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
92acpi_ps_get_next_package_end (
93 struct acpi_parse_state *parser_state);
94 80
95char * 81char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
96acpi_ps_get_next_namestring (
97 struct acpi_parse_state *parser_state);
98 82
99void 83void
100acpi_ps_get_next_simple_arg ( 84acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
101 struct acpi_parse_state *parser_state, 85 u32 arg_type, union acpi_parse_object *arg);
102 u32 arg_type,
103 union acpi_parse_object *arg);
104 86
105acpi_status 87acpi_status
106acpi_ps_get_next_namepath ( 88acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
107 struct acpi_walk_state *walk_state, 89 struct acpi_parse_state *parser_state,
108 struct acpi_parse_state *parser_state, 90 union acpi_parse_object *arg, u8 method_call);
109 union acpi_parse_object *arg,
110 u8 method_call);
111 91
112acpi_status 92acpi_status
113acpi_ps_get_next_arg ( 93acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
114 struct acpi_walk_state *walk_state, 94 struct acpi_parse_state *parser_state,
115 struct acpi_parse_state *parser_state, 95 u32 arg_type, union acpi_parse_object **return_arg);
116 u32 arg_type,
117 union acpi_parse_object **return_arg);
118
119 96
120/* 97/*
121 * psfind 98 * psfind
122 */ 99 */
123union acpi_parse_object * 100union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
124acpi_ps_find_name ( 101 u32 name, u32 opcode);
125 union acpi_parse_object *scope,
126 u32 name,
127 u32 opcode);
128
129union acpi_parse_object*
130acpi_ps_get_parent (
131 union acpi_parse_object *op);
132 102
103union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
133 104
134/* 105/*
135 * psopcode - AML Opcode information 106 * psopcode - AML Opcode information
136 */ 107 */
137const struct acpi_opcode_info * 108const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
138acpi_ps_get_opcode_info (
139 u16 opcode);
140
141char *
142acpi_ps_get_opcode_name (
143 u16 opcode);
144 109
110char *acpi_ps_get_opcode_name(u16 opcode);
145 111
146/* 112/*
147 * psparse - top level parsing routines 113 * psparse - top level parsing routines
148 */ 114 */
149acpi_status 115acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
150acpi_ps_parse_aml (
151 struct acpi_walk_state *walk_state);
152 116
153u32 117u32 acpi_ps_get_opcode_size(u32 opcode);
154acpi_ps_get_opcode_size (
155 u32 opcode);
156 118
157u16 119u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
158acpi_ps_peek_opcode (
159 struct acpi_parse_state *state);
160 120
121acpi_status
122acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
123 union acpi_parse_object *op);
124
125acpi_status
126acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
127 union acpi_parse_object *op,
128 acpi_status callback_status);
129
130/*
131 * psloop - main parse loop
132 */
133acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
161 134
162/* 135/*
163 * psscope - Scope stack management routines 136 * psscope - Scope stack management routines
164 */ 137 */
165acpi_status 138acpi_status
166acpi_ps_init_scope ( 139acpi_ps_init_scope(struct acpi_parse_state *parser_state,
167 struct acpi_parse_state *parser_state, 140 union acpi_parse_object *root);
168 union acpi_parse_object *root);
169 141
170union acpi_parse_object * 142union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
171acpi_ps_get_parent_scope ( 143 *state);
172 struct acpi_parse_state *state);
173 144
174u8 145u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
175acpi_ps_has_completed_scope (
176 struct acpi_parse_state *parser_state);
177 146
178void 147void
179acpi_ps_pop_scope ( 148acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
180 struct acpi_parse_state *parser_state, 149 union acpi_parse_object **op,
181 union acpi_parse_object **op, 150 u32 * arg_list, u32 * arg_count);
182 u32 *arg_list,
183 u32 *arg_count);
184 151
185acpi_status 152acpi_status
186acpi_ps_push_scope ( 153acpi_ps_push_scope(struct acpi_parse_state *parser_state,
187 struct acpi_parse_state *parser_state, 154 union acpi_parse_object *op,
188 union acpi_parse_object *op, 155 u32 remaining_args, u32 arg_count);
189 u32 remaining_args,
190 u32 arg_count);
191
192void
193acpi_ps_cleanup_scope (
194 struct acpi_parse_state *state);
195 156
157void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
196 158
197/* 159/*
198 * pstree - parse tree manipulation routines 160 * pstree - parse tree manipulation routines
199 */ 161 */
200void 162void
201acpi_ps_append_arg( 163acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
202 union acpi_parse_object *op,
203 union acpi_parse_object *arg);
204
205union acpi_parse_object*
206acpi_ps_find (
207 union acpi_parse_object *scope,
208 char *path,
209 u16 opcode,
210 u32 create);
211
212union acpi_parse_object *
213acpi_ps_get_arg(
214 union acpi_parse_object *op,
215 u32 argn);
216 164
217#ifdef ACPI_FUTURE_USAGE 165union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
218union acpi_parse_object * 166 char *path, u16 opcode, u32 create);
219acpi_ps_get_depth_next (
220 union acpi_parse_object *origin,
221 union acpi_parse_object *op);
222#endif /* ACPI_FUTURE_USAGE */
223 167
168union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
169
170#ifdef ACPI_FUTURE_USAGE
171union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
172 union acpi_parse_object *op);
173#endif /* ACPI_FUTURE_USAGE */
224 174
225/* 175/*
226 * pswalk - parse tree walk routines 176 * pswalk - parse tree walk routines
227 */ 177 */
228acpi_status 178acpi_status
229acpi_ps_walk_parsed_aml ( 179acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
230 union acpi_parse_object *start_op, 180 union acpi_parse_object *end_op,
231 union acpi_parse_object *end_op, 181 union acpi_operand_object *mth_desc,
232 union acpi_operand_object *mth_desc, 182 struct acpi_namespace_node *start_node,
233 struct acpi_namespace_node *start_node, 183 union acpi_operand_object **params,
234 union acpi_operand_object **params, 184 union acpi_operand_object **caller_return_desc,
235 union acpi_operand_object **caller_return_desc, 185 acpi_owner_id owner_id,
236 acpi_owner_id owner_id, 186 acpi_parse_downwards descending_callback,
237 acpi_parse_downwards descending_callback, 187 acpi_parse_upwards ascending_callback);
238 acpi_parse_upwards ascending_callback);
239
240acpi_status
241acpi_ps_get_next_walk_op (
242 struct acpi_walk_state *walk_state,
243 union acpi_parse_object *op,
244 acpi_parse_upwards ascending_callback);
245 188
246acpi_status 189acpi_status
247acpi_ps_delete_completed_op ( 190acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
248 struct acpi_walk_state *walk_state); 191 union acpi_parse_object *op,
192 acpi_parse_upwards ascending_callback);
249 193
250void 194acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
251acpi_ps_delete_parse_tree (
252 union acpi_parse_object *root);
253 195
196void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
254 197
255/* 198/*
256 * psutils - parser utilities 199 * psutils - parser utilities
257 */ 200 */
258union acpi_parse_object * 201union acpi_parse_object *acpi_ps_create_scope_op(void);
259acpi_ps_create_scope_op (
260 void);
261 202
262void 203void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
263acpi_ps_init_op (
264 union acpi_parse_object *op,
265 u16 opcode);
266 204
267union acpi_parse_object * 205union acpi_parse_object *acpi_ps_alloc_op(u16 opcode);
268acpi_ps_alloc_op (
269 u16 opcode);
270 206
271void 207void acpi_ps_free_op(union acpi_parse_object *op);
272acpi_ps_free_op (
273 union acpi_parse_object *op);
274 208
275u8 209u8 acpi_ps_is_leading_char(u32 c);
276acpi_ps_is_leading_char (
277 u32 c);
278 210
279u8 211u8 acpi_ps_is_prefix_char(u32 c);
280acpi_ps_is_prefix_char (
281 u32 c);
282 212
283#ifdef ACPI_FUTURE_USAGE 213#ifdef ACPI_FUTURE_USAGE
284u32 214u32 acpi_ps_get_name(union acpi_parse_object *op);
285acpi_ps_get_name( 215#endif /* ACPI_FUTURE_USAGE */
286 union acpi_parse_object *op);
287#endif /* ACPI_FUTURE_USAGE */
288
289void
290acpi_ps_set_name(
291 union acpi_parse_object *op,
292 u32 name);
293
294#ifdef ACPI_ENABLE_OBJECT_CACHE
295void
296acpi_ps_delete_parse_cache (
297 void);
298#endif
299 216
217void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
300 218
301/* 219/*
302 * psdump - display parser tree 220 * psdump - display parser tree
303 */ 221 */
304u32 222u32
305acpi_ps_sprint_path ( 223acpi_ps_sprint_path(char *buffer_start,
306 char *buffer_start, 224 u32 buffer_size, union acpi_parse_object *op);
307 u32 buffer_size,
308 union acpi_parse_object *op);
309 225
310u32 226u32
311acpi_ps_sprint_op ( 227acpi_ps_sprint_op(char *buffer_start,
312 char *buffer_start, 228 u32 buffer_size, union acpi_parse_object *op);
313 u32 buffer_size,
314 union acpi_parse_object *op);
315
316void
317acpi_ps_show (
318 union acpi_parse_object *op);
319 229
230void acpi_ps_show(union acpi_parse_object *op);
320 231
321#endif /* __ACPARSER_H__ */ 232#endif /* __ACPARSER_H__ */
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index a69d78942040..ccf34f9dac64 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -49,22 +49,21 @@
49 * We put them here because we don't want to duplicate them 49 * We put them here because we don't want to duplicate them
50 * in the rest of the source code again and again. 50 * in the rest of the source code again and again.
51 */ 51 */
52#include "acnames.h" /* Global ACPI names and strings */ 52#include "acnames.h" /* Global ACPI names and strings */
53#include "acconfig.h" /* Configuration constants */ 53#include "acconfig.h" /* Configuration constants */
54#include "platform/acenv.h" /* Target environment specific items */ 54#include "platform/acenv.h" /* Target environment specific items */
55#include "actypes.h" /* Fundamental common data types */ 55#include "actypes.h" /* Fundamental common data types */
56#include "acexcep.h" /* ACPI exception codes */ 56#include "acexcep.h" /* ACPI exception codes */
57#include "acmacros.h" /* C macros */ 57#include "acmacros.h" /* C macros */
58#include "actbl.h" /* ACPI table definitions */ 58#include "actbl.h" /* ACPI table definitions */
59#include "aclocal.h" /* Internal data types */ 59#include "aclocal.h" /* Internal data types */
60#include "acoutput.h" /* Error output and Debug macros */ 60#include "acoutput.h" /* Error output and Debug macros */
61#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/ 61#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer */
62#include "acpixf.h" /* ACPI core subsystem external interfaces */ 62#include "acpixf.h" /* ACPI core subsystem external interfaces */
63#include "acobject.h" /* ACPI internal object */ 63#include "acobject.h" /* ACPI internal object */
64#include "acstruct.h" /* Common structures */ 64#include "acstruct.h" /* Common structures */
65#include "acglobal.h" /* All global variables */ 65#include "acglobal.h" /* All global variables */
66#include "achware.h" /* Hardware defines and interfaces */ 66#include "achware.h" /* Hardware defines and interfaces */
67#include "acutils.h" /* Utility interfaces */ 67#include "acutils.h" /* Utility interfaces */
68 68
69 69#endif /* __ACPI_H__ */
70#endif /* __ACPI_H__ */
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 8d0e1290bc76..0b54e9a4a8a1 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -35,48 +35,41 @@
35/* TBD: Make dynamic */ 35/* TBD: Make dynamic */
36#define ACPI_MAX_HANDLES 10 36#define ACPI_MAX_HANDLES 10
37struct acpi_handle_list { 37struct acpi_handle_list {
38 u32 count; 38 u32 count;
39 acpi_handle handles[ACPI_MAX_HANDLES]; 39 acpi_handle handles[ACPI_MAX_HANDLES];
40}; 40};
41 41
42
43/* acpi_utils.h */ 42/* acpi_utils.h */
44acpi_status 43acpi_status
45acpi_extract_package ( 44acpi_extract_package(union acpi_object *package,
46 union acpi_object *package, 45 struct acpi_buffer *format, struct acpi_buffer *buffer);
47 struct acpi_buffer *format,
48 struct acpi_buffer *buffer);
49acpi_status 46acpi_status
50acpi_evaluate_integer ( 47acpi_evaluate_integer(acpi_handle handle,
51 acpi_handle handle, 48 acpi_string pathname,
52 acpi_string pathname, 49 struct acpi_object_list *arguments, unsigned long *data);
53 struct acpi_object_list *arguments,
54 unsigned long *data);
55acpi_status 50acpi_status
56acpi_evaluate_reference ( 51acpi_evaluate_reference(acpi_handle handle,
57 acpi_handle handle, 52 acpi_string pathname,
58 acpi_string pathname, 53 struct acpi_object_list *arguments,
59 struct acpi_object_list *arguments, 54 struct acpi_handle_list *list);
60 struct acpi_handle_list *list);
61
62 55
63#ifdef CONFIG_ACPI_BUS 56#ifdef CONFIG_ACPI
64 57
65#include <linux/proc_fs.h> 58#include <linux/proc_fs.h>
66 59
67#define ACPI_BUS_FILE_ROOT "acpi" 60#define ACPI_BUS_FILE_ROOT "acpi"
68extern struct proc_dir_entry *acpi_root_dir; 61extern struct proc_dir_entry *acpi_root_dir;
69extern FADT_DESCRIPTOR acpi_fadt; 62extern FADT_DESCRIPTOR acpi_fadt;
70 63
71enum acpi_bus_removal_type { 64enum acpi_bus_removal_type {
72 ACPI_BUS_REMOVAL_NORMAL = 0, 65 ACPI_BUS_REMOVAL_NORMAL = 0,
73 ACPI_BUS_REMOVAL_EJECT, 66 ACPI_BUS_REMOVAL_EJECT,
74 ACPI_BUS_REMOVAL_SUPRISE, 67 ACPI_BUS_REMOVAL_SUPRISE,
75 ACPI_BUS_REMOVAL_TYPE_COUNT 68 ACPI_BUS_REMOVAL_TYPE_COUNT
76}; 69};
77 70
78enum acpi_bus_device_type { 71enum acpi_bus_device_type {
79 ACPI_BUS_TYPE_DEVICE = 0, 72 ACPI_BUS_TYPE_DEVICE = 0,
80 ACPI_BUS_TYPE_POWER, 73 ACPI_BUS_TYPE_POWER,
81 ACPI_BUS_TYPE_PROCESSOR, 74 ACPI_BUS_TYPE_PROCESSOR,
82 ACPI_BUS_TYPE_THERMAL, 75 ACPI_BUS_TYPE_THERMAL,
@@ -89,61 +82,60 @@ enum acpi_bus_device_type {
89struct acpi_driver; 82struct acpi_driver;
90struct acpi_device; 83struct acpi_device;
91 84
92
93/* 85/*
94 * ACPI Driver 86 * ACPI Driver
95 * ----------- 87 * -----------
96 */ 88 */
97 89
98typedef int (*acpi_op_add) (struct acpi_device *device); 90typedef int (*acpi_op_add) (struct acpi_device * device);
99typedef int (*acpi_op_remove) (struct acpi_device *device, int type); 91typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
100typedef int (*acpi_op_lock) (struct acpi_device *device, int type); 92typedef int (*acpi_op_lock) (struct acpi_device * device, int type);
101typedef int (*acpi_op_start) (struct acpi_device *device); 93typedef int (*acpi_op_start) (struct acpi_device * device);
102typedef int (*acpi_op_stop) (struct acpi_device *device, int type); 94typedef int (*acpi_op_stop) (struct acpi_device * device, int type);
103typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); 95typedef int (*acpi_op_suspend) (struct acpi_device * device, int state);
104typedef int (*acpi_op_resume) (struct acpi_device *device, int state); 96typedef int (*acpi_op_resume) (struct acpi_device * device, int state);
105typedef int (*acpi_op_scan) (struct acpi_device *device); 97typedef int (*acpi_op_scan) (struct acpi_device * device);
106typedef int (*acpi_op_bind) (struct acpi_device *device); 98typedef int (*acpi_op_bind) (struct acpi_device * device);
107typedef int (*acpi_op_unbind) (struct acpi_device *device); 99typedef int (*acpi_op_unbind) (struct acpi_device * device);
108typedef int (*acpi_op_match) (struct acpi_device *device, 100typedef int (*acpi_op_match) (struct acpi_device * device,
109 struct acpi_driver *driver); 101 struct acpi_driver * driver);
110 102
111struct acpi_bus_ops { 103struct acpi_bus_ops {
112 u32 acpi_op_add:1; 104 u32 acpi_op_add:1;
113 u32 acpi_op_remove:1; 105 u32 acpi_op_remove:1;
114 u32 acpi_op_lock:1; 106 u32 acpi_op_lock:1;
115 u32 acpi_op_start:1; 107 u32 acpi_op_start:1;
116 u32 acpi_op_stop:1; 108 u32 acpi_op_stop:1;
117 u32 acpi_op_suspend:1; 109 u32 acpi_op_suspend:1;
118 u32 acpi_op_resume:1; 110 u32 acpi_op_resume:1;
119 u32 acpi_op_scan:1; 111 u32 acpi_op_scan:1;
120 u32 acpi_op_bind:1; 112 u32 acpi_op_bind:1;
121 u32 acpi_op_unbind:1; 113 u32 acpi_op_unbind:1;
122 u32 acpi_op_match:1; 114 u32 acpi_op_match:1;
123 u32 reserved:21; 115 u32 reserved:21;
124}; 116};
125 117
126struct acpi_device_ops { 118struct acpi_device_ops {
127 acpi_op_add add; 119 acpi_op_add add;
128 acpi_op_remove remove; 120 acpi_op_remove remove;
129 acpi_op_lock lock; 121 acpi_op_lock lock;
130 acpi_op_start start; 122 acpi_op_start start;
131 acpi_op_stop stop; 123 acpi_op_stop stop;
132 acpi_op_suspend suspend; 124 acpi_op_suspend suspend;
133 acpi_op_resume resume; 125 acpi_op_resume resume;
134 acpi_op_scan scan; 126 acpi_op_scan scan;
135 acpi_op_bind bind; 127 acpi_op_bind bind;
136 acpi_op_unbind unbind; 128 acpi_op_unbind unbind;
137 acpi_op_match match; 129 acpi_op_match match;
138}; 130};
139 131
140struct acpi_driver { 132struct acpi_driver {
141 struct list_head node; 133 struct list_head node;
142 char name[80]; 134 char name[80];
143 char class[80]; 135 char class[80];
144 atomic_t references; 136 atomic_t references;
145 char *ids; /* Supported Hardware IDs */ 137 char *ids; /* Supported Hardware IDs */
146 struct acpi_device_ops ops; 138 struct acpi_device_ops ops;
147}; 139};
148 140
149/* 141/*
@@ -154,60 +146,57 @@ struct acpi_driver {
154/* Status (_STA) */ 146/* Status (_STA) */
155 147
156struct acpi_device_status { 148struct acpi_device_status {
157 u32 present:1; 149 u32 present:1;
158 u32 enabled:1; 150 u32 enabled:1;
159 u32 show_in_ui:1; 151 u32 show_in_ui:1;
160 u32 functional:1; 152 u32 functional:1;
161 u32 battery_present:1; 153 u32 battery_present:1;
162 u32 reserved:27; 154 u32 reserved:27;
163}; 155};
164 156
165
166/* Flags */ 157/* Flags */
167 158
168struct acpi_device_flags { 159struct acpi_device_flags {
169 u32 dynamic_status:1; 160 u32 dynamic_status:1;
170 u32 hardware_id:1; 161 u32 hardware_id:1;
171 u32 compatible_ids:1; 162 u32 compatible_ids:1;
172 u32 bus_address:1; 163 u32 bus_address:1;
173 u32 unique_id:1; 164 u32 unique_id:1;
174 u32 removable:1; 165 u32 removable:1;
175 u32 ejectable:1; 166 u32 ejectable:1;
176 u32 lockable:1; 167 u32 lockable:1;
177 u32 suprise_removal_ok:1; 168 u32 suprise_removal_ok:1;
178 u32 power_manageable:1; 169 u32 power_manageable:1;
179 u32 performance_manageable:1; 170 u32 performance_manageable:1;
180 u32 wake_capable:1; /* Wakeup(_PRW) supported? */ 171 u32 wake_capable:1; /* Wakeup(_PRW) supported? */
181 u32 reserved:20; 172 u32 reserved:20;
182}; 173};
183 174
184
185/* File System */ 175/* File System */
186 176
187struct acpi_device_dir { 177struct acpi_device_dir {
188 struct proc_dir_entry *entry; 178 struct proc_dir_entry *entry;
189}; 179};
190 180
191#define acpi_device_dir(d) ((d)->dir.entry) 181#define acpi_device_dir(d) ((d)->dir.entry)
192 182
193
194/* Plug and Play */ 183/* Plug and Play */
195 184
196typedef char acpi_bus_id[5]; 185typedef char acpi_bus_id[5];
197typedef unsigned long acpi_bus_address; 186typedef unsigned long acpi_bus_address;
198typedef char acpi_hardware_id[9]; 187typedef char acpi_hardware_id[9];
199typedef char acpi_unique_id[9]; 188typedef char acpi_unique_id[9];
200typedef char acpi_device_name[40]; 189typedef char acpi_device_name[40];
201typedef char acpi_device_class[20]; 190typedef char acpi_device_class[20];
202 191
203struct acpi_device_pnp { 192struct acpi_device_pnp {
204 acpi_bus_id bus_id; /* Object name */ 193 acpi_bus_id bus_id; /* Object name */
205 acpi_bus_address bus_address; /* _ADR */ 194 acpi_bus_address bus_address; /* _ADR */
206 acpi_hardware_id hardware_id; /* _HID */ 195 acpi_hardware_id hardware_id; /* _HID */
207 struct acpi_compatible_id_list *cid_list; /* _CIDs */ 196 struct acpi_compatible_id_list *cid_list; /* _CIDs */
208 acpi_unique_id unique_id; /* _UID */ 197 acpi_unique_id unique_id; /* _UID */
209 acpi_device_name device_name; /* Driver-determined */ 198 acpi_device_name device_name; /* Driver-determined */
210 acpi_device_class device_class; /* " */ 199 acpi_device_class device_class; /* " */
211}; 200};
212 201
213#define acpi_device_bid(d) ((d)->pnp.bus_id) 202#define acpi_device_bid(d) ((d)->pnp.bus_id)
@@ -217,114 +206,111 @@ struct acpi_device_pnp {
217#define acpi_device_name(d) ((d)->pnp.device_name) 206#define acpi_device_name(d) ((d)->pnp.device_name)
218#define acpi_device_class(d) ((d)->pnp.device_class) 207#define acpi_device_class(d) ((d)->pnp.device_class)
219 208
220
221/* Power Management */ 209/* Power Management */
222 210
223struct acpi_device_power_flags { 211struct acpi_device_power_flags {
224 u32 explicit_get:1; /* _PSC present? */ 212 u32 explicit_get:1; /* _PSC present? */
225 u32 power_resources:1; /* Power resources */ 213 u32 power_resources:1; /* Power resources */
226 u32 inrush_current:1; /* Serialize Dx->D0 */ 214 u32 inrush_current:1; /* Serialize Dx->D0 */
227 u32 power_removed:1; /* Optimize Dx->D0 */ 215 u32 power_removed:1; /* Optimize Dx->D0 */
228 u32 reserved:28; 216 u32 reserved:28;
229}; 217};
230 218
231struct acpi_device_power_state { 219struct acpi_device_power_state {
232 struct { 220 struct {
233 u8 valid:1; 221 u8 valid:1;
234 u8 explicit_set:1; /* _PSx present? */ 222 u8 explicit_set:1; /* _PSx present? */
235 u8 reserved:6; 223 u8 reserved:6;
236 } flags; 224 } flags;
237 int power; /* % Power (compared to D0) */ 225 int power; /* % Power (compared to D0) */
238 int latency; /* Dx->D0 time (microseconds) */ 226 int latency; /* Dx->D0 time (microseconds) */
239 struct acpi_handle_list resources; /* Power resources referenced */ 227 struct acpi_handle_list resources; /* Power resources referenced */
240}; 228};
241 229
242struct acpi_device_power { 230struct acpi_device_power {
243 int state; /* Current state */ 231 int state; /* Current state */
244 struct acpi_device_power_flags flags; 232 struct acpi_device_power_flags flags;
245 struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ 233 struct acpi_device_power_state states[4]; /* Power states (D0-D3) */
246}; 234};
247 235
248
249/* Performance Management */ 236/* Performance Management */
250 237
251struct acpi_device_perf_flags { 238struct acpi_device_perf_flags {
252 u8 reserved:8; 239 u8 reserved:8;
253}; 240};
254 241
255struct acpi_device_perf_state { 242struct acpi_device_perf_state {
256 struct { 243 struct {
257 u8 valid:1; 244 u8 valid:1;
258 u8 reserved:7; 245 u8 reserved:7;
259 } flags; 246 } flags;
260 u8 power; /* % Power (compared to P0) */ 247 u8 power; /* % Power (compared to P0) */
261 u8 performance; /* % Performance ( " ) */ 248 u8 performance; /* % Performance ( " ) */
262 int latency; /* Px->P0 time (microseconds) */ 249 int latency; /* Px->P0 time (microseconds) */
263}; 250};
264 251
265struct acpi_device_perf { 252struct acpi_device_perf {
266 int state; 253 int state;
267 struct acpi_device_perf_flags flags; 254 struct acpi_device_perf_flags flags;
268 int state_count; 255 int state_count;
269 struct acpi_device_perf_state *states; 256 struct acpi_device_perf_state *states;
270}; 257};
271 258
272/* Wakeup Management */ 259/* Wakeup Management */
273struct acpi_device_wakeup_flags { 260struct acpi_device_wakeup_flags {
274 u8 valid:1; /* Can successfully enable wakeup? */ 261 u8 valid:1; /* Can successfully enable wakeup? */
275 u8 run_wake:1; /* Run-Wake GPE devices */ 262 u8 run_wake:1; /* Run-Wake GPE devices */
276}; 263};
277 264
278struct acpi_device_wakeup_state { 265struct acpi_device_wakeup_state {
279 u8 enabled:1; 266 u8 enabled:1;
280 u8 active:1; 267 u8 active:1;
281}; 268};
282 269
283struct acpi_device_wakeup { 270struct acpi_device_wakeup {
284 acpi_handle gpe_device; 271 acpi_handle gpe_device;
285 acpi_integer gpe_number;; 272 acpi_integer gpe_number;;
286 acpi_integer sleep_state; 273 acpi_integer sleep_state;
287 struct acpi_handle_list resources; 274 struct acpi_handle_list resources;
288 struct acpi_device_wakeup_state state; 275 struct acpi_device_wakeup_state state;
289 struct acpi_device_wakeup_flags flags; 276 struct acpi_device_wakeup_flags flags;
290}; 277};
291 278
292/* Device */ 279/* Device */
293 280
294struct acpi_device { 281struct acpi_device {
295 acpi_handle handle; 282 acpi_handle handle;
296 struct acpi_device *parent; 283 struct acpi_device *parent;
297 struct list_head children; 284 struct list_head children;
298 struct list_head node; 285 struct list_head node;
299 struct list_head wakeup_list; 286 struct list_head wakeup_list;
300 struct list_head g_list; 287 struct list_head g_list;
301 struct acpi_device_status status; 288 struct acpi_device_status status;
302 struct acpi_device_flags flags; 289 struct acpi_device_flags flags;
303 struct acpi_device_pnp pnp; 290 struct acpi_device_pnp pnp;
304 struct acpi_device_power power; 291 struct acpi_device_power power;
305 struct acpi_device_wakeup wakeup; 292 struct acpi_device_wakeup wakeup;
306 struct acpi_device_perf performance; 293 struct acpi_device_perf performance;
307 struct acpi_device_dir dir; 294 struct acpi_device_dir dir;
308 struct acpi_device_ops ops; 295 struct acpi_device_ops ops;
309 struct acpi_driver *driver; 296 struct acpi_driver *driver;
310 void *driver_data; 297 void *driver_data;
311 struct kobject kobj; 298 struct kobject kobj;
312}; 299};
313 300
314#define acpi_driver_data(d) ((d)->driver_data) 301#define acpi_driver_data(d) ((d)->driver_data)
315 302
316
317/* 303/*
318 * Events 304 * Events
319 * ------ 305 * ------
320 */ 306 */
321 307
322struct acpi_bus_event { 308struct acpi_bus_event {
323 struct list_head node; 309 struct list_head node;
324 acpi_device_class device_class; 310 acpi_device_class device_class;
325 acpi_bus_id bus_id; 311 acpi_bus_id bus_id;
326 u32 type; 312 u32 type;
327 u32 data; 313 u32 data;
328}; 314};
329 315
330extern struct subsystem acpi_subsys; 316extern struct subsystem acpi_subsys;
@@ -335,34 +321,32 @@ extern struct subsystem acpi_subsys;
335 321
336int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 322int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
337void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context); 323void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context);
338int acpi_bus_get_status (struct acpi_device *device); 324int acpi_bus_get_status(struct acpi_device *device);
339int acpi_bus_get_power (acpi_handle handle, int *state); 325int acpi_bus_get_power(acpi_handle handle, int *state);
340int acpi_bus_set_power (acpi_handle handle, int state); 326int acpi_bus_set_power(acpi_handle handle, int state);
341int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data); 327int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data);
342int acpi_bus_receive_event (struct acpi_bus_event *event); 328int acpi_bus_receive_event(struct acpi_bus_event *event);
343int acpi_bus_register_driver (struct acpi_driver *driver); 329int acpi_bus_register_driver(struct acpi_driver *driver);
344int acpi_bus_unregister_driver (struct acpi_driver *driver); 330int acpi_bus_unregister_driver(struct acpi_driver *driver);
345int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent, 331int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
346 acpi_handle handle, int type); 332 acpi_handle handle, int type);
347int acpi_bus_start (struct acpi_device *device); 333int acpi_bus_start(struct acpi_device *device);
348 334
349 335int acpi_match_ids(struct acpi_device *device, char *ids);
350int acpi_match_ids (struct acpi_device *device, char *ids);
351int acpi_create_dir(struct acpi_device *); 336int acpi_create_dir(struct acpi_device *);
352void acpi_remove_dir(struct acpi_device *); 337void acpi_remove_dir(struct acpi_device *);
353 338
354
355/* 339/*
356 * Bind physical devices with ACPI devices 340 * Bind physical devices with ACPI devices
357 */ 341 */
358#include <linux/device.h> 342#include <linux/device.h>
359struct acpi_bus_type { 343struct acpi_bus_type {
360 struct list_head list; 344 struct list_head list;
361 struct bus_type *bus; 345 struct bus_type *bus;
362 /* For general devices under the bus*/ 346 /* For general devices under the bus */
363 int (*find_device)(struct device *, acpi_handle*); 347 int (*find_device) (struct device *, acpi_handle *);
364 /* For bridges, such as PCI root bridge, IDE controller */ 348 /* For bridges, such as PCI root bridge, IDE controller */
365 int (*find_bridge)(struct device *, acpi_handle *); 349 int (*find_bridge) (struct device *, acpi_handle *);
366}; 350};
367int register_acpi_bus_type(struct acpi_bus_type *); 351int register_acpi_bus_type(struct acpi_bus_type *);
368int unregister_acpi_bus_type(struct acpi_bus_type *); 352int unregister_acpi_bus_type(struct acpi_bus_type *);
@@ -372,6 +356,6 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer);
372acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 356acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
373#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data)) 357#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data))
374 358
375#endif /*CONFIG_ACPI_BUS*/ 359#endif /* CONFIG_ACPI */
376 360
377#endif /*__ACPI_BUS_H__*/ 361#endif /*__ACPI_BUS_H__*/
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 579fe191b7e7..c1b4e1f882e4 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -29,7 +29,6 @@
29#include <linux/acpi.h> 29#include <linux/acpi.h>
30#include <acpi/acpi_bus.h> 30#include <acpi/acpi_bus.h>
31 31
32
33#define ACPI_MAX_STRING 80 32#define ACPI_MAX_STRING 80
34 33
35#define ACPI_BUS_COMPONENT 0x00010000 34#define ACPI_BUS_COMPONENT 0x00010000
@@ -44,60 +43,55 @@
44#define ACPI_BUTTON_HID_POWERF "ACPI_FPB" 43#define ACPI_BUTTON_HID_POWERF "ACPI_FPB"
45#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" 44#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB"
46 45
47
48/* -------------------------------------------------------------------------- 46/* --------------------------------------------------------------------------
49 PCI 47 PCI
50 -------------------------------------------------------------------------- */ 48 -------------------------------------------------------------------------- */
51 49
52#ifdef CONFIG_ACPI_PCI
53
54#define ACPI_PCI_COMPONENT 0x00400000 50#define ACPI_PCI_COMPONENT 0x00400000
55 51
56/* ACPI PCI Interrupt Link (pci_link.c) */ 52/* ACPI PCI Interrupt Link (pci_link.c) */
57 53
58int acpi_irq_penalty_init (void); 54int acpi_irq_penalty_init(void);
59int acpi_pci_link_allocate_irq (acpi_handle handle, int index, int *edge_level, 55int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level,
60 int *active_high_low, char **name); 56 int *active_high_low, char **name);
61int acpi_pci_link_free_irq(acpi_handle handle); 57int acpi_pci_link_free_irq(acpi_handle handle);
62 58
63/* ACPI PCI Interrupt Routing (pci_irq.c) */ 59/* ACPI PCI Interrupt Routing (pci_irq.c) */
64 60
65int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus); 61int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus);
66void acpi_pci_irq_del_prt (int segment, int bus); 62void acpi_pci_irq_del_prt(int segment, int bus);
67 63
68/* ACPI PCI Device Binding (pci_bind.c) */ 64/* ACPI PCI Device Binding (pci_bind.c) */
69 65
70struct pci_bus; 66struct pci_bus;
71 67
72acpi_status acpi_get_pci_id (acpi_handle handle, struct acpi_pci_id *id); 68acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id);
73int acpi_pci_bind (struct acpi_device *device); 69int acpi_pci_bind(struct acpi_device *device);
74int acpi_pci_unbind (struct acpi_device *device); 70int acpi_pci_unbind(struct acpi_device *device);
75int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); 71int acpi_pci_bind_root(struct acpi_device *device, struct acpi_pci_id *id,
72 struct pci_bus *bus);
76 73
77/* Arch-defined function to add a bus to the system */ 74/* Arch-defined function to add a bus to the system */
78 75
79struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, int bus); 76struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain,
80 77 int bus);
81#endif /*CONFIG_ACPI_PCI*/
82
83 78
84/* -------------------------------------------------------------------------- 79/* --------------------------------------------------------------------------
85 Power Resource 80 Power Resource
86 -------------------------------------------------------------------------- */ 81 -------------------------------------------------------------------------- */
87 82
88#ifdef CONFIG_ACPI_POWER 83#ifdef CONFIG_ACPI_POWER
89int acpi_enable_wakeup_device_power (struct acpi_device *dev); 84int acpi_enable_wakeup_device_power(struct acpi_device *dev);
90int acpi_disable_wakeup_device_power (struct acpi_device *dev); 85int acpi_disable_wakeup_device_power(struct acpi_device *dev);
91int acpi_power_get_inferred_state (struct acpi_device *device); 86int acpi_power_get_inferred_state(struct acpi_device *device);
92int acpi_power_transition (struct acpi_device *device, int state); 87int acpi_power_transition(struct acpi_device *device, int state);
93#endif 88#endif
94 89
95
96/* -------------------------------------------------------------------------- 90/* --------------------------------------------------------------------------
97 Embedded Controller 91 Embedded Controller
98 -------------------------------------------------------------------------- */ 92 -------------------------------------------------------------------------- */
99#ifdef CONFIG_ACPI_EC 93#ifdef CONFIG_ACPI_EC
100int acpi_ec_ecdt_probe (void); 94int acpi_ec_ecdt_probe(void);
101#endif 95#endif
102 96
103/* -------------------------------------------------------------------------- 97/* --------------------------------------------------------------------------
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index ea489f235216..98e0b8cd14ed 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -7,7 +7,6 @@
7 * 7 *
8 *****************************************************************************/ 8 *****************************************************************************/
9 9
10
11/* 10/*
12 * Copyright (C) 2000 - 2005, R. Byron Moore 11 * Copyright (C) 2000 - 2005, R. Byron Moore
13 * All rights reserved. 12 * All rights reserved.
@@ -51,7 +50,6 @@
51#include "platform/acenv.h" 50#include "platform/acenv.h"
52#include "actypes.h" 51#include "actypes.h"
53 52
54
55/* Priorities for acpi_os_queue_for_execution */ 53/* Priorities for acpi_os_queue_for_execution */
56 54
57#define OSD_PRIORITY_GPE 1 55#define OSD_PRIORITY_GPE 1
@@ -62,200 +60,136 @@
62#define ACPI_NO_UNIT_LIMIT ((u32) -1) 60#define ACPI_NO_UNIT_LIMIT ((u32) -1)
63#define ACPI_MUTEX_SEM 1 61#define ACPI_MUTEX_SEM 1
64 62
65
66/* Functions for acpi_os_signal */ 63/* Functions for acpi_os_signal */
67 64
68#define ACPI_SIGNAL_FATAL 0 65#define ACPI_SIGNAL_FATAL 0
69#define ACPI_SIGNAL_BREAKPOINT 1 66#define ACPI_SIGNAL_BREAKPOINT 1
70 67
71struct acpi_signal_fatal_info 68struct acpi_signal_fatal_info {
72{ 69 u32 type;
73 u32 type; 70 u32 code;
74 u32 code; 71 u32 argument;
75 u32 argument;
76}; 72};
77 73
78
79/* 74/*
80 * OSL Initialization and shutdown primitives 75 * OSL Initialization and shutdown primitives
81 */ 76 */
82acpi_status 77acpi_status acpi_os_initialize(void);
83acpi_os_initialize (
84 void);
85
86acpi_status
87acpi_os_terminate (
88 void);
89 78
79acpi_status acpi_os_terminate(void);
90 80
91/* 81/*
92 * ACPI Table interfaces 82 * ACPI Table interfaces
93 */ 83 */
94acpi_status 84acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *address);
95acpi_os_get_root_pointer (
96 u32 flags,
97 struct acpi_pointer *address);
98 85
99acpi_status 86acpi_status
100acpi_os_predefined_override ( 87acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
101 const struct acpi_predefined_names *init_val, 88 acpi_string * new_val);
102 acpi_string *new_val);
103 89
104acpi_status 90acpi_status
105acpi_os_table_override ( 91acpi_os_table_override(struct acpi_table_header *existing_table,
106 struct acpi_table_header *existing_table, 92 struct acpi_table_header **new_table);
107 struct acpi_table_header **new_table);
108
109 93
110/* 94/*
111 * Synchronization primitives 95 * Synchronization primitives
112 */ 96 */
113acpi_status 97acpi_status
114acpi_os_create_semaphore ( 98acpi_os_create_semaphore(u32 max_units,
115 u32 max_units, 99 u32 initial_units, acpi_handle * out_handle);
116 u32 initial_units,
117 acpi_handle *out_handle);
118
119acpi_status
120acpi_os_delete_semaphore (
121 acpi_handle handle);
122 100
123acpi_status 101acpi_status acpi_os_delete_semaphore(acpi_handle handle);
124acpi_os_wait_semaphore (
125 acpi_handle handle,
126 u32 units,
127 u16 timeout);
128 102
129acpi_status 103acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout);
130acpi_os_signal_semaphore (
131 acpi_handle handle,
132 u32 units);
133 104
134acpi_status 105acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units);
135acpi_os_create_lock (
136 acpi_handle *out_handle);
137 106
138void 107acpi_status acpi_os_create_lock(acpi_handle * out_handle);
139acpi_os_delete_lock (
140 acpi_handle handle);
141 108
142void 109void acpi_os_delete_lock(acpi_handle handle);
143acpi_os_acquire_lock (
144 acpi_handle handle,
145 u32 flags);
146 110
147void 111unsigned long acpi_os_acquire_lock(acpi_handle handle);
148acpi_os_release_lock (
149 acpi_handle handle,
150 u32 flags);
151 112
113void acpi_os_release_lock(acpi_handle handle, unsigned long flags);
152 114
153/* 115/*
154 * Memory allocation and mapping 116 * Memory allocation and mapping
155 */ 117 */
156void * 118void *acpi_os_allocate(acpi_size size);
157acpi_os_allocate (
158 acpi_size size);
159 119
160void 120void acpi_os_free(void *memory);
161acpi_os_free (
162 void * memory);
163 121
164acpi_status 122acpi_status
165acpi_os_map_memory ( 123acpi_os_map_memory(acpi_physical_address physical_address,
166 acpi_physical_address physical_address, 124 acpi_size size, void __iomem ** logical_address);
167 acpi_size size,
168 void __iomem **logical_address);
169 125
170void 126void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
171acpi_os_unmap_memory (
172 void __iomem *logical_address,
173 acpi_size size);
174 127
175#ifdef ACPI_FUTURE_USAGE 128#ifdef ACPI_FUTURE_USAGE
176acpi_status 129acpi_status
177acpi_os_get_physical_address ( 130acpi_os_get_physical_address(void *logical_address,
178 void *logical_address, 131 acpi_physical_address * physical_address);
179 acpi_physical_address *physical_address);
180#endif 132#endif
181 133
134/*
135 * Memory/Object Cache
136 */
137acpi_status
138acpi_os_create_cache(char *cache_name,
139 u16 object_size,
140 u16 max_depth, acpi_cache_t ** return_cache);
141
142acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
143
144acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
145
146void *acpi_os_acquire_object(acpi_cache_t * cache);
147
148acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
182 149
183/* 150/*
184 * Interrupt handlers 151 * Interrupt handlers
185 */ 152 */
186acpi_status 153acpi_status
187acpi_os_install_interrupt_handler ( 154acpi_os_install_interrupt_handler(u32 gsi,
188 u32 gsi, 155 acpi_osd_handler service_routine,
189 acpi_osd_handler service_routine, 156 void *context);
190 void *context);
191 157
192acpi_status 158acpi_status
193acpi_os_remove_interrupt_handler ( 159acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine);
194 u32 gsi,
195 acpi_osd_handler service_routine);
196
197 160
198/* 161/*
199 * Threads and Scheduling 162 * Threads and Scheduling
200 */ 163 */
201u32 164u32 acpi_os_get_thread_id(void);
202acpi_os_get_thread_id (
203 void);
204 165
205acpi_status 166acpi_status
206acpi_os_queue_for_execution ( 167acpi_os_queue_for_execution(u32 priority,
207 u32 priority, 168 acpi_osd_exec_callback function, void *context);
208 acpi_osd_exec_callback function,
209 void *context);
210 169
211void 170void acpi_os_wait_events_complete(void *context);
212acpi_os_wait_events_complete(
213 void * context);
214 171
215void 172void acpi_os_wait_events_complete(void *context);
216acpi_os_wait_events_complete (
217 void *context);
218 173
219void 174void acpi_os_sleep(acpi_integer milliseconds);
220acpi_os_sleep (
221 acpi_integer milliseconds);
222
223void
224acpi_os_stall (
225 u32 microseconds);
226 175
176void acpi_os_stall(u32 microseconds);
227 177
228/* 178/*
229 * Platform and hardware-independent I/O interfaces 179 * Platform and hardware-independent I/O interfaces
230 */ 180 */
231acpi_status 181acpi_status acpi_os_read_port(acpi_io_address address, u32 * value, u32 width);
232acpi_os_read_port (
233 acpi_io_address address,
234 u32 *value,
235 u32 width);
236
237acpi_status
238acpi_os_write_port (
239 acpi_io_address address,
240 u32 value,
241 u32 width);
242 182
183acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
243 184
244/* 185/*
245 * Platform and hardware-independent physical memory interfaces 186 * Platform and hardware-independent physical memory interfaces
246 */ 187 */
247acpi_status 188acpi_status
248acpi_os_read_memory ( 189acpi_os_read_memory(acpi_physical_address address, u32 * value, u32 width);
249 acpi_physical_address address,
250 u32 *value,
251 u32 width);
252 190
253acpi_status 191acpi_status
254acpi_os_write_memory ( 192acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width);
255 acpi_physical_address address,
256 u32 value,
257 u32 width);
258
259 193
260/* 194/*
261 * Platform and hardware-independent PCI configuration space access 195 * Platform and hardware-independent PCI configuration space access
@@ -263,111 +197,69 @@ acpi_os_write_memory (
263 * certain compilers complain. 197 * certain compilers complain.
264 */ 198 */
265acpi_status 199acpi_status
266acpi_os_read_pci_configuration ( 200acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
267 struct acpi_pci_id *pci_id, 201 u32 reg, void *value, u32 width);
268 u32 reg,
269 void *value,
270 u32 width);
271 202
272acpi_status 203acpi_status
273acpi_os_write_pci_configuration ( 204acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
274 struct acpi_pci_id *pci_id, 205 u32 reg, acpi_integer value, u32 width);
275 u32 reg,
276 acpi_integer value,
277 u32 width);
278 206
279/* 207/*
280 * Interim function needed for PCI IRQ routing 208 * Interim function needed for PCI IRQ routing
281 */ 209 */
282void 210void
283acpi_os_derive_pci_id( 211acpi_os_derive_pci_id(acpi_handle rhandle,
284 acpi_handle rhandle, 212 acpi_handle chandle, struct acpi_pci_id **pci_id);
285 acpi_handle chandle,
286 struct acpi_pci_id **pci_id);
287 213
288/* 214/*
289 * Miscellaneous 215 * Miscellaneous
290 */ 216 */
291u8 217u8 acpi_os_readable(void *pointer, acpi_size length);
292acpi_os_readable (
293 void *pointer,
294 acpi_size length);
295 218
296#ifdef ACPI_FUTURE_USAGE 219#ifdef ACPI_FUTURE_USAGE
297u8 220u8 acpi_os_writable(void *pointer, acpi_size length);
298acpi_os_writable (
299 void *pointer,
300 acpi_size length);
301#endif 221#endif
302 222
303u64 223u64 acpi_os_get_timer(void);
304acpi_os_get_timer (
305 void);
306 224
307acpi_status 225acpi_status acpi_os_signal(u32 function, void *info);
308acpi_os_signal (
309 u32 function,
310 void *info);
311 226
312/* 227/*
313 * Debug print routines 228 * Debug print routines
314 */ 229 */
315void ACPI_INTERNAL_VAR_XFACE 230void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
316acpi_os_printf (
317 const char *format,
318 ...);
319
320void
321acpi_os_vprintf (
322 const char *format,
323 va_list args);
324 231
325void 232void acpi_os_vprintf(const char *format, va_list args);
326acpi_os_redirect_output (
327 void *destination);
328 233
234void acpi_os_redirect_output(void *destination);
329 235
330#ifdef ACPI_FUTURE_USAGE 236#ifdef ACPI_FUTURE_USAGE
331/* 237/*
332 * Debug input 238 * Debug input
333 */ 239 */
334u32 240u32 acpi_os_get_line(char *buffer);
335acpi_os_get_line (
336 char *buffer);
337#endif 241#endif
338 242
339
340/* 243/*
341 * Directory manipulation 244 * Directory manipulation
342 */ 245 */
343void * 246void *acpi_os_open_directory(char *pathname,
344acpi_os_open_directory ( 247 char *wildcard_spec, char requested_file_type);
345 char *pathname,
346 char *wildcard_spec,
347 char requested_file_type);
348 248
349/* requeste_file_type values */ 249/* requeste_file_type values */
350 250
351#define REQUEST_FILE_ONLY 0 251#define REQUEST_FILE_ONLY 0
352#define REQUEST_DIR_ONLY 1 252#define REQUEST_DIR_ONLY 1
353 253
254char *acpi_os_get_next_filename(void *dir_handle);
354 255
355char * 256void acpi_os_close_directory(void *dir_handle);
356acpi_os_get_next_filename (
357 void *dir_handle);
358
359void
360acpi_os_close_directory (
361 void *dir_handle);
362 257
363/* 258/*
364 * Debug 259 * Debug
365 */ 260 */
366void 261void
367acpi_os_dbg_assert( 262acpi_os_dbg_assert(void *failed_assertion,
368 void *failed_assertion, 263 void *file_name, u32 line_number, char *message);
369 void *file_name,
370 u32 line_number,
371 char *message);
372 264
373#endif /* __ACPIOSXF_H__ */ 265#endif /* __ACPIOSXF_H__ */
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index f8f619f8e4f8..2a9dbc13b0f2 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -42,447 +42,283 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#ifndef __ACXFACE_H__ 45#ifndef __ACXFACE_H__
47#define __ACXFACE_H__ 46#define __ACXFACE_H__
48 47
49#include "actypes.h" 48#include "actypes.h"
50#include "actbl.h" 49#include "actbl.h"
51 50
52
53/* 51/*
54 * Global interfaces 52 * Global interfaces
55 */ 53 */
56acpi_status 54acpi_status acpi_initialize_subsystem(void);
57acpi_initialize_subsystem (
58 void);
59 55
60acpi_status 56acpi_status acpi_enable_subsystem(u32 flags);
61acpi_enable_subsystem (
62 u32 flags);
63 57
64acpi_status 58acpi_status acpi_initialize_objects(u32 flags);
65acpi_initialize_objects (
66 u32 flags);
67 59
68acpi_status 60acpi_status acpi_terminate(void);
69acpi_terminate (
70 void);
71 61
72#ifdef ACPI_FUTURE_USAGE 62#ifdef ACPI_FUTURE_USAGE
73acpi_status 63acpi_status acpi_subsystem_status(void);
74acpi_subsystem_status (
75 void);
76#endif 64#endif
77 65
78acpi_status 66acpi_status acpi_enable(void);
79acpi_enable (
80 void);
81 67
82acpi_status 68acpi_status acpi_disable(void);
83acpi_disable (
84 void);
85 69
86#ifdef ACPI_FUTURE_USAGE 70#ifdef ACPI_FUTURE_USAGE
87acpi_status 71acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer);
88acpi_get_system_info (
89 struct acpi_buffer *ret_buffer);
90#endif 72#endif
91 73
92const char * 74const char *acpi_format_exception(acpi_status exception);
93acpi_format_exception (
94 acpi_status exception);
95 75
96acpi_status 76acpi_status acpi_purge_cached_objects(void);
97acpi_purge_cached_objects (
98 void);
99 77
100#ifdef ACPI_FUTURE_USAGE 78#ifdef ACPI_FUTURE_USAGE
101acpi_status 79acpi_status
102acpi_install_initialization_handler ( 80acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
103 acpi_init_handler handler,
104 u32 function);
105#endif 81#endif
106 82
107/* 83/*
108 * ACPI Memory managment 84 * ACPI Memory managment
109 */ 85 */
110void * 86void *acpi_allocate(u32 size);
111acpi_allocate (
112 u32 size);
113
114void *
115acpi_callocate (
116 u32 size);
117 87
118void 88void *acpi_callocate(u32 size);
119acpi_free (
120 void *address);
121 89
90void acpi_free(void *address);
122 91
123/* 92/*
124 * ACPI table manipulation interfaces 93 * ACPI table manipulation interfaces
125 */ 94 */
126acpi_status 95acpi_status
127acpi_find_root_pointer ( 96acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address);
128 u32 flags,
129 struct acpi_pointer *rsdp_address);
130 97
131acpi_status 98acpi_status acpi_load_tables(void);
132acpi_load_tables (
133 void);
134 99
135#ifdef ACPI_FUTURE_USAGE 100#ifdef ACPI_FUTURE_USAGE
136acpi_status 101acpi_status acpi_load_table(struct acpi_table_header *table_ptr);
137acpi_load_table (
138 struct acpi_table_header *table_ptr);
139 102
140acpi_status 103acpi_status acpi_unload_table(acpi_table_type table_type);
141acpi_unload_table (
142 acpi_table_type table_type);
143 104
144acpi_status 105acpi_status
145acpi_get_table_header ( 106acpi_get_table_header(acpi_table_type table_type,
146 acpi_table_type table_type, 107 u32 instance, struct acpi_table_header *out_table_header);
147 u32 instance, 108#endif /* ACPI_FUTURE_USAGE */
148 struct acpi_table_header *out_table_header);
149#endif /* ACPI_FUTURE_USAGE */
150 109
151acpi_status 110acpi_status
152acpi_get_table ( 111acpi_get_table(acpi_table_type table_type,
153 acpi_table_type table_type, 112 u32 instance, struct acpi_buffer *ret_buffer);
154 u32 instance,
155 struct acpi_buffer *ret_buffer);
156 113
157acpi_status 114acpi_status
158acpi_get_firmware_table ( 115acpi_get_firmware_table(acpi_string signature,
159 acpi_string signature, 116 u32 instance,
160 u32 instance, 117 u32 flags, struct acpi_table_header **table_pointer);
161 u32 flags,
162 struct acpi_table_header **table_pointer);
163
164 118
165/* 119/*
166 * Namespace and name interfaces 120 * Namespace and name interfaces
167 */ 121 */
168acpi_status 122acpi_status
169acpi_walk_namespace ( 123acpi_walk_namespace(acpi_object_type type,
170 acpi_object_type type, 124 acpi_handle start_object,
171 acpi_handle start_object, 125 u32 max_depth,
172 u32 max_depth, 126 acpi_walk_callback user_function,
173 acpi_walk_callback user_function, 127 void *context, void **return_value);
174 void *context,
175 void **return_value);
176 128
177acpi_status 129acpi_status
178acpi_get_devices ( 130acpi_get_devices(char *HID,
179 char *HID, 131 acpi_walk_callback user_function,
180 acpi_walk_callback user_function, 132 void *context, void **return_value);
181 void *context,
182 void **return_value);
183 133
184acpi_status 134acpi_status
185acpi_get_name ( 135acpi_get_name(acpi_handle handle,
186 acpi_handle handle, 136 u32 name_type, struct acpi_buffer *ret_path_ptr);
187 u32 name_type,
188 struct acpi_buffer *ret_path_ptr);
189 137
190acpi_status 138acpi_status
191acpi_get_handle ( 139acpi_get_handle(acpi_handle parent,
192 acpi_handle parent, 140 acpi_string pathname, acpi_handle * ret_handle);
193 acpi_string pathname,
194 acpi_handle *ret_handle);
195 141
196acpi_status 142acpi_status
197acpi_attach_data ( 143acpi_attach_data(acpi_handle obj_handle,
198 acpi_handle obj_handle, 144 acpi_object_handler handler, void *data);
199 acpi_object_handler handler,
200 void *data);
201 145
202acpi_status 146acpi_status
203acpi_detach_data ( 147acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler);
204 acpi_handle obj_handle,
205 acpi_object_handler handler);
206 148
207acpi_status 149acpi_status
208acpi_get_data ( 150acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data);
209 acpi_handle obj_handle,
210 acpi_object_handler handler,
211 void **data);
212
213 151
214/* 152/*
215 * Object manipulation and enumeration 153 * Object manipulation and enumeration
216 */ 154 */
217acpi_status 155acpi_status
218acpi_evaluate_object ( 156acpi_evaluate_object(acpi_handle object,
219 acpi_handle object, 157 acpi_string pathname,
220 acpi_string pathname, 158 struct acpi_object_list *parameter_objects,
221 struct acpi_object_list *parameter_objects, 159 struct acpi_buffer *return_object_buffer);
222 struct acpi_buffer *return_object_buffer);
223 160
224#ifdef ACPI_FUTURE_USAGE 161#ifdef ACPI_FUTURE_USAGE
225acpi_status 162acpi_status
226acpi_evaluate_object_typed ( 163acpi_evaluate_object_typed(acpi_handle object,
227 acpi_handle object, 164 acpi_string pathname,
228 acpi_string pathname, 165 struct acpi_object_list *external_params,
229 struct acpi_object_list *external_params, 166 struct acpi_buffer *return_buffer,
230 struct acpi_buffer *return_buffer, 167 acpi_object_type return_type);
231 acpi_object_type return_type);
232#endif 168#endif
233 169
234acpi_status 170acpi_status
235acpi_get_object_info ( 171acpi_get_object_info(acpi_handle handle, struct acpi_buffer *return_buffer);
236 acpi_handle handle,
237 struct acpi_buffer *return_buffer);
238 172
239acpi_status 173acpi_status
240acpi_get_next_object ( 174acpi_get_next_object(acpi_object_type type,
241 acpi_object_type type, 175 acpi_handle parent,
242 acpi_handle parent, 176 acpi_handle child, acpi_handle * out_handle);
243 acpi_handle child,
244 acpi_handle *out_handle);
245 177
246acpi_status 178acpi_status acpi_get_type(acpi_handle object, acpi_object_type * out_type);
247acpi_get_type (
248 acpi_handle object,
249 acpi_object_type *out_type);
250
251acpi_status
252acpi_get_parent (
253 acpi_handle object,
254 acpi_handle *out_handle);
255 179
180acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
256 181
257/* 182/*
258 * Event handler interfaces 183 * Event handler interfaces
259 */ 184 */
260acpi_status 185acpi_status
261acpi_install_fixed_event_handler ( 186acpi_install_fixed_event_handler(u32 acpi_event,
262 u32 acpi_event, 187 acpi_event_handler handler, void *context);
263 acpi_event_handler handler,
264 void *context);
265 188
266acpi_status 189acpi_status
267acpi_remove_fixed_event_handler ( 190acpi_remove_fixed_event_handler(u32 acpi_event, acpi_event_handler handler);
268 u32 acpi_event,
269 acpi_event_handler handler);
270 191
271acpi_status 192acpi_status
272acpi_install_notify_handler ( 193acpi_install_notify_handler(acpi_handle device,
273 acpi_handle device, 194 u32 handler_type,
274 u32 handler_type, 195 acpi_notify_handler handler, void *context);
275 acpi_notify_handler handler,
276 void *context);
277 196
278acpi_status 197acpi_status
279acpi_remove_notify_handler ( 198acpi_remove_notify_handler(acpi_handle device,
280 acpi_handle device, 199 u32 handler_type, acpi_notify_handler handler);
281 u32 handler_type,
282 acpi_notify_handler handler);
283 200
284acpi_status 201acpi_status
285acpi_install_address_space_handler ( 202acpi_install_address_space_handler(acpi_handle device,
286 acpi_handle device, 203 acpi_adr_space_type space_id,
287 acpi_adr_space_type space_id, 204 acpi_adr_space_handler handler,
288 acpi_adr_space_handler handler, 205 acpi_adr_space_setup setup, void *context);
289 acpi_adr_space_setup setup,
290 void *context);
291 206
292acpi_status 207acpi_status
293acpi_remove_address_space_handler ( 208acpi_remove_address_space_handler(acpi_handle device,
294 acpi_handle device, 209 acpi_adr_space_type space_id,
295 acpi_adr_space_type space_id, 210 acpi_adr_space_handler handler);
296 acpi_adr_space_handler handler);
297 211
298acpi_status 212acpi_status
299acpi_install_gpe_handler ( 213acpi_install_gpe_handler(acpi_handle gpe_device,
300 acpi_handle gpe_device, 214 u32 gpe_number,
301 u32 gpe_number, 215 u32 type, acpi_event_handler address, void *context);
302 u32 type,
303 acpi_event_handler address,
304 void *context);
305 216
306#ifdef ACPI_FUTURE_USAGE 217#ifdef ACPI_FUTURE_USAGE
307acpi_status 218acpi_status acpi_install_exception_handler(acpi_exception_handler handler);
308acpi_install_exception_handler (
309 acpi_exception_handler handler);
310#endif 219#endif
311 220
312
313/* 221/*
314 * Event interfaces 222 * Event interfaces
315 */ 223 */
316acpi_status 224acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle);
317acpi_acquire_global_lock (
318 u16 timeout,
319 u32 *handle);
320 225
321acpi_status 226acpi_status acpi_release_global_lock(u32 handle);
322acpi_release_global_lock (
323 u32 handle);
324 227
325acpi_status 228acpi_status
326acpi_remove_gpe_handler ( 229acpi_remove_gpe_handler(acpi_handle gpe_device,
327 acpi_handle gpe_device, 230 u32 gpe_number, acpi_event_handler address);
328 u32 gpe_number,
329 acpi_event_handler address);
330 231
331acpi_status 232acpi_status acpi_enable_event(u32 event, u32 flags);
332acpi_enable_event (
333 u32 event,
334 u32 flags);
335 233
336acpi_status 234acpi_status acpi_disable_event(u32 event, u32 flags);
337acpi_disable_event (
338 u32 event,
339 u32 flags);
340 235
341acpi_status 236acpi_status acpi_clear_event(u32 event);
342acpi_clear_event (
343 u32 event);
344 237
345#ifdef ACPI_FUTURE_USAGE 238#ifdef ACPI_FUTURE_USAGE
346acpi_status 239acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status);
347acpi_get_event_status ( 240#endif /* ACPI_FUTURE_USAGE */
348 u32 event,
349 acpi_event_status *event_status);
350#endif /* ACPI_FUTURE_USAGE */
351 241
352acpi_status 242acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type);
353acpi_set_gpe_type (
354 acpi_handle gpe_device,
355 u32 gpe_number,
356 u8 type);
357 243
358acpi_status 244acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags);
359acpi_enable_gpe (
360 acpi_handle gpe_device,
361 u32 gpe_number,
362 u32 flags);
363 245
364acpi_status 246acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags);
365acpi_disable_gpe (
366 acpi_handle gpe_device,
367 u32 gpe_number,
368 u32 flags);
369 247
370acpi_status 248acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags);
371acpi_clear_gpe (
372 acpi_handle gpe_device,
373 u32 gpe_number,
374 u32 flags);
375 249
376#ifdef ACPI_FUTURE_USAGE 250#ifdef ACPI_FUTURE_USAGE
377acpi_status 251acpi_status
378acpi_get_gpe_status ( 252acpi_get_gpe_status(acpi_handle gpe_device,
379 acpi_handle gpe_device, 253 u32 gpe_number,
380 u32 gpe_number, 254 u32 flags, acpi_event_status * event_status);
381 u32 flags, 255#endif /* ACPI_FUTURE_USAGE */
382 acpi_event_status *event_status);
383#endif /* ACPI_FUTURE_USAGE */
384 256
385acpi_status 257acpi_status
386acpi_install_gpe_block ( 258acpi_install_gpe_block(acpi_handle gpe_device,
387 acpi_handle gpe_device, 259 struct acpi_generic_address *gpe_block_address,
388 struct acpi_generic_address *gpe_block_address, 260 u32 register_count, u32 interrupt_number);
389 u32 register_count,
390 u32 interrupt_level);
391
392acpi_status
393acpi_remove_gpe_block (
394 acpi_handle gpe_device);
395 261
262acpi_status acpi_remove_gpe_block(acpi_handle gpe_device);
396 263
397/* 264/*
398 * Resource interfaces 265 * Resource interfaces
399 */ 266 */
400typedef 267typedef
401acpi_status (*ACPI_WALK_RESOURCE_CALLBACK) ( 268acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource,
402 struct acpi_resource *resource, 269 void *context);
403 void *context);
404
405 270
406acpi_status 271acpi_status
407acpi_get_current_resources( 272acpi_get_current_resources(acpi_handle device_handle,
408 acpi_handle device_handle, 273 struct acpi_buffer *ret_buffer);
409 struct acpi_buffer *ret_buffer);
410 274
411#ifdef ACPI_FUTURE_USAGE 275#ifdef ACPI_FUTURE_USAGE
412acpi_status 276acpi_status
413acpi_get_possible_resources( 277acpi_get_possible_resources(acpi_handle device_handle,
414 acpi_handle device_handle, 278 struct acpi_buffer *ret_buffer);
415 struct acpi_buffer *ret_buffer);
416#endif 279#endif
417 280
418acpi_status 281acpi_status
419acpi_walk_resources ( 282acpi_walk_resources(acpi_handle device_handle,
420 acpi_handle device_handle, 283 char *path,
421 char *path, 284 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context);
422 ACPI_WALK_RESOURCE_CALLBACK user_function,
423 void *context);
424 285
425acpi_status 286acpi_status
426acpi_set_current_resources ( 287acpi_set_current_resources(acpi_handle device_handle,
427 acpi_handle device_handle, 288 struct acpi_buffer *in_buffer);
428 struct acpi_buffer *in_buffer);
429 289
430acpi_status 290acpi_status
431acpi_get_irq_routing_table ( 291acpi_get_irq_routing_table(acpi_handle bus_device_handle,
432 acpi_handle bus_device_handle, 292 struct acpi_buffer *ret_buffer);
433 struct acpi_buffer *ret_buffer);
434 293
435acpi_status 294acpi_status
436acpi_resource_to_address64 ( 295acpi_resource_to_address64(struct acpi_resource *resource,
437 struct acpi_resource *resource, 296 struct acpi_resource_address64 *out);
438 struct acpi_resource_address64 *out);
439 297
440/* 298/*
441 * Hardware (ACPI device) interfaces 299 * Hardware (ACPI device) interfaces
442 */ 300 */
443acpi_status 301acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags);
444acpi_get_register (
445 u32 register_id,
446 u32 *return_value,
447 u32 flags);
448 302
449acpi_status 303acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags);
450acpi_set_register (
451 u32 register_id,
452 u32 value,
453 u32 flags);
454 304
455acpi_status 305acpi_status
456acpi_set_firmware_waking_vector ( 306acpi_set_firmware_waking_vector(acpi_physical_address physical_address);
457 acpi_physical_address physical_address);
458 307
459#ifdef ACPI_FUTURE_USAGE 308#ifdef ACPI_FUTURE_USAGE
460acpi_status 309acpi_status
461acpi_get_firmware_waking_vector ( 310acpi_get_firmware_waking_vector(acpi_physical_address * physical_address);
462 acpi_physical_address *physical_address);
463#endif 311#endif
464 312
465acpi_status 313acpi_status
466acpi_get_sleep_type_data ( 314acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b);
467 u8 sleep_state,
468 u8 *slp_typ_a,
469 u8 *slp_typ_b);
470 315
471acpi_status 316acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
472acpi_enter_sleep_state_prep (
473 u8 sleep_state);
474 317
475acpi_status asmlinkage 318acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
476acpi_enter_sleep_state (
477 u8 sleep_state);
478 319
479acpi_status asmlinkage 320acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
480acpi_enter_sleep_state_s4bios (
481 void);
482
483acpi_status
484acpi_leave_sleep_state (
485 u8 sleep_state);
486 321
322acpi_status acpi_leave_sleep_state(u8 sleep_state);
487 323
488#endif /* __ACXFACE_H__ */ 324#endif /* __ACXFACE_H__ */
diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h
index ed679264c12c..38e798b05d08 100644
--- a/include/acpi/acresrc.h
+++ b/include/acpi/acresrc.h
@@ -44,303 +44,216 @@
44#ifndef __ACRESRC_H__ 44#ifndef __ACRESRC_H__
45#define __ACRESRC_H__ 45#define __ACRESRC_H__
46 46
47
48/* 47/*
49 * Function prototypes called from Acpi* APIs 48 * Function prototypes called from Acpi* APIs
50 */ 49 */
51acpi_status 50acpi_status
52acpi_rs_get_prt_method_data ( 51acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
53 acpi_handle handle,
54 struct acpi_buffer *ret_buffer);
55
56 52
57acpi_status 53acpi_status
58acpi_rs_get_crs_method_data ( 54acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
59 acpi_handle handle,
60 struct acpi_buffer *ret_buffer);
61 55
62#ifdef ACPI_FUTURE_USAGE 56#ifdef ACPI_FUTURE_USAGE
63acpi_status 57acpi_status
64acpi_rs_get_prs_method_data ( 58acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
65 acpi_handle handle, 59#endif /* ACPI_FUTURE_USAGE */
66 struct acpi_buffer *ret_buffer);
67#endif /* ACPI_FUTURE_USAGE */
68 60
69acpi_status 61acpi_status
70acpi_rs_get_method_data ( 62acpi_rs_get_method_data(acpi_handle handle,
71 acpi_handle handle, 63 char *path, struct acpi_buffer *ret_buffer);
72 char *path,
73 struct acpi_buffer *ret_buffer);
74 64
75acpi_status 65acpi_status
76acpi_rs_set_srs_method_data ( 66acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
77 acpi_handle handle,
78 struct acpi_buffer *ret_buffer);
79 67
80acpi_status 68acpi_status
81acpi_rs_create_resource_list ( 69acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
82 union acpi_operand_object *byte_stream_buffer, 70 struct acpi_buffer *output_buffer);
83 struct acpi_buffer *output_buffer);
84 71
85acpi_status 72acpi_status
86acpi_rs_create_byte_stream ( 73acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
87 struct acpi_resource *linked_list_buffer, 74 struct acpi_buffer *output_buffer);
88 struct acpi_buffer *output_buffer);
89 75
90acpi_status 76acpi_status
91acpi_rs_create_pci_routing_table ( 77acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
92 union acpi_operand_object *package_object, 78 struct acpi_buffer *output_buffer);
93 struct acpi_buffer *output_buffer);
94
95 79
96/* 80/*
97 * rsdump 81 * rsdump
98 */ 82 */
99#ifdef ACPI_FUTURE_USAGE 83#ifdef ACPI_FUTURE_USAGE
100void 84void acpi_rs_dump_resource_list(struct acpi_resource *resource);
101acpi_rs_dump_resource_list (
102 struct acpi_resource *resource);
103
104void
105acpi_rs_dump_irq_list (
106 u8 *route_table);
107#endif /* ACPI_FUTURE_USAGE */
108 85
86void acpi_rs_dump_irq_list(u8 * route_table);
87#endif /* ACPI_FUTURE_USAGE */
109 88
110/* 89/*
111 * rscalc 90 * rscalc
112 */ 91 */
113acpi_status 92acpi_status
114acpi_rs_get_byte_stream_start ( 93acpi_rs_get_byte_stream_start(u8 * byte_stream_buffer,
115 u8 *byte_stream_buffer, 94 u8 ** byte_stream_start, u32 * size);
116 u8 **byte_stream_start,
117 u32 *size);
118 95
119acpi_status 96acpi_status
120acpi_rs_get_list_length ( 97acpi_rs_get_list_length(u8 * byte_stream_buffer,
121 u8 *byte_stream_buffer, 98 u32 byte_stream_buffer_length, acpi_size * size_needed);
122 u32 byte_stream_buffer_length,
123 acpi_size *size_needed);
124 99
125acpi_status 100acpi_status
126acpi_rs_get_byte_stream_length ( 101acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list_buffer,
127 struct acpi_resource *linked_list_buffer, 102 acpi_size * size_needed);
128 acpi_size *size_needed);
129 103
130acpi_status 104acpi_status
131acpi_rs_get_pci_routing_table_length ( 105acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
132 union acpi_operand_object *package_object, 106 acpi_size * buffer_size_needed);
133 acpi_size *buffer_size_needed);
134 107
135acpi_status 108acpi_status
136acpi_rs_byte_stream_to_list ( 109acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
137 u8 *byte_stream_buffer, 110 u32 byte_stream_buffer_length, u8 * output_buffer);
138 u32 byte_stream_buffer_length,
139 u8 *output_buffer);
140 111
141acpi_status 112acpi_status
142acpi_rs_list_to_byte_stream ( 113acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list,
143 struct acpi_resource *linked_list, 114 acpi_size byte_stream_size_needed,
144 acpi_size byte_stream_size_needed, 115 u8 * output_buffer);
145 u8 *output_buffer);
146 116
147acpi_status 117acpi_status
148acpi_rs_io_resource ( 118acpi_rs_io_resource(u8 * byte_stream_buffer,
149 u8 *byte_stream_buffer, 119 acpi_size * bytes_consumed,
150 acpi_size *bytes_consumed, 120 u8 ** output_buffer, acpi_size * structure_size);
151 u8 **output_buffer,
152 acpi_size *structure_size);
153 121
154acpi_status 122acpi_status
155acpi_rs_fixed_io_resource ( 123acpi_rs_fixed_io_resource(u8 * byte_stream_buffer,
156 u8 *byte_stream_buffer, 124 acpi_size * bytes_consumed,
157 acpi_size *bytes_consumed, 125 u8 ** output_buffer, acpi_size * structure_size);
158 u8 **output_buffer,
159 acpi_size *structure_size);
160 126
161acpi_status 127acpi_status
162acpi_rs_io_stream ( 128acpi_rs_io_stream(struct acpi_resource *linked_list,
163 struct acpi_resource *linked_list, 129 u8 ** output_buffer, acpi_size * bytes_consumed);
164 u8 **output_buffer,
165 acpi_size *bytes_consumed);
166 130
167acpi_status 131acpi_status
168acpi_rs_fixed_io_stream ( 132acpi_rs_fixed_io_stream(struct acpi_resource *linked_list,
169 struct acpi_resource *linked_list, 133 u8 ** output_buffer, acpi_size * bytes_consumed);
170 u8 **output_buffer,
171 acpi_size *bytes_consumed);
172 134
173acpi_status 135acpi_status
174acpi_rs_irq_resource ( 136acpi_rs_irq_resource(u8 * byte_stream_buffer,
175 u8 *byte_stream_buffer, 137 acpi_size * bytes_consumed,
176 acpi_size *bytes_consumed, 138 u8 ** output_buffer, acpi_size * structure_size);
177 u8 **output_buffer,
178 acpi_size *structure_size);
179 139
180acpi_status 140acpi_status
181acpi_rs_irq_stream ( 141acpi_rs_irq_stream(struct acpi_resource *linked_list,
182 struct acpi_resource *linked_list, 142 u8 ** output_buffer, acpi_size * bytes_consumed);
183 u8 **output_buffer,
184 acpi_size *bytes_consumed);
185 143
186acpi_status 144acpi_status
187acpi_rs_dma_resource ( 145acpi_rs_dma_resource(u8 * byte_stream_buffer,
188 u8 *byte_stream_buffer, 146 acpi_size * bytes_consumed,
189 acpi_size *bytes_consumed, 147 u8 ** output_buffer, acpi_size * structure_size);
190 u8 **output_buffer,
191 acpi_size *structure_size);
192 148
193acpi_status 149acpi_status
194acpi_rs_dma_stream ( 150acpi_rs_dma_stream(struct acpi_resource *linked_list,
195 struct acpi_resource *linked_list, 151 u8 ** output_buffer, acpi_size * bytes_consumed);
196 u8 **output_buffer,
197 acpi_size *bytes_consumed);
198 152
199acpi_status 153acpi_status
200acpi_rs_address16_resource ( 154acpi_rs_address16_resource(u8 * byte_stream_buffer,
201 u8 *byte_stream_buffer, 155 acpi_size * bytes_consumed,
202 acpi_size *bytes_consumed, 156 u8 ** output_buffer, acpi_size * structure_size);
203 u8 **output_buffer,
204 acpi_size *structure_size);
205 157
206acpi_status 158acpi_status
207acpi_rs_address16_stream ( 159acpi_rs_address16_stream(struct acpi_resource *linked_list,
208 struct acpi_resource *linked_list, 160 u8 ** output_buffer, acpi_size * bytes_consumed);
209 u8 **output_buffer,
210 acpi_size *bytes_consumed);
211 161
212acpi_status 162acpi_status
213acpi_rs_address32_resource ( 163acpi_rs_address32_resource(u8 * byte_stream_buffer,
214 u8 *byte_stream_buffer, 164 acpi_size * bytes_consumed,
215 acpi_size *bytes_consumed, 165 u8 ** output_buffer, acpi_size * structure_size);
216 u8 **output_buffer,
217 acpi_size *structure_size);
218 166
219acpi_status 167acpi_status
220acpi_rs_address32_stream ( 168acpi_rs_address32_stream(struct acpi_resource *linked_list,
221 struct acpi_resource *linked_list, 169 u8 ** output_buffer, acpi_size * bytes_consumed);
222 u8 **output_buffer,
223 acpi_size *bytes_consumed);
224 170
225acpi_status 171acpi_status
226acpi_rs_address64_resource ( 172acpi_rs_address64_resource(u8 * byte_stream_buffer,
227 u8 *byte_stream_buffer, 173 acpi_size * bytes_consumed,
228 acpi_size *bytes_consumed, 174 u8 ** output_buffer, acpi_size * structure_size);
229 u8 **output_buffer,
230 acpi_size *structure_size);
231 175
232acpi_status 176acpi_status
233acpi_rs_address64_stream ( 177acpi_rs_address64_stream(struct acpi_resource *linked_list,
234 struct acpi_resource *linked_list, 178 u8 ** output_buffer, acpi_size * bytes_consumed);
235 u8 **output_buffer,
236 acpi_size *bytes_consumed);
237 179
238acpi_status 180acpi_status
239acpi_rs_start_depend_fns_resource ( 181acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer,
240 u8 *byte_stream_buffer, 182 acpi_size * bytes_consumed,
241 acpi_size *bytes_consumed, 183 u8 ** output_buffer,
242 u8 **output_buffer, 184 acpi_size * structure_size);
243 acpi_size *structure_size);
244 185
245acpi_status 186acpi_status
246acpi_rs_end_depend_fns_resource ( 187acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
247 u8 *byte_stream_buffer, 188 acpi_size * bytes_consumed,
248 acpi_size *bytes_consumed, 189 u8 ** output_buffer,
249 u8 **output_buffer, 190 acpi_size * structure_size);
250 acpi_size *structure_size);
251 191
252acpi_status 192acpi_status
253acpi_rs_start_depend_fns_stream ( 193acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
254 struct acpi_resource *linked_list, 194 u8 ** output_buffer,
255 u8 **output_buffer, 195 acpi_size * bytes_consumed);
256 acpi_size *bytes_consumed);
257 196
258acpi_status 197acpi_status
259acpi_rs_end_depend_fns_stream ( 198acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list,
260 struct acpi_resource *linked_list, 199 u8 ** output_buffer, acpi_size * bytes_consumed);
261 u8 **output_buffer,
262 acpi_size *bytes_consumed);
263 200
264acpi_status 201acpi_status
265acpi_rs_memory24_resource ( 202acpi_rs_memory24_resource(u8 * byte_stream_buffer,
266 u8 *byte_stream_buffer, 203 acpi_size * bytes_consumed,
267 acpi_size *bytes_consumed, 204 u8 ** output_buffer, acpi_size * structure_size);
268 u8 **output_buffer,
269 acpi_size *structure_size);
270 205
271acpi_status 206acpi_status
272acpi_rs_memory24_stream ( 207acpi_rs_memory24_stream(struct acpi_resource *linked_list,
273 struct acpi_resource *linked_list, 208 u8 ** output_buffer, acpi_size * bytes_consumed);
274 u8 **output_buffer,
275 acpi_size *bytes_consumed);
276 209
277acpi_status 210acpi_status
278acpi_rs_memory32_range_resource ( 211acpi_rs_memory32_range_resource(u8 * byte_stream_buffer,
279 u8 *byte_stream_buffer, 212 acpi_size * bytes_consumed,
280 acpi_size *bytes_consumed, 213 u8 ** output_buffer,
281 u8 **output_buffer, 214 acpi_size * structure_size);
282 acpi_size *structure_size);
283 215
284acpi_status 216acpi_status
285acpi_rs_fixed_memory32_resource ( 217acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer,
286 u8 *byte_stream_buffer, 218 acpi_size * bytes_consumed,
287 acpi_size *bytes_consumed, 219 u8 ** output_buffer,
288 u8 **output_buffer, 220 acpi_size * structure_size);
289 acpi_size *structure_size);
290 221
291acpi_status 222acpi_status
292acpi_rs_memory32_range_stream ( 223acpi_rs_memory32_range_stream(struct acpi_resource *linked_list,
293 struct acpi_resource *linked_list, 224 u8 ** output_buffer, acpi_size * bytes_consumed);
294 u8 **output_buffer,
295 acpi_size *bytes_consumed);
296 225
297acpi_status 226acpi_status
298acpi_rs_fixed_memory32_stream ( 227acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list,
299 struct acpi_resource *linked_list, 228 u8 ** output_buffer, acpi_size * bytes_consumed);
300 u8 **output_buffer,
301 acpi_size *bytes_consumed);
302 229
303acpi_status 230acpi_status
304acpi_rs_extended_irq_resource ( 231acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
305 u8 *byte_stream_buffer, 232 acpi_size * bytes_consumed,
306 acpi_size *bytes_consumed, 233 u8 ** output_buffer, acpi_size * structure_size);
307 u8 **output_buffer,
308 acpi_size *structure_size);
309 234
310acpi_status 235acpi_status
311acpi_rs_extended_irq_stream ( 236acpi_rs_extended_irq_stream(struct acpi_resource *linked_list,
312 struct acpi_resource *linked_list, 237 u8 ** output_buffer, acpi_size * bytes_consumed);
313 u8 **output_buffer,
314 acpi_size *bytes_consumed);
315 238
316acpi_status 239acpi_status
317acpi_rs_end_tag_resource ( 240acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
318 u8 *byte_stream_buffer, 241 acpi_size * bytes_consumed,
319 acpi_size *bytes_consumed, 242 u8 ** output_buffer, acpi_size * structure_size);
320 u8 **output_buffer,
321 acpi_size *structure_size);
322 243
323acpi_status 244acpi_status
324acpi_rs_end_tag_stream ( 245acpi_rs_end_tag_stream(struct acpi_resource *linked_list,
325 struct acpi_resource *linked_list, 246 u8 ** output_buffer, acpi_size * bytes_consumed);
326 u8 **output_buffer,
327 acpi_size *bytes_consumed);
328 247
329acpi_status 248acpi_status
330acpi_rs_vendor_resource ( 249acpi_rs_vendor_resource(u8 * byte_stream_buffer,
331 u8 *byte_stream_buffer, 250 acpi_size * bytes_consumed,
332 acpi_size *bytes_consumed, 251 u8 ** output_buffer, acpi_size * structure_size);
333 u8 **output_buffer,
334 acpi_size *structure_size);
335 252
336acpi_status 253acpi_status
337acpi_rs_vendor_stream ( 254acpi_rs_vendor_stream(struct acpi_resource *linked_list,
338 struct acpi_resource *linked_list, 255 u8 ** output_buffer, acpi_size * bytes_consumed);
339 u8 **output_buffer,
340 acpi_size *bytes_consumed);
341 256
342u8 257u8 acpi_rs_get_resource_type(u8 resource_start_byte);
343acpi_rs_get_resource_type (
344 u8 resource_start_byte);
345 258
346#endif /* __ACRESRC_H__ */ 259#endif /* __ACRESRC_H__ */
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index e6b9e36a2eda..99d235339801 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -44,14 +44,12 @@
44#ifndef __ACSTRUCT_H__ 44#ifndef __ACSTRUCT_H__
45#define __ACSTRUCT_H__ 45#define __ACSTRUCT_H__
46 46
47
48/***************************************************************************** 47/*****************************************************************************
49 * 48 *
50 * Tree walking typedefs and structs 49 * Tree walking typedefs and structs
51 * 50 *
52 ****************************************************************************/ 51 ****************************************************************************/
53 52
54
55/* 53/*
56 * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through 54 * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through
57 * the tree (for whatever reason), and for control method execution. 55 * the tree (for whatever reason), and for control method execution.
@@ -65,152 +63,142 @@
65#define ACPI_WALK_CONST_REQUIRED 3 63#define ACPI_WALK_CONST_REQUIRED 3
66#define ACPI_WALK_CONST_OPTIONAL 4 64#define ACPI_WALK_CONST_OPTIONAL 4
67 65
68struct acpi_walk_state 66struct acpi_walk_state {
69{ 67 u8 data_type; /* To differentiate various internal objs MUST BE FIRST! */
70 u8 data_type; /* To differentiate various internal objs MUST BE FIRST!*/\ 68 u8 walk_type;
71 u8 walk_type; 69 acpi_owner_id owner_id; /* Owner of objects created during the walk */
72 acpi_owner_id owner_id; /* Owner of objects created during the walk */ 70 u8 last_predicate; /* Result of last predicate */
73 u8 last_predicate; /* Result of last predicate */ 71 u8 current_result; /* */
74 u8 reserved; /* For alignment */ 72 u8 next_op_info; /* Info about next_op */
75 u8 current_result; /* */ 73 u8 num_operands; /* Stack pointer for Operands[] array */
76 u8 next_op_info; /* Info about next_op */ 74 u8 return_used;
77 u8 num_operands; /* Stack pointer for Operands[] array */ 75 u16 opcode; /* Current AML opcode */
78 u8 return_used; 76 u8 scope_depth;
79 u16 opcode; /* Current AML opcode */ 77 u8 pass_number; /* Parse pass during table load */
80 u8 scope_depth; 78 u32 arg_count; /* push for fixed or var args */
81 u8 reserved1; 79 u32 aml_offset;
82 u32 arg_count; /* push for fixed or var args */ 80 u32 arg_types;
83 u32 aml_offset; 81 u32 method_breakpoint; /* For single stepping */
84 u32 arg_types; 82 u32 user_breakpoint; /* User AML breakpoint */
85 u32 method_breakpoint; /* For single stepping */ 83 u32 parse_flags;
86 u32 user_breakpoint; /* User AML breakpoint */ 84 u32 prev_arg_types;
87 u32 parse_flags; 85
88 u32 prev_arg_types; 86 u8 *aml_last_while;
89 87 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
90 u8 *aml_last_while; 88 union acpi_operand_object **caller_return_desc;
91 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ 89 union acpi_generic_state *control_state; /* List of control states (nested IFs) */
92 union acpi_operand_object **caller_return_desc; 90 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */
93 union acpi_generic_state *control_state; /* List of control states (nested IFs) */ 91 struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */
94 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */ 92 union acpi_operand_object *implicit_return_obj;
95 struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */ 93 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
96 union acpi_operand_object *implicit_return_obj; 94 struct acpi_namespace_node *method_call_node; /* Called method Node */
97 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ 95 union acpi_parse_object *method_call_op; /* method_call Op if running a method */
98 struct acpi_namespace_node *method_call_node; /* Called method Node*/ 96 union acpi_operand_object *method_desc; /* Method descriptor if running a method */
99 union acpi_parse_object *method_call_op; /* method_call Op if running a method */ 97 struct acpi_namespace_node *method_node; /* Method node if running a method. */
100 union acpi_operand_object *method_desc; /* Method descriptor if running a method */ 98 union acpi_parse_object *op; /* Current parser op */
101 struct acpi_namespace_node *method_node; /* Method node if running a method. */ 99 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
102 union acpi_parse_object *op; /* Current parser op */ 100 const struct acpi_opcode_info *op_info; /* Info on current opcode */
103 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ 101 union acpi_parse_object *origin; /* Start of walk [Obsolete] */
104 const struct acpi_opcode_info *op_info; /* Info on current opcode */ 102 union acpi_operand_object **params;
105 union acpi_parse_object *origin; /* Start of walk [Obsolete] */ 103 struct acpi_parse_state parser_state; /* Current state of parser */
106 union acpi_operand_object **params; 104 union acpi_operand_object *result_obj;
107 struct acpi_parse_state parser_state; /* Current state of parser */ 105 union acpi_generic_state *results; /* Stack of accumulated results */
108 union acpi_operand_object *result_obj; 106 union acpi_operand_object *return_desc; /* Return object, if any */
109 union acpi_generic_state *results; /* Stack of accumulated results */ 107 union acpi_generic_state *scope_info; /* Stack of nested scopes */
110 union acpi_operand_object *return_desc; /* Return object, if any */ 108
111 union acpi_generic_state *scope_info; /* Stack of nested scopes */ 109 union acpi_parse_object *prev_op; /* Last op that was processed */
112 110 union acpi_parse_object *next_op; /* next op to be processed */
113 union acpi_parse_object *prev_op; /* Last op that was processed */ 111 acpi_parse_downwards descending_callback;
114 union acpi_parse_object *next_op; /* next op to be processed */ 112 acpi_parse_upwards ascending_callback;
115 acpi_parse_downwards descending_callback; 113 struct acpi_thread_state *thread;
116 acpi_parse_upwards ascending_callback; 114 struct acpi_walk_state *next; /* Next walk_state in list */
117 struct acpi_thread_state *thread;
118 struct acpi_walk_state *next; /* Next walk_state in list */
119}; 115};
120 116
121
122/* Info used by acpi_ps_init_objects */ 117/* Info used by acpi_ps_init_objects */
123 118
124struct acpi_init_walk_info 119struct acpi_init_walk_info {
125{ 120 u16 method_count;
126 u16 method_count; 121 u16 device_count;
127 u16 device_count; 122 u16 op_region_count;
128 u16 op_region_count; 123 u16 field_count;
129 u16 field_count; 124 u16 buffer_count;
130 u16 buffer_count; 125 u16 package_count;
131 u16 package_count; 126 u16 op_region_init;
132 u16 op_region_init; 127 u16 field_init;
133 u16 field_init; 128 u16 buffer_init;
134 u16 buffer_init; 129 u16 package_init;
135 u16 package_init; 130 u16 object_count;
136 u16 object_count; 131 struct acpi_table_desc *table_desc;
137 struct acpi_table_desc *table_desc;
138}; 132};
139 133
140
141/* Info used by acpi_ns_initialize_devices */ 134/* Info used by acpi_ns_initialize_devices */
142 135
143struct acpi_device_walk_info 136struct acpi_device_walk_info {
144{ 137 u16 device_count;
145 u16 device_count; 138 u16 num_STA;
146 u16 num_STA; 139 u16 num_INI;
147 u16 num_INI; 140 struct acpi_table_desc *table_desc;
148 struct acpi_table_desc *table_desc;
149}; 141};
150 142
151
152/* TBD: [Restructure] Merge with struct above */ 143/* TBD: [Restructure] Merge with struct above */
153 144
154struct acpi_walk_info 145struct acpi_walk_info {
155{ 146 u32 debug_level;
156 u32 debug_level; 147 u32 count;
157 u32 owner_id; 148 acpi_owner_id owner_id;
158 u8 display_type; 149 u8 display_type;
159}; 150};
160 151
161/* Display Types */ 152/* Display Types */
162 153
163#define ACPI_DISPLAY_SUMMARY 0 154#define ACPI_DISPLAY_SUMMARY (u8) 0
164#define ACPI_DISPLAY_OBJECTS 1 155#define ACPI_DISPLAY_OBJECTS (u8) 1
156#define ACPI_DISPLAY_MASK (u8) 1
165 157
166struct acpi_get_devices_info 158#define ACPI_DISPLAY_SHORT (u8) 2
167{
168 acpi_walk_callback user_function;
169 void *context;
170 char *hid;
171};
172 159
160struct acpi_get_devices_info {
161 acpi_walk_callback user_function;
162 void *context;
163 char *hid;
164};
173 165
174union acpi_aml_operands 166union acpi_aml_operands {
175{ 167 union acpi_operand_object *operands[7];
176 union acpi_operand_object *operands[7];
177 168
178 struct 169 struct {
179 { 170 struct acpi_object_integer *type;
180 struct acpi_object_integer *type; 171 struct acpi_object_integer *code;
181 struct acpi_object_integer *code; 172 struct acpi_object_integer *argument;
182 struct acpi_object_integer *argument;
183 173
184 } fatal; 174 } fatal;
185 175
186 struct 176 struct {
187 { 177 union acpi_operand_object *source;
188 union acpi_operand_object *source; 178 struct acpi_object_integer *index;
189 struct acpi_object_integer *index; 179 union acpi_operand_object *target;
190 union acpi_operand_object *target;
191 180
192 } index; 181 } index;
193 182
194 struct 183 struct {
195 { 184 union acpi_operand_object *source;
196 union acpi_operand_object *source; 185 struct acpi_object_integer *index;
197 struct acpi_object_integer *index; 186 struct acpi_object_integer *length;
198 struct acpi_object_integer *length; 187 union acpi_operand_object *target;
199 union acpi_operand_object *target;
200 188
201 } mid; 189 } mid;
202}; 190};
203 191
204
205/* Internal method parameter list */ 192/* Internal method parameter list */
206 193
207struct acpi_parameter_info 194struct acpi_parameter_info {
208{ 195 struct acpi_namespace_node *node;
209 struct acpi_namespace_node *node; 196 union acpi_operand_object *obj_desc;
210 union acpi_operand_object **parameters; 197 union acpi_operand_object **parameters;
211 union acpi_operand_object *return_object; 198 union acpi_operand_object *return_object;
212 u8 parameter_type; 199 u8 pass_number;
213 u8 return_object_type; 200 u8 parameter_type;
201 u8 return_object_type;
214}; 202};
215 203
216/* Types for parameter_type above */ 204/* Types for parameter_type above */
@@ -218,5 +206,4 @@ struct acpi_parameter_info
218#define ACPI_PARAM_ARGS 0 206#define ACPI_PARAM_ARGS 0
219#define ACPI_PARAM_GPE 1 207#define ACPI_PARAM_GPE 1
220 208
221
222#endif 209#endif
diff --git a/include/acpi/actables.h b/include/acpi/actables.h
index 39df92e21a0d..f92c1858b808 100644
--- a/include/acpi/actables.h
+++ b/include/acpi/actables.h
@@ -44,146 +44,101 @@
44#ifndef __ACTABLES_H__ 44#ifndef __ACTABLES_H__
45#define __ACTABLES_H__ 45#define __ACTABLES_H__
46 46
47
48/* Used in acpi_tb_map_acpi_table for size parameter if table header is to be used */ 47/* Used in acpi_tb_map_acpi_table for size parameter if table header is to be used */
49 48
50#define SIZE_IN_HEADER 0 49#define SIZE_IN_HEADER 0
51 50
52
53/* 51/*
54 * tbconvrt - Table conversion routines 52 * tbconvrt - Table conversion routines
55 */ 53 */
56acpi_status 54acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info);
57acpi_tb_convert_to_xsdt (
58 struct acpi_table_desc *table_info);
59 55
60acpi_status 56acpi_status acpi_tb_convert_table_fadt(void);
61acpi_tb_convert_table_fadt (
62 void);
63 57
64acpi_status 58acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info);
65acpi_tb_build_common_facs (
66 struct acpi_table_desc *table_info);
67 59
68u32 60u32
69acpi_tb_get_table_count ( 61acpi_tb_get_table_count(struct rsdp_descriptor *RSDP,
70 struct rsdp_descriptor *RSDP, 62 struct acpi_table_header *RSDT);
71 struct acpi_table_header *RSDT);
72
73 63
74/* 64/*
75 * tbget - Table "get" routines 65 * tbget - Table "get" routines
76 */ 66 */
77acpi_status 67acpi_status
78acpi_tb_get_table ( 68acpi_tb_get_table(struct acpi_pointer *address,
79 struct acpi_pointer *address, 69 struct acpi_table_desc *table_info);
80 struct acpi_table_desc *table_info);
81
82acpi_status
83acpi_tb_get_table_header (
84 struct acpi_pointer *address,
85 struct acpi_table_header *return_header);
86 70
87acpi_status 71acpi_status
88acpi_tb_get_table_body ( 72acpi_tb_get_table_header(struct acpi_pointer *address,
89 struct acpi_pointer *address, 73 struct acpi_table_header *return_header);
90 struct acpi_table_header *header,
91 struct acpi_table_desc *table_info);
92 74
93acpi_status 75acpi_status
94acpi_tb_get_table_ptr ( 76acpi_tb_get_table_body(struct acpi_pointer *address,
95 acpi_table_type table_type, 77 struct acpi_table_header *header,
96 u32 instance, 78 struct acpi_table_desc *table_info);
97 struct acpi_table_header **table_ptr_loc);
98 79
99acpi_status 80acpi_status
100acpi_tb_verify_rsdp ( 81acpi_tb_get_table_ptr(acpi_table_type table_type,
101 struct acpi_pointer *address); 82 u32 instance, struct acpi_table_header **table_ptr_loc);
102 83
103void 84acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address);
104acpi_tb_get_rsdt_address (
105 struct acpi_pointer *out_address);
106 85
107acpi_status 86void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address);
108acpi_tb_validate_rsdt (
109 struct acpi_table_header *table_ptr);
110 87
88acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr);
111 89
112/* 90/*
113 * tbgetall - get multiple required tables 91 * tbgetall - get multiple required tables
114 */ 92 */
115acpi_status 93acpi_status acpi_tb_get_required_tables(void);
116acpi_tb_get_required_tables (
117 void);
118
119 94
120/* 95/*
121 * tbinstall - Table installation 96 * tbinstall - Table installation
122 */ 97 */
123acpi_status 98acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info);
124acpi_tb_install_table (
125 struct acpi_table_desc *table_info);
126 99
127acpi_status 100acpi_status
128acpi_tb_recognize_table ( 101acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type);
129 struct acpi_table_desc *table_info,
130 u8 search_type);
131 102
132acpi_status 103acpi_status
133acpi_tb_init_table_descriptor ( 104acpi_tb_init_table_descriptor(acpi_table_type table_type,
134 acpi_table_type table_type, 105 struct acpi_table_desc *table_info);
135 struct acpi_table_desc *table_info);
136
137 106
138/* 107/*
139 * tbremove - Table removal and deletion 108 * tbremove - Table removal and deletion
140 */ 109 */
141void 110void acpi_tb_delete_all_tables(void);
142acpi_tb_delete_all_tables (
143 void);
144
145void
146acpi_tb_delete_tables_by_type (
147 acpi_table_type type);
148 111
149void 112void acpi_tb_delete_tables_by_type(acpi_table_type type);
150acpi_tb_delete_single_table (
151 struct acpi_table_desc *table_desc);
152 113
153struct acpi_table_desc * 114void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc);
154acpi_tb_uninstall_table (
155 struct acpi_table_desc *table_desc);
156 115
116struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
117 *table_desc);
157 118
158/* 119/*
159 * tbxfroot - RSDP, RSDT utilities 120 * tbxfroot - RSDP, RSDT utilities
160 */ 121 */
161acpi_status 122acpi_status
162acpi_tb_find_table ( 123acpi_tb_find_table(char *signature,
163 char *signature, 124 char *oem_id,
164 char *oem_id, 125 char *oem_table_id, struct acpi_table_header **table_ptr);
165 char *oem_table_id,
166 struct acpi_table_header **table_ptr);
167 126
168acpi_status 127acpi_status acpi_tb_get_table_rsdt(void);
169acpi_tb_get_table_rsdt (
170 void);
171 128
129acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp);
172 130
173/* 131/*
174 * tbutils - common table utilities 132 * tbutils - common table utilities
175 */ 133 */
134acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc);
135
176acpi_status 136acpi_status
177acpi_tb_verify_table_checksum ( 137acpi_tb_verify_table_checksum(struct acpi_table_header *table_header);
178 struct acpi_table_header *table_header);
179 138
180u8 139u8 acpi_tb_generate_checksum(void *buffer, u32 length);
181acpi_tb_checksum (
182 void *buffer,
183 u32 length);
184 140
185acpi_status 141acpi_status
186acpi_tb_validate_table_header ( 142acpi_tb_validate_table_header(struct acpi_table_header *table_header);
187 struct acpi_table_header *table_header);
188 143
189#endif /* __ACTABLES_H__ */ 144#endif /* __ACTABLES_H__ */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index b5cdcca444c8..a46f406e1c94 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -44,27 +44,24 @@
44#ifndef __ACTBL_H__ 44#ifndef __ACTBL_H__
45#define __ACTBL_H__ 45#define __ACTBL_H__
46 46
47
48/* 47/*
49 * Values for description table header signatures 48 * Values for description table header signatures
50 */ 49 */
51#define RSDP_NAME "RSDP" 50#define RSDP_NAME "RSDP"
52#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ 51#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
53#define APIC_SIG "APIC" /* Multiple APIC Description Table */ 52#define APIC_SIG "APIC" /* Multiple APIC Description Table */
54#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ 53#define DSDT_SIG "DSDT" /* Differentiated System Description Table */
55#define FADT_SIG "FACP" /* Fixed ACPI Description Table */ 54#define FADT_SIG "FACP" /* Fixed ACPI Description Table */
56#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ 55#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */
57#define PSDT_SIG "PSDT" /* Persistent System Description Table */ 56#define PSDT_SIG "PSDT" /* Persistent System Description Table */
58#define RSDT_SIG "RSDT" /* Root System Description Table */ 57#define RSDT_SIG "RSDT" /* Root System Description Table */
59#define XSDT_SIG "XSDT" /* Extended System Description Table */ 58#define XSDT_SIG "XSDT" /* Extended System Description Table */
60#define SSDT_SIG "SSDT" /* Secondary System Description Table */ 59#define SSDT_SIG "SSDT" /* Secondary System Description Table */
61#define SBST_SIG "SBST" /* Smart Battery Specification Table */ 60#define SBST_SIG "SBST" /* Smart Battery Specification Table */
62#define SPIC_SIG "SPIC" /* IOSAPIC table */ 61#define SPIC_SIG "SPIC" /* IOSAPIC table */
63#define BOOT_SIG "BOOT" /* Boot table */ 62#define BOOT_SIG "BOOT" /* Boot table */
64 63
65 64#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */
66#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */
67
68 65
69/* 66/*
70 * Common table types. The base code can remain 67 * Common table types. The base code can remain
@@ -75,7 +72,6 @@
75#define FACS_DESCRIPTOR struct facs_descriptor_rev2 72#define FACS_DESCRIPTOR struct facs_descriptor_rev2
76#define FADT_DESCRIPTOR struct fadt_descriptor_rev2 73#define FADT_DESCRIPTOR struct fadt_descriptor_rev2
77 74
78
79#pragma pack(1) 75#pragma pack(1)
80 76
81/* 77/*
@@ -84,45 +80,37 @@
84 * NOTE: The tables that are specific to ACPI versions (1.0, 2.0, etc.) 80 * NOTE: The tables that are specific to ACPI versions (1.0, 2.0, etc.)
85 * are in separate files. 81 * are in separate files.
86 */ 82 */
87struct rsdp_descriptor /* Root System Descriptor Pointer */ 83struct rsdp_descriptor { /* Root System Descriptor Pointer */
88{ 84 char signature[8]; /* ACPI signature, contains "RSD PTR " */
89 char signature [8]; /* ACPI signature, contains "RSD PTR " */ 85 u8 checksum; /* ACPI 1.0 checksum */
90 u8 checksum; /* To make sum of struct == 0 */ 86 char oem_id[6]; /* OEM identification */
91 char oem_id [6]; /* OEM identification */ 87 u8 revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */
92 u8 revision; /* Must be 0 for 1.0, 2 for 2.0 */ 88 u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */
93 u32 rsdt_physical_address; /* 32-bit physical address of RSDT */ 89 u32 length; /* XSDT Length in bytes, including header */
94 u32 length; /* XSDT Length in bytes including hdr */ 90 u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */
95 u64 xsdt_physical_address; /* 64-bit physical address of XSDT */ 91 u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */
96 u8 extended_checksum; /* Checksum of entire table */ 92 char reserved[3]; /* Reserved, must be zero */
97 char reserved [3]; /* Reserved field must be 0 */
98}; 93};
99 94
100 95struct acpi_common_facs { /* Common FACS for internal use */
101struct acpi_common_facs /* Common FACS for internal use */ 96 u32 *global_lock;
102{ 97 u64 *firmware_waking_vector;
103 u32 *global_lock; 98 u8 vector_width;
104 u64 *firmware_waking_vector;
105 u8 vector_width;
106}; 99};
107 100
108
109#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ 101#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \
110 char signature [4]; /* ACPI signature (4 ASCII characters) */\ 102 char signature[4]; /* ASCII table signature */\
111 u32 length; /* Length of table, in bytes, including header */\ 103 u32 length; /* Length of table in bytes, including this header */\
112 u8 revision; /* ACPI Specification minor version # */\ 104 u8 revision; /* ACPI Specification minor version # */\
113 u8 checksum; /* To make sum of entire table == 0 */\ 105 u8 checksum; /* To make sum of entire table == 0 */\
114 char oem_id [6]; /* OEM identification */\ 106 char oem_id[6]; /* ASCII OEM identification */\
115 char oem_table_id [8]; /* OEM table identification */\ 107 char oem_table_id[8]; /* ASCII OEM table identification */\
116 u32 oem_revision; /* OEM revision number */\ 108 u32 oem_revision; /* OEM revision number */\
117 char asl_compiler_id [4]; /* ASL compiler vendor ID */\ 109 char asl_compiler_id [4]; /* ASCII ASL compiler vendor ID */\
118 u32 asl_compiler_revision; /* ASL compiler revision number */ 110 u32 asl_compiler_revision; /* ASL compiler version */
119
120
121struct acpi_table_header /* ACPI common table header */
122{
123 ACPI_TABLE_HEADER_DEF
124};
125 111
112struct acpi_table_header { /* ACPI common table header */
113ACPI_TABLE_HEADER_DEF};
126 114
127/* 115/*
128 * MADT values and structures 116 * MADT values and structures
@@ -135,12 +123,15 @@ struct acpi_table_header /* ACPI common table header */
135 123
136/* Master MADT */ 124/* Master MADT */
137 125
138struct multiple_apic_table 126struct multiple_apic_table {
139{ 127 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
140 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 128 u32 local_apic_address; /* Physical address of local APIC */
141 u32 local_apic_address; /* Physical address of local APIC */ 129
142 u32 PCATcompat : 1; /* A one indicates system also has dual 8259s */ 130 /* Flags (32 bits) */
143 u32 reserved1 : 31; 131
132 u8 PCATcompat:1; /* 00: System also has dual 8259s */
133 u8:7; /* 01-07: Reserved, must be zero */
134 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
144}; 135};
145 136
146/* Values for Type in APIC_HEADER_DEF */ 137/* Values for Type in APIC_HEADER_DEF */
@@ -154,7 +145,7 @@ struct multiple_apic_table
154#define APIC_IO_SAPIC 6 145#define APIC_IO_SAPIC 6
155#define APIC_LOCAL_SAPIC 7 146#define APIC_LOCAL_SAPIC 7
156#define APIC_XRUPT_SOURCE 8 147#define APIC_XRUPT_SOURCE 8
157#define APIC_RESERVED 9 /* 9 and greater are reserved */ 148#define APIC_RESERVED 9 /* 9 and greater are reserved */
158 149
159/* 150/*
160 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) 151 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
@@ -163,10 +154,8 @@ struct multiple_apic_table
163 u8 type; \ 154 u8 type; \
164 u8 length; 155 u8 length;
165 156
166struct apic_header 157struct apic_header {
167{ 158APIC_HEADER_DEF};
168 APIC_HEADER_DEF
169};
170 159
171/* Values for MPS INTI flags */ 160/* Values for MPS INTI flags */
172 161
@@ -180,117 +169,90 @@ struct apic_header
180#define TRIGGER_RESERVED 2 169#define TRIGGER_RESERVED 2
181#define TRIGGER_LEVEL 3 170#define TRIGGER_LEVEL 3
182 171
183/* Common flag definitions */ 172/* Common flag definitions (16 bits each) */
184 173
185#define MPS_INTI_FLAGS \ 174#define MPS_INTI_FLAGS \
186 u16 polarity : 2; /* Polarity of APIC I/O input signals */\ 175 u8 polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\
187 u16 trigger_mode : 2; /* Trigger mode of APIC input signals */\ 176 u8 trigger_mode : 2; /* 02-03: Trigger mode of APIC input signals */\
188 u16 reserved1 : 12; /* Reserved, must be zero */ 177 u8 : 4; /* 04-07: Reserved, must be zero */\
178 u8 reserved1; /* 08-15: Reserved, must be zero */
189 179
190#define LOCAL_APIC_FLAGS \ 180#define LOCAL_APIC_FLAGS \
191 u32 processor_enabled: 1; /* Processor is usable if set */\ 181 u8 processor_enabled: 1; /* 00: Processor is usable if set */\
192 u32 reserved2 : 31; /* Reserved, must be zero */ 182 u8 : 7; /* 01-07: Reserved, must be zero */\
183 u8 reserved2; /* 08-15: Reserved, must be zero */
193 184
194/* Sub-structures for MADT */ 185/* Sub-structures for MADT */
195 186
196struct madt_processor_apic 187struct madt_processor_apic {
197{ 188 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
198 APIC_HEADER_DEF 189 u8 local_apic_id; /* Processor's local APIC id */
199 u8 processor_id; /* ACPI processor id */ 190 LOCAL_APIC_FLAGS};
200 u8 local_apic_id; /* Processor's local APIC id */ 191
201 LOCAL_APIC_FLAGS 192struct madt_io_apic {
202}; 193 APIC_HEADER_DEF u8 io_apic_id; /* I/O APIC ID */
203 194 u8 reserved; /* Reserved - must be zero */
204struct madt_io_apic 195 u32 address; /* APIC physical address */
205{ 196 u32 interrupt; /* Global system interrupt where INTI
206 APIC_HEADER_DEF 197 * lines start */
207 u8 io_apic_id; /* I/O APIC ID */
208 u8 reserved; /* Reserved - must be zero */
209 u32 address; /* APIC physical address */
210 u32 interrupt; /* Global system interrupt where INTI
211 * lines start */
212}; 198};
213 199
214struct madt_interrupt_override 200struct madt_interrupt_override {
215{ 201 APIC_HEADER_DEF u8 bus; /* 0 - ISA */
216 APIC_HEADER_DEF 202 u8 source; /* Interrupt source (IRQ) */
217 u8 bus; /* 0 - ISA */ 203 u32 interrupt; /* Global system interrupt */
218 u8 source; /* Interrupt source (IRQ) */ 204 MPS_INTI_FLAGS};
219 u32 interrupt; /* Global system interrupt */
220 MPS_INTI_FLAGS
221};
222 205
223struct madt_nmi_source 206struct madt_nmi_source {
224{ 207 APIC_HEADER_DEF MPS_INTI_FLAGS u32 interrupt; /* Global system interrupt */
225 APIC_HEADER_DEF
226 MPS_INTI_FLAGS
227 u32 interrupt; /* Global system interrupt */
228}; 208};
229 209
230struct madt_local_apic_nmi 210struct madt_local_apic_nmi {
231{ 211 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
232 APIC_HEADER_DEF 212 MPS_INTI_FLAGS u8 lint; /* LINTn to which NMI is connected */
233 u8 processor_id; /* ACPI processor id */
234 MPS_INTI_FLAGS
235 u8 lint; /* LINTn to which NMI is connected */
236}; 213};
237 214
238struct madt_address_override 215struct madt_address_override {
239{ 216 APIC_HEADER_DEF u16 reserved; /* Reserved, must be zero */
240 APIC_HEADER_DEF 217 u64 address; /* APIC physical address */
241 u16 reserved; /* Reserved - must be zero */
242 u64 address; /* APIC physical address */
243}; 218};
244 219
245struct madt_io_sapic 220struct madt_io_sapic {
246{ 221 APIC_HEADER_DEF u8 io_sapic_id; /* I/O SAPIC ID */
247 APIC_HEADER_DEF 222 u8 reserved; /* Reserved, must be zero */
248 u8 io_sapic_id; /* I/O SAPIC ID */ 223 u32 interrupt_base; /* Glocal interrupt for SAPIC start */
249 u8 reserved; /* Reserved - must be zero */ 224 u64 address; /* SAPIC physical address */
250 u32 interrupt_base; /* Glocal interrupt for SAPIC start */
251 u64 address; /* SAPIC physical address */
252}; 225};
253 226
254struct madt_local_sapic 227struct madt_local_sapic {
255{ 228 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
256 APIC_HEADER_DEF 229 u8 local_sapic_id; /* SAPIC ID */
257 u8 processor_id; /* ACPI processor id */ 230 u8 local_sapic_eid; /* SAPIC EID */
258 u8 local_sapic_id; /* SAPIC ID */ 231 u8 reserved[3]; /* Reserved, must be zero */
259 u8 local_sapic_eid; /* SAPIC EID */ 232 LOCAL_APIC_FLAGS u32 processor_uID; /* Numeric UID - ACPI 3.0 */
260 u8 reserved [3]; /* Reserved - must be zero */ 233 char processor_uIDstring[1]; /* String UID - ACPI 3.0 */
261 LOCAL_APIC_FLAGS
262 u32 processor_uID; /* Numeric UID - ACPI 3.0 */
263 char processor_uIDstring[1]; /* String UID - ACPI 3.0 */
264}; 234};
265 235
266struct madt_interrupt_source 236struct madt_interrupt_source {
267{ 237 APIC_HEADER_DEF MPS_INTI_FLAGS u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */
268 APIC_HEADER_DEF 238 u8 processor_id; /* Processor ID */
269 MPS_INTI_FLAGS 239 u8 processor_eid; /* Processor EID */
270 u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */ 240 u8 io_sapic_vector; /* Vector value for PMI interrupts */
271 u8 processor_id; /* Processor ID */ 241 u32 interrupt; /* Global system interrupt */
272 u8 processor_eid; /* Processor EID */ 242 u32 flags; /* Interrupt Source Flags */
273 u8 io_sapic_vector; /* Vector value for PMI interrupts */
274 u32 interrupt; /* Global system interrupt */
275 u32 flags; /* Interrupt Source Flags */
276}; 243};
277 244
278
279/* 245/*
280 * Smart Battery 246 * Smart Battery
281 */ 247 */
282struct smart_battery_table 248struct smart_battery_table {
283{ 249 ACPI_TABLE_HEADER_DEF u32 warning_level;
284 ACPI_TABLE_HEADER_DEF 250 u32 low_level;
285 u32 warning_level; 251 u32 critical_level;
286 u32 low_level;
287 u32 critical_level;
288}; 252};
289 253
290
291#pragma pack() 254#pragma pack()
292 255
293
294/* 256/*
295 * ACPI Table information. We save the table address, length, 257 * ACPI Table information. We save the table address, length,
296 * and type of memory allocation (mapped or allocated) for each 258 * and type of memory allocation (mapped or allocated) for each
@@ -314,39 +276,35 @@ struct smart_battery_table
314 276
315/* Data about each known table type */ 277/* Data about each known table type */
316 278
317struct acpi_table_support 279struct acpi_table_support {
318{ 280 char *name;
319 char *name; 281 char *signature;
320 char *signature; 282 void **global_ptr;
321 void **global_ptr; 283 u8 sig_length;
322 u8 sig_length; 284 u8 flags;
323 u8 flags;
324}; 285};
325 286
326
327/* 287/*
328 * Get the ACPI version-specific tables 288 * Get the ACPI version-specific tables
329 */ 289 */
330#include "actbl1.h" /* Acpi 1.0 table definitions */ 290#include "actbl1.h" /* Acpi 1.0 table definitions */
331#include "actbl2.h" /* Acpi 2.0 table definitions */ 291#include "actbl2.h" /* Acpi 2.0 table definitions */
332 292
333extern u8 acpi_fadt_is_v1; /* is set to 1 if FADT is revision 1, 293extern u8 acpi_fadt_is_v1; /* is set to 1 if FADT is revision 1,
334 * needed for certain workarounds */ 294 * needed for certain workarounds */
335 295
336#pragma pack(1) 296#pragma pack(1)
337/* 297/*
338 * High performance timer 298 * High performance timer
339 */ 299 */
340struct hpet_table 300struct hpet_table {
341{ 301 ACPI_TABLE_HEADER_DEF u32 hardware_id;
342 ACPI_TABLE_HEADER_DEF 302 struct acpi_generic_address base_address;
343 u32 hardware_id; 303 u8 hpet_number;
344 struct acpi_generic_address base_address; 304 u16 clock_tick;
345 u8 hpet_number; 305 u8 attributes;
346 u16 clock_tick;
347 u8 attributes;
348}; 306};
349 307
350#pragma pack() 308#pragma pack()
351 309
352#endif /* __ACTBL_H__ */ 310#endif /* __ACTBL_H__ */
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 33de5f4d2ccc..67312c3a915a 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -49,88 +49,87 @@
49/* 49/*
50 * ACPI 1.0 Root System Description Table (RSDT) 50 * ACPI 1.0 Root System Description Table (RSDT)
51 */ 51 */
52struct rsdt_descriptor_rev1 52struct rsdt_descriptor_rev1 {
53{ 53 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
54 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 54 u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */
55 u32 table_offset_entry [1]; /* Array of pointers to other */
56 /* ACPI tables */
57}; 55};
58 56
59
60/* 57/*
61 * ACPI 1.0 Firmware ACPI Control Structure (FACS) 58 * ACPI 1.0 Firmware ACPI Control Structure (FACS)
62 */ 59 */
63struct facs_descriptor_rev1 60struct facs_descriptor_rev1 {
64{ 61 char signature[4]; /* ASCII table signature */
65 char signature[4]; /* ACPI Signature */ 62 u32 length; /* Length of structure in bytes */
66 u32 length; /* Length of structure, in bytes */ 63 u32 hardware_signature; /* Hardware configuration signature */
67 u32 hardware_signature; /* Hardware configuration signature */ 64 u32 firmware_waking_vector; /* ACPI OS waking vector */
68 u32 firmware_waking_vector; /* ACPI OS waking vector */ 65 u32 global_lock; /* Global Lock */
69 u32 global_lock; /* Global Lock */ 66
70 u32 S4bios_f : 1; /* Indicates if S4BIOS support is present */ 67 /* Flags (32 bits) */
71 u32 reserved1 : 31; /* Must be 0 */
72 u8 resverved3 [40]; /* Reserved - must be zero */
73};
74 68
69 u8 S4bios_f:1; /* 00: S4BIOS support is present */
70 u8:7; /* 01-07: Reserved, must be zero */
71 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
72
73 u8 reserved2[40]; /* Reserved, must be zero */
74};
75 75
76/* 76/*
77 * ACPI 1.0 Fixed ACPI Description Table (FADT) 77 * ACPI 1.0 Fixed ACPI Description Table (FADT)
78 */ 78 */
79struct fadt_descriptor_rev1 79struct fadt_descriptor_rev1 {
80{ 80 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
81 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 81 u32 firmware_ctrl; /* Physical address of FACS */
82 u32 firmware_ctrl; /* Physical address of FACS */ 82 u32 dsdt; /* Physical address of DSDT */
83 u32 dsdt; /* Physical address of DSDT */ 83 u8 model; /* System Interrupt Model */
84 u8 model; /* System Interrupt Model */ 84 u8 reserved1; /* Reserved, must be zero */
85 u8 reserved1; /* Reserved */ 85 u16 sci_int; /* System vector of SCI interrupt */
86 u16 sci_int; /* System vector of SCI interrupt */ 86 u32 smi_cmd; /* Port address of SMI command port */
87 u32 smi_cmd; /* Port address of SMI command port */ 87 u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */
88 u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ 88 u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */
89 u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ 89 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */
90 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ 90 u8 reserved2; /* Reserved, must be zero */
91 u8 reserved2; /* Reserved - must be zero */ 91 u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */
92 u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ 92 u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */
93 u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ 93 u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */
94 u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ 94 u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */
95 u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ 95 u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */
96 u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ 96 u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */
97 u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ 97 u32 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */
98 u32 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ 98 u32 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */
99 u32 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ 99 u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */
100 u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ 100 u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */
101 u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ 101 u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */
102 u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ 102 u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */
103 u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ 103 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */
104 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ 104 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */
105 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ 105 u8 gpe1_base; /* Offset in gpe model where gpe1 events start */
106 u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ 106 u8 reserved3; /* Reserved, must be zero */
107 u8 reserved3; /* Reserved */ 107 u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */
108 u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */ 108 u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */
109 u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ 109 u16 flush_size; /* Size of area read to flush caches */
110 u16 flush_size; /* Size of area read to flush caches */ 110 u16 flush_stride; /* Stride used in flushing caches */
111 u16 flush_stride; /* Stride used in flushing caches */ 111 u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */
112 u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */ 112 u8 duty_width; /* Bit width of duty cycle field in p_cnt reg */
113 u8 duty_width; /* Bit width of duty cycle field in p_cnt reg */ 113 u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */
114 u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */ 114 u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */
115 u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ 115 u8 century; /* Index to century in RTC CMOS RAM */
116 u8 century; /* Index to century in RTC CMOS RAM */ 116 u8 reserved4[3]; /* Reserved, must be zero */
117 u8 reserved4; /* Reserved */
118 u8 reserved4a; /* Reserved */
119 u8 reserved4b; /* Reserved */
120 u32 wb_invd : 1; /* The wbinvd instruction works properly */
121 u32 wb_invd_flush : 1; /* The wbinvd flushes but does not invalidate */
122 u32 proc_c1 : 1; /* All processors support C1 state */
123 u32 plvl2_up : 1; /* C2 state works on MP system */
124 u32 pwr_button : 1; /* Power button is handled as a generic feature */
125 u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */
126 u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */
127 u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */
128 u32 tmr_val_ext : 1; /* The tmr_val width is 32 bits (0 = 24 bits) */
129 u32 reserved5 : 23; /* Reserved - must be zero */
130};
131 117
132#pragma pack() 118 /* Flags (32 bits) */
133 119
134#endif /* __ACTBL1_H__ */ 120 u8 wb_invd:1; /* 00: The wbinvd instruction works properly */
121 u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */
122 u8 proc_c1:1; /* 02: All processors support C1 state */
123 u8 plvl2_up:1; /* 03: C2 state works on MP system */
124 u8 pwr_button:1; /* 04: Power button is handled as a generic feature */
125 u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */
126 u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */
127 u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */
128 u8 tmr_val_ext:1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */
129 u8:7; /* 09-15: Reserved, must be zero */
130 u8 reserved5[2]; /* 16-31: Reserved, must be zero */
131};
135 132
133#pragma pack()
136 134
135#endif /* __ACTBL1_H__ */
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index e1729c967e05..50305ce2681a 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -64,62 +64,56 @@
64#define FADT2_REVISION_ID 3 64#define FADT2_REVISION_ID 3
65#define FADT2_MINUS_REVISION_ID 2 65#define FADT2_MINUS_REVISION_ID 2
66 66
67
68#pragma pack(1) 67#pragma pack(1)
69 68
70/* 69/*
71 * ACPI 2.0 Root System Description Table (RSDT) 70 * ACPI 2.0 Root System Description Table (RSDT)
72 */ 71 */
73struct rsdt_descriptor_rev2 72struct rsdt_descriptor_rev2 {
74{ 73 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
75 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 74 u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */
76 u32 table_offset_entry [1]; /* Array of pointers to */
77 /* ACPI table headers */
78}; 75};
79 76
80
81/* 77/*
82 * ACPI 2.0 Extended System Description Table (XSDT) 78 * ACPI 2.0 Extended System Description Table (XSDT)
83 */ 79 */
84struct xsdt_descriptor_rev2 80struct xsdt_descriptor_rev2 {
85{ 81 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
86 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 82 u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */
87 u64 table_offset_entry [1]; /* Array of pointers to */
88 /* ACPI table headers */
89}; 83};
90 84
91
92/* 85/*
93 * ACPI 2.0 Firmware ACPI Control Structure (FACS) 86 * ACPI 2.0 Firmware ACPI Control Structure (FACS)
94 */ 87 */
95struct facs_descriptor_rev2 88struct facs_descriptor_rev2 {
96{ 89 char signature[4]; /* ASCII table signature */
97 char signature[4]; /* ACPI signature */ 90 u32 length; /* Length of structure, in bytes */
98 u32 length; /* Length of structure, in bytes */ 91 u32 hardware_signature; /* Hardware configuration signature */
99 u32 hardware_signature; /* Hardware configuration signature */ 92 u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */
100 u32 firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */ 93 u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */
101 u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */ 94
102 u32 S4bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */ 95 /* Flags (32 bits) */
103 u32 reserved1 : 31; /* Must be 0 */ 96
104 u64 xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */ 97 u8 S4bios_f:1; /* 00: S4BIOS support is present */
105 u8 version; /* Version of this table */ 98 u8:7; /* 01-07: Reserved, must be zero */
106 u8 reserved3 [31]; /* Reserved - must be zero */ 99 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
100
101 u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */
102 u8 version; /* Version of this table */
103 u8 reserved3[31]; /* Reserved, must be zero */
107}; 104};
108 105
109
110/* 106/*
111 * ACPI 2.0+ Generic Address Structure (GAS) 107 * ACPI 2.0+ Generic Address Structure (GAS)
112 */ 108 */
113struct acpi_generic_address 109struct acpi_generic_address {
114{ 110 u8 address_space_id; /* Address space where struct or register exists. */
115 u8 address_space_id; /* Address space where struct or register exists. */ 111 u8 register_bit_width; /* Size in bits of given register */
116 u8 register_bit_width; /* Size in bits of given register */ 112 u8 register_bit_offset; /* Bit offset within the register */
117 u8 register_bit_offset; /* Bit offset within the register */ 113 u8 access_width; /* Minimum Access size (ACPI 3.0) */
118 u8 access_width; /* Minimum Access size (ACPI 3.0) */ 114 u64 address; /* 64-bit address of struct or register */
119 u64 address; /* 64-bit address of struct or register */
120}; 115};
121 116
122
123#define FADT_REV2_COMMON \ 117#define FADT_REV2_COMMON \
124 u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ \ 118 u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ \
125 u32 V1_dsdt; /* 32-bit physical address of DSDT */ \ 119 u32 V1_dsdt; /* 32-bit physical address of DSDT */ \
@@ -161,129 +155,123 @@ struct acpi_generic_address
161/* 155/*
162 * ACPI 2.0+ Fixed ACPI Description Table (FADT) 156 * ACPI 2.0+ Fixed ACPI Description Table (FADT)
163 */ 157 */
164struct fadt_descriptor_rev2 158struct fadt_descriptor_rev2 {
165{ 159 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
166 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 160 FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */
167 FADT_REV2_COMMON 161
168 u8 reserved2; /* Reserved */ 162 /* Flags (32 bits) */
169 u32 wb_invd : 1; /* The wbinvd instruction works properly */ 163
170 u32 wb_invd_flush : 1; /* The wbinvd flushes but does not invalidate */ 164 u8 wb_invd:1; /* 00: The wbinvd instruction works properly */
171 u32 proc_c1 : 1; /* All processors support C1 state */ 165 u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */
172 u32 plvl2_up : 1; /* C2 state works on MP system */ 166 u8 proc_c1:1; /* 02: All processors support C1 state */
173 u32 pwr_button : 1; /* Power button is handled as a generic feature */ 167 u8 plvl2_up:1; /* 03: C2 state works on MP system */
174 u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ 168 u8 pwr_button:1; /* 04: Power button is handled as a generic feature */
175 u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ 169 u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */
176 u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ 170 u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */
177 u32 tmr_val_ext : 1; /* Indicates tmr_val is 32 bits 0=24-bits */ 171 u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */
178 u32 dock_cap : 1; /* Supports Docking */ 172 u8 tmr_val_ext:1; /* 08: tmr_val is 32 bits 0=24-bits */
179 u32 reset_reg_sup : 1; /* Indicates system supports system reset via the FADT RESET_REG */ 173 u8 dock_cap:1; /* 09: Docking supported */
180 u32 sealed_case : 1; /* Indicates system has no internal expansion capabilities and case is sealed */ 174 u8 reset_reg_sup:1; /* 10: System reset via the FADT RESET_REG supported */
181 u32 headless : 1; /* Indicates system does not have local video capabilities or local input devices */ 175 u8 sealed_case:1; /* 11: No internal expansion capabilities and case is sealed */
182 u32 cpu_sw_sleep : 1; /* Indicates to OSPM that a processor native instruction */ 176 u8 headless:1; /* 12: No local video capabilities or local input devices */
183 /* must be executed after writing the SLP_TYPx register */ 177 u8 cpu_sw_sleep:1; /* 13: Must execute native instruction after writing SLP_TYPx register */
184 /* ACPI 3.0 flag bits */ 178
185 179 u8 pci_exp_wak:1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */
186 u32 pci_exp_wak : 1; /* System supports PCIEXP_WAKE (STS/EN) bits */ 180 u8 use_platform_clock:1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */
187 u32 use_platform_clock : 1; /* OSPM should use platform-provided timer */ 181 u8 S4rtc_sts_valid:1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */
188 u32 S4rtc_sts_valid : 1; /* Contents of RTC_STS valid after S4 wake */ 182 u8 remote_power_on_capable:1; /* 17: System is compatible with remote power on (ACPI 3.0) */
189 u32 remote_power_on_capable : 1; /* System is compatible with remote power on */ 183 u8 force_apic_cluster_model:1; /* 18: All local APICs must use cluster model (ACPI 3.0) */
190 u32 force_apic_cluster_model : 1; /* All local APICs must use cluster model */ 184 u8 force_apic_physical_destination_mode:1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */
191 u32 force_apic_physical_destination_mode : 1; /* all local x_aPICs must use physical dest mode */ 185 u8:4; /* 20-23: Reserved, must be zero */
192 u32 reserved6 : 12;/* Reserved - must be zero */ 186 u8 reserved3; /* 24-31: Reserved, must be zero */
193 187
194 struct acpi_generic_address reset_register; /* Reset register address in GAS format */ 188 struct acpi_generic_address reset_register; /* Reset register address in GAS format */
195 u8 reset_value; /* Value to write to the reset_register port to reset the system */ 189 u8 reset_value; /* Value to write to the reset_register port to reset the system */
196 u8 reserved7[3]; /* These three bytes must be zero */ 190 u8 reserved4[3]; /* These three bytes must be zero */
197 u64 xfirmware_ctrl; /* 64-bit physical address of FACS */ 191 u64 xfirmware_ctrl; /* 64-bit physical address of FACS */
198 u64 Xdsdt; /* 64-bit physical address of DSDT */ 192 u64 Xdsdt; /* 64-bit physical address of DSDT */
199 struct acpi_generic_address xpm1a_evt_blk; /* Extended Power Mgt 1a acpi_event Reg Blk address */ 193 struct acpi_generic_address xpm1a_evt_blk; /* Extended Power Mgt 1a acpi_event Reg Blk address */
200 struct acpi_generic_address xpm1b_evt_blk; /* Extended Power Mgt 1b acpi_event Reg Blk address */ 194 struct acpi_generic_address xpm1b_evt_blk; /* Extended Power Mgt 1b acpi_event Reg Blk address */
201 struct acpi_generic_address xpm1a_cnt_blk; /* Extended Power Mgt 1a Control Reg Blk address */ 195 struct acpi_generic_address xpm1a_cnt_blk; /* Extended Power Mgt 1a Control Reg Blk address */
202 struct acpi_generic_address xpm1b_cnt_blk; /* Extended Power Mgt 1b Control Reg Blk address */ 196 struct acpi_generic_address xpm1b_cnt_blk; /* Extended Power Mgt 1b Control Reg Blk address */
203 struct acpi_generic_address xpm2_cnt_blk; /* Extended Power Mgt 2 Control Reg Blk address */ 197 struct acpi_generic_address xpm2_cnt_blk; /* Extended Power Mgt 2 Control Reg Blk address */
204 struct acpi_generic_address xpm_tmr_blk; /* Extended Power Mgt Timer Ctrl Reg Blk address */ 198 struct acpi_generic_address xpm_tmr_blk; /* Extended Power Mgt Timer Ctrl Reg Blk address */
205 struct acpi_generic_address xgpe0_blk; /* Extended General Purpose acpi_event 0 Reg Blk address */ 199 struct acpi_generic_address xgpe0_blk; /* Extended General Purpose acpi_event 0 Reg Blk address */
206 struct acpi_generic_address xgpe1_blk; /* Extended General Purpose acpi_event 1 Reg Blk address */ 200 struct acpi_generic_address xgpe1_blk; /* Extended General Purpose acpi_event 1 Reg Blk address */
207}; 201};
208 202
209
210/* "Down-revved" ACPI 2.0 FADT descriptor */ 203/* "Down-revved" ACPI 2.0 FADT descriptor */
211 204
212struct fadt_descriptor_rev2_minus 205struct fadt_descriptor_rev2_minus {
213{ 206 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
214 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 207 FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */
215 FADT_REV2_COMMON 208 u32 flags;
216 u8 reserved2; /* Reserved */ 209 struct acpi_generic_address reset_register; /* Reset register address in GAS format */
217 u32 flags; 210 u8 reset_value; /* Value to write to the reset_register port to reset the system. */
218 struct acpi_generic_address reset_register; /* Reset register address in GAS format */ 211 u8 reserved7[3]; /* Reserved, must be zero */
219 u8 reset_value; /* Value to write to the reset_register port to reset the system. */
220 u8 reserved7[3]; /* These three bytes must be zero */
221}; 212};
222 213
223
224/* ECDT - Embedded Controller Boot Resources Table */ 214/* ECDT - Embedded Controller Boot Resources Table */
225 215
226struct ec_boot_resources 216struct ec_boot_resources {
227{ 217 ACPI_TABLE_HEADER_DEF struct acpi_generic_address ec_control; /* Address of EC command/status register */
228 ACPI_TABLE_HEADER_DEF 218 struct acpi_generic_address ec_data; /* Address of EC data register */
229 struct acpi_generic_address ec_control; /* Address of EC command/status register */ 219 u32 uid; /* Unique ID - must be same as the EC _UID method */
230 struct acpi_generic_address ec_data; /* Address of EC data register */ 220 u8 gpe_bit; /* The GPE for the EC */
231 u32 uid; /* Unique ID - must be same as the EC _UID method */ 221 u8 ec_id[1]; /* Full namepath of the EC in the ACPI namespace */
232 u8 gpe_bit; /* The GPE for the EC */
233 u8 ec_id[1]; /* Full namepath of the EC in the ACPI namespace */
234}; 222};
235 223
236
237/* SRAT - System Resource Affinity Table */ 224/* SRAT - System Resource Affinity Table */
238 225
239struct static_resource_alloc 226struct static_resource_alloc {
240{ 227 u8 type;
241 u8 type; 228 u8 length;
242 u8 length; 229 u8 proximity_domain_lo;
243 u8 proximity_domain_lo; 230 u8 apic_id;
244 u8 apic_id;
245 u32 enabled :1;
246 u32 reserved3 :31;
247 u8 local_sapic_eid;
248 u8 proximity_domain_hi[3];
249 u32 reserved4;
250};
251 231
252struct memory_affinity 232 /* Flags (32 bits) */
253{ 233
254 u8 type; 234 u8 enabled:1; /* 00: Use affinity structure */
255 u8 length; 235 u8:7; /* 01-07: Reserved, must be zero */
256 u32 proximity_domain; 236 u8 reserved3[3]; /* 08-31: Reserved, must be zero */
257 u16 reserved3; 237
258 u64 base_address; 238 u8 local_sapic_eid;
259 u64 address_length; 239 u8 proximity_domain_hi[3];
260 u32 reserved4; 240 u32 reserved4; /* Reserved, must be zero */
261 u32 enabled :1;
262 u32 hot_pluggable :1;
263 u32 non_volatile :1;
264 u32 reserved5 :29;
265 u64 reserved6;
266}; 241};
267 242
268struct system_resource_affinity 243struct memory_affinity {
269{ 244 u8 type;
270 ACPI_TABLE_HEADER_DEF 245 u8 length;
271 u32 reserved1; /* Must be value '1' */ 246 u32 proximity_domain;
272 u64 reserved2; 247 u16 reserved3;
248 u64 base_address;
249 u64 address_length;
250 u32 reserved4;
251
252 /* Flags (32 bits) */
253
254 u8 enabled:1; /* 00: Use affinity structure */
255 u8 hot_pluggable:1; /* 01: Memory region is hot pluggable */
256 u8 non_volatile:1; /* 02: Memory is non-volatile */
257 u8:5; /* 03-07: Reserved, must be zero */
258 u8 reserved5[3]; /* 08-31: Reserved, must be zero */
259
260 u64 reserved6; /* Reserved, must be zero */
273}; 261};
274 262
263struct system_resource_affinity {
264 ACPI_TABLE_HEADER_DEF u32 reserved1; /* Must be value '1' */
265 u64 reserved2; /* Reserved, must be zero */
266};
275 267
276/* SLIT - System Locality Distance Information Table */ 268/* SLIT - System Locality Distance Information Table */
277 269
278struct system_locality_info 270struct system_locality_info {
279{ 271 ACPI_TABLE_HEADER_DEF u64 locality_count;
280 ACPI_TABLE_HEADER_DEF 272 u8 entry[1][1];
281 u64 locality_count;
282 u8 entry[1][1];
283}; 273};
284 274
285
286#pragma pack() 275#pragma pack()
287 276
288#endif /* __ACTBL2_H__ */ 277#endif /* __ACTBL2_H__ */
289
diff --git a/include/acpi/actbl71.h b/include/acpi/actbl71.h
index 7b4fb44261f3..10ac05bb36bc 100644
--- a/include/acpi/actbl71.h
+++ b/include/acpi/actbl71.h
@@ -27,7 +27,6 @@
27#ifndef __ACTBL71_H__ 27#ifndef __ACTBL71_H__
28#define __ACTBL71_H__ 28#define __ACTBL71_H__
29 29
30
31/* 0.71 FADT address_space data item bitmasks defines */ 30/* 0.71 FADT address_space data item bitmasks defines */
32/* If the associated bit is zero then it is in memory space else in io space */ 31/* If the associated bit is zero then it is in memory space else in io space */
33 32
@@ -40,105 +39,96 @@
40 39
41/* Only for clarity in declarations */ 40/* Only for clarity in declarations */
42 41
43typedef u64 IO_ADDRESS; 42typedef u64 IO_ADDRESS;
44
45 43
46#pragma pack(1) 44#pragma pack(1)
47struct /* Root System Descriptor Pointer */ 45struct { /* Root System Descriptor Pointer */
48{ 46 NATIVE_CHAR signature[8]; /* contains "RSD PTR " */
49 NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ 47 u8 checksum; /* to make sum of struct == 0 */
50 u8 checksum; /* to make sum of struct == 0 */ 48 NATIVE_CHAR oem_id[6]; /* OEM identification */
51 NATIVE_CHAR oem_id [6]; /* OEM identification */ 49 u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */
52 u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ 50 u64 rsdt_physical_address; /* 64-bit physical address of RSDT */
53 u64 rsdt_physical_address; /* 64-bit physical address of RSDT */
54}; 51};
55 52
56
57/*****************************************/ 53/*****************************************/
58/* IA64 Extensions to ACPI Spec Rev 0.71 */ 54/* IA64 Extensions to ACPI Spec Rev 0.71 */
59/* for the Root System Description Table */ 55/* for the Root System Description Table */
60/*****************************************/ 56/*****************************************/
61struct 57struct {
62{ 58 struct acpi_table_header header; /* Table header */
63 struct acpi_table_header header; /* Table header */ 59 u32 reserved_pad; /* IA64 alignment, must be 0 */
64 u32 reserved_pad; /* IA64 alignment, must be 0 */ 60 u64 table_offset_entry[1]; /* Array of pointers to other */
65 u64 table_offset_entry [1]; /* Array of pointers to other */ 61 /* tables' headers */
66 /* tables' headers */
67}; 62};
68 63
69
70/*******************************************/ 64/*******************************************/
71/* IA64 Extensions to ACPI Spec Rev 0.71 */ 65/* IA64 Extensions to ACPI Spec Rev 0.71 */
72/* for the Firmware ACPI Control Structure */ 66/* for the Firmware ACPI Control Structure */
73/*******************************************/ 67/*******************************************/
74struct 68struct {
75{ 69 NATIVE_CHAR signature[4]; /* signature "FACS" */
76 NATIVE_CHAR signature[4]; /* signature "FACS" */ 70 u32 length; /* length of structure, in bytes */
77 u32 length; /* length of structure, in bytes */ 71 u32 hardware_signature; /* hardware configuration signature */
78 u32 hardware_signature; /* hardware configuration signature */ 72 u32 reserved4; /* must be 0 */
79 u32 reserved4; /* must be 0 */ 73 u64 firmware_waking_vector; /* ACPI OS waking vector */
80 u64 firmware_waking_vector; /* ACPI OS waking vector */ 74 u64 global_lock; /* Global Lock */
81 u64 global_lock; /* Global Lock */ 75 u32 S4bios_f:1; /* Indicates if S4BIOS support is present */
82 u32 S4bios_f : 1; /* Indicates if S4BIOS support is present */ 76 u32 reserved1:31; /* must be 0 */
83 u32 reserved1 : 31; /* must be 0 */ 77 u8 reserved3[28]; /* reserved - must be zero */
84 u8 reserved3 [28]; /* reserved - must be zero */
85}; 78};
86 79
87
88/******************************************/ 80/******************************************/
89/* IA64 Extensions to ACPI Spec Rev 0.71 */ 81/* IA64 Extensions to ACPI Spec Rev 0.71 */
90/* for the Fixed ACPI Description Table */ 82/* for the Fixed ACPI Description Table */
91/******************************************/ 83/******************************************/
92struct 84struct {
93{ 85 struct acpi_table_header header; /* table header */
94 struct acpi_table_header header; /* table header */ 86 u32 reserved_pad; /* IA64 alignment, must be 0 */
95 u32 reserved_pad; /* IA64 alignment, must be 0 */ 87 u64 firmware_ctrl; /* 64-bit Physical address of FACS */
96 u64 firmware_ctrl; /* 64-bit Physical address of FACS */ 88 u64 dsdt; /* 64-bit Physical address of DSDT */
97 u64 dsdt; /* 64-bit Physical address of DSDT */ 89 u8 model; /* System Interrupt Model */
98 u8 model; /* System Interrupt Model */ 90 u8 address_space; /* Address Space Bitmask */
99 u8 address_space; /* Address Space Bitmask */ 91 u16 sci_int; /* System vector of SCI interrupt */
100 u16 sci_int; /* System vector of SCI interrupt */ 92 u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */
101 u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ 93 u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */
102 u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ 94 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */
103 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ 95 u8 reserved2; /* reserved - must be zero */
104 u8 reserved2; /* reserved - must be zero */ 96 u64 smi_cmd; /* Port address of SMI command port */
105 u64 smi_cmd; /* Port address of SMI command port */ 97 u64 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */
106 u64 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ 98 u64 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */
107 u64 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ 99 u64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */
108 u64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ 100 u64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */
109 u64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ 101 u64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */
110 u64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ 102 u64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */
111 u64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ 103 u64 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */
112 u64 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ 104 u64 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */
113 u64 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ 105 u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */
114 u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ 106 u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */
115 u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ 107 u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */
116 u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ 108 u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */
117 u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ 109 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */
118 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ 110 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */
119 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ 111 u8 gpe1_base; /* offset in gpe model where gpe1 events start */
120 u8 gpe1_base; /* offset in gpe model where gpe1 events start */ 112 u8 reserved3; /* reserved */
121 u8 reserved3; /* reserved */ 113 u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */
122 u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ 114 u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */
123 u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ 115 u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */
124 u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ 116 u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */
125 u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ 117 u8 century; /* index to century in RTC CMOS RAM */
126 u8 century; /* index to century in RTC CMOS RAM */ 118 u8 reserved4; /* reserved */
127 u8 reserved4; /* reserved */ 119 u32 flush_cash:1; /* PAL_FLUSH_CACHE is correctly supported */
128 u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ 120 u32 reserved5:1; /* reserved - must be zero */
129 u32 reserved5 : 1; /* reserved - must be zero */ 121 u32 proc_c1:1; /* all processors support C1 state */
130 u32 proc_c1 : 1; /* all processors support C1 state */ 122 u32 plvl2_up:1; /* C2 state works on MP system */
131 u32 plvl2_up : 1; /* C2 state works on MP system */ 123 u32 pwr_button:1; /* Power button is handled as a generic feature */
132 u32 pwr_button : 1; /* Power button is handled as a generic feature */ 124 u32 sleep_button:1; /* Sleep button is handled as a generic feature, or not present */
133 u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ 125 u32 fixed_rTC:1; /* RTC wakeup stat not in fixed register space */
134 u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ 126 u32 rtcs4:1; /* RTC wakeup stat not possible from S4 */
135 u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ 127 u32 tmr_val_ext:1; /* tmr_val is 32 bits */
136 u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ 128 u32 dock_cap:1; /* Supports Docking */
137 u32 dock_cap : 1; /* Supports Docking */ 129 u32 reserved6:22; /* reserved - must be zero */
138 u32 reserved6 : 22; /* reserved - must be zero */
139}; 130};
140 131
141#pragma pack() 132#pragma pack()
142 133
143#endif /* __ACTBL71_H__ */ 134#endif /* __ACTBL71_H__ */
144
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 3a451dc48ac8..6213b27516e8 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -46,35 +46,31 @@
46 46
47/*! [Begin] no source code translation (keep the typedefs) */ 47/*! [Begin] no source code translation (keep the typedefs) */
48 48
49
50
51/* 49/*
52 * Data type ranges 50 * Data type ranges
53 * Note: These macros are designed to be compiler independent as well as 51 * Note: These macros are designed to be compiler independent as well as
54 * working around problems that some 32-bit compilers have with 64-bit 52 * working around problems that some 32-bit compilers have with 64-bit
55 * constants. 53 * constants.
56 */ 54 */
57#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ 55#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */
58#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ 56#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */
59#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ 57#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */
60#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ 58#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
61#define ACPI_ASCII_MAX 0x7F 59#define ACPI_ASCII_MAX 0x7F
62 60
63
64#ifdef DEFINE_ALTERNATE_TYPES 61#ifdef DEFINE_ALTERNATE_TYPES
65/* 62/*
66 * Types used only in translated source, defined here to enable 63 * Types used only in translated source, defined here to enable
67 * cross-platform compilation only. 64 * cross-platform compilation only.
68 */ 65 */
69typedef int s32; 66typedef int s32;
70typedef unsigned char u8; 67typedef unsigned char u8;
71typedef unsigned short u16; 68typedef unsigned short u16;
72typedef unsigned int u32; 69typedef unsigned int u32;
73typedef COMPILER_DEPENDENT_UINT64 u64; 70typedef COMPILER_DEPENDENT_UINT64 u64;
74 71
75#endif 72#endif
76 73
77
78/* 74/*
79 * Data types - Fixed across all compilation models (16/32/64) 75 * Data types - Fixed across all compilation models (16/32/64)
80 * 76 *
@@ -102,30 +98,29 @@ typedef COMPILER_DEPENDENT_UINT64 u64;
102/* 98/*
103 * 64-bit type definitions 99 * 64-bit type definitions
104 */ 100 */
105typedef unsigned char UINT8; 101typedef unsigned char UINT8;
106typedef unsigned char BOOLEAN; 102typedef unsigned char BOOLEAN;
107typedef unsigned short UINT16; 103typedef unsigned short UINT16;
108typedef int INT32; 104typedef int INT32;
109typedef unsigned int UINT32; 105typedef unsigned int UINT32;
110typedef COMPILER_DEPENDENT_INT64 INT64; 106typedef COMPILER_DEPENDENT_INT64 INT64;
111typedef COMPILER_DEPENDENT_UINT64 UINT64; 107typedef COMPILER_DEPENDENT_UINT64 UINT64;
112 108
113/*! [End] no source code translation !*/ 109/*! [End] no source code translation !*/
114 110
115typedef s64 acpi_native_int; 111typedef s64 acpi_native_int;
116typedef u64 acpi_native_uint; 112typedef u64 acpi_native_uint;
117 113
118typedef u64 acpi_table_ptr; 114typedef u64 acpi_table_ptr;
119typedef u64 acpi_io_address; 115typedef u64 acpi_io_address;
120typedef u64 acpi_physical_address; 116typedef u64 acpi_physical_address;
121typedef u64 acpi_size; 117typedef u64 acpi_size;
122 118
123#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */ 119#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */
124#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */ 120#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */
125#define ACPI_MAX_PTR ACPI_UINT64_MAX 121#define ACPI_MAX_PTR ACPI_UINT64_MAX
126#define ACPI_SIZE_MAX ACPI_UINT64_MAX 122#define ACPI_SIZE_MAX ACPI_UINT64_MAX
127 123
128
129#elif ACPI_MACHINE_WIDTH == 16 124#elif ACPI_MACHINE_WIDTH == 16
130 125
131/*! [Begin] no source code translation (keep the typedefs) */ 126/*! [Begin] no source code translation (keep the typedefs) */
@@ -133,32 +128,31 @@ typedef u64 acpi_size;
133/* 128/*
134 * 16-bit type definitions 129 * 16-bit type definitions
135 */ 130 */
136typedef unsigned char UINT8; 131typedef unsigned char UINT8;
137typedef unsigned char BOOLEAN; 132typedef unsigned char BOOLEAN;
138typedef unsigned int UINT16; 133typedef unsigned int UINT16;
139typedef long INT32; 134typedef long INT32;
140typedef int INT16; 135typedef int INT16;
141typedef unsigned long UINT32; 136typedef unsigned long UINT32;
142 137
143struct 138struct {
144{ 139 UINT32 Lo;
145 UINT32 Lo; 140 UINT32 Hi;
146 UINT32 Hi;
147}; 141};
148 142
149/*! [End] no source code translation !*/ 143/*! [End] no source code translation !*/
150 144
151typedef u16 acpi_native_uint; 145typedef u16 acpi_native_uint;
152typedef s16 acpi_native_int; 146typedef s16 acpi_native_int;
153 147
154typedef u32 acpi_table_ptr; 148typedef u32 acpi_table_ptr;
155typedef u32 acpi_io_address; 149typedef u32 acpi_io_address;
156typedef char *acpi_physical_address; 150typedef char *acpi_physical_address;
157typedef u16 acpi_size; 151typedef u16 acpi_size;
158 152
159#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 153#define ALIGNED_ADDRESS_BOUNDARY 0x00000002
160#define ACPI_MISALIGNED_TRANSFERS 154#define ACPI_MISALIGNED_TRANSFERS
161#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ 155#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */
162#define ACPI_MAX_PTR ACPI_UINT16_MAX 156#define ACPI_MAX_PTR ACPI_UINT16_MAX
163#define ACPI_SIZE_MAX ACPI_UINT16_MAX 157#define ACPI_SIZE_MAX ACPI_UINT16_MAX
164 158
@@ -168,7 +162,6 @@ typedef u16 acpi_size;
168 */ 162 */
169#define ACPI_NO_INTEGER64_SUPPORT 163#define ACPI_NO_INTEGER64_SUPPORT
170 164
171
172#elif ACPI_MACHINE_WIDTH == 32 165#elif ACPI_MACHINE_WIDTH == 32
173 166
174/*! [Begin] no source code translation (keep the typedefs) */ 167/*! [Begin] no source code translation (keep the typedefs) */
@@ -176,23 +169,23 @@ typedef u16 acpi_size;
176/* 169/*
177 * 32-bit type definitions (default) 170 * 32-bit type definitions (default)
178 */ 171 */
179typedef unsigned char UINT8; 172typedef unsigned char UINT8;
180typedef unsigned char BOOLEAN; 173typedef unsigned char BOOLEAN;
181typedef unsigned short UINT16; 174typedef unsigned short UINT16;
182typedef int INT32; 175typedef int INT32;
183typedef unsigned int UINT32; 176typedef unsigned int UINT32;
184typedef COMPILER_DEPENDENT_INT64 INT64; 177typedef COMPILER_DEPENDENT_INT64 INT64;
185typedef COMPILER_DEPENDENT_UINT64 UINT64; 178typedef COMPILER_DEPENDENT_UINT64 UINT64;
186 179
187/*! [End] no source code translation !*/ 180/*! [End] no source code translation !*/
188 181
189typedef s32 acpi_native_int; 182typedef s32 acpi_native_int;
190typedef u32 acpi_native_uint; 183typedef u32 acpi_native_uint;
191 184
192typedef u64 acpi_table_ptr; 185typedef u64 acpi_table_ptr;
193typedef u32 acpi_io_address; 186typedef u32 acpi_io_address;
194typedef u64 acpi_physical_address; 187typedef u64 acpi_physical_address;
195typedef u32 acpi_size; 188typedef u32 acpi_size;
196 189
197#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 190#define ALIGNED_ADDRESS_BOUNDARY 0x00000004
198#define ACPI_MISALIGNED_TRANSFERS 191#define ACPI_MISALIGNED_TRANSFERS
@@ -203,29 +196,27 @@ typedef u32 acpi_size;
203#error unknown ACPI_MACHINE_WIDTH 196#error unknown ACPI_MACHINE_WIDTH
204#endif 197#endif
205 198
206
207/* 199/*
208 * Miscellaneous common types 200 * This type is used for bitfields in ACPI tables. The only type that is
201 * even remotely portable is u8. Anything else is not portable, so
202 * do not add any more bitfield types.
209 */ 203 */
210typedef u16 UINT16_BIT; 204typedef u8 UINT8_BIT;
211typedef u32 UINT32_BIT; 205typedef acpi_native_uint ACPI_PTRDIFF;
212typedef acpi_native_uint ACPI_PTRDIFF;
213 206
214/* 207/*
215 * Pointer overlays to avoid lots of typecasting for 208 * Pointer overlays to avoid lots of typecasting for
216 * code that accepts both physical and logical pointers. 209 * code that accepts both physical and logical pointers.
217 */ 210 */
218union acpi_pointers 211union acpi_pointers {
219{ 212 acpi_physical_address physical;
220 acpi_physical_address physical; 213 void *logical;
221 void *logical; 214 acpi_table_ptr value;
222 acpi_table_ptr value;
223}; 215};
224 216
225struct acpi_pointer 217struct acpi_pointer {
226{ 218 u32 pointer_type;
227 u32 pointer_type; 219 union acpi_pointers pointer;
228 union acpi_pointers pointer;
229}; 220};
230 221
231/* pointer_types for above */ 222/* pointer_types for above */
@@ -243,6 +234,14 @@ struct acpi_pointer
243#define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER 234#define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER
244#define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER 235#define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER
245 236
237/*
238 * If acpi_cache_t was not defined in the OS-dependent header,
239 * define it now. This is typically the case where the local cache
240 * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)
241 */
242#ifndef acpi_cache_t
243#define acpi_cache_t struct acpi_memory_list
244#endif
246 245
247/* 246/*
248 * Useful defines 247 * Useful defines
@@ -261,34 +260,29 @@ struct acpi_pointer
261#define NULL (void *) 0 260#define NULL (void *) 0
262#endif 261#endif
263 262
264
265/* 263/*
266 * Local datatypes 264 * Local datatypes
267 */ 265 */
268typedef u32 acpi_status; /* All ACPI Exceptions */ 266typedef u32 acpi_status; /* All ACPI Exceptions */
269typedef u32 acpi_name; /* 4-byte ACPI name */ 267typedef u32 acpi_name; /* 4-byte ACPI name */
270typedef char * acpi_string; /* Null terminated ASCII string */ 268typedef char *acpi_string; /* Null terminated ASCII string */
271typedef void * acpi_handle; /* Actually a ptr to an Node */ 269typedef void *acpi_handle; /* Actually a ptr to an Node */
272 270
273struct uint64_struct 271struct uint64_struct {
274{ 272 u32 lo;
275 u32 lo; 273 u32 hi;
276 u32 hi;
277}; 274};
278 275
279union uint64_overlay 276union uint64_overlay {
280{ 277 u64 full;
281 u64 full; 278 struct uint64_struct part;
282 struct uint64_struct part;
283}; 279};
284 280
285struct uint32_struct 281struct uint32_struct {
286{ 282 u32 lo;
287 u32 lo; 283 u32 hi;
288 u32 hi;
289}; 284};
290 285
291
292/* 286/*
293 * Acpi integer width. In ACPI version 1, integers are 287 * Acpi integer width. In ACPI version 1, integers are
294 * 32 bits. In ACPI version 2, integers are 64 bits. 288 * 32 bits. In ACPI version 2, integers are 64 bits.
@@ -300,26 +294,24 @@ struct uint32_struct
300 294
301/* 32-bit integers only, no 64-bit support */ 295/* 32-bit integers only, no 64-bit support */
302 296
303typedef u32 acpi_integer; 297typedef u32 acpi_integer;
304#define ACPI_INTEGER_MAX ACPI_UINT32_MAX 298#define ACPI_INTEGER_MAX ACPI_UINT32_MAX
305#define ACPI_INTEGER_BIT_SIZE 32 299#define ACPI_INTEGER_BIT_SIZE 32
306#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ 300#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */
307
308#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */
309 301
302#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */
310 303
311#else 304#else
312 305
313/* 64-bit integers */ 306/* 64-bit integers */
314 307
315typedef u64 acpi_integer; 308typedef u64 acpi_integer;
316#define ACPI_INTEGER_MAX ACPI_UINT64_MAX 309#define ACPI_INTEGER_MAX ACPI_UINT64_MAX
317#define ACPI_INTEGER_BIT_SIZE 64 310#define ACPI_INTEGER_BIT_SIZE 64
318#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ 311#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */
319
320 312
321#if ACPI_MACHINE_WIDTH == 64 313#if ACPI_MACHINE_WIDTH == 64
322#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ 314#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */
323#endif 315#endif
324#endif 316#endif
325 317
@@ -333,7 +325,6 @@ typedef u64 acpi_integer;
333 */ 325 */
334#define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) 326#define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR)
335 327
336
337/* 328/*
338 * Initialization sequence 329 * Initialization sequence
339 */ 330 */
@@ -400,7 +391,7 @@ typedef u64 acpi_integer;
400/* 391/*
401 * Table types. These values are passed to the table related APIs 392 * Table types. These values are passed to the table related APIs
402 */ 393 */
403typedef u32 acpi_table_type; 394typedef u32 acpi_table_type;
404 395
405#define ACPI_TABLE_RSDP (acpi_table_type) 0 396#define ACPI_TABLE_RSDP (acpi_table_type) 0
406#define ACPI_TABLE_DSDT (acpi_table_type) 1 397#define ACPI_TABLE_DSDT (acpi_table_type) 1
@@ -421,22 +412,22 @@ typedef u32 acpi_table_type;
421 * NOTE: Types must be kept in sync with the global acpi_ns_properties 412 * NOTE: Types must be kept in sync with the global acpi_ns_properties
422 * and acpi_ns_type_names arrays. 413 * and acpi_ns_type_names arrays.
423 */ 414 */
424typedef u32 acpi_object_type; 415typedef u32 acpi_object_type;
425 416
426#define ACPI_TYPE_ANY 0x00 417#define ACPI_TYPE_ANY 0x00
427#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ 418#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */
428#define ACPI_TYPE_STRING 0x02 419#define ACPI_TYPE_STRING 0x02
429#define ACPI_TYPE_BUFFER 0x03 420#define ACPI_TYPE_BUFFER 0x03
430#define ACPI_TYPE_PACKAGE 0x04 /* byte_const, multiple data_term/Constant/super_name */ 421#define ACPI_TYPE_PACKAGE 0x04 /* byte_const, multiple data_term/Constant/super_name */
431#define ACPI_TYPE_FIELD_UNIT 0x05 422#define ACPI_TYPE_FIELD_UNIT 0x05
432#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ 423#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */
433#define ACPI_TYPE_EVENT 0x07 424#define ACPI_TYPE_EVENT 0x07
434#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */ 425#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */
435#define ACPI_TYPE_MUTEX 0x09 426#define ACPI_TYPE_MUTEX 0x09
436#define ACPI_TYPE_REGION 0x0A 427#define ACPI_TYPE_REGION 0x0A
437#define ACPI_TYPE_POWER 0x0B /* Name,byte_const,word_const,multi Node */ 428#define ACPI_TYPE_POWER 0x0B /* Name,byte_const,word_const,multi Node */
438#define ACPI_TYPE_PROCESSOR 0x0C /* Name,byte_const,Dword_const,byte_const,multi nm_o */ 429#define ACPI_TYPE_PROCESSOR 0x0C /* Name,byte_const,Dword_const,byte_const,multi nm_o */
439#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ 430#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */
440#define ACPI_TYPE_BUFFER_FIELD 0x0E 431#define ACPI_TYPE_BUFFER_FIELD 0x0E
441#define ACPI_TYPE_DDB_HANDLE 0x0F 432#define ACPI_TYPE_DDB_HANDLE 0x0F
442#define ACPI_TYPE_DEBUG_OBJECT 0x10 433#define ACPI_TYPE_DEBUG_OBJECT 0x10
@@ -453,16 +444,16 @@ typedef u32 acpi_object_type;
453#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 444#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11
454#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 445#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12
455#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 446#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13
456#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, ref_of, Index */ 447#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, ref_of, Index */
457#define ACPI_TYPE_LOCAL_ALIAS 0x15 448#define ACPI_TYPE_LOCAL_ALIAS 0x15
458#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 449#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16
459#define ACPI_TYPE_LOCAL_NOTIFY 0x17 450#define ACPI_TYPE_LOCAL_NOTIFY 0x17
460#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 451#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
461#define ACPI_TYPE_LOCAL_RESOURCE 0x19 452#define ACPI_TYPE_LOCAL_RESOURCE 0x19
462#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A 453#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A
463#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple object_list Nodes */ 454#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple object_list Nodes */
464 455
465#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ 456#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */
466 457
467/* 458/*
468 * These are special object types that never appear in 459 * These are special object types that never appear in
@@ -506,7 +497,7 @@ typedef u32 acpi_object_type;
506#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) 497#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
507#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) 498#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
508#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) 499#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
509#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ 500#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
510#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF 501#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
511 502
512/* 503/*
@@ -519,7 +510,7 @@ typedef u32 acpi_object_type;
519/* 510/*
520 * Event Types: Fixed & General Purpose 511 * Event Types: Fixed & General Purpose
521 */ 512 */
522typedef u32 acpi_event_type; 513typedef u32 acpi_event_type;
523 514
524/* 515/*
525 * Fixed events 516 * Fixed events
@@ -547,7 +538,7 @@ typedef u32 acpi_event_type;
547 * | +----- Set? 538 * | +----- Set?
548 * +----------- <Reserved> 539 * +----------- <Reserved>
549 */ 540 */
550typedef u32 acpi_event_status; 541typedef u32 acpi_event_status;
551 542
552#define ACPI_EVENT_FLAG_DISABLED (acpi_event_status) 0x00 543#define ACPI_EVENT_FLAG_DISABLED (acpi_event_status) 0x00
553#define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 544#define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01
@@ -564,7 +555,6 @@ typedef u32 acpi_event_status;
564#define ACPI_GPE_ENABLE 0 555#define ACPI_GPE_ENABLE 0
565#define ACPI_GPE_DISABLE 1 556#define ACPI_GPE_DISABLE 1
566 557
567
568/* 558/*
569 * GPE info flags - Per GPE 559 * GPE info flags - Per GPE
570 * +-+-+-+---+---+-+ 560 * +-+-+-+---+---+-+
@@ -585,22 +575,22 @@ typedef u32 acpi_event_status;
585#define ACPI_GPE_TYPE_MASK (u8) 0x06 575#define ACPI_GPE_TYPE_MASK (u8) 0x06
586#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 576#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06
587#define ACPI_GPE_TYPE_WAKE (u8) 0x02 577#define ACPI_GPE_TYPE_WAKE (u8) 0x02
588#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */ 578#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */
589 579
590#define ACPI_GPE_DISPATCH_MASK (u8) 0x18 580#define ACPI_GPE_DISPATCH_MASK (u8) 0x18
591#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08 581#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08
592#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10 582#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10
593#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */ 583#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */
594 584
595#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 585#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20
596#define ACPI_GPE_RUN_ENABLED (u8) 0x20 586#define ACPI_GPE_RUN_ENABLED (u8) 0x20
597#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */ 587#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */
598 588
599#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 589#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40
600#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 590#define ACPI_GPE_WAKE_ENABLED (u8) 0x40
601#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */ 591#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */
602 592
603#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */ 593#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */
604 594
605#define ACPI_GPE_SYSTEM_MASK (u8) 0x80 595#define ACPI_GPE_SYSTEM_MASK (u8) 0x80
606#define ACPI_GPE_SYSTEM_RUNNING (u8) 0x80 596#define ACPI_GPE_SYSTEM_RUNNING (u8) 0x80
@@ -609,13 +599,12 @@ typedef u32 acpi_event_status;
609/* 599/*
610 * Flags for GPE and Lock interfaces 600 * Flags for GPE and Lock interfaces
611 */ 601 */
612#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */ 602#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */
613#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */ 603#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */
614 604
615#define ACPI_NOT_ISR 0x1 605#define ACPI_NOT_ISR 0x1
616#define ACPI_ISR 0x0 606#define ACPI_ISR 0x0
617 607
618
619/* Notify types */ 608/* Notify types */
620 609
621#define ACPI_SYSTEM_NOTIFY 0x1 610#define ACPI_SYSTEM_NOTIFY 0x1
@@ -625,10 +614,9 @@ typedef u32 acpi_event_status;
625 614
626#define ACPI_MAX_SYS_NOTIFY 0x7f 615#define ACPI_MAX_SYS_NOTIFY 0x7f
627 616
628
629/* Address Space (Operation Region) Types */ 617/* Address Space (Operation Region) Types */
630 618
631typedef u8 acpi_adr_space_type; 619typedef u8 acpi_adr_space_type;
632 620
633#define ACPI_ADR_SPACE_SYSTEM_MEMORY (acpi_adr_space_type) 0 621#define ACPI_ADR_SPACE_SYSTEM_MEMORY (acpi_adr_space_type) 0
634#define ACPI_ADR_SPACE_SYSTEM_IO (acpi_adr_space_type) 1 622#define ACPI_ADR_SPACE_SYSTEM_IO (acpi_adr_space_type) 1
@@ -640,7 +628,6 @@ typedef u8 acpi_adr_space_type;
640#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7 628#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7
641#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 629#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127
642 630
643
644/* 631/*
645 * bit_register IDs 632 * bit_register IDs
646 * These are bitfields defined within the full ACPI registers 633 * These are bitfields defined within the full ACPI registers
@@ -674,74 +661,62 @@ typedef u8 acpi_adr_space_type;
674#define ACPI_BITREG_MAX 0x15 661#define ACPI_BITREG_MAX 0x15
675#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 662#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1
676 663
677
678/* 664/*
679 * External ACPI object definition 665 * External ACPI object definition
680 */ 666 */
681union acpi_object 667union acpi_object {
682{ 668 acpi_object_type type; /* See definition of acpi_ns_type for values */
683 acpi_object_type type; /* See definition of acpi_ns_type for values */ 669 struct {
684 struct 670 acpi_object_type type;
685 { 671 acpi_integer value; /* The actual number */
686 acpi_object_type type;
687 acpi_integer value; /* The actual number */
688 } integer; 672 } integer;
689 673
690 struct 674 struct {
691 { 675 acpi_object_type type;
692 acpi_object_type type; 676 u32 length; /* # of bytes in string, excluding trailing null */
693 u32 length; /* # of bytes in string, excluding trailing null */ 677 char *pointer; /* points to the string value */
694 char *pointer; /* points to the string value */
695 } string; 678 } string;
696 679
697 struct 680 struct {
698 { 681 acpi_object_type type;
699 acpi_object_type type; 682 u32 length; /* # of bytes in buffer */
700 u32 length; /* # of bytes in buffer */ 683 u8 *pointer; /* points to the buffer */
701 u8 *pointer; /* points to the buffer */
702 } buffer; 684 } buffer;
703 685
704 struct 686 struct {
705 { 687 acpi_object_type type;
706 acpi_object_type type; 688 u32 fill1;
707 u32 fill1; 689 acpi_handle handle; /* object reference */
708 acpi_handle handle; /* object reference */
709 } reference; 690 } reference;
710 691
711 struct 692 struct {
712 { 693 acpi_object_type type;
713 acpi_object_type type; 694 u32 count; /* # of elements in package */
714 u32 count; /* # of elements in package */ 695 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */
715 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */
716 } package; 696 } package;
717 697
718 struct 698 struct {
719 { 699 acpi_object_type type;
720 acpi_object_type type; 700 u32 proc_id;
721 u32 proc_id; 701 acpi_io_address pblk_address;
722 acpi_io_address pblk_address; 702 u32 pblk_length;
723 u32 pblk_length;
724 } processor; 703 } processor;
725 704
726 struct 705 struct {
727 { 706 acpi_object_type type;
728 acpi_object_type type; 707 u32 system_level;
729 u32 system_level; 708 u32 resource_order;
730 u32 resource_order;
731 } power_resource; 709 } power_resource;
732}; 710};
733 711
734
735/* 712/*
736 * List of objects, used as a parameter list for control method evaluation 713 * List of objects, used as a parameter list for control method evaluation
737 */ 714 */
738struct acpi_object_list 715struct acpi_object_list {
739{ 716 u32 count;
740 u32 count; 717 union acpi_object *pointer;
741 union acpi_object *pointer;
742}; 718};
743 719
744
745/* 720/*
746 * Miscellaneous common Data Structures used by the interfaces 721 * Miscellaneous common Data Structures used by the interfaces
747 */ 722 */
@@ -749,13 +724,11 @@ struct acpi_object_list
749#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) 724#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1)
750#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) 725#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2)
751 726
752struct acpi_buffer 727struct acpi_buffer {
753{ 728 acpi_size length; /* Length in bytes of the buffer */
754 acpi_size length; /* Length in bytes of the buffer */ 729 void *pointer; /* pointer to buffer */
755 void *pointer; /* pointer to buffer */
756}; 730};
757 731
758
759/* 732/*
760 * name_type for acpi_get_name 733 * name_type for acpi_get_name
761 */ 734 */
@@ -763,7 +736,6 @@ struct acpi_buffer
763#define ACPI_SINGLE_NAME 1 736#define ACPI_SINGLE_NAME 1
764#define ACPI_NAME_TYPE_MAX 1 737#define ACPI_NAME_TYPE_MAX 1
765 738
766
767/* 739/*
768 * Structure and flags for acpi_get_system_info 740 * Structure and flags for acpi_get_system_info
769 */ 741 */
@@ -772,139 +744,106 @@ struct acpi_buffer
772#define ACPI_SYS_MODE_LEGACY 0x0002 744#define ACPI_SYS_MODE_LEGACY 0x0002
773#define ACPI_SYS_MODES_MASK 0x0003 745#define ACPI_SYS_MODES_MASK 0x0003
774 746
775
776/* 747/*
777 * ACPI Table Info. One per ACPI table _type_ 748 * ACPI Table Info. One per ACPI table _type_
778 */ 749 */
779struct acpi_table_info 750struct acpi_table_info {
780{ 751 u32 count;
781 u32 count;
782}; 752};
783 753
784
785/* 754/*
786 * System info returned by acpi_get_system_info() 755 * System info returned by acpi_get_system_info()
787 */ 756 */
788struct acpi_system_info 757struct acpi_system_info {
789{ 758 u32 acpi_ca_version;
790 u32 acpi_ca_version; 759 u32 flags;
791 u32 flags; 760 u32 timer_resolution;
792 u32 timer_resolution; 761 u32 reserved1;
793 u32 reserved1; 762 u32 reserved2;
794 u32 reserved2; 763 u32 debug_level;
795 u32 debug_level; 764 u32 debug_layer;
796 u32 debug_layer; 765 u32 num_table_types;
797 u32 num_table_types; 766 struct acpi_table_info table_info[NUM_ACPI_TABLE_TYPES];
798 struct acpi_table_info table_info [NUM_ACPI_TABLE_TYPES];
799}; 767};
800 768
801
802/* 769/*
803 * Types specific to the OS service interfaces 770 * Types specific to the OS service interfaces
804 */ 771 */
805typedef u32 772typedef u32(ACPI_SYSTEM_XFACE * acpi_osd_handler) (void *context);
806(ACPI_SYSTEM_XFACE *acpi_osd_handler) (
807 void *context);
808 773
809typedef void 774typedef void
810(ACPI_SYSTEM_XFACE *acpi_osd_exec_callback) ( 775 (ACPI_SYSTEM_XFACE * acpi_osd_exec_callback) (void *context);
811 void *context);
812 776
813/* 777/*
814 * Various handlers and callback procedures 778 * Various handlers and callback procedures
815 */ 779 */
816typedef 780typedef u32(*acpi_event_handler) (void *context);
817u32 (*acpi_event_handler) (
818 void *context);
819 781
820typedef 782typedef
821void (*acpi_notify_handler) ( 783void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
822 acpi_handle device,
823 u32 value,
824 void *context);
825 784
826typedef 785typedef
827void (*acpi_object_handler) ( 786void (*acpi_object_handler) (acpi_handle object, u32 function, void *data);
828 acpi_handle object,
829 u32 function,
830 void *data);
831 787
832typedef 788typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function);
833acpi_status (*acpi_init_handler) (
834 acpi_handle object,
835 u32 function);
836 789
837#define ACPI_INIT_DEVICE_INI 1 790#define ACPI_INIT_DEVICE_INI 1
838 791
839typedef 792typedef
840acpi_status (*acpi_exception_handler) ( 793acpi_status(*acpi_exception_handler) (acpi_status aml_status,
841 acpi_status aml_status, 794 acpi_name name,
842 acpi_name name, 795 u16 opcode,
843 u16 opcode, 796 u32 aml_offset, void *context);
844 u32 aml_offset,
845 void *context);
846
847 797
848/* Address Spaces (For Operation Regions) */ 798/* Address Spaces (For Operation Regions) */
849 799
850typedef 800typedef
851acpi_status (*acpi_adr_space_handler) ( 801acpi_status(*acpi_adr_space_handler) (u32 function,
852 u32 function, 802 acpi_physical_address address,
853 acpi_physical_address address, 803 u32 bit_width,
854 u32 bit_width, 804 acpi_integer * value,
855 acpi_integer *value, 805 void *handler_context,
856 void *handler_context, 806 void *region_context);
857 void *region_context);
858 807
859#define ACPI_DEFAULT_HANDLER NULL 808#define ACPI_DEFAULT_HANDLER NULL
860 809
861
862typedef 810typedef
863acpi_status (*acpi_adr_space_setup) ( 811acpi_status(*acpi_adr_space_setup) (acpi_handle region_handle,
864 acpi_handle region_handle, 812 u32 function,
865 u32 function, 813 void *handler_context,
866 void *handler_context, 814 void **region_context);
867 void **region_context);
868 815
869#define ACPI_REGION_ACTIVATE 0 816#define ACPI_REGION_ACTIVATE 0
870#define ACPI_REGION_DEACTIVATE 1 817#define ACPI_REGION_DEACTIVATE 1
871 818
872typedef 819typedef
873acpi_status (*acpi_walk_callback) ( 820acpi_status(*acpi_walk_callback) (acpi_handle obj_handle,
874 acpi_handle obj_handle, 821 u32 nesting_level,
875 u32 nesting_level, 822 void *context, void **return_value);
876 void *context,
877 void **return_value);
878
879 823
880/* Interrupt handler return values */ 824/* Interrupt handler return values */
881 825
882#define ACPI_INTERRUPT_NOT_HANDLED 0x00 826#define ACPI_INTERRUPT_NOT_HANDLED 0x00
883#define ACPI_INTERRUPT_HANDLED 0x01 827#define ACPI_INTERRUPT_HANDLED 0x01
884 828
885
886/* Common string version of device HIDs and UIDs */ 829/* Common string version of device HIDs and UIDs */
887 830
888struct acpi_device_id 831struct acpi_device_id {
889{ 832 char value[ACPI_DEVICE_ID_LENGTH];
890 char value[ACPI_DEVICE_ID_LENGTH];
891}; 833};
892 834
893/* Common string version of device CIDs */ 835/* Common string version of device CIDs */
894 836
895struct acpi_compatible_id 837struct acpi_compatible_id {
896{ 838 char value[ACPI_MAX_CID_LENGTH];
897 char value[ACPI_MAX_CID_LENGTH];
898}; 839};
899 840
900struct acpi_compatible_id_list 841struct acpi_compatible_id_list {
901{ 842 u32 count;
902 u32 count; 843 u32 size;
903 u32 size; 844 struct acpi_compatible_id id[1];
904 struct acpi_compatible_id id[1];
905}; 845};
906 846
907
908/* Structure and flags for acpi_get_object_info */ 847/* Structure and flags for acpi_get_object_info */
909 848
910#define ACPI_VALID_STA 0x0001 849#define ACPI_VALID_STA 0x0001
@@ -914,55 +853,45 @@ struct acpi_compatible_id_list
914#define ACPI_VALID_CID 0x0010 853#define ACPI_VALID_CID 0x0010
915#define ACPI_VALID_SXDS 0x0020 854#define ACPI_VALID_SXDS 0x0020
916 855
917
918#define ACPI_COMMON_OBJ_INFO \ 856#define ACPI_COMMON_OBJ_INFO \
919 acpi_object_type type; /* ACPI object type */ \ 857 acpi_object_type type; /* ACPI object type */ \
920 acpi_name name /* ACPI object Name */ 858 acpi_name name /* ACPI object Name */
921
922 859
923struct acpi_obj_info_header 860struct acpi_obj_info_header {
924{
925 ACPI_COMMON_OBJ_INFO; 861 ACPI_COMMON_OBJ_INFO;
926}; 862};
927 863
928
929/* Structure returned from Get Object Info */ 864/* Structure returned from Get Object Info */
930 865
931struct acpi_device_info 866struct acpi_device_info {
932{
933 ACPI_COMMON_OBJ_INFO; 867 ACPI_COMMON_OBJ_INFO;
934 868
935 u32 valid; /* Indicates which fields below are valid */ 869 u32 valid; /* Indicates which fields below are valid */
936 u32 current_status; /* _STA value */ 870 u32 current_status; /* _STA value */
937 acpi_integer address; /* _ADR value if any */ 871 acpi_integer address; /* _ADR value if any */
938 struct acpi_device_id hardware_id; /* _HID value if any */ 872 struct acpi_device_id hardware_id; /* _HID value if any */
939 struct acpi_device_id unique_id; /* _UID value if any */ 873 struct acpi_device_id unique_id; /* _UID value if any */
940 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 874 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */
941 struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */ 875 struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */
942}; 876};
943 877
944
945/* Context structs for address space handlers */ 878/* Context structs for address space handlers */
946 879
947struct acpi_pci_id 880struct acpi_pci_id {
948{ 881 u16 segment;
949 u16 segment; 882 u16 bus;
950 u16 bus; 883 u16 device;
951 u16 device; 884 u16 function;
952 u16 function;
953}; 885};
954 886
955 887struct acpi_mem_space_context {
956struct acpi_mem_space_context 888 u32 length;
957{ 889 acpi_physical_address address;
958 u32 length; 890 acpi_physical_address mapped_physical_address;
959 acpi_physical_address address; 891 u8 *mapped_logical_address;
960 acpi_physical_address mapped_physical_address; 892 acpi_size mapped_length;
961 u8 *mapped_logical_address;
962 acpi_size mapped_length;
963}; 893};
964 894
965
966/* 895/*
967 * Definitions for Resource Attributes 896 * Definitions for Resource Attributes
968 */ 897 */
@@ -992,8 +921,8 @@ struct acpi_mem_space_context
992/* 921/*
993 * IO Port Descriptor Decode 922 * IO Port Descriptor Decode
994 */ 923 */
995#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ 924#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */
996#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ 925#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */
997 926
998/* 927/*
999 * IRQ Attributes 928 * IRQ Attributes
@@ -1045,32 +974,28 @@ struct acpi_mem_space_context
1045#define ACPI_PRODUCER (u8) 0x00 974#define ACPI_PRODUCER (u8) 0x00
1046#define ACPI_CONSUMER (u8) 0x01 975#define ACPI_CONSUMER (u8) 0x01
1047 976
1048
1049/* 977/*
1050 * Structures used to describe device resources 978 * Structures used to describe device resources
1051 */ 979 */
1052struct acpi_resource_irq 980struct acpi_resource_irq {
1053{ 981 u32 edge_level;
1054 u32 edge_level; 982 u32 active_high_low;
1055 u32 active_high_low; 983 u32 shared_exclusive;
1056 u32 shared_exclusive; 984 u32 number_of_interrupts;
1057 u32 number_of_interrupts; 985 u32 interrupts[1];
1058 u32 interrupts[1];
1059}; 986};
1060 987
1061struct acpi_resource_dma 988struct acpi_resource_dma {
1062{ 989 u32 type;
1063 u32 type; 990 u32 bus_master;
1064 u32 bus_master; 991 u32 transfer;
1065 u32 transfer; 992 u32 number_of_channels;
1066 u32 number_of_channels; 993 u32 channels[1];
1067 u32 channels[1];
1068}; 994};
1069 995
1070struct acpi_resource_start_dpf 996struct acpi_resource_start_dpf {
1071{ 997 u32 compatibility_priority;
1072 u32 compatibility_priority; 998 u32 performance_robustness;
1073 u32 performance_robustness;
1074}; 999};
1075 1000
1076/* 1001/*
@@ -1078,149 +1003,127 @@ struct acpi_resource_start_dpf
1078 * needed because it has no fields 1003 * needed because it has no fields
1079 */ 1004 */
1080 1005
1081struct acpi_resource_io 1006struct acpi_resource_io {
1082{ 1007 u32 io_decode;
1083 u32 io_decode; 1008 u32 min_base_address;
1084 u32 min_base_address; 1009 u32 max_base_address;
1085 u32 max_base_address; 1010 u32 alignment;
1086 u32 alignment; 1011 u32 range_length;
1087 u32 range_length;
1088}; 1012};
1089 1013
1090struct acpi_resource_fixed_io 1014struct acpi_resource_fixed_io {
1091{ 1015 u32 base_address;
1092 u32 base_address; 1016 u32 range_length;
1093 u32 range_length;
1094}; 1017};
1095 1018
1096struct acpi_resource_vendor 1019struct acpi_resource_vendor {
1097{ 1020 u32 length;
1098 u32 length; 1021 u8 reserved[1];
1099 u8 reserved[1];
1100}; 1022};
1101 1023
1102struct acpi_resource_end_tag 1024struct acpi_resource_end_tag {
1103{ 1025 u8 checksum;
1104 u8 checksum;
1105}; 1026};
1106 1027
1107struct acpi_resource_mem24 1028struct acpi_resource_mem24 {
1108{ 1029 u32 read_write_attribute;
1109 u32 read_write_attribute; 1030 u32 min_base_address;
1110 u32 min_base_address; 1031 u32 max_base_address;
1111 u32 max_base_address; 1032 u32 alignment;
1112 u32 alignment; 1033 u32 range_length;
1113 u32 range_length;
1114}; 1034};
1115 1035
1116struct acpi_resource_mem32 1036struct acpi_resource_mem32 {
1117{ 1037 u32 read_write_attribute;
1118 u32 read_write_attribute; 1038 u32 min_base_address;
1119 u32 min_base_address; 1039 u32 max_base_address;
1120 u32 max_base_address; 1040 u32 alignment;
1121 u32 alignment; 1041 u32 range_length;
1122 u32 range_length;
1123}; 1042};
1124 1043
1125struct acpi_resource_fixed_mem32 1044struct acpi_resource_fixed_mem32 {
1126{ 1045 u32 read_write_attribute;
1127 u32 read_write_attribute; 1046 u32 range_base_address;
1128 u32 range_base_address; 1047 u32 range_length;
1129 u32 range_length;
1130}; 1048};
1131 1049
1132struct acpi_memory_attribute 1050struct acpi_memory_attribute {
1133{ 1051 u16 cache_attribute;
1134 u16 cache_attribute; 1052 u16 read_write_attribute;
1135 u16 read_write_attribute;
1136}; 1053};
1137 1054
1138struct acpi_io_attribute 1055struct acpi_io_attribute {
1139{ 1056 u16 range_attribute;
1140 u16 range_attribute; 1057 u16 translation_attribute;
1141 u16 translation_attribute;
1142}; 1058};
1143 1059
1144struct acpi_bus_attribute 1060struct acpi_bus_attribute {
1145{ 1061 u16 reserved1;
1146 u16 reserved1; 1062 u16 reserved2;
1147 u16 reserved2;
1148}; 1063};
1149 1064
1150union acpi_resource_attribute 1065union acpi_resource_attribute {
1151{ 1066 struct acpi_memory_attribute memory;
1152 struct acpi_memory_attribute memory; 1067 struct acpi_io_attribute io;
1153 struct acpi_io_attribute io; 1068 struct acpi_bus_attribute bus;
1154 struct acpi_bus_attribute bus;
1155}; 1069};
1156 1070
1157struct acpi_resource_source 1071struct acpi_resource_source {
1158{ 1072 u32 index;
1159 u32 index; 1073 u32 string_length;
1160 u32 string_length; 1074 char *string_ptr;
1161 char *string_ptr;
1162}; 1075};
1163 1076
1164struct acpi_resource_address16 1077/* Fields common to all address descriptors, 16/32/64 bit */
1165{
1166 u32 resource_type;
1167 u32 producer_consumer;
1168 u32 decode;
1169 u32 min_address_fixed;
1170 u32 max_address_fixed;
1171 union acpi_resource_attribute attribute;
1172 u32 granularity;
1173 u32 min_address_range;
1174 u32 max_address_range;
1175 u32 address_translation_offset;
1176 u32 address_length;
1177 struct acpi_resource_source resource_source;
1178};
1179 1078
1180struct acpi_resource_address32 1079#define ACPI_RESOURCE_ADDRESS_COMMON \
1181{ 1080 u32 resource_type; \
1182 u32 resource_type; 1081 u32 producer_consumer; \
1183 u32 producer_consumer; 1082 u32 decode; \
1184 u32 decode; 1083 u32 min_address_fixed; \
1185 u32 min_address_fixed; 1084 u32 max_address_fixed; \
1186 u32 max_address_fixed;
1187 union acpi_resource_attribute attribute; 1085 union acpi_resource_attribute attribute;
1188 u32 granularity; 1086
1189 u32 min_address_range; 1087struct acpi_resource_address {
1190 u32 max_address_range; 1088ACPI_RESOURCE_ADDRESS_COMMON};
1191 u32 address_translation_offset; 1089
1192 u32 address_length; 1090struct acpi_resource_address16 {
1193 struct acpi_resource_source resource_source; 1091 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
1092 u32 min_address_range;
1093 u32 max_address_range;
1094 u32 address_translation_offset;
1095 u32 address_length;
1096 struct acpi_resource_source resource_source;
1194}; 1097};
1195 1098
1196struct acpi_resource_address64 1099struct acpi_resource_address32 {
1197{ 1100 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
1198 u32 resource_type; 1101 u32 min_address_range;
1199 u32 producer_consumer; 1102 u32 max_address_range;
1200 u32 decode; 1103 u32 address_translation_offset;
1201 u32 min_address_fixed; 1104 u32 address_length;
1202 u32 max_address_fixed; 1105 struct acpi_resource_source resource_source;
1203 union acpi_resource_attribute attribute;
1204 u64 granularity;
1205 u64 min_address_range;
1206 u64 max_address_range;
1207 u64 address_translation_offset;
1208 u64 address_length;
1209 u64 type_specific_attributes;
1210 struct acpi_resource_source resource_source;
1211}; 1106};
1212 1107
1213struct acpi_resource_ext_irq 1108struct acpi_resource_address64 {
1214{ 1109 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity;
1215 u32 producer_consumer; 1110 u64 min_address_range;
1216 u32 edge_level; 1111 u64 max_address_range;
1217 u32 active_high_low; 1112 u64 address_translation_offset;
1218 u32 shared_exclusive; 1113 u64 address_length;
1219 u32 number_of_interrupts; 1114 u64 type_specific_attributes;
1220 struct acpi_resource_source resource_source; 1115 struct acpi_resource_source resource_source;
1221 u32 interrupts[1];
1222}; 1116};
1223 1117
1118struct acpi_resource_ext_irq {
1119 u32 producer_consumer;
1120 u32 edge_level;
1121 u32 active_high_low;
1122 u32 shared_exclusive;
1123 u32 number_of_interrupts;
1124 struct acpi_resource_source resource_source;
1125 u32 interrupts[1];
1126};
1224 1127
1225/* ACPI_RESOURCE_TYPEs */ 1128/* ACPI_RESOURCE_TYPEs */
1226 1129
@@ -1240,35 +1143,34 @@ struct acpi_resource_ext_irq
1240#define ACPI_RSTYPE_ADDRESS64 13 1143#define ACPI_RSTYPE_ADDRESS64 13
1241#define ACPI_RSTYPE_EXT_IRQ 14 1144#define ACPI_RSTYPE_EXT_IRQ 14
1242 1145
1243typedef u32 acpi_resource_type; 1146typedef u32 acpi_resource_type;
1244 1147
1245union acpi_resource_data 1148union acpi_resource_data {
1246{ 1149 struct acpi_resource_irq irq;
1247 struct acpi_resource_irq irq; 1150 struct acpi_resource_dma dma;
1248 struct acpi_resource_dma dma; 1151 struct acpi_resource_start_dpf start_dpf;
1249 struct acpi_resource_start_dpf start_dpf; 1152 struct acpi_resource_io io;
1250 struct acpi_resource_io io; 1153 struct acpi_resource_fixed_io fixed_io;
1251 struct acpi_resource_fixed_io fixed_io; 1154 struct acpi_resource_vendor vendor_specific;
1252 struct acpi_resource_vendor vendor_specific; 1155 struct acpi_resource_end_tag end_tag;
1253 struct acpi_resource_end_tag end_tag; 1156 struct acpi_resource_mem24 memory24;
1254 struct acpi_resource_mem24 memory24; 1157 struct acpi_resource_mem32 memory32;
1255 struct acpi_resource_mem32 memory32; 1158 struct acpi_resource_fixed_mem32 fixed_memory32;
1256 struct acpi_resource_fixed_mem32 fixed_memory32; 1159 struct acpi_resource_address address; /* Common 16/32/64 address fields */
1257 struct acpi_resource_address16 address16; 1160 struct acpi_resource_address16 address16;
1258 struct acpi_resource_address32 address32; 1161 struct acpi_resource_address32 address32;
1259 struct acpi_resource_address64 address64; 1162 struct acpi_resource_address64 address64;
1260 struct acpi_resource_ext_irq extended_irq; 1163 struct acpi_resource_ext_irq extended_irq;
1261}; 1164};
1262 1165
1263struct acpi_resource 1166struct acpi_resource {
1264{ 1167 acpi_resource_type id;
1265 acpi_resource_type id; 1168 u32 length;
1266 u32 length; 1169 union acpi_resource_data data;
1267 union acpi_resource_data data;
1268}; 1170};
1269 1171
1270#define ACPI_RESOURCE_LENGTH 12 1172#define ACPI_RESOURCE_LENGTH 12
1271#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ 1173#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */
1272 1174
1273#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) 1175#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
1274 1176
@@ -1284,19 +1186,16 @@ struct acpi_resource
1284 * END: of definitions for Resource Attributes 1186 * END: of definitions for Resource Attributes
1285 */ 1187 */
1286 1188
1287 1189struct acpi_pci_routing_table {
1288struct acpi_pci_routing_table 1190 u32 length;
1289{ 1191 u32 pin;
1290 u32 length; 1192 acpi_integer address; /* here for 64-bit alignment */
1291 u32 pin; 1193 u32 source_index;
1292 acpi_integer address; /* here for 64-bit alignment */ 1194 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
1293 u32 source_index;
1294 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
1295}; 1195};
1296 1196
1297/* 1197/*
1298 * END: of definitions for PCI Routing tables 1198 * END: of definitions for PCI Routing tables
1299 */ 1199 */
1300 1200
1301 1201#endif /* __ACTYPES_H__ */
1302#endif /* __ACTYPES_H__ */
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index 192d0bea3884..c1086452696e 100644
--- a/include/acpi/acutils.h
+++ b/include/acpi/acutils.h
@@ -44,20 +44,17 @@
44#ifndef _ACUTILS_H 44#ifndef _ACUTILS_H
45#define _ACUTILS_H 45#define _ACUTILS_H
46 46
47
48typedef 47typedef
49acpi_status (*acpi_pkg_callback) ( 48acpi_status(*acpi_pkg_callback) (u8 object_type,
50 u8 object_type, 49 union acpi_operand_object * source_object,
51 union acpi_operand_object *source_object, 50 union acpi_generic_state * state,
52 union acpi_generic_state *state, 51 void *context);
53 void *context); 52
54 53struct acpi_pkg_info {
55struct acpi_pkg_info 54 u8 *free_space;
56{ 55 acpi_size length;
57 u8 *free_space; 56 u32 object_space;
58 acpi_size length; 57 u32 num_packages;
59 u32 object_space;
60 u32 num_packages;
61}; 58};
62 59
63#define REF_INCREMENT (u16) 0 60#define REF_INCREMENT (u16) 0
@@ -71,167 +68,89 @@ struct acpi_pkg_info
71#define DB_DWORD_DISPLAY 4 68#define DB_DWORD_DISPLAY 4
72#define DB_QWORD_DISPLAY 8 69#define DB_QWORD_DISPLAY 8
73 70
74
75/* 71/*
76 * utglobal - Global data structures and procedures 72 * utglobal - Global data structures and procedures
77 */ 73 */
78void 74void acpi_ut_init_globals(void);
79acpi_ut_init_globals (
80 void);
81 75
82#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 76#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
83 77
84char * 78char *acpi_ut_get_mutex_name(u32 mutex_id);
85acpi_ut_get_mutex_name (
86 u32 mutex_id);
87 79
88#endif 80#endif
89 81
90char * 82char *acpi_ut_get_type_name(acpi_object_type type);
91acpi_ut_get_type_name (
92 acpi_object_type type);
93
94char *
95acpi_ut_get_node_name (
96 void *object);
97
98char *
99acpi_ut_get_descriptor_name (
100 void *object);
101 83
102char * 84char *acpi_ut_get_node_name(void *object);
103acpi_ut_get_object_type_name (
104 union acpi_operand_object *obj_desc);
105 85
106char * 86char *acpi_ut_get_descriptor_name(void *object);
107acpi_ut_get_region_name (
108 u8 space_id);
109 87
110char * 88char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
111acpi_ut_get_event_name (
112 u32 event_id);
113 89
114char 90char *acpi_ut_get_region_name(u8 space_id);
115acpi_ut_hex_to_ascii_char (
116 acpi_integer integer,
117 u32 position);
118 91
119u8 92char *acpi_ut_get_event_name(u32 event_id);
120acpi_ut_valid_object_type (
121 acpi_object_type type);
122 93
123acpi_owner_id 94char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position);
124acpi_ut_allocate_owner_id (
125 u32 id_type);
126 95
96u8 acpi_ut_valid_object_type(acpi_object_type type);
127 97
128/* 98/*
129 * utinit - miscellaneous initialization and shutdown 99 * utinit - miscellaneous initialization and shutdown
130 */ 100 */
131acpi_status 101acpi_status acpi_ut_hardware_initialize(void);
132acpi_ut_hardware_initialize (
133 void);
134 102
135void 103void acpi_ut_subsystem_shutdown(void);
136acpi_ut_subsystem_shutdown (
137 void);
138
139acpi_status
140acpi_ut_validate_fadt (
141 void);
142 104
105acpi_status acpi_ut_validate_fadt(void);
143 106
144/* 107/*
145 * utclib - Local implementations of C library functions 108 * utclib - Local implementations of C library functions
146 */ 109 */
147#ifndef ACPI_USE_SYSTEM_CLIBRARY 110#ifndef ACPI_USE_SYSTEM_CLIBRARY
148 111
149acpi_size 112acpi_size acpi_ut_strlen(const char *string);
150acpi_ut_strlen ( 113
151 const char *string); 114char *acpi_ut_strcpy(char *dst_string, const char *src_string);
152 115
153char * 116char *acpi_ut_strncpy(char *dst_string,
154acpi_ut_strcpy ( 117 const char *src_string, acpi_size count);
155 char *dst_string, 118
156 const char *src_string); 119int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count);
157 120
158char * 121int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count);
159acpi_ut_strncpy ( 122
160 char *dst_string, 123int acpi_ut_strcmp(const char *string1, const char *string2);
161 const char *src_string, 124
162 acpi_size count); 125char *acpi_ut_strcat(char *dst_string, const char *src_string);
163 126
164int 127char *acpi_ut_strncat(char *dst_string,
165acpi_ut_memcmp ( 128 const char *src_string, acpi_size count);
166 const char *buffer1, 129
167 const char *buffer2, 130u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base);
168 acpi_size count); 131
169 132char *acpi_ut_strstr(char *string1, char *string2);
170int 133
171acpi_ut_strncmp ( 134void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count);
172 const char *string1, 135
173 const char *string2, 136void *acpi_ut_memset(void *dest, acpi_native_uint value, acpi_size count);
174 acpi_size count); 137
175 138int acpi_ut_to_upper(int c);
176int 139
177acpi_ut_strcmp ( 140int acpi_ut_to_lower(int c);
178 const char *string1,
179 const char *string2);
180
181char *
182acpi_ut_strcat (
183 char *dst_string,
184 const char *src_string);
185
186char *
187acpi_ut_strncat (
188 char *dst_string,
189 const char *src_string,
190 acpi_size count);
191
192u32
193acpi_ut_strtoul (
194 const char *string,
195 char **terminator,
196 u32 base);
197
198char *
199acpi_ut_strstr (
200 char *string1,
201 char *string2);
202
203void *
204acpi_ut_memcpy (
205 void *dest,
206 const void *src,
207 acpi_size count);
208
209void *
210acpi_ut_memset (
211 void *dest,
212 acpi_native_uint value,
213 acpi_size count);
214
215int
216acpi_ut_to_upper (
217 int c);
218
219int
220acpi_ut_to_lower (
221 int c);
222 141
223extern const u8 _acpi_ctype[]; 142extern const u8 _acpi_ctype[];
224 143
225#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ 144#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
226#define _ACPI_XS 0x40 /* extra space */ 145#define _ACPI_XS 0x40 /* extra space */
227#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ 146#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
228#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ 147#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
229#define _ACPI_DI 0x04 /* '0'-'9' */ 148#define _ACPI_DI 0x04 /* '0'-'9' */
230#define _ACPI_LO 0x02 /* 'a'-'z' */ 149#define _ACPI_LO 0x02 /* 'a'-'z' */
231#define _ACPI_PU 0x10 /* punctuation */ 150#define _ACPI_PU 0x10 /* punctuation */
232#define _ACPI_SP 0x08 /* space */ 151#define _ACPI_SP 0x08 /* space */
233#define _ACPI_UP 0x01 /* 'A'-'Z' */ 152#define _ACPI_UP 0x01 /* 'A'-'Z' */
234#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ 153#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
235 154
236#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) 155#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
237#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) 156#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
@@ -242,502 +161,323 @@ extern const u8 _acpi_ctype[];
242#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) 161#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
243#define ACPI_IS_ASCII(c) ((c) < 0x80) 162#define ACPI_IS_ASCII(c) ((c) < 0x80)
244 163
245#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 164#endif /* ACPI_USE_SYSTEM_CLIBRARY */
246
247 165
248/* 166/*
249 * utcopy - Object construction and conversion interfaces 167 * utcopy - Object construction and conversion interfaces
250 */ 168 */
251acpi_status 169acpi_status
252acpi_ut_build_simple_object( 170acpi_ut_build_simple_object(union acpi_operand_object *obj,
253 union acpi_operand_object *obj, 171 union acpi_object *user_obj,
254 union acpi_object *user_obj, 172 u8 * data_space, u32 * buffer_space_used);
255 u8 *data_space,
256 u32 *buffer_space_used);
257 173
258acpi_status 174acpi_status
259acpi_ut_build_package_object ( 175acpi_ut_build_package_object(union acpi_operand_object *obj,
260 union acpi_operand_object *obj, 176 u8 * buffer, u32 * space_used);
261 u8 *buffer,
262 u32 *space_used);
263 177
264acpi_status 178acpi_status
265acpi_ut_copy_iobject_to_eobject ( 179acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj,
266 union acpi_operand_object *obj, 180 struct acpi_buffer *ret_buffer);
267 struct acpi_buffer *ret_buffer);
268 181
269acpi_status 182acpi_status
270acpi_ut_copy_eobject_to_iobject ( 183acpi_ut_copy_eobject_to_iobject(union acpi_object *obj,
271 union acpi_object *obj, 184 union acpi_operand_object **internal_obj);
272 union acpi_operand_object **internal_obj);
273 185
274acpi_status 186acpi_status
275acpi_ut_copy_isimple_to_isimple ( 187acpi_ut_copy_isimple_to_isimple(union acpi_operand_object *source_obj,
276 union acpi_operand_object *source_obj, 188 union acpi_operand_object *dest_obj);
277 union acpi_operand_object *dest_obj);
278 189
279acpi_status 190acpi_status
280acpi_ut_copy_iobject_to_iobject ( 191acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
281 union acpi_operand_object *source_desc, 192 union acpi_operand_object **dest_desc,
282 union acpi_operand_object **dest_desc, 193 struct acpi_walk_state *walk_state);
283 struct acpi_walk_state *walk_state);
284
285 194
286/* 195/*
287 * utcreate - Object creation 196 * utcreate - Object creation
288 */ 197 */
289acpi_status 198acpi_status
290acpi_ut_update_object_reference ( 199acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action);
291 union acpi_operand_object *object,
292 u16 action);
293
294 200
295/* 201/*
296 * utdebug - Debug interfaces 202 * utdebug - Debug interfaces
297 */ 203 */
298void 204void acpi_ut_init_stack_ptr_trace(void);
299acpi_ut_init_stack_ptr_trace (
300 void);
301 205
302void 206void acpi_ut_track_stack_ptr(void);
303acpi_ut_track_stack_ptr (
304 void);
305 207
306void 208void
307acpi_ut_trace ( 209acpi_ut_trace(u32 line_number,
308 u32 line_number, 210 const char *function_name, char *module_name, u32 component_id);
309 struct acpi_debug_print_info *dbg_info);
310 211
311void 212void
312acpi_ut_trace_ptr ( 213acpi_ut_trace_ptr(u32 line_number,
313 u32 line_number, 214 const char *function_name,
314 struct acpi_debug_print_info *dbg_info, 215 char *module_name, u32 component_id, void *pointer);
315 void *pointer);
316 216
317void 217void
318acpi_ut_trace_u32 ( 218acpi_ut_trace_u32(u32 line_number,
319 u32 line_number, 219 const char *function_name,
320 struct acpi_debug_print_info *dbg_info, 220 char *module_name, u32 component_id, u32 integer);
321 u32 integer);
322 221
323void 222void
324acpi_ut_trace_str ( 223acpi_ut_trace_str(u32 line_number,
325 u32 line_number, 224 const char *function_name,
326 struct acpi_debug_print_info *dbg_info, 225 char *module_name, u32 component_id, char *string);
327 char *string);
328 226
329void 227void
330acpi_ut_exit ( 228acpi_ut_exit(u32 line_number,
331 u32 line_number, 229 const char *function_name, char *module_name, u32 component_id);
332 struct acpi_debug_print_info *dbg_info);
333 230
334void 231void
335acpi_ut_status_exit ( 232acpi_ut_status_exit(u32 line_number,
336 u32 line_number, 233 const char *function_name,
337 struct acpi_debug_print_info *dbg_info, 234 char *module_name, u32 component_id, acpi_status status);
338 acpi_status status);
339 235
340void 236void
341acpi_ut_value_exit ( 237acpi_ut_value_exit(u32 line_number,
342 u32 line_number, 238 const char *function_name,
343 struct acpi_debug_print_info *dbg_info, 239 char *module_name, u32 component_id, acpi_integer value);
344 acpi_integer value);
345 240
346void 241void
347acpi_ut_ptr_exit ( 242acpi_ut_ptr_exit(u32 line_number,
348 u32 line_number, 243 const char *function_name,
349 struct acpi_debug_print_info *dbg_info, 244 char *module_name, u32 component_id, u8 * ptr);
350 u8 *ptr);
351 245
352void 246void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id);
353acpi_ut_report_info (
354 char *module_name,
355 u32 line_number,
356 u32 component_id);
357 247
358void 248void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id);
359acpi_ut_report_error (
360 char *module_name,
361 u32 line_number,
362 u32 component_id);
363 249
364void 250void
365acpi_ut_report_warning ( 251acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id);
366 char *module_name,
367 u32 line_number,
368 u32 component_id);
369 252
370void 253void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
371acpi_ut_dump_buffer (
372 u8 *buffer,
373 u32 count,
374 u32 display,
375 u32 component_id);
376 254
377void ACPI_INTERNAL_VAR_XFACE 255void ACPI_INTERNAL_VAR_XFACE
378acpi_ut_debug_print ( 256acpi_ut_debug_print(u32 requested_debug_level,
379 u32 requested_debug_level, 257 u32 line_number,
380 u32 line_number, 258 const char *function_name,
381 struct acpi_debug_print_info *dbg_info, 259 char *module_name,
382 char *format, 260 u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC;
383 ...) ACPI_PRINTF_LIKE_FUNC;
384 261
385void ACPI_INTERNAL_VAR_XFACE 262void ACPI_INTERNAL_VAR_XFACE
386acpi_ut_debug_print_raw ( 263acpi_ut_debug_print_raw(u32 requested_debug_level,
387 u32 requested_debug_level, 264 u32 line_number,
388 u32 line_number, 265 const char *function_name,
389 struct acpi_debug_print_info *dbg_info, 266 char *module_name,
390 char *format, 267 u32 component_id,
391 ...) ACPI_PRINTF_LIKE_FUNC; 268 char *format, ...) ACPI_PRINTF_LIKE_FUNC;
392
393 269
394/* 270/*
395 * utdelete - Object deletion and reference counts 271 * utdelete - Object deletion and reference counts
396 */ 272 */
397void 273void acpi_ut_add_reference(union acpi_operand_object *object);
398acpi_ut_add_reference (
399 union acpi_operand_object *object);
400 274
401void 275void acpi_ut_remove_reference(union acpi_operand_object *object);
402acpi_ut_remove_reference (
403 union acpi_operand_object *object);
404 276
405void 277void acpi_ut_delete_internal_package_object(union acpi_operand_object *object);
406acpi_ut_delete_internal_package_object (
407 union acpi_operand_object *object);
408 278
409void 279void acpi_ut_delete_internal_simple_object(union acpi_operand_object *object);
410acpi_ut_delete_internal_simple_object (
411 union acpi_operand_object *object);
412
413void
414acpi_ut_delete_internal_object_list (
415 union acpi_operand_object **obj_list);
416 280
281void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list);
417 282
418/* 283/*
419 * uteval - object evaluation 284 * uteval - object evaluation
420 */ 285 */
421acpi_status 286acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
422acpi_ut_osi_implementation (
423 struct acpi_walk_state *walk_state);
424 287
425acpi_status 288acpi_status
426acpi_ut_evaluate_object ( 289acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
427 struct acpi_namespace_node *prefix_node, 290 char *path,
428 char *path, 291 u32 expected_return_btypes,
429 u32 expected_return_btypes, 292 union acpi_operand_object **return_desc);
430 union acpi_operand_object **return_desc);
431 293
432acpi_status 294acpi_status
433acpi_ut_evaluate_numeric_object ( 295acpi_ut_evaluate_numeric_object(char *object_name,
434 char *object_name, 296 struct acpi_namespace_node *device_node,
435 struct acpi_namespace_node *device_node, 297 acpi_integer * address);
436 acpi_integer *address);
437 298
438acpi_status 299acpi_status
439acpi_ut_execute_HID ( 300acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
440 struct acpi_namespace_node *device_node, 301 struct acpi_device_id *hid);
441 struct acpi_device_id *hid);
442 302
443acpi_status 303acpi_status
444acpi_ut_execute_CID ( 304acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
445 struct acpi_namespace_node *device_node, 305 struct acpi_compatible_id_list **return_cid_list);
446 struct acpi_compatible_id_list **return_cid_list);
447 306
448acpi_status 307acpi_status
449acpi_ut_execute_STA ( 308acpi_ut_execute_STA(struct acpi_namespace_node *device_node,
450 struct acpi_namespace_node *device_node, 309 u32 * status_flags);
451 u32 *status_flags);
452 310
453acpi_status 311acpi_status
454acpi_ut_execute_UID ( 312acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
455 struct acpi_namespace_node *device_node, 313 struct acpi_device_id *uid);
456 struct acpi_device_id *uid);
457 314
458acpi_status 315acpi_status
459acpi_ut_execute_sxds ( 316acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
460 struct acpi_namespace_node *device_node,
461 u8 *highest);
462
463 317
464/* 318/*
465 * utobject - internal object create/delete/cache routines 319 * utobject - internal object create/delete/cache routines
466 */ 320 */
467union acpi_operand_object * 321union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name,
468acpi_ut_create_internal_object_dbg ( 322 u32 line_number,
469 char *module_name, 323 u32 component_id,
470 u32 line_number, 324 acpi_object_type
471 u32 component_id, 325 type);
472 acpi_object_type type);
473
474void *
475acpi_ut_allocate_object_desc_dbg (
476 char *module_name,
477 u32 line_number,
478 u32 component_id);
479
480#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
481#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
482 326
483void 327void *acpi_ut_allocate_object_desc_dbg(char *module_name,
484acpi_ut_delete_object_desc ( 328 u32 line_number, u32 component_id);
485 union acpi_operand_object *object);
486 329
487u8 330#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t)
488acpi_ut_valid_internal_object ( 331#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT)
489 void *object);
490 332
491union acpi_operand_object * 333void acpi_ut_delete_object_desc(union acpi_operand_object *object);
492acpi_ut_create_buffer_object (
493 acpi_size buffer_size);
494 334
495union acpi_operand_object * 335u8 acpi_ut_valid_internal_object(void *object);
496acpi_ut_create_string_object (
497 acpi_size string_size);
498 336
499acpi_status 337union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
500acpi_ut_get_object_size(
501 union acpi_operand_object *obj,
502 acpi_size *obj_length);
503 338
339union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
340
341acpi_status
342acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length);
504 343
505/* 344/*
506 * utstate - Generic state creation/cache routines 345 * utstate - Generic state creation/cache routines
507 */ 346 */
508void 347void
509acpi_ut_push_generic_state ( 348acpi_ut_push_generic_state(union acpi_generic_state **list_head,
510 union acpi_generic_state **list_head, 349 union acpi_generic_state *state);
511 union acpi_generic_state *state);
512 350
513union acpi_generic_state * 351union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
514acpi_ut_pop_generic_state ( 352 **list_head);
515 union acpi_generic_state **list_head);
516 353
354union acpi_generic_state *acpi_ut_create_generic_state(void);
517 355
518union acpi_generic_state * 356struct acpi_thread_state *acpi_ut_create_thread_state(void);
519acpi_ut_create_generic_state (
520 void);
521 357
522struct acpi_thread_state * 358union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
523acpi_ut_create_thread_state ( 359 *object, u16 action);
524 void);
525 360
526union acpi_generic_state * 361union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
527acpi_ut_create_update_state ( 362 void *external_object,
528 union acpi_operand_object *object, 363 u16 index);
529 u16 action);
530
531union acpi_generic_state *
532acpi_ut_create_pkg_state (
533 void *internal_object,
534 void *external_object,
535 u16 index);
536 364
537acpi_status 365acpi_status
538acpi_ut_create_update_state_and_push ( 366acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
539 union acpi_operand_object *object, 367 u16 action,
540 u16 action, 368 union acpi_generic_state **state_list);
541 union acpi_generic_state **state_list);
542 369
543#ifdef ACPI_FUTURE_USAGE 370#ifdef ACPI_FUTURE_USAGE
544acpi_status 371acpi_status
545acpi_ut_create_pkg_state_and_push ( 372acpi_ut_create_pkg_state_and_push(void *internal_object,
546 void *internal_object, 373 void *external_object,
547 void *external_object, 374 u16 index,
548 u16 index, 375 union acpi_generic_state **state_list);
549 union acpi_generic_state **state_list); 376#endif /* ACPI_FUTURE_USAGE */
550#endif /* ACPI_FUTURE_USAGE */
551 377
552union acpi_generic_state * 378union acpi_generic_state *acpi_ut_create_control_state(void);
553acpi_ut_create_control_state (
554 void);
555
556void
557acpi_ut_delete_generic_state (
558 union acpi_generic_state *state);
559
560#ifdef ACPI_ENABLE_OBJECT_CACHE
561void
562acpi_ut_delete_generic_state_cache (
563 void);
564
565void
566acpi_ut_delete_object_cache (
567 void);
568#endif
569 379
380void acpi_ut_delete_generic_state(union acpi_generic_state *state);
570 381
571/* 382/*
572 * utmath 383 * utmath
573 */ 384 */
574acpi_status 385acpi_status
575acpi_ut_divide ( 386acpi_ut_divide(acpi_integer in_dividend,
576 acpi_integer in_dividend, 387 acpi_integer in_divisor,
577 acpi_integer in_divisor, 388 acpi_integer * out_quotient, acpi_integer * out_remainder);
578 acpi_integer *out_quotient,
579 acpi_integer *out_remainder);
580 389
581acpi_status 390acpi_status
582acpi_ut_short_divide ( 391acpi_ut_short_divide(acpi_integer in_dividend,
583 acpi_integer in_dividend, 392 u32 divisor,
584 u32 divisor, 393 acpi_integer * out_quotient, u32 * out_remainder);
585 acpi_integer *out_quotient,
586 u32 *out_remainder);
587 394
588/* 395/*
589 * utmisc 396 * utmisc
590 */ 397 */
398acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
399
400void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
401
591acpi_status 402acpi_status
592acpi_ut_walk_package_tree ( 403acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
593 union acpi_operand_object *source_object, 404 void *target_object,
594 void *target_object, 405 acpi_pkg_callback walk_callback, void *context);
595 acpi_pkg_callback walk_callback,
596 void *context);
597 406
598char * 407void acpi_ut_strupr(char *src_string);
599acpi_ut_strupr (
600 char *src_string);
601 408
602void 409void acpi_ut_print_string(char *string, u8 max_length);
603acpi_ut_print_string (
604 char *string,
605 u8 max_length);
606 410
607u8 411u8 acpi_ut_valid_acpi_name(u32 name);
608acpi_ut_valid_acpi_name (
609 u32 name);
610 412
611u8 413u8 acpi_ut_valid_acpi_character(char character);
612acpi_ut_valid_acpi_character (
613 char character);
614 414
615acpi_status 415acpi_status
616acpi_ut_strtoul64 ( 416acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
617 char *string,
618 u32 base,
619 acpi_integer *ret_integer);
620 417
621/* Values for Base above (16=Hex, 10=Decimal) */ 418/* Values for Base above (16=Hex, 10=Decimal) */
622 419
623#define ACPI_ANY_BASE 0 420#define ACPI_ANY_BASE 0
624 421
625acpi_status 422u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc);
626acpi_ut_mutex_initialize (
627 void);
628
629void
630acpi_ut_mutex_terminate (
631 void);
632
633acpi_status
634acpi_ut_acquire_mutex (
635 acpi_mutex_handle mutex_id);
636
637acpi_status
638acpi_ut_release_mutex (
639 acpi_mutex_handle mutex_id);
640
641u8 *
642acpi_ut_get_resource_end_tag (
643 union acpi_operand_object *obj_desc);
644 423
645u8 424u8 acpi_ut_generate_checksum(u8 * buffer, u32 length);
646acpi_ut_generate_checksum (
647 u8 *buffer,
648 u32 length);
649 425
650u32 426u32 acpi_ut_dword_byte_swap(u32 value);
651acpi_ut_dword_byte_swap (
652 u32 value);
653 427
654void 428void acpi_ut_set_integer_width(u8 revision);
655acpi_ut_set_integer_width (
656 u8 revision);
657 429
658#ifdef ACPI_DEBUG_OUTPUT 430#ifdef ACPI_DEBUG_OUTPUT
659void 431void
660acpi_ut_display_init_pathname ( 432acpi_ut_display_init_pathname(u8 type,
661 u8 type, 433 struct acpi_namespace_node *obj_handle,
662 struct acpi_namespace_node *obj_handle, 434 char *path);
663 char *path);
664 435
665#endif 436#endif
666 437
438/*
439 * utmutex - mutex support
440 */
441acpi_status acpi_ut_mutex_initialize(void);
442
443void acpi_ut_mutex_terminate(void);
444
445acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id);
446
447acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id);
667 448
668/* 449/*
669 * utalloc - memory allocation and object caching 450 * utalloc - memory allocation and object caching
670 */ 451 */
671void * 452acpi_status acpi_ut_create_caches(void);
672acpi_ut_acquire_from_cache (
673 u32 list_id);
674 453
675void 454acpi_status acpi_ut_delete_caches(void);
676acpi_ut_release_to_cache (
677 u32 list_id,
678 void *object);
679 455
680#ifdef ACPI_ENABLE_OBJECT_CACHE 456acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer);
681void
682acpi_ut_delete_generic_cache (
683 u32 list_id);
684#endif
685 457
686acpi_status 458acpi_status
687acpi_ut_validate_buffer ( 459acpi_ut_initialize_buffer(struct acpi_buffer *buffer,
688 struct acpi_buffer *buffer); 460 acpi_size required_length);
689 461
690acpi_status 462void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line);
691acpi_ut_initialize_buffer ( 463
692 struct acpi_buffer *buffer, 464void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line);
693 acpi_size required_length);
694
695void *
696acpi_ut_allocate (
697 acpi_size size,
698 u32 component,
699 char *module,
700 u32 line);
701
702void *
703acpi_ut_callocate (
704 acpi_size size,
705 u32 component,
706 char *module,
707 u32 line);
708 465
709#ifdef ACPI_DBG_TRACK_ALLOCATIONS 466#ifdef ACPI_DBG_TRACK_ALLOCATIONS
710void * 467void *acpi_ut_allocate_and_track(acpi_size size,
711acpi_ut_allocate_and_track ( 468 u32 component, char *module, u32 line);
712 acpi_size size, 469
713 u32 component, 470void *acpi_ut_callocate_and_track(acpi_size size,
714 char *module, 471 u32 component, char *module, u32 line);
715 u32 line);
716
717void *
718acpi_ut_callocate_and_track (
719 acpi_size size,
720 u32 component,
721 char *module,
722 u32 line);
723 472
724void 473void
725acpi_ut_free_and_track ( 474acpi_ut_free_and_track(void *address, u32 component, char *module, u32 line);
726 void *address,
727 u32 component,
728 char *module,
729 u32 line);
730 475
731#ifdef ACPI_FUTURE_USAGE 476#ifdef ACPI_FUTURE_USAGE
732void 477void acpi_ut_dump_allocation_info(void);
733acpi_ut_dump_allocation_info ( 478#endif /* ACPI_FUTURE_USAGE */
734 void);
735#endif /* ACPI_FUTURE_USAGE */
736 479
737void 480void acpi_ut_dump_allocations(u32 component, char *module);
738acpi_ut_dump_allocations (
739 u32 component,
740 char *module);
741#endif 481#endif
742 482
743#endif /* _ACUTILS_H */ 483#endif /* _ACUTILS_H */
diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h
index 55e97ed29190..7fdf5299f501 100644
--- a/include/acpi/amlcode.h
+++ b/include/acpi/amlcode.h
@@ -59,17 +59,17 @@
59#define AML_WORD_OP (u16) 0x0b 59#define AML_WORD_OP (u16) 0x0b
60#define AML_DWORD_OP (u16) 0x0c 60#define AML_DWORD_OP (u16) 0x0c
61#define AML_STRING_OP (u16) 0x0d 61#define AML_STRING_OP (u16) 0x0d
62#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */ 62#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */
63#define AML_SCOPE_OP (u16) 0x10 63#define AML_SCOPE_OP (u16) 0x10
64#define AML_BUFFER_OP (u16) 0x11 64#define AML_BUFFER_OP (u16) 0x11
65#define AML_PACKAGE_OP (u16) 0x12 65#define AML_PACKAGE_OP (u16) 0x12
66#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */ 66#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */
67#define AML_METHOD_OP (u16) 0x14 67#define AML_METHOD_OP (u16) 0x14
68#define AML_DUAL_NAME_PREFIX (u16) 0x2e 68#define AML_DUAL_NAME_PREFIX (u16) 0x2e
69#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f 69#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f
70#define AML_NAME_CHAR_SUBSEQ (u16) 0x30 70#define AML_NAME_CHAR_SUBSEQ (u16) 0x30
71#define AML_NAME_CHAR_FIRST (u16) 0x41 71#define AML_NAME_CHAR_FIRST (u16) 0x41
72#define AML_OP_PREFIX (u16) 0x5b 72#define AML_EXTENDED_OP_PREFIX (u16) 0x5b
73#define AML_ROOT_PREFIX (u16) 0x5c 73#define AML_ROOT_PREFIX (u16) 0x5c
74#define AML_PARENT_PREFIX (u16) 0x5e 74#define AML_PARENT_PREFIX (u16) 0x5e
75#define AML_LOCAL_OP (u16) 0x60 75#define AML_LOCAL_OP (u16) 0x60
@@ -109,8 +109,8 @@
109#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81 109#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81
110#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82 110#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82
111#define AML_DEREF_OF_OP (u16) 0x83 111#define AML_DEREF_OF_OP (u16) 0x83
112#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */ 112#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */
113#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */ 113#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */
114#define AML_NOTIFY_OP (u16) 0x86 114#define AML_NOTIFY_OP (u16) 0x86
115#define AML_SIZE_OF_OP (u16) 0x87 115#define AML_SIZE_OF_OP (u16) 0x87
116#define AML_INDEX_OP (u16) 0x88 116#define AML_INDEX_OP (u16) 0x88
@@ -120,21 +120,21 @@
120#define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c 120#define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c
121#define AML_CREATE_BIT_FIELD_OP (u16) 0x8d 121#define AML_CREATE_BIT_FIELD_OP (u16) 0x8d
122#define AML_TYPE_OP (u16) 0x8e 122#define AML_TYPE_OP (u16) 0x8e
123#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */ 123#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */
124#define AML_LAND_OP (u16) 0x90 124#define AML_LAND_OP (u16) 0x90
125#define AML_LOR_OP (u16) 0x91 125#define AML_LOR_OP (u16) 0x91
126#define AML_LNOT_OP (u16) 0x92 126#define AML_LNOT_OP (u16) 0x92
127#define AML_LEQUAL_OP (u16) 0x93 127#define AML_LEQUAL_OP (u16) 0x93
128#define AML_LGREATER_OP (u16) 0x94 128#define AML_LGREATER_OP (u16) 0x94
129#define AML_LLESS_OP (u16) 0x95 129#define AML_LLESS_OP (u16) 0x95
130#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */ 130#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */
131#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */ 131#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */
132#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */ 132#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */
133#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */ 133#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */
134#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */ 134#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */
135#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */ 135#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */
136#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */ 136#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */
137#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */ 137#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */
138#define AML_IF_OP (u16) 0xa0 138#define AML_IF_OP (u16) 0xa0
139#define AML_ELSE_OP (u16) 0xa1 139#define AML_ELSE_OP (u16) 0xa1
140#define AML_WHILE_OP (u16) 0xa2 140#define AML_WHILE_OP (u16) 0xa2
@@ -146,7 +146,7 @@
146 146
147/* prefixed opcodes */ 147/* prefixed opcodes */
148 148
149#define AML_EXTOP (u16) 0x005b /* prefix for 2-byte opcodes */ 149#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */
150 150
151#define AML_MUTEX_OP (u16) 0x5b01 151#define AML_MUTEX_OP (u16) 0x5b01
152#define AML_EVENT_OP (u16) 0x5b02 152#define AML_EVENT_OP (u16) 0x5b02
@@ -154,7 +154,7 @@
154#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11 154#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11
155#define AML_COND_REF_OF_OP (u16) 0x5b12 155#define AML_COND_REF_OF_OP (u16) 0x5b12
156#define AML_CREATE_FIELD_OP (u16) 0x5b13 156#define AML_CREATE_FIELD_OP (u16) 0x5b13
157#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */ 157#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */
158#define AML_LOAD_OP (u16) 0x5b20 158#define AML_LOAD_OP (u16) 0x5b20
159#define AML_STALL_OP (u16) 0x5b21 159#define AML_STALL_OP (u16) 0x5b21
160#define AML_SLEEP_OP (u16) 0x5b22 160#define AML_SLEEP_OP (u16) 0x5b22
@@ -169,7 +169,7 @@
169#define AML_REVISION_OP (u16) 0x5b30 169#define AML_REVISION_OP (u16) 0x5b30
170#define AML_DEBUG_OP (u16) 0x5b31 170#define AML_DEBUG_OP (u16) 0x5b31
171#define AML_FATAL_OP (u16) 0x5b32 171#define AML_FATAL_OP (u16) 0x5b32
172#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */ 172#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */
173#define AML_REGION_OP (u16) 0x5b80 173#define AML_REGION_OP (u16) 0x5b80
174#define AML_FIELD_OP (u16) 0x5b81 174#define AML_FIELD_OP (u16) 0x5b81
175#define AML_DEVICE_OP (u16) 0x5b82 175#define AML_DEVICE_OP (u16) 0x5b82
@@ -178,8 +178,7 @@
178#define AML_THERMAL_ZONE_OP (u16) 0x5b85 178#define AML_THERMAL_ZONE_OP (u16) 0x5b85
179#define AML_INDEX_FIELD_OP (u16) 0x5b86 179#define AML_INDEX_FIELD_OP (u16) 0x5b86
180#define AML_BANK_FIELD_OP (u16) 0x5b87 180#define AML_BANK_FIELD_OP (u16) 0x5b87
181#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */ 181#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */
182
183 182
184/* Bogus opcodes (they are actually two separate opcodes) */ 183/* Bogus opcodes (they are actually two separate opcodes) */
185 184
@@ -187,7 +186,6 @@
187#define AML_LLESSEQUAL_OP (u16) 0x9294 186#define AML_LLESSEQUAL_OP (u16) 0x9294
188#define AML_LNOTEQUAL_OP (u16) 0x9293 187#define AML_LNOTEQUAL_OP (u16) 0x9293
189 188
190
191/* 189/*
192 * Internal opcodes 190 * Internal opcodes
193 * Use only "Unknown" AML opcodes, don't attempt to use 191 * Use only "Unknown" AML opcodes, don't attempt to use
@@ -203,7 +201,6 @@
203#define AML_INT_RETURN_VALUE_OP (u16) 0x0036 201#define AML_INT_RETURN_VALUE_OP (u16) 0x0036
204#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037 202#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037
205 203
206
207#define ARG_NONE 0x0 204#define ARG_NONE 0x0
208 205
209/* 206/*
@@ -245,7 +242,7 @@
245 242
246/* Single, simple types */ 243/* Single, simple types */
247 244
248#define ARGI_ANYTYPE 0x01 /* Don't care */ 245#define ARGI_ANYTYPE 0x01 /* Don't care */
249#define ARGI_PACKAGE 0x02 246#define ARGI_PACKAGE 0x02
250#define ARGI_EVENT 0x03 247#define ARGI_EVENT 0x03
251#define ARGI_MUTEX 0x04 248#define ARGI_MUTEX 0x04
@@ -256,8 +253,8 @@
256#define ARGI_INTEGER 0x06 253#define ARGI_INTEGER 0x06
257#define ARGI_STRING 0x07 254#define ARGI_STRING 0x07
258#define ARGI_BUFFER 0x08 255#define ARGI_BUFFER 0x08
259#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ 256#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */
260#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ 257#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */
261 258
262/* Reference objects */ 259/* Reference objects */
263 260
@@ -265,30 +262,28 @@
265#define ARGI_OBJECT_REF 0x0C 262#define ARGI_OBJECT_REF 0x0C
266#define ARGI_DEVICE_REF 0x0D 263#define ARGI_DEVICE_REF 0x0D
267#define ARGI_REFERENCE 0x0E 264#define ARGI_REFERENCE 0x0E
268#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ 265#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */
269#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ 266#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */
270#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ 267#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */
271 268
272/* Multiple/complex types */ 269/* Multiple/complex types */
273 270
274#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator*/ 271#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator */
275#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ 272#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */
276#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ 273#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */
277#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ 274#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */
278#define ARGI_DATAREFOBJ 0x16 275#define ARGI_DATAREFOBJ 0x16
279 276
280/* Note: types above can expand to 0x1F maximum */ 277/* Note: types above can expand to 0x1F maximum */
281 278
282#define ARGI_INVALID_OPCODE 0xFFFFFFFF 279#define ARGI_INVALID_OPCODE 0xFFFFFFFF
283 280
284
285/* 281/*
286 * hash offsets 282 * hash offsets
287 */ 283 */
288#define AML_EXTOP_HASH_OFFSET 22 284#define AML_EXTOP_HASH_OFFSET 22
289#define AML_LNOT_HASH_OFFSET 19 285#define AML_LNOT_HASH_OFFSET 19
290 286
291
292/* 287/*
293 * opcode groups and types 288 * opcode groups and types
294 */ 289 */
@@ -296,7 +291,6 @@
296#define OPGRP_FIELD 0x02 291#define OPGRP_FIELD 0x02
297#define OPGRP_BYTELIST 0x04 292#define OPGRP_BYTELIST 0x04
298 293
299
300/* 294/*
301 * Opcode information 295 * Opcode information
302 */ 296 */
@@ -322,31 +316,30 @@
322/* Convenient flag groupings */ 316/* Convenient flag groupings */
323 317
324#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL 318#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL
325#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ 319#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */
326#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ 320#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */
327#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET 321#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET
328#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */ 322#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */
329#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ 323#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */
330#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ 324#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */
331#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */ 325#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */
332#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL 326#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
333#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS 327#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS
334#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL 328#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
335#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL 329#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL
336 330
337
338/* 331/*
339 * The opcode Type is used in a dispatch table, do not change 332 * The opcode Type is used in a dispatch table, do not change
340 * without updating the table. 333 * without updating the table.
341 */ 334 */
342#define AML_TYPE_EXEC_0A_0T_1R 0x00 335#define AML_TYPE_EXEC_0A_0T_1R 0x00
343#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ 336#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */
344#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ 337#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */
345#define AML_TYPE_EXEC_1A_1T_0R 0x03 338#define AML_TYPE_EXEC_1A_1T_0R 0x03
346#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */ 339#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */
347#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ 340#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */
348#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ 341#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */
349#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */ 342#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */
350#define AML_TYPE_EXEC_2A_2T_1R 0x08 343#define AML_TYPE_EXEC_2A_2T_1R 0x08
351#define AML_TYPE_EXEC_3A_0T_0R 0x09 344#define AML_TYPE_EXEC_3A_0T_0R 0x09
352#define AML_TYPE_EXEC_3A_1T_1R 0x0A 345#define AML_TYPE_EXEC_3A_1T_1R 0x0A
@@ -399,40 +392,33 @@
399#define AML_CLASS_METHOD_CALL 0x09 392#define AML_CLASS_METHOD_CALL 0x09
400#define AML_CLASS_UNKNOWN 0x0A 393#define AML_CLASS_UNKNOWN 0x0A
401 394
402
403/* Predefined Operation Region space_iDs */ 395/* Predefined Operation Region space_iDs */
404 396
405typedef enum 397typedef enum {
406{ 398 REGION_MEMORY = 0,
407 REGION_MEMORY = 0,
408 REGION_IO, 399 REGION_IO,
409 REGION_PCI_CONFIG, 400 REGION_PCI_CONFIG,
410 REGION_EC, 401 REGION_EC,
411 REGION_SMBUS, 402 REGION_SMBUS,
412 REGION_CMOS, 403 REGION_CMOS,
413 REGION_PCI_BAR, 404 REGION_PCI_BAR,
414 REGION_DATA_TABLE, /* Internal use only */ 405 REGION_DATA_TABLE, /* Internal use only */
415 REGION_FIXED_HW = 0x7F 406 REGION_FIXED_HW = 0x7F
416
417} AML_REGION_TYPES; 407} AML_REGION_TYPES;
418 408
419
420/* Comparison operation codes for match_op operator */ 409/* Comparison operation codes for match_op operator */
421 410
422typedef enum 411typedef enum {
423{ 412 MATCH_MTR = 0,
424 MATCH_MTR = 0, 413 MATCH_MEQ = 1,
425 MATCH_MEQ = 1, 414 MATCH_MLE = 2,
426 MATCH_MLE = 2, 415 MATCH_MLT = 3,
427 MATCH_MLT = 3, 416 MATCH_MGE = 4,
428 MATCH_MGE = 4, 417 MATCH_MGT = 5
429 MATCH_MGT = 5
430
431} AML_MATCH_OPERATOR; 418} AML_MATCH_OPERATOR;
432 419
433#define MAX_MATCH_OPERATOR 5 420#define MAX_MATCH_OPERATOR 5
434 421
435
436/* 422/*
437 * field_flags 423 * field_flags
438 * 424 *
@@ -450,60 +436,47 @@ typedef enum
450#define AML_FIELD_LOCK_RULE_MASK 0x10 436#define AML_FIELD_LOCK_RULE_MASK 0x10
451#define AML_FIELD_UPDATE_RULE_MASK 0x60 437#define AML_FIELD_UPDATE_RULE_MASK 0x60
452 438
453
454/* 1) Field Access Types */ 439/* 1) Field Access Types */
455 440
456typedef enum 441typedef enum {
457{ 442 AML_FIELD_ACCESS_ANY = 0x00,
458 AML_FIELD_ACCESS_ANY = 0x00, 443 AML_FIELD_ACCESS_BYTE = 0x01,
459 AML_FIELD_ACCESS_BYTE = 0x01, 444 AML_FIELD_ACCESS_WORD = 0x02,
460 AML_FIELD_ACCESS_WORD = 0x02, 445 AML_FIELD_ACCESS_DWORD = 0x03,
461 AML_FIELD_ACCESS_DWORD = 0x03, 446 AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */
462 AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ 447 AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */
463 AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */
464
465} AML_ACCESS_TYPE; 448} AML_ACCESS_TYPE;
466 449
467
468/* 2) Field Lock Rules */ 450/* 2) Field Lock Rules */
469 451
470typedef enum 452typedef enum {
471{ 453 AML_FIELD_LOCK_NEVER = 0x00,
472 AML_FIELD_LOCK_NEVER = 0x00, 454 AML_FIELD_LOCK_ALWAYS = 0x10
473 AML_FIELD_LOCK_ALWAYS = 0x10
474
475} AML_LOCK_RULE; 455} AML_LOCK_RULE;
476 456
477
478/* 3) Field Update Rules */ 457/* 3) Field Update Rules */
479 458
480typedef enum 459typedef enum {
481{ 460 AML_FIELD_UPDATE_PRESERVE = 0x00,
482 AML_FIELD_UPDATE_PRESERVE = 0x00, 461 AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20,
483 AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20,
484 AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 462 AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
485
486} AML_UPDATE_RULE; 463} AML_UPDATE_RULE;
487 464
488
489/* 465/*
490 * Field Access Attributes. 466 * Field Access Attributes.
491 * This byte is extracted from the AML via the 467 * This byte is extracted from the AML via the
492 * access_as keyword 468 * access_as keyword
493 */ 469 */
494typedef enum 470typedef enum {
495{ 471 AML_FIELD_ATTRIB_SMB_QUICK = 0x02,
496 AML_FIELD_ATTRIB_SMB_QUICK = 0x02, 472 AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04,
497 AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, 473 AML_FIELD_ATTRIB_SMB_BYTE = 0x06,
498 AML_FIELD_ATTRIB_SMB_BYTE = 0x06, 474 AML_FIELD_ATTRIB_SMB_WORD = 0x08,
499 AML_FIELD_ATTRIB_SMB_WORD = 0x08, 475 AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A,
500 AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, 476 AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C,
501 AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C,
502 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D 477 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
503
504} AML_ACCESS_ATTRIBUTE; 478} AML_ACCESS_ATTRIBUTE;
505 479
506
507/* Bit fields in method_flags byte */ 480/* Bit fields in method_flags byte */
508 481
509#define AML_METHOD_ARG_COUNT 0x07 482#define AML_METHOD_ARG_COUNT 0x07
@@ -516,5 +489,4 @@ typedef enum
516#define AML_METHOD_RESERVED1 0x02 489#define AML_METHOD_RESERVED1 0x02
517#define AML_METHOD_RESERVED2 0x04 490#define AML_METHOD_RESERVED2 0x04
518 491
519 492#endif /* __AMLCODE_H__ */
520#endif /* __AMLCODE_H__ */
diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h
index b20ec303df07..051786e4b210 100644
--- a/include/acpi/amlresrc.h
+++ b/include/acpi/amlresrc.h
@@ -42,29 +42,27 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#ifndef __AMLRESRC_H 45#ifndef __AMLRESRC_H
47#define __AMLRESRC_H 46#define __AMLRESRC_H
48 47
49
50#define ASL_RESNAME_ADDRESS "_ADR" 48#define ASL_RESNAME_ADDRESS "_ADR"
51#define ASL_RESNAME_ALIGNMENT "_ALN" 49#define ASL_RESNAME_ALIGNMENT "_ALN"
52#define ASL_RESNAME_ADDRESSSPACE "_ASI" 50#define ASL_RESNAME_ADDRESSSPACE "_ASI"
53#define ASL_RESNAME_ACCESSSIZE "_ASZ" 51#define ASL_RESNAME_ACCESSSIZE "_ASZ"
54#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" 52#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT"
55#define ASL_RESNAME_BASEADDRESS "_BAS" 53#define ASL_RESNAME_BASEADDRESS "_BAS"
56#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ 54#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */
57#define ASL_RESNAME_DECODE "_DEC" 55#define ASL_RESNAME_DECODE "_DEC"
58#define ASL_RESNAME_DMA "_DMA" 56#define ASL_RESNAME_DMA "_DMA"
59#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ 57#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
60#define ASL_RESNAME_GRANULARITY "_GRA" 58#define ASL_RESNAME_GRANULARITY "_GRA"
61#define ASL_RESNAME_INTERRUPT "_INT" 59#define ASL_RESNAME_INTERRUPT "_INT"
62#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ 60#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
63#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ 61#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
64#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ 62#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
65#define ASL_RESNAME_LENGTH "_LEN" 63#define ASL_RESNAME_LENGTH "_LEN"
66#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ 64#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
67#define ASL_RESNAME_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ 65#define ASL_RESNAME_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
68#define ASL_RESNAME_MAXADDR "_MAX" 66#define ASL_RESNAME_MAXADDR "_MAX"
69#define ASL_RESNAME_MINADDR "_MIN" 67#define ASL_RESNAME_MINADDR "_MIN"
70#define ASL_RESNAME_MAXTYPE "_MAF" 68#define ASL_RESNAME_MAXTYPE "_MAF"
@@ -72,12 +70,11 @@
72#define ASL_RESNAME_REGISTERBITOFFSET "_RBO" 70#define ASL_RESNAME_REGISTERBITOFFSET "_RBO"
73#define ASL_RESNAME_REGISTERBITWIDTH "_RBW" 71#define ASL_RESNAME_REGISTERBITWIDTH "_RBW"
74#define ASL_RESNAME_RANGETYPE "_RNG" 72#define ASL_RESNAME_RANGETYPE "_RNG"
75#define ASL_RESNAME_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ 73#define ASL_RESNAME_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
76#define ASL_RESNAME_TRANSLATION "_TRA" 74#define ASL_RESNAME_TRANSLATION "_TRA"
77#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ 75#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
78#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */ 76#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */
79#define ASL_RESNAME_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */ 77#define ASL_RESNAME_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */
80
81 78
82/* Default sizes for "small" resource descriptors */ 79/* Default sizes for "small" resource descriptors */
83 80
@@ -89,15 +86,12 @@
89#define ASL_RDESC_FIXED_IO_SIZE 0x03 86#define ASL_RDESC_FIXED_IO_SIZE 0x03
90#define ASL_RDESC_END_TAG_SIZE 0x01 87#define ASL_RDESC_END_TAG_SIZE 0x01
91 88
92 89struct asl_resource_node {
93struct asl_resource_node 90 u32 buffer_length;
94{ 91 void *buffer;
95 u32 buffer_length; 92 struct asl_resource_node *next;
96 void *buffer;
97 struct asl_resource_node *next;
98}; 93};
99 94
100
101/* 95/*
102 * Resource descriptors defined in the ACPI specification. 96 * Resource descriptors defined in the ACPI specification.
103 * 97 *
@@ -106,214 +100,175 @@ struct asl_resource_node
106 */ 100 */
107#pragma pack(1) 101#pragma pack(1)
108 102
109struct asl_irq_format_desc 103struct asl_irq_format_desc {
110{ 104 u8 descriptor_type;
111 u8 descriptor_type; 105 u16 irq_mask;
112 u16 irq_mask; 106 u8 flags;
113 u8 flags;
114}; 107};
115 108
116 109struct asl_irq_noflags_desc {
117struct asl_irq_noflags_desc 110 u8 descriptor_type;
118{ 111 u16 irq_mask;
119 u8 descriptor_type;
120 u16 irq_mask;
121}; 112};
122 113
123 114struct asl_dma_format_desc {
124struct asl_dma_format_desc 115 u8 descriptor_type;
125{ 116 u8 dma_channel_mask;
126 u8 descriptor_type; 117 u8 flags;
127 u8 dma_channel_mask;
128 u8 flags;
129}; 118};
130 119
131 120struct asl_start_dependent_desc {
132struct asl_start_dependent_desc 121 u8 descriptor_type;
133{ 122 u8 flags;
134 u8 descriptor_type;
135 u8 flags;
136}; 123};
137 124
138 125struct asl_start_dependent_noprio_desc {
139struct asl_start_dependent_noprio_desc 126 u8 descriptor_type;
140{
141 u8 descriptor_type;
142}; 127};
143 128
144 129struct asl_end_dependent_desc {
145struct asl_end_dependent_desc 130 u8 descriptor_type;
146{
147 u8 descriptor_type;
148}; 131};
149 132
150 133struct asl_io_port_desc {
151struct asl_io_port_desc 134 u8 descriptor_type;
152{ 135 u8 information;
153 u8 descriptor_type; 136 u16 address_min;
154 u8 information; 137 u16 address_max;
155 u16 address_min; 138 u8 alignment;
156 u16 address_max; 139 u8 length;
157 u8 alignment;
158 u8 length;
159}; 140};
160 141
161 142struct asl_fixed_io_port_desc {
162struct asl_fixed_io_port_desc 143 u8 descriptor_type;
163{ 144 u16 base_address;
164 u8 descriptor_type; 145 u8 length;
165 u16 base_address;
166 u8 length;
167}; 146};
168 147
169 148struct asl_small_vendor_desc {
170struct asl_small_vendor_desc 149 u8 descriptor_type;
171{ 150 u8 vendor_defined[7];
172 u8 descriptor_type;
173 u8 vendor_defined[7];
174}; 151};
175 152
176 153struct asl_end_tag_desc {
177struct asl_end_tag_desc 154 u8 descriptor_type;
178{ 155 u8 checksum;
179 u8 descriptor_type;
180 u8 checksum;
181}; 156};
182 157
183
184/* LARGE descriptors */ 158/* LARGE descriptors */
185 159
186struct asl_memory_24_desc 160struct asl_memory_24_desc {
187{ 161 u8 descriptor_type;
188 u8 descriptor_type; 162 u16 length;
189 u16 length; 163 u8 information;
190 u8 information; 164 u16 address_min;
191 u16 address_min; 165 u16 address_max;
192 u16 address_max; 166 u16 alignment;
193 u16 alignment; 167 u16 range_length;
194 u16 range_length;
195}; 168};
196 169
197 170struct asl_large_vendor_desc {
198struct asl_large_vendor_desc 171 u8 descriptor_type;
199{ 172 u16 length;
200 u8 descriptor_type; 173 u8 vendor_defined[1];
201 u16 length;
202 u8 vendor_defined[1];
203}; 174};
204 175
205 176struct asl_memory_32_desc {
206struct asl_memory_32_desc 177 u8 descriptor_type;
207{ 178 u16 length;
208 u8 descriptor_type; 179 u8 information;
209 u16 length; 180 u32 address_min;
210 u8 information; 181 u32 address_max;
211 u32 address_min; 182 u32 alignment;
212 u32 address_max; 183 u32 range_length;
213 u32 alignment;
214 u32 range_length;
215}; 184};
216 185
217 186struct asl_fixed_memory_32_desc {
218struct asl_fixed_memory_32_desc 187 u8 descriptor_type;
219{ 188 u16 length;
220 u8 descriptor_type; 189 u8 information;
221 u16 length; 190 u32 base_address;
222 u8 information; 191 u32 range_length;
223 u32 base_address;
224 u32 range_length;
225}; 192};
226 193
227 194struct asl_extended_address_desc {
228struct asl_extended_address_desc 195 u8 descriptor_type;
229{ 196 u16 length;
230 u8 descriptor_type; 197 u8 resource_type;
231 u16 length; 198 u8 flags;
232 u8 resource_type; 199 u8 specific_flags;
233 u8 flags; 200 u8 revision_iD;
234 u8 specific_flags; 201 u8 reserved;
235 u8 revision_iD; 202 u64 granularity;
236 u8 reserved; 203 u64 address_min;
237 u64 granularity; 204 u64 address_max;
238 u64 address_min; 205 u64 translation_offset;
239 u64 address_max; 206 u64 address_length;
240 u64 translation_offset; 207 u64 type_specific_attributes;
241 u64 address_length; 208 u8 optional_fields[2]; /* Used for length calculation only */
242 u64 type_specific_attributes;
243 u8 optional_fields[2]; /* Used for length calculation only */
244}; 209};
245 210
246#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ 211#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */
247 212
248 213struct asl_qword_address_desc {
249struct asl_qword_address_desc 214 u8 descriptor_type;
250{ 215 u16 length;
251 u8 descriptor_type; 216 u8 resource_type;
252 u16 length; 217 u8 flags;
253 u8 resource_type; 218 u8 specific_flags;
254 u8 flags; 219 u64 granularity;
255 u8 specific_flags; 220 u64 address_min;
256 u64 granularity; 221 u64 address_max;
257 u64 address_min; 222 u64 translation_offset;
258 u64 address_max; 223 u64 address_length;
259 u64 translation_offset; 224 u8 optional_fields[2];
260 u64 address_length;
261 u8 optional_fields[2];
262}; 225};
263 226
264 227struct asl_dword_address_desc {
265struct asl_dword_address_desc 228 u8 descriptor_type;
266{ 229 u16 length;
267 u8 descriptor_type; 230 u8 resource_type;
268 u16 length; 231 u8 flags;
269 u8 resource_type; 232 u8 specific_flags;
270 u8 flags; 233 u32 granularity;
271 u8 specific_flags; 234 u32 address_min;
272 u32 granularity; 235 u32 address_max;
273 u32 address_min; 236 u32 translation_offset;
274 u32 address_max; 237 u32 address_length;
275 u32 translation_offset; 238 u8 optional_fields[2];
276 u32 address_length;
277 u8 optional_fields[2];
278}; 239};
279 240
280 241struct asl_word_address_desc {
281struct asl_word_address_desc 242 u8 descriptor_type;
282{ 243 u16 length;
283 u8 descriptor_type; 244 u8 resource_type;
284 u16 length; 245 u8 flags;
285 u8 resource_type; 246 u8 specific_flags;
286 u8 flags; 247 u16 granularity;
287 u8 specific_flags; 248 u16 address_min;
288 u16 granularity; 249 u16 address_max;
289 u16 address_min; 250 u16 translation_offset;
290 u16 address_max; 251 u16 address_length;
291 u16 translation_offset; 252 u8 optional_fields[2];
292 u16 address_length;
293 u8 optional_fields[2];
294}; 253};
295 254
296 255struct asl_extended_xrupt_desc {
297struct asl_extended_xrupt_desc 256 u8 descriptor_type;
298{ 257 u16 length;
299 u8 descriptor_type; 258 u8 flags;
300 u16 length; 259 u8 table_length;
301 u8 flags; 260 u32 interrupt_number[1];
302 u8 table_length;
303 u32 interrupt_number[1];
304 /* res_source_index, res_source optional fields follow */ 261 /* res_source_index, res_source optional fields follow */
305}; 262};
306 263
307 264struct asl_general_register_desc {
308struct asl_general_register_desc 265 u8 descriptor_type;
309{ 266 u16 length;
310 u8 descriptor_type; 267 u8 address_space_id;
311 u16 length; 268 u8 bit_width;
312 u8 address_space_id; 269 u8 bit_offset;
313 u8 bit_width; 270 u8 access_size; /* ACPI 3.0, was Reserved */
314 u8 bit_offset; 271 u64 address;
315 u8 access_size; /* ACPI 3.0, was Reserved */
316 u64 address;
317}; 272};
318 273
319/* restore default alignment */ 274/* restore default alignment */
@@ -322,32 +277,29 @@ struct asl_general_register_desc
322 277
323/* Union of all resource descriptors, so we can allocate the worst case */ 278/* Union of all resource descriptors, so we can allocate the worst case */
324 279
325union asl_resource_desc 280union asl_resource_desc {
326{ 281 struct asl_irq_format_desc irq;
327 struct asl_irq_format_desc irq; 282 struct asl_dma_format_desc dma;
328 struct asl_dma_format_desc dma; 283 struct asl_start_dependent_desc std;
329 struct asl_start_dependent_desc std; 284 struct asl_end_dependent_desc end;
330 struct asl_end_dependent_desc end; 285 struct asl_io_port_desc iop;
331 struct asl_io_port_desc iop; 286 struct asl_fixed_io_port_desc fio;
332 struct asl_fixed_io_port_desc fio; 287 struct asl_small_vendor_desc smv;
333 struct asl_small_vendor_desc smv; 288 struct asl_end_tag_desc et;
334 struct asl_end_tag_desc et; 289
335 290 struct asl_memory_24_desc M24;
336 struct asl_memory_24_desc M24; 291 struct asl_large_vendor_desc lgv;
337 struct asl_large_vendor_desc lgv; 292 struct asl_memory_32_desc M32;
338 struct asl_memory_32_desc M32; 293 struct asl_fixed_memory_32_desc F32;
339 struct asl_fixed_memory_32_desc F32; 294 struct asl_qword_address_desc qas;
340 struct asl_qword_address_desc qas; 295 struct asl_dword_address_desc das;
341 struct asl_dword_address_desc das; 296 struct asl_word_address_desc was;
342 struct asl_word_address_desc was; 297 struct asl_extended_address_desc eas;
343 struct asl_extended_address_desc eas; 298 struct asl_extended_xrupt_desc exx;
344 struct asl_extended_xrupt_desc exx; 299 struct asl_general_register_desc grg;
345 struct asl_general_register_desc grg; 300 u32 u32_item;
346 u32 u32_item; 301 u16 u16_item;
347 u16 u16_item; 302 u8 U8item;
348 u8 U8item;
349}; 303};
350 304
351
352#endif 305#endif
353
diff --git a/include/acpi/container.h b/include/acpi/container.h
index d716df04d9dc..a703f14e049e 100644
--- a/include/acpi/container.h
+++ b/include/acpi/container.h
@@ -9,5 +9,4 @@ struct acpi_container {
9 int state; 9 int state;
10}; 10};
11 11
12#endif /* __ACPI_CONTAINER_H */ 12#endif /* __ACPI_CONTAINER_H */
13
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
index fd6730e4e567..91f4a12a99a1 100644
--- a/include/acpi/pdc_intel.h
+++ b/include/acpi/pdc_intel.h
@@ -14,7 +14,6 @@
14#define ACPI_PDC_SMP_T_SWCOORD (0x0080) 14#define ACPI_PDC_SMP_T_SWCOORD (0x0080)
15#define ACPI_PDC_C_C1_FFH (0x0100) 15#define ACPI_PDC_C_C1_FFH (0x0100)
16 16
17
18#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ 17#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
19 ACPI_PDC_C_C1_HALT) 18 ACPI_PDC_C_C1_HALT)
20 19
@@ -25,5 +24,4 @@
25 ACPI_PDC_SMP_C1PT | \ 24 ACPI_PDC_SMP_C1PT | \
26 ACPI_PDC_C_C1_HALT) 25 ACPI_PDC_C_C1_HALT)
27 26
28#endif /* __PDC_INTEL_H__ */ 27#endif /* __PDC_INTEL_H__ */
29
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index adf969efa510..16609c1ab2eb 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -44,40 +44,42 @@
44#ifndef __ACENV_H__ 44#ifndef __ACENV_H__
45#define __ACENV_H__ 45#define __ACENV_H__
46 46
47
48/* 47/*
49 * Configuration for ACPI tools and utilities 48 * Configuration for ACPI tools and utilities
50 */ 49 */
51 50
52#ifdef _ACPI_DUMP_APP 51#ifdef ACPI_LIBRARY
52#define ACPI_USE_LOCAL_CACHE
53#endif
54
55#ifdef ACPI_DUMP_APP
53#ifndef MSDOS 56#ifndef MSDOS
54#define ACPI_DEBUG_OUTPUT 57#define ACPI_DEBUG_OUTPUT
55#endif 58#endif
56#define ACPI_APPLICATION 59#define ACPI_APPLICATION
57#define ACPI_DISASSEMBLER 60#define ACPI_DISASSEMBLER
58#define ACPI_NO_METHOD_EXECUTION 61#define ACPI_NO_METHOD_EXECUTION
59#define ACPI_USE_SYSTEM_CLIBRARY
60#define ACPI_ENABLE_OBJECT_CACHE
61#endif 62#endif
62 63
63#ifdef _ACPI_EXEC_APP 64#ifdef ACPI_EXEC_APP
64#undef DEBUGGER_THREADING 65#undef DEBUGGER_THREADING
65#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED 66#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
66#define ACPI_DEBUG_OUTPUT 67#define ACPI_DEBUG_OUTPUT
67#define ACPI_APPLICATION 68#define ACPI_APPLICATION
68#define ACPI_DEBUGGER 69#define ACPI_DEBUGGER
69#define ACPI_DISASSEMBLER 70#define ACPI_DISASSEMBLER
70#define ACPI_USE_SYSTEM_CLIBRARY
71#define ACPI_ENABLE_OBJECT_CACHE
72#endif 71#endif
73 72
74#ifdef _ACPI_ASL_COMPILER 73#ifdef ACPI_ASL_COMPILER
75#define ACPI_DEBUG_OUTPUT 74#define ACPI_DEBUG_OUTPUT
76#define ACPI_APPLICATION 75#define ACPI_APPLICATION
77#define ACPI_DISASSEMBLER 76#define ACPI_DISASSEMBLER
78#define ACPI_CONSTANT_EVAL_ONLY 77#define ACPI_CONSTANT_EVAL_ONLY
78#endif
79
80#ifdef ACPI_APPLICATION
79#define ACPI_USE_SYSTEM_CLIBRARY 81#define ACPI_USE_SYSTEM_CLIBRARY
80#define ACPI_ENABLE_OBJECT_CACHE 82#define ACPI_USE_LOCAL_CACHE
81#endif 83#endif
82 84
83/* 85/*
@@ -131,7 +133,7 @@
131#elif defined(WIN64) 133#elif defined(WIN64)
132#include "acwin64.h" 134#include "acwin64.h"
133 135
134#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ 136#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */
135#include "acdos16.h" 137#include "acdos16.h"
136 138
137#elif defined(__FreeBSD__) 139#elif defined(__FreeBSD__)
@@ -177,7 +179,6 @@
177 179
178/*! [End] no source code translation !*/ 180/*! [End] no source code translation !*/
179 181
180
181/* 182/*
182 * Debugger threading model 183 * Debugger threading model
183 * Use single threaded if the entire subsystem is contained in an application 184 * Use single threaded if the entire subsystem is contained in an application
@@ -196,8 +197,7 @@
196#else 197#else
197#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED 198#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED
198#endif 199#endif
199#endif /* !DEBUGGER_THREADING */ 200#endif /* !DEBUGGER_THREADING */
200
201 201
202/****************************************************************************** 202/******************************************************************************
203 * 203 *
@@ -219,7 +219,7 @@
219#include <string.h> 219#include <string.h>
220#include <ctype.h> 220#include <ctype.h>
221 221
222#endif /* ACPI_USE_STANDARD_HEADERS */ 222#endif /* ACPI_USE_STANDARD_HEADERS */
223 223
224/* 224/*
225 * We will be linking to the standard Clib functions 225 * We will be linking to the standard Clib functions
@@ -238,15 +238,15 @@
238#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n)) 238#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n))
239#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n)) 239#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n))
240 240
241#define ACPI_TOUPPER toupper 241#define ACPI_TOUPPER(i) toupper((int) (i))
242#define ACPI_TOLOWER tolower 242#define ACPI_TOLOWER(i) tolower((int) (i))
243#define ACPI_IS_XDIGIT isxdigit 243#define ACPI_IS_XDIGIT(i) isxdigit((int) (i))
244#define ACPI_IS_DIGIT isdigit 244#define ACPI_IS_DIGIT(i) isdigit((int) (i))
245#define ACPI_IS_SPACE isspace 245#define ACPI_IS_SPACE(i) isspace((int) (i))
246#define ACPI_IS_UPPER isupper 246#define ACPI_IS_UPPER(i) isupper((int) (i))
247#define ACPI_IS_PRINT isprint 247#define ACPI_IS_PRINT(i) isprint((int) (i))
248#define ACPI_IS_ALPHA isalpha 248#define ACPI_IS_ALPHA(i) isalpha((int) (i))
249#define ACPI_IS_ASCII isascii 249#define ACPI_IS_ASCII(i) isascii((int) (i))
250 250
251#else 251#else
252 252
@@ -257,18 +257,18 @@
257 *****************************************************************************/ 257 *****************************************************************************/
258 258
259 /* 259 /*
260 * Use local definitions of C library macros and functions 260 * Use local definitions of C library macros and functions
261 * NOTE: The function implementations may not be as efficient 261 * NOTE: The function implementations may not be as efficient
262 * as an inline or assembly code implementation provided by a 262 * as an inline or assembly code implementation provided by a
263 * native C library. 263 * native C library.
264 */ 264 */
265 265
266#ifndef va_arg 266#ifndef va_arg
267 267
268#ifndef _VALIST 268#ifndef _VALIST
269#define _VALIST 269#define _VALIST
270typedef char *va_list; 270typedef char *va_list;
271#endif /* _VALIST */ 271#endif /* _VALIST */
272 272
273/* 273/*
274 * Storage alignment properties 274 * Storage alignment properties
@@ -284,8 +284,7 @@ typedef char *va_list;
284#define va_end(ap) (void) 0 284#define va_end(ap) (void) 0
285#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND)))) 285#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
286 286
287#endif /* va_arg */ 287#endif /* va_arg */
288
289 288
290#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2)) 289#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))
291#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c)) 290#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))
@@ -303,8 +302,7 @@ typedef char *va_list;
303#define ACPI_TOUPPER acpi_ut_to_upper 302#define ACPI_TOUPPER acpi_ut_to_upper
304#define ACPI_TOLOWER acpi_ut_to_lower 303#define ACPI_TOLOWER acpi_ut_to_lower
305 304
306#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 305#endif /* ACPI_USE_SYSTEM_CLIBRARY */
307
308 306
309/****************************************************************************** 307/******************************************************************************
310 * 308 *
@@ -345,8 +343,7 @@ typedef char *va_list;
345#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) 343#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
346#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) 344#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
347 345
348#endif /* ACPI_ASM_MACROS */ 346#endif /* ACPI_ASM_MACROS */
349
350 347
351#ifdef ACPI_APPLICATION 348#ifdef ACPI_APPLICATION
352 349
@@ -356,11 +353,10 @@ typedef char *va_list;
356#define BREAKPOINT3 353#define BREAKPOINT3
357#endif 354#endif
358 355
359
360/****************************************************************************** 356/******************************************************************************
361 * 357 *
362 * Compiler-specific information is contained in the compiler-specific 358 * Compiler-specific information is contained in the compiler-specific
363 * headers. 359 * headers.
364 * 360 *
365 *****************************************************************************/ 361 *****************************************************************************/
366#endif /* __ACENV_H__ */ 362#endif /* __ACENV_H__ */
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 91fda36b042b..4c0e0ba09ba0 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -44,16 +44,20 @@
44#ifndef __ACGCC_H__ 44#ifndef __ACGCC_H__
45#define __ACGCC_H__ 45#define __ACGCC_H__
46 46
47/* Function name is used for debug output. Non-ANSI, compiler-dependent */
48
49#define ACPI_GET_FUNCTION_NAME __FUNCTION__
50
47/* This macro is used to tag functions as "printf-like" because 51/* This macro is used to tag functions as "printf-like" because
48 * some compilers (like GCC) can catch printf format string problems. 52 * some compilers (like GCC) can catch printf format string problems.
49 */ 53 */
50#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5))) 54#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 6, 7)))
51 55
52/* Some compilers complain about unused variables. Sometimes we don't want to 56/* Some compilers complain about unused variables. Sometimes we don't want to
53 * use all the variables (most specifically for _THIS_MODULE). This allow us 57 * use all the variables (for example, _acpi_module_name). This allows us
54 * to to tell the compiler warning in a per-variable manner that a variable 58 * to to tell the compiler warning in a per-variable manner that a variable
55 * is unused. 59 * is unused.
56 */ 60 */
57#define ACPI_UNUSED_VAR __attribute__ ((unused)) 61#define ACPI_UNUSED_VAR __attribute__ ((unused))
58 62
59#endif /* __ACGCC_H__ */ 63#endif /* __ACGCC_H__ */
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index a3de0db85694..c93e6562f0e1 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -62,7 +62,16 @@
62 62
63#define ACPI_MACHINE_WIDTH BITS_PER_LONG 63#define ACPI_MACHINE_WIDTH BITS_PER_LONG
64 64
65#else /* !__KERNEL__ */ 65/* Type(s) for the OSL */
66
67#ifdef ACPI_USE_LOCAL_CACHE
68#define acpi_cache_t struct acpi_memory_list
69#else
70#include <linux/slab.h>
71#define acpi_cache_t kmem_cache_t
72#endif
73
74#else /* !__KERNEL__ */
66 75
67#include <stdarg.h> 76#include <stdarg.h>
68#include <string.h> 77#include <string.h>
@@ -83,10 +92,10 @@
83 92
84#define __cdecl 93#define __cdecl
85#define ACPI_FLUSH_CPU_CACHE() 94#define ACPI_FLUSH_CPU_CACHE()
86#endif /* __KERNEL__ */ 95#endif /* __KERNEL__ */
87 96
88/* Linux uses GCC */ 97/* Linux uses GCC */
89 98
90#include "acgcc.h" 99#include "acgcc.h"
91 100
92#endif /* __ACLINUX_H__ */ 101#endif /* __ACLINUX_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 50cfea4ff6ca..7a00d5089de9 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -23,45 +23,44 @@
23struct acpi_processor_cx; 23struct acpi_processor_cx;
24 24
25struct acpi_power_register { 25struct acpi_power_register {
26 u8 descriptor; 26 u8 descriptor;
27 u16 length; 27 u16 length;
28 u8 space_id; 28 u8 space_id;
29 u8 bit_width; 29 u8 bit_width;
30 u8 bit_offset; 30 u8 bit_offset;
31 u8 reserved; 31 u8 reserved;
32 u64 address; 32 u64 address;
33} __attribute__ ((packed)); 33} __attribute__ ((packed));
34 34
35
36struct acpi_processor_cx_policy { 35struct acpi_processor_cx_policy {
37 u32 count; 36 u32 count;
38 struct acpi_processor_cx *state; 37 struct acpi_processor_cx *state;
39 struct { 38 struct {
40 u32 time; 39 u32 time;
41 u32 ticks; 40 u32 ticks;
42 u32 count; 41 u32 count;
43 u32 bm; 42 u32 bm;
44 } threshold; 43 } threshold;
45}; 44};
46 45
47struct acpi_processor_cx { 46struct acpi_processor_cx {
48 u8 valid; 47 u8 valid;
49 u8 type; 48 u8 type;
50 u32 address; 49 u32 address;
51 u32 latency; 50 u32 latency;
52 u32 latency_ticks; 51 u32 latency_ticks;
53 u32 power; 52 u32 power;
54 u32 usage; 53 u32 usage;
55 struct acpi_processor_cx_policy promotion; 54 struct acpi_processor_cx_policy promotion;
56 struct acpi_processor_cx_policy demotion; 55 struct acpi_processor_cx_policy demotion;
57}; 56};
58 57
59struct acpi_processor_power { 58struct acpi_processor_power {
60 struct acpi_processor_cx *state; 59 struct acpi_processor_cx *state;
61 unsigned long bm_check_timestamp; 60 unsigned long bm_check_timestamp;
62 u32 default_state; 61 u32 default_state;
63 u32 bm_activity; 62 u32 bm_activity;
64 int count; 63 int count;
65 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; 64 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
66 65
67 /* the _PDC objects passed by the driver, if any */ 66 /* the _PDC objects passed by the driver, if any */
@@ -71,85 +70,82 @@ struct acpi_processor_power {
71/* Performance Management */ 70/* Performance Management */
72 71
73struct acpi_pct_register { 72struct acpi_pct_register {
74 u8 descriptor; 73 u8 descriptor;
75 u16 length; 74 u16 length;
76 u8 space_id; 75 u8 space_id;
77 u8 bit_width; 76 u8 bit_width;
78 u8 bit_offset; 77 u8 bit_offset;
79 u8 reserved; 78 u8 reserved;
80 u64 address; 79 u64 address;
81} __attribute__ ((packed)); 80} __attribute__ ((packed));
82 81
83struct acpi_processor_px { 82struct acpi_processor_px {
84 acpi_integer core_frequency; /* megahertz */ 83 acpi_integer core_frequency; /* megahertz */
85 acpi_integer power; /* milliWatts */ 84 acpi_integer power; /* milliWatts */
86 acpi_integer transition_latency; /* microseconds */ 85 acpi_integer transition_latency; /* microseconds */
87 acpi_integer bus_master_latency; /* microseconds */ 86 acpi_integer bus_master_latency; /* microseconds */
88 acpi_integer control; /* control value */ 87 acpi_integer control; /* control value */
89 acpi_integer status; /* success indicator */ 88 acpi_integer status; /* success indicator */
90}; 89};
91 90
92struct acpi_processor_performance { 91struct acpi_processor_performance {
93 unsigned int state; 92 unsigned int state;
94 unsigned int platform_limit; 93 unsigned int platform_limit;
95 struct acpi_pct_register control_register; 94 struct acpi_pct_register control_register;
96 struct acpi_pct_register status_register; 95 struct acpi_pct_register status_register;
97 unsigned int state_count; 96 unsigned int state_count;
98 struct acpi_processor_px *states; 97 struct acpi_processor_px *states;
99 98
100 /* the _PDC objects passed by the driver, if any */ 99 /* the _PDC objects passed by the driver, if any */
101 struct acpi_object_list *pdc; 100 struct acpi_object_list *pdc;
102}; 101};
103 102
104
105
106/* Throttling Control */ 103/* Throttling Control */
107 104
108struct acpi_processor_tx { 105struct acpi_processor_tx {
109 u16 power; 106 u16 power;
110 u16 performance; 107 u16 performance;
111}; 108};
112 109
113struct acpi_processor_throttling { 110struct acpi_processor_throttling {
114 int state; 111 int state;
115 u32 address; 112 u32 address;
116 u8 duty_offset; 113 u8 duty_offset;
117 u8 duty_width; 114 u8 duty_width;
118 int state_count; 115 int state_count;
119 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; 116 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
120}; 117};
121 118
122/* Limit Interface */ 119/* Limit Interface */
123 120
124struct acpi_processor_lx { 121struct acpi_processor_lx {
125 int px; /* performace state */ 122 int px; /* performace state */
126 int tx; /* throttle level */ 123 int tx; /* throttle level */
127}; 124};
128 125
129struct acpi_processor_limit { 126struct acpi_processor_limit {
130 struct acpi_processor_lx state; /* current limit */ 127 struct acpi_processor_lx state; /* current limit */
131 struct acpi_processor_lx thermal; /* thermal limit */ 128 struct acpi_processor_lx thermal; /* thermal limit */
132 struct acpi_processor_lx user; /* user limit */ 129 struct acpi_processor_lx user; /* user limit */
133}; 130};
134 131
135
136struct acpi_processor_flags { 132struct acpi_processor_flags {
137 u8 power:1; 133 u8 power:1;
138 u8 performance:1; 134 u8 performance:1;
139 u8 throttling:1; 135 u8 throttling:1;
140 u8 limit:1; 136 u8 limit:1;
141 u8 bm_control:1; 137 u8 bm_control:1;
142 u8 bm_check:1; 138 u8 bm_check:1;
143 u8 has_cst:1; 139 u8 has_cst:1;
144 u8 power_setup_done:1; 140 u8 power_setup_done:1;
145}; 141};
146 142
147struct acpi_processor { 143struct acpi_processor {
148 acpi_handle handle; 144 acpi_handle handle;
149 u32 acpi_id; 145 u32 acpi_id;
150 u32 id; 146 u32 id;
151 u32 pblk; 147 u32 pblk;
152 int performance_platform_limit; 148 int performance_platform_limit;
153 struct acpi_processor_flags flags; 149 struct acpi_processor_flags flags;
154 struct acpi_processor_power power; 150 struct acpi_processor_power power;
155 struct acpi_processor_performance *performance; 151 struct acpi_processor_performance *performance;
@@ -158,50 +154,49 @@ struct acpi_processor {
158}; 154};
159 155
160struct acpi_processor_errata { 156struct acpi_processor_errata {
161 u8 smp; 157 u8 smp;
162 struct { 158 struct {
163 u8 throttle:1; 159 u8 throttle:1;
164 u8 fdma:1; 160 u8 fdma:1;
165 u8 reserved:6; 161 u8 reserved:6;
166 u32 bmisx; 162 u32 bmisx;
167 } piix4; 163 } piix4;
168}; 164};
169 165
170extern int acpi_processor_register_performance ( 166extern int acpi_processor_register_performance(struct acpi_processor_performance
171 struct acpi_processor_performance * performance, 167 *performance, unsigned int cpu);
172 unsigned int cpu); 168extern void acpi_processor_unregister_performance(struct
173extern void acpi_processor_unregister_performance ( 169 acpi_processor_performance
174 struct acpi_processor_performance * performance, 170 *performance,
175 unsigned int cpu); 171 unsigned int cpu);
176 172
177/* note: this locks both the calling module and the processor module 173/* note: this locks both the calling module and the processor module
178 if a _PPC object exists, rmmod is disallowed then */ 174 if a _PPC object exists, rmmod is disallowed then */
179int acpi_processor_notify_smm(struct module *calling_module); 175int acpi_processor_notify_smm(struct module *calling_module);
180 176
181
182
183/* for communication between multiple parts of the processor kernel module */ 177/* for communication between multiple parts of the processor kernel module */
184extern struct acpi_processor *processors[NR_CPUS]; 178extern struct acpi_processor *processors[NR_CPUS];
185extern struct acpi_processor_errata errata; 179extern struct acpi_processor_errata errata;
186 180
187int acpi_processor_set_pdc(struct acpi_processor *pr, 181int acpi_processor_set_pdc(struct acpi_processor *pr,
188 struct acpi_object_list *pdc_in); 182 struct acpi_object_list *pdc_in);
189 183
190#ifdef ARCH_HAS_POWER_PDC_INIT 184#ifdef ARCH_HAS_POWER_PDC_INIT
191void acpi_processor_power_init_pdc(struct acpi_processor_power *pow, 185void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
192 unsigned int cpu); 186 unsigned int cpu);
193void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, 187void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
194 unsigned int cpu); 188 unsigned int cpu);
195#else 189#else
196static inline void acpi_processor_power_init_pdc( 190static inline void acpi_processor_power_init_pdc(struct acpi_processor_power
197 struct acpi_processor_power *pow, unsigned int cpu) 191 *pow, unsigned int cpu)
198{ 192{
199 pow->pdc = NULL; 193 pow->pdc = NULL;
200 return; 194 return;
201} 195}
202 196
203static inline void acpi_processor_power_init_bm_check( 197static inline void acpi_processor_power_init_bm_check(struct
204 struct acpi_processor_flags *flags, unsigned int cpu) 198 acpi_processor_flags
199 *flags, unsigned int cpu)
205{ 200{
206 flags->bm_check = 1; 201 flags->bm_check = 1;
207 return; 202 return;
@@ -215,51 +210,62 @@ void acpi_processor_ppc_init(void);
215void acpi_processor_ppc_exit(void); 210void acpi_processor_ppc_exit(void);
216int acpi_processor_ppc_has_changed(struct acpi_processor *pr); 211int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
217#else 212#else
218static inline void acpi_processor_ppc_init(void) { return; } 213static inline void acpi_processor_ppc_init(void)
219static inline void acpi_processor_ppc_exit(void) { return; } 214{
220static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) { 215 return;
216}
217static inline void acpi_processor_ppc_exit(void)
218{
219 return;
220}
221static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
222{
221 static unsigned int printout = 1; 223 static unsigned int printout = 1;
222 if (printout) { 224 if (printout) {
223 printk(KERN_WARNING "Warning: Processor Platform Limit event detected, but not handled.\n"); 225 printk(KERN_WARNING
224 printk(KERN_WARNING "Consider compiling CPUfreq support into your kernel.\n"); 226 "Warning: Processor Platform Limit event detected, but not handled.\n");
227 printk(KERN_WARNING
228 "Consider compiling CPUfreq support into your kernel.\n");
225 printout = 0; 229 printout = 0;
226 } 230 }
227 return 0; 231 return 0;
228} 232}
229#endif /* CONFIG_CPU_FREQ */ 233#endif /* CONFIG_CPU_FREQ */
230 234
231/* in processor_throttling.c */ 235/* in processor_throttling.c */
232int acpi_processor_get_throttling_info (struct acpi_processor *pr); 236int acpi_processor_get_throttling_info(struct acpi_processor *pr);
233int acpi_processor_set_throttling (struct acpi_processor *pr, int state); 237int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
234ssize_t acpi_processor_write_throttling ( 238ssize_t acpi_processor_write_throttling(struct file *file,
235 struct file *file, 239 const char __user * buffer,
236 const char __user *buffer, 240 size_t count, loff_t * data);
237 size_t count,
238 loff_t *data);
239extern struct file_operations acpi_processor_throttling_fops; 241extern struct file_operations acpi_processor_throttling_fops;
240 242
241/* in processor_idle.c */ 243/* in processor_idle.c */
242int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device); 244int acpi_processor_power_init(struct acpi_processor *pr,
243int acpi_processor_cst_has_changed (struct acpi_processor *pr); 245 struct acpi_device *device);
244int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device); 246int acpi_processor_cst_has_changed(struct acpi_processor *pr);
245 247int acpi_processor_power_exit(struct acpi_processor *pr,
248 struct acpi_device *device);
246 249
247/* in processor_thermal.c */ 250/* in processor_thermal.c */
248int acpi_processor_get_limit_info (struct acpi_processor *pr); 251int acpi_processor_get_limit_info(struct acpi_processor *pr);
249ssize_t acpi_processor_write_limit ( 252ssize_t acpi_processor_write_limit(struct file *file,
250 struct file *file, 253 const char __user * buffer,
251 const char __user *buffer, 254 size_t count, loff_t * data);
252 size_t count,
253 loff_t *data);
254extern struct file_operations acpi_processor_limit_fops; 255extern struct file_operations acpi_processor_limit_fops;
255 256
256#ifdef CONFIG_CPU_FREQ 257#ifdef CONFIG_CPU_FREQ
257void acpi_thermal_cpufreq_init(void); 258void acpi_thermal_cpufreq_init(void);
258void acpi_thermal_cpufreq_exit(void); 259void acpi_thermal_cpufreq_exit(void);
259#else 260#else
260static inline void acpi_thermal_cpufreq_init(void) { return; } 261static inline void acpi_thermal_cpufreq_init(void)
261static inline void acpi_thermal_cpufreq_exit(void) { return; } 262{
263 return;
264}
265static inline void acpi_thermal_cpufreq_exit(void)
266{
267 return;
268}
262#endif 269#endif
263 270
264
265#endif 271#endif
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index cf828ace13f9..df4ed323aa4d 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -103,7 +103,7 @@ __acpi_release_global_lock (unsigned int *lock)
103 :"=r"(n_hi), "=r"(n_lo) \ 103 :"=r"(n_hi), "=r"(n_lo) \
104 :"0"(n_hi), "1"(n_lo)) 104 :"0"(n_hi), "1"(n_lo))
105 105
106#ifdef CONFIG_ACPI_BOOT 106#ifdef CONFIG_ACPI
107extern int acpi_lapic; 107extern int acpi_lapic;
108extern int acpi_ioapic; 108extern int acpi_ioapic;
109extern int acpi_noirq; 109extern int acpi_noirq;
@@ -146,13 +146,6 @@ static inline void check_acpi_pci(void) { }
146 146
147#endif 147#endif
148 148
149#else /* CONFIG_ACPI_BOOT */
150# define acpi_lapic 0
151# define acpi_ioapic 0
152
153#endif
154
155#ifdef CONFIG_ACPI_PCI
156static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 149static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
157static inline void acpi_disable_pci(void) 150static inline void acpi_disable_pci(void)
158{ 151{
@@ -160,11 +153,16 @@ static inline void acpi_disable_pci(void)
160 acpi_noirq_set(); 153 acpi_noirq_set();
161} 154}
162extern int acpi_irq_balance_set(char *str); 155extern int acpi_irq_balance_set(char *str);
163#else 156
157#else /* !CONFIG_ACPI */
158
159#define acpi_lapic 0
160#define acpi_ioapic 0
164static inline void acpi_noirq_set(void) { } 161static inline void acpi_noirq_set(void) { }
165static inline void acpi_disable_pci(void) { } 162static inline void acpi_disable_pci(void) { }
166static inline int acpi_irq_balance_set(char *str) { return 0; } 163
167#endif 164#endif /* !CONFIG_ACPI */
165
168 166
169#ifdef CONFIG_ACPI_SLEEP 167#ifdef CONFIG_ACPI_SLEEP
170 168
diff --git a/include/asm-i386/fixmap.h b/include/asm-i386/fixmap.h
index c94cac958389..cfb1c61d3b9c 100644
--- a/include/asm-i386/fixmap.h
+++ b/include/asm-i386/fixmap.h
@@ -76,7 +76,7 @@ enum fixed_addresses {
76 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 76 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
77 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 77 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
78#endif 78#endif
79#ifdef CONFIG_ACPI_BOOT 79#ifdef CONFIG_ACPI
80 FIX_ACPI_BEGIN, 80 FIX_ACPI_BEGIN,
81 FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1, 81 FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
82#endif 82#endif
diff --git a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h
index 002c203ccd6a..51c4e5fe6062 100644
--- a/include/asm-i386/io_apic.h
+++ b/include/asm-i386/io_apic.h
@@ -195,12 +195,12 @@ extern int skip_ioapic_setup;
195 */ 195 */
196#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) 196#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
197 197
198#ifdef CONFIG_ACPI_BOOT 198#ifdef CONFIG_ACPI
199extern int io_apic_get_unique_id (int ioapic, int apic_id); 199extern int io_apic_get_unique_id (int ioapic, int apic_id);
200extern int io_apic_get_version (int ioapic); 200extern int io_apic_get_version (int ioapic);
201extern int io_apic_get_redir_entries (int ioapic); 201extern int io_apic_get_redir_entries (int ioapic);
202extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low); 202extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
203#endif /*CONFIG_ACPI_BOOT*/ 203#endif /* CONFIG_ACPI */
204 204
205extern int (*ioapic_renumber_irq)(int ioapic, int irq); 205extern int (*ioapic_renumber_irq)(int ioapic, int irq);
206 206
diff --git a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h
index d9fafba075bc..b9e9f66d2721 100644
--- a/include/asm-i386/mpspec.h
+++ b/include/asm-i386/mpspec.h
@@ -26,14 +26,14 @@ extern unsigned long mp_lapic_addr;
26extern int pic_mode; 26extern int pic_mode;
27extern int using_apic_timer; 27extern int using_apic_timer;
28 28
29#ifdef CONFIG_ACPI_BOOT 29#ifdef CONFIG_ACPI
30extern void mp_register_lapic (u8 id, u8 enabled); 30extern void mp_register_lapic (u8 id, u8 enabled);
31extern void mp_register_lapic_address (u64 address); 31extern void mp_register_lapic_address (u64 address);
32extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); 32extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
33extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); 33extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
34extern void mp_config_acpi_legacy_irqs (void); 34extern void mp_config_acpi_legacy_irqs (void);
35extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); 35extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
36#endif /*CONFIG_ACPI_BOOT*/ 36#endif /* CONFIG_ACPI */
37 37
38#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) 38#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
39 39
diff --git a/include/asm-ia64/acpi-ext.h b/include/asm-ia64/acpi-ext.h
index 9271d74c64cc..56d2ddc97b30 100644
--- a/include/asm-ia64/acpi-ext.h
+++ b/include/asm-ia64/acpi-ext.h
@@ -11,6 +11,7 @@
11#define _ASM_IA64_ACPI_EXT_H 11#define _ASM_IA64_ACPI_EXT_H
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14#include <acpi/actypes.h>
14 15
15extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length); 16extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length);
16 17
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index dc8c981af27f..aa1c7b2e438c 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -101,7 +101,7 @@ __acpi_release_global_lock (unsigned int *lock)
101 :"=r"(n_hi), "=r"(n_lo) \ 101 :"=r"(n_hi), "=r"(n_lo) \
102 :"0"(n_hi), "1"(n_lo)) 102 :"0"(n_hi), "1"(n_lo))
103 103
104#ifdef CONFIG_ACPI_BOOT 104#ifdef CONFIG_ACPI
105extern int acpi_lapic; 105extern int acpi_lapic;
106extern int acpi_ioapic; 106extern int acpi_ioapic;
107extern int acpi_noirq; 107extern int acpi_noirq;
@@ -121,17 +121,6 @@ static inline void disable_acpi(void)
121#define FIX_ACPI_PAGES 4 121#define FIX_ACPI_PAGES 4
122 122
123extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); 123extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
124
125#else /* !CONFIG_ACPI_BOOT */
126#define acpi_lapic 0
127#define acpi_ioapic 0
128#endif /* !CONFIG_ACPI_BOOT */
129
130extern int acpi_numa;
131extern int acpi_scan_nodes(unsigned long start, unsigned long end);
132#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
133
134#ifdef CONFIG_ACPI_PCI
135static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 124static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
136static inline void acpi_disable_pci(void) 125static inline void acpi_disable_pci(void)
137{ 126{
@@ -139,11 +128,19 @@ static inline void acpi_disable_pci(void)
139 acpi_noirq_set(); 128 acpi_noirq_set();
140} 129}
141extern int acpi_irq_balance_set(char *str); 130extern int acpi_irq_balance_set(char *str);
142#else 131
132#else /* !CONFIG_ACPI */
133
134#define acpi_lapic 0
135#define acpi_ioapic 0
143static inline void acpi_noirq_set(void) { } 136static inline void acpi_noirq_set(void) { }
144static inline void acpi_disable_pci(void) { } 137static inline void acpi_disable_pci(void) { }
145static inline int acpi_irq_balance_set(char *str) { return 0; } 138
146#endif 139#endif /* !CONFIG_ACPI */
140
141extern int acpi_numa;
142extern int acpi_scan_nodes(unsigned long start, unsigned long end);
143#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
147 144
148#ifdef CONFIG_ACPI_SLEEP 145#ifdef CONFIG_ACPI_SLEEP
149 146
diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h
index a8babd2bbe84..ee1bc69aec9c 100644
--- a/include/asm-x86_64/io_apic.h
+++ b/include/asm-x86_64/io_apic.h
@@ -201,7 +201,7 @@ extern int skip_ioapic_setup;
201 */ 201 */
202#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) 202#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
203 203
204#ifdef CONFIG_ACPI_BOOT 204#ifdef CONFIG_ACPI
205extern int io_apic_get_version (int ioapic); 205extern int io_apic_get_version (int ioapic);
206extern int io_apic_get_redir_entries (int ioapic); 206extern int io_apic_get_redir_entries (int ioapic);
207extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int); 207extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int);
diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
index 331f6a3c72a2..f267e10c023d 100644
--- a/include/asm-x86_64/mpspec.h
+++ b/include/asm-x86_64/mpspec.h
@@ -179,7 +179,7 @@ extern int mpc_default_type;
179extern unsigned long mp_lapic_addr; 179extern unsigned long mp_lapic_addr;
180extern int pic_mode; 180extern int pic_mode;
181 181
182#ifdef CONFIG_ACPI_BOOT 182#ifdef CONFIG_ACPI
183extern void mp_register_lapic (u8 id, u8 enabled); 183extern void mp_register_lapic (u8 id, u8 enabled);
184extern void mp_register_lapic_address (u64 address); 184extern void mp_register_lapic_address (u64 address);
185 185
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index b46a5205ee7b..026c3c011dc0 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -41,7 +41,7 @@
41#include <asm/acpi.h> 41#include <asm/acpi.h>
42 42
43 43
44#ifdef CONFIG_ACPI_BOOT 44#ifdef CONFIG_ACPI
45 45
46enum acpi_irq_model_id { 46enum acpi_irq_model_id {
47 ACPI_IRQ_MODEL_PIC = 0, 47 ACPI_IRQ_MODEL_PIC = 0,
@@ -429,23 +429,13 @@ extern int pci_mmcfg_config_num;
429 429
430extern int sbf_port ; 430extern int sbf_port ;
431 431
432#else /*!CONFIG_ACPI_BOOT*/ 432#else /* !CONFIG_ACPI */
433 433
434#define acpi_mp_config 0 434#define acpi_mp_config 0
435 435
436static inline int acpi_boot_init(void) 436#endif /* !CONFIG_ACPI */
437{
438 return 0;
439}
440
441static inline int acpi_boot_table_init(void)
442{
443 return 0;
444}
445 437
446#endif /*!CONFIG_ACPI_BOOT*/ 438int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
447
448unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
449int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 439int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
450 440
451/* 441/*
@@ -455,7 +445,7 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
455 */ 445 */
456void acpi_unregister_gsi (u32 gsi); 446void acpi_unregister_gsi (u32 gsi);
457 447
458#ifdef CONFIG_ACPI_PCI 448#ifdef CONFIG_ACPI
459 449
460struct acpi_prt_entry { 450struct acpi_prt_entry {
461 struct list_head node; 451 struct list_head node;
@@ -489,7 +479,7 @@ struct acpi_pci_driver {
489int acpi_pci_register_driver(struct acpi_pci_driver *driver); 479int acpi_pci_register_driver(struct acpi_pci_driver *driver);
490void acpi_pci_unregister_driver(struct acpi_pci_driver *driver); 480void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
491 481
492#endif /*CONFIG_ACPI_PCI*/ 482#endif /* CONFIG_ACPI */
493 483
494#ifdef CONFIG_ACPI_EC 484#ifdef CONFIG_ACPI_EC
495 485
@@ -498,20 +488,9 @@ extern int ec_write(u8 addr, u8 val);
498 488
499#endif /*CONFIG_ACPI_EC*/ 489#endif /*CONFIG_ACPI_EC*/
500 490
501#ifdef CONFIG_ACPI_INTERPRETER
502
503extern int acpi_blacklisted(void); 491extern int acpi_blacklisted(void);
504extern void acpi_bios_year(char *s); 492extern void acpi_bios_year(char *s);
505 493
506#else /*!CONFIG_ACPI_INTERPRETER*/
507
508static inline int acpi_blacklisted(void)
509{
510 return 0;
511}
512
513#endif /*!CONFIG_ACPI_INTERPRETER*/
514
515#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */ 494#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
516#ifdef CONFIG_ACPI 495#ifdef CONFIG_ACPI
517 496
@@ -549,5 +528,17 @@ static inline int acpi_get_pxm(acpi_handle handle)
549 528
550extern int pnpacpi_disabled; 529extern int pnpacpi_disabled;
551 530
531#else /* CONFIG_ACPI */
532
533static inline int acpi_boot_init(void)
534{
535 return 0;
536}
537
538static inline int acpi_boot_table_init(void)
539{
540 return 0;
541}
542
552#endif /* CONFIG_ACPI */ 543#endif /* CONFIG_ACPI */
553#endif /*_LINUX_ACPI_H*/ 544#endif /*_LINUX_ACPI_H*/
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 2c7121d9bff1..b99f61b82685 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -1,5 +1,6 @@
1config PM 1config PM
2 bool "Power Management support" 2 bool "Power Management support"
3 depends on !IA64_HP_SIM
3 ---help--- 4 ---help---
4 "Power Management" means that parts of your computer are shut 5 "Power Management" means that parts of your computer are shut
5 off or put into a power conserving "sleep" mode if they are not 6 off or put into a power conserving "sleep" mode if they are not