aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--arch/i386/kernel/acpi/boot.c530
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c40
-rw-r--r--arch/i386/kernel/acpi/sleep.c35
-rw-r--r--arch/ia64/kernel/acpi-ext.c37
-rw-r--r--arch/ia64/kernel/acpi.c324
-rw-r--r--arch/x86_64/kernel/acpi/sleep.c17
-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.c123
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c354
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c413
-rw-r--r--drivers/acpi/dispatcher/dsobject.c329
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c710
-rw-r--r--drivers/acpi/dispatcher/dsutils.c421
-rw-r--r--drivers/acpi/dispatcher/dswexec.c519
-rw-r--r--drivers/acpi/dispatcher/dswload.c488
-rw-r--r--drivers/acpi/dispatcher/dswscope.c139
-rw-r--r--drivers/acpi/dispatcher/dswstate.c640
-rw-r--r--drivers/acpi/ec.c957
-rw-r--r--drivers/acpi/event.c62
-rw-r--r--drivers/acpi/events/evevent.c168
-rw-r--r--drivers/acpi/events/evgpe.c428
-rw-r--r--drivers/acpi/events/evgpeblk.c756
-rw-r--r--drivers/acpi/events/evmisc.c294
-rw-r--r--drivers/acpi/events/evregion.c582
-rw-r--r--drivers/acpi/events/evrgnini.c311
-rw-r--r--drivers/acpi/events/evsci.c77
-rw-r--r--drivers/acpi/events/evxface.c446
-rw-r--r--drivers/acpi/events/evxfevnt.c463
-rw-r--r--drivers/acpi/events/evxfregn.c114
-rw-r--r--drivers/acpi/executer/exconfig.c319
-rw-r--r--drivers/acpi/executer/exconvrt.c311
-rw-r--r--drivers/acpi/executer/excreate.c342
-rw-r--r--drivers/acpi/executer/exdump.c744
-rw-r--r--drivers/acpi/executer/exfield.c252
-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.c235
-rw-r--r--drivers/acpi/executer/exoparg1.c555
-rw-r--r--drivers/acpi/executer/exoparg2.c317
-rw-r--r--drivers/acpi/executer/exoparg3.c116
-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.c390
-rw-r--r--drivers/acpi/executer/exstore.c415
-rw-r--r--drivers/acpi/executer/exstoren.c121
-rw-r--r--drivers/acpi/executer/exstorob.c86
-rw-r--r--drivers/acpi/executer/exsystem.c183
-rw-r--r--drivers/acpi/executer/exutils.c171
-rw-r--r--drivers/acpi/fan.c125
-rw-r--r--drivers/acpi/glue.c6
-rw-r--r--drivers/acpi/hardware/hwacpi.c116
-rw-r--r--drivers/acpi/hardware/hwgpe.c197
-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.c322
-rw-r--r--drivers/acpi/motherboard.c108
-rw-r--r--drivers/acpi/namespace/nsaccess.c342
-rw-r--r--drivers/acpi/namespace/nsalloc.c232
-rw-r--r--drivers/acpi/namespace/nsdump.c429
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c74
-rw-r--r--drivers/acpi/namespace/nseval.c270
-rw-r--r--drivers/acpi/namespace/nsinit.c257
-rw-r--r--drivers/acpi/namespace/nsload.c228
-rw-r--r--drivers/acpi/namespace/nsnames.c118
-rw-r--r--drivers/acpi/namespace/nsobject.c209
-rw-r--r--drivers/acpi/namespace/nsparse.c86
-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.c567
-rw-r--r--drivers/acpi/parser/psargs.c376
-rw-r--r--drivers/acpi/parser/psloop.c511
-rw-r--r--drivers/acpi/parser/psopcode.c719
-rw-r--r--drivers/acpi/parser/psparse.c362
-rw-r--r--drivers/acpi/parser/psscope.c130
-rw-r--r--drivers/acpi/parser/pstree.c92
-rw-r--r--drivers/acpi/parser/psutils.c105
-rw-r--r--drivers/acpi/parser/pswalk.c26
-rw-r--r--drivers/acpi/parser/psxface.c142
-rw-r--r--drivers/acpi/pci_bind.c219
-rw-r--r--drivers/acpi/pci_irq.c263
-rw-r--r--drivers/acpi/pci_link.c477
-rw-r--r--drivers/acpi/pci_root.c130
-rw-r--r--drivers/acpi/power.c271
-rw-r--r--drivers/acpi/processor_core.c437
-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.c503
-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.c236
-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.c243
-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.c402
-rw-r--r--drivers/acpi/tables/tbget.c275
-rw-r--r--drivers/acpi/tables/tbgetall.c189
-rw-r--r--drivers/acpi/tables/tbinstal.c256
-rw-r--r--drivers/acpi/tables/tbrsdt.c190
-rw-r--r--drivers/acpi/tables/tbutils.c147
-rw-r--r--drivers/acpi/tables/tbxface.c246
-rw-r--r--drivers/acpi/tables/tbxfroot.c431
-rw-r--r--drivers/acpi/thermal.c801
-rw-r--r--drivers/acpi/toshiba_acpi.c174
-rw-r--r--drivers/acpi/utilities/utalloc.c505
-rw-r--r--drivers/acpi/utilities/utcache.c149
-rw-r--r--drivers/acpi/utilities/utcopy.c556
-rw-r--r--drivers/acpi/utilities/utdebug.c330
-rw-r--r--drivers/acpi/utilities/utdelete.c325
-rw-r--r--drivers/acpi/utilities/uteval.c396
-rw-r--r--drivers/acpi/utilities/utglobal.c557
-rw-r--r--drivers/acpi/utilities/utinit.c135
-rw-r--r--drivers/acpi/utilities/utmath.c144
-rw-r--r--drivers/acpi/utilities/utmisc.c431
-rw-r--r--drivers/acpi/utilities/utmutex.c220
-rw-r--r--drivers/acpi/utilities/utobject.c324
-rw-r--r--drivers/acpi/utilities/utstate.c159
-rw-r--r--drivers/acpi/utilities/utxface.c267
-rw-r--r--drivers/acpi/utils.c195
-rw-r--r--drivers/acpi/video.c1070
-rw-r--r--include/acpi/acconfig.h26
-rw-r--r--include/acpi/acdebug.h263
-rw-r--r--include/acpi/acdisasm.h323
-rw-r--r--include/acpi/acdispat.h398
-rw-r--r--include/acpi/acevents.h240
-rw-r--r--include/acpi/acexcep.h28
-rw-r--r--include/acpi/acglobal.h262
-rw-r--r--include/acpi/achware.h107
-rw-r--r--include/acpi/acinterp.h626
-rw-r--r--include/acpi/aclocal.h678
-rw-r--r--include/acpi/acmacros.h43
-rw-r--r--include/acpi/acnames.h11
-rw-r--r--include/acpi/acnamesp.h357
-rw-r--r--include/acpi/acobject.h390
-rw-r--r--include/acpi/acopcode.h4
-rw-r--r--include/acpi/acoutput.h8
-rw-r--r--include/acpi/acparser.h248
-rw-r--r--include/acpi/acpi.h35
-rw-r--r--include/acpi/acpi_bus.h332
-rw-r--r--include/acpi/acpi_drivers.h38
-rw-r--r--include/acpi/acpiosxf.h275
-rw-r--r--include/acpi/acpixf.h408
-rw-r--r--include/acpi/acresrc.h309
-rw-r--r--include/acpi/acstruct.h216
-rw-r--r--include/acpi/actables.h127
-rw-r--r--include/acpi/actbl.h260
-rw-r--r--include/acpi/actbl1.h133
-rw-r--r--include/acpi/actbl2.h245
-rw-r--r--include/acpi/actbl71.h148
-rw-r--r--include/acpi/actypes.h800
-rw-r--r--include/acpi/acutils.h709
-rw-r--r--include/acpi/amlcode.h170
-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.h33
-rw-r--r--include/acpi/platform/acgcc.h2
-rw-r--r--include/acpi/platform/aclinux.h8
-rw-r--r--include/acpi/processor.h238
190 files changed, 24398 insertions, 29344 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 55c0fbd68956..98d119c66379 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 || \
@@ -62,7 +68,7 @@ static inline int ioapic_setup_disabled(void) { return 0; }
62 68
63#ifdef CONFIG_ACPI_PCI 69#ifdef CONFIG_ACPI_PCI
64int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ 70int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
65int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ 71int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
66#else 72#else
67int acpi_noirq __initdata = 1; 73int acpi_noirq __initdata = 1;
68int acpi_pci_disabled __initdata = 1; 74int acpi_pci_disabled __initdata = 1;
@@ -88,7 +94,7 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
88 94
89#define MAX_MADT_ENTRIES 256 95#define MAX_MADT_ENTRIES 256
90u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = 96u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
91 { [0 ... MAX_MADT_ENTRIES-1] = 0xff }; 97 {[0...MAX_MADT_ENTRIES - 1] = 0xff };
92EXPORT_SYMBOL(x86_acpiid_to_apicid); 98EXPORT_SYMBOL(x86_acpiid_to_apicid);
93 99
94/* -------------------------------------------------------------------------- 100/* --------------------------------------------------------------------------
@@ -99,7 +105,7 @@ EXPORT_SYMBOL(x86_acpiid_to_apicid);
99 * The default interrupt routing model is PIC (8259). This gets 105 * The default interrupt routing model is PIC (8259). This gets
100 * overriden if IOAPICs are enumerated (below). 106 * overriden if IOAPICs are enumerated (below).
101 */ 107 */
102enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; 108enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
103 109
104#ifdef CONFIG_X86_64 110#ifdef CONFIG_X86_64
105 111
@@ -107,7 +113,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
107char *__acpi_map_table(unsigned long phys_addr, unsigned long size) 113char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
108{ 114{
109 if (!phys_addr || !size) 115 if (!phys_addr || !size)
110 return NULL; 116 return NULL;
111 117
112 if (phys_addr < (end_pfn_map << PAGE_SHIFT)) 118 if (phys_addr < (end_pfn_map << PAGE_SHIFT))
113 return __va(phys_addr); 119 return __va(phys_addr);
@@ -134,8 +140,8 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
134 unsigned long base, offset, mapped_size; 140 unsigned long base, offset, mapped_size;
135 int idx; 141 int idx;
136 142
137 if (phys + size < 8*1024*1024) 143 if (phys + size < 8 * 1024 * 1024)
138 return __va(phys); 144 return __va(phys);
139 145
140 offset = phys & (PAGE_SIZE - 1); 146 offset = phys & (PAGE_SIZE - 1);
141 mapped_size = PAGE_SIZE - offset; 147 mapped_size = PAGE_SIZE - offset;
@@ -154,7 +160,7 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
154 mapped_size += PAGE_SIZE; 160 mapped_size += PAGE_SIZE;
155 } 161 }
156 162
157 return ((unsigned char *) base + offset); 163 return ((unsigned char *)base + offset);
158} 164}
159#endif 165#endif
160 166
@@ -172,7 +178,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
172 if (!phys_addr || !size) 178 if (!phys_addr || !size)
173 return -EINVAL; 179 return -EINVAL;
174 180
175 mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size); 181 mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
176 if (!mcfg) { 182 if (!mcfg) {
177 printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); 183 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
178 return -ENODEV; 184 return -ENODEV;
@@ -209,20 +215,17 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
209 215
210 return 0; 216 return 0;
211} 217}
212#endif /* CONFIG_PCI_MMCONFIG */ 218#endif /* CONFIG_PCI_MMCONFIG */
213 219
214#ifdef CONFIG_X86_LOCAL_APIC 220#ifdef CONFIG_X86_LOCAL_APIC
215static int __init 221static 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{ 222{
220 struct acpi_table_madt *madt = NULL; 223 struct acpi_table_madt *madt = NULL;
221 224
222 if (!phys_addr || !size) 225 if (!phys_addr || !size)
223 return -EINVAL; 226 return -EINVAL;
224 227
225 madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size); 228 madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
226 if (!madt) { 229 if (!madt) {
227 printk(KERN_WARNING PREFIX "Unable to map MADT\n"); 230 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
228 return -ENODEV; 231 return -ENODEV;
@@ -232,22 +235,20 @@ acpi_parse_madt (
232 acpi_lapic_addr = (u64) madt->lapic_address; 235 acpi_lapic_addr = (u64) madt->lapic_address;
233 236
234 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", 237 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
235 madt->lapic_address); 238 madt->lapic_address);
236 } 239 }
237 240
238 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); 241 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
239 242
240 return 0; 243 return 0;
241} 244}
242 245
243
244static int __init 246static int __init
245acpi_parse_lapic ( 247acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
246 acpi_table_entry_header *header, const unsigned long end)
247{ 248{
248 struct acpi_table_lapic *processor = NULL; 249 struct acpi_table_lapic *processor = NULL;
249 250
250 processor = (struct acpi_table_lapic*) header; 251 processor = (struct acpi_table_lapic *)header;
251 252
252 if (BAD_MADT_ENTRY(processor, end)) 253 if (BAD_MADT_ENTRY(processor, end))
253 return -EINVAL; 254 return -EINVAL;
@@ -260,20 +261,19 @@ acpi_parse_lapic (
260 261
261 x86_acpiid_to_apicid[processor->acpi_id] = processor->id; 262 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
262 263
263 mp_register_lapic ( 264 mp_register_lapic(processor->id, /* APIC ID */
264 processor->id, /* APIC ID */ 265 processor->flags.enabled); /* Enabled? */
265 processor->flags.enabled); /* Enabled? */
266 266
267 return 0; 267 return 0;
268} 268}
269 269
270static int __init 270static int __init
271acpi_parse_lapic_addr_ovr ( 271acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
272 acpi_table_entry_header *header, const unsigned long end) 272 const unsigned long end)
273{ 273{
274 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL; 274 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
275 275
276 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header; 276 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
277 277
278 if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) 278 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
279 return -EINVAL; 279 return -EINVAL;
@@ -284,12 +284,11 @@ acpi_parse_lapic_addr_ovr (
284} 284}
285 285
286static int __init 286static int __init
287acpi_parse_lapic_nmi ( 287acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
288 acpi_table_entry_header *header, const unsigned long end)
289{ 288{
290 struct acpi_table_lapic_nmi *lapic_nmi = NULL; 289 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
291 290
292 lapic_nmi = (struct acpi_table_lapic_nmi*) header; 291 lapic_nmi = (struct acpi_table_lapic_nmi *)header;
293 292
294 if (BAD_MADT_ENTRY(lapic_nmi, end)) 293 if (BAD_MADT_ENTRY(lapic_nmi, end))
295 return -EINVAL; 294 return -EINVAL;
@@ -302,37 +301,32 @@ acpi_parse_lapic_nmi (
302 return 0; 301 return 0;
303} 302}
304 303
305 304#endif /*CONFIG_X86_LOCAL_APIC */
306#endif /*CONFIG_X86_LOCAL_APIC*/
307 305
308#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) 306#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
309 307
310static int __init 308static int __init
311acpi_parse_ioapic ( 309acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
312 acpi_table_entry_header *header, const unsigned long end)
313{ 310{
314 struct acpi_table_ioapic *ioapic = NULL; 311 struct acpi_table_ioapic *ioapic = NULL;
315 312
316 ioapic = (struct acpi_table_ioapic*) header; 313 ioapic = (struct acpi_table_ioapic *)header;
317 314
318 if (BAD_MADT_ENTRY(ioapic, end)) 315 if (BAD_MADT_ENTRY(ioapic, end))
319 return -EINVAL; 316 return -EINVAL;
320 317
321 acpi_table_print_madt_entry(header); 318 acpi_table_print_madt_entry(header);
322 319
323 mp_register_ioapic ( 320 mp_register_ioapic(ioapic->id,
324 ioapic->id, 321 ioapic->address, ioapic->global_irq_base);
325 ioapic->address, 322
326 ioapic->global_irq_base);
327
328 return 0; 323 return 0;
329} 324}
330 325
331/* 326/*
332 * Parse Interrupt Source Override for the ACPI SCI 327 * Parse Interrupt Source Override for the ACPI SCI
333 */ 328 */
334static void 329static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
335acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
336{ 330{
337 if (trigger == 0) /* compatible SCI trigger is level */ 331 if (trigger == 0) /* compatible SCI trigger is level */
338 trigger = 3; 332 trigger = 3;
@@ -348,7 +342,7 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
348 polarity = acpi_sci_flags.polarity; 342 polarity = acpi_sci_flags.polarity;
349 343
350 /* 344 /*
351 * mp_config_acpi_legacy_irqs() already setup IRQs < 16 345 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
352 * If GSI is < 16, this will update its flags, 346 * If GSI is < 16, this will update its flags,
353 * else it will create a new mp_irqs[] entry. 347 * else it will create a new mp_irqs[] entry.
354 */ 348 */
@@ -363,12 +357,12 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
363} 357}
364 358
365static int __init 359static int __init
366acpi_parse_int_src_ovr ( 360acpi_parse_int_src_ovr(acpi_table_entry_header * header,
367 acpi_table_entry_header *header, const unsigned long end) 361 const unsigned long end)
368{ 362{
369 struct acpi_table_int_src_ovr *intsrc = NULL; 363 struct acpi_table_int_src_ovr *intsrc = NULL;
370 364
371 intsrc = (struct acpi_table_int_src_ovr*) header; 365 intsrc = (struct acpi_table_int_src_ovr *)header;
372 366
373 if (BAD_MADT_ENTRY(intsrc, end)) 367 if (BAD_MADT_ENTRY(intsrc, end))
374 return -EINVAL; 368 return -EINVAL;
@@ -377,33 +371,30 @@ acpi_parse_int_src_ovr (
377 371
378 if (intsrc->bus_irq == acpi_fadt.sci_int) { 372 if (intsrc->bus_irq == acpi_fadt.sci_int) {
379 acpi_sci_ioapic_setup(intsrc->global_irq, 373 acpi_sci_ioapic_setup(intsrc->global_irq,
380 intsrc->flags.polarity, intsrc->flags.trigger); 374 intsrc->flags.polarity,
375 intsrc->flags.trigger);
381 return 0; 376 return 0;
382 } 377 }
383 378
384 if (acpi_skip_timer_override && 379 if (acpi_skip_timer_override &&
385 intsrc->bus_irq == 0 && intsrc->global_irq == 2) { 380 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
386 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); 381 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
387 return 0; 382 return 0;
388 } 383 }
389 384
390 mp_override_legacy_irq ( 385 mp_override_legacy_irq(intsrc->bus_irq,
391 intsrc->bus_irq, 386 intsrc->flags.polarity,
392 intsrc->flags.polarity, 387 intsrc->flags.trigger, intsrc->global_irq);
393 intsrc->flags.trigger,
394 intsrc->global_irq);
395 388
396 return 0; 389 return 0;
397} 390}
398 391
399
400static int __init 392static int __init
401acpi_parse_nmi_src ( 393acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
402 acpi_table_entry_header *header, const unsigned long end)
403{ 394{
404 struct acpi_table_nmi_src *nmi_src = NULL; 395 struct acpi_table_nmi_src *nmi_src = NULL;
405 396
406 nmi_src = (struct acpi_table_nmi_src*) header; 397 nmi_src = (struct acpi_table_nmi_src *)header;
407 398
408 if (BAD_MADT_ENTRY(nmi_src, end)) 399 if (BAD_MADT_ENTRY(nmi_src, end))
409 return -EINVAL; 400 return -EINVAL;
@@ -415,7 +406,7 @@ acpi_parse_nmi_src (
415 return 0; 406 return 0;
416} 407}
417 408
418#endif /* CONFIG_X86_IO_APIC */ 409#endif /* CONFIG_X86_IO_APIC */
419 410
420#ifdef CONFIG_ACPI_BUS 411#ifdef CONFIG_ACPI_BUS
421 412
@@ -433,8 +424,7 @@ acpi_parse_nmi_src (
433 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0) 424 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
434 */ 425 */
435 426
436void __init 427void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
437acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
438{ 428{
439 unsigned int mask = 1 << irq; 429 unsigned int mask = 1 << irq;
440 unsigned int old, new; 430 unsigned int old, new;
@@ -454,10 +444,10 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
454 * routing tables.. 444 * routing tables..
455 */ 445 */
456 switch (trigger) { 446 switch (trigger) {
457 case 1: /* Edge - clear */ 447 case 1: /* Edge - clear */
458 new &= ~mask; 448 new &= ~mask;
459 break; 449 break;
460 case 3: /* Level - set */ 450 case 3: /* Level - set */
461 new |= mask; 451 new |= mask;
462 break; 452 break;
463 } 453 }
@@ -470,14 +460,13 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
470 outb(new >> 8, 0x4d1); 460 outb(new >> 8, 0x4d1);
471} 461}
472 462
473 463#endif /* CONFIG_ACPI_BUS */
474#endif /* CONFIG_ACPI_BUS */
475 464
476int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) 465int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
477{ 466{
478#ifdef CONFIG_X86_IO_APIC 467#ifdef CONFIG_X86_IO_APIC
479 if (use_pci_vector() && !platform_legacy_irq(gsi)) 468 if (use_pci_vector() && !platform_legacy_irq(gsi))
480 *irq = IO_APIC_VECTOR(gsi); 469 *irq = IO_APIC_VECTOR(gsi);
481 else 470 else
482#endif 471#endif
483 *irq = gsi; 472 *irq = gsi;
@@ -501,7 +490,7 @@ int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
501 extern void eisa_set_level_irq(unsigned int irq); 490 extern void eisa_set_level_irq(unsigned int irq);
502 491
503 if (edge_level == ACPI_LEVEL_SENSITIVE) 492 if (edge_level == ACPI_LEVEL_SENSITIVE)
504 eisa_set_level_irq(gsi); 493 eisa_set_level_irq(gsi);
505 } 494 }
506#endif 495#endif
507 496
@@ -513,60 +502,58 @@ int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
513 acpi_gsi_to_irq(plat_gsi, &irq); 502 acpi_gsi_to_irq(plat_gsi, &irq);
514 return irq; 503 return irq;
515} 504}
505
516EXPORT_SYMBOL(acpi_register_gsi); 506EXPORT_SYMBOL(acpi_register_gsi);
517 507
518/* 508/*
519 * ACPI based hotplug support for CPU 509 * ACPI based hotplug support for CPU
520 */ 510 */
521#ifdef CONFIG_ACPI_HOTPLUG_CPU 511#ifdef CONFIG_ACPI_HOTPLUG_CPU
522int 512int acpi_map_lsapic(acpi_handle handle, int *pcpu)
523acpi_map_lsapic(acpi_handle handle, int *pcpu)
524{ 513{
525 /* TBD */ 514 /* TBD */
526 return -EINVAL; 515 return -EINVAL;
527} 516}
528EXPORT_SYMBOL(acpi_map_lsapic);
529 517
518EXPORT_SYMBOL(acpi_map_lsapic);
530 519
531int 520int acpi_unmap_lsapic(int cpu)
532acpi_unmap_lsapic(int cpu)
533{ 521{
534 /* TBD */ 522 /* TBD */
535 return -EINVAL; 523 return -EINVAL;
536} 524}
525
537EXPORT_SYMBOL(acpi_unmap_lsapic); 526EXPORT_SYMBOL(acpi_unmap_lsapic);
538#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 527#endif /* CONFIG_ACPI_HOTPLUG_CPU */
539 528
540int 529int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
541acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
542{ 530{
543 /* TBD */ 531 /* TBD */
544 return -EINVAL; 532 return -EINVAL;
545} 533}
534
546EXPORT_SYMBOL(acpi_register_ioapic); 535EXPORT_SYMBOL(acpi_register_ioapic);
547 536
548int 537int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
549acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
550{ 538{
551 /* TBD */ 539 /* TBD */
552 return -EINVAL; 540 return -EINVAL;
553} 541}
542
554EXPORT_SYMBOL(acpi_unregister_ioapic); 543EXPORT_SYMBOL(acpi_unregister_ioapic);
555 544
556static unsigned long __init 545static unsigned long __init
557acpi_scan_rsdp ( 546acpi_scan_rsdp(unsigned long start, unsigned long length)
558 unsigned long start,
559 unsigned long length)
560{ 547{
561 unsigned long offset = 0; 548 unsigned long offset = 0;
562 unsigned long sig_len = sizeof("RSD PTR ") - 1; 549 unsigned long sig_len = sizeof("RSD PTR ") - 1;
563 550
564 /* 551 /*
565 * Scan all 16-byte boundaries of the physical memory region for the 552 * Scan all 16-byte boundaries of the physical memory region for the
566 * RSDP signature. 553 * RSDP signature.
567 */ 554 */
568 for (offset = 0; offset < length; offset += 16) { 555 for (offset = 0; offset < length; offset += 16) {
569 if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) 556 if (strncmp((char *)(start + offset), "RSD PTR ", sig_len))
570 continue; 557 continue;
571 return (start + offset); 558 return (start + offset);
572 } 559 }
@@ -579,20 +566,19 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
579 struct acpi_table_sbf *sb; 566 struct acpi_table_sbf *sb;
580 567
581 if (!phys_addr || !size) 568 if (!phys_addr || !size)
582 return -EINVAL; 569 return -EINVAL;
583 570
584 sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size); 571 sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
585 if (!sb) { 572 if (!sb) {
586 printk(KERN_WARNING PREFIX "Unable to map SBF\n"); 573 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
587 return -ENODEV; 574 return -ENODEV;
588 } 575 }
589 576
590 sbf_port = sb->sbf_cmos; /* Save CMOS port */ 577 sbf_port = sb->sbf_cmos; /* Save CMOS port */
591 578
592 return 0; 579 return 0;
593} 580}
594 581
595
596#ifdef CONFIG_HPET_TIMER 582#ifdef CONFIG_HPET_TIMER
597 583
598static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) 584static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
@@ -602,7 +588,7 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
602 if (!phys || !size) 588 if (!phys || !size)
603 return -EINVAL; 589 return -EINVAL;
604 590
605 hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size); 591 hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
606 if (!hpet_tbl) { 592 if (!hpet_tbl) {
607 printk(KERN_WARNING PREFIX "Unable to map HPET\n"); 593 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
608 return -ENODEV; 594 return -ENODEV;
@@ -613,22 +599,21 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
613 "memory.\n"); 599 "memory.\n");
614 return -1; 600 return -1;
615 } 601 }
616
617#ifdef CONFIG_X86_64 602#ifdef CONFIG_X86_64
618 vxtime.hpet_address = hpet_tbl->addr.addrl | 603 vxtime.hpet_address = hpet_tbl->addr.addrl |
619 ((long) hpet_tbl->addr.addrh << 32); 604 ((long)hpet_tbl->addr.addrh << 32);
620 605
621 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 606 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
622 hpet_tbl->id, vxtime.hpet_address); 607 hpet_tbl->id, vxtime.hpet_address);
623#else /* X86 */ 608#else /* X86 */
624 { 609 {
625 extern unsigned long hpet_address; 610 extern unsigned long hpet_address;
626 611
627 hpet_address = hpet_tbl->addr.addrl; 612 hpet_address = hpet_tbl->addr.addrl;
628 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 613 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
629 hpet_tbl->id, hpet_address); 614 hpet_tbl->id, hpet_address);
630 } 615 }
631#endif /* X86 */ 616#endif /* X86 */
632 617
633 return 0; 618 return 0;
634} 619}
@@ -644,12 +629,11 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
644{ 629{
645 struct fadt_descriptor_rev2 *fadt = NULL; 630 struct fadt_descriptor_rev2 *fadt = NULL;
646 631
647 fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); 632 fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
648 if(!fadt) { 633 if (!fadt) {
649 printk(KERN_WARNING PREFIX "Unable to map FADT\n"); 634 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
650 return 0; 635 return 0;
651 } 636 }
652
653#ifdef CONFIG_ACPI_INTERPRETER 637#ifdef CONFIG_ACPI_INTERPRETER
654 /* initialize sci_int early for INT_SRC_OVR MADT parsing */ 638 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
655 acpi_fadt.sci_int = fadt->sci_int; 639 acpi_fadt.sci_int = fadt->sci_int;
@@ -658,14 +642,16 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
658#ifdef CONFIG_ACPI_BUS 642#ifdef CONFIG_ACPI_BUS
659 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ 643 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
660 acpi_fadt.revision = fadt->revision; 644 acpi_fadt.revision = fadt->revision;
661 acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode; 645 acpi_fadt.force_apic_physical_destination_mode =
646 fadt->force_apic_physical_destination_mode;
662#endif 647#endif
663 648
664#ifdef CONFIG_X86_PM_TIMER 649#ifdef CONFIG_X86_PM_TIMER
665 /* detect the location of the ACPI PM Timer */ 650 /* detect the location of the ACPI PM Timer */
666 if (fadt->revision >= FADT2_REVISION_ID) { 651 if (fadt->revision >= FADT2_REVISION_ID) {
667 /* FADT rev. 2 */ 652 /* FADT rev. 2 */
668 if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) 653 if (fadt->xpm_tmr_blk.address_space_id !=
654 ACPI_ADR_SPACE_SYSTEM_IO)
669 return 0; 655 return 0;
670 656
671 pmtmr_ioport = fadt->xpm_tmr_blk.address; 657 pmtmr_ioport = fadt->xpm_tmr_blk.address;
@@ -674,16 +660,15 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
674 pmtmr_ioport = fadt->V1_pm_tmr_blk; 660 pmtmr_ioport = fadt->V1_pm_tmr_blk;
675 } 661 }
676 if (pmtmr_ioport) 662 if (pmtmr_ioport)
677 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport); 663 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
664 pmtmr_ioport);
678#endif 665#endif
679 return 0; 666 return 0;
680} 667}
681 668
682 669unsigned long __init acpi_find_rsdp(void)
683unsigned long __init
684acpi_find_rsdp (void)
685{ 670{
686 unsigned long rsdp_phys = 0; 671 unsigned long rsdp_phys = 0;
687 672
688 if (efi_enabled) { 673 if (efi_enabled) {
689 if (efi.acpi20) 674 if (efi.acpi20)
@@ -695,9 +680,9 @@ acpi_find_rsdp (void)
695 * Scan memory looking for the RSDP signature. First search EBDA (low 680 * Scan memory looking for the RSDP signature. First search EBDA (low
696 * memory) paragraphs and then search upper memory (E0000-FFFFF). 681 * memory) paragraphs and then search upper memory (E0000-FFFFF).
697 */ 682 */
698 rsdp_phys = acpi_scan_rsdp (0, 0x400); 683 rsdp_phys = acpi_scan_rsdp(0, 0x400);
699 if (!rsdp_phys) 684 if (!rsdp_phys)
700 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000); 685 rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
701 686
702 return rsdp_phys; 687 return rsdp_phys;
703} 688}
@@ -707,8 +692,7 @@ acpi_find_rsdp (void)
707 * Parse LAPIC entries in MADT 692 * Parse LAPIC entries in MADT
708 * returns 0 on success, < 0 on error 693 * returns 0 on success, < 0 on error
709 */ 694 */
710static int __init 695static int __init acpi_parse_madt_lapic_entries(void)
711acpi_parse_madt_lapic_entries(void)
712{ 696{
713 int count; 697 int count;
714 698
@@ -717,28 +701,31 @@ acpi_parse_madt_lapic_entries(void)
717 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). 701 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
718 */ 702 */
719 703
720 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0); 704 count =
705 acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
706 acpi_parse_lapic_addr_ovr, 0);
721 if (count < 0) { 707 if (count < 0) {
722 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); 708 printk(KERN_ERR PREFIX
709 "Error parsing LAPIC address override entry\n");
723 return count; 710 return count;
724 } 711 }
725 712
726 mp_register_lapic_address(acpi_lapic_addr); 713 mp_register_lapic_address(acpi_lapic_addr);
727 714
728 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic, 715 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
729 MAX_APICS); 716 MAX_APICS);
730 if (!count) { 717 if (!count) {
731 printk(KERN_ERR PREFIX "No LAPIC entries present\n"); 718 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
732 /* TBD: Cleanup to allow fallback to MPS */ 719 /* TBD: Cleanup to allow fallback to MPS */
733 return -ENODEV; 720 return -ENODEV;
734 } 721 } else if (count < 0) {
735 else if (count < 0) {
736 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); 722 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
737 /* TBD: Cleanup to allow fallback to MPS */ 723 /* TBD: Cleanup to allow fallback to MPS */
738 return count; 724 return count;
739 } 725 }
740 726
741 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); 727 count =
728 acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
742 if (count < 0) { 729 if (count < 0) {
743 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 730 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
744 /* TBD: Cleanup to allow fallback to MPS */ 731 /* TBD: Cleanup to allow fallback to MPS */
@@ -746,15 +733,14 @@ acpi_parse_madt_lapic_entries(void)
746 } 733 }
747 return 0; 734 return 0;
748} 735}
749#endif /* CONFIG_X86_LOCAL_APIC */ 736#endif /* CONFIG_X86_LOCAL_APIC */
750 737
751#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) 738#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
752/* 739/*
753 * Parse IOAPIC related entries in MADT 740 * Parse IOAPIC related entries in MADT
754 * returns 0 on success, < 0 on error 741 * returns 0 on success, < 0 on error
755 */ 742 */
756static int __init 743static int __init acpi_parse_madt_ioapic_entries(void)
757acpi_parse_madt_ioapic_entries(void)
758{ 744{
759 int count; 745 int count;
760 746
@@ -766,30 +752,34 @@ acpi_parse_madt_ioapic_entries(void)
766 */ 752 */
767 if (acpi_disabled || acpi_noirq) { 753 if (acpi_disabled || acpi_noirq) {
768 return -ENODEV; 754 return -ENODEV;
769 } 755 }
770 756
771 /* 757 /*
772 * if "noapic" boot option, don't look for IO-APICs 758 * if "noapic" boot option, don't look for IO-APICs
773 */ 759 */
774 if (skip_ioapic_setup) { 760 if (skip_ioapic_setup) {
775 printk(KERN_INFO PREFIX "Skipping IOAPIC probe " 761 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
776 "due to 'noapic' option.\n"); 762 "due to 'noapic' option.\n");
777 return -ENODEV; 763 return -ENODEV;
778 } 764 }
779 765
780 count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS); 766 count =
767 acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
768 MAX_IO_APICS);
781 if (!count) { 769 if (!count) {
782 printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); 770 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
783 return -ENODEV; 771 return -ENODEV;
784 } 772 } else if (count < 0) {
785 else if (count < 0) {
786 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); 773 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
787 return count; 774 return count;
788 } 775 }
789 776
790 count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS); 777 count =
778 acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
779 NR_IRQ_VECTORS);
791 if (count < 0) { 780 if (count < 0) {
792 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); 781 printk(KERN_ERR PREFIX
782 "Error parsing interrupt source overrides entry\n");
793 /* TBD: Cleanup to allow fallback to MPS */ 783 /* TBD: Cleanup to allow fallback to MPS */
794 return count; 784 return count;
795 } 785 }
@@ -804,7 +794,9 @@ acpi_parse_madt_ioapic_entries(void)
804 /* Fill in identity legacy mapings where no override */ 794 /* Fill in identity legacy mapings where no override */
805 mp_config_acpi_legacy_irqs(); 795 mp_config_acpi_legacy_irqs();
806 796
807 count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS); 797 count =
798 acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
799 NR_IRQ_VECTORS);
808 if (count < 0) { 800 if (count < 0) {
809 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 801 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
810 /* TBD: Cleanup to allow fallback to MPS */ 802 /* TBD: Cleanup to allow fallback to MPS */
@@ -818,11 +810,9 @@ static inline int acpi_parse_madt_ioapic_entries(void)
818{ 810{
819 return -1; 811 return -1;
820} 812}
821#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ 813#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
822
823 814
824static void __init 815static void __init acpi_process_madt(void)
825acpi_process_madt(void)
826{ 816{
827#ifdef CONFIG_X86_LOCAL_APIC 817#ifdef CONFIG_X86_LOCAL_APIC
828 int count, error; 818 int count, error;
@@ -854,7 +844,8 @@ acpi_process_madt(void)
854 /* 844 /*
855 * Dell Precision Workstation 410, 610 come here. 845 * Dell Precision Workstation 410, 610 come here.
856 */ 846 */
857 printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n"); 847 printk(KERN_ERR PREFIX
848 "Invalid BIOS MADT, disabling ACPI\n");
858 disable_acpi(); 849 disable_acpi();
859 } 850 }
860 } 851 }
@@ -891,7 +882,7 @@ static int __init disable_acpi_pci(struct dmi_system_id *d)
891static int __init dmi_disable_acpi(struct dmi_system_id *d) 882static int __init dmi_disable_acpi(struct dmi_system_id *d)
892{ 883{
893 if (!acpi_force) { 884 if (!acpi_force) {
894 printk(KERN_NOTICE "%s detected: acpi off\n",d->ident); 885 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
895 disable_acpi(); 886 disable_acpi();
896 } else { 887 } else {
897 printk(KERN_NOTICE 888 printk(KERN_NOTICE
@@ -906,7 +897,8 @@ static int __init dmi_disable_acpi(struct dmi_system_id *d)
906static int __init force_acpi_ht(struct dmi_system_id *d) 897static int __init force_acpi_ht(struct dmi_system_id *d)
907{ 898{
908 if (!acpi_force) { 899 if (!acpi_force) {
909 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident); 900 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
901 d->ident);
910 disable_acpi(); 902 disable_acpi();
911 acpi_ht = 1; 903 acpi_ht = 1;
912 } else { 904 } else {
@@ -925,155 +917,157 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
925 * Boxes that need ACPI disabled 917 * Boxes that need ACPI disabled
926 */ 918 */
927 { 919 {
928 .callback = dmi_disable_acpi, 920 .callback = dmi_disable_acpi,
929 .ident = "IBM Thinkpad", 921 .ident = "IBM Thinkpad",
930 .matches = { 922 .matches = {
931 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 923 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
932 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), 924 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
933 }, 925 },
934 }, 926 },
935 927
936 /* 928 /*
937 * Boxes that need acpi=ht 929 * Boxes that need acpi=ht
938 */ 930 */
939 { 931 {
940 .callback = force_acpi_ht, 932 .callback = force_acpi_ht,
941 .ident = "FSC Primergy T850", 933 .ident = "FSC Primergy T850",
942 .matches = { 934 .matches = {
943 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 935 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
944 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), 936 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
945 }, 937 },
946 }, 938 },
947 { 939 {
948 .callback = force_acpi_ht, 940 .callback = force_acpi_ht,
949 .ident = "DELL GX240", 941 .ident = "DELL GX240",
950 .matches = { 942 .matches = {
951 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"), 943 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
952 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"), 944 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
953 }, 945 },
954 }, 946 },
955 { 947 {
956 .callback = force_acpi_ht, 948 .callback = force_acpi_ht,
957 .ident = "HP VISUALIZE NT Workstation", 949 .ident = "HP VISUALIZE NT Workstation",
958 .matches = { 950 .matches = {
959 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 951 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
960 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), 952 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
961 }, 953 },
962 }, 954 },
963 { 955 {
964 .callback = force_acpi_ht, 956 .callback = force_acpi_ht,
965 .ident = "Compaq Workstation W8000", 957 .ident = "Compaq Workstation W8000",
966 .matches = { 958 .matches = {
967 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), 959 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
968 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), 960 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
969 }, 961 },
970 }, 962 },
971 { 963 {
972 .callback = force_acpi_ht, 964 .callback = force_acpi_ht,
973 .ident = "ASUS P4B266", 965 .ident = "ASUS P4B266",
974 .matches = { 966 .matches = {
975 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 967 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
976 DMI_MATCH(DMI_BOARD_NAME, "P4B266"), 968 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
977 }, 969 },
978 }, 970 },
979 { 971 {
980 .callback = force_acpi_ht, 972 .callback = force_acpi_ht,
981 .ident = "ASUS P2B-DS", 973 .ident = "ASUS P2B-DS",
982 .matches = { 974 .matches = {
983 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 975 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
984 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"), 976 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
985 }, 977 },
986 }, 978 },
987 { 979 {
988 .callback = force_acpi_ht, 980 .callback = force_acpi_ht,
989 .ident = "ASUS CUR-DLS", 981 .ident = "ASUS CUR-DLS",
990 .matches = { 982 .matches = {
991 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 983 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
992 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), 984 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
993 }, 985 },
994 }, 986 },
995 { 987 {
996 .callback = force_acpi_ht, 988 .callback = force_acpi_ht,
997 .ident = "ABIT i440BX-W83977", 989 .ident = "ABIT i440BX-W83977",
998 .matches = { 990 .matches = {
999 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"), 991 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1000 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), 992 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1001 }, 993 },
1002 }, 994 },
1003 { 995 {
1004 .callback = force_acpi_ht, 996 .callback = force_acpi_ht,
1005 .ident = "IBM Bladecenter", 997 .ident = "IBM Bladecenter",
1006 .matches = { 998 .matches = {
1007 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 999 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1008 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), 1000 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1009 }, 1001 },
1010 }, 1002 },
1011 { 1003 {
1012 .callback = force_acpi_ht, 1004 .callback = force_acpi_ht,
1013 .ident = "IBM eServer xSeries 360", 1005 .ident = "IBM eServer xSeries 360",
1014 .matches = { 1006 .matches = {
1015 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1007 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1016 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), 1008 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1017 }, 1009 },
1018 }, 1010 },
1019 { 1011 {
1020 .callback = force_acpi_ht, 1012 .callback = force_acpi_ht,
1021 .ident = "IBM eserver xSeries 330", 1013 .ident = "IBM eserver xSeries 330",
1022 .matches = { 1014 .matches = {
1023 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1015 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1024 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), 1016 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1025 }, 1017 },
1026 }, 1018 },
1027 { 1019 {
1028 .callback = force_acpi_ht, 1020 .callback = force_acpi_ht,
1029 .ident = "IBM eserver xSeries 440", 1021 .ident = "IBM eserver xSeries 440",
1030 .matches = { 1022 .matches = {
1031 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1023 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1032 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), 1024 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1033 }, 1025 },
1034 }, 1026 },
1035 1027
1036#ifdef CONFIG_ACPI_PCI 1028#ifdef CONFIG_ACPI_PCI
1037 /* 1029 /*
1038 * Boxes that need ACPI PCI IRQ routing disabled 1030 * Boxes that need ACPI PCI IRQ routing disabled
1039 */ 1031 */
1040 { 1032 {
1041 .callback = disable_acpi_irq, 1033 .callback = disable_acpi_irq,
1042 .ident = "ASUS A7V", 1034 .ident = "ASUS A7V",
1043 .matches = { 1035 .matches = {
1044 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), 1036 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1045 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"), 1037 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1046 /* newer BIOS, Revision 1011, does work */ 1038 /* newer BIOS, Revision 1011, does work */
1047 DMI_MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"), 1039 DMI_MATCH(DMI_BIOS_VERSION,
1048 }, 1040 "ASUS A7V ACPI BIOS Revision 1007"),
1049 }, 1041 },
1042 },
1050 1043
1051 /* 1044 /*
1052 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled 1045 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1053 */ 1046 */
1054 { /* _BBN 0 bug */ 1047 { /* _BBN 0 bug */
1055 .callback = disable_acpi_pci, 1048 .callback = disable_acpi_pci,
1056 .ident = "ASUS PR-DLS", 1049 .ident = "ASUS PR-DLS",
1057 .matches = { 1050 .matches = {
1058 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 1051 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1059 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), 1052 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1060 DMI_MATCH(DMI_BIOS_VERSION, "ASUS PR-DLS ACPI BIOS Revision 1010"), 1053 DMI_MATCH(DMI_BIOS_VERSION,
1061 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") 1054 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1062 }, 1055 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1063 }, 1056 },
1057 },
1064 { 1058 {
1065 .callback = disable_acpi_pci, 1059 .callback = disable_acpi_pci,
1066 .ident = "Acer TravelMate 36x Laptop", 1060 .ident = "Acer TravelMate 36x Laptop",
1067 .matches = { 1061 .matches = {
1068 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 1062 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1069 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), 1063 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1070 }, 1064 },
1071 }, 1065 },
1072#endif 1066#endif
1073 { } 1067 {}
1074}; 1068};
1075 1069
1076#endif /* __i386__ */ 1070#endif /* __i386__ */
1077 1071
1078/* 1072/*
1079 * acpi_boot_table_init() and acpi_boot_init() 1073 * acpi_boot_table_init() and acpi_boot_init()
@@ -1098,8 +1092,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1098 * !0: failure 1092 * !0: failure
1099 */ 1093 */
1100 1094
1101int __init 1095int __init acpi_boot_table_init(void)
1102acpi_boot_table_init(void)
1103{ 1096{
1104 int error; 1097 int error;
1105 1098
@@ -1112,7 +1105,7 @@ acpi_boot_table_init(void)
1112 * One exception: acpi=ht continues far enough to enumerate LAPICs 1105 * One exception: acpi=ht continues far enough to enumerate LAPICs
1113 */ 1106 */
1114 if (acpi_disabled && !acpi_ht) 1107 if (acpi_disabled && !acpi_ht)
1115 return 1; 1108 return 1;
1116 1109
1117 /* 1110 /*
1118 * Initialize the ACPI boot-time table parser. 1111 * Initialize the ACPI boot-time table parser.
@@ -1122,7 +1115,6 @@ acpi_boot_table_init(void)
1122 disable_acpi(); 1115 disable_acpi();
1123 return error; 1116 return error;
1124 } 1117 }
1125
1126#ifdef __i386__ 1118#ifdef __i386__
1127 check_acpi_pci(); 1119 check_acpi_pci();
1128#endif 1120#endif
@@ -1146,7 +1138,6 @@ acpi_boot_table_init(void)
1146 return 0; 1138 return 0;
1147} 1139}
1148 1140
1149
1150int __init acpi_boot_init(void) 1141int __init acpi_boot_init(void)
1151{ 1142{
1152 /* 1143 /*
@@ -1154,7 +1145,7 @@ int __init acpi_boot_init(void)
1154 * One exception: acpi=ht continues far enough to enumerate LAPICs 1145 * One exception: acpi=ht continues far enough to enumerate LAPICs
1155 */ 1146 */
1156 if (acpi_disabled && !acpi_ht) 1147 if (acpi_disabled && !acpi_ht)
1157 return 1; 1148 return 1;
1158 1149
1159 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); 1150 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
1160 1151
@@ -1172,4 +1163,3 @@ int __init acpi_boot_init(void)
1172 1163
1173 return 0; 1164 return 0;
1174} 1165}
1175
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/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 d362ecf5381b..f3046bdd4b14 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
@@ -137,7 +138,7 @@ acpi_get_sysname (void)
137 138
138/* Array to record platform interrupt vectors for generic interrupt routing. */ 139/* Array to record platform interrupt vectors for generic interrupt routing. */
139int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { 140int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = {
140 [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 141 [0...ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1
141}; 142};
142 143
143enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; 144enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
@@ -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,40 +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
566/* 566/*
567 * success: return IRQ number (>=0) 567 * success: return IRQ number (>=0)
568 * failure: return < 0 568 * failure: return < 0
569 */ 569 */
570int 570int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
571acpi_register_gsi (u32 gsi, int edge_level, int active_high_low)
572{ 571{
573 if (has_8259 && gsi < 16) 572 if (has_8259 && gsi < 16)
574 return isa_irq_to_vector(gsi); 573 return isa_irq_to_vector(gsi);
575 574
576 return iosapic_register_intr(gsi, 575 return iosapic_register_intr(gsi,
577 (active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 576 (active_high_low ==
578 (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);
579} 582}
583
580EXPORT_SYMBOL(acpi_register_gsi); 584EXPORT_SYMBOL(acpi_register_gsi);
581 585
582#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 586#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
583void 587void acpi_unregister_gsi(u32 gsi)
584acpi_unregister_gsi (u32 gsi)
585{ 588{
586 iosapic_unregister_intr(gsi); 589 iosapic_unregister_intr(gsi);
587} 590}
591
588EXPORT_SYMBOL(acpi_unregister_gsi); 592EXPORT_SYMBOL(acpi_unregister_gsi);
589#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ 593#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
590 594
591static int __init 595static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
592acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
593{ 596{
594 struct acpi_table_header *fadt_header; 597 struct acpi_table_header *fadt_header;
595 struct fadt_descriptor_rev2 *fadt; 598 struct fadt_descriptor_rev2 *fadt;
@@ -597,11 +600,11 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
597 if (!phys_addr || !size) 600 if (!phys_addr || !size)
598 return -EINVAL; 601 return -EINVAL;
599 602
600 fadt_header = (struct acpi_table_header *) __va(phys_addr); 603 fadt_header = (struct acpi_table_header *)__va(phys_addr);
601 if (fadt_header->revision != 3) 604 if (fadt_header->revision != 3)
602 return -ENODEV; /* Only deal with ACPI 2.0 FADT */ 605 return -ENODEV; /* Only deal with ACPI 2.0 FADT */
603 606
604 fadt = (struct fadt_descriptor_rev2 *) fadt_header; 607 fadt = (struct fadt_descriptor_rev2 *)fadt_header;
605 608
606 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER)) 609 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
607 acpi_kbd_controller_present = 0; 610 acpi_kbd_controller_present = 0;
@@ -613,22 +616,19 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
613 return 0; 616 return 0;
614} 617}
615 618
616 619unsigned long __init acpi_find_rsdp(void)
617unsigned long __init
618acpi_find_rsdp (void)
619{ 620{
620 unsigned long rsdp_phys = 0; 621 unsigned long rsdp_phys = 0;
621 622
622 if (efi.acpi20) 623 if (efi.acpi20)
623 rsdp_phys = __pa(efi.acpi20); 624 rsdp_phys = __pa(efi.acpi20);
624 else if (efi.acpi) 625 else if (efi.acpi)
625 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");
626 return rsdp_phys; 628 return rsdp_phys;
627} 629}
628 630
629 631int __init acpi_boot_init(void)
630int __init
631acpi_boot_init (void)
632{ 632{
633 633
634 /* 634 /*
@@ -646,31 +646,43 @@ acpi_boot_init (void)
646 646
647 /* Local APIC */ 647 /* Local APIC */
648 648
649 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) 649 if (acpi_table_parse_madt
650 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");
651 653
652 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)
653 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");
654 658
655 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)
656 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 661 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
657 662
658 /* I/O APIC */ 663 /* I/O APIC */
659 664
660 if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) 665 if (acpi_table_parse_madt
661 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");
662 669
663 /* System-Level Interrupt Routing */ 670 /* System-Level Interrupt Routing */
664 671
665 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
666 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");
667 677
668 if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) 678 if (acpi_table_parse_madt
669 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");
670 682
671 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)
672 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 684 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
673 skip_madt: 685 skip_madt:
674 686
675 /* 687 /*
676 * FADT says whether a legacy keyboard controller is present. 688 * FADT says whether a legacy keyboard controller is present.
@@ -685,8 +697,9 @@ acpi_boot_init (void)
685 if (available_cpus == 0) { 697 if (available_cpus == 0) {
686 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); 698 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
687 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id()); 699 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
688 smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id(); 700 smp_boot_data.cpu_phys_id[available_cpus] =
689 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? */
690 } 703 }
691 smp_boot_data.cpu_count = available_cpus; 704 smp_boot_data.cpu_count = available_cpus;
692 705
@@ -695,8 +708,10 @@ acpi_boot_init (void)
695 if (srat_num_cpus == 0) { 708 if (srat_num_cpus == 0) {
696 int cpu, i = 1; 709 int cpu, i = 1;
697 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) 710 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
698 if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id()) 711 if (smp_boot_data.cpu_phys_id[cpu] !=
699 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];
700 } 715 }
701# endif 716# endif
702#endif 717#endif
@@ -704,12 +719,12 @@ acpi_boot_init (void)
704 build_cpu_to_node_map(); 719 build_cpu_to_node_map();
705#endif 720#endif
706 /* Make boot-up look pretty */ 721 /* Make boot-up look pretty */
707 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);
708 return 0; 724 return 0;
709} 725}
710 726
711int 727int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
712acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
713{ 728{
714 int vector; 729 int vector;
715 730
@@ -730,11 +745,10 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
730 */ 745 */
731#ifdef CONFIG_ACPI_HOTPLUG_CPU 746#ifdef CONFIG_ACPI_HOTPLUG_CPU
732static 747static
733int 748int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
734acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
735{ 749{
736#ifdef CONFIG_ACPI_NUMA 750#ifdef CONFIG_ACPI_NUMA
737 int pxm_id; 751 int pxm_id;
738 752
739 pxm_id = acpi_get_pxm(handle); 753 pxm_id = acpi_get_pxm(handle);
740 754
@@ -742,31 +756,28 @@ acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
742 * Assuming that the container driver would have set the proximity 756 * Assuming that the container driver would have set the proximity
743 * 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
744 */ 758 */
745 node_cpuid[cpu].nid = (pxm_id < 0) ? 0: 759 node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id];
746 pxm_to_nid_map[pxm_id];
747 760
748 node_cpuid[cpu].phys_id = physid; 761 node_cpuid[cpu].phys_id = physid;
749#endif 762#endif
750 return(0); 763 return (0);
751} 764}
752 765
753 766int acpi_map_lsapic(acpi_handle handle, int *pcpu)
754int
755acpi_map_lsapic(acpi_handle handle, int *pcpu)
756{ 767{
757 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 768 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
758 union acpi_object *obj; 769 union acpi_object *obj;
759 struct acpi_table_lsapic *lsapic; 770 struct acpi_table_lsapic *lsapic;
760 cpumask_t tmp_map; 771 cpumask_t tmp_map;
761 long physid; 772 long physid;
762 int cpu; 773 int cpu;
763 774
764 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 775 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
765 return -EINVAL; 776 return -EINVAL;
766 777
767 if (!buffer.length || !buffer.pointer) 778 if (!buffer.length || !buffer.pointer)
768 return -EINVAL; 779 return -EINVAL;
769 780
770 obj = buffer.pointer; 781 obj = buffer.pointer;
771 if (obj->type != ACPI_TYPE_BUFFER || 782 if (obj->type != ACPI_TYPE_BUFFER ||
772 obj->buffer.length < sizeof(*lsapic)) { 783 obj->buffer.length < sizeof(*lsapic)) {
@@ -782,7 +793,7 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
782 return -EINVAL; 793 return -EINVAL;
783 } 794 }
784 795
785 physid = ((lsapic->id <<8) | (lsapic->eid)); 796 physid = ((lsapic->id << 8) | (lsapic->eid));
786 797
787 acpi_os_free(buffer.pointer); 798 acpi_os_free(buffer.pointer);
788 buffer.length = ACPI_ALLOCATE_BUFFER; 799 buffer.length = ACPI_ALLOCATE_BUFFER;
@@ -790,50 +801,49 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
790 801
791 cpus_complement(tmp_map, cpu_present_map); 802 cpus_complement(tmp_map, cpu_present_map);
792 cpu = first_cpu(tmp_map); 803 cpu = first_cpu(tmp_map);
793 if(cpu >= NR_CPUS) 804 if (cpu >= NR_CPUS)
794 return -EINVAL; 805 return -EINVAL;
795 806
796 acpi_map_cpu2node(handle, cpu, physid); 807 acpi_map_cpu2node(handle, cpu, physid);
797 808
798 cpu_set(cpu, cpu_present_map); 809 cpu_set(cpu, cpu_present_map);
799 ia64_cpu_to_sapicid[cpu] = physid; 810 ia64_cpu_to_sapicid[cpu] = physid;
800 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];
801 812
802 *pcpu = cpu; 813 *pcpu = cpu;
803 return(0); 814 return (0);
804} 815}
805EXPORT_SYMBOL(acpi_map_lsapic);
806 816
817EXPORT_SYMBOL(acpi_map_lsapic);
807 818
808int 819int acpi_unmap_lsapic(int cpu)
809acpi_unmap_lsapic(int cpu)
810{ 820{
811 int i; 821 int i;
812 822
813 for (i=0; i<MAX_SAPICS; i++) { 823 for (i = 0; i < MAX_SAPICS; i++) {
814 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) { 824 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) {
815 ia64_acpiid_to_sapicid[i] = -1; 825 ia64_acpiid_to_sapicid[i] = -1;
816 break; 826 break;
817 } 827 }
818 } 828 }
819 ia64_cpu_to_sapicid[cpu] = -1; 829 ia64_cpu_to_sapicid[cpu] = -1;
820 cpu_clear(cpu,cpu_present_map); 830 cpu_clear(cpu, cpu_present_map);
821 831
822#ifdef CONFIG_ACPI_NUMA 832#ifdef CONFIG_ACPI_NUMA
823 /* NUMA specific cleanup's */ 833 /* NUMA specific cleanup's */
824#endif 834#endif
825 835
826 return(0); 836 return (0);
827} 837}
838
828EXPORT_SYMBOL(acpi_unmap_lsapic); 839EXPORT_SYMBOL(acpi_unmap_lsapic);
829#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 840#endif /* CONFIG_ACPI_HOTPLUG_CPU */
830
831 841
832#ifdef CONFIG_ACPI_NUMA 842#ifdef CONFIG_ACPI_NUMA
833acpi_status __devinit 843acpi_status __devinit
834acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) 844acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
835{ 845{
836 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 846 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
837 union acpi_object *obj; 847 union acpi_object *obj;
838 struct acpi_table_iosapic *iosapic; 848 struct acpi_table_iosapic *iosapic;
839 unsigned int gsi_base; 849 unsigned int gsi_base;
@@ -882,10 +892,9 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
882 map_iosapic_to_node(gsi_base, node); 892 map_iosapic_to_node(gsi_base, node);
883 return AE_OK; 893 return AE_OK;
884} 894}
885#endif /* CONFIG_NUMA */ 895#endif /* CONFIG_NUMA */
886 896
887int 897int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
888acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
889{ 898{
890 int err; 899 int err;
891 900
@@ -894,17 +903,18 @@ acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
894 903
895#if CONFIG_ACPI_NUMA 904#if CONFIG_ACPI_NUMA
896 acpi_map_iosapic(handle, 0, NULL, NULL); 905 acpi_map_iosapic(handle, 0, NULL, NULL);
897#endif /* CONFIG_ACPI_NUMA */ 906#endif /* CONFIG_ACPI_NUMA */
898 907
899 return 0; 908 return 0;
900} 909}
910
901EXPORT_SYMBOL(acpi_register_ioapic); 911EXPORT_SYMBOL(acpi_register_ioapic);
902 912
903int 913int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
904acpi_unregister_ioapic (acpi_handle handle, u32 gsi_base)
905{ 914{
906 return iosapic_remove(gsi_base); 915 return iosapic_remove(gsi_base);
907} 916}
917
908EXPORT_SYMBOL(acpi_unregister_ioapic); 918EXPORT_SYMBOL(acpi_unregister_ioapic);
909 919
910#endif /* CONFIG_ACPI_BOOT */ 920#endif /* CONFIG_ACPI_BOOT */
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/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 bcd1d472b90f..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,20 +74,17 @@ 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 struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; 80 struct acpi_init_walk_info *info =
90 struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; 81 (struct acpi_init_walk_info *)context;
91 acpi_object_type type; 82 struct acpi_namespace_node *node =
92 acpi_status status; 83 (struct acpi_namespace_node *)obj_handle;
93 84 acpi_object_type type;
94 85 acpi_status status;
95 ACPI_FUNCTION_NAME ("ds_init_one_object");
96 86
87 ACPI_FUNCTION_NAME("ds_init_one_object");
97 88
98 /* 89 /*
99 * We are only interested in NS nodes owned by the table that 90 * We are only interested in NS nodes owned by the table that
@@ -107,23 +98,23 @@ 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 /* 120 /*
@@ -131,7 +122,7 @@ acpi_ds_init_one_object (
131 * the entire pathname 122 * the entire pathname
132 */ 123 */
133 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 124 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
134 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 125 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
135 } 126 }
136 127
137 /* 128 /*
@@ -148,12 +139,13 @@ acpi_ds_init_one_object (
148 * Always parse methods to detect errors, we will delete 139 * Always parse methods to detect errors, we will delete
149 * the parse tree below 140 * the parse tree below
150 */ 141 */
151 status = acpi_ds_parse_method (obj_handle); 142 status = acpi_ds_parse_method(obj_handle);
152 if (ACPI_FAILURE (status)) { 143 if (ACPI_FAILURE(status)) {
153 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
154 "\n+Method %p [%4.4s] - parse failure, %s\n", 145 "\n+Method %p [%4.4s] - parse failure, %s\n",
155 obj_handle, acpi_ut_get_node_name (obj_handle), 146 obj_handle,
156 acpi_format_exception (status))); 147 acpi_ut_get_node_name(obj_handle),
148 acpi_format_exception(status)));
157 149
158 /* This parse failed, but we will continue parsing more methods */ 150 /* This parse failed, but we will continue parsing more methods */
159 } 151 }
@@ -161,13 +153,11 @@ acpi_ds_init_one_object (
161 info->method_count++; 153 info->method_count++;
162 break; 154 break;
163 155
164
165 case ACPI_TYPE_DEVICE: 156 case ACPI_TYPE_DEVICE:
166 157
167 info->device_count++; 158 info->device_count++;
168 break; 159 break;
169 160
170
171 default: 161 default:
172 break; 162 break;
173 } 163 }
@@ -179,7 +169,6 @@ acpi_ds_init_one_object (
179 return (AE_OK); 169 return (AE_OK);
180} 170}
181 171
182
183/******************************************************************************* 172/*******************************************************************************
184 * 173 *
185 * FUNCTION: acpi_ds_initialize_objects 174 * FUNCTION: acpi_ds_initialize_objects
@@ -195,45 +184,43 @@ acpi_ds_init_one_object (
195 ******************************************************************************/ 184 ******************************************************************************/
196 185
197acpi_status 186acpi_status
198acpi_ds_initialize_objects ( 187acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
199 struct acpi_table_desc *table_desc, 188 struct acpi_namespace_node * start_node)
200 struct acpi_namespace_node *start_node)
201{ 189{
202 acpi_status status; 190 acpi_status status;
203 struct acpi_init_walk_info info; 191 struct acpi_init_walk_info info;
204
205 192
206 ACPI_FUNCTION_TRACE ("ds_initialize_objects"); 193 ACPI_FUNCTION_TRACE("ds_initialize_objects");
207 194
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:"));
208 198
209 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 199 info.method_count = 0;
210 "**** Starting initialization of namespace objects ****\n"));
211 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
212
213 info.method_count = 0;
214 info.op_region_count = 0; 200 info.op_region_count = 0;
215 info.object_count = 0; 201 info.object_count = 0;
216 info.device_count = 0; 202 info.device_count = 0;
217 info.table_desc = table_desc; 203 info.table_desc = table_desc;
218 204
219 /* Walk entire namespace from the supplied root */ 205 /* Walk entire namespace from the supplied root */
220 206
221 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,
222 acpi_ds_init_one_object, &info, NULL); 208 acpi_ds_init_one_object, &info, NULL);
223 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
224 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n", 210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
225 acpi_format_exception (status))); 211 acpi_format_exception(status)));
226 } 212 }
227 213
228 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 214 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
229 "\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",
230 table_desc->pointer->signature, table_desc->owner_id, info.object_count, 216 table_desc->pointer->signature,
231 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));
232 220
233 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 221 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
234 "%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));
235 224
236 return_ACPI_STATUS (AE_OK); 225 return_ACPI_STATUS(AE_OK);
237} 226}
238
239
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index e344c06ed33f..77fcfc3070db 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,10 +48,8 @@
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 *
@@ -67,45 +64,41 @@
67 * MUTEX: Assumes parser is locked 64 * MUTEX: Assumes parser is locked
68 * 65 *
69 ******************************************************************************/ 66 ******************************************************************************/
70 67acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
71acpi_status
72acpi_ds_parse_method (
73 struct acpi_namespace_node *node)
74{ 68{
75 acpi_status status; 69 acpi_status status;
76 union acpi_operand_object *obj_desc; 70 union acpi_operand_object *obj_desc;
77 union acpi_parse_object *op; 71 union acpi_parse_object *op;
78 struct acpi_walk_state *walk_state; 72 struct acpi_walk_state *walk_state;
79
80
81 ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", node);
82 73
74 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
83 75
84 /* Parameter Validation */ 76 /* Parameter Validation */
85 77
86 if (!node) { 78 if (!node) {
87 return_ACPI_STATUS (AE_NULL_ENTRY); 79 return_ACPI_STATUS(AE_NULL_ENTRY);
88 } 80 }
89 81
90 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n", 82 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
91 acpi_ut_get_node_name (node), node)); 83 "**** Parsing [%4.4s] **** named_obj=%p\n",
84 acpi_ut_get_node_name(node), node));
92 85
93 /* Extract the method object from the method Node */ 86 /* Extract the method object from the method Node */
94 87
95 obj_desc = acpi_ns_get_attached_object (node); 88 obj_desc = acpi_ns_get_attached_object(node);
96 if (!obj_desc) { 89 if (!obj_desc) {
97 return_ACPI_STATUS (AE_NULL_OBJECT); 90 return_ACPI_STATUS(AE_NULL_OBJECT);
98 } 91 }
99 92
100 /* 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 */
101 94
102 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && 95 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
103 (!obj_desc->method.semaphore)) { 96 (!obj_desc->method.semaphore)) {
104 status = acpi_os_create_semaphore (obj_desc->method.concurrency, 97 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
105 obj_desc->method.concurrency, 98 obj_desc->method.concurrency,
106 &obj_desc->method.semaphore); 99 &obj_desc->method.semaphore);
107 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
108 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
109 } 102 }
110 } 103 }
111 104
@@ -113,14 +106,14 @@ acpi_ds_parse_method (
113 * 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
114 * method tree 107 * method tree
115 */ 108 */
116 op = acpi_ps_alloc_op (AML_METHOD_OP); 109 op = acpi_ps_alloc_op(AML_METHOD_OP);
117 if (!op) { 110 if (!op) {
118 return_ACPI_STATUS (AE_NO_MEMORY); 111 return_ACPI_STATUS(AE_NO_MEMORY);
119 } 112 }
120 113
121 /* 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 */
122 115
123 acpi_ps_set_name (op, node->name.integer); 116 acpi_ps_set_name(op, node->name.integer);
124 op->common.node = node; 117 op->common.node = node;
125 118
126 /* 119 /*
@@ -128,25 +121,26 @@ acpi_ds_parse_method (
128 * objects (such as Operation Regions) can be created during the 121 * objects (such as Operation Regions) can be created during the
129 * first pass parse. 122 * first pass parse.
130 */ 123 */
131 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); 124 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
132 if (ACPI_FAILURE (status)) { 125 if (ACPI_FAILURE(status)) {
133 goto cleanup; 126 goto cleanup;
134 } 127 }
135 128
136 /* Create and initialize a new walk state */ 129 /* Create and initialize a new walk state */
137 130
138 walk_state = acpi_ds_create_walk_state ( 131 walk_state =
139 obj_desc->method.owner_id, NULL, NULL, NULL); 132 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
133 NULL);
140 if (!walk_state) { 134 if (!walk_state) {
141 status = AE_NO_MEMORY; 135 status = AE_NO_MEMORY;
142 goto cleanup2; 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 goto cleanup2; 144 goto cleanup2;
151 } 145 }
152 146
@@ -159,32 +153,31 @@ 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 goto cleanup2; 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 (node), node, op)); 163 acpi_ut_get_node_name(node), node, op));
170 164
171 /* 165 /*
172 * Delete the parse tree. We simply re-parse the method for every 166 * Delete the parse tree. We simply re-parse the method for every
173 * execution since there isn't much overhead (compared to keeping lots 167 * execution since there isn't much overhead (compared to keeping lots
174 * of parse trees around) 168 * of parse trees around)
175 */ 169 */
176 acpi_ns_delete_namespace_subtree (node); 170 acpi_ns_delete_namespace_subtree(node);
177 acpi_ns_delete_namespace_by_owner (obj_desc->method.owner_id); 171 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
178 172
179cleanup2: 173 cleanup2:
180 acpi_ut_release_owner_id (&obj_desc->method.owner_id); 174 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
181 175
182cleanup: 176 cleanup:
183 acpi_ps_delete_parse_tree (op); 177 acpi_ps_delete_parse_tree(op);
184 return_ACPI_STATUS (status); 178 return_ACPI_STATUS(status);
185} 179}
186 180
187
188/******************************************************************************* 181/*******************************************************************************
189 * 182 *
190 * FUNCTION: acpi_ds_begin_method_execution 183 * FUNCTION: acpi_ds_begin_method_execution
@@ -202,19 +195,16 @@ cleanup:
202 ******************************************************************************/ 195 ******************************************************************************/
203 196
204acpi_status 197acpi_status
205acpi_ds_begin_method_execution ( 198acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
206 struct acpi_namespace_node *method_node, 199 union acpi_operand_object *obj_desc,
207 union acpi_operand_object *obj_desc, 200 struct acpi_namespace_node *calling_method_node)
208 struct acpi_namespace_node *calling_method_node)
209{ 201{
210 acpi_status status = AE_OK; 202 acpi_status status = AE_OK;
211
212
213 ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node);
214 203
204 ACPI_FUNCTION_TRACE_PTR("ds_begin_method_execution", method_node);
215 205
216 if (!method_node) { 206 if (!method_node) {
217 return_ACPI_STATUS (AE_NULL_ENTRY); 207 return_ACPI_STATUS(AE_NULL_ENTRY);
218 } 208 }
219 209
220 /* 210 /*
@@ -231,8 +221,9 @@ acpi_ds_begin_method_execution (
231 * thread that is making recursive method calls. 221 * thread that is making recursive method calls.
232 */ 222 */
233 if (method_node == calling_method_node) { 223 if (method_node == calling_method_node) {
234 if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { 224 if (obj_desc->method.thread_count >=
235 return_ACPI_STATUS (AE_AML_METHOD_LIMIT); 225 obj_desc->method.concurrency) {
226 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
236 } 227 }
237 } 228 }
238 229
@@ -240,8 +231,9 @@ acpi_ds_begin_method_execution (
240 * Get a unit from the method semaphore. This releases the 231 * Get a unit from the method semaphore. This releases the
241 * interpreter if we block 232 * interpreter if we block
242 */ 233 */
243 status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore, 234 status =
244 ACPI_WAIT_FOREVER); 235 acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,
236 ACPI_WAIT_FOREVER);
245 } 237 }
246 238
247 /* 239 /*
@@ -249,10 +241,9 @@ acpi_ds_begin_method_execution (
249 * reentered one more time (even if it is the same thread) 241 * reentered one more time (even if it is the same thread)
250 */ 242 */
251 obj_desc->method.thread_count++; 243 obj_desc->method.thread_count++;
252 return_ACPI_STATUS (status); 244 return_ACPI_STATUS(status);
253} 245}
254 246
255
256/******************************************************************************* 247/*******************************************************************************
257 * 248 *
258 * FUNCTION: acpi_ds_call_control_method 249 * FUNCTION: acpi_ds_call_control_method
@@ -268,85 +259,86 @@ acpi_ds_begin_method_execution (
268 ******************************************************************************/ 259 ******************************************************************************/
269 260
270acpi_status 261acpi_status
271acpi_ds_call_control_method ( 262acpi_ds_call_control_method(struct acpi_thread_state *thread,
272 struct acpi_thread_state *thread, 263 struct acpi_walk_state *this_walk_state,
273 struct acpi_walk_state *this_walk_state, 264 union acpi_parse_object *op)
274 union acpi_parse_object *op)
275{ 265{
276 acpi_status status; 266 acpi_status status;
277 struct acpi_namespace_node *method_node; 267 struct acpi_namespace_node *method_node;
278 struct acpi_walk_state *next_walk_state = NULL; 268 struct acpi_walk_state *next_walk_state = NULL;
279 union acpi_operand_object *obj_desc; 269 union acpi_operand_object *obj_desc;
280 struct acpi_parameter_info info; 270 struct acpi_parameter_info info;
281 u32 i; 271 u32 i;
282
283 272
284 ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state); 273 ACPI_FUNCTION_TRACE_PTR("ds_call_control_method", this_walk_state);
285 274
286 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", 275 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
287 this_walk_state->prev_op, this_walk_state)); 276 "Execute method %p, currentstate=%p\n",
277 this_walk_state->prev_op, this_walk_state));
288 278
289 /* 279 /*
290 * Get the namespace entry for the control method we are about to call 280 * Get the namespace entry for the control method we are about to call
291 */ 281 */
292 method_node = this_walk_state->method_call_node; 282 method_node = this_walk_state->method_call_node;
293 if (!method_node) { 283 if (!method_node) {
294 return_ACPI_STATUS (AE_NULL_ENTRY); 284 return_ACPI_STATUS(AE_NULL_ENTRY);
295 } 285 }
296 286
297 obj_desc = acpi_ns_get_attached_object (method_node); 287 obj_desc = acpi_ns_get_attached_object(method_node);
298 if (!obj_desc) { 288 if (!obj_desc) {
299 return_ACPI_STATUS (AE_NULL_OBJECT); 289 return_ACPI_STATUS(AE_NULL_OBJECT);
300 } 290 }
301 291
302 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); 292 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
303 if (ACPI_FAILURE (status)) { 293 if (ACPI_FAILURE(status)) {
304 return_ACPI_STATUS (status); 294 return_ACPI_STATUS(status);
305 } 295 }
306 296
307 /* Init for new method, wait on concurrency semaphore */ 297 /* Init for new method, wait on concurrency semaphore */
308 298
309 status = acpi_ds_begin_method_execution (method_node, obj_desc, 299 status = acpi_ds_begin_method_execution(method_node, obj_desc,
310 this_walk_state->method_node); 300 this_walk_state->method_node);
311 if (ACPI_FAILURE (status)) { 301 if (ACPI_FAILURE(status)) {
312 goto cleanup; 302 goto cleanup;
313 } 303 }
314 304
315 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { 305 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
316 /* 1) Parse: Create a new walk state for the preempting walk */ 306 /* 1) Parse: Create a new walk state for the preempting walk */
317 307
318 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, 308 next_walk_state =
319 op, obj_desc, NULL); 309 acpi_ds_create_walk_state(obj_desc->method.owner_id, op,
310 obj_desc, NULL);
320 if (!next_walk_state) { 311 if (!next_walk_state) {
321 return_ACPI_STATUS (AE_NO_MEMORY); 312 return_ACPI_STATUS(AE_NO_MEMORY);
322 } 313 }
323 314
324 /* Create and init a Root Node */ 315 /* Create and init a Root Node */
325 316
326 op = acpi_ps_create_scope_op (); 317 op = acpi_ps_create_scope_op();
327 if (!op) { 318 if (!op) {
328 status = AE_NO_MEMORY; 319 status = AE_NO_MEMORY;
329 goto cleanup; 320 goto cleanup;
330 } 321 }
331 322
332 status = acpi_ds_init_aml_walk (next_walk_state, op, method_node, 323 status = acpi_ds_init_aml_walk(next_walk_state, op, method_node,
333 obj_desc->method.aml_start, obj_desc->method.aml_length, 324 obj_desc->method.aml_start,
334 NULL, 1); 325 obj_desc->method.aml_length,
335 if (ACPI_FAILURE (status)) { 326 NULL, 1);
336 acpi_ds_delete_walk_state (next_walk_state); 327 if (ACPI_FAILURE(status)) {
328 acpi_ds_delete_walk_state(next_walk_state);
337 goto cleanup; 329 goto cleanup;
338 } 330 }
339 331
340 /* Begin AML parse */ 332 /* Begin AML parse */
341 333
342 status = acpi_ps_parse_aml (next_walk_state); 334 status = acpi_ps_parse_aml(next_walk_state);
343 acpi_ps_delete_parse_tree (op); 335 acpi_ps_delete_parse_tree(op);
344 } 336 }
345 337
346 /* 2) Execute: Create a new state for the preempting walk */ 338 /* 2) Execute: Create a new state for the preempting walk */
347 339
348 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, 340 next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
349 NULL, obj_desc, thread); 341 NULL, obj_desc, thread);
350 if (!next_walk_state) { 342 if (!next_walk_state) {
351 status = AE_NO_MEMORY; 343 status = AE_NO_MEMORY;
352 goto cleanup; 344 goto cleanup;
@@ -357,15 +349,15 @@ acpi_ds_call_control_method (
357 * start at index 0. 349 * start at index 0.
358 * Null terminate the list of arguments 350 * Null terminate the list of arguments
359 */ 351 */
360 this_walk_state->operands [this_walk_state->num_operands] = NULL; 352 this_walk_state->operands[this_walk_state->num_operands] = NULL;
361 353
362 info.parameters = &this_walk_state->operands[0]; 354 info.parameters = &this_walk_state->operands[0];
363 info.parameter_type = ACPI_PARAM_ARGS; 355 info.parameter_type = ACPI_PARAM_ARGS;
364 356
365 status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node, 357 status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node,
366 obj_desc->method.aml_start, obj_desc->method.aml_length, 358 obj_desc->method.aml_start,
367 &info, 3); 359 obj_desc->method.aml_length, &info, 3);
368 if (ACPI_FAILURE (status)) { 360 if (ACPI_FAILURE(status)) {
369 goto cleanup; 361 goto cleanup;
370 } 362 }
371 363
@@ -374,40 +366,39 @@ acpi_ds_call_control_method (
374 * (they were copied to new objects) 366 * (they were copied to new objects)
375 */ 367 */
376 for (i = 0; i < obj_desc->method.param_count; i++) { 368 for (i = 0; i < obj_desc->method.param_count; i++) {
377 acpi_ut_remove_reference (this_walk_state->operands [i]); 369 acpi_ut_remove_reference(this_walk_state->operands[i]);
378 this_walk_state->operands [i] = NULL; 370 this_walk_state->operands[i] = NULL;
379 } 371 }
380 372
381 /* Clear the operand stack */ 373 /* Clear the operand stack */
382 374
383 this_walk_state->num_operands = 0; 375 this_walk_state->num_operands = 0;
384 376
385 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 377 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
386 "Starting nested execution, newstate=%p\n", next_walk_state)); 378 "Starting nested execution, newstate=%p\n",
379 next_walk_state));
387 380
388 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 381 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
389 status = obj_desc->method.implementation (next_walk_state); 382 status = obj_desc->method.implementation(next_walk_state);
390 return_ACPI_STATUS (status); 383 return_ACPI_STATUS(status);
391 } 384 }
392 385
393 return_ACPI_STATUS (AE_OK); 386 return_ACPI_STATUS(AE_OK);
394
395 387
396 /* On error, we must delete the new walk state */ 388 /* On error, we must delete the new walk state */
397 389
398cleanup: 390 cleanup:
399 acpi_ut_release_owner_id (&obj_desc->method.owner_id); 391 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
400 if (next_walk_state && (next_walk_state->method_desc)) { 392 if (next_walk_state && (next_walk_state->method_desc)) {
401 /* Decrement the thread count on the method parse tree */ 393 /* Decrement the thread count on the method parse tree */
402 394
403 next_walk_state->method_desc->method.thread_count--; 395 next_walk_state->method_desc->method.thread_count--;
404 } 396 }
405 (void) acpi_ds_terminate_control_method (next_walk_state); 397 (void)acpi_ds_terminate_control_method(next_walk_state);
406 acpi_ds_delete_walk_state (next_walk_state); 398 acpi_ds_delete_walk_state(next_walk_state);
407 return_ACPI_STATUS (status); 399 return_ACPI_STATUS(status);
408} 400}
409 401
410
411/******************************************************************************* 402/*******************************************************************************
412 * 403 *
413 * FUNCTION: acpi_ds_restart_control_method 404 * FUNCTION: acpi_ds_restart_control_method
@@ -423,25 +414,22 @@ cleanup:
423 ******************************************************************************/ 414 ******************************************************************************/
424 415
425acpi_status 416acpi_status
426acpi_ds_restart_control_method ( 417acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
427 struct acpi_walk_state *walk_state, 418 union acpi_operand_object *return_desc)
428 union acpi_operand_object *return_desc)
429{ 419{
430 acpi_status status; 420 acpi_status status;
431
432 421
433 ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state); 422 ACPI_FUNCTION_TRACE_PTR("ds_restart_control_method", walk_state);
434 423
424 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
425 "****Restart [%4.4s] Op %p return_value_from_callee %p\n",
426 (char *)&walk_state->method_node->name,
427 walk_state->method_call_op, return_desc));
435 428
436 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 429 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
437 "****Restart [%4.4s] Op %p return_value_from_callee %p\n", 430 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
438 (char *) &walk_state->method_node->name, walk_state->method_call_op, 431 walk_state->return_used,
439 return_desc)); 432 walk_state->results, walk_state));
440
441 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
442 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
443 walk_state->return_used,
444 walk_state->results, walk_state));
445 433
446 /* Did the called method return a value? */ 434 /* Did the called method return a value? */
447 435
@@ -451,10 +439,10 @@ acpi_ds_restart_control_method (
451 if (walk_state->return_used) { 439 if (walk_state->return_used) {
452 /* Save the return value from the previous method */ 440 /* Save the return value from the previous method */
453 441
454 status = acpi_ds_result_push (return_desc, walk_state); 442 status = acpi_ds_result_push(return_desc, walk_state);
455 if (ACPI_FAILURE (status)) { 443 if (ACPI_FAILURE(status)) {
456 acpi_ut_remove_reference (return_desc); 444 acpi_ut_remove_reference(return_desc);
457 return_ACPI_STATUS (status); 445 return_ACPI_STATUS(status);
458 } 446 }
459 447
460 /* 448 /*
@@ -472,19 +460,19 @@ acpi_ds_restart_control_method (
472 * NOTE: this is optional because the ASL language does not actually 460 * NOTE: this is optional because the ASL language does not actually
473 * support this behavior. 461 * support this behavior.
474 */ 462 */
475 else if (!acpi_ds_do_implicit_return (return_desc, walk_state, FALSE)) { 463 else if (!acpi_ds_do_implicit_return
464 (return_desc, walk_state, FALSE)) {
476 /* 465 /*
477 * Delete the return value if it will not be used by the 466 * Delete the return value if it will not be used by the
478 * calling method 467 * calling method
479 */ 468 */
480 acpi_ut_remove_reference (return_desc); 469 acpi_ut_remove_reference(return_desc);
481 } 470 }
482 } 471 }
483 472
484 return_ACPI_STATUS (AE_OK); 473 return_ACPI_STATUS(AE_OK);
485} 474}
486 475
487
488/******************************************************************************* 476/*******************************************************************************
489 * 477 *
490 * FUNCTION: acpi_ds_terminate_control_method 478 * FUNCTION: acpi_ds_terminate_control_method
@@ -499,17 +487,13 @@ acpi_ds_restart_control_method (
499 * 487 *
500 ******************************************************************************/ 488 ******************************************************************************/
501 489
502acpi_status 490acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
503acpi_ds_terminate_control_method (
504 struct acpi_walk_state *walk_state)
505{ 491{
506 union acpi_operand_object *obj_desc; 492 union acpi_operand_object *obj_desc;
507 struct acpi_namespace_node *method_node; 493 struct acpi_namespace_node *method_node;
508 acpi_status status; 494 acpi_status status;
509
510
511 ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state);
512 495
496 ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state);
513 497
514 if (!walk_state) { 498 if (!walk_state) {
515 return (AE_BAD_PARAMETER); 499 return (AE_BAD_PARAMETER);
@@ -519,30 +503,31 @@ acpi_ds_terminate_control_method (
519 503
520 obj_desc = walk_state->method_desc; 504 obj_desc = walk_state->method_desc;
521 if (!obj_desc) { 505 if (!obj_desc) {
522 return_ACPI_STATUS (AE_OK); 506 return_ACPI_STATUS(AE_OK);
523 } 507 }
524 508
525 /* Delete all arguments and locals */ 509 /* Delete all arguments and locals */
526 510
527 acpi_ds_method_data_delete_all (walk_state); 511 acpi_ds_method_data_delete_all(walk_state);
528 512
529 /* 513 /*
530 * Lock the parser while we terminate this method. 514 * Lock the parser while we terminate this method.
531 * If this is the last thread executing the method, 515 * If this is the last thread executing the method,
532 * we have additional cleanup to perform 516 * we have additional cleanup to perform
533 */ 517 */
534 status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER); 518 status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER);
535 if (ACPI_FAILURE (status)) { 519 if (ACPI_FAILURE(status)) {
536 return_ACPI_STATUS (status); 520 return_ACPI_STATUS(status);
537 } 521 }
538 522
539 /* Signal completion of the execution of this method if necessary */ 523 /* Signal completion of the execution of this method if necessary */
540 524
541 if (walk_state->method_desc->method.semaphore) { 525 if (walk_state->method_desc->method.semaphore) {
542 status = acpi_os_signal_semaphore ( 526 status =
543 walk_state->method_desc->method.semaphore, 1); 527 acpi_os_signal_semaphore(walk_state->method_desc->method.
544 if (ACPI_FAILURE (status)) { 528 semaphore, 1);
545 ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); 529 if (ACPI_FAILURE(status)) {
530 ACPI_REPORT_ERROR(("Could not signal method semaphore\n"));
546 status = AE_OK; 531 status = AE_OK;
547 532
548 /* Ignore error and continue cleanup */ 533 /* Ignore error and continue cleanup */
@@ -550,9 +535,10 @@ acpi_ds_terminate_control_method (
550 } 535 }
551 536
552 if (walk_state->method_desc->method.thread_count) { 537 if (walk_state->method_desc->method.thread_count) {
553 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 538 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
554 "*** Not deleting method namespace, there are still %d threads\n", 539 "*** Not deleting method namespace, there are still %d threads\n",
555 walk_state->method_desc->method.thread_count)); 540 walk_state->method_desc->method.
541 thread_count));
556 } 542 }
557 543
558 if (!walk_state->method_desc->method.thread_count) { 544 if (!walk_state->method_desc->method.thread_count) {
@@ -567,9 +553,11 @@ acpi_ds_terminate_control_method (
567 * before creating the synchronization semaphore. 553 * before creating the synchronization semaphore.
568 */ 554 */
569 if ((walk_state->method_desc->method.concurrency == 1) && 555 if ((walk_state->method_desc->method.concurrency == 1) &&
570 (!walk_state->method_desc->method.semaphore)) { 556 (!walk_state->method_desc->method.semaphore)) {
571 status = acpi_os_create_semaphore (1, 1, 557 status = acpi_os_create_semaphore(1, 1,
572 &walk_state->method_desc->method.semaphore); 558 &walk_state->
559 method_desc->method.
560 semaphore);
573 } 561 }
574 562
575 /* 563 /*
@@ -584,30 +572,30 @@ acpi_ds_terminate_control_method (
584 * Delete any namespace entries created immediately underneath 572 * Delete any namespace entries created immediately underneath
585 * the method 573 * the method
586 */ 574 */
587 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
588 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
589 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
590 } 578 }
591 579
592 if (method_node->child) { 580 if (method_node->child) {
593 acpi_ns_delete_namespace_subtree (method_node); 581 acpi_ns_delete_namespace_subtree(method_node);
594 } 582 }
595 583
596 /* 584 /*
597 * Delete any namespace entries created anywhere else within 585 * Delete any namespace entries created anywhere else within
598 * the namespace 586 * the namespace
599 */ 587 */
600 acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); 588 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
601 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 589 method.owner_id);
602 acpi_ut_release_owner_id (&walk_state->method_desc->method.owner_id); 590 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
603 591 acpi_ut_release_owner_id(&walk_state->method_desc->method.
604 if (ACPI_FAILURE (status)) { 592 owner_id);
605 return_ACPI_STATUS (status); 593
594 if (ACPI_FAILURE(status)) {
595 return_ACPI_STATUS(status);
606 } 596 }
607 } 597 }
608 598
609 status = acpi_ut_release_mutex (ACPI_MTX_PARSER); 599 status = acpi_ut_release_mutex(ACPI_MTX_PARSER);
610 return_ACPI_STATUS (status); 600 return_ACPI_STATUS(status);
611} 601}
612
613
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index c83d53fd6398..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 541
571 542 ACPI_FUNCTION_TRACE("ds_store_object_to_local");
572 ACPI_FUNCTION_TRACE ("ds_store_object_to_local"); 543 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
573 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", 544 opcode, index, obj_desc));
574 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
@@ -636,28 +608,36 @@ acpi_ds_store_object_to_local (
636 * 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(),
637 * do the indirect store 609 * do the indirect store
638 */ 610 */
639 if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) && 611 if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
640 (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 612 ACPI_DESC_TYPE_OPERAND)
641 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { 613 && (current_obj_desc->common.type ==
642 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 614 ACPI_TYPE_LOCAL_REFERENCE)
643 "Arg (%p) is an obj_ref(Node), storing in node %p\n", 615 && (current_obj_desc->reference.opcode ==
644 new_obj_desc, current_obj_desc)); 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));
645 621
646 /* 622 /*
647 * Store this object to the Node (perform the indirect store) 623 * Store this object to the Node (perform the indirect store)
648 * NOTE: No implicit conversion is performed, as per the ACPI 624 * NOTE: No implicit conversion is performed, as per the ACPI
649 * specification rules on storing to Locals/Args. 625 * specification rules on storing to Locals/Args.
650 */ 626 */
651 status = acpi_ex_store_object_to_node (new_obj_desc, 627 status =
652 current_obj_desc->reference.object, walk_state, 628 acpi_ex_store_object_to_node(new_obj_desc,
653 ACPI_NO_IMPLICIT_CONVERSION); 629 current_obj_desc->
630 reference.
631 object,
632 walk_state,
633 ACPI_NO_IMPLICIT_CONVERSION);
654 634
655 /* Remove local reference if we copied the object above */ 635 /* Remove local reference if we copied the object above */
656 636
657 if (new_obj_desc != obj_desc) { 637 if (new_obj_desc != obj_desc) {
658 acpi_ut_remove_reference (new_obj_desc); 638 acpi_ut_remove_reference(new_obj_desc);
659 } 639 }
660 return_ACPI_STATUS (status); 640 return_ACPI_STATUS(status);
661 } 641 }
662 } 642 }
663 643
@@ -665,7 +645,7 @@ acpi_ds_store_object_to_local (
665 * Delete the existing object 645 * Delete the existing object
666 * before storing the new one 646 * before storing the new one
667 */ 647 */
668 acpi_ds_method_data_delete_value (opcode, index, walk_state); 648 acpi_ds_method_data_delete_value(opcode, index, walk_state);
669 } 649 }
670 650
671 /* 651 /*
@@ -673,18 +653,19 @@ acpi_ds_store_object_to_local (
673 * the descriptor for the Arg or Local. 653 * the descriptor for the Arg or Local.
674 * (increments the object reference count by one) 654 * (increments the object reference count by one)
675 */ 655 */
676 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);
677 659
678 /* Remove local reference if we copied the object above */ 660 /* Remove local reference if we copied the object above */
679 661
680 if (new_obj_desc != obj_desc) { 662 if (new_obj_desc != obj_desc) {
681 acpi_ut_remove_reference (new_obj_desc); 663 acpi_ut_remove_reference(new_obj_desc);
682 } 664 }
683 665
684 return_ACPI_STATUS (status); 666 return_ACPI_STATUS(status);
685} 667}
686 668
687
688#ifdef ACPI_OBSOLETE_FUNCTIONS 669#ifdef ACPI_OBSOLETE_FUNCTIONS
689/******************************************************************************* 670/*******************************************************************************
690 * 671 *
@@ -701,39 +682,33 @@ acpi_ds_store_object_to_local (
701 ******************************************************************************/ 682 ******************************************************************************/
702 683
703acpi_object_type 684acpi_object_type
704acpi_ds_method_data_get_type ( 685acpi_ds_method_data_get_type(u16 opcode,
705 u16 opcode, 686 u32 index, struct acpi_walk_state *walk_state)
706 u32 index,
707 struct acpi_walk_state *walk_state)
708{ 687{
709 acpi_status status; 688 acpi_status status;
710 struct acpi_namespace_node *node; 689 struct acpi_namespace_node *node;
711 union acpi_operand_object *object; 690 union acpi_operand_object *object;
712
713
714 ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
715 691
692 ACPI_FUNCTION_TRACE("ds_method_data_get_type");
716 693
717 /* Get the namespace node for the arg/local */ 694 /* Get the namespace node for the arg/local */
718 695
719 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);
720 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
721 return_VALUE ((ACPI_TYPE_NOT_FOUND)); 698 return_VALUE((ACPI_TYPE_NOT_FOUND));
722 } 699 }
723 700
724 /* Get the object */ 701 /* Get the object */
725 702
726 object = acpi_ns_get_attached_object (node); 703 object = acpi_ns_get_attached_object(node);
727 if (!object) { 704 if (!object) {
728 /* Uninitialized local/arg, return TYPE_ANY */ 705 /* Uninitialized local/arg, return TYPE_ANY */
729 706
730 return_VALUE (ACPI_TYPE_ANY); 707 return_VALUE(ACPI_TYPE_ANY);
731 } 708 }
732 709
733 /* Get the object type */ 710 /* Get the object type */
734 711
735 return_VALUE (ACPI_GET_OBJECT_TYPE (object)); 712 return_VALUE(ACPI_GET_OBJECT_TYPE(object));
736} 713}
737#endif 714#endif
738
739
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index 1eee2d54180f..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,36 +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;
550#ifndef ACPI_NO_METHOD_EXECUTION 532#ifndef ACPI_NO_METHOD_EXECUTION
551 acpi_ex_truncate_for32bit_table (obj_desc); 533 acpi_ex_truncate_for32bit_table(obj_desc);
552#endif 534#endif
553 break; 535 break;
554 536
555
556 default: 537 default:
557 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", 538 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
558 op_info->type)); 539 "Unknown Integer type %X\n",
540 op_info->type));
559 status = AE_AML_OPERAND_TYPE; 541 status = AE_AML_OPERAND_TYPE;
560 break; 542 break;
561 } 543 }
562 break; 544 break;
563 545
564
565 case ACPI_TYPE_STRING: 546 case ACPI_TYPE_STRING:
566 547
567 obj_desc->string.pointer = op->common.value.string; 548 obj_desc->string.pointer = op->common.value.string;
568 obj_desc->string.length = (u32) ACPI_STRLEN (op->common.value.string); 549 obj_desc->string.length =
550 (u32) ACPI_STRLEN(op->common.value.string);
569 551
570 /* 552 /*
571 * 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
@@ -574,11 +556,9 @@ acpi_ds_init_object_from_op (
574 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 556 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
575 break; 557 break;
576 558
577
578 case ACPI_TYPE_METHOD: 559 case ACPI_TYPE_METHOD:
579 break; 560 break;
580 561
581
582 case ACPI_TYPE_LOCAL_REFERENCE: 562 case ACPI_TYPE_LOCAL_REFERENCE:
583 563
584 switch (op_info->type) { 564 switch (op_info->type) {
@@ -590,14 +570,17 @@ acpi_ds_init_object_from_op (
590 obj_desc->reference.offset = opcode - AML_LOCAL_OP; 570 obj_desc->reference.offset = opcode - AML_LOCAL_OP;
591 571
592#ifndef ACPI_NO_METHOD_EXECUTION 572#ifndef ACPI_NO_METHOD_EXECUTION
593 status = acpi_ds_method_data_get_node (AML_LOCAL_OP, 573 status = acpi_ds_method_data_get_node(AML_LOCAL_OP,
594 obj_desc->reference.offset, 574 obj_desc->
595 walk_state, 575 reference.offset,
596 (struct acpi_namespace_node **) &obj_desc->reference.object); 576 walk_state,
577 (struct
578 acpi_namespace_node
579 **)&obj_desc->
580 reference.object);
597#endif 581#endif
598 break; 582 break;
599 583
600
601 case AML_TYPE_METHOD_ARGUMENT: 584 case AML_TYPE_METHOD_ARGUMENT:
602 585
603 /* Split the opcode into a base opcode + offset */ 586 /* Split the opcode into a base opcode + offset */
@@ -606,14 +589,18 @@ acpi_ds_init_object_from_op (
606 obj_desc->reference.offset = opcode - AML_ARG_OP; 589 obj_desc->reference.offset = opcode - AML_ARG_OP;
607 590
608#ifndef ACPI_NO_METHOD_EXECUTION 591#ifndef ACPI_NO_METHOD_EXECUTION
609 status = acpi_ds_method_data_get_node (AML_ARG_OP, 592 status = acpi_ds_method_data_get_node(AML_ARG_OP,
610 obj_desc->reference.offset, 593 obj_desc->
611 walk_state, 594 reference.offset,
612 (struct acpi_namespace_node **) &obj_desc->reference.object); 595 walk_state,
596 (struct
597 acpi_namespace_node
598 **)&obj_desc->
599 reference.object);
613#endif 600#endif
614 break; 601 break;
615 602
616 default: /* Other literals, etc.. */ 603 default: /* Other literals, etc.. */
617 604
618 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 605 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
619 /* Node was saved in Op */ 606 /* Node was saved in Op */
@@ -626,17 +613,15 @@ acpi_ds_init_object_from_op (
626 } 613 }
627 break; 614 break;
628 615
629
630 default: 616 default:
631 617
632 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", 618 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
633 ACPI_GET_OBJECT_TYPE (obj_desc))); 619 "Unimplemented data type: %X\n",
620 ACPI_GET_OBJECT_TYPE(obj_desc)));
634 621
635 status = AE_AML_OPERAND_TYPE; 622 status = AE_AML_OPERAND_TYPE;
636 break; 623 break;
637 } 624 }
638 625
639 return_ACPI_STATUS (status); 626 return_ACPI_STATUS(status);
640} 627}
641
642
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 750bdb1ac344..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,16 @@ 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 status = AE_NO_MEMORY; 112 status = AE_NO_MEMORY;
123 goto cleanup; 113 goto cleanup;
124 } 114 }
125 115
126 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,
127 aml_length, NULL, 1); 117 aml_length, NULL, 1);
128 if (ACPI_FAILURE (status)) { 118 if (ACPI_FAILURE(status)) {
129 acpi_ds_delete_walk_state (walk_state); 119 acpi_ds_delete_walk_state(walk_state);
130 goto cleanup; 120 goto cleanup;
131 } 121 }
132 122
@@ -137,28 +127,28 @@ acpi_ds_execute_arguments (
137 127
138 /* Pass1: Parse the entire declaration */ 128 /* Pass1: Parse the entire declaration */
139 129
140 status = acpi_ps_parse_aml (walk_state); 130 status = acpi_ps_parse_aml(walk_state);
141 if (ACPI_FAILURE (status)) { 131 if (ACPI_FAILURE(status)) {
142 goto cleanup; 132 goto cleanup;
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 status = AE_NO_MEMORY; 153 status = AE_NO_MEMORY;
164 goto cleanup; 154 goto cleanup;
@@ -166,24 +156,23 @@ acpi_ds_execute_arguments (
166 156
167 /* Execute the opcode and arguments */ 157 /* Execute the opcode and arguments */
168 158
169 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,
170 aml_length, NULL, 3); 160 aml_length, NULL, 3);
171 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
172 acpi_ds_delete_walk_state (walk_state); 162 acpi_ds_delete_walk_state(walk_state);
173 goto cleanup; 163 goto cleanup;
174 } 164 }
175 165
176 /* Mark this execution as a deferred opcode */ 166 /* Mark this execution as a deferred opcode */
177 167
178 walk_state->deferred_node = node; 168 walk_state->deferred_node = node;
179 status = acpi_ps_parse_aml (walk_state); 169 status = acpi_ps_parse_aml(walk_state);
180 170
181cleanup: 171 cleanup:
182 acpi_ps_delete_parse_tree (op); 172 acpi_ps_delete_parse_tree(op);
183 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
184} 174}
185 175
186
187/******************************************************************************* 176/*******************************************************************************
188 * 177 *
189 * FUNCTION: acpi_ds_get_buffer_field_arguments 178 * FUNCTION: acpi_ds_get_buffer_field_arguments
@@ -198,38 +187,36 @@ cleanup:
198 ******************************************************************************/ 187 ******************************************************************************/
199 188
200acpi_status 189acpi_status
201acpi_ds_get_buffer_field_arguments ( 190acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
202 union acpi_operand_object *obj_desc)
203{ 191{
204 union acpi_operand_object *extra_desc; 192 union acpi_operand_object *extra_desc;
205 struct acpi_namespace_node *node; 193 struct acpi_namespace_node *node;
206 acpi_status status; 194 acpi_status status;
207
208
209 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc);
210 195
196 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc);
211 197
212 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 198 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
213 return_ACPI_STATUS (AE_OK); 199 return_ACPI_STATUS(AE_OK);
214 } 200 }
215 201
216 /* Get the AML pointer (method object) and buffer_field node */ 202 /* Get the AML pointer (method object) and buffer_field node */
217 203
218 extra_desc = acpi_ns_get_secondary_object (obj_desc); 204 extra_desc = acpi_ns_get_secondary_object(obj_desc);
219 node = obj_desc->buffer_field.node; 205 node = obj_desc->buffer_field.node;
220 206
221 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL)); 207 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
222 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", 208 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
223 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)));
224 211
225 /* Execute the AML code for the term_arg arguments */ 212 /* Execute the AML code for the term_arg arguments */
226 213
227 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),
228 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 215 extra_desc->extra.aml_length,
229 return_ACPI_STATUS (status); 216 extra_desc->extra.aml_start);
217 return_ACPI_STATUS(status);
230} 218}
231 219
232
233/******************************************************************************* 220/*******************************************************************************
234 * 221 *
235 * FUNCTION: acpi_ds_get_buffer_arguments 222 * FUNCTION: acpi_ds_get_buffer_arguments
@@ -243,40 +230,35 @@ acpi_ds_get_buffer_field_arguments (
243 * 230 *
244 ******************************************************************************/ 231 ******************************************************************************/
245 232
246acpi_status 233acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
247acpi_ds_get_buffer_arguments (
248 union acpi_operand_object *obj_desc)
249{ 234{
250 struct acpi_namespace_node *node; 235 struct acpi_namespace_node *node;
251 acpi_status status; 236 acpi_status status;
252
253
254 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc);
255 237
238 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc);
256 239
257 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 240 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
258 return_ACPI_STATUS (AE_OK); 241 return_ACPI_STATUS(AE_OK);
259 } 242 }
260 243
261 /* Get the Buffer node */ 244 /* Get the Buffer node */
262 245
263 node = obj_desc->buffer.node; 246 node = obj_desc->buffer.node;
264 if (!node) { 247 if (!node) {
265 ACPI_REPORT_ERROR (( 248 ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc));
266 "No pointer back to NS node in buffer obj %p\n", obj_desc)); 249 return_ACPI_STATUS(AE_AML_INTERNAL);
267 return_ACPI_STATUS (AE_AML_INTERNAL);
268 } 250 }
269 251
270 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 252 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
271 253
272 /* Execute the AML code for the term_arg arguments */ 254 /* Execute the AML code for the term_arg arguments */
273 255
274 status = acpi_ds_execute_arguments (node, node, 256 status = acpi_ds_execute_arguments(node, node,
275 obj_desc->buffer.aml_length, obj_desc->buffer.aml_start); 257 obj_desc->buffer.aml_length,
276 return_ACPI_STATUS (status); 258 obj_desc->buffer.aml_start);
259 return_ACPI_STATUS(status);
277} 260}
278 261
279
280/******************************************************************************* 262/*******************************************************************************
281 * 263 *
282 * FUNCTION: acpi_ds_get_package_arguments 264 * FUNCTION: acpi_ds_get_package_arguments
@@ -290,40 +272,36 @@ acpi_ds_get_buffer_arguments (
290 * 272 *
291 ******************************************************************************/ 273 ******************************************************************************/
292 274
293acpi_status 275acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
294acpi_ds_get_package_arguments (
295 union acpi_operand_object *obj_desc)
296{ 276{
297 struct acpi_namespace_node *node; 277 struct acpi_namespace_node *node;
298 acpi_status status; 278 acpi_status status;
299
300
301 ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc);
302 279
280 ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc);
303 281
304 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 282 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
305 return_ACPI_STATUS (AE_OK); 283 return_ACPI_STATUS(AE_OK);
306 } 284 }
307 285
308 /* Get the Package node */ 286 /* Get the Package node */
309 287
310 node = obj_desc->package.node; 288 node = obj_desc->package.node;
311 if (!node) { 289 if (!node) {
312 ACPI_REPORT_ERROR (( 290 ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n",
313 "No pointer back to NS node in package %p\n", obj_desc)); 291 obj_desc));
314 return_ACPI_STATUS (AE_AML_INTERNAL); 292 return_ACPI_STATUS(AE_AML_INTERNAL);
315 } 293 }
316 294
317 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 295 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
318 296
319 /* Execute the AML code for the term_arg arguments */ 297 /* Execute the AML code for the term_arg arguments */
320 298
321 status = acpi_ds_execute_arguments (node, node, 299 status = acpi_ds_execute_arguments(node, node,
322 obj_desc->package.aml_length, obj_desc->package.aml_start); 300 obj_desc->package.aml_length,
323 return_ACPI_STATUS (status); 301 obj_desc->package.aml_start);
302 return_ACPI_STATUS(status);
324} 303}
325 304
326
327/***************************************************************************** 305/*****************************************************************************
328 * 306 *
329 * FUNCTION: acpi_ds_get_region_arguments 307 * FUNCTION: acpi_ds_get_region_arguments
@@ -337,44 +315,43 @@ acpi_ds_get_package_arguments (
337 * 315 *
338 ****************************************************************************/ 316 ****************************************************************************/
339 317
340acpi_status 318acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
341acpi_ds_get_region_arguments (
342 union acpi_operand_object *obj_desc)
343{ 319{
344 struct acpi_namespace_node *node; 320 struct acpi_namespace_node *node;
345 acpi_status status; 321 acpi_status status;
346 union acpi_operand_object *extra_desc; 322 union acpi_operand_object *extra_desc;
347
348
349 ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc);
350 323
324 ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc);
351 325
352 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 326 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
353 return_ACPI_STATUS (AE_OK); 327 return_ACPI_STATUS(AE_OK);
354 } 328 }
355 329
356 extra_desc = acpi_ns_get_secondary_object (obj_desc); 330 extra_desc = acpi_ns_get_secondary_object(obj_desc);
357 if (!extra_desc) { 331 if (!extra_desc) {
358 return_ACPI_STATUS (AE_NOT_EXIST); 332 return_ACPI_STATUS(AE_NOT_EXIST);
359 } 333 }
360 334
361 /* Get the Region node */ 335 /* Get the Region node */
362 336
363 node = obj_desc->region.node; 337 node = obj_desc->region.node;
364 338
365 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));
366 341
367 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n", 342 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
368 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));
369 346
370 /* Execute the argument AML */ 347 /* Execute the argument AML */
371 348
372 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),
373 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 350 extra_desc->extra.aml_length,
374 return_ACPI_STATUS (status); 351 extra_desc->extra.aml_start);
352 return_ACPI_STATUS(status);
375} 353}
376 354
377
378/******************************************************************************* 355/*******************************************************************************
379 * 356 *
380 * FUNCTION: acpi_ds_initialize_region 357 * FUNCTION: acpi_ds_initialize_region
@@ -387,23 +364,19 @@ acpi_ds_get_region_arguments (
387 * 364 *
388 ******************************************************************************/ 365 ******************************************************************************/
389 366
390acpi_status 367acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
391acpi_ds_initialize_region (
392 acpi_handle obj_handle)
393{ 368{
394 union acpi_operand_object *obj_desc; 369 union acpi_operand_object *obj_desc;
395 acpi_status status; 370 acpi_status status;
396 371
397 372 obj_desc = acpi_ns_get_attached_object(obj_handle);
398 obj_desc = acpi_ns_get_attached_object (obj_handle);
399 373
400 /* Namespace is NOT locked */ 374 /* Namespace is NOT locked */
401 375
402 status = acpi_ev_initialize_region (obj_desc, FALSE); 376 status = acpi_ev_initialize_region(obj_desc, FALSE);
403 return (status); 377 return (status);
404} 378}
405 379
406
407/******************************************************************************* 380/*******************************************************************************
408 * 381 *
409 * FUNCTION: acpi_ds_init_buffer_field 382 * FUNCTION: acpi_ds_init_buffer_field
@@ -422,30 +395,27 @@ acpi_ds_initialize_region (
422 ******************************************************************************/ 395 ******************************************************************************/
423 396
424static acpi_status 397static acpi_status
425acpi_ds_init_buffer_field ( 398acpi_ds_init_buffer_field(u16 aml_opcode,
426 u16 aml_opcode, 399 union acpi_operand_object *obj_desc,
427 union acpi_operand_object *obj_desc, 400 union acpi_operand_object *buffer_desc,
428 union acpi_operand_object *buffer_desc, 401 union acpi_operand_object *offset_desc,
429 union acpi_operand_object *offset_desc, 402 union acpi_operand_object *length_desc,
430 union acpi_operand_object *length_desc, 403 union acpi_operand_object *result_desc)
431 union acpi_operand_object *result_desc)
432{ 404{
433 u32 offset; 405 u32 offset;
434 u32 bit_offset; 406 u32 bit_offset;
435 u32 bit_count; 407 u32 bit_count;
436 u8 field_flags; 408 u8 field_flags;
437 acpi_status status; 409 acpi_status status;
438
439
440 ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc);
441 410
411 ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc);
442 412
443 /* Host object must be a Buffer */ 413 /* Host object must be a Buffer */
444 414
445 if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) { 415 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
446 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
447 "Target of Create Field is not a Buffer object - %s\n", 417 "Target of Create Field is not a Buffer object - %s\n",
448 acpi_ut_get_object_type_name (buffer_desc))); 418 acpi_ut_get_object_type_name(buffer_desc)));
449 419
450 status = AE_AML_OPERAND_TYPE; 420 status = AE_AML_OPERAND_TYPE;
451 goto cleanup; 421 goto cleanup;
@@ -456,11 +426,11 @@ acpi_ds_init_buffer_field (
456 * 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
457 * after resolution in acpi_ex_resolve_operands(). 427 * after resolution in acpi_ex_resolve_operands().
458 */ 428 */
459 if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { 429 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
460 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 430 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
461 "(%s) destination not a NS Node [%s]\n", 431 "(%s) destination not a NS Node [%s]\n",
462 acpi_ps_get_opcode_name (aml_opcode), 432 acpi_ps_get_opcode_name(aml_opcode),
463 acpi_ut_get_descriptor_name (result_desc))); 433 acpi_ut_get_descriptor_name(result_desc)));
464 434
465 status = AE_AML_OPERAND_TYPE; 435 status = AE_AML_OPERAND_TYPE;
466 goto cleanup; 436 goto cleanup;
@@ -478,13 +448,13 @@ acpi_ds_init_buffer_field (
478 448
479 field_flags = AML_FIELD_ACCESS_BYTE; 449 field_flags = AML_FIELD_ACCESS_BYTE;
480 bit_offset = offset; 450 bit_offset = offset;
481 bit_count = (u32) length_desc->integer.value; 451 bit_count = (u32) length_desc->integer.value;
482 452
483 /* Must have a valid (>0) bit count */ 453 /* Must have a valid (>0) bit count */
484 454
485 if (bit_count == 0) { 455 if (bit_count == 0) {
486 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 456 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
487 "Attempt to create_field of length 0\n")); 457 "Attempt to create_field of length 0\n"));
488 status = AE_AML_OPERAND_VALUE; 458 status = AE_AML_OPERAND_VALUE;
489 goto cleanup; 459 goto cleanup;
490 } 460 }
@@ -495,7 +465,7 @@ acpi_ds_init_buffer_field (
495 /* Offset is in bits, Field is one bit */ 465 /* Offset is in bits, Field is one bit */
496 466
497 bit_offset = offset; 467 bit_offset = offset;
498 bit_count = 1; 468 bit_count = 1;
499 field_flags = AML_FIELD_ACCESS_BYTE; 469 field_flags = AML_FIELD_ACCESS_BYTE;
500 break; 470 break;
501 471
@@ -504,7 +474,7 @@ acpi_ds_init_buffer_field (
504 /* Offset is in bytes, field is one byte */ 474 /* Offset is in bytes, field is one byte */
505 475
506 bit_offset = 8 * offset; 476 bit_offset = 8 * offset;
507 bit_count = 8; 477 bit_count = 8;
508 field_flags = AML_FIELD_ACCESS_BYTE; 478 field_flags = AML_FIELD_ACCESS_BYTE;
509 break; 479 break;
510 480
@@ -513,7 +483,7 @@ acpi_ds_init_buffer_field (
513 /* Offset is in bytes, field is one word */ 483 /* Offset is in bytes, field is one word */
514 484
515 bit_offset = 8 * offset; 485 bit_offset = 8 * offset;
516 bit_count = 16; 486 bit_count = 16;
517 field_flags = AML_FIELD_ACCESS_WORD; 487 field_flags = AML_FIELD_ACCESS_WORD;
518 break; 488 break;
519 489
@@ -522,7 +492,7 @@ acpi_ds_init_buffer_field (
522 /* Offset is in bytes, field is one dword */ 492 /* Offset is in bytes, field is one dword */
523 493
524 bit_offset = 8 * offset; 494 bit_offset = 8 * offset;
525 bit_count = 32; 495 bit_count = 32;
526 field_flags = AML_FIELD_ACCESS_DWORD; 496 field_flags = AML_FIELD_ACCESS_DWORD;
527 break; 497 break;
528 498
@@ -531,29 +501,29 @@ acpi_ds_init_buffer_field (
531 /* Offset is in bytes, field is one qword */ 501 /* Offset is in bytes, field is one qword */
532 502
533 bit_offset = 8 * offset; 503 bit_offset = 8 * offset;
534 bit_count = 64; 504 bit_count = 64;
535 field_flags = AML_FIELD_ACCESS_QWORD; 505 field_flags = AML_FIELD_ACCESS_QWORD;
536 break; 506 break;
537 507
538 default: 508 default:
539 509
540 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 510 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
541 "Unknown field creation opcode %02x\n", 511 "Unknown field creation opcode %02x\n",
542 aml_opcode)); 512 aml_opcode));
543 status = AE_AML_BAD_OPCODE; 513 status = AE_AML_BAD_OPCODE;
544 goto cleanup; 514 goto cleanup;
545 } 515 }
546 516
547 /* Entire field must fit within the current length of the buffer */ 517 /* Entire field must fit within the current length of the buffer */
548 518
549 if ((bit_offset + bit_count) > 519 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
550 (8 * (u32) buffer_desc->buffer.length)) { 520 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
551 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 521 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n",
552 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 522 acpi_ut_get_node_name(result_desc),
553 acpi_ut_get_node_name (result_desc), 523 bit_offset + bit_count,
554 bit_offset + bit_count, 524 acpi_ut_get_node_name(buffer_desc->buffer.
555 acpi_ut_get_node_name (buffer_desc->buffer.node), 525 node),
556 8 * (u32) buffer_desc->buffer.length)); 526 8 * (u32) buffer_desc->buffer.length));
557 status = AE_AML_BUFFER_LIMIT; 527 status = AE_AML_BUFFER_LIMIT;
558 goto cleanup; 528 goto cleanup;
559 } 529 }
@@ -563,9 +533,9 @@ acpi_ds_init_buffer_field (
563 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), 533 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
564 * UPDATE_RULE = 0 (UPDATE_PRESERVE) 534 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
565 */ 535 */
566 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,
567 bit_offset, bit_count); 537 bit_offset, bit_count);
568 if (ACPI_FAILURE (status)) { 538 if (ACPI_FAILURE(status)) {
569 goto cleanup; 539 goto cleanup;
570 } 540 }
571 541
@@ -574,35 +544,33 @@ acpi_ds_init_buffer_field (
574 /* Reference count for buffer_desc inherits obj_desc count */ 544 /* Reference count for buffer_desc inherits obj_desc count */
575 545
576 buffer_desc->common.reference_count = (u16) 546 buffer_desc->common.reference_count = (u16)
577 (buffer_desc->common.reference_count + obj_desc->common.reference_count); 547 (buffer_desc->common.reference_count +
548 obj_desc->common.reference_count);
578 549
579 550 cleanup:
580cleanup:
581 551
582 /* Always delete the operands */ 552 /* Always delete the operands */
583 553
584 acpi_ut_remove_reference (offset_desc); 554 acpi_ut_remove_reference(offset_desc);
585 acpi_ut_remove_reference (buffer_desc); 555 acpi_ut_remove_reference(buffer_desc);
586 556
587 if (aml_opcode == AML_CREATE_FIELD_OP) { 557 if (aml_opcode == AML_CREATE_FIELD_OP) {
588 acpi_ut_remove_reference (length_desc); 558 acpi_ut_remove_reference(length_desc);
589 } 559 }
590 560
591 /* On failure, delete the result descriptor */ 561 /* On failure, delete the result descriptor */
592 562
593 if (ACPI_FAILURE (status)) { 563 if (ACPI_FAILURE(status)) {
594 acpi_ut_remove_reference (result_desc); /* Result descriptor */ 564 acpi_ut_remove_reference(result_desc); /* Result descriptor */
595 } 565 } else {
596 else {
597 /* Now the address and length are valid for this buffer_field */ 566 /* Now the address and length are valid for this buffer_field */
598 567
599 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; 568 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
600 } 569 }
601 570
602 return_ACPI_STATUS (status); 571 return_ACPI_STATUS(status);
603} 572}
604 573
605
606/******************************************************************************* 574/*******************************************************************************
607 * 575 *
608 * FUNCTION: acpi_ds_eval_buffer_field_operands 576 * FUNCTION: acpi_ds_eval_buffer_field_operands
@@ -618,24 +586,21 @@ cleanup:
618 ******************************************************************************/ 586 ******************************************************************************/
619 587
620acpi_status 588acpi_status
621acpi_ds_eval_buffer_field_operands ( 589acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
622 struct acpi_walk_state *walk_state, 590 union acpi_parse_object *op)
623 union acpi_parse_object *op)
624{ 591{
625 acpi_status status; 592 acpi_status status;
626 union acpi_operand_object *obj_desc; 593 union acpi_operand_object *obj_desc;
627 struct acpi_namespace_node *node; 594 struct acpi_namespace_node *node;
628 union acpi_parse_object *next_op; 595 union acpi_parse_object *next_op;
629
630
631 ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op);
632 596
597 ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op);
633 598
634 /* 599 /*
635 * 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
636 * create_xxx_field declaration 601 * create_xxx_field declaration
637 */ 602 */
638 node = op->common.node; 603 node = op->common.node;
639 604
640 /* next_op points to the op that holds the Buffer */ 605 /* next_op points to the op that holds the Buffer */
641 606
@@ -643,30 +608,32 @@ acpi_ds_eval_buffer_field_operands (
643 608
644 /* Evaluate/create the address and length operands */ 609 /* Evaluate/create the address and length operands */
645 610
646 status = acpi_ds_create_operands (walk_state, next_op); 611 status = acpi_ds_create_operands(walk_state, next_op);
647 if (ACPI_FAILURE (status)) { 612 if (ACPI_FAILURE(status)) {
648 return_ACPI_STATUS (status); 613 return_ACPI_STATUS(status);
649 } 614 }
650 615
651 obj_desc = acpi_ns_get_attached_object (node); 616 obj_desc = acpi_ns_get_attached_object(node);
652 if (!obj_desc) { 617 if (!obj_desc) {
653 return_ACPI_STATUS (AE_NOT_EXIST); 618 return_ACPI_STATUS(AE_NOT_EXIST);
654 } 619 }
655 620
656 /* Resolve the operands */ 621 /* Resolve the operands */
657 622
658 status = acpi_ex_resolve_operands (op->common.aml_opcode, 623 status = acpi_ex_resolve_operands(op->common.aml_opcode,
659 ACPI_WALK_OPERANDS, walk_state); 624 ACPI_WALK_OPERANDS, walk_state);
660 625
661 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 626 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
662 acpi_ps_get_opcode_name (op->common.aml_opcode), 627 acpi_ps_get_opcode_name(op->common.aml_opcode),
663 walk_state->num_operands, "after acpi_ex_resolve_operands"); 628 walk_state->num_operands,
629 "after acpi_ex_resolve_operands");
664 630
665 if (ACPI_FAILURE (status)) { 631 if (ACPI_FAILURE(status)) {
666 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",
667 acpi_ps_get_opcode_name (op->common.aml_opcode), status)); 633 acpi_ps_get_opcode_name(op->common.
634 aml_opcode), status));
668 635
669 return_ACPI_STATUS (status); 636 return_ACPI_STATUS(status);
670 } 637 }
671 638
672 /* Initialize the Buffer Field */ 639 /* Initialize the Buffer Field */
@@ -674,22 +641,25 @@ acpi_ds_eval_buffer_field_operands (
674 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { 641 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
675 /* NOTE: Slightly different operands for this opcode */ 642 /* NOTE: Slightly different operands for this opcode */
676 643
677 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 644 status =
678 walk_state->operands[0], walk_state->operands[1], 645 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
679 walk_state->operands[2], walk_state->operands[3]); 646 walk_state->operands[0],
680 } 647 walk_state->operands[1],
681 else { 648 walk_state->operands[2],
649 walk_state->operands[3]);
650 } else {
682 /* All other, create_xxx_field opcodes */ 651 /* All other, create_xxx_field opcodes */
683 652
684 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 653 status =
685 walk_state->operands[0], walk_state->operands[1], 654 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
686 NULL, walk_state->operands[2]); 655 walk_state->operands[0],
656 walk_state->operands[1], NULL,
657 walk_state->operands[2]);
687 } 658 }
688 659
689 return_ACPI_STATUS (status); 660 return_ACPI_STATUS(status);
690} 661}
691 662
692
693/******************************************************************************* 663/*******************************************************************************
694 * 664 *
695 * FUNCTION: acpi_ds_eval_region_operands 665 * FUNCTION: acpi_ds_eval_region_operands
@@ -705,25 +675,22 @@ acpi_ds_eval_buffer_field_operands (
705 ******************************************************************************/ 675 ******************************************************************************/
706 676
707acpi_status 677acpi_status
708acpi_ds_eval_region_operands ( 678acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
709 struct acpi_walk_state *walk_state, 679 union acpi_parse_object *op)
710 union acpi_parse_object *op)
711{ 680{
712 acpi_status status; 681 acpi_status status;
713 union acpi_operand_object *obj_desc; 682 union acpi_operand_object *obj_desc;
714 union acpi_operand_object *operand_desc; 683 union acpi_operand_object *operand_desc;
715 struct acpi_namespace_node *node; 684 struct acpi_namespace_node *node;
716 union acpi_parse_object *next_op; 685 union acpi_parse_object *next_op;
717
718
719 ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op);
720 686
687 ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op);
721 688
722 /* 689 /*
723 * 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
724 * op_region declaration 691 * op_region declaration
725 */ 692 */
726 node = op->common.node; 693 node = op->common.node;
727 694
728 /* next_op points to the op that holds the space_iD */ 695 /* next_op points to the op that holds the space_iD */
729 696
@@ -735,26 +702,26 @@ acpi_ds_eval_region_operands (
735 702
736 /* Evaluate/create the address and length operands */ 703 /* Evaluate/create the address and length operands */
737 704
738 status = acpi_ds_create_operands (walk_state, next_op); 705 status = acpi_ds_create_operands(walk_state, next_op);
739 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
740 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
741 } 708 }
742 709
743 /* Resolve the length and address operands to numbers */ 710 /* Resolve the length and address operands to numbers */
744 711
745 status = acpi_ex_resolve_operands (op->common.aml_opcode, 712 status = acpi_ex_resolve_operands(op->common.aml_opcode,
746 ACPI_WALK_OPERANDS, walk_state); 713 ACPI_WALK_OPERANDS, walk_state);
747 if (ACPI_FAILURE (status)) { 714 if (ACPI_FAILURE(status)) {
748 return_ACPI_STATUS (status); 715 return_ACPI_STATUS(status);
749 } 716 }
750 717
751 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 718 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
752 acpi_ps_get_opcode_name (op->common.aml_opcode), 719 acpi_ps_get_opcode_name(op->common.aml_opcode),
753 1, "after acpi_ex_resolve_operands"); 720 1, "after acpi_ex_resolve_operands");
754 721
755 obj_desc = acpi_ns_get_attached_object (node); 722 obj_desc = acpi_ns_get_attached_object(node);
756 if (!obj_desc) { 723 if (!obj_desc) {
757 return_ACPI_STATUS (AE_NOT_EXIST); 724 return_ACPI_STATUS(AE_NOT_EXIST);
758 } 725 }
759 726
760 /* 727 /*
@@ -764,7 +731,7 @@ acpi_ds_eval_region_operands (
764 operand_desc = walk_state->operands[walk_state->num_operands - 1]; 731 operand_desc = walk_state->operands[walk_state->num_operands - 1];
765 732
766 obj_desc->region.length = (u32) operand_desc->integer.value; 733 obj_desc->region.length = (u32) operand_desc->integer.value;
767 acpi_ut_remove_reference (operand_desc); 734 acpi_ut_remove_reference(operand_desc);
768 735
769 /* 736 /*
770 * Get the address and save it 737 * Get the address and save it
@@ -773,22 +740,21 @@ acpi_ds_eval_region_operands (
773 operand_desc = walk_state->operands[walk_state->num_operands - 2]; 740 operand_desc = walk_state->operands[walk_state->num_operands - 2];
774 741
775 obj_desc->region.address = (acpi_physical_address) 742 obj_desc->region.address = (acpi_physical_address)
776 operand_desc->integer.value; 743 operand_desc->integer.value;
777 acpi_ut_remove_reference (operand_desc); 744 acpi_ut_remove_reference(operand_desc);
778 745
779 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",
780 obj_desc, 747 obj_desc,
781 ACPI_FORMAT_UINT64 (obj_desc->region.address), 748 ACPI_FORMAT_UINT64(obj_desc->region.address),
782 obj_desc->region.length)); 749 obj_desc->region.length));
783 750
784 /* Now the address and length are valid for this opregion */ 751 /* Now the address and length are valid for this opregion */
785 752
786 obj_desc->region.flags |= AOPOBJ_DATA_VALID; 753 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
787 754
788 return_ACPI_STATUS (status); 755 return_ACPI_STATUS(status);
789} 756}
790 757
791
792/******************************************************************************* 758/*******************************************************************************
793 * 759 *
794 * FUNCTION: acpi_ds_eval_data_object_operands 760 * FUNCTION: acpi_ds_eval_data_object_operands
@@ -805,46 +771,44 @@ acpi_ds_eval_region_operands (
805 ******************************************************************************/ 771 ******************************************************************************/
806 772
807acpi_status 773acpi_status
808acpi_ds_eval_data_object_operands ( 774acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
809 struct acpi_walk_state *walk_state, 775 union acpi_parse_object *op,
810 union acpi_parse_object *op, 776 union acpi_operand_object *obj_desc)
811 union acpi_operand_object *obj_desc)
812{ 777{
813 acpi_status status; 778 acpi_status status;
814 union acpi_operand_object *arg_desc; 779 union acpi_operand_object *arg_desc;
815 u32 length; 780 u32 length;
816
817
818 ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands");
819 781
782 ACPI_FUNCTION_TRACE("ds_eval_data_object_operands");
820 783
821 /* 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 */
822 785
823 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);
824 if (ACPI_FAILURE (status)) { 787 if (ACPI_FAILURE(status)) {
825 return_ACPI_STATUS (status); 788 return_ACPI_STATUS(status);
826 } 789 }
827 790
828 status = acpi_ex_resolve_operands (walk_state->opcode, 791 status = acpi_ex_resolve_operands(walk_state->opcode,
829 &(walk_state->operands [walk_state->num_operands -1]), 792 &(walk_state->
830 walk_state); 793 operands[walk_state->num_operands -
831 if (ACPI_FAILURE (status)) { 794 1]), walk_state);
832 return_ACPI_STATUS (status); 795 if (ACPI_FAILURE(status)) {
796 return_ACPI_STATUS(status);
833 } 797 }
834 798
835 /* Extract length operand */ 799 /* Extract length operand */
836 800
837 arg_desc = walk_state->operands [walk_state->num_operands - 1]; 801 arg_desc = walk_state->operands[walk_state->num_operands - 1];
838 length = (u32) arg_desc->integer.value; 802 length = (u32) arg_desc->integer.value;
839 803
840 /* Cleanup for length operand */ 804 /* Cleanup for length operand */
841 805
842 status = acpi_ds_obj_stack_pop (1, walk_state); 806 status = acpi_ds_obj_stack_pop(1, walk_state);
843 if (ACPI_FAILURE (status)) { 807 if (ACPI_FAILURE(status)) {
844 return_ACPI_STATUS (status); 808 return_ACPI_STATUS(status);
845 } 809 }
846 810
847 acpi_ut_remove_reference (arg_desc); 811 acpi_ut_remove_reference(arg_desc);
848 812
849 /* 813 /*
850 * Create the actual data object 814 * Create the actual data object
@@ -852,37 +816,42 @@ acpi_ds_eval_data_object_operands (
852 switch (op->common.aml_opcode) { 816 switch (op->common.aml_opcode) {
853 case AML_BUFFER_OP: 817 case AML_BUFFER_OP:
854 818
855 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);
856 break; 822 break;
857 823
858 case AML_PACKAGE_OP: 824 case AML_PACKAGE_OP:
859 case AML_VAR_PACKAGE_OP: 825 case AML_VAR_PACKAGE_OP:
860 826
861 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);
862 break; 830 break;
863 831
864 default: 832 default:
865 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 833 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
866 } 834 }
867 835
868 if (ACPI_SUCCESS (status)) { 836 if (ACPI_SUCCESS(status)) {
869 /* 837 /*
870 * 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 -
871 * 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
872 * for the package. 840 * for the package.
873 */ 841 */
874 if ((!op->common.parent) || 842 if ((!op->common.parent) ||
875 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && 843 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
876 (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) && 844 (op->common.parent->common.aml_opcode !=
877 (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))) {
878 walk_state->result_obj = obj_desc; 848 walk_state->result_obj = obj_desc;
879 } 849 }
880 } 850 }
881 851
882 return_ACPI_STATUS (status); 852 return_ACPI_STATUS(status);
883} 853}
884 854
885
886/******************************************************************************* 855/*******************************************************************************
887 * 856 *
888 * FUNCTION: acpi_ds_exec_begin_control_op 857 * FUNCTION: acpi_ds_exec_begin_control_op
@@ -898,19 +867,16 @@ acpi_ds_eval_data_object_operands (
898 ******************************************************************************/ 867 ******************************************************************************/
899 868
900acpi_status 869acpi_status
901acpi_ds_exec_begin_control_op ( 870acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
902 struct acpi_walk_state *walk_state, 871 union acpi_parse_object *op)
903 union acpi_parse_object *op)
904{ 872{
905 acpi_status status = AE_OK; 873 acpi_status status = AE_OK;
906 union acpi_generic_state *control_state; 874 union acpi_generic_state *control_state;
907
908
909 ACPI_FUNCTION_NAME ("ds_exec_begin_control_op");
910 875
876 ACPI_FUNCTION_NAME("ds_exec_begin_control_op");
911 877
912 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, 878 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
913 op->common.aml_opcode, walk_state)); 879 op->common.aml_opcode, walk_state));
914 880
915 switch (op->common.aml_opcode) { 881 switch (op->common.aml_opcode) {
916 case AML_IF_OP: 882 case AML_IF_OP:
@@ -921,7 +887,7 @@ acpi_ds_exec_begin_control_op (
921 * constructs. We need to manage these as a stack, in order 887 * constructs. We need to manage these as a stack, in order
922 * to handle nesting. 888 * to handle nesting.
923 */ 889 */
924 control_state = acpi_ut_create_control_state (); 890 control_state = acpi_ut_create_control_state();
925 if (!control_state) { 891 if (!control_state) {
926 status = AE_NO_MEMORY; 892 status = AE_NO_MEMORY;
927 break; 893 break;
@@ -930,14 +896,16 @@ acpi_ds_exec_begin_control_op (
930 * Save a pointer to the predicate for multiple executions 896 * Save a pointer to the predicate for multiple executions
931 * of a loop 897 * of a loop
932 */ 898 */
933 control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; 899 control_state->control.aml_predicate_start =
934 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;
935 control_state->control.opcode = op->common.aml_opcode; 903 control_state->control.opcode = op->common.aml_opcode;
936 904
937
938 /* Push the control state on this walk's control stack */ 905 /* Push the control state on this walk's control stack */
939 906
940 acpi_ut_push_generic_state (&walk_state->control_state, control_state); 907 acpi_ut_push_generic_state(&walk_state->control_state,
908 control_state);
941 break; 909 break;
942 910
943 case AML_ELSE_OP: 911 case AML_ELSE_OP:
@@ -962,7 +930,6 @@ acpi_ds_exec_begin_control_op (
962 return (status); 930 return (status);
963} 931}
964 932
965
966/******************************************************************************* 933/*******************************************************************************
967 * 934 *
968 * FUNCTION: acpi_ds_exec_end_control_op 935 * FUNCTION: acpi_ds_exec_end_control_op
@@ -978,46 +945,42 @@ acpi_ds_exec_begin_control_op (
978 ******************************************************************************/ 945 ******************************************************************************/
979 946
980acpi_status 947acpi_status
981acpi_ds_exec_end_control_op ( 948acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
982 struct acpi_walk_state *walk_state, 949 union acpi_parse_object * op)
983 union acpi_parse_object *op)
984{ 950{
985 acpi_status status = AE_OK; 951 acpi_status status = AE_OK;
986 union acpi_generic_state *control_state; 952 union acpi_generic_state *control_state;
987
988
989 ACPI_FUNCTION_NAME ("ds_exec_end_control_op");
990 953
954 ACPI_FUNCTION_NAME("ds_exec_end_control_op");
991 955
992 switch (op->common.aml_opcode) { 956 switch (op->common.aml_opcode) {
993 case AML_IF_OP: 957 case AML_IF_OP:
994 958
995 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));
996 960
997 /* 961 /*
998 * Save the result of the predicate in case there is an 962 * Save the result of the predicate in case there is an
999 * ELSE to come 963 * ELSE to come
1000 */ 964 */
1001 walk_state->last_predicate = 965 walk_state->last_predicate =
1002 (u8) walk_state->control_state->common.value; 966 (u8) walk_state->control_state->common.value;
1003 967
1004 /* 968 /*
1005 * Pop the control state that was created at the start 969 * Pop the control state that was created at the start
1006 * of the IF and free it 970 * of the IF and free it
1007 */ 971 */
1008 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 972 control_state =
1009 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);
1010 break; 975 break;
1011 976
1012
1013 case AML_ELSE_OP: 977 case AML_ELSE_OP:
1014 978
1015 break; 979 break;
1016 980
1017
1018 case AML_WHILE_OP: 981 case AML_WHILE_OP:
1019 982
1020 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));
1021 984
1022 if (walk_state->control_state->common.value) { 985 if (walk_state->control_state->common.value) {
1023 /* Predicate was true, go back and evaluate it again! */ 986 /* Predicate was true, go back and evaluate it again! */
@@ -1025,22 +988,24 @@ acpi_ds_exec_end_control_op (
1025 status = AE_CTRL_PENDING; 988 status = AE_CTRL_PENDING;
1026 } 989 }
1027 990
1028 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 991 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1029 "[WHILE_OP] termination! Op=%p\n",op)); 992 "[WHILE_OP] termination! Op=%p\n", op));
1030 993
1031 /* Pop this control state and free it */ 994 /* Pop this control state and free it */
1032 995
1033 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 996 control_state =
997 acpi_ut_pop_generic_state(&walk_state->control_state);
1034 998
1035 walk_state->aml_last_while = control_state->control.aml_predicate_start; 999 walk_state->aml_last_while =
1036 acpi_ut_delete_generic_state (control_state); 1000 control_state->control.aml_predicate_start;
1001 acpi_ut_delete_generic_state(control_state);
1037 break; 1002 break;
1038 1003
1039
1040 case AML_RETURN_OP: 1004 case AML_RETURN_OP:
1041 1005
1042 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1006 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1043 "[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));
1044 1009
1045 /* 1010 /*
1046 * One optional operand -- the return value 1011 * One optional operand -- the return value
@@ -1050,12 +1015,14 @@ acpi_ds_exec_end_control_op (
1050 if (op->common.value.arg) { 1015 if (op->common.value.arg) {
1051 /* Since we have a real Return(), delete any implicit return */ 1016 /* Since we have a real Return(), delete any implicit return */
1052 1017
1053 acpi_ds_clear_implicit_return (walk_state); 1018 acpi_ds_clear_implicit_return(walk_state);
1054 1019
1055 /* Return statement has an immediate operand */ 1020 /* Return statement has an immediate operand */
1056 1021
1057 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 1022 status =
1058 if (ACPI_FAILURE (status)) { 1023 acpi_ds_create_operands(walk_state,
1024 op->common.value.arg);
1025 if (ACPI_FAILURE(status)) {
1059 return (status); 1026 return (status);
1060 } 1027 }
1061 1028
@@ -1064,8 +1031,10 @@ acpi_ds_exec_end_control_op (
1064 * an arg or local), resolve it now because it may 1031 * an arg or local), resolve it now because it may
1065 * cease to exist at the end of the method. 1032 * cease to exist at the end of the method.
1066 */ 1033 */
1067 status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); 1034 status =
1068 if (ACPI_FAILURE (status)) { 1035 acpi_ex_resolve_to_value(&walk_state->operands[0],
1036 walk_state);
1037 if (ACPI_FAILURE(status)) {
1069 return (status); 1038 return (status);
1070 } 1039 }
1071 1040
@@ -1075,12 +1044,11 @@ acpi_ds_exec_end_control_op (
1075 * is set to anything other than zero! 1044 * is set to anything other than zero!
1076 */ 1045 */
1077 walk_state->return_desc = walk_state->operands[0]; 1046 walk_state->return_desc = walk_state->operands[0];
1078 } 1047 } else if ((walk_state->results) &&
1079 else if ((walk_state->results) && 1048 (walk_state->results->results.num_results > 0)) {
1080 (walk_state->results->results.num_results > 0)) {
1081 /* Since we have a real Return(), delete any implicit return */ 1049 /* Since we have a real Return(), delete any implicit return */
1082 1050
1083 acpi_ds_clear_implicit_return (walk_state); 1051 acpi_ds_clear_implicit_return(walk_state);
1084 1052
1085 /* 1053 /*
1086 * The return value has come from a previous calculation. 1054 * The return value has come from a previous calculation.
@@ -1091,67 +1059,78 @@ acpi_ds_exec_end_control_op (
1091 * 1059 *
1092 * Allow references created by the Index operator to return unchanged. 1060 * Allow references created by the Index operator to return unchanged.
1093 */ 1061 */
1094 if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) && 1062 if ((ACPI_GET_DESCRIPTOR_TYPE
1095 (ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1063 (walk_state->results->results.obj_desc[0]) ==
1096 ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { 1064 ACPI_DESC_TYPE_OPERAND)
1097 status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); 1065 &&
1098 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)) {
1099 return (status); 1077 return (status);
1100 } 1078 }
1101 } 1079 }
1102 1080
1103 walk_state->return_desc = walk_state->results->results.obj_desc [0]; 1081 walk_state->return_desc =
1104 } 1082 walk_state->results->results.obj_desc[0];
1105 else { 1083 } else {
1106 /* No return operand */ 1084 /* No return operand */
1107 1085
1108 if (walk_state->num_operands) { 1086 if (walk_state->num_operands) {
1109 acpi_ut_remove_reference (walk_state->operands [0]); 1087 acpi_ut_remove_reference(walk_state->
1088 operands[0]);
1110 } 1089 }
1111 1090
1112 walk_state->operands [0] = NULL; 1091 walk_state->operands[0] = NULL;
1113 walk_state->num_operands = 0; 1092 walk_state->num_operands = 0;
1114 walk_state->return_desc = NULL; 1093 walk_state->return_desc = NULL;
1115 } 1094 }
1116 1095
1117 1096 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1118 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1097 "Completed RETURN_OP State=%p, ret_val=%p\n",
1119 "Completed RETURN_OP State=%p, ret_val=%p\n", 1098 walk_state, walk_state->return_desc));
1120 walk_state, walk_state->return_desc));
1121 1099
1122 /* End the control method execution right now */ 1100 /* End the control method execution right now */
1123 1101
1124 status = AE_CTRL_TERMINATE; 1102 status = AE_CTRL_TERMINATE;
1125 break; 1103 break;
1126 1104
1127
1128 case AML_NOOP_OP: 1105 case AML_NOOP_OP:
1129 1106
1130 /* Just do nothing! */ 1107 /* Just do nothing! */
1131 break; 1108 break;
1132 1109
1133
1134 case AML_BREAK_POINT_OP: 1110 case AML_BREAK_POINT_OP:
1135 1111
1136 /* Call up to the OS service layer to handle this */ 1112 /* Call up to the OS service layer to handle this */
1137 1113
1138 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");
1139 1117
1140 /* If and when it returns, all done. */ 1118 /* If and when it returns, all done. */
1141 1119
1142 break; 1120 break;
1143 1121
1144
1145 case AML_BREAK_OP: 1122 case AML_BREAK_OP:
1146 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1123 case AML_CONTINUE_OP: /* ACPI 2.0 */
1147
1148 1124
1149 /* Pop and delete control states until we find a while */ 1125 /* Pop and delete control states until we find a while */
1150 1126
1151 while (walk_state->control_state && 1127 while (walk_state->control_state &&
1152 (walk_state->control_state->control.opcode != AML_WHILE_OP)) { 1128 (walk_state->control_state->control.opcode !=
1153 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 1129 AML_WHILE_OP)) {
1154 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);
1155 } 1134 }
1156 1135
1157 /* No while found? */ 1136 /* No while found? */
@@ -1162,23 +1141,23 @@ acpi_ds_exec_end_control_op (
1162 1141
1163 /* 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; */
1164 1143
1165 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;
1166 1146
1167 /* Return status depending on opcode */ 1147 /* Return status depending on opcode */
1168 1148
1169 if (op->common.aml_opcode == AML_BREAK_OP) { 1149 if (op->common.aml_opcode == AML_BREAK_OP) {
1170 status = AE_CTRL_BREAK; 1150 status = AE_CTRL_BREAK;
1171 } 1151 } else {
1172 else {
1173 status = AE_CTRL_CONTINUE; 1152 status = AE_CTRL_CONTINUE;
1174 } 1153 }
1175 break; 1154 break;
1176 1155
1177
1178 default: 1156 default:
1179 1157
1180 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1181 op->common.aml_opcode, op)); 1159 "Unknown control opcode=%X Op=%p\n",
1160 op->common.aml_opcode, op));
1182 1161
1183 status = AE_AML_BAD_OPCODE; 1162 status = AE_AML_BAD_OPCODE;
1184 break; 1163 break;
@@ -1186,4 +1165,3 @@ acpi_ds_exec_end_control_op (
1186 1165
1187 return (status); 1166 return (status);
1188} 1167}
1189
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 9100c0bda470..362bbcfc1718 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>
@@ -55,8 +54,7 @@
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,23 +117,21 @@ 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
@@ -157,14 +149,15 @@ acpi_ds_load1_begin_op (
157 } 149 }
158 } 150 }
159 151
160 path = acpi_ps_get_next_namestring (&walk_state->parser_state); 152 path = acpi_ps_get_next_namestring(&walk_state->parser_state);
161 153
162 /* Map the raw opcode into an internal object type */ 154 /* Map the raw opcode into an internal object type */
163 155
164 object_type = walk_state->op_info->object_type; 156 object_type = walk_state->op_info->object_type;
165 157
166 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 158 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
167 "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)));
168 161
169 switch (walk_state->opcode) { 162 switch (walk_state->opcode) {
170 case AML_SCOPE_OP: 163 case AML_SCOPE_OP:
@@ -174,8 +167,10 @@ acpi_ds_load1_begin_op (
174 * 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.
175 * Allow search-to-root for single namesegs. 168 * Allow search-to-root for single namesegs.
176 */ 169 */
177 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 170 status =
178 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 171 acpi_ns_lookup(walk_state->scope_info, path, object_type,
172 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
173 walk_state, &(node));
179#ifdef ACPI_ASL_COMPILER 174#ifdef ACPI_ASL_COMPILER
180 if (status == AE_NOT_FOUND) { 175 if (status == AE_NOT_FOUND) {
181 /* 176 /*
@@ -183,14 +178,16 @@ acpi_ds_load1_begin_op (
183 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
184 * insert the name into the namespace. 179 * insert the name into the namespace.
185 */ 180 */
186 acpi_dm_add_to_external_list (path); 181 acpi_dm_add_to_external_list(path);
187 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 182 status =
188 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 183 acpi_ns_lookup(walk_state->scope_info, path,
189 walk_state, &(node)); 184 object_type, ACPI_IMODE_LOAD_PASS1,
185 ACPI_NS_SEARCH_PARENT, walk_state,
186 &(node));
190 } 187 }
191#endif 188#endif
192 if (ACPI_FAILURE (status)) { 189 if (ACPI_FAILURE(status)) {
193 ACPI_REPORT_NSERROR (path, status); 190 ACPI_REPORT_NSERROR(path, status);
194 return (status); 191 return (status);
195 } 192 }
196 193
@@ -199,7 +196,7 @@ acpi_ds_load1_begin_op (
199 * one of the opcodes that actually opens a scope 196 * one of the opcodes that actually opens a scope
200 */ 197 */
201 switch (node->type) { 198 switch (node->type) {
202 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 199 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
203 case ACPI_TYPE_DEVICE: 200 case ACPI_TYPE_DEVICE:
204 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
205 case ACPI_TYPE_PROCESSOR: 202 case ACPI_TYPE_PROCESSOR:
@@ -223,9 +220,10 @@ acpi_ds_load1_begin_op (
223 * a warning 220 * a warning
224 */ 221 */
225 222
226 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 223 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
227 "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",
228 path, acpi_ut_get_type_name (node->type))); 225 path,
226 acpi_ut_get_type_name(node->type)));
229 227
230 node->type = ACPI_TYPE_ANY; 228 node->type = ACPI_TYPE_ANY;
231 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 229 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -235,15 +233,12 @@ acpi_ds_load1_begin_op (
235 233
236 /* All other types are an error */ 234 /* All other types are an error */
237 235
238 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));
239 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
240 acpi_ut_get_type_name (node->type), path));
241 237
242 return (AE_AML_OPERAND_TYPE); 238 return (AE_AML_OPERAND_TYPE);
243 } 239 }
244 break; 240 break;
245 241
246
247 default: 242 default:
248 243
249 /* 244 /*
@@ -272,15 +267,15 @@ acpi_ds_load1_begin_op (
272 267
273 flags = ACPI_NS_NO_UPSEARCH; 268 flags = ACPI_NS_NO_UPSEARCH;
274 if ((walk_state->opcode != AML_SCOPE_OP) && 269 if ((walk_state->opcode != AML_SCOPE_OP) &&
275 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
276 flags |= ACPI_NS_ERROR_IF_FOUND; 271 flags |= ACPI_NS_ERROR_IF_FOUND;
277 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 272 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
278 acpi_ut_get_type_name (object_type))); 273 "[%s] Cannot already exist\n",
279 } 274 acpi_ut_get_type_name(object_type)));
280 else { 275 } else {
281 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 276 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
282 "[%s] Both Find or Create allowed\n", 277 "[%s] Both Find or Create allowed\n",
283 acpi_ut_get_type_name (object_type))); 278 acpi_ut_get_type_name(object_type)));
284 } 279 }
285 280
286 /* 281 /*
@@ -289,22 +284,23 @@ acpi_ds_load1_begin_op (
289 * 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
290 * parse tree later. 285 * parse tree later.
291 */ 286 */
292 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 287 status =
293 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); 288 acpi_ns_lookup(walk_state->scope_info, path, object_type,
294 if (ACPI_FAILURE (status)) { 289 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
295 ACPI_REPORT_NSERROR (path, status); 290 &(node));
291 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status);
296 return (status); 293 return (status);
297 } 294 }
298 break; 295 break;
299 } 296 }
300 297
301
302 /* Common exit */ 298 /* Common exit */
303 299
304 if (!op) { 300 if (!op) {
305 /* Create a new op */ 301 /* Create a new op */
306 302
307 op = acpi_ps_alloc_op (walk_state->opcode); 303 op = acpi_ps_alloc_op(walk_state->opcode);
308 if (!op) { 304 if (!op) {
309 return (AE_NO_MEMORY); 305 return (AE_NO_MEMORY);
310 } 306 }
@@ -318,19 +314,18 @@ acpi_ds_load1_begin_op (
318 op->named.path = (u8 *) path; 314 op->named.path = (u8 *) path;
319#endif 315#endif
320 316
321
322 /* 317 /*
323 * 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
324 * can get it again quickly when this scope is closed 319 * can get it again quickly when this scope is closed
325 */ 320 */
326 op->common.node = node; 321 op->common.node = node;
327 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);
328 324
329 *out_op = op; 325 *out_op = op;
330 return (status); 326 return (status);
331} 327}
332 328
333
334/******************************************************************************* 329/*******************************************************************************
335 * 330 *
336 * FUNCTION: acpi_ds_load1_end_op 331 * FUNCTION: acpi_ds_load1_end_op
@@ -344,20 +339,17 @@ acpi_ds_load1_begin_op (
344 * 339 *
345 ******************************************************************************/ 340 ******************************************************************************/
346 341
347acpi_status 342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
348acpi_ds_load1_end_op (
349 struct acpi_walk_state *walk_state)
350{ 343{
351 union acpi_parse_object *op; 344 union acpi_parse_object *op;
352 acpi_object_type object_type; 345 acpi_object_type object_type;
353 acpi_status status = AE_OK; 346 acpi_status status = AE_OK;
354
355
356 ACPI_FUNCTION_NAME ("ds_load1_end_op");
357 347
348 ACPI_FUNCTION_NAME("ds_load1_end_op");
358 349
359 op = walk_state->op; 350 op = walk_state->op;
360 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));
361 353
362 /* We are only interested in opcodes that have an associated name */ 354 /* We are only interested in opcodes that have an associated name */
363 355
@@ -371,21 +363,20 @@ acpi_ds_load1_end_op (
371 363
372#ifndef ACPI_NO_METHOD_EXECUTION 364#ifndef ACPI_NO_METHOD_EXECUTION
373 if (walk_state->op_info->flags & AML_FIELD) { 365 if (walk_state->op_info->flags & AML_FIELD) {
374 if (walk_state->opcode == AML_FIELD_OP || 366 if (walk_state->opcode == AML_FIELD_OP ||
375 walk_state->opcode == AML_BANK_FIELD_OP || 367 walk_state->opcode == AML_BANK_FIELD_OP ||
376 walk_state->opcode == AML_INDEX_FIELD_OP) { 368 walk_state->opcode == AML_INDEX_FIELD_OP) {
377 status = acpi_ds_init_field_objects (op, walk_state); 369 status = acpi_ds_init_field_objects(op, walk_state);
378 } 370 }
379 return (status); 371 return (status);
380 } 372 }
381 373
382
383 if (op->common.aml_opcode == AML_REGION_OP) { 374 if (op->common.aml_opcode == AML_REGION_OP) {
384 status = acpi_ex_create_region (op->named.data, op->named.length, 375 status = acpi_ex_create_region(op->named.data, op->named.length,
385 (acpi_adr_space_type) 376 (acpi_adr_space_type)
386 ((op->common.value.arg)->common.value.integer), 377 ((op->common.value.arg)->common.
387 walk_state); 378 value.integer), walk_state);
388 if (ACPI_FAILURE (status)) { 379 if (ACPI_FAILURE(status)) {
389 return (status); 380 return (status);
390 } 381 }
391 } 382 }
@@ -395,8 +386,11 @@ acpi_ds_load1_end_op (
395 /* For Name opcode, get the object type from the argument */ 386 /* For Name opcode, get the object type from the argument */
396 387
397 if (op->common.value.arg) { 388 if (op->common.value.arg) {
398 object_type = (acpi_ps_get_opcode_info ( 389 object_type = (acpi_ps_get_opcode_info((op->common.
399 (op->common.value.arg)->common.aml_opcode))->object_type; 390 value.arg)->
391 common.
392 aml_opcode))->
393 object_type;
400 op->common.node->type = (u8) object_type; 394 op->common.node->type = (u8) object_type;
401 } 395 }
402 } 396 }
@@ -410,23 +404,26 @@ acpi_ds_load1_end_op (
410 * of invocations of the method (need to know the number of 404 * of invocations of the method (need to know the number of
411 * arguments.) 405 * arguments.)
412 */ 406 */
413 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
414 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 408 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
415 walk_state, op, op->named.node)); 409 walk_state, op, op->named.node));
416 410
417 if (!acpi_ns_get_attached_object (op->named.node)) { 411 if (!acpi_ns_get_attached_object(op->named.node)) {
418 walk_state->operands[0] = (void *) op->named.node; 412 walk_state->operands[0] = (void *)op->named.node;
419 walk_state->num_operands = 1; 413 walk_state->num_operands = 1;
420 414
421 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 415 status =
422 if (ACPI_SUCCESS (status)) { 416 acpi_ds_create_operands(walk_state,
423 status = acpi_ex_create_method (op->named.data, 417 op->common.value.arg);
424 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);
425 } 422 }
426 walk_state->operands[0] = NULL; 423 walk_state->operands[0] = NULL;
427 walk_state->num_operands = 0; 424 walk_state->num_operands = 0;
428 425
429 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
430 return (status); 427 return (status);
431 } 428 }
432 } 429 }
@@ -434,17 +431,17 @@ acpi_ds_load1_end_op (
434 431
435 /* Pop the scope stack */ 432 /* Pop the scope stack */
436 433
437 if (acpi_ns_opens_scope (object_type)) { 434 if (acpi_ns_opens_scope(object_type)) {
438 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
439 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));
440 438
441 status = acpi_ds_scope_stack_pop (walk_state); 439 status = acpi_ds_scope_stack_pop(walk_state);
442 } 440 }
443 441
444 return (status); 442 return (status);
445} 443}
446 444
447
448/******************************************************************************* 445/*******************************************************************************
449 * 446 *
450 * FUNCTION: acpi_ds_load2_begin_op 447 * FUNCTION: acpi_ds_load2_begin_op
@@ -459,50 +456,50 @@ acpi_ds_load1_end_op (
459 ******************************************************************************/ 456 ******************************************************************************/
460 457
461acpi_status 458acpi_status
462acpi_ds_load2_begin_op ( 459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
463 struct acpi_walk_state *walk_state, 460 union acpi_parse_object ** out_op)
464 union acpi_parse_object **out_op)
465{ 461{
466 union acpi_parse_object *op; 462 union acpi_parse_object *op;
467 struct acpi_namespace_node *node; 463 struct acpi_namespace_node *node;
468 acpi_status status; 464 acpi_status status;
469 acpi_object_type object_type; 465 acpi_object_type object_type;
470 char *buffer_ptr; 466 char *buffer_ptr;
471
472
473 ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
474 467
468 ACPI_FUNCTION_TRACE("ds_load2_begin_op");
475 469
476 op = walk_state->op; 470 op = walk_state->op;
477 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));
478 473
479 if (op) { 474 if (op) {
480 if ((walk_state->control_state) && 475 if ((walk_state->control_state) &&
481 (walk_state->control_state->common.state == 476 (walk_state->control_state->common.state ==
482 ACPI_CONTROL_CONDITIONAL_EXECUTING)) { 477 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
483 /* We are executing a while loop outside of a method */ 478 /* We are executing a while loop outside of a method */
484 479
485 status = acpi_ds_exec_begin_op (walk_state, out_op); 480 status = acpi_ds_exec_begin_op(walk_state, out_op);
486 return_ACPI_STATUS (status); 481 return_ACPI_STATUS(status);
487 } 482 }
488 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 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 489 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
495 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 490 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
496 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 491 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
497 "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, 492 "Begin/EXEC: %s (fl %8.8X)\n",
498 walk_state->op_info->flags)); 493 walk_state->op_info->name,
494 walk_state->op_info->flags));
499 495
500 /* Executing a type1 or type2 opcode outside of a method */ 496 /* Executing a type1 or type2 opcode outside of a method */
501 497
502 status = acpi_ds_exec_begin_op (walk_state, out_op); 498 status =
503 return_ACPI_STATUS (status); 499 acpi_ds_exec_begin_op(walk_state, out_op);
500 return_ACPI_STATUS(status);
504 } 501 }
505 return_ACPI_STATUS (AE_OK); 502 return_ACPI_STATUS(AE_OK);
506 } 503 }
507 504
508 /* Get the name we are going to enter or lookup in the namespace */ 505 /* Get the name we are going to enter or lookup in the namespace */
@@ -514,28 +511,27 @@ acpi_ds_load2_begin_op (
514 if (!buffer_ptr) { 511 if (!buffer_ptr) {
515 /* No name, just exit */ 512 /* No name, just exit */
516 513
517 return_ACPI_STATUS (AE_OK); 514 return_ACPI_STATUS(AE_OK);
518 } 515 }
519 } 516 } else {
520 else {
521 /* Get name from the op */ 517 /* Get name from the op */
522 518
523 buffer_ptr = (char *) &op->named.name; 519 buffer_ptr = (char *)&op->named.name;
524 } 520 }
525 } 521 } else {
526 else {
527 /* Get the namestring from the raw AML */ 522 /* Get the namestring from the raw AML */
528 523
529 buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state); 524 buffer_ptr =
525 acpi_ps_get_next_namestring(&walk_state->parser_state);
530 } 526 }
531 527
532 /* Map the opcode into an internal object type */ 528 /* Map the opcode into an internal object type */
533 529
534 object_type = walk_state->op_info->object_type; 530 object_type = walk_state->op_info->object_type;
535 531
536 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 532 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
537 "State=%p Op=%p Type=%X\n", walk_state, op, object_type)); 533 "State=%p Op=%p Type=%X\n", walk_state, op,
538 534 object_type));
539 535
540 switch (walk_state->opcode) { 536 switch (walk_state->opcode) {
541 case AML_FIELD_OP: 537 case AML_FIELD_OP:
@@ -553,9 +549,10 @@ acpi_ds_load2_begin_op (
553 * Don't enter the name into the namespace, but look it up 549 * Don't enter the name into the namespace, but look it up
554 * for use later. 550 * for use later.
555 */ 551 */
556 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 552 status =
557 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 553 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
558 walk_state, &(node)); 554 object_type, ACPI_IMODE_EXECUTE,
555 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
559 break; 556 break;
560 557
561 case AML_SCOPE_OP: 558 case AML_SCOPE_OP:
@@ -565,28 +562,28 @@ acpi_ds_load2_begin_op (
565 * Don't enter the name into the namespace, but look it up 562 * Don't enter the name into the namespace, but look it up
566 * for use later. 563 * for use later.
567 */ 564 */
568 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 565 status =
569 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 566 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
570 walk_state, &(node)); 567 object_type, ACPI_IMODE_EXECUTE,
571 if (ACPI_FAILURE (status)) { 568 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
569 if (ACPI_FAILURE(status)) {
572#ifdef ACPI_ASL_COMPILER 570#ifdef ACPI_ASL_COMPILER
573 if (status == AE_NOT_FOUND) { 571 if (status == AE_NOT_FOUND) {
574 status = AE_OK; 572 status = AE_OK;
575 } 573 } else {
576 else { 574 ACPI_REPORT_NSERROR(buffer_ptr, status);
577 ACPI_REPORT_NSERROR (buffer_ptr, status);
578 } 575 }
579#else 576#else
580 ACPI_REPORT_NSERROR (buffer_ptr, status); 577 ACPI_REPORT_NSERROR(buffer_ptr, status);
581#endif 578#endif
582 return_ACPI_STATUS (status); 579 return_ACPI_STATUS(status);
583 } 580 }
584 /* 581 /*
585 * We must check to make sure that the target is 582 * We must check to make sure that the target is
586 * one of the opcodes that actually opens a scope 583 * one of the opcodes that actually opens a scope
587 */ 584 */
588 switch (node->type) { 585 switch (node->type) {
589 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 586 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
590 case ACPI_TYPE_DEVICE: 587 case ACPI_TYPE_DEVICE:
591 case ACPI_TYPE_POWER: 588 case ACPI_TYPE_POWER:
592 case ACPI_TYPE_PROCESSOR: 589 case ACPI_TYPE_PROCESSOR:
@@ -607,9 +604,7 @@ acpi_ds_load2_begin_op (
607 * Scope (DEB) { ... } 604 * Scope (DEB) { ... }
608 */ 605 */
609 606
610 ACPI_REPORT_WARNING (( 607 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)));
611 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
612 buffer_ptr, acpi_ut_get_type_name (node->type)));
613 608
614 node->type = ACPI_TYPE_ANY; 609 node->type = ACPI_TYPE_ANY;
615 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 610 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -619,9 +614,7 @@ acpi_ds_load2_begin_op (
619 614
620 /* All other types are an error */ 615 /* All other types are an error */
621 616
622 ACPI_REPORT_ERROR (( 617 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr));
623 "Invalid type (%s) for target of Scope operator [%4.4s]\n",
624 acpi_ut_get_type_name (node->type), buffer_ptr));
625 618
626 return (AE_AML_OPERAND_TYPE); 619 return (AE_AML_OPERAND_TYPE);
627 } 620 }
@@ -636,14 +629,16 @@ acpi_ds_load2_begin_op (
636 629
637 node = op->common.node; 630 node = op->common.node;
638 631
639 if (acpi_ns_opens_scope (object_type)) { 632 if (acpi_ns_opens_scope(object_type)) {
640 status = acpi_ds_scope_stack_push (node, object_type, walk_state); 633 status =
641 if (ACPI_FAILURE (status)) { 634 acpi_ds_scope_stack_push(node, object_type,
642 return_ACPI_STATUS (status); 635 walk_state);
636 if (ACPI_FAILURE(status)) {
637 return_ACPI_STATUS(status);
643 } 638 }
644 639
645 } 640 }
646 return_ACPI_STATUS (AE_OK); 641 return_ACPI_STATUS(AE_OK);
647 } 642 }
648 643
649 /* 644 /*
@@ -664,23 +659,24 @@ acpi_ds_load2_begin_op (
664 659
665 /* Add new entry into namespace */ 660 /* Add new entry into namespace */
666 661
667 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 662 status =
668 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 663 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
669 walk_state, &(node)); 664 object_type, ACPI_IMODE_LOAD_PASS2,
665 ACPI_NS_NO_UPSEARCH, walk_state, &(node));
670 break; 666 break;
671 } 667 }
672 668
673 if (ACPI_FAILURE (status)) { 669 if (ACPI_FAILURE(status)) {
674 ACPI_REPORT_NSERROR (buffer_ptr, status); 670 ACPI_REPORT_NSERROR(buffer_ptr, status);
675 return_ACPI_STATUS (status); 671 return_ACPI_STATUS(status);
676 } 672 }
677 673
678 if (!op) { 674 if (!op) {
679 /* Create a new op */ 675 /* Create a new op */
680 676
681 op = acpi_ps_alloc_op (walk_state->opcode); 677 op = acpi_ps_alloc_op(walk_state->opcode);
682 if (!op) { 678 if (!op) {
683 return_ACPI_STATUS (AE_NO_MEMORY); 679 return_ACPI_STATUS(AE_NO_MEMORY);
684 } 680 }
685 681
686 /* Initialize the new op */ 682 /* Initialize the new op */
@@ -697,10 +693,9 @@ acpi_ds_load2_begin_op (
697 */ 693 */
698 op->common.node = node; 694 op->common.node = node;
699 695
700 return_ACPI_STATUS (status); 696 return_ACPI_STATUS(status);
701} 697}
702 698
703
704/******************************************************************************* 699/*******************************************************************************
705 * 700 *
706 * FUNCTION: acpi_ds_load2_end_op 701 * FUNCTION: acpi_ds_load2_end_op
@@ -714,26 +709,23 @@ acpi_ds_load2_begin_op (
714 * 709 *
715 ******************************************************************************/ 710 ******************************************************************************/
716 711
717acpi_status 712acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
718acpi_ds_load2_end_op (
719 struct acpi_walk_state *walk_state)
720{ 713{
721 union acpi_parse_object *op; 714 union acpi_parse_object *op;
722 acpi_status status = AE_OK; 715 acpi_status status = AE_OK;
723 acpi_object_type object_type; 716 acpi_object_type object_type;
724 struct acpi_namespace_node *node; 717 struct acpi_namespace_node *node;
725 union acpi_parse_object *arg; 718 union acpi_parse_object *arg;
726 struct acpi_namespace_node *new_node; 719 struct acpi_namespace_node *new_node;
727#ifndef ACPI_NO_METHOD_EXECUTION 720#ifndef ACPI_NO_METHOD_EXECUTION
728 u32 i; 721 u32 i;
729#endif 722#endif
730 723
731 724 ACPI_FUNCTION_TRACE("ds_load2_end_op");
732 ACPI_FUNCTION_TRACE ("ds_load2_end_op");
733 725
734 op = walk_state->op; 726 op = walk_state->op;
735 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 727 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
736 walk_state->op_info->name, op, walk_state)); 728 walk_state->op_info->name, op, walk_state));
737 729
738 /* Check if opcode had an associated namespace object */ 730 /* Check if opcode had an associated namespace object */
739 731
@@ -742,23 +734,25 @@ acpi_ds_load2_end_op (
742 /* No namespace object. Executable opcode? */ 734 /* No namespace object. Executable opcode? */
743 735
744 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 736 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
745 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 737 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
746 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 738 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
747 "End/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, 739 "End/EXEC: %s (fl %8.8X)\n",
748 walk_state->op_info->flags)); 740 walk_state->op_info->name,
741 walk_state->op_info->flags));
749 742
750 /* Executing a type1 or type2 opcode outside of a method */ 743 /* Executing a type1 or type2 opcode outside of a method */
751 744
752 status = acpi_ds_exec_end_op (walk_state); 745 status = acpi_ds_exec_end_op(walk_state);
753 return_ACPI_STATUS (status); 746 return_ACPI_STATUS(status);
754 } 747 }
755#endif 748#endif
756 return_ACPI_STATUS (AE_OK); 749 return_ACPI_STATUS(AE_OK);
757 } 750 }
758 751
759 if (op->common.aml_opcode == AML_SCOPE_OP) { 752 if (op->common.aml_opcode == AML_SCOPE_OP) {
760 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 753 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
761 "Ending scope Op=%p State=%p\n", op, walk_state)); 754 "Ending scope Op=%p State=%p\n", op,
755 walk_state));
762 } 756 }
763 757
764 object_type = walk_state->op_info->object_type; 758 object_type = walk_state->op_info->object_type;
@@ -773,18 +767,19 @@ acpi_ds_load2_end_op (
773 * Put the Node on the object stack (Contains the ACPI Name of 767 * Put the Node on the object stack (Contains the ACPI Name of
774 * this object) 768 * this object)
775 */ 769 */
776 walk_state->operands[0] = (void *) node; 770 walk_state->operands[0] = (void *)node;
777 walk_state->num_operands = 1; 771 walk_state->num_operands = 1;
778 772
779 /* Pop the scope stack */ 773 /* Pop the scope stack */
780 774
781 if (acpi_ns_opens_scope (object_type) && 775 if (acpi_ns_opens_scope(object_type) &&
782 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 776 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
783 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 777 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
784 acpi_ut_get_type_name (object_type), op)); 778 "(%s) Popping scope for Op %p\n",
779 acpi_ut_get_type_name(object_type), op));
785 780
786 status = acpi_ds_scope_stack_pop (walk_state); 781 status = acpi_ds_scope_stack_pop(walk_state);
787 if (ACPI_FAILURE (status)) { 782 if (ACPI_FAILURE(status)) {
788 goto cleanup; 783 goto cleanup;
789 } 784 }
790 } 785 }
@@ -817,9 +812,10 @@ acpi_ds_load2_end_op (
817 * AML_THERMALZONE 812 * AML_THERMALZONE
818 */ 813 */
819 814
820 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 815 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
821 "Create-Load [%s] State=%p Op=%p named_obj=%p\n", 816 "Create-Load [%s] State=%p Op=%p named_obj=%p\n",
822 acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node)); 817 acpi_ps_get_opcode_name(op->common.aml_opcode),
818 walk_state, op, node));
823 819
824 /* Decode the opcode */ 820 /* Decode the opcode */
825 821
@@ -834,27 +830,32 @@ acpi_ds_load2_end_op (
834 * Create the field object, but the field buffer and index must 830 * Create the field object, but the field buffer and index must
835 * be evaluated later during the execution phase 831 * be evaluated later during the execution phase
836 */ 832 */
837 status = acpi_ds_create_buffer_field (op, walk_state); 833 status = acpi_ds_create_buffer_field(op, walk_state);
838 break; 834 break;
839 835
840 836 case AML_TYPE_NAMED_FIELD:
841 case AML_TYPE_NAMED_FIELD:
842 837
843 switch (op->common.aml_opcode) { 838 switch (op->common.aml_opcode) {
844 case AML_INDEX_FIELD_OP: 839 case AML_INDEX_FIELD_OP:
845 840
846 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node, 841 status =
847 walk_state); 842 acpi_ds_create_index_field(op,
843 (acpi_handle) arg->
844 common.node, walk_state);
848 break; 845 break;
849 846
850 case AML_BANK_FIELD_OP: 847 case AML_BANK_FIELD_OP:
851 848
852 status = acpi_ds_create_bank_field (op, arg->common.node, walk_state); 849 status =
850 acpi_ds_create_bank_field(op, arg->common.node,
851 walk_state);
853 break; 852 break;
854 853
855 case AML_FIELD_OP: 854 case AML_FIELD_OP:
856 855
857 status = acpi_ds_create_field (op, arg->common.node, walk_state); 856 status =
857 acpi_ds_create_field(op, arg->common.node,
858 walk_state);
858 break; 859 break;
859 860
860 default: 861 default:
@@ -863,43 +864,42 @@ acpi_ds_load2_end_op (
863 } 864 }
864 break; 865 break;
865 866
867 case AML_TYPE_NAMED_SIMPLE:
866 868
867 case AML_TYPE_NAMED_SIMPLE: 869 status = acpi_ds_create_operands(walk_state, arg);
868 870 if (ACPI_FAILURE(status)) {
869 status = acpi_ds_create_operands (walk_state, arg);
870 if (ACPI_FAILURE (status)) {
871 goto cleanup; 871 goto cleanup;
872 } 872 }
873 873
874 switch (op->common.aml_opcode) { 874 switch (op->common.aml_opcode) {
875 case AML_PROCESSOR_OP: 875 case AML_PROCESSOR_OP:
876 876
877 status = acpi_ex_create_processor (walk_state); 877 status = acpi_ex_create_processor(walk_state);
878 break; 878 break;
879 879
880 case AML_POWER_RES_OP: 880 case AML_POWER_RES_OP:
881 881
882 status = acpi_ex_create_power_resource (walk_state); 882 status = acpi_ex_create_power_resource(walk_state);
883 break; 883 break;
884 884
885 case AML_MUTEX_OP: 885 case AML_MUTEX_OP:
886 886
887 status = acpi_ex_create_mutex (walk_state); 887 status = acpi_ex_create_mutex(walk_state);
888 break; 888 break;
889 889
890 case AML_EVENT_OP: 890 case AML_EVENT_OP:
891 891
892 status = acpi_ex_create_event (walk_state); 892 status = acpi_ex_create_event(walk_state);
893 break; 893 break;
894 894
895 case AML_DATA_REGION_OP: 895 case AML_DATA_REGION_OP:
896 896
897 status = acpi_ex_create_table_region (walk_state); 897 status = acpi_ex_create_table_region(walk_state);
898 break; 898 break;
899 899
900 case AML_ALIAS_OP: 900 case AML_ALIAS_OP:
901 901
902 status = acpi_ex_create_alias (walk_state); 902 status = acpi_ex_create_alias(walk_state);
903 break; 903 break;
904 904
905 default: 905 default:
@@ -912,12 +912,12 @@ acpi_ds_load2_end_op (
912 /* Delete operands */ 912 /* Delete operands */
913 913
914 for (i = 1; i < walk_state->num_operands; i++) { 914 for (i = 1; i < walk_state->num_operands; i++) {
915 acpi_ut_remove_reference (walk_state->operands[i]); 915 acpi_ut_remove_reference(walk_state->operands[i]);
916 walk_state->operands[i] = NULL; 916 walk_state->operands[i] = NULL;
917 } 917 }
918 918
919 break; 919 break;
920#endif /* ACPI_NO_METHOD_EXECUTION */ 920#endif /* ACPI_NO_METHOD_EXECUTION */
921 921
922 case AML_TYPE_NAMED_COMPLEX: 922 case AML_TYPE_NAMED_COMPLEX:
923 923
@@ -933,9 +933,10 @@ acpi_ds_load2_end_op (
933 * If we have a valid region, initialize it 933 * If we have a valid region, initialize it
934 * Namespace is NOT locked at this point. 934 * Namespace is NOT locked at this point.
935 */ 935 */
936 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), 936 status =
937 FALSE); 937 acpi_ev_initialize_region
938 if (ACPI_FAILURE (status)) { 938 (acpi_ns_get_attached_object(node), FALSE);
939 if (ACPI_FAILURE(status)) {
939 /* 940 /*
940 * If AE_NOT_EXIST is returned, it is not fatal 941 * If AE_NOT_EXIST is returned, it is not fatal
941 * because many regions get created before a handler 942 * because many regions get created before a handler
@@ -947,13 +948,11 @@ acpi_ds_load2_end_op (
947 } 948 }
948 break; 949 break;
949 950
950
951 case AML_NAME_OP: 951 case AML_NAME_OP:
952 952
953 status = acpi_ds_create_node (walk_state, node, op); 953 status = acpi_ds_create_node(walk_state, node, op);
954 break; 954 break;
955#endif /* ACPI_NO_METHOD_EXECUTION */ 955#endif /* ACPI_NO_METHOD_EXECUTION */
956
957 956
958 default: 957 default:
959 /* All NAMED_COMPLEX opcodes must be handled above */ 958 /* All NAMED_COMPLEX opcodes must be handled above */
@@ -962,27 +961,28 @@ acpi_ds_load2_end_op (
962 } 961 }
963 break; 962 break;
964 963
965
966 case AML_CLASS_INTERNAL: 964 case AML_CLASS_INTERNAL:
967 965
968 /* case AML_INT_NAMEPATH_OP: */ 966 /* case AML_INT_NAMEPATH_OP: */
969 break; 967 break;
970 968
971
972 case AML_CLASS_METHOD_CALL: 969 case AML_CLASS_METHOD_CALL:
973 970
974 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 971 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
975 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n", 972 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
976 walk_state, op, node)); 973 walk_state, op, node));
977 974
978 /* 975 /*
979 * Lookup the method name and save the Node 976 * Lookup the method name and save the Node
980 */ 977 */
981 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 978 status =
982 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, 979 acpi_ns_lookup(walk_state->scope_info,
983 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 980 arg->common.value.string, ACPI_TYPE_ANY,
984 walk_state, &(new_node)); 981 ACPI_IMODE_LOAD_PASS2,
985 if (ACPI_SUCCESS (status)) { 982 ACPI_NS_SEARCH_PARENT |
983 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
984 &(new_node));
985 if (ACPI_SUCCESS(status)) {
986 986
987 /* 987 /*
988 * Make sure that what we found is indeed a method 988 * Make sure that what we found is indeed a method
@@ -998,24 +998,20 @@ acpi_ds_load2_end_op (
998 * parser uses, so we can get it again at the end of this scope 998 * parser uses, so we can get it again at the end of this scope
999 */ 999 */
1000 op->common.node = new_node; 1000 op->common.node = new_node;
1001 } 1001 } else {
1002 else { 1002 ACPI_REPORT_NSERROR(arg->common.value.string, status);
1003 ACPI_REPORT_NSERROR (arg->common.value.string, status);
1004 } 1003 }
1005 break; 1004 break;
1006 1005
1007
1008 default: 1006 default:
1009 break; 1007 break;
1010 } 1008 }
1011 1009
1012cleanup: 1010 cleanup:
1013 1011
1014 /* Remove the Node pushed at the very beginning */ 1012 /* Remove the Node pushed at the very beginning */
1015 1013
1016 walk_state->operands[0] = NULL; 1014 walk_state->operands[0] = NULL;
1017 walk_state->num_operands = 0; 1015 walk_state->num_operands = 0;
1018 return_ACPI_STATUS (status); 1016 return_ACPI_STATUS(status);
1019} 1017}
1020
1021
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 5621665991b5..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 341
350 ACPI_FUNCTION_NAME ("ds_result_stack_push"); 342 ACPI_FUNCTION_NAME("ds_result_stack_push");
351 343
352 344 state = acpi_ut_create_generic_state();
353 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
681 ACPI_FUNCTION_TRACE ("ds_create_walk_state");
682 650
651 ACPI_FUNCTION_TRACE("ds_create_walk_state");
683 652
684 walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state)); 653 walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state));
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_MEM_FREE (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,27 +705,23 @@ 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 u8 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
753 718
754 ACPI_FUNCTION_TRACE ("ds_init_aml_walk"); 719 ACPI_FUNCTION_TRACE("ds_init_aml_walk");
755 720
756 721 walk_state->parser_state.aml =
757 walk_state->parser_state.aml = 722 walk_state->parser_state.aml_start = aml_start;
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
@@ -766,42 +730,45 @@ acpi_ds_init_aml_walk (
766 730
767 if (info) { 731 if (info) {
768 if (info->parameter_type == ACPI_PARAM_GPE) { 732 if (info->parameter_type == ACPI_PARAM_GPE) {
769 walk_state->gpe_event_info = ACPI_CAST_PTR (struct acpi_gpe_event_info, 733 walk_state->gpe_event_info =
770 info->parameters); 734 ACPI_CAST_PTR(struct acpi_gpe_event_info,
771 } 735 info->parameters);
772 else { 736 } else {
773 walk_state->params = info->parameters; 737 walk_state->params = info->parameters;
774 walk_state->caller_return_desc = &info->return_object; 738 walk_state->caller_return_desc = &info->return_object;
775 } 739 }
776 } 740 }
777 741
778 status = acpi_ps_init_scope (&walk_state->parser_state, op); 742 status = acpi_ps_init_scope(&walk_state->parser_state, op);
779 if (ACPI_FAILURE (status)) { 743 if (ACPI_FAILURE(status)) {
780 return_ACPI_STATUS (status); 744 return_ACPI_STATUS(status);
781 } 745 }
782 746
783 if (method_node) { 747 if (method_node) {
784 walk_state->parser_state.start_node = method_node; 748 walk_state->parser_state.start_node = method_node;
785 walk_state->walk_type = ACPI_WALK_METHOD; 749 walk_state->walk_type = ACPI_WALK_METHOD;
786 walk_state->method_node = method_node; 750 walk_state->method_node = method_node;
787 walk_state->method_desc = acpi_ns_get_attached_object (method_node); 751 walk_state->method_desc =
752 acpi_ns_get_attached_object(method_node);
788 753
789 /* Push start scope on scope stack and make it current */ 754 /* Push start scope on scope stack and make it current */
790 755
791 status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state); 756 status =
792 if (ACPI_FAILURE (status)) { 757 acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD,
793 return_ACPI_STATUS (status); 758 walk_state);
759 if (ACPI_FAILURE(status)) {
760 return_ACPI_STATUS(status);
794 } 761 }
795 762
796 /* Init the method arguments */ 763 /* Init the method arguments */
797 764
798 status = acpi_ds_method_data_init_args (walk_state->params, 765 status = acpi_ds_method_data_init_args(walk_state->params,
799 ACPI_METHOD_NUM_ARGS, walk_state); 766 ACPI_METHOD_NUM_ARGS,
800 if (ACPI_FAILURE (status)) { 767 walk_state);
801 return_ACPI_STATUS (status); 768 if (ACPI_FAILURE(status)) {
769 return_ACPI_STATUS(status);
802 } 770 }
803 } 771 } else {
804 else {
805 /* 772 /*
806 * Setup the current scope. 773 * Setup the current scope.
807 * 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.
@@ -815,27 +782,27 @@ acpi_ds_init_aml_walk (
815 782
816 if (!extra_op) { 783 if (!extra_op) {
817 parser_state->start_node = NULL; 784 parser_state->start_node = NULL;
818 } 785 } else {
819 else {
820 parser_state->start_node = extra_op->common.node; 786 parser_state->start_node = extra_op->common.node;
821 } 787 }
822 788
823 if (parser_state->start_node) { 789 if (parser_state->start_node) {
824 /* Push start scope on scope stack and make it current */ 790 /* Push start scope on scope stack and make it current */
825 791
826 status = acpi_ds_scope_stack_push (parser_state->start_node, 792 status =
827 parser_state->start_node->type, walk_state); 793 acpi_ds_scope_stack_push(parser_state->start_node,
828 if (ACPI_FAILURE (status)) { 794 parser_state->start_node->
829 return_ACPI_STATUS (status); 795 type, walk_state);
796 if (ACPI_FAILURE(status)) {
797 return_ACPI_STATUS(status);
830 } 798 }
831 } 799 }
832 } 800 }
833 801
834 status = acpi_ds_init_callbacks (walk_state, pass_number); 802 status = acpi_ds_init_callbacks(walk_state, pass_number);
835 return_ACPI_STATUS (status); 803 return_ACPI_STATUS(status);
836} 804}
837 805
838
839/******************************************************************************* 806/*******************************************************************************
840 * 807 *
841 * FUNCTION: acpi_ds_delete_walk_state 808 * FUNCTION: acpi_ds_delete_walk_state
@@ -848,29 +815,27 @@ acpi_ds_init_aml_walk (
848 * 815 *
849 ******************************************************************************/ 816 ******************************************************************************/
850 817
851void 818void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
852acpi_ds_delete_walk_state (
853 struct acpi_walk_state *walk_state)
854{ 819{
855 union acpi_generic_state *state; 820 union acpi_generic_state *state;
856
857
858 ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state);
859 821
822 ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state);
860 823
861 if (!walk_state) { 824 if (!walk_state) {
862 return; 825 return;
863 } 826 }
864 827
865 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 828 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
866 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", 829 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
867 walk_state)); 830 "%p is not a valid walk state\n",
831 walk_state));
868 return; 832 return;
869 } 833 }
870 834
871 if (walk_state->parser_state.scope) { 835 if (walk_state->parser_state.scope) {
872 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", 836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
873 walk_state)); 837 "%p walk still has a scope list\n",
838 walk_state));
874 } 839 }
875 840
876 /* Always must free any linked control states */ 841 /* Always must free any linked control states */
@@ -879,7 +844,7 @@ acpi_ds_delete_walk_state (
879 state = walk_state->control_state; 844 state = walk_state->control_state;
880 walk_state->control_state = state->common.next; 845 walk_state->control_state = state->common.next;
881 846
882 acpi_ut_delete_generic_state (state); 847 acpi_ut_delete_generic_state(state);
883 } 848 }
884 849
885 /* Always must free any linked parse states */ 850 /* Always must free any linked parse states */
@@ -888,7 +853,7 @@ acpi_ds_delete_walk_state (
888 state = walk_state->scope_info; 853 state = walk_state->scope_info;
889 walk_state->scope_info = state->common.next; 854 walk_state->scope_info = state->common.next;
890 855
891 acpi_ut_delete_generic_state (state); 856 acpi_ut_delete_generic_state(state);
892 } 857 }
893 858
894 /* Always must free any stacked result states */ 859 /* Always must free any stacked result states */
@@ -897,14 +862,13 @@ acpi_ds_delete_walk_state (
897 state = walk_state->results; 862 state = walk_state->results;
898 walk_state->results = state->common.next; 863 walk_state->results = state->common.next;
899 864
900 acpi_ut_delete_generic_state (state); 865 acpi_ut_delete_generic_state(state);
901 } 866 }
902 867
903 ACPI_MEM_FREE (walk_state); 868 ACPI_MEM_FREE(walk_state);
904 return_VOID; 869 return_VOID;
905} 870}
906 871
907
908#ifdef ACPI_OBSOLETE_FUNCTIONS 872#ifdef ACPI_OBSOLETE_FUNCTIONS
909/******************************************************************************* 873/*******************************************************************************
910 * 874 *
@@ -921,50 +885,53 @@ acpi_ds_delete_walk_state (
921 ******************************************************************************/ 885 ******************************************************************************/
922 886
923acpi_status 887acpi_status
924acpi_ds_result_insert ( 888acpi_ds_result_insert(void *object,
925 void *object, 889 u32 index, struct acpi_walk_state *walk_state)
926 u32 index,
927 struct acpi_walk_state *walk_state)
928{ 890{
929 union acpi_generic_state *state; 891 union acpi_generic_state *state;
930
931
932 ACPI_FUNCTION_NAME ("ds_result_insert");
933 892
893 ACPI_FUNCTION_NAME("ds_result_insert");
934 894
935 state = walk_state->results; 895 state = walk_state->results;
936 if (!state) { 896 if (!state) {
937 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", 897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
938 walk_state)); 898 "No result object pushed! State=%p\n",
899 walk_state));
939 return (AE_NOT_EXIST); 900 return (AE_NOT_EXIST);
940 } 901 }
941 902
942 if (index >= ACPI_OBJ_NUM_OPERANDS) { 903 if (index >= ACPI_OBJ_NUM_OPERANDS) {
943 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 904 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
944 "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",
945 index, object, walk_state, state->results.num_results)); 906 index, object, walk_state,
907 state->results.num_results));
946 return (AE_BAD_PARAMETER); 908 return (AE_BAD_PARAMETER);
947 } 909 }
948 910
949 if (!object) { 911 if (!object) {
950 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 912 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
951 "Null Object! Index=%X Obj=%p State=%p Num=%X\n", 913 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
952 index, object, walk_state, state->results.num_results)); 914 index, object, walk_state,
915 state->results.num_results));
953 return (AE_BAD_PARAMETER); 916 return (AE_BAD_PARAMETER);
954 } 917 }
955 918
956 state->results.obj_desc [index] = object; 919 state->results.obj_desc[index] = object;
957 state->results.num_results++; 920 state->results.num_results++;
958 921
959 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 922 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
960 "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 923 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
961 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", 924 object,
962 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));
963 931
964 return (AE_OK); 932 return (AE_OK);
965} 933}
966 934
967
968/******************************************************************************* 935/*******************************************************************************
969 * 936 *
970 * FUNCTION: acpi_ds_obj_stack_delete_all 937 * FUNCTION: acpi_ds_obj_stack_delete_all
@@ -978,29 +945,24 @@ acpi_ds_result_insert (
978 * 945 *
979 ******************************************************************************/ 946 ******************************************************************************/
980 947
981acpi_status 948acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state)
982acpi_ds_obj_stack_delete_all (
983 struct acpi_walk_state *walk_state)
984{ 949{
985 u32 i; 950 u32 i;
986
987
988 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
989 951
952 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state);
990 953
991 /* The stack size is configurable, but fixed */ 954 /* The stack size is configurable, but fixed */
992 955
993 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) { 956 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
994 if (walk_state->operands[i]) { 957 if (walk_state->operands[i]) {
995 acpi_ut_remove_reference (walk_state->operands[i]); 958 acpi_ut_remove_reference(walk_state->operands[i]);
996 walk_state->operands[i] = NULL; 959 walk_state->operands[i] = NULL;
997 } 960 }
998 } 961 }
999 962
1000 return_ACPI_STATUS (AE_OK); 963 return_ACPI_STATUS(AE_OK);
1001} 964}
1002 965
1003
1004/******************************************************************************* 966/*******************************************************************************
1005 * 967 *
1006 * FUNCTION: acpi_ds_obj_stack_pop_object 968 * FUNCTION: acpi_ds_obj_stack_pop_object
@@ -1016,19 +978,17 @@ acpi_ds_obj_stack_delete_all (
1016 ******************************************************************************/ 978 ******************************************************************************/
1017 979
1018acpi_status 980acpi_status
1019acpi_ds_obj_stack_pop_object ( 981acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
1020 union acpi_operand_object **object, 982 struct acpi_walk_state *walk_state)
1021 struct acpi_walk_state *walk_state)
1022{ 983{
1023 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object"); 984 ACPI_FUNCTION_NAME("ds_obj_stack_pop_object");
1024
1025 985
1026 /* Check for stack underflow */ 986 /* Check for stack underflow */
1027 987
1028 if (walk_state->num_operands == 0) { 988 if (walk_state->num_operands == 0) {
1029 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 989 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1030 "Missing operand/stack empty! State=%p #Ops=%X\n", 990 "Missing operand/stack empty! State=%p #Ops=%X\n",
1031 walk_state, walk_state->num_operands)); 991 walk_state, walk_state->num_operands));
1032 *object = NULL; 992 *object = NULL;
1033 return (AE_AML_NO_OPERAND); 993 return (AE_AML_NO_OPERAND);
1034 } 994 }
@@ -1039,27 +999,26 @@ acpi_ds_obj_stack_pop_object (
1039 999
1040 /* Check for a valid operand */ 1000 /* Check for a valid operand */
1041 1001
1042 if (!walk_state->operands [walk_state->num_operands]) { 1002 if (!walk_state->operands[walk_state->num_operands]) {
1043 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1003 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1044 "Null operand! State=%p #Ops=%X\n", 1004 "Null operand! State=%p #Ops=%X\n",
1045 walk_state, walk_state->num_operands)); 1005 walk_state, walk_state->num_operands));
1046 *object = NULL; 1006 *object = NULL;
1047 return (AE_AML_NO_OPERAND); 1007 return (AE_AML_NO_OPERAND);
1048 } 1008 }
1049 1009
1050 /* Get operand and set stack entry to null */ 1010 /* Get operand and set stack entry to null */
1051 1011
1052 *object = walk_state->operands [walk_state->num_operands]; 1012 *object = walk_state->operands[walk_state->num_operands];
1053 walk_state->operands [walk_state->num_operands] = NULL; 1013 walk_state->operands[walk_state->num_operands] = NULL;
1054 1014
1055 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",
1056 *object, acpi_ut_get_object_type_name (*object), 1016 *object, acpi_ut_get_object_type_name(*object),
1057 walk_state, walk_state->num_operands)); 1017 walk_state, walk_state->num_operands));
1058 1018
1059 return (AE_OK); 1019 return (AE_OK);
1060} 1020}
1061 1021
1062
1063/******************************************************************************* 1022/*******************************************************************************
1064 * 1023 *
1065 * FUNCTION: acpi_ds_obj_stack_get_value 1024 * FUNCTION: acpi_ds_obj_stack_get_value
@@ -1075,30 +1034,25 @@ acpi_ds_obj_stack_pop_object (
1075 * 1034 *
1076 ******************************************************************************/ 1035 ******************************************************************************/
1077 1036
1078void * 1037void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state)
1079acpi_ds_obj_stack_get_value (
1080 u32 index,
1081 struct acpi_walk_state *walk_state)
1082{ 1038{
1083 1039
1084 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state); 1040 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state);
1085
1086 1041
1087 /* Can't do it if the stack is empty */ 1042 /* Can't do it if the stack is empty */
1088 1043
1089 if (walk_state->num_operands == 0) { 1044 if (walk_state->num_operands == 0) {
1090 return_PTR (NULL); 1045 return_PTR(NULL);
1091 } 1046 }
1092 1047
1093 /* or if the index is past the top of the stack */ 1048 /* or if the index is past the top of the stack */
1094 1049
1095 if (index > (walk_state->num_operands - (u32) 1)) { 1050 if (index > (walk_state->num_operands - (u32) 1)) {
1096 return_PTR (NULL); 1051 return_PTR(NULL);
1097 } 1052 }
1098 1053
1099 return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) - 1054 return_PTR(walk_state->
1100 index]); 1055 operands[(acpi_native_uint) (walk_state->num_operands - 1) -
1056 index]);
1101} 1057}
1102#endif 1058#endif
1103
1104
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 1ac5731d45e5..b15f5ec81d05 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,7 +205,7 @@ 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
@@ -235,14 +213,15 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
235 smp_mb(); 213 smp_mb();
236 214
237 result = wait_event_interruptible_timeout(ec->burst.wait, 215 result = wait_event_interruptible_timeout(ec->burst.wait,
238 !ec->burst.expect_event, 216 !ec->burst.expect_event,
239 msecs_to_jiffies(ACPI_EC_DELAY)); 217 msecs_to_jiffies
240 218 (ACPI_EC_DELAY));
219
241 ec->burst.expect_event = 0; 220 ec->burst.expect_event = 0;
242 smp_mb(); 221 smp_mb();
243 222
244 if (result < 0){ 223 if (result < 0) {
245 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result)); 224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, " result = %d ", result));
246 return_VALUE(result); 225 return_VALUE(result);
247 } 226 }
248 227
@@ -266,54 +245,49 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
266 return_VALUE(-ETIME); 245 return_VALUE(-ETIME);
267} 246}
268 247
269 248static int acpi_ec_enter_burst_mode(union acpi_ec *ec)
270
271static int
272acpi_ec_enter_burst_mode (
273 union acpi_ec *ec)
274{ 249{
275 u32 tmp = 0; 250 u32 tmp = 0;
276 int status = 0; 251 int status = 0;
277 252
278 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); 253 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
279 254
280 status = acpi_ec_read_status(ec); 255 status = acpi_ec_read_status(ec);
281 if (status != -EINVAL && 256 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
282 !(status & ACPI_EC_FLAG_BURST)){ 257 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE,
283 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); 258 &ec->common.command_addr);
284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 259 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
285 if (status){ 260 if (status) {
286 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 261 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
287 return_VALUE(-EINVAL); 262 return_VALUE(-EINVAL);
288 } 263 }
289 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 264 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
290 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 265 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
291 if(tmp != 0x90 ) {/* Burst ACK byte*/ 266 if (tmp != 0x90) { /* Burst ACK byte */
292 return_VALUE(-EINVAL); 267 return_VALUE(-EINVAL);
293 } 268 }
294 } 269 }
295 270
296 atomic_set(&ec->burst.leaving_burst , 0); 271 atomic_set(&ec->burst.leaving_burst, 0);
297 return_VALUE(0); 272 return_VALUE(0);
298} 273}
299 274
300static int 275static int acpi_ec_leave_burst_mode(union acpi_ec *ec)
301acpi_ec_leave_burst_mode (
302 union acpi_ec *ec)
303{ 276{
304 int status =0; 277 int status = 0;
305 278
306 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 279 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
307 280
308 atomic_set(&ec->burst.leaving_burst , 1); 281 atomic_set(&ec->burst.leaving_burst, 1);
309 status = acpi_ec_read_status(ec); 282 status = acpi_ec_read_status(ec);
310 if (status != -EINVAL && 283 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
311 (status & ACPI_EC_FLAG_BURST)){ 284 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE,
312 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); 285 &ec->common.command_addr);
313 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 286 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
314 if (status){ 287 if (status) {
315 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 288 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
316 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); 289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
290 "------->wait fail\n"));
317 return_VALUE(-EINVAL); 291 return_VALUE(-EINVAL);
318 } 292 }
319 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 293 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
@@ -323,38 +297,26 @@ acpi_ec_leave_burst_mode (
323 return_VALUE(0); 297 return_VALUE(0);
324} 298}
325 299
326static int 300static 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{ 301{
332 if (acpi_ec_polling_mode) 302 if (acpi_ec_polling_mode)
333 return acpi_ec_polling_read(ec, address, data); 303 return acpi_ec_polling_read(ec, address, data);
334 else 304 else
335 return acpi_ec_burst_read(ec, address, data); 305 return acpi_ec_burst_read(ec, address, data);
336} 306}
337static int 307static 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{ 308{
343 if (acpi_ec_polling_mode) 309 if (acpi_ec_polling_mode)
344 return acpi_ec_polling_write(ec, address, data); 310 return acpi_ec_polling_write(ec, address, data);
345 else 311 else
346 return acpi_ec_burst_write(ec, address, data); 312 return acpi_ec_burst_write(ec, address, data);
347} 313}
348static int 314static 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{ 315{
354 acpi_status status = AE_OK; 316 acpi_status status = AE_OK;
355 int result = 0; 317 int result = 0;
356 unsigned long flags = 0; 318 unsigned long flags = 0;
357 u32 glk = 0; 319 u32 glk = 0;
358 320
359 ACPI_FUNCTION_TRACE("acpi_ec_read"); 321 ACPI_FUNCTION_TRACE("acpi_ec_read");
360 322
@@ -371,7 +333,8 @@ acpi_ec_polling_read (
371 333
372 spin_lock_irqsave(&ec->polling.lock, flags); 334 spin_lock_irqsave(&ec->polling.lock, flags);
373 335
374 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); 336 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
337 &ec->common.command_addr);
375 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 338 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
376 if (result) 339 if (result)
377 goto end; 340 goto end;
@@ -384,9 +347,9 @@ acpi_ec_polling_read (
384 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 347 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
385 348
386 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 349 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
387 *data, address)); 350 *data, address));
388 351
389end: 352 end:
390 spin_unlock_irqrestore(&ec->polling.lock, flags); 353 spin_unlock_irqrestore(&ec->polling.lock, flags);
391 354
392 if (ec->common.global_lock) 355 if (ec->common.global_lock)
@@ -395,17 +358,12 @@ end:
395 return_VALUE(result); 358 return_VALUE(result);
396} 359}
397 360
398 361static 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{ 362{
405 int result = 0; 363 int result = 0;
406 acpi_status status = AE_OK; 364 acpi_status status = AE_OK;
407 unsigned long flags = 0; 365 unsigned long flags = 0;
408 u32 glk = 0; 366 u32 glk = 0;
409 367
410 ACPI_FUNCTION_TRACE("acpi_ec_write"); 368 ACPI_FUNCTION_TRACE("acpi_ec_write");
411 369
@@ -420,7 +378,8 @@ acpi_ec_polling_write (
420 378
421 spin_lock_irqsave(&ec->polling.lock, flags); 379 spin_lock_irqsave(&ec->polling.lock, flags);
422 380
423 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); 381 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
382 &ec->common.command_addr);
424 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 383 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
425 if (result) 384 if (result)
426 goto end; 385 goto end;
@@ -436,9 +395,9 @@ acpi_ec_polling_write (
436 goto end; 395 goto end;
437 396
438 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 397 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
439 data, address)); 398 data, address));
440 399
441end: 400 end:
442 spin_unlock_irqrestore(&ec->polling.lock, flags); 401 spin_unlock_irqrestore(&ec->polling.lock, flags);
443 402
444 if (ec->common.global_lock) 403 if (ec->common.global_lock)
@@ -447,21 +406,17 @@ end:
447 return_VALUE(result); 406 return_VALUE(result);
448} 407}
449 408
450static int 409static 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{ 410{
456 int status = 0; 411 int status = 0;
457 u32 glk; 412 u32 glk;
458 413
459 ACPI_FUNCTION_TRACE("acpi_ec_read"); 414 ACPI_FUNCTION_TRACE("acpi_ec_read");
460 415
461 if (!ec || !data) 416 if (!ec || !data)
462 return_VALUE(-EINVAL); 417 return_VALUE(-EINVAL);
463 418
464retry: 419 retry:
465 *data = 0; 420 *data = 0;
466 421
467 if (ec->common.global_lock) { 422 if (ec->common.global_lock) {
@@ -473,10 +428,11 @@ retry:
473 WARN_ON(in_interrupt()); 428 WARN_ON(in_interrupt());
474 down(&ec->burst.sem); 429 down(&ec->burst.sem);
475 430
476 if(acpi_ec_enter_burst_mode(ec)) 431 if (acpi_ec_enter_burst_mode(ec))
477 goto end; 432 goto end;
478 433
479 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); 434 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
435 &ec->common.command_addr);
480 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 436 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
481 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 437 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
482 if (status) { 438 if (status) {
@@ -484,8 +440,8 @@ retry:
484 } 440 }
485 441
486 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 442 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
487 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 443 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
488 if (status){ 444 if (status) {
489 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 445 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
490 goto end; 446 goto end;
491 } 447 }
@@ -494,19 +450,19 @@ retry:
494 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 450 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
495 451
496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 452 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
497 *data, address)); 453 *data, address));
498 454
499end: 455 end:
500 acpi_ec_leave_burst_mode(ec); 456 acpi_ec_leave_burst_mode(ec);
501 up(&ec->burst.sem); 457 up(&ec->burst.sem);
502 458
503 if (ec->common.global_lock) 459 if (ec->common.global_lock)
504 acpi_release_global_lock(glk); 460 acpi_release_global_lock(glk);
505 461
506 if(atomic_read(&ec->burst.leaving_burst) == 2){ 462 if (atomic_read(&ec->burst.leaving_burst) == 2) {
507 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 463 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n"));
508 while(atomic_read(&ec->burst.pending_gpe)){ 464 while (atomic_read(&ec->burst.pending_gpe)) {
509 msleep(1); 465 msleep(1);
510 } 466 }
511 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 467 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
512 goto retry; 468 goto retry;
@@ -515,22 +471,17 @@ end:
515 return_VALUE(status); 471 return_VALUE(status);
516} 472}
517 473
518 474static 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{ 475{
525 int status = 0; 476 int status = 0;
526 u32 glk; 477 u32 glk;
527 u32 tmp; 478 u32 tmp;
528 479
529 ACPI_FUNCTION_TRACE("acpi_ec_write"); 480 ACPI_FUNCTION_TRACE("acpi_ec_write");
530 481
531 if (!ec) 482 if (!ec)
532 return_VALUE(-EINVAL); 483 return_VALUE(-EINVAL);
533retry: 484 retry:
534 if (ec->common.global_lock) { 485 if (ec->common.global_lock) {
535 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 486 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
536 if (ACPI_FAILURE(status)) 487 if (ACPI_FAILURE(status))
@@ -540,32 +491,33 @@ retry:
540 WARN_ON(in_interrupt()); 491 WARN_ON(in_interrupt());
541 down(&ec->burst.sem); 492 down(&ec->burst.sem);
542 493
543 if(acpi_ec_enter_burst_mode(ec)) 494 if (acpi_ec_enter_burst_mode(ec))
544 goto end; 495 goto end;
545 496
546 status = acpi_ec_read_status(ec); 497 status = acpi_ec_read_status(ec);
547 if (status != -EINVAL && 498 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
548 !(status & ACPI_EC_FLAG_BURST)){ 499 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE,
549 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); 500 &ec->common.command_addr);
550 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 501 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
551 if (status) 502 if (status)
552 goto end; 503 goto end;
553 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 504 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
554 if(tmp != 0x90 ) /* Burst ACK byte*/ 505 if (tmp != 0x90) /* Burst ACK byte */
555 goto end; 506 goto end;
556 } 507 }
557 /*Now we are in burst mode*/ 508 /*Now we are in burst mode */
558 509
559 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); 510 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
511 &ec->common.command_addr);
560 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 512 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
561 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 513 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
562 if (status){ 514 if (status) {
563 goto end; 515 goto end;
564 } 516 }
565 517
566 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 518 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
567 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 519 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
568 if (status){ 520 if (status) {
569 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 521 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
570 goto end; 522 goto end;
571 } 523 }
@@ -577,19 +529,19 @@ retry:
577 goto end; 529 goto end;
578 530
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 531 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
580 data, address)); 532 data, address));
581 533
582end: 534 end:
583 acpi_ec_leave_burst_mode(ec); 535 acpi_ec_leave_burst_mode(ec);
584 up(&ec->burst.sem); 536 up(&ec->burst.sem);
585 537
586 if (ec->common.global_lock) 538 if (ec->common.global_lock)
587 acpi_release_global_lock(glk); 539 acpi_release_global_lock(glk);
588 540
589 if(atomic_read(&ec->burst.leaving_burst) == 2){ 541 if (atomic_read(&ec->burst.leaving_burst) == 2) {
590 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 542 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n"));
591 while(atomic_read(&ec->burst.pending_gpe)){ 543 while (atomic_read(&ec->burst.pending_gpe)) {
592 msleep(1); 544 msleep(1);
593 } 545 }
594 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 546 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
595 goto retry; 547 goto retry;
@@ -601,8 +553,7 @@ end:
601/* 553/*
602 * Externally callable EC access functions. For now, assume 1 EC only 554 * Externally callable EC access functions. For now, assume 1 EC only
603 */ 555 */
604int 556int ec_read(u8 addr, u8 * val)
605ec_read(u8 addr, u8 *val)
606{ 557{
607 union acpi_ec *ec; 558 union acpi_ec *ec;
608 int err; 559 int err;
@@ -618,14 +569,13 @@ ec_read(u8 addr, u8 *val)
618 if (!err) { 569 if (!err) {
619 *val = temp_data; 570 *val = temp_data;
620 return 0; 571 return 0;
621 } 572 } else
622 else
623 return err; 573 return err;
624} 574}
575
625EXPORT_SYMBOL(ec_read); 576EXPORT_SYMBOL(ec_read);
626 577
627int 578int ec_write(u8 addr, u8 val)
628ec_write(u8 addr, u8 val)
629{ 579{
630 union acpi_ec *ec; 580 union acpi_ec *ec;
631 int err; 581 int err;
@@ -639,27 +589,22 @@ ec_write(u8 addr, u8 val)
639 589
640 return err; 590 return err;
641} 591}
592
642EXPORT_SYMBOL(ec_write); 593EXPORT_SYMBOL(ec_write);
643 594
644static int 595static int acpi_ec_query(union acpi_ec *ec, u32 * data)
645acpi_ec_query (
646 union acpi_ec *ec,
647 u32 *data)
648{ 596{
649 if (acpi_ec_polling_mode) 597 if (acpi_ec_polling_mode)
650 return acpi_ec_polling_query(ec, data); 598 return acpi_ec_polling_query(ec, data);
651 else 599 else
652 return acpi_ec_burst_query(ec, data); 600 return acpi_ec_burst_query(ec, data);
653} 601}
654static int 602static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
655acpi_ec_polling_query (
656 union acpi_ec *ec,
657 u32 *data)
658{ 603{
659 int result = 0; 604 int result = 0;
660 acpi_status status = AE_OK; 605 acpi_status status = AE_OK;
661 unsigned long flags = 0; 606 unsigned long flags = 0;
662 u32 glk = 0; 607 u32 glk = 0;
663 608
664 ACPI_FUNCTION_TRACE("acpi_ec_query"); 609 ACPI_FUNCTION_TRACE("acpi_ec_query");
665 610
@@ -681,7 +626,8 @@ acpi_ec_polling_query (
681 */ 626 */
682 spin_lock_irqsave(&ec->polling.lock, flags); 627 spin_lock_irqsave(&ec->polling.lock, flags);
683 628
684 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); 629 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
630 &ec->common.command_addr);
685 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 631 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
686 if (result) 632 if (result)
687 goto end; 633 goto end;
@@ -690,7 +636,7 @@ acpi_ec_polling_query (
690 if (!*data) 636 if (!*data)
691 result = -ENODATA; 637 result = -ENODATA;
692 638
693end: 639 end:
694 spin_unlock_irqrestore(&ec->polling.lock, flags); 640 spin_unlock_irqrestore(&ec->polling.lock, flags);
695 641
696 if (ec->common.global_lock) 642 if (ec->common.global_lock)
@@ -698,13 +644,10 @@ end:
698 644
699 return_VALUE(result); 645 return_VALUE(result);
700} 646}
701static int 647static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
702acpi_ec_burst_query (
703 union acpi_ec *ec,
704 u32 *data)
705{ 648{
706 int status = 0; 649 int status = 0;
707 u32 glk; 650 u32 glk;
708 651
709 ACPI_FUNCTION_TRACE("acpi_ec_query"); 652 ACPI_FUNCTION_TRACE("acpi_ec_query");
710 653
@@ -719,16 +662,17 @@ acpi_ec_burst_query (
719 } 662 }
720 663
721 down(&ec->burst.sem); 664 down(&ec->burst.sem);
722 if(acpi_ec_enter_burst_mode(ec)) 665 if (acpi_ec_enter_burst_mode(ec))
723 goto end; 666 goto end;
724 /* 667 /*
725 * Query the EC to find out which _Qxx method we need to evaluate. 668 * 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 669 * Note that successful completion of the query causes the ACPI_EC_SCI
727 * bit to be cleared (and thus clearing the interrupt source). 670 * bit to be cleared (and thus clearing the interrupt source).
728 */ 671 */
729 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); 672 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
673 &ec->common.command_addr);
730 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 674 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
731 if (status){ 675 if (status) {
732 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 676 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
733 goto end; 677 goto end;
734 } 678 }
@@ -738,51 +682,47 @@ acpi_ec_burst_query (
738 if (!*data) 682 if (!*data)
739 status = -ENODATA; 683 status = -ENODATA;
740 684
741end: 685 end:
742 acpi_ec_leave_burst_mode(ec); 686 acpi_ec_leave_burst_mode(ec);
743 up(&ec->burst.sem); 687 up(&ec->burst.sem);
744 688
745 if (ec->common.global_lock) 689 if (ec->common.global_lock)
746 acpi_release_global_lock(glk); 690 acpi_release_global_lock(glk);
747 691
748 if(atomic_read(&ec->burst.leaving_burst) == 2){ 692 if (atomic_read(&ec->burst.leaving_burst) == 2) {
749 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 693 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n"));
750 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 694 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
751 status = -ENODATA; 695 status = -ENODATA;
752 } 696 }
753 return_VALUE(status); 697 return_VALUE(status);
754} 698}
755 699
756
757/* -------------------------------------------------------------------------- 700/* --------------------------------------------------------------------------
758 Event Management 701 Event Management
759 -------------------------------------------------------------------------- */ 702 -------------------------------------------------------------------------- */
760 703
761union acpi_ec_query_data { 704union acpi_ec_query_data {
762 acpi_handle handle; 705 acpi_handle handle;
763 u8 data; 706 u8 data;
764}; 707};
765 708
766static void 709static void acpi_ec_gpe_query(void *ec_cxt)
767acpi_ec_gpe_query (
768 void *ec_cxt)
769{ 710{
770 if (acpi_ec_polling_mode) 711 if (acpi_ec_polling_mode)
771 acpi_ec_gpe_polling_query(ec_cxt); 712 acpi_ec_gpe_polling_query(ec_cxt);
772 else 713 else
773 acpi_ec_gpe_burst_query(ec_cxt); 714 acpi_ec_gpe_burst_query(ec_cxt);
774} 715}
775 716
776static void 717static void acpi_ec_gpe_polling_query(void *ec_cxt)
777acpi_ec_gpe_polling_query (
778 void *ec_cxt)
779{ 718{
780 union acpi_ec *ec = (union acpi_ec *) ec_cxt; 719 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
781 u32 value = 0; 720 u32 value = 0;
782 unsigned long flags = 0; 721 unsigned long flags = 0;
783 static char object_name[5] = {'_','Q','0','0','\0'}; 722 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
784 const char hex[] = {'0','1','2','3','4','5','6','7', 723 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
785 '8','9','A','B','C','D','E','F'}; 724 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
725 };
786 726
787 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); 727 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
788 728
@@ -812,19 +752,18 @@ acpi_ec_gpe_polling_query (
812 752
813 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 753 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
814 754
815end: 755 end:
816 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 756 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
817} 757}
818static void 758static void acpi_ec_gpe_burst_query(void *ec_cxt)
819acpi_ec_gpe_burst_query (
820 void *ec_cxt)
821{ 759{
822 union acpi_ec *ec = (union acpi_ec *) ec_cxt; 760 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
823 u32 value; 761 u32 value;
824 int result = -ENODATA; 762 int result = -ENODATA;
825 static char object_name[5] = {'_','Q','0','0','\0'}; 763 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
826 const char hex[] = {'0','1','2','3','4','5','6','7', 764 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
827 '8','9','A','B','C','D','E','F'}; 765 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
766 };
828 767
829 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); 768 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
830 769
@@ -840,26 +779,22 @@ acpi_ec_gpe_burst_query (
840 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 779 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
841 780
842 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 781 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
843end: 782 end:
844 atomic_dec(&ec->burst.pending_gpe); 783 atomic_dec(&ec->burst.pending_gpe);
845 return; 784 return;
846} 785}
847 786
848static u32 787static u32 acpi_ec_gpe_handler(void *data)
849acpi_ec_gpe_handler (
850 void *data)
851{ 788{
852 if (acpi_ec_polling_mode) 789 if (acpi_ec_polling_mode)
853 return acpi_ec_gpe_polling_handler(data); 790 return acpi_ec_gpe_polling_handler(data);
854 else 791 else
855 return acpi_ec_gpe_burst_handler(data); 792 return acpi_ec_gpe_burst_handler(data);
856} 793}
857static u32 794static u32 acpi_ec_gpe_polling_handler(void *data)
858acpi_ec_gpe_polling_handler (
859 void *data)
860{ 795{
861 acpi_status status = AE_OK; 796 acpi_status status = AE_OK;
862 union acpi_ec *ec = (union acpi_ec *) data; 797 union acpi_ec *ec = (union acpi_ec *)data;
863 798
864 if (!ec) 799 if (!ec)
865 return ACPI_INTERRUPT_NOT_HANDLED; 800 return ACPI_INTERRUPT_NOT_HANDLED;
@@ -867,20 +802,18 @@ acpi_ec_gpe_polling_handler (
867 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 802 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
868 803
869 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 804 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
870 acpi_ec_gpe_query, ec); 805 acpi_ec_gpe_query, ec);
871 806
872 if (status == AE_OK) 807 if (status == AE_OK)
873 return ACPI_INTERRUPT_HANDLED; 808 return ACPI_INTERRUPT_HANDLED;
874 else 809 else
875 return ACPI_INTERRUPT_NOT_HANDLED; 810 return ACPI_INTERRUPT_NOT_HANDLED;
876} 811}
877static u32 812static u32 acpi_ec_gpe_burst_handler(void *data)
878acpi_ec_gpe_burst_handler (
879 void *data)
880{ 813{
881 acpi_status status = AE_OK; 814 acpi_status status = AE_OK;
882 u32 value; 815 u32 value;
883 union acpi_ec *ec = (union acpi_ec *) data; 816 union acpi_ec *ec = (union acpi_ec *)data;
884 817
885 if (!ec) 818 if (!ec)
886 return ACPI_INTERRUPT_NOT_HANDLED; 819 return ACPI_INTERRUPT_NOT_HANDLED;
@@ -889,39 +822,39 @@ acpi_ec_gpe_burst_handler (
889 822
890 value = acpi_ec_read_status(ec); 823 value = acpi_ec_read_status(ec);
891 824
892 if((value & ACPI_EC_FLAG_IBF) && 825 if ((value & ACPI_EC_FLAG_IBF) &&
893 !(value & ACPI_EC_FLAG_BURST) && 826 !(value & ACPI_EC_FLAG_BURST) &&
894 (atomic_read(&ec->burst.leaving_burst) == 0)) { 827 (atomic_read(&ec->burst.leaving_burst) == 0)) {
895 /* 828 /*
896 * the embedded controller disables 829 * the embedded controller disables
897 * burst mode for any reason other 830 * burst mode for any reason other
898 * than the burst disable command 831 * than the burst disable command
899 * to process critical event. 832 * to process critical event.
900 */ 833 */
901 atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction 834 atomic_set(&ec->burst.leaving_burst, 2); /* block current pending transaction
902 and retry */ 835 and retry */
903 wake_up(&ec->burst.wait); 836 wake_up(&ec->burst.wait);
904 }else { 837 } else {
905 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF && 838 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF &&
906 (value & ACPI_EC_FLAG_OBF)) || 839 (value & ACPI_EC_FLAG_OBF)) ||
907 (ec->burst.expect_event == ACPI_EC_EVENT_IBE && 840 (ec->burst.expect_event == ACPI_EC_EVENT_IBE &&
908 !(value & ACPI_EC_FLAG_IBF))) { 841 !(value & ACPI_EC_FLAG_IBF))) {
909 ec->burst.expect_event = 0; 842 ec->burst.expect_event = 0;
910 wake_up(&ec->burst.wait); 843 wake_up(&ec->burst.wait);
911 return ACPI_INTERRUPT_HANDLED; 844 return ACPI_INTERRUPT_HANDLED;
912 } 845 }
913 } 846 }
914 847
915 if (value & ACPI_EC_FLAG_SCI){ 848 if (value & ACPI_EC_FLAG_SCI) {
916 atomic_add(1, &ec->burst.pending_gpe) ; 849 atomic_add(1, &ec->burst.pending_gpe);
917 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 850 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
918 acpi_ec_gpe_query, ec); 851 acpi_ec_gpe_query, ec);
919 return status == AE_OK ? 852 return status == AE_OK ?
920 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 853 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
921 } 854 }
922 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 855 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
923 return status == AE_OK ? 856 return status == AE_OK ?
924 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 857 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
925} 858}
926 859
927/* -------------------------------------------------------------------------- 860/* --------------------------------------------------------------------------
@@ -929,37 +862,31 @@ acpi_ec_gpe_burst_handler (
929 -------------------------------------------------------------------------- */ 862 -------------------------------------------------------------------------- */
930 863
931static acpi_status 864static acpi_status
932acpi_ec_space_setup ( 865acpi_ec_space_setup(acpi_handle region_handle,
933 acpi_handle region_handle, 866 u32 function, void *handler_context, void **return_context)
934 u32 function,
935 void *handler_context,
936 void **return_context)
937{ 867{
938 /* 868 /*
939 * The EC object is in the handler context and is needed 869 * The EC object is in the handler context and is needed
940 * when calling the acpi_ec_space_handler. 870 * when calling the acpi_ec_space_handler.
941 */ 871 */
942 *return_context = (function != ACPI_REGION_DEACTIVATE) ? 872 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
943 handler_context : NULL; 873 handler_context : NULL;
944 874
945 return AE_OK; 875 return AE_OK;
946} 876}
947 877
948
949static acpi_status 878static acpi_status
950acpi_ec_space_handler ( 879acpi_ec_space_handler(u32 function,
951 u32 function, 880 acpi_physical_address address,
952 acpi_physical_address address, 881 u32 bit_width,
953 u32 bit_width, 882 acpi_integer * value,
954 acpi_integer *value, 883 void *handler_context, void *region_context)
955 void *handler_context,
956 void *region_context)
957{ 884{
958 int result = 0; 885 int result = 0;
959 union acpi_ec *ec = NULL; 886 union acpi_ec *ec = NULL;
960 u64 temp = *value; 887 u64 temp = *value;
961 acpi_integer f_v = 0; 888 acpi_integer f_v = 0;
962 int i = 0; 889 int i = 0;
963 890
964 ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); 891 ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
965 892
@@ -967,17 +894,18 @@ acpi_ec_space_handler (
967 return_VALUE(AE_BAD_PARAMETER); 894 return_VALUE(AE_BAD_PARAMETER);
968 895
969 if (bit_width != 8 && acpi_strict) { 896 if (bit_width != 8 && acpi_strict) {
970 printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); 897 printk(KERN_WARNING PREFIX
898 "acpi_ec_space_handler: bit_width should be 8\n");
971 return_VALUE(AE_BAD_PARAMETER); 899 return_VALUE(AE_BAD_PARAMETER);
972 } 900 }
973 901
974 ec = (union acpi_ec *) handler_context; 902 ec = (union acpi_ec *)handler_context;
975 903
976next_byte: 904 next_byte:
977 switch (function) { 905 switch (function) {
978 case ACPI_READ: 906 case ACPI_READ:
979 temp = 0; 907 temp = 0;
980 result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); 908 result = acpi_ec_read(ec, (u8) address, (u32 *) & temp);
981 break; 909 break;
982 case ACPI_WRITE: 910 case ACPI_WRITE:
983 result = acpi_ec_write(ec, (u8) address, (u8) temp); 911 result = acpi_ec_write(ec, (u8) address, (u8) temp);
@@ -1004,8 +932,7 @@ next_byte:
1004 *value = f_v; 932 *value = f_v;
1005 } 933 }
1006 934
1007 935 out:
1008out:
1009 switch (result) { 936 switch (result) {
1010 case -EINVAL: 937 case -EINVAL:
1011 return_VALUE(AE_BAD_PARAMETER); 938 return_VALUE(AE_BAD_PARAMETER);
@@ -1021,18 +948,15 @@ out:
1021 } 948 }
1022} 949}
1023 950
1024
1025/* -------------------------------------------------------------------------- 951/* --------------------------------------------------------------------------
1026 FS Interface (/proc) 952 FS Interface (/proc)
1027 -------------------------------------------------------------------------- */ 953 -------------------------------------------------------------------------- */
1028 954
1029static struct proc_dir_entry *acpi_ec_dir; 955static struct proc_dir_entry *acpi_ec_dir;
1030 956
1031 957static int acpi_ec_read_info(struct seq_file *seq, void *offset)
1032static int
1033acpi_ec_read_info (struct seq_file *seq, void *offset)
1034{ 958{
1035 union acpi_ec *ec = (union acpi_ec *) seq->private; 959 union acpi_ec *ec = (union acpi_ec *)seq->private;
1036 960
1037 ACPI_FUNCTION_TRACE("acpi_ec_read_info"); 961 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
1038 962
@@ -1040,14 +964,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
1040 goto end; 964 goto end;
1041 965
1042 seq_printf(seq, "gpe bit: 0x%02x\n", 966 seq_printf(seq, "gpe bit: 0x%02x\n",
1043 (u32) ec->common.gpe_bit); 967 (u32) ec->common.gpe_bit);
1044 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 968 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
1045 (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address); 969 (u32) ec->common.status_addr.address,
970 (u32) ec->common.data_addr.address);
1046 seq_printf(seq, "use global lock: %s\n", 971 seq_printf(seq, "use global lock: %s\n",
1047 ec->common.global_lock?"yes":"no"); 972 ec->common.global_lock ? "yes" : "no");
1048 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 973 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
1049 974
1050end: 975 end:
1051 return_VALUE(0); 976 return_VALUE(0);
1052} 977}
1053 978
@@ -1057,34 +982,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
1057} 982}
1058 983
1059static struct file_operations acpi_ec_info_ops = { 984static struct file_operations acpi_ec_info_ops = {
1060 .open = acpi_ec_info_open_fs, 985 .open = acpi_ec_info_open_fs,
1061 .read = seq_read, 986 .read = seq_read,
1062 .llseek = seq_lseek, 987 .llseek = seq_lseek,
1063 .release = single_release, 988 .release = single_release,
1064 .owner = THIS_MODULE, 989 .owner = THIS_MODULE,
1065}; 990};
1066 991
1067static int 992static int acpi_ec_add_fs(struct acpi_device *device)
1068acpi_ec_add_fs (
1069 struct acpi_device *device)
1070{ 993{
1071 struct proc_dir_entry *entry = NULL; 994 struct proc_dir_entry *entry = NULL;
1072 995
1073 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 996 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
1074 997
1075 if (!acpi_device_dir(device)) { 998 if (!acpi_device_dir(device)) {
1076 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 999 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1077 acpi_ec_dir); 1000 acpi_ec_dir);
1078 if (!acpi_device_dir(device)) 1001 if (!acpi_device_dir(device))
1079 return_VALUE(-ENODEV); 1002 return_VALUE(-ENODEV);
1080 } 1003 }
1081 1004
1082 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, 1005 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
1083 acpi_device_dir(device)); 1006 acpi_device_dir(device));
1084 if (!entry) 1007 if (!entry)
1085 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 1008 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
1086 "Unable to create '%s' fs entry\n", 1009 "Unable to create '%s' fs entry\n",
1087 ACPI_EC_FILE_INFO)); 1010 ACPI_EC_FILE_INFO));
1088 else { 1011 else {
1089 entry->proc_fops = &acpi_ec_info_ops; 1012 entry->proc_fops = &acpi_ec_info_ops;
1090 entry->data = acpi_driver_data(device); 1013 entry->data = acpi_driver_data(device);
@@ -1094,10 +1017,7 @@ acpi_ec_add_fs (
1094 return_VALUE(0); 1017 return_VALUE(0);
1095} 1018}
1096 1019
1097 1020static int acpi_ec_remove_fs(struct acpi_device *device)
1098static int
1099acpi_ec_remove_fs (
1100 struct acpi_device *device)
1101{ 1021{
1102 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); 1022 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
1103 1023
@@ -1110,20 +1030,16 @@ acpi_ec_remove_fs (
1110 return_VALUE(0); 1030 return_VALUE(0);
1111} 1031}
1112 1032
1113
1114/* -------------------------------------------------------------------------- 1033/* --------------------------------------------------------------------------
1115 Driver Interface 1034 Driver Interface
1116 -------------------------------------------------------------------------- */ 1035 -------------------------------------------------------------------------- */
1117 1036
1118 1037static int acpi_ec_polling_add(struct acpi_device *device)
1119static int
1120acpi_ec_polling_add (
1121 struct acpi_device *device)
1122{ 1038{
1123 int result = 0; 1039 int result = 0;
1124 acpi_status status = AE_OK; 1040 acpi_status status = AE_OK;
1125 union acpi_ec *ec = NULL; 1041 union acpi_ec *ec = NULL;
1126 unsigned long uid; 1042 unsigned long uid;
1127 1043
1128 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1044 ACPI_FUNCTION_TRACE("acpi_ec_add");
1129 1045
@@ -1143,26 +1059,31 @@ acpi_ec_polling_add (
1143 acpi_driver_data(device) = ec; 1059 acpi_driver_data(device) = ec;
1144 1060
1145 /* Use the global lock for all EC transactions? */ 1061 /* Use the global lock for all EC transactions? */
1146 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); 1062 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1063 &ec->common.global_lock);
1147 1064
1148 /* If our UID matches the UID for the ECDT-enumerated EC, 1065 /* If our UID matches the UID for the ECDT-enumerated EC,
1149 we now have the *real* EC info, so kill the makeshift one.*/ 1066 we now have the *real* EC info, so kill the makeshift one. */
1150 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); 1067 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1151 if (ec_ecdt && ec_ecdt->common.uid == uid) { 1068 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1152 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1069 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1153 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1070 ACPI_ADR_SPACE_EC,
1154 1071 &acpi_ec_space_handler);
1155 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); 1072
1073 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1074 &acpi_ec_gpe_handler);
1156 1075
1157 kfree(ec_ecdt); 1076 kfree(ec_ecdt);
1158 } 1077 }
1159 1078
1160 /* Get GPE bit assignment (EC events). */ 1079 /* Get GPE bit assignment (EC events). */
1161 /* TODO: Add support for _GPE returning a package */ 1080 /* TODO: Add support for _GPE returning a package */
1162 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); 1081 status =
1082 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1083 &ec->common.gpe_bit);
1163 if (ACPI_FAILURE(status)) { 1084 if (ACPI_FAILURE(status)) {
1164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1085 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1165 "Error obtaining GPE bit assignment\n")); 1086 "Error obtaining GPE bit assignment\n"));
1166 result = -ENODEV; 1087 result = -ENODEV;
1167 goto end; 1088 goto end;
1168 } 1089 }
@@ -1172,26 +1093,24 @@ acpi_ec_polling_add (
1172 goto end; 1093 goto end;
1173 1094
1174 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1095 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1175 acpi_device_name(device), acpi_device_bid(device), 1096 acpi_device_name(device), acpi_device_bid(device),
1176 (u32) ec->common.gpe_bit); 1097 (u32) ec->common.gpe_bit);
1177 1098
1178 if (!first_ec) 1099 if (!first_ec)
1179 first_ec = device; 1100 first_ec = device;
1180 1101
1181end: 1102 end:
1182 if (result) 1103 if (result)
1183 kfree(ec); 1104 kfree(ec);
1184 1105
1185 return_VALUE(result); 1106 return_VALUE(result);
1186} 1107}
1187static int 1108static int acpi_ec_burst_add(struct acpi_device *device)
1188acpi_ec_burst_add (
1189 struct acpi_device *device)
1190{ 1109{
1191 int result = 0; 1110 int result = 0;
1192 acpi_status status = AE_OK; 1111 acpi_status status = AE_OK;
1193 union acpi_ec *ec = NULL; 1112 union acpi_ec *ec = NULL;
1194 unsigned long uid; 1113 unsigned long uid;
1195 1114
1196 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1115 ACPI_FUNCTION_TRACE("acpi_ec_add");
1197 1116
@@ -1205,35 +1124,40 @@ acpi_ec_burst_add (
1205 1124
1206 ec->common.handle = device->handle; 1125 ec->common.handle = device->handle;
1207 ec->common.uid = -1; 1126 ec->common.uid = -1;
1208 atomic_set(&ec->burst.pending_gpe, 0); 1127 atomic_set(&ec->burst.pending_gpe, 0);
1209 atomic_set(&ec->burst.leaving_burst , 1); 1128 atomic_set(&ec->burst.leaving_burst, 1);
1210 init_MUTEX(&ec->burst.sem); 1129 init_MUTEX(&ec->burst.sem);
1211 init_waitqueue_head(&ec->burst.wait); 1130 init_waitqueue_head(&ec->burst.wait);
1212 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1131 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1213 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1132 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1214 acpi_driver_data(device) = ec; 1133 acpi_driver_data(device) = ec;
1215 1134
1216 /* Use the global lock for all EC transactions? */ 1135 /* Use the global lock for all EC transactions? */
1217 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); 1136 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1137 &ec->common.global_lock);
1218 1138
1219 /* If our UID matches the UID for the ECDT-enumerated EC, 1139 /* If our UID matches the UID for the ECDT-enumerated EC,
1220 we now have the *real* EC info, so kill the makeshift one.*/ 1140 we now have the *real* EC info, so kill the makeshift one. */
1221 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); 1141 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1222 if (ec_ecdt && ec_ecdt->common.uid == uid) { 1142 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1223 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1143 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1224 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1144 ACPI_ADR_SPACE_EC,
1145 &acpi_ec_space_handler);
1225 1146
1226 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); 1147 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1148 &acpi_ec_gpe_handler);
1227 1149
1228 kfree(ec_ecdt); 1150 kfree(ec_ecdt);
1229 } 1151 }
1230 1152
1231 /* Get GPE bit assignment (EC events). */ 1153 /* Get GPE bit assignment (EC events). */
1232 /* TODO: Add support for _GPE returning a package */ 1154 /* TODO: Add support for _GPE returning a package */
1233 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); 1155 status =
1156 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1157 &ec->common.gpe_bit);
1234 if (ACPI_FAILURE(status)) { 1158 if (ACPI_FAILURE(status)) {
1235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1159 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1236 "Error obtaining GPE bit assignment\n")); 1160 "Error obtaining GPE bit assignment\n"));
1237 result = -ENODEV; 1161 result = -ENODEV;
1238 goto end; 1162 goto end;
1239 } 1163 }
@@ -1243,26 +1167,22 @@ acpi_ec_burst_add (
1243 goto end; 1167 goto end;
1244 1168
1245 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1169 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1246 acpi_device_name(device), acpi_device_bid(device), 1170 acpi_device_name(device), acpi_device_bid(device),
1247 (u32) ec->common.gpe_bit); 1171 (u32) ec->common.gpe_bit);
1248 1172
1249 if (!first_ec) 1173 if (!first_ec)
1250 first_ec = device; 1174 first_ec = device;
1251 1175
1252end: 1176 end:
1253 if (result) 1177 if (result)
1254 kfree(ec); 1178 kfree(ec);
1255 1179
1256 return_VALUE(result); 1180 return_VALUE(result);
1257} 1181}
1258 1182
1259 1183static int acpi_ec_remove(struct acpi_device *device, int type)
1260static int
1261acpi_ec_remove (
1262 struct acpi_device *device,
1263 int type)
1264{ 1184{
1265 union acpi_ec *ec = NULL; 1185 union acpi_ec *ec = NULL;
1266 1186
1267 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 1187 ACPI_FUNCTION_TRACE("acpi_ec_remove");
1268 1188
@@ -1278,13 +1198,10 @@ acpi_ec_remove (
1278 return_VALUE(0); 1198 return_VALUE(0);
1279} 1199}
1280 1200
1281
1282static acpi_status 1201static acpi_status
1283acpi_ec_io_ports ( 1202acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1284 struct acpi_resource *resource,
1285 void *context)
1286{ 1203{
1287 union acpi_ec *ec = (union acpi_ec *) context; 1204 union acpi_ec *ec = (union acpi_ec *)context;
1288 struct acpi_generic_address *addr; 1205 struct acpi_generic_address *addr;
1289 1206
1290 if (resource->id != ACPI_RSTYPE_IO) { 1207 if (resource->id != ACPI_RSTYPE_IO) {
@@ -1312,13 +1229,10 @@ acpi_ec_io_ports (
1312 return AE_OK; 1229 return AE_OK;
1313} 1230}
1314 1231
1315 1232static int acpi_ec_start(struct acpi_device *device)
1316static int
1317acpi_ec_start (
1318 struct acpi_device *device)
1319{ 1233{
1320 acpi_status status = AE_OK; 1234 acpi_status status = AE_OK;
1321 union acpi_ec *ec = NULL; 1235 union acpi_ec *ec = NULL;
1322 1236
1323 ACPI_FUNCTION_TRACE("acpi_ec_start"); 1237 ACPI_FUNCTION_TRACE("acpi_ec_start");
1324 1238
@@ -1334,49 +1248,50 @@ acpi_ec_start (
1334 * Get I/O port addresses. Convert to GAS format. 1248 * Get I/O port addresses. Convert to GAS format.
1335 */ 1249 */
1336 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, 1250 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS,
1337 acpi_ec_io_ports, ec); 1251 acpi_ec_io_ports, ec);
1338 if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { 1252 if (ACPI_FAILURE(status)
1339 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); 1253 || ec->common.command_addr.register_bit_width == 0) {
1254 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1255 "Error getting I/O port addresses"));
1340 return_VALUE(-ENODEV); 1256 return_VALUE(-ENODEV);
1341 } 1257 }
1342 1258
1343 ec->common.status_addr = ec->common.command_addr; 1259 ec->common.status_addr = ec->common.command_addr;
1344 1260
1345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", 1261 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, 1262 (u32) ec->common.gpe_bit,
1347 (u32) ec->common.data_addr.address)); 1263 (u32) ec->common.command_addr.address,
1348 1264 (u32) ec->common.data_addr.address));
1349 1265
1350 /* 1266 /*
1351 * Install GPE handler 1267 * Install GPE handler
1352 */ 1268 */
1353 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, 1269 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit,
1354 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); 1270 ACPI_GPE_EDGE_TRIGGERED,
1271 &acpi_ec_gpe_handler, ec);
1355 if (ACPI_FAILURE(status)) { 1272 if (ACPI_FAILURE(status)) {
1356 return_VALUE(-ENODEV); 1273 return_VALUE(-ENODEV);
1357 } 1274 }
1358 acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1275 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); 1276 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
1360 1277
1361 status = acpi_install_address_space_handler (ec->common.handle, 1278 status = acpi_install_address_space_handler(ec->common.handle,
1362 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1279 ACPI_ADR_SPACE_EC,
1363 &acpi_ec_space_setup, ec); 1280 &acpi_ec_space_handler,
1281 &acpi_ec_space_setup, ec);
1364 if (ACPI_FAILURE(status)) { 1282 if (ACPI_FAILURE(status)) {
1365 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); 1283 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1284 &acpi_ec_gpe_handler);
1366 return_VALUE(-ENODEV); 1285 return_VALUE(-ENODEV);
1367 } 1286 }
1368 1287
1369 return_VALUE(AE_OK); 1288 return_VALUE(AE_OK);
1370} 1289}
1371 1290
1372 1291static int acpi_ec_stop(struct acpi_device *device, int type)
1373static int
1374acpi_ec_stop (
1375 struct acpi_device *device,
1376 int type)
1377{ 1292{
1378 acpi_status status = AE_OK; 1293 acpi_status status = AE_OK;
1379 union acpi_ec *ec = NULL; 1294 union acpi_ec *ec = NULL;
1380 1295
1381 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 1296 ACPI_FUNCTION_TRACE("acpi_ec_stop");
1382 1297
@@ -1386,11 +1301,14 @@ acpi_ec_stop (
1386 ec = acpi_driver_data(device); 1301 ec = acpi_driver_data(device);
1387 1302
1388 status = acpi_remove_address_space_handler(ec->common.handle, 1303 status = acpi_remove_address_space_handler(ec->common.handle,
1389 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1304 ACPI_ADR_SPACE_EC,
1305 &acpi_ec_space_handler);
1390 if (ACPI_FAILURE(status)) 1306 if (ACPI_FAILURE(status))
1391 return_VALUE(-ENODEV); 1307 return_VALUE(-ENODEV);
1392 1308
1393 status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); 1309 status =
1310 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1311 &acpi_ec_gpe_handler);
1394 if (ACPI_FAILURE(status)) 1312 if (ACPI_FAILURE(status))
1395 return_VALUE(-ENODEV); 1313 return_VALUE(-ENODEV);
1396 1314
@@ -1398,32 +1316,26 @@ acpi_ec_stop (
1398} 1316}
1399 1317
1400static acpi_status __init 1318static acpi_status __init
1401acpi_fake_ecdt_callback ( 1319acpi_fake_ecdt_callback(acpi_handle handle,
1402 acpi_handle handle, 1320 u32 Level, void *context, void **retval)
1403 u32 Level,
1404 void *context,
1405 void **retval)
1406{ 1321{
1407 1322
1408 if (acpi_ec_polling_mode) 1323 if (acpi_ec_polling_mode)
1409 return acpi_fake_ecdt_polling_callback(handle, 1324 return acpi_fake_ecdt_polling_callback(handle,
1410 Level, context, retval); 1325 Level, context, retval);
1411 else 1326 else
1412 return acpi_fake_ecdt_burst_callback(handle, 1327 return acpi_fake_ecdt_burst_callback(handle,
1413 Level, context, retval); 1328 Level, context, retval);
1414} 1329}
1415 1330
1416static acpi_status __init 1331static acpi_status __init
1417acpi_fake_ecdt_polling_callback ( 1332acpi_fake_ecdt_polling_callback(acpi_handle handle,
1418 acpi_handle handle, 1333 u32 Level, void *context, void **retval)
1419 u32 Level,
1420 void *context,
1421 void **retval)
1422{ 1334{
1423 acpi_status status; 1335 acpi_status status;
1424 1336
1425 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1337 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1426 acpi_ec_io_ports, ec_ecdt); 1338 acpi_ec_io_ports, ec_ecdt);
1427 if (ACPI_FAILURE(status)) 1339 if (ACPI_FAILURE(status))
1428 return status; 1340 return status;
1429 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; 1341 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
@@ -1431,33 +1343,33 @@ acpi_fake_ecdt_polling_callback (
1431 ec_ecdt->common.uid = -1; 1343 ec_ecdt->common.uid = -1;
1432 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 1344 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1433 1345
1434 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); 1346 status =
1347 acpi_evaluate_integer(handle, "_GPE", NULL,
1348 &ec_ecdt->common.gpe_bit);
1435 if (ACPI_FAILURE(status)) 1349 if (ACPI_FAILURE(status))
1436 return status; 1350 return status;
1437 spin_lock_init(&ec_ecdt->polling.lock); 1351 spin_lock_init(&ec_ecdt->polling.lock);
1438 ec_ecdt->common.global_lock = TRUE; 1352 ec_ecdt->common.global_lock = TRUE;
1439 ec_ecdt->common.handle = handle; 1353 ec_ecdt->common.handle = handle;
1440 1354
1441 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1355 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, 1356 (u32) ec_ecdt->common.gpe_bit,
1443 (u32) ec_ecdt->common.data_addr.address); 1357 (u32) ec_ecdt->common.command_addr.address,
1358 (u32) ec_ecdt->common.data_addr.address);
1444 1359
1445 return AE_CTRL_TERMINATE; 1360 return AE_CTRL_TERMINATE;
1446} 1361}
1447 1362
1448static acpi_status __init 1363static acpi_status __init
1449acpi_fake_ecdt_burst_callback ( 1364acpi_fake_ecdt_burst_callback(acpi_handle handle,
1450 acpi_handle handle, 1365 u32 Level, void *context, void **retval)
1451 u32 Level,
1452 void *context,
1453 void **retval)
1454{ 1366{
1455 acpi_status status; 1367 acpi_status status;
1456 1368
1457 init_MUTEX(&ec_ecdt->burst.sem); 1369 init_MUTEX(&ec_ecdt->burst.sem);
1458 init_waitqueue_head(&ec_ecdt->burst.wait); 1370 init_waitqueue_head(&ec_ecdt->burst.wait);
1459 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1371 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1460 acpi_ec_io_ports, ec_ecdt); 1372 acpi_ec_io_ports, ec_ecdt);
1461 if (ACPI_FAILURE(status)) 1373 if (ACPI_FAILURE(status))
1462 return status; 1374 return status;
1463 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; 1375 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
@@ -1465,15 +1377,18 @@ acpi_fake_ecdt_burst_callback (
1465 ec_ecdt->common.uid = -1; 1377 ec_ecdt->common.uid = -1;
1466 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 1378 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1467 1379
1468 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); 1380 status =
1381 acpi_evaluate_integer(handle, "_GPE", NULL,
1382 &ec_ecdt->common.gpe_bit);
1469 if (ACPI_FAILURE(status)) 1383 if (ACPI_FAILURE(status))
1470 return status; 1384 return status;
1471 ec_ecdt->common.global_lock = TRUE; 1385 ec_ecdt->common.global_lock = TRUE;
1472 ec_ecdt->common.handle = handle; 1386 ec_ecdt->common.handle = handle;
1473 1387
1474 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1388 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, 1389 (u32) ec_ecdt->common.gpe_bit,
1476 (u32) ec_ecdt->common.data_addr.address); 1390 (u32) ec_ecdt->common.command_addr.address,
1391 (u32) ec_ecdt->common.data_addr.address);
1477 1392
1478 return AE_CTRL_TERMINATE; 1393 return AE_CTRL_TERMINATE;
1479} 1394}
@@ -1488,11 +1403,10 @@ acpi_fake_ecdt_burst_callback (
1488 * op region (since _REG isn't invoked yet). The assumption is true for 1403 * op region (since _REG isn't invoked yet). The assumption is true for
1489 * all systems found. 1404 * all systems found.
1490 */ 1405 */
1491static int __init 1406static int __init acpi_ec_fake_ecdt(void)
1492acpi_ec_fake_ecdt(void)
1493{ 1407{
1494 acpi_status status; 1408 acpi_status status;
1495 int ret = 0; 1409 int ret = 0;
1496 1410
1497 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 1411 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
1498 1412
@@ -1503,10 +1417,8 @@ acpi_ec_fake_ecdt(void)
1503 } 1417 }
1504 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1418 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1505 1419
1506 status = acpi_get_devices (ACPI_EC_HID, 1420 status = acpi_get_devices(ACPI_EC_HID,
1507 acpi_fake_ecdt_callback, 1421 acpi_fake_ecdt_callback, NULL, NULL);
1508 NULL,
1509 NULL);
1510 if (ACPI_FAILURE(status)) { 1422 if (ACPI_FAILURE(status)) {
1511 kfree(ec_ecdt); 1423 kfree(ec_ecdt);
1512 ec_ecdt = NULL; 1424 ec_ecdt = NULL;
@@ -1514,13 +1426,12 @@ acpi_ec_fake_ecdt(void)
1514 goto error; 1426 goto error;
1515 } 1427 }
1516 return 0; 1428 return 0;
1517error: 1429 error:
1518 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); 1430 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n");
1519 return ret; 1431 return ret;
1520} 1432}
1521 1433
1522static int __init 1434static int __init acpi_ec_get_real_ecdt(void)
1523acpi_ec_get_real_ecdt(void)
1524{ 1435{
1525 if (acpi_ec_polling_mode) 1436 if (acpi_ec_polling_mode)
1526 return acpi_ec_polling_get_real_ecdt(); 1437 return acpi_ec_polling_get_real_ecdt();
@@ -1528,14 +1439,14 @@ acpi_ec_get_real_ecdt(void)
1528 return acpi_ec_burst_get_real_ecdt(); 1439 return acpi_ec_burst_get_real_ecdt();
1529} 1440}
1530 1441
1531static int __init 1442static int __init acpi_ec_polling_get_real_ecdt(void)
1532acpi_ec_polling_get_real_ecdt(void)
1533{ 1443{
1534 acpi_status status; 1444 acpi_status status;
1535 struct acpi_table_ecdt *ecdt_ptr; 1445 struct acpi_table_ecdt *ecdt_ptr;
1536 1446
1537 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 1447 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1538 (struct acpi_table_header **) &ecdt_ptr); 1448 (struct acpi_table_header **)
1449 &ecdt_ptr);
1539 if (ACPI_FAILURE(status)) 1450 if (ACPI_FAILURE(status))
1540 return -ENODEV; 1451 return -ENODEV;
1541 1452
@@ -1558,13 +1469,14 @@ acpi_ec_polling_get_real_ecdt(void)
1558 ec_ecdt->common.global_lock = TRUE; 1469 ec_ecdt->common.global_lock = TRUE;
1559 ec_ecdt->common.uid = ecdt_ptr->uid; 1470 ec_ecdt->common.uid = ecdt_ptr->uid;
1560 1471
1561 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 1472 status =
1473 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1562 if (ACPI_FAILURE(status)) { 1474 if (ACPI_FAILURE(status)) {
1563 goto error; 1475 goto error;
1564 } 1476 }
1565 1477
1566 return 0; 1478 return 0;
1567error: 1479 error:
1568 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1480 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1569 kfree(ec_ecdt); 1481 kfree(ec_ecdt);
1570 ec_ecdt = NULL; 1482 ec_ecdt = NULL;
@@ -1572,15 +1484,14 @@ error:
1572 return -ENODEV; 1484 return -ENODEV;
1573} 1485}
1574 1486
1575 1487static int __init acpi_ec_burst_get_real_ecdt(void)
1576static int __init
1577acpi_ec_burst_get_real_ecdt(void)
1578{ 1488{
1579 acpi_status status; 1489 acpi_status status;
1580 struct acpi_table_ecdt *ecdt_ptr; 1490 struct acpi_table_ecdt *ecdt_ptr;
1581 1491
1582 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 1492 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1583 (struct acpi_table_header **) &ecdt_ptr); 1493 (struct acpi_table_header **)
1494 &ecdt_ptr);
1584 if (ACPI_FAILURE(status)) 1495 if (ACPI_FAILURE(status))
1585 return -ENODEV; 1496 return -ENODEV;
1586 1497
@@ -1594,8 +1505,8 @@ acpi_ec_burst_get_real_ecdt(void)
1594 return -ENOMEM; 1505 return -ENOMEM;
1595 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1506 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1596 1507
1597 init_MUTEX(&ec_ecdt->burst.sem); 1508 init_MUTEX(&ec_ecdt->burst.sem);
1598 init_waitqueue_head(&ec_ecdt->burst.wait); 1509 init_waitqueue_head(&ec_ecdt->burst.wait);
1599 ec_ecdt->common.command_addr = ecdt_ptr->ec_control; 1510 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1600 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1511 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1601 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1512 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
@@ -1604,13 +1515,14 @@ acpi_ec_burst_get_real_ecdt(void)
1604 ec_ecdt->common.global_lock = TRUE; 1515 ec_ecdt->common.global_lock = TRUE;
1605 ec_ecdt->common.uid = ecdt_ptr->uid; 1516 ec_ecdt->common.uid = ecdt_ptr->uid;
1606 1517
1607 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 1518 status =
1519 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1608 if (ACPI_FAILURE(status)) { 1520 if (ACPI_FAILURE(status)) {
1609 goto error; 1521 goto error;
1610 } 1522 }
1611 1523
1612 return 0; 1524 return 0;
1613error: 1525 error:
1614 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1526 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1615 kfree(ec_ecdt); 1527 kfree(ec_ecdt);
1616 ec_ecdt = NULL; 1528 ec_ecdt = NULL;
@@ -1619,11 +1531,10 @@ error:
1619} 1531}
1620 1532
1621static int __initdata acpi_fake_ecdt_enabled; 1533static int __initdata acpi_fake_ecdt_enabled;
1622int __init 1534int __init acpi_ec_ecdt_probe(void)
1623acpi_ec_ecdt_probe (void)
1624{ 1535{
1625 acpi_status status; 1536 acpi_status status;
1626 int ret; 1537 int ret;
1627 1538
1628 ret = acpi_ec_get_real_ecdt(); 1539 ret = acpi_ec_get_real_ecdt();
1629 /* Try to make a fake ECDT */ 1540 /* Try to make a fake ECDT */
@@ -1638,26 +1549,28 @@ acpi_ec_ecdt_probe (void)
1638 * Install GPE handler 1549 * Install GPE handler
1639 */ 1550 */
1640 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 1551 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1641 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, 1552 ACPI_GPE_EDGE_TRIGGERED,
1642 ec_ecdt); 1553 &acpi_ec_gpe_handler, ec_ecdt);
1643 if (ACPI_FAILURE(status)) { 1554 if (ACPI_FAILURE(status)) {
1644 goto error; 1555 goto error;
1645 } 1556 }
1646 acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1557 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); 1558 acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR);
1648 1559
1649 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, 1560 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
1650 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1561 ACPI_ADR_SPACE_EC,
1651 &acpi_ec_space_setup, ec_ecdt); 1562 &acpi_ec_space_handler,
1563 &acpi_ec_space_setup,
1564 ec_ecdt);
1652 if (ACPI_FAILURE(status)) { 1565 if (ACPI_FAILURE(status)) {
1653 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 1566 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1654 &acpi_ec_gpe_handler); 1567 &acpi_ec_gpe_handler);
1655 goto error; 1568 goto error;
1656 } 1569 }
1657 1570
1658 return 0; 1571 return 0;
1659 1572
1660error: 1573 error:
1661 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 1574 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1662 kfree(ec_ecdt); 1575 kfree(ec_ecdt);
1663 ec_ecdt = NULL; 1576 ec_ecdt = NULL;
@@ -1665,10 +1578,9 @@ error:
1665 return -ENODEV; 1578 return -ENODEV;
1666} 1579}
1667 1580
1668 1581static int __init acpi_ec_init(void)
1669static int __init acpi_ec_init (void)
1670{ 1582{
1671 int result = 0; 1583 int result = 0;
1672 1584
1673 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1585 ACPI_FUNCTION_TRACE("acpi_ec_init");
1674 1586
@@ -1693,8 +1605,7 @@ subsys_initcall(acpi_ec_init);
1693 1605
1694/* EC driver currently not unloadable */ 1606/* EC driver currently not unloadable */
1695#if 0 1607#if 0
1696static void __exit 1608static void __exit acpi_ec_exit(void)
1697acpi_ec_exit (void)
1698{ 1609{
1699 ACPI_FUNCTION_TRACE("acpi_ec_exit"); 1610 ACPI_FUNCTION_TRACE("acpi_ec_exit");
1700 1611
@@ -1704,7 +1615,7 @@ acpi_ec_exit (void)
1704 1615
1705 return_VOID; 1616 return_VOID;
1706} 1617}
1707#endif /* 0 */ 1618#endif /* 0 */
1708 1619
1709static int __init acpi_fake_ecdt_setup(char *str) 1620static int __init acpi_fake_ecdt_setup(char *str)
1710{ 1621{
@@ -1727,8 +1638,8 @@ static int __init acpi_ec_set_polling_mode(char *str)
1727 acpi_ec_polling_mode = EC_POLLING; 1638 acpi_ec_polling_mode = EC_POLLING;
1728 acpi_ec_driver.ops.add = acpi_ec_polling_add; 1639 acpi_ec_driver.ops.add = acpi_ec_polling_add;
1729 } 1640 }
1730 printk(KERN_INFO PREFIX "EC %s mode.\n", 1641 printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling");
1731 burst ? "burst": "polling");
1732 return 0; 1642 return 0;
1733} 1643}
1644
1734__setup("ec_burst=", acpi_ec_set_polling_mode); 1645__setup("ec_burst=", acpi_ec_set_polling_mode);
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index ce8d3eec3911..bfa8b76de403 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -13,16 +13,15 @@
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
@@ -34,20 +33,20 @@ acpi_system_open_event(struct inode *inode, struct file *file)
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(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 42acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
43 loff_t * ppos)
44{ 44{
45 int result = 0; 45 int result = 0;
46 struct acpi_bus_event event; 46 struct acpi_bus_event event;
47 static char str[ACPI_MAX_STRING]; 47 static char str[ACPI_MAX_STRING];
48 static int chars_remaining = 0; 48 static int chars_remaining = 0;
49 static char *ptr; 49 static char *ptr;
50
51 50
52 ACPI_FUNCTION_TRACE("acpi_system_read_event"); 51 ACPI_FUNCTION_TRACE("acpi_system_read_event");
53 52
@@ -63,10 +62,12 @@ acpi_system_read_event(struct file *file, char __user *buffer, size_t count, lof
63 return_VALUE(-EIO); 62 return_VALUE(-EIO);
64 } 63 }
65 64
66 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 65 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
67 event.device_class?event.device_class:"<unknown>", 66 event.device_class ? event.
68 event.bus_id?event.bus_id:"<unknown>", 67 device_class : "<unknown>",
69 event.type, event.data); 68 event.bus_id ? event.
69 bus_id : "<unknown>", event.type,
70 event.data);
70 ptr = str; 71 ptr = str;
71 } 72 }
72 73
@@ -84,17 +85,15 @@ acpi_system_read_event(struct file *file, char __user *buffer, size_t count, lof
84 return_VALUE(count); 85 return_VALUE(count);
85} 86}
86 87
87static int 88static int acpi_system_close_event(struct inode *inode, struct file *file)
88acpi_system_close_event(struct inode *inode, struct file *file)
89{ 89{
90 spin_lock_irq (&acpi_system_event_lock); 90 spin_lock_irq(&acpi_system_event_lock);
91 event_is_open = 0; 91 event_is_open = 0;
92 spin_unlock_irq (&acpi_system_event_lock); 92 spin_unlock_irq(&acpi_system_event_lock);
93 return 0; 93 return 0;
94} 94}
95 95
96static unsigned int 96static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
97acpi_system_poll_event(struct file *file, poll_table *wait)
98{ 97{
99 poll_wait(file, &acpi_bus_event_queue, wait); 98 poll_wait(file, &acpi_bus_event_queue, wait);
100 if (!list_empty(&acpi_bus_event_list)) 99 if (!list_empty(&acpi_bus_event_list))
@@ -103,15 +102,15 @@ acpi_system_poll_event(struct file *file, poll_table *wait)
103} 102}
104 103
105static struct file_operations acpi_system_event_ops = { 104static struct file_operations acpi_system_event_ops = {
106 .open = acpi_system_open_event, 105 .open = acpi_system_open_event,
107 .read = acpi_system_read_event, 106 .read = acpi_system_read_event,
108 .release = acpi_system_close_event, 107 .release = acpi_system_close_event,
109 .poll = acpi_system_poll_event, 108 .poll = acpi_system_poll_event,
110}; 109};
111 110
112static int __init acpi_event_init(void) 111static int __init acpi_event_init(void)
113{ 112{
114 struct proc_dir_entry *entry; 113 struct proc_dir_entry *entry;
115 int error = 0; 114 int error = 0;
116 115
117 ACPI_FUNCTION_TRACE("acpi_event_init"); 116 ACPI_FUNCTION_TRACE("acpi_event_init");
@@ -124,8 +123,9 @@ static int __init acpi_event_init(void)
124 if (entry) 123 if (entry)
125 entry->proc_fops = &acpi_system_event_ops; 124 entry->proc_fops = &acpi_system_event_ops;
126 else { 125 else {
127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
128 "Unable to create '%s' proc fs entry\n","event" )); 127 "Unable to create '%s' proc fs entry\n",
128 "event"));
129 error = -EFAULT; 129 error = -EFAULT;
130 } 130 }
131 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 ede834df4f69..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,23 +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 u32 flags; 380 u32 flags;
400 acpi_status status; 381 acpi_status status;
401 struct acpi_gpe_block_info *gpe_block; 382 struct acpi_gpe_block_info *gpe_block;
402 acpi_native_uint i; 383 acpi_native_uint i;
403 acpi_native_uint j; 384 acpi_native_uint j;
404 385
405 386 ACPI_FUNCTION_NAME("ev_gpe_detect");
406 ACPI_FUNCTION_NAME ("ev_gpe_detect");
407 387
408 /* Check for the case where there are no GPEs */ 388 /* Check for the case where there are no GPEs */
409 389
@@ -413,7 +393,7 @@ acpi_ev_gpe_detect (
413 393
414 /* Examine all GPE blocks attached to this interrupt level */ 394 /* Examine all GPE blocks attached to this interrupt level */
415 395
416 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 396 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
417 gpe_block = gpe_xrupt_list->gpe_block_list_head; 397 gpe_block = gpe_xrupt_list->gpe_block_list_head;
418 while (gpe_block) { 398 while (gpe_block) {
419 /* 399 /*
@@ -428,23 +408,30 @@ acpi_ev_gpe_detect (
428 408
429 /* Read the Status Register */ 409 /* Read the Status Register */
430 410
431 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg, 411 status =
432 &gpe_register_info->status_address); 412 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
433 if (ACPI_FAILURE (status)) { 413 &status_reg,
414 &gpe_register_info->
415 status_address);
416 if (ACPI_FAILURE(status)) {
434 goto unlock_and_exit; 417 goto unlock_and_exit;
435 } 418 }
436 419
437 /* Read the Enable Register */ 420 /* Read the Enable Register */
438 421
439 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg, 422 status =
440 &gpe_register_info->enable_address); 423 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
441 if (ACPI_FAILURE (status)) { 424 &enable_reg,
425 &gpe_register_info->
426 enable_address);
427 if (ACPI_FAILURE(status)) {
442 goto unlock_and_exit; 428 goto unlock_and_exit;
443 } 429 }
444 430
445 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 431 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
446 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", 432 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
447 gpe_register_info->base_gpe_number, status_reg, enable_reg)); 433 gpe_register_info->base_gpe_number,
434 status_reg, enable_reg));
448 435
449 /* Check if there is anything active at all in this register */ 436 /* Check if there is anything active at all in this register */
450 437
@@ -460,14 +447,21 @@ acpi_ev_gpe_detect (
460 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 447 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
461 /* Examine one GPE bit */ 448 /* Examine one GPE bit */
462 449
463 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) { 450 if (enabled_status_byte &
451 acpi_gbl_decode_to8bit[j]) {
464 /* 452 /*
465 * Found an active GPE. Dispatch the event to a handler 453 * Found an active GPE. Dispatch the event to a handler
466 * or method. 454 * or method.
467 */ 455 */
468 int_status |= acpi_ev_gpe_dispatch ( 456 int_status |=
469 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], 457 acpi_ev_gpe_dispatch(&gpe_block->
470 (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);
471 } 465 }
472 } 466 }
473 } 467 }
@@ -475,13 +469,12 @@ acpi_ev_gpe_detect (
475 gpe_block = gpe_block->next; 469 gpe_block = gpe_block->next;
476 } 470 }
477 471
478unlock_and_exit: 472 unlock_and_exit:
479 473
480 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 474 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
481 return (int_status); 475 return (int_status);
482} 476}
483 477
484
485/******************************************************************************* 478/*******************************************************************************
486 * 479 *
487 * FUNCTION: acpi_ev_asynch_execute_gpe_method 480 * FUNCTION: acpi_ev_asynch_execute_gpe_method
@@ -498,45 +491,41 @@ unlock_and_exit:
498 * 491 *
499 ******************************************************************************/ 492 ******************************************************************************/
500 493
501static void ACPI_SYSTEM_XFACE 494static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
502acpi_ev_asynch_execute_gpe_method (
503 void *context)
504{ 495{
505 struct acpi_gpe_event_info *gpe_event_info = (void *) context; 496 struct acpi_gpe_event_info *gpe_event_info = (void *)context;
506 u32 gpe_number = 0; 497 u32 gpe_number = 0;
507 acpi_status status; 498 acpi_status status;
508 struct acpi_gpe_event_info local_gpe_event_info; 499 struct acpi_gpe_event_info local_gpe_event_info;
509 struct acpi_parameter_info info; 500 struct acpi_parameter_info info;
510
511 501
512 ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method"); 502 ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method");
513 503
514 504 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
515 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 505 if (ACPI_FAILURE(status)) {
516 if (ACPI_FAILURE (status)) {
517 return_VOID; 506 return_VOID;
518 } 507 }
519 508
520 /* Must revalidate the gpe_number/gpe_block */ 509 /* Must revalidate the gpe_number/gpe_block */
521 510
522 if (!acpi_ev_valid_gpe_event (gpe_event_info)) { 511 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
523 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 512 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
524 return_VOID; 513 return_VOID;
525 } 514 }
526 515
527 /* Set the GPE flags for return to enabled state */ 516 /* Set the GPE flags for return to enabled state */
528 517
529 (void) acpi_ev_enable_gpe (gpe_event_info, FALSE); 518 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
530 519
531 /* 520 /*
532 * 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
533 * info to prevent a race condition with remove_handler/remove_block. 522 * info to prevent a race condition with remove_handler/remove_block.
534 */ 523 */
535 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, 524 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
536 sizeof (struct acpi_gpe_event_info)); 525 sizeof(struct acpi_gpe_event_info));
537 526
538 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 527 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
539 if (ACPI_FAILURE (status)) { 528 if (ACPI_FAILURE(status)) {
540 return_VOID; 529 return_VOID;
541 } 530 }
542 531
@@ -545,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method (
545 * time to avoid race with ev_gpe_install_handler 534 * time to avoid race with ev_gpe_install_handler
546 */ 535 */
547 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 536 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
548 ACPI_GPE_DISPATCH_METHOD) { 537 ACPI_GPE_DISPATCH_METHOD) {
549 /* 538 /*
550 * 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
551 * control method that corresponds to this GPE 540 * control method that corresponds to this GPE
552 */ 541 */
553 info.node = local_gpe_event_info.dispatch.method_node; 542 info.node = local_gpe_event_info.dispatch.method_node;
554 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);
555 info.parameter_type = ACPI_PARAM_GPE; 545 info.parameter_type = ACPI_PARAM_GPE;
556 546
557 status = acpi_ns_evaluate_by_handle (&info); 547 status = acpi_ns_evaluate_by_handle(&info);
558 if (ACPI_FAILURE (status)) { 548 if (ACPI_FAILURE(status)) {
559 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));
560 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
561 acpi_format_exception (status),
562 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
563 gpe_number));
564 } 550 }
565 } 551 }
566 552
567 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == 553 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
568 ACPI_GPE_LEVEL_TRIGGERED) { 554 ACPI_GPE_LEVEL_TRIGGERED) {
569 /* 555 /*
570 * GPE is level-triggered, we clear the GPE status bit after 556 * GPE is level-triggered, we clear the GPE status bit after
571 * handling the event. 557 * handling the event.
572 */ 558 */
573 status = acpi_hw_clear_gpe (&local_gpe_event_info); 559 status = acpi_hw_clear_gpe(&local_gpe_event_info);
574 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
575 return_VOID; 561 return_VOID;
576 } 562 }
577 } 563 }
578 564
579 /* Enable this GPE */ 565 /* Enable this GPE */
580 566
581 (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info); 567 (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info);
582 return_VOID; 568 return_VOID;
583} 569}
584 570
585
586/******************************************************************************* 571/*******************************************************************************
587 * 572 *
588 * FUNCTION: acpi_ev_gpe_dispatch 573 * FUNCTION: acpi_ev_gpe_dispatch
@@ -600,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method (
600 ******************************************************************************/ 585 ******************************************************************************/
601 586
602u32 587u32
603acpi_ev_gpe_dispatch ( 588acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
604 struct acpi_gpe_event_info *gpe_event_info,
605 u32 gpe_number)
606{ 589{
607 acpi_status status; 590 acpi_status status;
608
609
610 ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
611 591
592 ACPI_FUNCTION_TRACE("ev_gpe_dispatch");
612 593
613 /* 594 /*
614 * If edge-triggered, clear the GPE status bit now. Note that 595 * If edge-triggered, clear the GPE status bit now. Note that
615 * level-triggered events are cleared after the GPE is serviced. 596 * level-triggered events are cleared after the GPE is serviced.
616 */ 597 */
617 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 598 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
618 ACPI_GPE_EDGE_TRIGGERED) { 599 ACPI_GPE_EDGE_TRIGGERED) {
619 status = acpi_hw_clear_gpe (gpe_event_info); 600 status = acpi_hw_clear_gpe(gpe_event_info);
620 if (ACPI_FAILURE (status)) { 601 if (ACPI_FAILURE(status)) {
621 ACPI_REPORT_ERROR (( 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
622 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
623 acpi_format_exception (status), gpe_number));
624 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
625 } 604 }
626 } 605 }
627 606
628 /* Save current system state */ 607 /* Save current system state */
629 608
630 if (acpi_gbl_system_awake_and_running) { 609 if (acpi_gbl_system_awake_and_running) {
631 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); 610 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
632 } 611 } else {
633 else { 612 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
634 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
635 } 613 }
636 614
637 /* 615 /*
@@ -648,19 +626,19 @@ acpi_ev_gpe_dispatch (
648 * Invoke the installed handler (at interrupt level) 626 * Invoke the installed handler (at interrupt level)
649 * Ignore return status for now. TBD: leave GPE disabled on error? 627 * Ignore return status for now. TBD: leave GPE disabled on error?
650 */ 628 */
651 (void) gpe_event_info->dispatch.handler->address ( 629 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
652 gpe_event_info->dispatch.handler->context); 630 dispatch.
631 handler->
632 context);
653 633
654 /* It is now safe to clear level-triggered events. */ 634 /* It is now safe to clear level-triggered events. */
655 635
656 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 636 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
657 ACPI_GPE_LEVEL_TRIGGERED) { 637 ACPI_GPE_LEVEL_TRIGGERED) {
658 status = acpi_hw_clear_gpe (gpe_event_info); 638 status = acpi_hw_clear_gpe(gpe_event_info);
659 if (ACPI_FAILURE (status)) { 639 if (ACPI_FAILURE(status)) {
660 ACPI_REPORT_ERROR (( 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
661 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
662 acpi_format_exception (status), gpe_number));
663 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
664 } 642 }
665 } 643 }
666 break; 644 break;
@@ -671,24 +649,21 @@ acpi_ev_gpe_dispatch (
671 * 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
672 * chance to run. 650 * chance to run.
673 */ 651 */
674 status = acpi_ev_disable_gpe (gpe_event_info); 652 status = acpi_ev_disable_gpe(gpe_event_info);
675 if (ACPI_FAILURE (status)) { 653 if (ACPI_FAILURE(status)) {
676 ACPI_REPORT_ERROR (( 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
677 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
678 acpi_format_exception (status), gpe_number));
679 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
680 } 656 }
681 657
682 /* 658 /*
683 * Execute the method associated with the GPE 659 * Execute the method associated with the GPE
684 * NOTE: Level-triggered GPEs are cleared after the method completes. 660 * NOTE: Level-triggered GPEs are cleared after the method completes.
685 */ 661 */
686 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE, 662 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
687 acpi_ev_asynch_execute_gpe_method, gpe_event_info); 663 acpi_ev_asynch_execute_gpe_method,
688 if (ACPI_FAILURE (status)) { 664 gpe_event_info);
689 ACPI_REPORT_ERROR (( 665 if (ACPI_FAILURE(status)) {
690 "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));
691 acpi_format_exception (status), gpe_number));
692 } 667 }
693 break; 668 break;
694 669
@@ -696,28 +671,23 @@ acpi_ev_gpe_dispatch (
696 671
697 /* No handler or method to run! */ 672 /* No handler or method to run! */
698 673
699 ACPI_REPORT_ERROR (( 674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number));
700 "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
701 gpe_number));
702 675
703 /* 676 /*
704 * Disable the GPE. The GPE will remain disabled until the ACPI 677 * Disable the GPE. The GPE will remain disabled until the ACPI
705 * Core Subsystem is restarted, or a handler is installed. 678 * Core Subsystem is restarted, or a handler is installed.
706 */ 679 */
707 status = acpi_ev_disable_gpe (gpe_event_info); 680 status = acpi_ev_disable_gpe(gpe_event_info);
708 if (ACPI_FAILURE (status)) { 681 if (ACPI_FAILURE(status)) {
709 ACPI_REPORT_ERROR (( 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
710 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
711 acpi_format_exception (status), gpe_number));
712 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
713 } 684 }
714 break; 685 break;
715 } 686 }
716 687
717 return_VALUE (ACPI_INTERRUPT_HANDLED); 688 return_VALUE(ACPI_INTERRUPT_HANDLED);
718} 689}
719 690
720
721#ifdef ACPI_GPE_NOTIFY_CHECK 691#ifdef ACPI_GPE_NOTIFY_CHECK
722/******************************************************************************* 692/*******************************************************************************
723 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED 693 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
@@ -736,35 +706,29 @@ acpi_ev_gpe_dispatch (
736 ******************************************************************************/ 706 ******************************************************************************/
737 707
738acpi_status 708acpi_status
739acpi_ev_check_for_wake_only_gpe ( 709acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
740 struct acpi_gpe_event_info *gpe_event_info)
741{ 710{
742 acpi_status status; 711 acpi_status status;
743 712
713 ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe");
744 714
745 ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe"); 715 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
746 716 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */
747
748 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
749 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
750 /* This must be a wake-only GPE, disable it */ 717 /* This must be a wake-only GPE, disable it */
751 718
752 status = acpi_ev_disable_gpe (gpe_event_info); 719 status = acpi_ev_disable_gpe(gpe_event_info);
753 720
754 /* 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 */
755 722
756 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);
757 724
758 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));
759 gpe_event_info));
760 726
761 /* This was a wake-only GPE */ 727 /* This was a wake-only GPE */
762 728
763 return_ACPI_STATUS (AE_WAKE_ONLY_GPE); 729 return_ACPI_STATUS(AE_WAKE_ONLY_GPE);
764 } 730 }
765 731
766 return_ACPI_STATUS (AE_OK); 732 return_ACPI_STATUS(AE_OK);
767} 733}
768#endif 734#endif
769
770
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index dfc54692b127..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_number);
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_number);
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,7 +119,6 @@ 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
@@ -145,20 +131,16 @@ acpi_ev_valid_gpe_event (
145 * 131 *
146 ******************************************************************************/ 132 ******************************************************************************/
147 133
148acpi_status 134acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
149acpi_ev_walk_gpe_list (
150 ACPI_GPE_CALLBACK gpe_walk_callback)
151{ 135{
152 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
153 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
154 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
155 u32 flags; 139 u32 flags;
156
157 140
158 ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
159 142
160 143 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
161 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
162 144
163 /* Walk the interrupt level descriptor list */ 145 /* Walk the interrupt level descriptor list */
164 146
@@ -170,8 +152,8 @@ acpi_ev_walk_gpe_list (
170 while (gpe_block) { 152 while (gpe_block) {
171 /* One callback per GPE block */ 153 /* One callback per GPE block */
172 154
173 status = gpe_walk_callback (gpe_xrupt_info, gpe_block); 155 status = gpe_walk_callback(gpe_xrupt_info, gpe_block);
174 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
175 goto unlock_and_exit; 157 goto unlock_and_exit;
176 } 158 }
177 159
@@ -181,12 +163,11 @@ acpi_ev_walk_gpe_list (
181 gpe_xrupt_info = gpe_xrupt_info->next; 163 gpe_xrupt_info = gpe_xrupt_info->next;
182 } 164 }
183 165
184unlock_and_exit: 166 unlock_and_exit:
185 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 167 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
186 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
187} 169}
188 170
189
190/******************************************************************************* 171/*******************************************************************************
191 * 172 *
192 * FUNCTION: acpi_ev_delete_gpe_handlers 173 * FUNCTION: acpi_ev_delete_gpe_handlers
@@ -202,17 +183,14 @@ unlock_and_exit:
202 ******************************************************************************/ 183 ******************************************************************************/
203 184
204acpi_status 185acpi_status
205acpi_ev_delete_gpe_handlers ( 186acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
206 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 187 struct acpi_gpe_block_info *gpe_block)
207 struct acpi_gpe_block_info *gpe_block)
208{ 188{
209 struct acpi_gpe_event_info *gpe_event_info; 189 struct acpi_gpe_event_info *gpe_event_info;
210 acpi_native_uint i; 190 acpi_native_uint i;
211 acpi_native_uint j; 191 acpi_native_uint j;
212
213
214 ACPI_FUNCTION_TRACE ("ev_delete_gpe_handlers");
215 192
193 ACPI_FUNCTION_TRACE("ev_delete_gpe_handlers");
216 194
217 /* Examine each GPE Register within the block */ 195 /* Examine each GPE Register within the block */
218 196
@@ -220,21 +198,23 @@ acpi_ev_delete_gpe_handlers (
220 /* Now look at the individual GPEs in this byte register */ 198 /* Now look at the individual GPEs in this byte register */
221 199
222 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 200 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
223 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];
224 204
225 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 205 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
226 ACPI_GPE_DISPATCH_HANDLER) { 206 ACPI_GPE_DISPATCH_HANDLER) {
227 ACPI_MEM_FREE (gpe_event_info->dispatch.handler); 207 ACPI_MEM_FREE(gpe_event_info->dispatch.handler);
228 gpe_event_info->dispatch.handler = NULL; 208 gpe_event_info->dispatch.handler = NULL;
229 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; 209 gpe_event_info->flags &=
210 ~ACPI_GPE_DISPATCH_MASK;
230 } 211 }
231 } 212 }
232 } 213 }
233 214
234 return_ACPI_STATUS (AE_OK); 215 return_ACPI_STATUS(AE_OK);
235} 216}
236 217
237
238/******************************************************************************* 218/*******************************************************************************
239 * 219 *
240 * FUNCTION: acpi_ev_save_method_info 220 * FUNCTION: acpi_ev_save_method_info
@@ -258,30 +238,26 @@ acpi_ev_delete_gpe_handlers (
258 ******************************************************************************/ 238 ******************************************************************************/
259 239
260static acpi_status 240static acpi_status
261acpi_ev_save_method_info ( 241acpi_ev_save_method_info(acpi_handle obj_handle,
262 acpi_handle obj_handle, 242 u32 level, void *obj_desc, void **return_value)
263 u32 level,
264 void *obj_desc,
265 void **return_value)
266{ 243{
267 struct acpi_gpe_block_info *gpe_block = (void *) obj_desc; 244 struct acpi_gpe_block_info *gpe_block = (void *)obj_desc;
268 struct acpi_gpe_event_info *gpe_event_info; 245 struct acpi_gpe_event_info *gpe_event_info;
269 u32 gpe_number; 246 u32 gpe_number;
270 char name[ACPI_NAME_SIZE + 1]; 247 char name[ACPI_NAME_SIZE + 1];
271 u8 type; 248 u8 type;
272 acpi_status status; 249 acpi_status status;
273
274
275 ACPI_FUNCTION_TRACE ("ev_save_method_info");
276 250
251 ACPI_FUNCTION_TRACE("ev_save_method_info");
277 252
278 /* 253 /*
279 * _Lxx and _Exx GPE method support 254 * _Lxx and _Exx GPE method support
280 * 255 *
281 * 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
282 */ 257 */
283 ACPI_MOVE_32_TO_32 (name, 258 ACPI_MOVE_32_TO_32(name,
284 &((struct acpi_namespace_node *) obj_handle)->name.integer); 259 &((struct acpi_namespace_node *)obj_handle)->name.
260 integer);
285 name[ACPI_NAME_SIZE] = 0; 261 name[ACPI_NAME_SIZE] = 0;
286 262
287 /* 263 /*
@@ -303,34 +279,36 @@ acpi_ev_save_method_info (
303 default: 279 default:
304 /* Unknown method type, just ignore it! */ 280 /* Unknown method type, just ignore it! */
305 281
306 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
307 "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",
308 name)); 284 name));
309 return_ACPI_STATUS (AE_OK); 285 return_ACPI_STATUS(AE_OK);
310 } 286 }
311 287
312 /* 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 */
313 289
314 gpe_number = ACPI_STRTOUL (&name[2], NULL, 16); 290 gpe_number = ACPI_STRTOUL(&name[2], NULL, 16);
315 if (gpe_number == ACPI_UINT32_MAX) { 291 if (gpe_number == ACPI_UINT32_MAX) {
316 /* Conversion failed; invalid method, just ignore it */ 292 /* Conversion failed; invalid method, just ignore it */
317 293
318 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
319 "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",
320 name)); 296 name));
321 return_ACPI_STATUS (AE_OK); 297 return_ACPI_STATUS(AE_OK);
322 } 298 }
323 299
324 /* 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 */
325 301
326 if ((gpe_number < gpe_block->block_base_number) || 302 if ((gpe_number < gpe_block->block_base_number) ||
327 (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)))) {
328 /* 306 /*
329 * Not valid for this GPE block, just ignore it 307 * Not valid for this GPE block, just ignore it
330 * 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
331 * methods both appear under \_GPE. 309 * methods both appear under \_GPE.
332 */ 310 */
333 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
334 } 312 }
335 313
336 /* 314 /*
@@ -338,24 +316,25 @@ acpi_ev_save_method_info (
338 * 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
339 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
340 */ 318 */
341 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];
342 321
343 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD |
344 ACPI_GPE_TYPE_RUNTIME); 323 ACPI_GPE_TYPE_RUNTIME);
345 324
346 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;
347 327
348 /* 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 */
349 329
350 status = acpi_ev_enable_gpe (gpe_event_info, FALSE); 330 status = acpi_ev_enable_gpe(gpe_event_info, FALSE);
351 331
352 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, 332 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
353 "Registered GPE method %s as GPE number 0x%.2X\n", 333 "Registered GPE method %s as GPE number 0x%.2X\n",
354 name, gpe_number)); 334 name, gpe_number));
355 return_ACPI_STATUS (status); 335 return_ACPI_STATUS(status);
356} 336}
357 337
358
359/******************************************************************************* 338/*******************************************************************************
360 * 339 *
361 * FUNCTION: acpi_ev_match_prw_and_gpe 340 * FUNCTION: acpi_ev_match_prw_and_gpe
@@ -372,34 +351,29 @@ acpi_ev_save_method_info (
372 ******************************************************************************/ 351 ******************************************************************************/
373 352
374static acpi_status 353static acpi_status
375acpi_ev_match_prw_and_gpe ( 354acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
376 acpi_handle obj_handle, 355 u32 level, void *info, void **return_value)
377 u32 level,
378 void *info,
379 void **return_value)
380{ 356{
381 struct acpi_gpe_walk_info *gpe_info = (void *) info; 357 struct acpi_gpe_walk_info *gpe_info = (void *)info;
382 struct acpi_namespace_node *gpe_device; 358 struct acpi_namespace_node *gpe_device;
383 struct acpi_gpe_block_info *gpe_block; 359 struct acpi_gpe_block_info *gpe_block;
384 struct acpi_namespace_node *target_gpe_device; 360 struct acpi_namespace_node *target_gpe_device;
385 struct acpi_gpe_event_info *gpe_event_info; 361 struct acpi_gpe_event_info *gpe_event_info;
386 union acpi_operand_object *pkg_desc; 362 union acpi_operand_object *pkg_desc;
387 union acpi_operand_object *obj_desc; 363 union acpi_operand_object *obj_desc;
388 u32 gpe_number; 364 u32 gpe_number;
389 acpi_status status; 365 acpi_status status;
390 366
391 367 ACPI_FUNCTION_TRACE("ev_match_prw_and_gpe");
392 ACPI_FUNCTION_TRACE ("ev_match_prw_and_gpe");
393
394 368
395 /* Check for a _PRW method under this device */ 369 /* Check for a _PRW method under this device */
396 370
397 status = acpi_ut_evaluate_object (obj_handle, METHOD_NAME__PRW, 371 status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW,
398 ACPI_BTYPE_PACKAGE, &pkg_desc); 372 ACPI_BTYPE_PACKAGE, &pkg_desc);
399 if (ACPI_FAILURE (status)) { 373 if (ACPI_FAILURE(status)) {
400 /* 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 */
401 375
402 return_ACPI_STATUS (AE_OK); 376 return_ACPI_STATUS(AE_OK);
403 } 377 }
404 378
405 /* The returned _PRW package must have at least two elements */ 379 /* The returned _PRW package must have at least two elements */
@@ -419,7 +393,7 @@ acpi_ev_match_prw_and_gpe (
419 */ 393 */
420 obj_desc = pkg_desc->package.elements[0]; 394 obj_desc = pkg_desc->package.elements[0];
421 395
422 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 396 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
423 /* Use FADT-defined GPE device (from definition of _PRW) */ 397 /* Use FADT-defined GPE device (from definition of _PRW) */
424 398
425 target_gpe_device = acpi_gbl_fadt_gpe_device; 399 target_gpe_device = acpi_gbl_fadt_gpe_device;
@@ -427,22 +401,23 @@ acpi_ev_match_prw_and_gpe (
427 /* Integer is the GPE number in the FADT described GPE blocks */ 401 /* Integer is the GPE number in the FADT described GPE blocks */
428 402
429 gpe_number = (u32) obj_desc->integer.value; 403 gpe_number = (u32) obj_desc->integer.value;
430 } 404 } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
431 else if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) {
432 /* 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 */
433 406
434 if ((obj_desc->package.count < 2) || 407 if ((obj_desc->package.count < 2) ||
435 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || 408 (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) !=
436 (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)) {
437 goto cleanup; 412 goto cleanup;
438 } 413 }
439 414
440 /* Get GPE block reference and decode */ 415 /* Get GPE block reference and decode */
441 416
442 target_gpe_device = obj_desc->package.elements[0]->reference.node; 417 target_gpe_device =
418 obj_desc->package.elements[0]->reference.node;
443 gpe_number = (u32) obj_desc->package.elements[1]->integer.value; 419 gpe_number = (u32) obj_desc->package.elements[1]->integer.value;
444 } 420 } else {
445 else {
446 /* Unknown type, just ignore it */ 421 /* Unknown type, just ignore it */
447 422
448 goto cleanup; 423 goto cleanup;
@@ -457,26 +432,32 @@ acpi_ev_match_prw_and_gpe (
457 * associated with the GPE device. 432 * associated with the GPE device.
458 */ 433 */
459 if ((gpe_device == target_gpe_device) && 434 if ((gpe_device == target_gpe_device) &&
460 (gpe_number >= gpe_block->block_base_number) && 435 (gpe_number >= gpe_block->block_base_number) &&
461 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 436 (gpe_number <
462 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];
463 441
464 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ 442 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
465 443
466 gpe_event_info->flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 444 gpe_event_info->flags &=
467 status = acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
468 if (ACPI_FAILURE (status)) { 446 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) {
469 goto cleanup; 449 goto cleanup;
470 } 450 }
471 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);
472 } 454 }
473 455
474cleanup: 456 cleanup:
475 acpi_ut_remove_reference (pkg_desc); 457 acpi_ut_remove_reference(pkg_desc);
476 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS(AE_OK);
477} 459}
478 460
479
480/******************************************************************************* 461/*******************************************************************************
481 * 462 *
482 * FUNCTION: acpi_ev_get_gpe_xrupt_block 463 * FUNCTION: acpi_ev_get_gpe_xrupt_block
@@ -492,25 +473,22 @@ cleanup:
492 * 473 *
493 ******************************************************************************/ 474 ******************************************************************************/
494 475
495static struct acpi_gpe_xrupt_info * 476static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
496acpi_ev_get_gpe_xrupt_block ( 477 interrupt_number)
497 u32 interrupt_number)
498{ 478{
499 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 479 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
500 struct acpi_gpe_xrupt_info *gpe_xrupt; 480 struct acpi_gpe_xrupt_info *gpe_xrupt;
501 acpi_status status; 481 acpi_status status;
502 u32 flags; 482 u32 flags;
503
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_number == interrupt_number) { 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_number = interrupt_number; 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 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 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, flags); 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_number != acpi_gbl_FADT->sci_int) { 524 if (interrupt_number != acpi_gbl_FADT->sci_int) {
548 status = acpi_os_install_interrupt_handler (interrupt_number, 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_number)); 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,34 +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 u32 flags; 556 u32 flags;
581
582
583 ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
584 557
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
585 559
586 /* We never want to remove the SCI interrupt handler */ 560 /* We never want to remove the SCI interrupt handler */
587 561
588 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) { 562 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) {
589 gpe_xrupt->gpe_block_list_head = NULL; 563 gpe_xrupt->gpe_block_list_head = NULL;
590 return_ACPI_STATUS (AE_OK); 564 return_ACPI_STATUS(AE_OK);
591 } 565 }
592 566
593 /* Disable this interrupt */ 567 /* Disable this interrupt */
594 568
595 status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_number, 569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
596 acpi_ev_gpe_xrupt_handler); 570 acpi_ev_gpe_xrupt_handler);
597 if (ACPI_FAILURE (status)) { 571 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS (status); 572 return_ACPI_STATUS(status);
599 } 573 }
600 574
601 /* Unlink the interrupt block with lock */ 575 /* Unlink the interrupt block with lock */
602 576
603 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 577 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
604 if (gpe_xrupt->previous) { 578 if (gpe_xrupt->previous) {
605 gpe_xrupt->previous->next = gpe_xrupt->next; 579 gpe_xrupt->previous->next = gpe_xrupt->next;
606 } 580 }
@@ -608,15 +582,14 @@ acpi_ev_delete_gpe_xrupt (
608 if (gpe_xrupt->next) { 582 if (gpe_xrupt->next) {
609 gpe_xrupt->next->previous = gpe_xrupt->previous; 583 gpe_xrupt->next->previous = gpe_xrupt->previous;
610 } 584 }
611 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 585 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
612 586
613 /* Free the block */ 587 /* Free the block */
614 588
615 ACPI_MEM_FREE (gpe_xrupt); 589 ACPI_MEM_FREE(gpe_xrupt);
616 return_ACPI_STATUS (AE_OK); 590 return_ACPI_STATUS(AE_OK);
617} 591}
618 592
619
620/******************************************************************************* 593/*******************************************************************************
621 * 594 *
622 * FUNCTION: acpi_ev_install_gpe_block 595 * FUNCTION: acpi_ev_install_gpe_block
@@ -631,25 +604,22 @@ acpi_ev_delete_gpe_xrupt (
631 ******************************************************************************/ 604 ******************************************************************************/
632 605
633static acpi_status 606static acpi_status
634acpi_ev_install_gpe_block ( 607acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
635 struct acpi_gpe_block_info *gpe_block, 608 u32 interrupt_number)
636 u32 interrupt_number)
637{ 609{
638 struct acpi_gpe_block_info *next_gpe_block; 610 struct acpi_gpe_block_info *next_gpe_block;
639 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 611 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
640 acpi_status status; 612 acpi_status status;
641 u32 flags; 613 u32 flags;
642 614
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
643 616
644 ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); 617 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
645 618 if (ACPI_FAILURE(status)) {
646 619 return_ACPI_STATUS(status);
647 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
648 if (ACPI_FAILURE (status)) {
649 return_ACPI_STATUS (status);
650 } 620 }
651 621
652 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_number); 622 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number);
653 if (!gpe_xrupt_block) { 623 if (!gpe_xrupt_block) {
654 status = AE_NO_MEMORY; 624 status = AE_NO_MEMORY;
655 goto unlock_and_exit; 625 goto unlock_and_exit;
@@ -657,7 +627,7 @@ acpi_ev_install_gpe_block (
657 627
658 /* 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 */
659 629
660 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 630 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
661 if (gpe_xrupt_block->gpe_block_list_head) { 631 if (gpe_xrupt_block->gpe_block_list_head) {
662 next_gpe_block = gpe_xrupt_block->gpe_block_list_head; 632 next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
663 while (next_gpe_block->next) { 633 while (next_gpe_block->next) {
@@ -666,20 +636,18 @@ acpi_ev_install_gpe_block (
666 636
667 next_gpe_block->next = gpe_block; 637 next_gpe_block->next = gpe_block;
668 gpe_block->previous = next_gpe_block; 638 gpe_block->previous = next_gpe_block;
669 } 639 } else {
670 else {
671 gpe_xrupt_block->gpe_block_list_head = gpe_block; 640 gpe_xrupt_block->gpe_block_list_head = gpe_block;
672 } 641 }
673 642
674 gpe_block->xrupt_block = gpe_xrupt_block; 643 gpe_block->xrupt_block = gpe_xrupt_block;
675 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 644 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
676 645
677unlock_and_exit: 646 unlock_and_exit:
678 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 647 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
679 return_ACPI_STATUS (status); 648 return_ACPI_STATUS(status);
680} 649}
681 650
682
683/******************************************************************************* 651/*******************************************************************************
684 * 652 *
685 * FUNCTION: acpi_ev_delete_gpe_block 653 * FUNCTION: acpi_ev_delete_gpe_block
@@ -692,63 +660,57 @@ unlock_and_exit:
692 * 660 *
693 ******************************************************************************/ 661 ******************************************************************************/
694 662
695acpi_status 663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
696acpi_ev_delete_gpe_block (
697 struct acpi_gpe_block_info *gpe_block)
698{ 664{
699 acpi_status status; 665 acpi_status status;
700 u32 flags; 666 u32 flags;
701
702
703 ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
704 667
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
705 669
706 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 670 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
707 if (ACPI_FAILURE (status)) { 671 if (ACPI_FAILURE(status)) {
708 return_ACPI_STATUS (status); 672 return_ACPI_STATUS(status);
709 } 673 }
710 674
711 /* Disable all GPEs in this block */ 675 /* Disable all GPEs in this block */
712 676
713 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);
714 678
715 if (!gpe_block->previous && !gpe_block->next) { 679 if (!gpe_block->previous && !gpe_block->next) {
716 /* This is the last gpe_block on this interrupt */ 680 /* This is the last gpe_block on this interrupt */
717 681
718 status = acpi_ev_delete_gpe_xrupt (gpe_block->xrupt_block); 682 status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block);
719 if (ACPI_FAILURE (status)) { 683 if (ACPI_FAILURE(status)) {
720 goto unlock_and_exit; 684 goto unlock_and_exit;
721 } 685 }
722 } 686 } else {
723 else {
724 /* Remove the block on this interrupt with lock */ 687 /* Remove the block on this interrupt with lock */
725 688
726 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 689 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
727 if (gpe_block->previous) { 690 if (gpe_block->previous) {
728 gpe_block->previous->next = gpe_block->next; 691 gpe_block->previous->next = gpe_block->next;
729 } 692 } else {
730 else { 693 gpe_block->xrupt_block->gpe_block_list_head =
731 gpe_block->xrupt_block->gpe_block_list_head = gpe_block->next; 694 gpe_block->next;
732 } 695 }
733 696
734 if (gpe_block->next) { 697 if (gpe_block->next) {
735 gpe_block->next->previous = gpe_block->previous; 698 gpe_block->next->previous = gpe_block->previous;
736 } 699 }
737 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 700 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
738 } 701 }
739 702
740 /* Free the gpe_block */ 703 /* Free the gpe_block */
741 704
742 ACPI_MEM_FREE (gpe_block->register_info); 705 ACPI_MEM_FREE(gpe_block->register_info);
743 ACPI_MEM_FREE (gpe_block->event_info); 706 ACPI_MEM_FREE(gpe_block->event_info);
744 ACPI_MEM_FREE (gpe_block); 707 ACPI_MEM_FREE(gpe_block);
745 708
746unlock_and_exit: 709 unlock_and_exit:
747 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 710 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
748 return_ACPI_STATUS (status); 711 return_ACPI_STATUS(status);
749} 712}
750 713
751
752/******************************************************************************* 714/*******************************************************************************
753 * 715 *
754 * FUNCTION: acpi_ev_create_gpe_info_blocks 716 * FUNCTION: acpi_ev_create_gpe_info_blocks
@@ -762,43 +724,41 @@ unlock_and_exit:
762 ******************************************************************************/ 724 ******************************************************************************/
763 725
764static acpi_status 726static acpi_status
765acpi_ev_create_gpe_info_blocks ( 727acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
766 struct acpi_gpe_block_info *gpe_block)
767{ 728{
768 struct acpi_gpe_register_info *gpe_register_info = NULL; 729 struct acpi_gpe_register_info *gpe_register_info = NULL;
769 struct acpi_gpe_event_info *gpe_event_info = NULL; 730 struct acpi_gpe_event_info *gpe_event_info = NULL;
770 struct acpi_gpe_event_info *this_event; 731 struct acpi_gpe_event_info *this_event;
771 struct acpi_gpe_register_info *this_register; 732 struct acpi_gpe_register_info *this_register;
772 acpi_native_uint i; 733 acpi_native_uint i;
773 acpi_native_uint j; 734 acpi_native_uint j;
774 acpi_status status; 735 acpi_status status;
775
776
777 ACPI_FUNCTION_TRACE ("ev_create_gpe_info_blocks");
778 736
737 ACPI_FUNCTION_TRACE("ev_create_gpe_info_blocks");
779 738
780 /* Allocate the GPE register information block */ 739 /* Allocate the GPE register information block */
781 740
782 gpe_register_info = ACPI_MEM_CALLOCATE ( 741 gpe_register_info = ACPI_MEM_CALLOCATE((acpi_size) gpe_block->
783 (acpi_size) gpe_block->register_count * 742 register_count *
784 sizeof (struct acpi_gpe_register_info)); 743 sizeof(struct
744 acpi_gpe_register_info));
785 if (!gpe_register_info) { 745 if (!gpe_register_info) {
786 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 746 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
787 "Could not allocate the gpe_register_info table\n")); 747 "Could not allocate the gpe_register_info table\n"));
788 return_ACPI_STATUS (AE_NO_MEMORY); 748 return_ACPI_STATUS(AE_NO_MEMORY);
789 } 749 }
790 750
791 /* 751 /*
792 * Allocate the GPE event_info block. There are eight distinct GPEs 752 * Allocate the GPE event_info block. There are eight distinct GPEs
793 * per register. Initialization to zeros is sufficient. 753 * per register. Initialization to zeros is sufficient.
794 */ 754 */
795 gpe_event_info = ACPI_MEM_CALLOCATE ( 755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
796 ((acpi_size) gpe_block->register_count * 756 register_count *
797 ACPI_GPE_REGISTER_WIDTH) * 757 ACPI_GPE_REGISTER_WIDTH) *
798 sizeof (struct acpi_gpe_event_info)); 758 sizeof(struct acpi_gpe_event_info));
799 if (!gpe_event_info) { 759 if (!gpe_event_info) {
800 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 760 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
801 "Could not allocate the gpe_event_info table\n")); 761 "Could not allocate the gpe_event_info table\n"));
802 status = AE_NO_MEMORY; 762 status = AE_NO_MEMORY;
803 goto error_exit; 763 goto error_exit;
804 } 764 }
@@ -806,7 +766,7 @@ acpi_ev_create_gpe_info_blocks (
806 /* Save the new Info arrays in the GPE block */ 766 /* Save the new Info arrays in the GPE block */
807 767
808 gpe_block->register_info = gpe_register_info; 768 gpe_block->register_info = gpe_register_info;
809 gpe_block->event_info = gpe_event_info; 769 gpe_block->event_info = gpe_event_info;
810 770
811 /* 771 /*
812 * Initialize the GPE Register and Event structures. A goal of these 772 * Initialize the GPE Register and Event structures. A goal of these
@@ -815,29 +775,34 @@ acpi_ev_create_gpe_info_blocks (
815 * and the enable registers occupy the second half. 775 * and the enable registers occupy the second half.
816 */ 776 */
817 this_register = gpe_register_info; 777 this_register = gpe_register_info;
818 this_event = gpe_event_info; 778 this_event = gpe_event_info;
819 779
820 for (i = 0; i < gpe_block->register_count; i++) { 780 for (i = 0; i < gpe_block->register_count; i++) {
821 /* Init the register_info for this GPE register (8 GPEs) */ 781 /* Init the register_info for this GPE register (8 GPEs) */
822 782
823 this_register->base_gpe_number = (u8) (gpe_block->block_base_number + 783 this_register->base_gpe_number =
824 (i * ACPI_GPE_REGISTER_WIDTH)); 784 (u8) (gpe_block->block_base_number +
825 785 (i * ACPI_GPE_REGISTER_WIDTH));
826 ACPI_STORE_ADDRESS (this_register->status_address.address, 786
827 (gpe_block->block_address.address 787 ACPI_STORE_ADDRESS(this_register->status_address.address,
828 + i)); 788 (gpe_block->block_address.address + i));
829 789
830 ACPI_STORE_ADDRESS (this_register->enable_address.address, 790 ACPI_STORE_ADDRESS(this_register->enable_address.address,
831 (gpe_block->block_address.address 791 (gpe_block->block_address.address
832 + i 792 + i + gpe_block->register_count));
833 + gpe_block->register_count)); 793
834 794 this_register->status_address.address_space_id =
835 this_register->status_address.address_space_id = gpe_block->block_address.address_space_id; 795 gpe_block->block_address.address_space_id;
836 this_register->enable_address.address_space_id = gpe_block->block_address.address_space_id; 796 this_register->enable_address.address_space_id =
837 this_register->status_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 797 gpe_block->block_address.address_space_id;
838 this_register->enable_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 798 this_register->status_address.register_bit_width =
839 this_register->status_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; 799 ACPI_GPE_REGISTER_WIDTH;
840 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;
841 806
842 /* Init the event_info for each GPE within this register */ 807 /* Init the event_info for each GPE within this register */
843 808
@@ -852,36 +817,36 @@ acpi_ev_create_gpe_info_blocks (
852 * are cleared by writing a '1', while enable registers are cleared 817 * are cleared by writing a '1', while enable registers are cleared
853 * by writing a '0'. 818 * by writing a '0'.
854 */ 819 */
855 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0x00, 820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
856 &this_register->enable_address); 821 &this_register->
857 if (ACPI_FAILURE (status)) { 822 enable_address);
823 if (ACPI_FAILURE(status)) {
858 goto error_exit; 824 goto error_exit;
859 } 825 }
860 826
861 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0xFF, 827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
862 &this_register->status_address); 828 &this_register->
863 if (ACPI_FAILURE (status)) { 829 status_address);
830 if (ACPI_FAILURE(status)) {
864 goto error_exit; 831 goto error_exit;
865 } 832 }
866 833
867 this_register++; 834 this_register++;
868 } 835 }
869 836
870 return_ACPI_STATUS (AE_OK); 837 return_ACPI_STATUS(AE_OK);
871
872 838
873error_exit: 839 error_exit:
874 if (gpe_register_info) { 840 if (gpe_register_info) {
875 ACPI_MEM_FREE (gpe_register_info); 841 ACPI_MEM_FREE(gpe_register_info);
876 } 842 }
877 if (gpe_event_info) { 843 if (gpe_event_info) {
878 ACPI_MEM_FREE (gpe_event_info); 844 ACPI_MEM_FREE(gpe_event_info);
879 } 845 }
880 846
881 return_ACPI_STATUS (status); 847 return_ACPI_STATUS(status);
882} 848}
883 849
884
885/******************************************************************************* 850/*******************************************************************************
886 * 851 *
887 * FUNCTION: acpi_ev_create_gpe_block 852 * FUNCTION: acpi_ev_create_gpe_block
@@ -900,68 +865,66 @@ error_exit:
900 ******************************************************************************/ 865 ******************************************************************************/
901 866
902acpi_status 867acpi_status
903acpi_ev_create_gpe_block ( 868acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
904 struct acpi_namespace_node *gpe_device, 869 struct acpi_generic_address *gpe_block_address,
905 struct acpi_generic_address *gpe_block_address, 870 u32 register_count,
906 u32 register_count, 871 u8 gpe_block_base_number,
907 u8 gpe_block_base_number, 872 u32 interrupt_number,
908 u32 interrupt_number, 873 struct acpi_gpe_block_info **return_gpe_block)
909 struct acpi_gpe_block_info **return_gpe_block)
910{ 874{
911 struct acpi_gpe_block_info *gpe_block; 875 struct acpi_gpe_block_info *gpe_block;
912 struct acpi_gpe_event_info *gpe_event_info; 876 struct acpi_gpe_event_info *gpe_event_info;
913 acpi_native_uint i; 877 acpi_native_uint i;
914 acpi_native_uint j; 878 acpi_native_uint j;
915 u32 wake_gpe_count; 879 u32 wake_gpe_count;
916 u32 gpe_enabled_count; 880 u32 gpe_enabled_count;
917 acpi_status status; 881 acpi_status status;
918 struct acpi_gpe_walk_info gpe_info; 882 struct acpi_gpe_walk_info gpe_info;
919
920
921 ACPI_FUNCTION_TRACE ("ev_create_gpe_block");
922 883
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
923 885
924 if (!register_count) { 886 if (!register_count) {
925 return_ACPI_STATUS (AE_OK); 887 return_ACPI_STATUS(AE_OK);
926 } 888 }
927 889
928 /* Allocate a new GPE block */ 890 /* Allocate a new GPE block */
929 891
930 gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info)); 892 gpe_block = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_block_info));
931 if (!gpe_block) { 893 if (!gpe_block) {
932 return_ACPI_STATUS (AE_NO_MEMORY); 894 return_ACPI_STATUS(AE_NO_MEMORY);
933 } 895 }
934 896
935 /* Initialize the new GPE block */ 897 /* Initialize the new GPE block */
936 898
937 gpe_block->register_count = register_count; 899 gpe_block->register_count = register_count;
938 gpe_block->block_base_number = gpe_block_base_number; 900 gpe_block->block_base_number = gpe_block_base_number;
939 gpe_block->node = gpe_device; 901 gpe_block->node = gpe_device;
940 902
941 ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, 903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
942 sizeof (struct acpi_generic_address)); 904 sizeof(struct acpi_generic_address));
943 905
944 /* Create the register_info and event_info sub-structures */ 906 /* Create the register_info and event_info sub-structures */
945 907
946 status = acpi_ev_create_gpe_info_blocks (gpe_block); 908 status = acpi_ev_create_gpe_info_blocks(gpe_block);
947 if (ACPI_FAILURE (status)) { 909 if (ACPI_FAILURE(status)) {
948 ACPI_MEM_FREE (gpe_block); 910 ACPI_MEM_FREE(gpe_block);
949 return_ACPI_STATUS (status); 911 return_ACPI_STATUS(status);
950 } 912 }
951 913
952 /* Install the new block in the global list(s) */ 914 /* Install the new block in the global list(s) */
953 915
954 status = acpi_ev_install_gpe_block (gpe_block, interrupt_number); 916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
955 if (ACPI_FAILURE (status)) { 917 if (ACPI_FAILURE(status)) {
956 ACPI_MEM_FREE (gpe_block); 918 ACPI_MEM_FREE(gpe_block);
957 return_ACPI_STATUS (status); 919 return_ACPI_STATUS(status);
958 } 920 }
959 921
960 /* Find all GPE methods (_Lxx, _Exx) for this block */ 922 /* Find all GPE methods (_Lxx, _Exx) for this block */
961 923
962 status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device, 924 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
963 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, 925 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
964 gpe_block, NULL); 926 acpi_ev_save_method_info, gpe_block,
927 NULL);
965 928
966 /* 929 /*
967 * Runtime option: Should Wake GPEs be enabled at runtime? The default 930 * Runtime option: Should Wake GPEs be enabled at runtime? The default
@@ -977,9 +940,11 @@ acpi_ev_create_gpe_block (
977 gpe_info.gpe_block = gpe_block; 940 gpe_info.gpe_block = gpe_block;
978 gpe_info.gpe_device = gpe_device; 941 gpe_info.gpe_device = gpe_device;
979 942
980 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 943 status =
981 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ev_match_prw_and_gpe, 944 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
982 &gpe_info, NULL); 945 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
946 acpi_ev_match_prw_and_gpe, &gpe_info,
947 NULL);
983 } 948 }
984 949
985 /* 950 /*
@@ -994,10 +959,14 @@ acpi_ev_create_gpe_block (
994 for (j = 0; j < 8; j++) { 959 for (j = 0; j < 8; j++) {
995 /* Get the info block for this particular GPE */ 960 /* Get the info block for this particular GPE */
996 961
997 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];
998 965
999 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && 966 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
1000 (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { 967 ACPI_GPE_DISPATCH_METHOD)
968 && (gpe_event_info->
969 flags & ACPI_GPE_TYPE_RUNTIME)) {
1001 gpe_enabled_count++; 970 gpe_enabled_count++;
1002 } 971 }
1003 972
@@ -1009,22 +978,22 @@ acpi_ev_create_gpe_block (
1009 978
1010 /* Dump info about this GPE block */ 979 /* Dump info about this GPE block */
1011 980
1012 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1013 "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",
1014 (u32) gpe_block->block_base_number, 983 (u32) gpe_block->block_base_number,
1015 (u32) (gpe_block->block_base_number + 984 (u32) (gpe_block->block_base_number +
1016 ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), 985 ((gpe_block->register_count *
1017 gpe_device->name.ascii, 986 ACPI_GPE_REGISTER_WIDTH) - 1)),
1018 gpe_block->register_count, 987 gpe_device->name.ascii, gpe_block->register_count,
1019 interrupt_number)); 988 interrupt_number));
1020 989
1021 /* Enable all valid GPEs found above */ 990 /* Enable all valid GPEs found above */
1022 991
1023 status = acpi_hw_enable_runtime_gpe_block (NULL, gpe_block); 992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1024 993
1025 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 994 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1026 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
1027 wake_gpe_count, gpe_enabled_count)); 996 wake_gpe_count, gpe_enabled_count));
1028 997
1029 /* Return the new block */ 998 /* Return the new block */
1030 999
@@ -1032,10 +1001,9 @@ acpi_ev_create_gpe_block (
1032 (*return_gpe_block) = gpe_block; 1001 (*return_gpe_block) = gpe_block;
1033 } 1002 }
1034 1003
1035 return_ACPI_STATUS (AE_OK); 1004 return_ACPI_STATUS(AE_OK);
1036} 1005}
1037 1006
1038
1039/******************************************************************************* 1007/*******************************************************************************
1040 * 1008 *
1041 * FUNCTION: acpi_ev_gpe_initialize 1009 * FUNCTION: acpi_ev_gpe_initialize
@@ -1048,22 +1016,18 @@ acpi_ev_create_gpe_block (
1048 * 1016 *
1049 ******************************************************************************/ 1017 ******************************************************************************/
1050 1018
1051acpi_status 1019acpi_status acpi_ev_gpe_initialize(void)
1052acpi_ev_gpe_initialize (
1053 void)
1054{ 1020{
1055 u32 register_count0 = 0; 1021 u32 register_count0 = 0;
1056 u32 register_count1 = 0; 1022 u32 register_count1 = 0;
1057 u32 gpe_number_max = 0; 1023 u32 gpe_number_max = 0;
1058 acpi_status status; 1024 acpi_status status;
1059 1025
1026 ACPI_FUNCTION_TRACE("ev_gpe_initialize");
1060 1027
1061 ACPI_FUNCTION_TRACE ("ev_gpe_initialize"); 1028 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1062 1029 if (ACPI_FAILURE(status)) {
1063 1030 return_ACPI_STATUS(status);
1064 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
1065 if (ACPI_FAILURE (status)) {
1066 return_ACPI_STATUS (status);
1067 } 1031 }
1068 1032
1069 /* 1033 /*
@@ -1091,29 +1055,29 @@ acpi_ev_gpe_initialize (
1091 * 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
1092 * particular block is not supported. 1056 * particular block is not supported.
1093 */ 1057 */
1094 if (acpi_gbl_FADT->gpe0_blk_len && 1058 if (acpi_gbl_FADT->gpe0_blk_len && acpi_gbl_FADT->xgpe0_blk.address) {
1095 acpi_gbl_FADT->xgpe0_blk.address) {
1096 /* GPE block 0 exists (has both length and address > 0) */ 1059 /* GPE block 0 exists (has both length and address > 0) */
1097 1060
1098 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2); 1061 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2);
1099 1062
1100 gpe_number_max = (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; 1063 gpe_number_max =
1064 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
1101 1065
1102 /* Install GPE Block 0 */ 1066 /* Install GPE Block 0 */
1103 1067
1104 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1068 status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1105 &acpi_gbl_FADT->xgpe0_blk, register_count0, 0, 1069 &acpi_gbl_FADT->xgpe0_blk,
1106 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]);
1107 1073
1108 if (ACPI_FAILURE (status)) { 1074 if (ACPI_FAILURE(status)) {
1109 ACPI_REPORT_ERROR (( 1075 ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n",
1110 "Could not create GPE Block 0, %s\n", 1076 acpi_format_exception(status)));
1111 acpi_format_exception (status)));
1112 } 1077 }
1113 } 1078 }
1114 1079
1115 if (acpi_gbl_FADT->gpe1_blk_len && 1080 if (acpi_gbl_FADT->gpe1_blk_len && acpi_gbl_FADT->xgpe1_blk.address) {
1116 acpi_gbl_FADT->xgpe1_blk.address) {
1117 /* GPE block 1 exists (has both length and address > 0) */ 1081 /* GPE block 1 exists (has both length and address > 0) */
1118 1082
1119 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2); 1083 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2);
@@ -1121,29 +1085,26 @@ acpi_ev_gpe_initialize (
1121 /* Check for GPE0/GPE1 overlap (if both banks exist) */ 1085 /* Check for GPE0/GPE1 overlap (if both banks exist) */
1122 1086
1123 if ((register_count0) && 1087 if ((register_count0) &&
1124 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { 1088 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
1125 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)));
1126 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n",
1127 gpe_number_max, acpi_gbl_FADT->gpe1_base,
1128 acpi_gbl_FADT->gpe1_base +
1129 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
1130 1090
1131 /* Ignore GPE1 block by setting the register count to zero */ 1091 /* Ignore GPE1 block by setting the register count to zero */
1132 1092
1133 register_count1 = 0; 1093 register_count1 = 0;
1134 } 1094 } else {
1135 else {
1136 /* Install GPE Block 1 */ 1095 /* Install GPE Block 1 */
1137 1096
1138 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1097 status =
1139 &acpi_gbl_FADT->xgpe1_blk, register_count1, 1098 acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1140 acpi_gbl_FADT->gpe1_base, 1099 &acpi_gbl_FADT->xgpe1_blk,
1141 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]); 1100 register_count1,
1142 1101 acpi_gbl_FADT->gpe1_base,
1143 if (ACPI_FAILURE (status)) { 1102 acpi_gbl_FADT->sci_int,
1144 ACPI_REPORT_ERROR (( 1103 &acpi_gbl_gpe_fadt_blocks
1145 "Could not create GPE Block 1, %s\n", 1104 [1]);
1146 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)));
1147 } 1108 }
1148 1109
1149 /* 1110 /*
@@ -1151,7 +1112,7 @@ acpi_ev_gpe_initialize (
1151 * space. However, GPE0 always starts at GPE number zero. 1112 * space. However, GPE0 always starts at GPE number zero.
1152 */ 1113 */
1153 gpe_number_max = acpi_gbl_FADT->gpe1_base + 1114 gpe_number_max = acpi_gbl_FADT->gpe1_base +
1154 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); 1115 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
1155 } 1116 }
1156 } 1117 }
1157 1118
@@ -1160,8 +1121,8 @@ acpi_ev_gpe_initialize (
1160 if ((register_count0 + register_count1) == 0) { 1121 if ((register_count0 + register_count1) == 0) {
1161 /* GPEs are not required by ACPI, this is OK */ 1122 /* GPEs are not required by ACPI, this is OK */
1162 1123
1163 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 1124 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1164 "There are no GPE blocks defined in the FADT\n")); 1125 "There are no GPE blocks defined in the FADT\n"));
1165 status = AE_OK; 1126 status = AE_OK;
1166 goto cleanup; 1127 goto cleanup;
1167 } 1128 }
@@ -1169,15 +1130,12 @@ acpi_ev_gpe_initialize (
1169 /* Check for Max GPE number out-of-range */ 1130 /* Check for Max GPE number out-of-range */
1170 1131
1171 if (gpe_number_max > ACPI_GPE_MAX) { 1132 if (gpe_number_max > ACPI_GPE_MAX) {
1172 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));
1173 gpe_number_max));
1174 status = AE_BAD_VALUE; 1134 status = AE_BAD_VALUE;
1175 goto cleanup; 1135 goto cleanup;
1176 } 1136 }
1177 1137
1178cleanup: 1138 cleanup:
1179 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 1139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1180 return_ACPI_STATUS (AE_OK); 1140 return_ACPI_STATUS(AE_OK);
1181} 1141}
1182
1183
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 3df3ada4b9e7..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,17 +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) {
414 ACPI_REPORT_ERROR (( 387 ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n"));
415 "No response from Global Lock hardware, disabling lock\n"));
416 388
417 acpi_gbl_global_lock_present = FALSE; 389 acpi_gbl_global_lock_present = FALSE;
418 status = AE_OK; 390 status = AE_OK;
419 } 391 }
420 392
421 return_ACPI_STATUS (status); 393 return_ACPI_STATUS(status);
422} 394}
423 395
424
425/****************************************************************************** 396/******************************************************************************
426 * 397 *
427 * FUNCTION: acpi_ev_acquire_global_lock 398 * FUNCTION: acpi_ev_acquire_global_lock
@@ -434,22 +405,18 @@ acpi_ev_init_global_lock_handler (
434 * 405 *
435 *****************************************************************************/ 406 *****************************************************************************/
436 407
437acpi_status 408acpi_status acpi_ev_acquire_global_lock(u16 timeout)
438acpi_ev_acquire_global_lock (
439 u16 timeout)
440{ 409{
441 acpi_status status = AE_OK; 410 acpi_status status = AE_OK;
442 u8 acquired = FALSE; 411 u8 acquired = FALSE;
443
444
445 ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");
446 412
413 ACPI_FUNCTION_TRACE("ev_acquire_global_lock");
447 414
448#ifndef ACPI_APPLICATION 415#ifndef ACPI_APPLICATION
449 /* Make sure that we actually have a global lock */ 416 /* Make sure that we actually have a global lock */
450 417
451 if (!acpi_gbl_global_lock_present) { 418 if (!acpi_gbl_global_lock_present) {
452 return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); 419 return_ACPI_STATUS(AE_NO_GLOBAL_LOCK);
453 } 420 }
454#endif 421#endif
455 422
@@ -462,37 +429,37 @@ acpi_ev_acquire_global_lock (
462 * we are done 429 * we are done
463 */ 430 */
464 if (acpi_gbl_global_lock_acquired) { 431 if (acpi_gbl_global_lock_acquired) {
465 return_ACPI_STATUS (AE_OK); 432 return_ACPI_STATUS(AE_OK);
466 } 433 }
467 434
468 /* We must acquire the actual hardware lock */ 435 /* We must acquire the actual hardware lock */
469 436
470 ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); 437 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
471 if (acquired) { 438 if (acquired) {
472 /* We got the lock */ 439 /* We got the lock */
473 440
474 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"));
475 443
476 acpi_gbl_global_lock_acquired = TRUE; 444 acpi_gbl_global_lock_acquired = TRUE;
477 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS(AE_OK);
478 } 446 }
479 447
480 /* 448 /*
481 * 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
482 * wait until we get the global lock released interrupt. 450 * wait until we get the global lock released interrupt.
483 */ 451 */
484 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"));
485 453
486 /* 454 /*
487 * Acquire the global lock semaphore first. 455 * Acquire the global lock semaphore first.
488 * Since this wait will block, we must release the interpreter 456 * Since this wait will block, we must release the interpreter
489 */ 457 */
490 status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore, 458 status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
491 timeout); 459 timeout);
492 return_ACPI_STATUS (status); 460 return_ACPI_STATUS(status);
493} 461}
494 462
495
496/******************************************************************************* 463/*******************************************************************************
497 * 464 *
498 * FUNCTION: acpi_ev_release_global_lock 465 * FUNCTION: acpi_ev_release_global_lock
@@ -505,21 +472,16 @@ acpi_ev_acquire_global_lock (
505 * 472 *
506 ******************************************************************************/ 473 ******************************************************************************/
507 474
508acpi_status 475acpi_status acpi_ev_release_global_lock(void)
509acpi_ev_release_global_lock (
510 void)
511{ 476{
512 u8 pending = FALSE; 477 u8 pending = FALSE;
513 acpi_status status = AE_OK; 478 acpi_status status = AE_OK;
514
515
516 ACPI_FUNCTION_TRACE ("ev_release_global_lock");
517 479
480 ACPI_FUNCTION_TRACE("ev_release_global_lock");
518 481
519 if (!acpi_gbl_global_lock_thread_count) { 482 if (!acpi_gbl_global_lock_thread_count) {
520 ACPI_REPORT_WARNING(( 483 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
521 "Cannot release HW Global Lock, it has not been acquired\n")); 484 return_ACPI_STATUS(AE_NOT_ACQUIRED);
522 return_ACPI_STATUS (AE_NOT_ACQUIRED);
523 } 485 }
524 486
525 /* One fewer thread has the global lock */ 487 /* One fewer thread has the global lock */
@@ -528,14 +490,14 @@ acpi_ev_release_global_lock (
528 if (acpi_gbl_global_lock_thread_count) { 490 if (acpi_gbl_global_lock_thread_count) {
529 /* There are still some threads holding the lock, cannot release */ 491 /* There are still some threads holding the lock, cannot release */
530 492
531 return_ACPI_STATUS (AE_OK); 493 return_ACPI_STATUS(AE_OK);
532 } 494 }
533 495
534 /* 496 /*
535 * No more threads holding lock, we can do the actual hardware 497 * No more threads holding lock, we can do the actual hardware
536 * release 498 * release
537 */ 499 */
538 ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending); 500 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, pending);
539 acpi_gbl_global_lock_acquired = FALSE; 501 acpi_gbl_global_lock_acquired = FALSE;
540 502
541 /* 503 /*
@@ -543,14 +505,13 @@ acpi_ev_release_global_lock (
543 * register 505 * register
544 */ 506 */
545 if (pending) { 507 if (pending) {
546 status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 508 status = acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE,
547 1, ACPI_MTX_LOCK); 509 1, ACPI_MTX_LOCK);
548 } 510 }
549 511
550 return_ACPI_STATUS (status); 512 return_ACPI_STATUS(status);
551} 513}
552 514
553
554/****************************************************************************** 515/******************************************************************************
555 * 516 *
556 * FUNCTION: acpi_ev_terminate 517 * FUNCTION: acpi_ev_terminate
@@ -563,16 +524,12 @@ acpi_ev_release_global_lock (
563 * 524 *
564 ******************************************************************************/ 525 ******************************************************************************/
565 526
566void 527void acpi_ev_terminate(void)
567acpi_ev_terminate (
568 void)
569{ 528{
570 acpi_native_uint i; 529 acpi_native_uint i;
571 acpi_status status; 530 acpi_status status;
572
573
574 ACPI_FUNCTION_TRACE ("ev_terminate");
575 531
532 ACPI_FUNCTION_TRACE("ev_terminate");
576 533
577 if (acpi_gbl_events_initialized) { 534 if (acpi_gbl_events_initialized) {
578 /* 535 /*
@@ -583,38 +540,39 @@ acpi_ev_terminate (
583 /* Disable all fixed events */ 540 /* Disable all fixed events */
584 541
585 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 542 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
586 status = acpi_disable_event ((u32) i, 0); 543 status = acpi_disable_event((u32) i, 0);
587 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
588 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
589 "Could not disable fixed event %d\n", (u32) i)); 546 "Could not disable fixed event %d\n",
547 (u32) i));
590 } 548 }
591 } 549 }
592 550
593 /* Disable all GPEs in all GPE blocks */ 551 /* Disable all GPEs in all GPE blocks */
594 552
595 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); 553 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
596 554
597 /* Remove SCI handler */ 555 /* Remove SCI handler */
598 556
599 status = acpi_ev_remove_sci_handler (); 557 status = acpi_ev_remove_sci_handler();
600 if (ACPI_FAILURE(status)) { 558 if (ACPI_FAILURE(status)) {
601 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 559 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
602 "Could not remove SCI handler\n")); 560 "Could not remove SCI handler\n"));
603 } 561 }
604 } 562 }
605 563
606 /* Deallocate all handler objects installed within GPE info structs */ 564 /* Deallocate all handler objects installed within GPE info structs */
607 565
608 status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers); 566 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers);
609 567
610 /* Return to original mode if necessary */ 568 /* Return to original mode if necessary */
611 569
612 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { 570 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
613 status = acpi_disable (); 571 status = acpi_disable();
614 if (ACPI_FAILURE (status)) { 572 if (ACPI_FAILURE(status)) {
615 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n")); 573 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
574 "acpi_disable failed\n"));
616 } 575 }
617 } 576 }
618 return_VOID; 577 return_VOID;
619} 578}
620
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 f2d53af97610..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,22 +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);
208 if (ACPI_SUCCESS(status)) {
221 /* 209 /*
222 * Got a valid _HID string, check if this is a PCI root. 210 * Got a valid _HID string, check if this is a PCI root.
223 * New for ACPI 3.0: check for a PCI Express root also. 211 * New for ACPI 3.0: check for a PCI Express root also.
224 */ 212 */
225 if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, 213 if (!
226 sizeof (PCI_ROOT_HID_STRING)) || 214 (ACPI_STRNCMP
227 !(ACPI_STRNCMP (object_hID.value, PCI_EXPRESS_ROOT_HID_STRING, 215 (object_hID.value, PCI_ROOT_HID_STRING,
228 sizeof (PCI_EXPRESS_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 {
229 /* Install a handler for this PCI root bridge */ 223 /* Install a handler for this PCI root bridge */
230 224
231 status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, 225 status =
232 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);
233 ACPI_DEFAULT_HANDLER, NULL, NULL); 227 if (ACPI_FAILURE(status)) {
234 if (ACPI_FAILURE (status)) {
235 if (status == AE_SAME_HANDLER) { 228 if (status == AE_SAME_HANDLER) {
236 /* 229 /*
237 * 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
@@ -239,23 +232,19 @@ acpi_ev_pci_config_region_setup (
239 * new PCI_Config operation region, however. 232 * new PCI_Config operation region, however.
240 */ 233 */
241 status = AE_OK; 234 status = AE_OK;
242 } 235 } else {
243 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)));
244 ACPI_REPORT_ERROR ((
245 "Could not install pci_config handler for Root Bridge %4.4s, %s\n",
246 acpi_ut_get_node_name (pci_root_node), acpi_format_exception (status)));
247 } 237 }
248 } 238 }
249 break; 239 break;
250 } 240 }
251 } 241 }
252 242
253 pci_root_node = acpi_ns_get_parent_node (pci_root_node); 243 pci_root_node = acpi_ns_get_parent_node(pci_root_node);
254 } 244 }
255 245
256 /* PCI root bridge not found, use namespace root node */ 246 /* PCI root bridge not found, use namespace root node */
257 } 247 } else {
258 else {
259 pci_root_node = handler_obj->address_space.node; 248 pci_root_node = handler_obj->address_space.node;
260 } 249 }
261 250
@@ -264,14 +253,14 @@ acpi_ev_pci_config_region_setup (
264 * (install_address_space_handler could have initialized it) 253 * (install_address_space_handler could have initialized it)
265 */ 254 */
266 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 255 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
267 return_ACPI_STATUS (AE_OK); 256 return_ACPI_STATUS(AE_OK);
268 } 257 }
269 258
270 /* Region is still not initialized. Create a new context */ 259 /* Region is still not initialized. Create a new context */
271 260
272 pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id)); 261 pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id));
273 if (!pci_id) { 262 if (!pci_id) {
274 return_ACPI_STATUS (AE_NO_MEMORY); 263 return_ACPI_STATUS(AE_NO_MEMORY);
275 } 264 }
276 265
277 /* 266 /*
@@ -283,40 +272,45 @@ acpi_ev_pci_config_region_setup (
283 * Get the PCI device and function numbers from the _ADR object 272 * Get the PCI device and function numbers from the _ADR object
284 * contained in the parent's scope. 273 * contained in the parent's scope.
285 */ 274 */
286 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);
287 278
288 /* 279 /*
289 * The default is zero, and since the allocation above zeroed 280 * The default is zero, and since the allocation above zeroed
290 * the data, just do nothing on failure. 281 * the data, just do nothing on failure.
291 */ 282 */
292 if (ACPI_SUCCESS (status)) { 283 if (ACPI_SUCCESS(status)) {
293 pci_id->device = ACPI_HIWORD (ACPI_LODWORD (pci_value)); 284 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
294 pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value)); 285 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
295 } 286 }
296 287
297 /* The PCI segment number comes from the _SEG method */ 288 /* The PCI segment number comes from the _SEG method */
298 289
299 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value); 290 status =
300 if (ACPI_SUCCESS (status)) { 291 acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node,
301 pci_id->segment = ACPI_LOWORD (pci_value); 292 &pci_value);
293 if (ACPI_SUCCESS(status)) {
294 pci_id->segment = ACPI_LOWORD(pci_value);
302 } 295 }
303 296
304 /* The PCI bus number comes from the _BBN method */ 297 /* The PCI bus number comes from the _BBN method */
305 298
306 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value); 299 status =
307 if (ACPI_SUCCESS (status)) { 300 acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node,
308 pci_id->bus = ACPI_LOWORD (pci_value); 301 &pci_value);
302 if (ACPI_SUCCESS(status)) {
303 pci_id->bus = ACPI_LOWORD(pci_value);
309 } 304 }
310 305
311 /* Complete this device's pci_id */ 306 /* Complete this device's pci_id */
312 307
313 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);
314 309
315 *region_context = pci_id; 310 *region_context = pci_id;
316 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
317} 312}
318 313
319
320/******************************************************************************* 314/*******************************************************************************
321 * 315 *
322 * FUNCTION: acpi_ev_pci_bar_region_setup 316 * FUNCTION: acpi_ev_pci_bar_region_setup
@@ -335,19 +329,15 @@ acpi_ev_pci_config_region_setup (
335 ******************************************************************************/ 329 ******************************************************************************/
336 330
337acpi_status 331acpi_status
338acpi_ev_pci_bar_region_setup ( 332acpi_ev_pci_bar_region_setup(acpi_handle handle,
339 acpi_handle handle, 333 u32 function,
340 u32 function, 334 void *handler_context, void **region_context)
341 void *handler_context,
342 void **region_context)
343{ 335{
344 ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup"); 336 ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup");
345
346 337
347 return_ACPI_STATUS (AE_OK); 338 return_ACPI_STATUS(AE_OK);
348} 339}
349 340
350
351/******************************************************************************* 341/*******************************************************************************
352 * 342 *
353 * FUNCTION: acpi_ev_cmos_region_setup 343 * FUNCTION: acpi_ev_cmos_region_setup
@@ -366,19 +356,15 @@ acpi_ev_pci_bar_region_setup (
366 ******************************************************************************/ 356 ******************************************************************************/
367 357
368acpi_status 358acpi_status
369acpi_ev_cmos_region_setup ( 359acpi_ev_cmos_region_setup(acpi_handle handle,
370 acpi_handle handle, 360 u32 function,
371 u32 function, 361 void *handler_context, void **region_context)
372 void *handler_context,
373 void **region_context)
374{ 362{
375 ACPI_FUNCTION_TRACE ("ev_cmos_region_setup"); 363 ACPI_FUNCTION_TRACE("ev_cmos_region_setup");
376
377 364
378 return_ACPI_STATUS (AE_OK); 365 return_ACPI_STATUS(AE_OK);
379} 366}
380 367
381
382/******************************************************************************* 368/*******************************************************************************
383 * 369 *
384 * FUNCTION: acpi_ev_default_region_setup 370 * FUNCTION: acpi_ev_default_region_setup
@@ -395,26 +381,21 @@ acpi_ev_cmos_region_setup (
395 ******************************************************************************/ 381 ******************************************************************************/
396 382
397acpi_status 383acpi_status
398acpi_ev_default_region_setup ( 384acpi_ev_default_region_setup(acpi_handle handle,
399 acpi_handle handle, 385 u32 function,
400 u32 function, 386 void *handler_context, void **region_context)
401 void *handler_context,
402 void **region_context)
403{ 387{
404 ACPI_FUNCTION_TRACE ("ev_default_region_setup"); 388 ACPI_FUNCTION_TRACE("ev_default_region_setup");
405
406 389
407 if (function == ACPI_REGION_DEACTIVATE) { 390 if (function == ACPI_REGION_DEACTIVATE) {
408 *region_context = NULL; 391 *region_context = NULL;
409 } 392 } else {
410 else {
411 *region_context = handler_context; 393 *region_context = handler_context;
412 } 394 }
413 395
414 return_ACPI_STATUS (AE_OK); 396 return_ACPI_STATUS(AE_OK);
415} 397}
416 398
417
418/******************************************************************************* 399/*******************************************************************************
419 * 400 *
420 * FUNCTION: acpi_ev_initialize_region 401 * FUNCTION: acpi_ev_initialize_region
@@ -438,37 +419,34 @@ acpi_ev_default_region_setup (
438 ******************************************************************************/ 419 ******************************************************************************/
439 420
440acpi_status 421acpi_status
441acpi_ev_initialize_region ( 422acpi_ev_initialize_region(union acpi_operand_object *region_obj,
442 union acpi_operand_object *region_obj, 423 u8 acpi_ns_locked)
443 u8 acpi_ns_locked)
444{ 424{
445 union acpi_operand_object *handler_obj; 425 union acpi_operand_object *handler_obj;
446 union acpi_operand_object *obj_desc; 426 union acpi_operand_object *obj_desc;
447 acpi_adr_space_type space_id; 427 acpi_adr_space_type space_id;
448 struct acpi_namespace_node *node; 428 struct acpi_namespace_node *node;
449 acpi_status status; 429 acpi_status status;
450 struct acpi_namespace_node *method_node; 430 struct acpi_namespace_node *method_node;
451 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; 431 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
452 union acpi_operand_object *region_obj2; 432 union acpi_operand_object *region_obj2;
453
454
455 ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked);
456 433
434 ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked);
457 435
458 if (!region_obj) { 436 if (!region_obj) {
459 return_ACPI_STATUS (AE_BAD_PARAMETER); 437 return_ACPI_STATUS(AE_BAD_PARAMETER);
460 } 438 }
461 439
462 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { 440 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
463 return_ACPI_STATUS (AE_OK); 441 return_ACPI_STATUS(AE_OK);
464 } 442 }
465 443
466 region_obj2 = acpi_ns_get_secondary_object (region_obj); 444 region_obj2 = acpi_ns_get_secondary_object(region_obj);
467 if (!region_obj2) { 445 if (!region_obj2) {
468 return_ACPI_STATUS (AE_NOT_EXIST); 446 return_ACPI_STATUS(AE_NOT_EXIST);
469 } 447 }
470 448
471 node = acpi_ns_get_parent_node (region_obj->region.node); 449 node = acpi_ns_get_parent_node(region_obj->region.node);
472 space_id = region_obj->region.space_id; 450 space_id = region_obj->region.space_id;
473 451
474 /* Setup defaults */ 452 /* Setup defaults */
@@ -480,9 +458,9 @@ acpi_ev_initialize_region (
480 458
481 /* Find any "_REG" method associated with this region definition */ 459 /* Find any "_REG" method associated with this region definition */
482 460
483 status = acpi_ns_search_node (*reg_name_ptr, node, 461 status = acpi_ns_search_node(*reg_name_ptr, node,
484 ACPI_TYPE_METHOD, &method_node); 462 ACPI_TYPE_METHOD, &method_node);
485 if (ACPI_SUCCESS (status)) { 463 if (ACPI_SUCCESS(status)) {
486 /* 464 /*
487 * 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
488 * definition. This will be executed when the handler is attached 466 * definition. This will be executed when the handler is attached
@@ -499,7 +477,7 @@ acpi_ev_initialize_region (
499 /* Check to see if a handler exists */ 477 /* Check to see if a handler exists */
500 478
501 handler_obj = NULL; 479 handler_obj = NULL;
502 obj_desc = acpi_ns_get_attached_object (node); 480 obj_desc = acpi_ns_get_attached_object(node);
503 if (obj_desc) { 481 if (obj_desc) {
504 /* Can only be a handler if the object exists */ 482 /* Can only be a handler if the object exists */
505 483
@@ -527,37 +505,50 @@ acpi_ev_initialize_region (
527 while (handler_obj) { 505 while (handler_obj) {
528 /* Is this handler of the correct type? */ 506 /* Is this handler of the correct type? */
529 507
530 if (handler_obj->address_space.space_id == space_id) { 508 if (handler_obj->address_space.space_id ==
509 space_id) {
531 /* Found correct handler */ 510 /* Found correct handler */
532 511
533 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 512 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
534 "Found handler %p for region %p in obj %p\n", 513 "Found handler %p for region %p in obj %p\n",
535 handler_obj, region_obj, obj_desc)); 514 handler_obj,
515 region_obj,
516 obj_desc));
536 517
537 status = acpi_ev_attach_region (handler_obj, region_obj, 518 status =
538 acpi_ns_locked); 519 acpi_ev_attach_region(handler_obj,
520 region_obj,
521 acpi_ns_locked);
539 522
540 /* 523 /*
541 * 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
542 * method 525 * method
543 */ 526 */
544 if (acpi_ns_locked) { 527 if (acpi_ns_locked) {
545 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 528 status =
546 if (ACPI_FAILURE (status)) { 529 acpi_ut_release_mutex
547 return_ACPI_STATUS (status); 530 (ACPI_MTX_NAMESPACE);
531 if (ACPI_FAILURE(status)) {
532 return_ACPI_STATUS
533 (status);
548 } 534 }
549 } 535 }
550 536
551 status = acpi_ev_execute_reg_method (region_obj, 1); 537 status =
538 acpi_ev_execute_reg_method
539 (region_obj, 1);
552 540
553 if (acpi_ns_locked) { 541 if (acpi_ns_locked) {
554 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 542 status =
555 if (ACPI_FAILURE (status)) { 543 acpi_ut_acquire_mutex
556 return_ACPI_STATUS (status); 544 (ACPI_MTX_NAMESPACE);
545 if (ACPI_FAILURE(status)) {
546 return_ACPI_STATUS
547 (status);
557 } 548 }
558 } 549 }
559 550
560 return_ACPI_STATUS (AE_OK); 551 return_ACPI_STATUS(AE_OK);
561 } 552 }
562 553
563 /* Try next handler in the list */ 554 /* Try next handler in the list */
@@ -570,15 +561,15 @@ acpi_ev_initialize_region (
570 * This node does not have the handler we need; 561 * This node does not have the handler we need;
571 * Pop up one level 562 * Pop up one level
572 */ 563 */
573 node = acpi_ns_get_parent_node (node); 564 node = acpi_ns_get_parent_node(node);
574 } 565 }
575 566
576 /* If we get here, there is no handler for this region */ 567 /* If we get here, there is no handler for this region */
577 568
578 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 569 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
579 "No handler for region_type %s(%X) (region_obj %p)\n", 570 "No handler for region_type %s(%X) (region_obj %p)\n",
580 acpi_ut_get_region_name (space_id), space_id, region_obj)); 571 acpi_ut_get_region_name(space_id), space_id,
572 region_obj));
581 573
582 return_ACPI_STATUS (AE_NOT_EXIST); 574 return_ACPI_STATUS(AE_NOT_EXIST);
583} 575}
584
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 4c1c25e316a8..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,36 +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 u32 flags; 565 u32 flags;
595
596
597 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
598 566
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
599 568
600 /* Parameter validation */ 569 /* Parameter validation */
601 570
602 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 571 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
603 return_ACPI_STATUS (AE_BAD_PARAMETER); 572 return_ACPI_STATUS(AE_BAD_PARAMETER);
604 } 573 }
605 574
606 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
607 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
608 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
609 } 578 }
610 579
611 /* Ensure that we have a valid GPE number */ 580 /* Ensure that we have a valid GPE number */
612 581
613 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);
614 if (!gpe_event_info) { 583 if (!gpe_event_info) {
615 status = AE_BAD_PARAMETER; 584 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit; 585 goto unlock_and_exit;
@@ -618,49 +587,49 @@ acpi_install_gpe_handler (
618 587
619 /* Make sure that there isn't a handler there already */ 588 /* Make sure that there isn't a handler there already */
620 589
621 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) {
622 status = AE_ALREADY_EXISTS; 592 status = AE_ALREADY_EXISTS;
623 goto unlock_and_exit; 593 goto unlock_and_exit;
624 } 594 }
625 595
626 /* Allocate and init handler object */ 596 /* Allocate and init handler object */
627 597
628 handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info)); 598 handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info));
629 if (!handler) { 599 if (!handler) {
630 status = AE_NO_MEMORY; 600 status = AE_NO_MEMORY;
631 goto unlock_and_exit; 601 goto unlock_and_exit;
632 } 602 }
633 603
634 handler->address = address; 604 handler->address = address;
635 handler->context = context; 605 handler->context = context;
636 handler->method_node = gpe_event_info->dispatch.method_node; 606 handler->method_node = gpe_event_info->dispatch.method_node;
637 607
638 /* Disable the GPE before installing the handler */ 608 /* Disable the GPE before installing the handler */
639 609
640 status = acpi_ev_disable_gpe (gpe_event_info); 610 status = acpi_ev_disable_gpe(gpe_event_info);
641 if (ACPI_FAILURE (status)) { 611 if (ACPI_FAILURE(status)) {
642 goto unlock_and_exit; 612 goto unlock_and_exit;
643 } 613 }
644 614
645 /* Install the handler */ 615 /* Install the handler */
646 616
647 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 617 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
648 gpe_event_info->dispatch.handler = handler; 618 gpe_event_info->dispatch.handler = handler;
649 619
650 /* Setup up dispatch flags to indicate handler (vs. method) */ 620 /* Setup up dispatch flags to indicate handler (vs. method) */
651 621
652 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 */
653 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 623 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
654 624
655 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 625 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
656
657 626
658unlock_and_exit: 627 unlock_and_exit:
659 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 628 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
660 return_ACPI_STATUS (status); 629 return_ACPI_STATUS(status);
661} 630}
662EXPORT_SYMBOL(acpi_install_gpe_handler);
663 631
632EXPORT_SYMBOL(acpi_install_gpe_handler);
664 633
665/******************************************************************************* 634/*******************************************************************************
666 * 635 *
@@ -678,34 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
678 ******************************************************************************/ 647 ******************************************************************************/
679 648
680acpi_status 649acpi_status
681acpi_remove_gpe_handler ( 650acpi_remove_gpe_handler(acpi_handle gpe_device,
682 acpi_handle gpe_device, 651 u32 gpe_number, acpi_event_handler address)
683 u32 gpe_number,
684 acpi_event_handler address)
685{ 652{
686 struct acpi_gpe_event_info *gpe_event_info; 653 struct acpi_gpe_event_info *gpe_event_info;
687 struct acpi_handler_info *handler; 654 struct acpi_handler_info *handler;
688 acpi_status status; 655 acpi_status status;
689 u32 flags; 656 u32 flags;
690
691
692 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
693 657
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
694 659
695 /* Parameter validation */ 660 /* Parameter validation */
696 661
697 if (!address) { 662 if (!address) {
698 return_ACPI_STATUS (AE_BAD_PARAMETER); 663 return_ACPI_STATUS(AE_BAD_PARAMETER);
699 } 664 }
700 665
701 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
702 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
703 return_ACPI_STATUS (status); 668 return_ACPI_STATUS(status);
704 } 669 }
705 670
706 /* Ensure that we have a valid GPE number */ 671 /* Ensure that we have a valid GPE number */
707 672
708 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);
709 if (!gpe_event_info) { 674 if (!gpe_event_info) {
710 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
711 goto unlock_and_exit; 676 goto unlock_and_exit;
@@ -713,7 +678,8 @@ acpi_remove_gpe_handler (
713 678
714 /* Make sure that a handler is indeed installed */ 679 /* Make sure that a handler is indeed installed */
715 680
716 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) {
717 status = AE_NOT_EXIST; 683 status = AE_NOT_EXIST;
718 goto unlock_and_exit; 684 goto unlock_and_exit;
719 } 685 }
@@ -727,45 +693,44 @@ acpi_remove_gpe_handler (
727 693
728 /* Disable the GPE before removing the handler */ 694 /* Disable the GPE before removing the handler */
729 695
730 status = acpi_ev_disable_gpe (gpe_event_info); 696 status = acpi_ev_disable_gpe(gpe_event_info);
731 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
732 goto unlock_and_exit; 698 goto unlock_and_exit;
733 } 699 }
734 700
735 /* Make sure all deferred tasks are completed */ 701 /* Make sure all deferred tasks are completed */
736 702
737 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 703 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
738 acpi_os_wait_events_complete(NULL); 704 acpi_os_wait_events_complete(NULL);
739 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 705 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
740 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
741 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
742 } 708 }
743 709
744 /* Remove the handler */ 710 /* Remove the handler */
745 711
746 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 712 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
747 handler = gpe_event_info->dispatch.handler; 713 handler = gpe_event_info->dispatch.handler;
748 714
749 /* Restore Method node (if any), set dispatch flags */ 715 /* Restore Method node (if any), set dispatch flags */
750 716
751 gpe_event_info->dispatch.method_node = handler->method_node; 717 gpe_event_info->dispatch.method_node = handler->method_node;
752 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ 718 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
753 if (handler->method_node) { 719 if (handler->method_node) {
754 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 720 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
755 } 721 }
756 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 722 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
757 723
758 /* Now we can free the handler object */ 724 /* Now we can free the handler object */
759 725
760 ACPI_MEM_FREE (handler); 726 ACPI_MEM_FREE(handler);
761 727
762 728 unlock_and_exit:
763unlock_and_exit: 729 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
764 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 730 return_ACPI_STATUS(status);
765 return_ACPI_STATUS (status);
766} 731}
767EXPORT_SYMBOL(acpi_remove_gpe_handler);
768 732
733EXPORT_SYMBOL(acpi_remove_gpe_handler);
769 734
770/******************************************************************************* 735/*******************************************************************************
771 * 736 *
@@ -781,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
781 * 746 *
782 ******************************************************************************/ 747 ******************************************************************************/
783 748
784acpi_status 749acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
785acpi_acquire_global_lock (
786 u16 timeout,
787 u32 *handle)
788{ 750{
789 acpi_status status; 751 acpi_status status;
790
791 752
792 if (!handle) { 753 if (!handle) {
793 return (AE_BAD_PARAMETER); 754 return (AE_BAD_PARAMETER);
794 } 755 }
795 756
796 status = acpi_ex_enter_interpreter (); 757 status = acpi_ex_enter_interpreter();
797 if (ACPI_FAILURE (status)) { 758 if (ACPI_FAILURE(status)) {
798 return (status); 759 return (status);
799 } 760 }
800 761
801 status = acpi_ev_acquire_global_lock (timeout); 762 status = acpi_ev_acquire_global_lock(timeout);
802 acpi_ex_exit_interpreter (); 763 acpi_ex_exit_interpreter();
803 764
804 if (ACPI_SUCCESS (status)) { 765 if (ACPI_SUCCESS(status)) {
805 acpi_gbl_global_lock_handle++; 766 acpi_gbl_global_lock_handle++;
806 *handle = acpi_gbl_global_lock_handle; 767 *handle = acpi_gbl_global_lock_handle;
807 } 768 }
808 769
809 return (status); 770 return (status);
810} 771}
811EXPORT_SYMBOL(acpi_acquire_global_lock);
812 772
773EXPORT_SYMBOL(acpi_acquire_global_lock);
813 774
814/******************************************************************************* 775/*******************************************************************************
815 * 776 *
@@ -823,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
823 * 784 *
824 ******************************************************************************/ 785 ******************************************************************************/
825 786
826acpi_status 787acpi_status acpi_release_global_lock(u32 handle)
827acpi_release_global_lock (
828 u32 handle)
829{ 788{
830 acpi_status status; 789 acpi_status status;
831
832 790
833 if (handle != acpi_gbl_global_lock_handle) { 791 if (handle != acpi_gbl_global_lock_handle) {
834 return (AE_NOT_ACQUIRED); 792 return (AE_NOT_ACQUIRED);
835 } 793 }
836 794
837 status = acpi_ev_release_global_lock (); 795 status = acpi_ev_release_global_lock();
838 return (status); 796 return (status);
839} 797}
840EXPORT_SYMBOL(acpi_release_global_lock);
841 798
799EXPORT_SYMBOL(acpi_release_global_lock);
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index c5f74d7b64d8..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 *
@@ -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_number)
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_number, &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 d11e9ec827f1..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,24 +74,21 @@ 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
102 /* Init the table handle */ 94 /* Init the table handle */
@@ -106,45 +98,43 @@ acpi_ex_add_table (
106 98
107 /* Install the new table into the local data structures */ 99 /* Install the new table into the local data structures */
108 100
109 ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); 101 ACPI_MEMSET(&table_info, 0, sizeof(struct acpi_table_desc));
110 102
111 table_info.type = ACPI_TABLE_SSDT; 103 table_info.type = ACPI_TABLE_SSDT;
112 table_info.pointer = table; 104 table_info.pointer = table;
113 table_info.length = (acpi_size) table->length; 105 table_info.length = (acpi_size) table->length;
114 table_info.allocation = ACPI_MEM_ALLOCATED; 106 table_info.allocation = ACPI_MEM_ALLOCATED;
115 107
116 status = acpi_tb_install_table (&table_info); 108 status = acpi_tb_install_table(&table_info);
117 obj_desc->reference.object = table_info.installed_desc; 109 obj_desc->reference.object = table_info.installed_desc;
118 110
119 if (ACPI_FAILURE (status)) { 111 if (ACPI_FAILURE(status)) {
120 if (status == AE_ALREADY_EXISTS) { 112 if (status == AE_ALREADY_EXISTS) {
121 /* Table already exists, just return the handle */ 113 /* Table already exists, just return the handle */
122 114
123 return_ACPI_STATUS (AE_OK); 115 return_ACPI_STATUS(AE_OK);
124 } 116 }
125 goto cleanup; 117 goto cleanup;
126 } 118 }
127 119
128 /* Add the table to the namespace */ 120 /* Add the table to the namespace */
129 121
130 status = acpi_ns_load_table (table_info.installed_desc, parent_node); 122 status = acpi_ns_load_table(table_info.installed_desc, parent_node);
131 if (ACPI_FAILURE (status)) { 123 if (ACPI_FAILURE(status)) {
132 /* Uninstall table on error */ 124 /* Uninstall table on error */
133 125
134 (void) acpi_tb_uninstall_table (table_info.installed_desc); 126 (void)acpi_tb_uninstall_table(table_info.installed_desc);
135 goto cleanup; 127 goto cleanup;
136 } 128 }
137 129
138 return_ACPI_STATUS (AE_OK); 130 return_ACPI_STATUS(AE_OK);
139
140 131
141cleanup: 132 cleanup:
142 acpi_ut_remove_reference (obj_desc); 133 acpi_ut_remove_reference(obj_desc);
143 *ddb_handle = NULL; 134 *ddb_handle = NULL;
144 return_ACPI_STATUS (status); 135 return_ACPI_STATUS(status);
145} 136}
146 137
147
148/******************************************************************************* 138/*******************************************************************************
149 * 139 *
150 * FUNCTION: acpi_ex_load_table_op 140 * FUNCTION: acpi_ex_load_table_op
@@ -159,56 +149,53 @@ cleanup:
159 ******************************************************************************/ 149 ******************************************************************************/
160 150
161acpi_status 151acpi_status
162acpi_ex_load_table_op ( 152acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
163 struct acpi_walk_state *walk_state, 153 union acpi_operand_object **return_desc)
164 union acpi_operand_object **return_desc)
165{ 154{
166 acpi_status status; 155 acpi_status status;
167 union acpi_operand_object **operand = &walk_state->operands[0]; 156 union acpi_operand_object **operand = &walk_state->operands[0];
168 struct acpi_table_header *table; 157 struct acpi_table_header *table;
169 struct acpi_namespace_node *parent_node; 158 struct acpi_namespace_node *parent_node;
170 struct acpi_namespace_node *start_node; 159 struct acpi_namespace_node *start_node;
171 struct acpi_namespace_node *parameter_node = NULL; 160 struct acpi_namespace_node *parameter_node = NULL;
172 union acpi_operand_object *ddb_handle; 161 union acpi_operand_object *ddb_handle;
173
174
175 ACPI_FUNCTION_TRACE ("ex_load_table_op");
176 162
163 ACPI_FUNCTION_TRACE("ex_load_table_op");
177 164
178#if 0 165#if 0
179 /* 166 /*
180 * 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
181 * is already loaded. 168 * is already loaded.
182 */ 169 */
183 status = acpi_tb_match_signature (operand[0]->string.pointer, NULL); 170 status = acpi_tb_match_signature(operand[0]->string.pointer, NULL);
184 if (status == AE_OK) { 171 if (status == AE_OK) {
185 /* Signature matched -- don't allow override */ 172 /* Signature matched -- don't allow override */
186 173
187 return_ACPI_STATUS (AE_ALREADY_EXISTS); 174 return_ACPI_STATUS(AE_ALREADY_EXISTS);
188 } 175 }
189#endif 176#endif
190 177
191 /* Find the ACPI table */ 178 /* Find the ACPI table */
192 179
193 status = acpi_tb_find_table (operand[0]->string.pointer, 180 status = acpi_tb_find_table(operand[0]->string.pointer,
194 operand[1]->string.pointer, 181 operand[1]->string.pointer,
195 operand[2]->string.pointer, &table); 182 operand[2]->string.pointer, &table);
196 if (ACPI_FAILURE (status)) { 183 if (ACPI_FAILURE(status)) {
197 if (status != AE_NOT_FOUND) { 184 if (status != AE_NOT_FOUND) {
198 return_ACPI_STATUS (status); 185 return_ACPI_STATUS(status);
199 } 186 }
200 187
201 /* Table not found, return an Integer=0 and AE_OK */ 188 /* Table not found, return an Integer=0 and AE_OK */
202 189
203 ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 190 ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
204 if (!ddb_handle) { 191 if (!ddb_handle) {
205 return_ACPI_STATUS (AE_NO_MEMORY); 192 return_ACPI_STATUS(AE_NO_MEMORY);
206 } 193 }
207 194
208 ddb_handle->integer.value = 0; 195 ddb_handle->integer.value = 0;
209 *return_desc = ddb_handle; 196 *return_desc = ddb_handle;
210 197
211 return_ACPI_STATUS (AE_OK); 198 return_ACPI_STATUS(AE_OK);
212 } 199 }
213 200
214 /* Default nodes */ 201 /* Default nodes */
@@ -223,10 +210,12 @@ acpi_ex_load_table_op (
223 * 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
224 * location within the namespace where the table will be loaded. 211 * location within the namespace where the table will be loaded.
225 */ 212 */
226 status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node, 213 status =
227 ACPI_NS_SEARCH_PARENT, &parent_node); 214 acpi_ns_get_node_by_path(operand[3]->string.pointer,
228 if (ACPI_FAILURE (status)) { 215 start_node, ACPI_NS_SEARCH_PARENT,
229 return_ACPI_STATUS (status); 216 &parent_node);
217 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS(status);
230 } 219 }
231 } 220 }
232 221
@@ -234,7 +223,7 @@ acpi_ex_load_table_op (
234 223
235 if (operand[4]->string.length > 0) { 224 if (operand[4]->string.length > 0) {
236 if ((operand[4]->string.pointer[0] != '\\') && 225 if ((operand[4]->string.pointer[0] != '\\') &&
237 (operand[4]->string.pointer[0] != '^')) { 226 (operand[4]->string.pointer[0] != '^')) {
238 /* 227 /*
239 * 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
240 * 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)
@@ -244,18 +233,20 @@ acpi_ex_load_table_op (
244 233
245 /* Find the node referenced by the parameter_path_string */ 234 /* Find the node referenced by the parameter_path_string */
246 235
247 status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node, 236 status =
248 ACPI_NS_SEARCH_PARENT, &parameter_node); 237 acpi_ns_get_node_by_path(operand[4]->string.pointer,
249 if (ACPI_FAILURE (status)) { 238 start_node, ACPI_NS_SEARCH_PARENT,
250 return_ACPI_STATUS (status); 239 &parameter_node);
240 if (ACPI_FAILURE(status)) {
241 return_ACPI_STATUS(status);
251 } 242 }
252 } 243 }
253 244
254 /* Load the table into the namespace */ 245 /* Load the table into the namespace */
255 246
256 status = acpi_ex_add_table (table, parent_node, &ddb_handle); 247 status = acpi_ex_add_table(table, parent_node, &ddb_handle);
257 if (ACPI_FAILURE (status)) { 248 if (ACPI_FAILURE(status)) {
258 return_ACPI_STATUS (status); 249 return_ACPI_STATUS(status);
259 } 250 }
260 251
261 /* Parameter Data (optional) */ 252 /* Parameter Data (optional) */
@@ -263,20 +254,20 @@ acpi_ex_load_table_op (
263 if (parameter_node) { 254 if (parameter_node) {
264 /* Store the parameter data into the optional parameter object */ 255 /* Store the parameter data into the optional parameter object */
265 256
266 status = acpi_ex_store (operand[5], 257 status = acpi_ex_store(operand[5],
267 ACPI_CAST_PTR (union acpi_operand_object, parameter_node), 258 ACPI_CAST_PTR(union acpi_operand_object,
268 walk_state); 259 parameter_node),
269 if (ACPI_FAILURE (status)) { 260 walk_state);
270 (void) acpi_ex_unload_table (ddb_handle); 261 if (ACPI_FAILURE(status)) {
271 return_ACPI_STATUS (status); 262 (void)acpi_ex_unload_table(ddb_handle);
263 return_ACPI_STATUS(status);
272 } 264 }
273 } 265 }
274 266
275 *return_desc = ddb_handle; 267 *return_desc = ddb_handle;
276 return_ACPI_STATUS (status); 268 return_ACPI_STATUS(status);
277} 269}
278 270
279
280/******************************************************************************* 271/*******************************************************************************
281 * 272 *
282 * FUNCTION: acpi_ex_load_op 273 * FUNCTION: acpi_ex_load_op
@@ -293,38 +284,37 @@ acpi_ex_load_table_op (
293 ******************************************************************************/ 284 ******************************************************************************/
294 285
295acpi_status 286acpi_status
296acpi_ex_load_op ( 287acpi_ex_load_op(union acpi_operand_object *obj_desc,
297 union acpi_operand_object *obj_desc, 288 union acpi_operand_object *target,
298 union acpi_operand_object *target, 289 struct acpi_walk_state *walk_state)
299 struct acpi_walk_state *walk_state)
300{ 290{
301 acpi_status status; 291 acpi_status status;
302 union acpi_operand_object *ddb_handle; 292 union acpi_operand_object *ddb_handle;
303 union acpi_operand_object *buffer_desc = NULL; 293 union acpi_operand_object *buffer_desc = NULL;
304 struct acpi_table_header *table_ptr = NULL; 294 struct acpi_table_header *table_ptr = NULL;
305 acpi_physical_address address; 295 acpi_physical_address address;
306 struct acpi_table_header table_header; 296 struct acpi_table_header table_header;
307 u32 i; 297 u32 i;
308
309 ACPI_FUNCTION_TRACE ("ex_load_op");
310 298
299 ACPI_FUNCTION_TRACE("ex_load_op");
311 300
312 /* Object can be either an op_region or a Field */ 301 /* Object can be either an op_region or a Field */
313 302
314 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 303 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
315 case ACPI_TYPE_REGION: 304 case ACPI_TYPE_REGION:
316 305
317 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",
318 obj_desc, acpi_ut_get_object_type_name (obj_desc))); 307 obj_desc,
308 acpi_ut_get_object_type_name(obj_desc)));
319 309
320 /* 310 /*
321 * If the Region Address and Length have not been previously evaluated, 311 * If the Region Address and Length have not been previously evaluated,
322 * evaluate them now and save the results. 312 * evaluate them now and save the results.
323 */ 313 */
324 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 314 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
325 status = acpi_ds_get_region_arguments (obj_desc); 315 status = acpi_ds_get_region_arguments(obj_desc);
326 if (ACPI_FAILURE (status)) { 316 if (ACPI_FAILURE(status)) {
327 return_ACPI_STATUS (status); 317 return_ACPI_STATUS(status);
328 } 318 }
329 } 319 }
330 320
@@ -336,121 +326,127 @@ acpi_ex_load_op (
336 326
337 table_header.length = 0; 327 table_header.length = 0;
338 for (i = 0; i < 8; i++) { 328 for (i = 0; i < 8; i++) {
339 status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, 329 status =
340 (acpi_physical_address) (i + address), 8, 330 acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
341 ((u8 *) &table_header) + i); 331 (acpi_physical_address)
342 if (ACPI_FAILURE (status)) { 332 (i + address), 8,
343 return_ACPI_STATUS (status); 333 ((u8 *) &
334 table_header) + i);
335 if (ACPI_FAILURE(status)) {
336 return_ACPI_STATUS(status);
344 } 337 }
345 } 338 }
346 339
347 /* Sanity check the table length */ 340 /* Sanity check the table length */
348 341
349 if (table_header.length < sizeof (struct acpi_table_header)) { 342 if (table_header.length < sizeof(struct acpi_table_header)) {
350 return_ACPI_STATUS (AE_BAD_HEADER); 343 return_ACPI_STATUS(AE_BAD_HEADER);
351 } 344 }
352 345
353 /* Allocate a buffer for the entire table */ 346 /* Allocate a buffer for the entire table */
354 347
355 table_ptr = ACPI_MEM_ALLOCATE (table_header.length); 348 table_ptr = ACPI_MEM_ALLOCATE(table_header.length);
356 if (!table_ptr) { 349 if (!table_ptr) {
357 return_ACPI_STATUS (AE_NO_MEMORY); 350 return_ACPI_STATUS(AE_NO_MEMORY);
358 } 351 }
359 352
360 /* Get the entire table from the op region */ 353 /* Get the entire table from the op region */
361 354
362 for (i = 0; i < table_header.length; i++) { 355 for (i = 0; i < table_header.length; i++) {
363 status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, 356 status =
364 (acpi_physical_address) (i + address), 8, 357 acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
365 ((u8 *) table_ptr + i)); 358 (acpi_physical_address)
366 if (ACPI_FAILURE (status)) { 359 (i + address), 8,
360 ((u8 *) table_ptr +
361 i));
362 if (ACPI_FAILURE(status)) {
367 goto cleanup; 363 goto cleanup;
368 } 364 }
369 } 365 }
370 break; 366 break;
371 367
372
373 case ACPI_TYPE_LOCAL_REGION_FIELD: 368 case ACPI_TYPE_LOCAL_REGION_FIELD:
374 case ACPI_TYPE_LOCAL_BANK_FIELD: 369 case ACPI_TYPE_LOCAL_BANK_FIELD:
375 case ACPI_TYPE_LOCAL_INDEX_FIELD: 370 case ACPI_TYPE_LOCAL_INDEX_FIELD:
376 371
377 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",
378 obj_desc, acpi_ut_get_object_type_name (obj_desc))); 373 obj_desc,
374 acpi_ut_get_object_type_name(obj_desc)));
379 375
380 /* 376 /*
381 * 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.
382 * Read the entire field and thus the entire table. Buffer is 378 * Read the entire field and thus the entire table. Buffer is
383 * allocated during the read. 379 * allocated during the read.
384 */ 380 */
385 status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); 381 status =
386 if (ACPI_FAILURE (status)) { 382 acpi_ex_read_data_from_field(walk_state, obj_desc,
387 return_ACPI_STATUS (status); 383 &buffer_desc);
384 if (ACPI_FAILURE(status)) {
385 return_ACPI_STATUS(status);
388 } 386 }
389 387
390 table_ptr = ACPI_CAST_PTR (struct acpi_table_header, 388 table_ptr = ACPI_CAST_PTR(struct acpi_table_header,
391 buffer_desc->buffer.pointer); 389 buffer_desc->buffer.pointer);
392 390
393 /* All done with the buffer_desc, delete it */ 391 /* All done with the buffer_desc, delete it */
394 392
395 buffer_desc->buffer.pointer = NULL; 393 buffer_desc->buffer.pointer = NULL;
396 acpi_ut_remove_reference (buffer_desc); 394 acpi_ut_remove_reference(buffer_desc);
397 395
398 /* Sanity check the table length */ 396 /* Sanity check the table length */
399 397
400 if (table_ptr->length < sizeof (struct acpi_table_header)) { 398 if (table_ptr->length < sizeof(struct acpi_table_header)) {
401 status = AE_BAD_HEADER; 399 status = AE_BAD_HEADER;
402 goto cleanup; 400 goto cleanup;
403 } 401 }
404 break; 402 break;
405 403
406
407 default: 404 default:
408 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 405 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
409 } 406 }
410 407
411 /* The table must be either an SSDT or a PSDT */ 408 /* The table must be either an SSDT or a PSDT */
412 409
413 if ((!ACPI_STRNCMP (table_ptr->signature, 410 if ((!ACPI_STRNCMP(table_ptr->signature,
414 acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, 411 acpi_gbl_table_data[ACPI_TABLE_PSDT].signature,
415 acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && 412 acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) &&
416 (!ACPI_STRNCMP (table_ptr->signature, 413 (!ACPI_STRNCMP(table_ptr->signature,
417 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, 414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
418 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { 415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
419 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
420 "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",
421 table_ptr->signature)); 418 table_ptr->signature));
422 status = AE_BAD_SIGNATURE; 419 status = AE_BAD_SIGNATURE;
423 goto cleanup; 420 goto cleanup;
424 } 421 }
425 422
426 /* Install the new table into the local data structures */ 423 /* Install the new table into the local data structures */
427 424
428 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);
429 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
430 /* On error, table_ptr was deallocated above */ 427 /* On error, table_ptr was deallocated above */
431 428
432 return_ACPI_STATUS (status); 429 return_ACPI_STATUS(status);
433 } 430 }
434 431
435 /* Store the ddb_handle into the Target operand */ 432 /* Store the ddb_handle into the Target operand */
436 433
437 status = acpi_ex_store (ddb_handle, target, walk_state); 434 status = acpi_ex_store(ddb_handle, target, walk_state);
438 if (ACPI_FAILURE (status)) { 435 if (ACPI_FAILURE(status)) {
439 (void) acpi_ex_unload_table (ddb_handle); 436 (void)acpi_ex_unload_table(ddb_handle);
440 437
441 /* table_ptr was deallocated above */ 438 /* table_ptr was deallocated above */
442 439
443 return_ACPI_STATUS (status); 440 return_ACPI_STATUS(status);
444 } 441 }
445 442
446cleanup: 443 cleanup:
447 if (ACPI_FAILURE (status)) { 444 if (ACPI_FAILURE(status)) {
448 ACPI_MEM_FREE (table_ptr); 445 ACPI_MEM_FREE(table_ptr);
449 } 446 }
450 return_ACPI_STATUS (status); 447 return_ACPI_STATUS(status);
451} 448}
452 449
453
454/******************************************************************************* 450/*******************************************************************************
455 * 451 *
456 * FUNCTION: acpi_ex_unload_table 452 * FUNCTION: acpi_ex_unload_table
@@ -463,17 +459,13 @@ cleanup:
463 * 459 *
464 ******************************************************************************/ 460 ******************************************************************************/
465 461
466acpi_status 462acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
467acpi_ex_unload_table (
468 union acpi_operand_object *ddb_handle)
469{ 463{
470 acpi_status status = AE_OK; 464 acpi_status status = AE_OK;
471 union acpi_operand_object *table_desc = ddb_handle; 465 union acpi_operand_object *table_desc = ddb_handle;
472 struct acpi_table_desc *table_info; 466 struct acpi_table_desc *table_info;
473
474
475 ACPI_FUNCTION_TRACE ("ex_unload_table");
476 467
468 ACPI_FUNCTION_TRACE("ex_unload_table");
477 469
478 /* 470 /*
479 * Validate the handle 471 * Validate the handle
@@ -482,29 +474,28 @@ acpi_ex_unload_table (
482 * validated here. 474 * validated here.
483 */ 475 */
484 if ((!ddb_handle) || 476 if ((!ddb_handle) ||
485 (ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) || 477 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
486 (ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { 478 (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
487 return_ACPI_STATUS (AE_BAD_PARAMETER); 479 return_ACPI_STATUS(AE_BAD_PARAMETER);
488 } 480 }
489 481
490 /* Get the actual table descriptor from the ddb_handle */ 482 /* Get the actual table descriptor from the ddb_handle */
491 483
492 table_info = (struct acpi_table_desc *) table_desc->reference.object; 484 table_info = (struct acpi_table_desc *)table_desc->reference.object;
493 485
494 /* 486 /*
495 * Delete the entire namespace under this table Node 487 * Delete the entire namespace under this table Node
496 * (Offset contains the table_id) 488 * (Offset contains the table_id)
497 */ 489 */
498 acpi_ns_delete_namespace_by_owner (table_info->owner_id); 490 acpi_ns_delete_namespace_by_owner(table_info->owner_id);
499 acpi_ut_release_owner_id (&table_info->owner_id); 491 acpi_ut_release_owner_id(&table_info->owner_id);
500 492
501 /* Delete the table itself */ 493 /* Delete the table itself */
502 494
503 (void) acpi_tb_uninstall_table (table_info->installed_desc); 495 (void)acpi_tb_uninstall_table(table_info->installed_desc);
504 496
505 /* Delete the table descriptor (ddb_handle) */ 497 /* Delete the table descriptor (ddb_handle) */
506 498
507 acpi_ut_remove_reference (table_desc); 499 acpi_ut_remove_reference(table_desc);
508 return_ACPI_STATUS (status); 500 return_ACPI_STATUS(status);
509} 501}
510
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 21331625e66e..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_native_uint) 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 4f98dceed39a..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,46 +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
54/* 53/*
55 * The following routines are used for debug output only 54 * The following routines are used for debug output only
56 */ 55 */
57#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
58
59/* Local prototypes */ 57/* Local prototypes */
60
61#ifdef ACPI_FUTURE_USAGE 58#ifdef ACPI_FUTURE_USAGE
62static void 59static void acpi_ex_out_string(char *title, char *value);
63acpi_ex_out_string (
64 char *title,
65 char *value);
66 60
67static void 61static void acpi_ex_out_pointer(char *title, void *value);
68acpi_ex_out_pointer (
69 char *title,
70 void *value);
71 62
72static void 63static void acpi_ex_out_integer(char *title, u32 value);
73acpi_ex_out_integer (
74 char *title,
75 u32 value);
76 64
77static void 65static void acpi_ex_out_address(char *title, acpi_physical_address value);
78acpi_ex_out_address (
79 char *title,
80 acpi_physical_address value);
81 66
82static void 67static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc);
83acpi_ex_dump_reference (
84 union acpi_operand_object *obj_desc);
85 68
86static void 69static void
87acpi_ex_dump_package ( 70acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index);
88 union acpi_operand_object *obj_desc, 71#endif /* ACPI_FUTURE_USAGE */
89 u32 level,
90 u32 index);
91#endif /* ACPI_FUTURE_USAGE */
92 72
93/******************************************************************************* 73/*******************************************************************************
94 * 74 *
@@ -103,143 +83,140 @@ acpi_ex_dump_package (
103 * 83 *
104 ******************************************************************************/ 84 ******************************************************************************/
105 85
106void 86void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
107acpi_ex_dump_operand (
108 union acpi_operand_object *obj_desc,
109 u32 depth)
110{ 87{
111 u32 length; 88 u32 length;
112 u32 index; 89 u32 index;
113
114
115 ACPI_FUNCTION_NAME ("ex_dump_operand")
116 90
91 ACPI_FUNCTION_NAME("ex_dump_operand")
117 92
118 if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { 93 if (!
94 ((ACPI_LV_EXEC & acpi_dbg_level)
95 && (_COMPONENT & acpi_dbg_layer))) {
119 return; 96 return;
120 } 97 }
121 98
122 if (!obj_desc) { 99 if (!obj_desc) {
123 /* This could be a null element of a package */ 100 /* This could be a null element of a package */
124 101
125 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); 102 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
126 return; 103 return;
127 } 104 }
128 105
129 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 106 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
130 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc)); 107 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
131 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); 108 obj_desc));
109 ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
132 return; 110 return;
133 } 111 }
134 112
135 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 113 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
136 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 114 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
137 "%p is not a node or operand object: [%s]\n", 115 "%p is not a node or operand object: [%s]\n",
138 obj_desc, acpi_ut_get_descriptor_name (obj_desc))); 116 obj_desc,
139 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));
140 return; 119 return;
141 } 120 }
142 121
143 /* obj_desc is a valid object */ 122 /* obj_desc is a valid object */
144 123
145 if (depth > 0) { 124 if (depth > 0) {
146 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", 125 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ",
147 depth, " ", depth, obj_desc)); 126 depth, " ", depth, obj_desc));
148 } 127 } else {
149 else { 128 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc));
150 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
151 } 129 }
152 130
153 /* Decode object type */ 131 /* Decode object type */
154 132
155 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 133 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
156 case ACPI_TYPE_LOCAL_REFERENCE: 134 case ACPI_TYPE_LOCAL_REFERENCE:
157 135
158 switch (obj_desc->reference.opcode) { 136 switch (obj_desc->reference.opcode) {
159 case AML_DEBUG_OP: 137 case AML_DEBUG_OP:
160 138
161 acpi_os_printf ("Reference: Debug\n"); 139 acpi_os_printf("Reference: Debug\n");
162 break; 140 break;
163 141
164
165 case AML_NAME_OP: 142 case AML_NAME_OP:
166 143
167 ACPI_DUMP_PATHNAME (obj_desc->reference.object, 144 ACPI_DUMP_PATHNAME(obj_desc->reference.object,
168 "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); 145 "Reference: Name: ", ACPI_LV_INFO,
169 ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO); 146 _COMPONENT);
147 ACPI_DUMP_ENTRY(obj_desc->reference.object,
148 ACPI_LV_INFO);
170 break; 149 break;
171 150
172
173 case AML_INDEX_OP: 151 case AML_INDEX_OP:
174 152
175 acpi_os_printf ("Reference: Index %p\n", 153 acpi_os_printf("Reference: Index %p\n",
176 obj_desc->reference.object); 154 obj_desc->reference.object);
177 break; 155 break;
178 156
179
180 case AML_REF_OF_OP: 157 case AML_REF_OF_OP:
181 158
182 acpi_os_printf ("Reference: (ref_of) %p\n", 159 acpi_os_printf("Reference: (ref_of) %p\n",
183 obj_desc->reference.object); 160 obj_desc->reference.object);
184 break; 161 break;
185 162
186
187 case AML_ARG_OP: 163 case AML_ARG_OP:
188 164
189 acpi_os_printf ("Reference: Arg%d", 165 acpi_os_printf("Reference: Arg%d",
190 obj_desc->reference.offset); 166 obj_desc->reference.offset);
191 167
192 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 168 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
193 /* Value is an Integer */ 169 /* Value is an Integer */
194 170
195 acpi_os_printf (" value is [%8.8X%8.8x]", 171 acpi_os_printf(" value is [%8.8X%8.8x]",
196 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 172 ACPI_FORMAT_UINT64(obj_desc->
173 integer.
174 value));
197 } 175 }
198 176
199 acpi_os_printf ("\n"); 177 acpi_os_printf("\n");
200 break; 178 break;
201 179
202
203 case AML_LOCAL_OP: 180 case AML_LOCAL_OP:
204 181
205 acpi_os_printf ("Reference: Local%d", 182 acpi_os_printf("Reference: Local%d",
206 obj_desc->reference.offset); 183 obj_desc->reference.offset);
207 184
208 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 185 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
209 186
210 /* Value is an Integer */ 187 /* Value is an Integer */
211 188
212 acpi_os_printf (" value is [%8.8X%8.8x]", 189 acpi_os_printf(" value is [%8.8X%8.8x]",
213 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 190 ACPI_FORMAT_UINT64(obj_desc->
191 integer.
192 value));
214 } 193 }
215 194
216 acpi_os_printf ("\n"); 195 acpi_os_printf("\n");
217 break; 196 break;
218 197
219
220 case AML_INT_NAMEPATH_OP: 198 case AML_INT_NAMEPATH_OP:
221 199
222 acpi_os_printf ("Reference.Node->Name %X\n", 200 acpi_os_printf("Reference.Node->Name %X\n",
223 obj_desc->reference.node->name.integer); 201 obj_desc->reference.node->name.integer);
224 break; 202 break;
225 203
226
227 default: 204 default:
228 205
229 /* Unknown opcode */ 206 /* Unknown opcode */
230 207
231 acpi_os_printf ("Unknown Reference opcode=%X\n", 208 acpi_os_printf("Unknown Reference opcode=%X\n",
232 obj_desc->reference.opcode); 209 obj_desc->reference.opcode);
233 break; 210 break;
234 211
235 } 212 }
236 break; 213 break;
237 214
238
239 case ACPI_TYPE_BUFFER: 215 case ACPI_TYPE_BUFFER:
240 216
241 acpi_os_printf ("Buffer len %X @ %p \n", 217 acpi_os_printf("Buffer len %X @ %p \n",
242 obj_desc->buffer.length, obj_desc->buffer.pointer); 218 obj_desc->buffer.length,
219 obj_desc->buffer.pointer);
243 220
244 length = obj_desc->buffer.length; 221 length = obj_desc->buffer.length;
245 if (length > 64) { 222 if (length > 64) {
@@ -249,178 +226,166 @@ acpi_ex_dump_operand (
249 /* Debug only -- dump the buffer contents */ 226 /* Debug only -- dump the buffer contents */
250 227
251 if (obj_desc->buffer.pointer) { 228 if (obj_desc->buffer.pointer) {
252 acpi_os_printf ("Buffer Contents: "); 229 acpi_os_printf("Buffer Contents: ");
253 230
254 for (index = 0; index < length; index++) { 231 for (index = 0; index < length; index++) {
255 acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]); 232 acpi_os_printf(" %02x",
233 obj_desc->buffer.pointer[index]);
256 } 234 }
257 acpi_os_printf ("\n"); 235 acpi_os_printf("\n");
258 } 236 }
259 break; 237 break;
260 238
261
262 case ACPI_TYPE_INTEGER: 239 case ACPI_TYPE_INTEGER:
263 240
264 acpi_os_printf ("Integer %8.8X%8.8X\n", 241 acpi_os_printf("Integer %8.8X%8.8X\n",
265 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 242 ACPI_FORMAT_UINT64(obj_desc->integer.value));
266 break; 243 break;
267 244
268
269 case ACPI_TYPE_PACKAGE: 245 case ACPI_TYPE_PACKAGE:
270 246
271 acpi_os_printf ("Package [Len %X] element_array %p\n", 247 acpi_os_printf("Package [Len %X] element_array %p\n",
272 obj_desc->package.count, obj_desc->package.elements); 248 obj_desc->package.count,
249 obj_desc->package.elements);
273 250
274 /* 251 /*
275 * If elements exist, package element pointer is valid, 252 * If elements exist, package element pointer is valid,
276 * and debug_level exceeds 1, dump package's elements. 253 * and debug_level exceeds 1, dump package's elements.
277 */ 254 */
278 if (obj_desc->package.count && 255 if (obj_desc->package.count &&
279 obj_desc->package.elements && 256 obj_desc->package.elements && acpi_dbg_level > 1) {
280 acpi_dbg_level > 1) { 257 for (index = 0; index < obj_desc->package.count;
281 for (index = 0; index < obj_desc->package.count; index++) { 258 index++) {
282 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);
283 } 262 }
284 } 263 }
285 break; 264 break;
286 265
287
288 case ACPI_TYPE_REGION: 266 case ACPI_TYPE_REGION:
289 267
290 acpi_os_printf ("Region %s (%X)", 268 acpi_os_printf("Region %s (%X)",
291 acpi_ut_get_region_name (obj_desc->region.space_id), 269 acpi_ut_get_region_name(obj_desc->region.
292 obj_desc->region.space_id); 270 space_id),
271 obj_desc->region.space_id);
293 272
294 /* 273 /*
295 * If the address and length have not been evaluated, 274 * If the address and length have not been evaluated,
296 * don't print them. 275 * don't print them.
297 */ 276 */
298 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) { 277 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
299 acpi_os_printf ("\n"); 278 acpi_os_printf("\n");
300 } 279 } else {
301 else { 280 acpi_os_printf(" base %8.8X%8.8X Length %X\n",
302 acpi_os_printf (" base %8.8X%8.8X Length %X\n", 281 ACPI_FORMAT_UINT64(obj_desc->region.
303 ACPI_FORMAT_UINT64 (obj_desc->region.address), 282 address),
304 obj_desc->region.length); 283 obj_desc->region.length);
305 } 284 }
306 break; 285 break;
307 286
308
309 case ACPI_TYPE_STRING: 287 case ACPI_TYPE_STRING:
310 288
311 acpi_os_printf ("String length %X @ %p ", 289 acpi_os_printf("String length %X @ %p ",
312 obj_desc->string.length, 290 obj_desc->string.length,
313 obj_desc->string.pointer); 291 obj_desc->string.pointer);
314 292
315 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); 293 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
316 acpi_os_printf ("\n"); 294 acpi_os_printf("\n");
317 break; 295 break;
318 296
319
320 case ACPI_TYPE_LOCAL_BANK_FIELD: 297 case ACPI_TYPE_LOCAL_BANK_FIELD:
321 298
322 acpi_os_printf ("bank_field\n"); 299 acpi_os_printf("bank_field\n");
323 break; 300 break;
324 301
325
326 case ACPI_TYPE_LOCAL_REGION_FIELD: 302 case ACPI_TYPE_LOCAL_REGION_FIELD:
327 303
328 acpi_os_printf ( 304 acpi_os_printf
329 "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",
330 obj_desc->field.bit_length, 306 obj_desc->field.bit_length,
331 obj_desc->field.access_byte_width, 307 obj_desc->field.access_byte_width,
332 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, 308 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
333 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, 309 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
334 obj_desc->field.base_byte_offset, 310 obj_desc->field.base_byte_offset,
335 obj_desc->field.start_field_bit_offset); 311 obj_desc->field.start_field_bit_offset);
336 312
337 acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1); 313 acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
338 break; 314 break;
339 315
340
341 case ACPI_TYPE_LOCAL_INDEX_FIELD: 316 case ACPI_TYPE_LOCAL_INDEX_FIELD:
342 317
343 acpi_os_printf ("index_field\n"); 318 acpi_os_printf("index_field\n");
344 break; 319 break;
345 320
346
347 case ACPI_TYPE_BUFFER_FIELD: 321 case ACPI_TYPE_BUFFER_FIELD:
348 322
349 acpi_os_printf ( 323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n",
350 "buffer_field: %X bits at byte %X bit %X of \n", 324 obj_desc->buffer_field.bit_length,
351 obj_desc->buffer_field.bit_length, 325 obj_desc->buffer_field.base_byte_offset,
352 obj_desc->buffer_field.base_byte_offset, 326 obj_desc->buffer_field.start_field_bit_offset);
353 obj_desc->buffer_field.start_field_bit_offset);
354 327
355 if (!obj_desc->buffer_field.buffer_obj) { 328 if (!obj_desc->buffer_field.buffer_obj) {
356 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); 329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n"));
357 } 330 } else
358 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != 331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
359 ACPI_TYPE_BUFFER) { 332 != ACPI_TYPE_BUFFER) {
360 acpi_os_printf ("*not a Buffer* \n"); 333 acpi_os_printf("*not a Buffer* \n");
361 } 334 } else {
362 else { 335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
363 acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1); 336 depth + 1);
364 } 337 }
365 break; 338 break;
366 339
367
368 case ACPI_TYPE_EVENT: 340 case ACPI_TYPE_EVENT:
369 341
370 acpi_os_printf ("Event\n"); 342 acpi_os_printf("Event\n");
371 break; 343 break;
372 344
373
374 case ACPI_TYPE_METHOD: 345 case ACPI_TYPE_METHOD:
375 346
376 acpi_os_printf ("Method(%X) @ %p:%X\n", 347 acpi_os_printf("Method(%X) @ %p:%X\n",
377 obj_desc->method.param_count, 348 obj_desc->method.param_count,
378 obj_desc->method.aml_start, 349 obj_desc->method.aml_start,
379 obj_desc->method.aml_length); 350 obj_desc->method.aml_length);
380 break; 351 break;
381 352
382
383 case ACPI_TYPE_MUTEX: 353 case ACPI_TYPE_MUTEX:
384 354
385 acpi_os_printf ("Mutex\n"); 355 acpi_os_printf("Mutex\n");
386 break; 356 break;
387 357
388
389 case ACPI_TYPE_DEVICE: 358 case ACPI_TYPE_DEVICE:
390 359
391 acpi_os_printf ("Device\n"); 360 acpi_os_printf("Device\n");
392 break; 361 break;
393 362
394
395 case ACPI_TYPE_POWER: 363 case ACPI_TYPE_POWER:
396 364
397 acpi_os_printf ("Power\n"); 365 acpi_os_printf("Power\n");
398 break; 366 break;
399 367
400
401 case ACPI_TYPE_PROCESSOR: 368 case ACPI_TYPE_PROCESSOR:
402 369
403 acpi_os_printf ("Processor\n"); 370 acpi_os_printf("Processor\n");
404 break; 371 break;
405 372
406
407 case ACPI_TYPE_THERMAL: 373 case ACPI_TYPE_THERMAL:
408 374
409 acpi_os_printf ("Thermal\n"); 375 acpi_os_printf("Thermal\n");
410 break; 376 break;
411 377
412
413 default: 378 default:
414 /* Unknown Type */ 379 /* Unknown Type */
415 380
416 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));
417 break; 383 break;
418 } 384 }
419 385
420 return; 386 return;
421} 387}
422 388
423
424/******************************************************************************* 389/*******************************************************************************
425 * 390 *
426 * FUNCTION: acpi_ex_dump_operands 391 * FUNCTION: acpi_ex_dump_operands
@@ -438,20 +403,15 @@ acpi_ex_dump_operand (
438 ******************************************************************************/ 403 ******************************************************************************/
439 404
440void 405void
441acpi_ex_dump_operands ( 406acpi_ex_dump_operands(union acpi_operand_object **operands,
442 union acpi_operand_object **operands, 407 acpi_interpreter_mode interpreter_mode,
443 acpi_interpreter_mode interpreter_mode, 408 char *ident,
444 char *ident, 409 u32 num_levels,
445 u32 num_levels, 410 char *note, char *module_name, u32 line_number)
446 char *note,
447 char *module_name,
448 u32 line_number)
449{ 411{
450 acpi_native_uint i; 412 acpi_native_uint i;
451
452
453 ACPI_FUNCTION_NAME ("ex_dump_operands");
454 413
414 ACPI_FUNCTION_NAME("ex_dump_operands");
455 415
456 if (!ident) { 416 if (!ident) {
457 ident = "?"; 417 ident = "?";
@@ -461,9 +421,9 @@ acpi_ex_dump_operands (
461 note = "?"; 421 note = "?";
462 } 422 }
463 423
464 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 424 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
465 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", 425 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
466 ident, num_levels)); 426 ident, num_levels));
467 427
468 if (num_levels == 0) { 428 if (num_levels == 0) {
469 num_levels = 1; 429 num_levels = 1;
@@ -472,16 +432,15 @@ acpi_ex_dump_operands (
472 /* Dump the operand stack starting at the top */ 432 /* Dump the operand stack starting at the top */
473 433
474 for (i = 0; num_levels > 0; i--, num_levels--) { 434 for (i = 0; num_levels > 0; i--, num_levels--) {
475 acpi_ex_dump_operand (operands[i], 0); 435 acpi_ex_dump_operand(operands[i], 0);
476 } 436 }
477 437
478 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 438 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
479 "************* Operand Stack dump from %s(%d), %s\n", 439 "************* Operand Stack dump from %s(%d), %s\n",
480 module_name, line_number, note)); 440 module_name, line_number, note));
481 return; 441 return;
482} 442}
483 443
484
485#ifdef ACPI_FUTURE_USAGE 444#ifdef ACPI_FUTURE_USAGE
486/******************************************************************************* 445/*******************************************************************************
487 * 446 *
@@ -496,44 +455,31 @@ acpi_ex_dump_operands (
496 * 455 *
497 ******************************************************************************/ 456 ******************************************************************************/
498 457
499static void 458static void acpi_ex_out_string(char *title, char *value)
500acpi_ex_out_string (
501 char *title,
502 char *value)
503{ 459{
504 acpi_os_printf ("%20s : %s\n", title, value); 460 acpi_os_printf("%20s : %s\n", title, value);
505} 461}
506 462
507static void 463static void acpi_ex_out_pointer(char *title, void *value)
508acpi_ex_out_pointer (
509 char *title,
510 void *value)
511{ 464{
512 acpi_os_printf ("%20s : %p\n", title, value); 465 acpi_os_printf("%20s : %p\n", title, value);
513} 466}
514 467
515static void 468static void acpi_ex_out_integer(char *title, u32 value)
516acpi_ex_out_integer (
517 char *title,
518 u32 value)
519{ 469{
520 acpi_os_printf ("%20s : %.2X\n", title, value); 470 acpi_os_printf("%20s : %.2X\n", title, value);
521} 471}
522 472
523static void 473static void acpi_ex_out_address(char *title, acpi_physical_address value)
524acpi_ex_out_address (
525 char *title,
526 acpi_physical_address value)
527{ 474{
528 475
529#if ACPI_MACHINE_WIDTH == 16 476#if ACPI_MACHINE_WIDTH == 16
530 acpi_os_printf ("%20s : %p\n", title, value); 477 acpi_os_printf("%20s : %p\n", title, value);
531#else 478#else
532 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));
533#endif 480#endif
534} 481}
535 482
536
537/******************************************************************************* 483/*******************************************************************************
538 * 484 *
539 * FUNCTION: acpi_ex_dump_node 485 * FUNCTION: acpi_ex_dump_node
@@ -545,33 +491,31 @@ acpi_ex_out_address (
545 * 491 *
546 ******************************************************************************/ 492 ******************************************************************************/
547 493
548void 494void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
549acpi_ex_dump_node (
550 struct acpi_namespace_node *node,
551 u32 flags)
552{ 495{
553 496
554 ACPI_FUNCTION_ENTRY (); 497 ACPI_FUNCTION_ENTRY();
555
556 498
557 if (!flags) { 499 if (!flags) {
558 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))) {
559 return; 503 return;
560 } 504 }
561 } 505 }
562 506
563 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));
564 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));
565 acpi_ex_out_integer ("Flags", node->flags); 509 acpi_ex_out_integer("Flags", node->flags);
566 acpi_ex_out_integer ("Owner Id", node->owner_id); 510 acpi_ex_out_integer("Owner Id", node->owner_id);
567 acpi_ex_out_integer ("Reference Count", node->reference_count); 511 acpi_ex_out_integer("Reference Count", node->reference_count);
568 acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node)); 512 acpi_ex_out_pointer("Attached Object",
569 acpi_ex_out_pointer ("child_list", node->child); 513 acpi_ns_get_attached_object(node));
570 acpi_ex_out_pointer ("next_peer", node->peer); 514 acpi_ex_out_pointer("child_list", node->child);
571 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));
572} 517}
573 518
574
575/******************************************************************************* 519/*******************************************************************************
576 * 520 *
577 * FUNCTION: acpi_ex_dump_reference 521 * FUNCTION: acpi_ex_dump_reference
@@ -582,32 +526,29 @@ acpi_ex_dump_node (
582 * 526 *
583 ******************************************************************************/ 527 ******************************************************************************/
584 528
585static void 529static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
586acpi_ex_dump_reference (
587 union acpi_operand_object *obj_desc)
588{ 530{
589 struct acpi_buffer ret_buf; 531 struct acpi_buffer ret_buf;
590 acpi_status status; 532 acpi_status status;
591
592 533
593 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 534 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
594 acpi_os_printf ("Named Object %p ", obj_desc->reference.node); 535 acpi_os_printf("Named Object %p ", obj_desc->reference.node);
595 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 536 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
596 status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf); 537 status =
597 if (ACPI_FAILURE (status)) { 538 acpi_ns_handle_to_pathname(obj_desc->reference.node,
598 acpi_os_printf ("Could not convert name to pathname\n"); 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);
599 } 545 }
600 else { 546 } else if (obj_desc->reference.object) {
601 acpi_os_printf ("%s\n", (char *) ret_buf.pointer); 547 acpi_os_printf("\nReferenced Object: %p\n",
602 ACPI_MEM_FREE (ret_buf.pointer); 548 obj_desc->reference.object);
603 }
604 }
605 else if (obj_desc->reference.object) {
606 acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
607 } 549 }
608} 550}
609 551
610
611/******************************************************************************* 552/*******************************************************************************
612 * 553 *
613 * FUNCTION: acpi_ex_dump_package 554 * FUNCTION: acpi_ex_dump_package
@@ -621,92 +562,85 @@ acpi_ex_dump_reference (
621 ******************************************************************************/ 562 ******************************************************************************/
622 563
623static void 564static void
624acpi_ex_dump_package ( 565acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
625 union acpi_operand_object *obj_desc,
626 u32 level,
627 u32 index)
628{ 566{
629 u32 i; 567 u32 i;
630
631 568
632 /* Indentation and index output */ 569 /* Indentation and index output */
633 570
634 if (level > 0) { 571 if (level > 0) {
635 for (i = 0; i < level; i++) { 572 for (i = 0; i < level; i++) {
636 acpi_os_printf (" "); 573 acpi_os_printf(" ");
637 } 574 }
638 575
639 acpi_os_printf ("[%.2d] ", index); 576 acpi_os_printf("[%.2d] ", index);
640 } 577 }
641 578
642 acpi_os_printf ("%p ", obj_desc); 579 acpi_os_printf("%p ", obj_desc);
643 580
644 /* Null package elements are allowed */ 581 /* Null package elements are allowed */
645 582
646 if (!obj_desc) { 583 if (!obj_desc) {
647 acpi_os_printf ("[Null Object]\n"); 584 acpi_os_printf("[Null Object]\n");
648 return; 585 return;
649 } 586 }
650 587
651 /* Packages may only contain a few object types */ 588 /* Packages may only contain a few object types */
652 589
653 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 590 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
654 case ACPI_TYPE_INTEGER: 591 case ACPI_TYPE_INTEGER:
655 592
656 acpi_os_printf ("[Integer] = %8.8X%8.8X\n", 593 acpi_os_printf("[Integer] = %8.8X%8.8X\n",
657 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 594 ACPI_FORMAT_UINT64(obj_desc->integer.value));
658 break; 595 break;
659 596
660
661 case ACPI_TYPE_STRING: 597 case ACPI_TYPE_STRING:
662 598
663 acpi_os_printf ("[String] Value: "); 599 acpi_os_printf("[String] Value: ");
664 for (i = 0; i < obj_desc->string.length; i++) { 600 for (i = 0; i < obj_desc->string.length; i++) {
665 acpi_os_printf ("%c", obj_desc->string.pointer[i]); 601 acpi_os_printf("%c", obj_desc->string.pointer[i]);
666 } 602 }
667 acpi_os_printf ("\n"); 603 acpi_os_printf("\n");
668 break; 604 break;
669 605
670
671 case ACPI_TYPE_BUFFER: 606 case ACPI_TYPE_BUFFER:
672 607
673 acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length); 608 acpi_os_printf("[Buffer] Length %.2X = ",
609 obj_desc->buffer.length);
674 if (obj_desc->buffer.length) { 610 if (obj_desc->buffer.length) {
675 acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer, 611 acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer,
676 obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT); 612 obj_desc->buffer.length,
677 } 613 DB_DWORD_DISPLAY, _COMPONENT);
678 else { 614 } else {
679 acpi_os_printf ("\n"); 615 acpi_os_printf("\n");
680 } 616 }
681 break; 617 break;
682 618
683
684 case ACPI_TYPE_PACKAGE: 619 case ACPI_TYPE_PACKAGE:
685 620
686 acpi_os_printf ("[Package] Contains %d Elements: \n", 621 acpi_os_printf("[Package] Contains %d Elements: \n",
687 obj_desc->package.count); 622 obj_desc->package.count);
688 623
689 for (i = 0; i < obj_desc->package.count; i++) { 624 for (i = 0; i < obj_desc->package.count; i++) {
690 acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i); 625 acpi_ex_dump_package(obj_desc->package.elements[i],
626 level + 1, i);
691 } 627 }
692 break; 628 break;
693 629
694
695 case ACPI_TYPE_LOCAL_REFERENCE: 630 case ACPI_TYPE_LOCAL_REFERENCE:
696 631
697 acpi_os_printf ("[Object Reference] "); 632 acpi_os_printf("[Object Reference] ");
698 acpi_ex_dump_reference (obj_desc); 633 acpi_ex_dump_reference(obj_desc);
699 break; 634 break;
700 635
701
702 default: 636 default:
703 637
704 acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); 638 acpi_os_printf("[Unknown Type] %X\n",
639 ACPI_GET_OBJECT_TYPE(obj_desc));
705 break; 640 break;
706 } 641 }
707} 642}
708 643
709
710/******************************************************************************* 644/*******************************************************************************
711 * 645 *
712 * FUNCTION: acpi_ex_dump_object_descriptor 646 * FUNCTION: acpi_ex_dump_object_descriptor
@@ -719,190 +653,213 @@ acpi_ex_dump_package (
719 ******************************************************************************/ 653 ******************************************************************************/
720 654
721void 655void
722acpi_ex_dump_object_descriptor ( 656acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
723 union acpi_operand_object *obj_desc,
724 u32 flags)
725{ 657{
726 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); 658 ACPI_FUNCTION_TRACE("ex_dump_object_descriptor");
727
728 659
729 if (!obj_desc) { 660 if (!obj_desc) {
730 return_VOID; 661 return_VOID;
731 } 662 }
732 663
733 if (!flags) { 664 if (!flags) {
734 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))) {
735 return_VOID; 668 return_VOID;
736 } 669 }
737 } 670 }
738 671
739 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
740 acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags); 673 acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc,
741 acpi_os_printf ("\nAttached Object (%p):\n", 674 flags);
742 ((struct acpi_namespace_node *) obj_desc)->object); 675 acpi_os_printf("\nAttached Object (%p):\n",
743 acpi_ex_dump_object_descriptor ( 676 ((struct acpi_namespace_node *)obj_desc)->
744 ((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);
745 return_VOID; 680 return_VOID;
746 } 681 }
747 682
748 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 683 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
749 acpi_os_printf ( 684 acpi_os_printf
750 "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",
751 obj_desc, acpi_ut_get_descriptor_name (obj_desc)); 686 obj_desc, acpi_ut_get_descriptor_name(obj_desc));
752 return_VOID; 687 return_VOID;
753 } 688 }
754 689
755 /* Common Fields */ 690 /* Common Fields */
756 691
757 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));
758 acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count); 693 acpi_ex_out_integer("Reference Count",
759 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);
760 696
761 /* Object-specific Fields */ 697 /* Object-specific Fields */
762 698
763 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 699 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
764 case ACPI_TYPE_INTEGER: 700 case ACPI_TYPE_INTEGER:
765 701
766 acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value", 702 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
767 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 703 ACPI_FORMAT_UINT64(obj_desc->integer.value));
768 break; 704 break;
769 705
770
771 case ACPI_TYPE_STRING: 706 case ACPI_TYPE_STRING:
772 707
773 acpi_ex_out_integer ("Length", obj_desc->string.length); 708 acpi_ex_out_integer("Length", obj_desc->string.length);
774 709
775 acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer); 710 acpi_os_printf("%20s : %p ", "Pointer",
776 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); 711 obj_desc->string.pointer);
777 acpi_os_printf ("\n"); 712 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
713 acpi_os_printf("\n");
778 break; 714 break;
779 715
780
781 case ACPI_TYPE_BUFFER: 716 case ACPI_TYPE_BUFFER:
782 717
783 acpi_ex_out_integer ("Length", obj_desc->buffer.length); 718 acpi_ex_out_integer("Length", obj_desc->buffer.length);
784 acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer); 719 acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
785 ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length); 720 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
721 obj_desc->buffer.length);
786 break; 722 break;
787 723
788
789 case ACPI_TYPE_PACKAGE: 724 case ACPI_TYPE_PACKAGE:
790 725
791 acpi_ex_out_integer ("Flags", obj_desc->package.flags); 726 acpi_ex_out_integer("Flags", obj_desc->package.flags);
792 acpi_ex_out_integer ("Elements", obj_desc->package.count); 727 acpi_ex_out_integer("Elements", obj_desc->package.count);
793 acpi_ex_out_pointer ("Element List", obj_desc->package.elements); 728 acpi_ex_out_pointer("Element List", obj_desc->package.elements);
794 729
795 /* Dump the package contents */ 730 /* Dump the package contents */
796 731
797 acpi_os_printf ("\nPackage Contents:\n"); 732 acpi_os_printf("\nPackage Contents:\n");
798 acpi_ex_dump_package (obj_desc, 0, 0); 733 acpi_ex_dump_package(obj_desc, 0, 0);
799 break; 734 break;
800 735
801
802 case ACPI_TYPE_DEVICE: 736 case ACPI_TYPE_DEVICE:
803 737
804 acpi_ex_out_pointer ("Handler", obj_desc->device.handler); 738 acpi_ex_out_pointer("Handler", obj_desc->device.handler);
805 acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify); 739 acpi_ex_out_pointer("system_notify",
806 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);
807 break; 743 break;
808 744
809
810 case ACPI_TYPE_EVENT: 745 case ACPI_TYPE_EVENT:
811 746
812 acpi_ex_out_pointer ("Semaphore", obj_desc->event.semaphore); 747 acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
813 break; 748 break;
814 749
815
816 case ACPI_TYPE_METHOD: 750 case ACPI_TYPE_METHOD:
817 751
818 acpi_ex_out_integer ("param_count", obj_desc->method.param_count); 752 acpi_ex_out_integer("param_count",
819 acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); 753 obj_desc->method.param_count);
820 acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); 754 acpi_ex_out_integer("Concurrency",
821 acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id); 755 obj_desc->method.concurrency);
822 acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); 756 acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
823 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);
824 break; 760 break;
825 761
826
827 case ACPI_TYPE_MUTEX: 762 case ACPI_TYPE_MUTEX:
828 763
829 acpi_ex_out_integer ("sync_level", obj_desc->mutex.sync_level); 764 acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
830 acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread); 765 acpi_ex_out_pointer("owner_thread",
831 acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth); 766 obj_desc->mutex.owner_thread);
832 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);
833 break; 770 break;
834 771
835
836 case ACPI_TYPE_REGION: 772 case ACPI_TYPE_REGION:
837 773
838 acpi_ex_out_integer ("space_id", obj_desc->region.space_id); 774 acpi_ex_out_integer("space_id", obj_desc->region.space_id);
839 acpi_ex_out_integer ("Flags", obj_desc->region.flags); 775 acpi_ex_out_integer("Flags", obj_desc->region.flags);
840 acpi_ex_out_address ("Address", obj_desc->region.address); 776 acpi_ex_out_address("Address", obj_desc->region.address);
841 acpi_ex_out_integer ("Length", obj_desc->region.length); 777 acpi_ex_out_integer("Length", obj_desc->region.length);
842 acpi_ex_out_pointer ("Handler", obj_desc->region.handler); 778 acpi_ex_out_pointer("Handler", obj_desc->region.handler);
843 acpi_ex_out_pointer ("Next", obj_desc->region.next); 779 acpi_ex_out_pointer("Next", obj_desc->region.next);
844 break; 780 break;
845 781
846
847 case ACPI_TYPE_POWER: 782 case ACPI_TYPE_POWER:
848 783
849 acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level); 784 acpi_ex_out_integer("system_level",
850 acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order); 785 obj_desc->power_resource.system_level);
851 acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify); 786 acpi_ex_out_integer("resource_order",
852 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);
853 break; 792 break;
854 793
855
856 case ACPI_TYPE_PROCESSOR: 794 case ACPI_TYPE_PROCESSOR:
857 795
858 acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id); 796 acpi_ex_out_integer("Processor ID",
859 acpi_ex_out_integer ("Length", obj_desc->processor.length); 797 obj_desc->processor.proc_id);
860 acpi_ex_out_address ("Address", (acpi_physical_address) obj_desc->processor.address); 798 acpi_ex_out_integer("Length", obj_desc->processor.length);
861 acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify); 799 acpi_ex_out_address("Address",
862 acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify); 800 (acpi_physical_address) obj_desc->processor.
863 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);
864 break; 807 break;
865 808
866
867 case ACPI_TYPE_THERMAL: 809 case ACPI_TYPE_THERMAL:
868 810
869 acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify); 811 acpi_ex_out_pointer("system_notify",
870 acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify); 812 obj_desc->thermal_zone.system_notify);
871 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);
872 break; 816 break;
873 817
874
875 case ACPI_TYPE_BUFFER_FIELD: 818 case ACPI_TYPE_BUFFER_FIELD:
876 case ACPI_TYPE_LOCAL_REGION_FIELD: 819 case ACPI_TYPE_LOCAL_REGION_FIELD:
877 case ACPI_TYPE_LOCAL_BANK_FIELD: 820 case ACPI_TYPE_LOCAL_BANK_FIELD:
878 case ACPI_TYPE_LOCAL_INDEX_FIELD: 821 case ACPI_TYPE_LOCAL_INDEX_FIELD:
879 822
880 acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags); 823 acpi_ex_out_integer("field_flags",
881 acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width); 824 obj_desc->common_field.field_flags);
882 acpi_ex_out_integer ("bit_length", obj_desc->common_field.bit_length); 825 acpi_ex_out_integer("access_byte_width",
883 acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset); 826 obj_desc->common_field.access_byte_width);
884 acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset); 827 acpi_ex_out_integer("bit_length",
885 acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node); 828 obj_desc->common_field.bit_length);
886 829 acpi_ex_out_integer("fld_bit_offset",
887 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)) {
888 case ACPI_TYPE_BUFFER_FIELD: 837 case ACPI_TYPE_BUFFER_FIELD:
889 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);
890 break; 840 break;
891 841
892 case ACPI_TYPE_LOCAL_REGION_FIELD: 842 case ACPI_TYPE_LOCAL_REGION_FIELD:
893 acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj); 843 acpi_ex_out_pointer("region_obj",
844 obj_desc->field.region_obj);
894 break; 845 break;
895 846
896 case ACPI_TYPE_LOCAL_BANK_FIELD: 847 case ACPI_TYPE_LOCAL_BANK_FIELD:
897 acpi_ex_out_integer ("Value", obj_desc->bank_field.value); 848 acpi_ex_out_integer("Value",
898 acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj); 849 obj_desc->bank_field.value);
899 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);
900 break; 854 break;
901 855
902 case ACPI_TYPE_LOCAL_INDEX_FIELD: 856 case ACPI_TYPE_LOCAL_INDEX_FIELD:
903 acpi_ex_out_integer ("Value", obj_desc->index_field.value); 857 acpi_ex_out_integer("Value",
904 acpi_ex_out_pointer ("Index", obj_desc->index_field.index_obj); 858 obj_desc->index_field.value);
905 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);
906 break; 863 break;
907 864
908 default: 865 default:
@@ -911,53 +868,52 @@ acpi_ex_dump_object_descriptor (
911 } 868 }
912 break; 869 break;
913 870
914
915 case ACPI_TYPE_LOCAL_REFERENCE: 871 case ACPI_TYPE_LOCAL_REFERENCE:
916 872
917 acpi_ex_out_integer ("target_type", obj_desc->reference.target_type); 873 acpi_ex_out_integer("target_type",
918 acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info ( 874 obj_desc->reference.target_type);
919 obj_desc->reference.opcode))->name); 875 acpi_ex_out_string("Opcode",
920 acpi_ex_out_integer ("Offset", obj_desc->reference.offset); 876 (acpi_ps_get_opcode_info
921 acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object); 877 (obj_desc->reference.opcode))->name);
922 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 878 acpi_ex_out_integer("Offset", obj_desc->reference.offset);
923 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 879 acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
880 acpi_ex_out_pointer("Node", obj_desc->reference.node);
881 acpi_ex_out_pointer("Where", obj_desc->reference.where);
924 882
925 acpi_ex_dump_reference (obj_desc); 883 acpi_ex_dump_reference(obj_desc);
926 break; 884 break;
927 885
928
929 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: 886 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
930 887
931 acpi_ex_out_integer ("space_id", obj_desc->address_space.space_id); 888 acpi_ex_out_integer("space_id",
932 acpi_ex_out_pointer ("Next", obj_desc->address_space.next); 889 obj_desc->address_space.space_id);
933 acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list); 890 acpi_ex_out_pointer("Next", obj_desc->address_space.next);
934 acpi_ex_out_pointer ("Node", obj_desc->address_space.node); 891 acpi_ex_out_pointer("region_list",
935 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);
936 break; 895 break;
937 896
938
939 case ACPI_TYPE_LOCAL_NOTIFY: 897 case ACPI_TYPE_LOCAL_NOTIFY:
940 898
941 acpi_ex_out_pointer ("Node", obj_desc->notify.node); 899 acpi_ex_out_pointer("Node", obj_desc->notify.node);
942 acpi_ex_out_pointer ("Context", obj_desc->notify.context); 900 acpi_ex_out_pointer("Context", obj_desc->notify.context);
943 break; 901 break;
944 902
945
946 case ACPI_TYPE_LOCAL_ALIAS: 903 case ACPI_TYPE_LOCAL_ALIAS:
947 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 904 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
948 case ACPI_TYPE_LOCAL_EXTRA: 905 case ACPI_TYPE_LOCAL_EXTRA:
949 case ACPI_TYPE_LOCAL_DATA: 906 case ACPI_TYPE_LOCAL_DATA:
950 default: 907 default:
951 908
952 acpi_os_printf ( 909 acpi_os_printf
953 "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",
954 acpi_ut_get_object_type_name (obj_desc)); 911 acpi_ut_get_object_type_name(obj_desc));
955 break; 912 break;
956 } 913 }
957 914
958 return_VOID; 915 return_VOID;
959} 916}
960 917
961#endif /* ACPI_FUTURE_USAGE */ 918#endif /* ACPI_FUTURE_USAGE */
962#endif 919#endif
963
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index a690c9250990..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,67 +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);
89 } 82 }
90 if (!ret_buffer_desc) { 83 if (!ret_buffer_desc) {
91 return_ACPI_STATUS (AE_BAD_PARAMETER); 84 return_ACPI_STATUS(AE_BAD_PARAMETER);
92 } 85 }
93 86
94 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 87 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
95 /* 88 /*
96 * If the buffer_field arguments have not been previously evaluated, 89 * If the buffer_field arguments have not been previously evaluated,
97 * evaluate them now and save the results. 90 * evaluate them now and save the results.
98 */ 91 */
99 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 92 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
100 status = acpi_ds_get_buffer_field_arguments (obj_desc); 93 status = acpi_ds_get_buffer_field_arguments(obj_desc);
101 if (ACPI_FAILURE (status)) { 94 if (ACPI_FAILURE(status)) {
102 return_ACPI_STATUS (status); 95 return_ACPI_STATUS(status);
103 } 96 }
104 } 97 }
105 } 98 } else
106 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)
107 (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)) {
108 /* 102 /*
109 * 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
110 * and directly access the region handler. 104 * and directly access the region handler.
111 */ 105 */
112 buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); 106 buffer_desc =
107 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
113 if (!buffer_desc) { 108 if (!buffer_desc) {
114 return_ACPI_STATUS (AE_NO_MEMORY); 109 return_ACPI_STATUS(AE_NO_MEMORY);
115 } 110 }
116 111
117 /* Lock entire transaction if requested */ 112 /* Lock entire transaction if requested */
118 113
119 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);
120 117
121 /* 118 /*
122 * Perform the read. 119 * Perform the read.
123 * 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
124 */ 121 */
125 status = acpi_ex_access_region (obj_desc, 0, 122 status = acpi_ex_access_region(obj_desc, 0,
126 ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer), 123 ACPI_CAST_PTR(acpi_integer,
127 ACPI_READ | (obj_desc->field.attribute << 16)); 124 buffer_desc->
128 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);
129 goto exit; 129 goto exit;
130 } 130 }
131 131
@@ -139,22 +139,22 @@ acpi_ex_read_data_from_field (
139 * 139 *
140 * Note: Field.length is in bits. 140 * Note: Field.length is in bits.
141 */ 141 */
142 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);
143 if (length > acpi_gbl_integer_byte_width) { 144 if (length > acpi_gbl_integer_byte_width) {
144 /* Field is too large for an Integer, create a Buffer instead */ 145 /* Field is too large for an Integer, create a Buffer instead */
145 146
146 buffer_desc = acpi_ut_create_buffer_object (length); 147 buffer_desc = acpi_ut_create_buffer_object(length);
147 if (!buffer_desc) { 148 if (!buffer_desc) {
148 return_ACPI_STATUS (AE_NO_MEMORY); 149 return_ACPI_STATUS(AE_NO_MEMORY);
149 } 150 }
150 buffer = buffer_desc->buffer.pointer; 151 buffer = buffer_desc->buffer.pointer;
151 } 152 } else {
152 else {
153 /* Field will fit within an Integer (normal case) */ 153 /* Field will fit within an Integer (normal case) */
154 154
155 buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 155 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
156 if (!buffer_desc) { 156 if (!buffer_desc) {
157 return_ACPI_STATUS (AE_NO_MEMORY); 157 return_ACPI_STATUS(AE_NO_MEMORY);
158 } 158 }
159 159
160 length = acpi_gbl_integer_byte_width; 160 length = acpi_gbl_integer_byte_width;
@@ -162,37 +162,36 @@ acpi_ex_read_data_from_field (
162 buffer = &buffer_desc->integer.value; 162 buffer = &buffer_desc->integer.value;
163 } 163 }
164 164
165 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 165 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
166 "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",
167 obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, (u32) length)); 167 obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer,
168 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 168 (u32) length));
169 "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
170 obj_desc->common_field.bit_length, 170 "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n",
171 obj_desc->common_field.start_field_bit_offset, 171 obj_desc->common_field.bit_length,
172 obj_desc->common_field.base_byte_offset)); 172 obj_desc->common_field.start_field_bit_offset,
173 obj_desc->common_field.base_byte_offset));
173 174
174 /* Lock entire transaction if requested */ 175 /* Lock entire transaction if requested */
175 176
176 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);
177 179
178 /* Read from the field */ 180 /* Read from the field */
179 181
180 status = acpi_ex_extract_from_field (obj_desc, buffer, (u32) length); 182 status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length);
181 acpi_ex_release_global_lock (locked); 183 acpi_ex_release_global_lock(locked);
182
183 184
184exit: 185 exit:
185 if (ACPI_FAILURE (status)) { 186 if (ACPI_FAILURE(status)) {
186 acpi_ut_remove_reference (buffer_desc); 187 acpi_ut_remove_reference(buffer_desc);
187 } 188 } else {
188 else {
189 *ret_buffer_desc = buffer_desc; 189 *ret_buffer_desc = buffer_desc;
190 } 190 }
191 191
192 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
193} 193}
194 194
195
196/******************************************************************************* 195/*******************************************************************************
197 * 196 *
198 * FUNCTION: acpi_ex_write_data_to_field 197 * FUNCTION: acpi_ex_write_data_to_field
@@ -208,97 +207,96 @@ exit:
208 ******************************************************************************/ 207 ******************************************************************************/
209 208
210acpi_status 209acpi_status
211acpi_ex_write_data_to_field ( 210acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
212 union acpi_operand_object *source_desc, 211 union acpi_operand_object *obj_desc,
213 union acpi_operand_object *obj_desc, 212 union acpi_operand_object **result_desc)
214 union acpi_operand_object **result_desc)
215{ 213{
216 acpi_status status; 214 acpi_status status;
217 u32 length; 215 u32 length;
218 u32 required_length; 216 u32 required_length;
219 void *buffer; 217 void *buffer;
220 void *new_buffer; 218 void *new_buffer;
221 u8 locked; 219 u8 locked;
222 union acpi_operand_object *buffer_desc; 220 union acpi_operand_object *buffer_desc;
223
224
225 ACPI_FUNCTION_TRACE_PTR ("ex_write_data_to_field", obj_desc);
226 221
222 ACPI_FUNCTION_TRACE_PTR("ex_write_data_to_field", obj_desc);
227 223
228 /* Parameter validation */ 224 /* Parameter validation */
229 225
230 if (!source_desc || !obj_desc) { 226 if (!source_desc || !obj_desc) {
231 return_ACPI_STATUS (AE_AML_NO_OPERAND); 227 return_ACPI_STATUS(AE_AML_NO_OPERAND);
232 } 228 }
233 229
234 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 230 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
235 /* 231 /*
236 * If the buffer_field arguments have not been previously evaluated, 232 * If the buffer_field arguments have not been previously evaluated,
237 * evaluate them now and save the results. 233 * evaluate them now and save the results.
238 */ 234 */
239 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { 235 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
240 status = acpi_ds_get_buffer_field_arguments (obj_desc); 236 status = acpi_ds_get_buffer_field_arguments(obj_desc);
241 if (ACPI_FAILURE (status)) { 237 if (ACPI_FAILURE(status)) {
242 return_ACPI_STATUS (status); 238 return_ACPI_STATUS(status);
243 } 239 }
244 } 240 }
245 } 241 } else
246 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)
247 (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)) {
248 /* 245 /*
249 * 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
250 * and handoff the buffer directly to the handler. 247 * and handoff the buffer directly to the handler.
251 * 248 *
252 * 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).
253 */ 250 */
254 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { 251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
255 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)));
256 acpi_ut_get_object_type_name (source_desc)));
257 253
258 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 254 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
259 } 255 }
260 256
261 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 257 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
262 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));
263 "SMBus write requires Buffer of length %X, found length %X\n",
264 ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
265 259
266 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); 260 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
267 } 261 }
268 262
269 buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); 263 buffer_desc =
264 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
270 if (!buffer_desc) { 265 if (!buffer_desc) {
271 return_ACPI_STATUS (AE_NO_MEMORY); 266 return_ACPI_STATUS(AE_NO_MEMORY);
272 } 267 }
273 268
274 buffer = buffer_desc->buffer.pointer; 269 buffer = buffer_desc->buffer.pointer;
275 ACPI_MEMCPY (buffer, source_desc->buffer.pointer, 270 ACPI_MEMCPY(buffer, source_desc->buffer.pointer,
276 ACPI_SMBUS_BUFFER_SIZE); 271 ACPI_SMBUS_BUFFER_SIZE);
277 272
278 /* Lock entire transaction if requested */ 273 /* Lock entire transaction if requested */
279 274
280 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);
281 278
282 /* 279 /*
283 * Perform the write (returns status and perhaps data in the 280 * Perform the write (returns status and perhaps data in the
284 * same buffer) 281 * same buffer)
285 * 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.
286 */ 283 */
287 status = acpi_ex_access_region (obj_desc, 0, 284 status = acpi_ex_access_region(obj_desc, 0,
288 (acpi_integer *) buffer, 285 (acpi_integer *) buffer,
289 ACPI_WRITE | (obj_desc->field.attribute << 16)); 286 ACPI_WRITE | (obj_desc->field.
290 acpi_ex_release_global_lock (locked); 287 attribute << 16));
288 acpi_ex_release_global_lock(locked);
291 289
292 *result_desc = buffer_desc; 290 *result_desc = buffer_desc;
293 return_ACPI_STATUS (status); 291 return_ACPI_STATUS(status);
294 } 292 }
295 293
296 /* Get a pointer to the data to be written */ 294 /* Get a pointer to the data to be written */
297 295
298 switch (ACPI_GET_OBJECT_TYPE (source_desc)) { 296 switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
299 case ACPI_TYPE_INTEGER: 297 case ACPI_TYPE_INTEGER:
300 buffer = &source_desc->integer.value; 298 buffer = &source_desc->integer.value;
301 length = sizeof (source_desc->integer.value); 299 length = sizeof(source_desc->integer.value);
302 break; 300 break;
303 301
304 case ACPI_TYPE_BUFFER: 302 case ACPI_TYPE_BUFFER:
@@ -312,7 +310,7 @@ acpi_ex_write_data_to_field (
312 break; 310 break;
313 311
314 default: 312 default:
315 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 313 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
316 } 314 }
317 315
318 /* 316 /*
@@ -322,15 +320,15 @@ acpi_ex_write_data_to_field (
322 * the ACPI specification. 320 * the ACPI specification.
323 */ 321 */
324 new_buffer = NULL; 322 new_buffer = NULL;
325 required_length = ACPI_ROUND_BITS_UP_TO_BYTES ( 323 required_length =
326 obj_desc->common_field.bit_length); 324 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
327 325
328 if (length < required_length) { 326 if (length < required_length) {
329 /* We need to create a new buffer */ 327 /* We need to create a new buffer */
330 328
331 new_buffer = ACPI_MEM_CALLOCATE (required_length); 329 new_buffer = ACPI_MEM_CALLOCATE(required_length);
332 if (!new_buffer) { 330 if (!new_buffer) {
333 return_ACPI_STATUS (AE_NO_MEMORY); 331 return_ACPI_STATUS(AE_NO_MEMORY);
334 } 332 }
335 333
336 /* 334 /*
@@ -338,40 +336,42 @@ acpi_ex_write_data_to_field (
338 * at Byte zero. All unused (upper) bytes of the 336 * at Byte zero. All unused (upper) bytes of the
339 * buffer will be 0. 337 * buffer will be 0.
340 */ 338 */
341 ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length); 339 ACPI_MEMCPY((char *)new_buffer, (char *)buffer, length);
342 buffer = new_buffer; 340 buffer = new_buffer;
343 length = required_length; 341 length = required_length;
344 } 342 }
345 343
346 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 344 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
347 "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",
348 source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)), 346 source_desc,
349 ACPI_GET_OBJECT_TYPE (source_desc), buffer, length)); 347 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
350 348 (source_desc)),
351 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 349 ACPI_GET_OBJECT_TYPE(source_desc), buffer, length));
352 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n", 350
353 obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)), 351 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
354 ACPI_GET_OBJECT_TYPE (obj_desc), 352 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
355 obj_desc->common_field.bit_length, 353 obj_desc,
356 obj_desc->common_field.start_field_bit_offset, 354 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)),
357 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));
358 359
359 /* Lock entire transaction if requested */ 360 /* Lock entire transaction if requested */
360 361
361 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);
362 364
363 /* Write to the field */ 365 /* Write to the field */
364 366
365 status = acpi_ex_insert_into_field (obj_desc, buffer, length); 367 status = acpi_ex_insert_into_field(obj_desc, buffer, length);
366 acpi_ex_release_global_lock (locked); 368 acpi_ex_release_global_lock(locked);
367 369
368 /* Free temporary buffer if we used one */ 370 /* Free temporary buffer if we used one */
369 371
370 if (new_buffer) { 372 if (new_buffer) {
371 ACPI_MEM_FREE (new_buffer); 373 ACPI_MEM_FREE(new_buffer);
372 } 374 }
373 375
374 return_ACPI_STATUS (status); 376 return_ACPI_STATUS(status);
375} 377}
376
377
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 237ef28c8132..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 ((acpi_size) 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 b6ba1a7a677a..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));
195 } else {
196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
197 "No Name string - %s \n", char_buf));
216 } 198 }
217 else { 199 } else if (index == 0) {
218 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
219 "No Name string - %s \n", char_buf));
220 }
221 }
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,22 +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
441 if (ACPI_FAILURE (status)) { 420 if (ACPI_FAILURE(status)) {
442 if (name_string) { 421 if (name_string) {
443 ACPI_MEM_FREE (name_string); 422 ACPI_MEM_FREE(name_string);
444 } 423 }
445 return_ACPI_STATUS (status); 424 return_ACPI_STATUS(status);
446 } 425 }
447 426
448 *out_name_string = name_string; 427 *out_name_string = name_string;
449 *out_name_length = (u32) (aml_address - in_aml_address); 428 *out_name_length = (u32) (aml_address - in_aml_address);
450 429
451 return_ACPI_STATUS (status); 430 return_ACPI_STATUS(status);
452} 431}
453
454
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 48c30f800083..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,61 +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#if ACPI_MACHINE_WIDTH != 16 107#if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer (); 108 return_desc->integer.value = acpi_os_get_timer();
118#endif 109#endif
119 break; 110 break;
120 111
121 default: /* Unknown opcode */ 112 default: /* Unknown opcode */
122 113
123 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));
124 walk_state->opcode));
125 status = AE_AML_BAD_OPCODE; 115 status = AE_AML_BAD_OPCODE;
126 break; 116 break;
127 } 117 }
128 118
129cleanup: 119 cleanup:
130 120
131 /* Delete return object on error */ 121 /* Delete return object on error */
132 122
133 if ((ACPI_FAILURE (status)) || walk_state->result_obj) { 123 if ((ACPI_FAILURE(status)) || walk_state->result_obj) {
134 acpi_ut_remove_reference (return_desc); 124 acpi_ut_remove_reference(return_desc);
135 } 125 } else {
136 else {
137 /* Save the return value */ 126 /* Save the return value */
138 127
139 walk_state->result_obj = return_desc; 128 walk_state->result_obj = return_desc;
140 } 129 }
141 130
142 return_ACPI_STATUS (status); 131 return_ACPI_STATUS(status);
143} 132}
144 133
145
146/******************************************************************************* 134/*******************************************************************************
147 * 135 *
148 * FUNCTION: acpi_ex_opcode_1A_0T_0R 136 * FUNCTION: acpi_ex_opcode_1A_0T_0R
@@ -156,69 +144,58 @@ cleanup:
156 * 144 *
157 ******************************************************************************/ 145 ******************************************************************************/
158 146
159acpi_status 147acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
160acpi_ex_opcode_1A_0T_0R (
161 struct acpi_walk_state *walk_state)
162{ 148{
163 union acpi_operand_object **operand = &walk_state->operands[0]; 149 union acpi_operand_object **operand = &walk_state->operands[0];
164 acpi_status status = AE_OK; 150 acpi_status status = AE_OK;
165
166
167 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
168 acpi_ps_get_opcode_name (walk_state->opcode));
169 151
152 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_0R",
153 acpi_ps_get_opcode_name(walk_state->opcode));
170 154
171 /* Examine the AML opcode */ 155 /* Examine the AML opcode */
172 156
173 switch (walk_state->opcode) { 157 switch (walk_state->opcode) {
174 case AML_RELEASE_OP: /* Release (mutex_object) */ 158 case AML_RELEASE_OP: /* Release (mutex_object) */
175 159
176 status = acpi_ex_release_mutex (operand[0], walk_state); 160 status = acpi_ex_release_mutex(operand[0], walk_state);
177 break; 161 break;
178 162
163 case AML_RESET_OP: /* Reset (event_object) */
179 164
180 case AML_RESET_OP: /* Reset (event_object) */ 165 status = acpi_ex_system_reset_event(operand[0]);
181
182 status = acpi_ex_system_reset_event (operand[0]);
183 break; 166 break;
184 167
168 case AML_SIGNAL_OP: /* Signal (event_object) */
185 169
186 case AML_SIGNAL_OP: /* Signal (event_object) */ 170 status = acpi_ex_system_signal_event(operand[0]);
187
188 status = acpi_ex_system_signal_event (operand[0]);
189 break; 171 break;
190 172
173 case AML_SLEEP_OP: /* Sleep (msec_time) */
191 174
192 case AML_SLEEP_OP: /* Sleep (msec_time) */ 175 status = acpi_ex_system_do_suspend(operand[0]->integer.value);
193
194 status = acpi_ex_system_do_suspend (operand[0]->integer.value);
195 break; 176 break;
196 177
178 case AML_STALL_OP: /* Stall (usec_time) */
197 179
198 case AML_STALL_OP: /* Stall (usec_time) */ 180 status =
199 181 acpi_ex_system_do_stall((u32) operand[0]->integer.value);
200 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
201 break; 182 break;
202 183
184 case AML_UNLOAD_OP: /* Unload (Handle) */
203 185
204 case AML_UNLOAD_OP: /* Unload (Handle) */ 186 status = acpi_ex_unload_table(operand[0]);
205
206 status = acpi_ex_unload_table (operand[0]);
207 break; 187 break;
208 188
189 default: /* Unknown opcode */
209 190
210 default: /* Unknown opcode */ 191 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
211
212 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
213 walk_state->opcode));
214 status = AE_AML_BAD_OPCODE; 192 status = AE_AML_BAD_OPCODE;
215 break; 193 break;
216 } 194 }
217 195
218 return_ACPI_STATUS (status); 196 return_ACPI_STATUS(status);
219} 197}
220 198
221
222/******************************************************************************* 199/*******************************************************************************
223 * 200 *
224 * FUNCTION: acpi_ex_opcode_1A_1T_0R 201 * FUNCTION: acpi_ex_opcode_1A_1T_0R
@@ -232,41 +209,34 @@ acpi_ex_opcode_1A_0T_0R (
232 * 209 *
233 ******************************************************************************/ 210 ******************************************************************************/
234 211
235acpi_status 212acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
236acpi_ex_opcode_1A_1T_0R (
237 struct acpi_walk_state *walk_state)
238{ 213{
239 acpi_status status = AE_OK; 214 acpi_status status = AE_OK;
240 union acpi_operand_object **operand = &walk_state->operands[0]; 215 union acpi_operand_object **operand = &walk_state->operands[0];
241
242
243 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
244 acpi_ps_get_opcode_name (walk_state->opcode));
245 216
217 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_0R",
218 acpi_ps_get_opcode_name(walk_state->opcode));
246 219
247 /* Examine the AML opcode */ 220 /* Examine the AML opcode */
248 221
249 switch (walk_state->opcode) { 222 switch (walk_state->opcode) {
250 case AML_LOAD_OP: 223 case AML_LOAD_OP:
251 224
252 status = acpi_ex_load_op (operand[0], operand[1], walk_state); 225 status = acpi_ex_load_op(operand[0], operand[1], walk_state);
253 break; 226 break;
254 227
255 default: /* Unknown opcode */ 228 default: /* Unknown opcode */
256 229
257 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));
258 walk_state->opcode));
259 status = AE_AML_BAD_OPCODE; 231 status = AE_AML_BAD_OPCODE;
260 goto cleanup; 232 goto cleanup;
261 } 233 }
262 234
235 cleanup:
263 236
264cleanup: 237 return_ACPI_STATUS(status);
265
266 return_ACPI_STATUS (status);
267} 238}
268 239
269
270/******************************************************************************* 240/*******************************************************************************
271 * 241 *
272 * FUNCTION: acpi_ex_opcode_1A_1T_1R 242 * FUNCTION: acpi_ex_opcode_1A_1T_1R
@@ -280,23 +250,19 @@ cleanup:
280 * 250 *
281 ******************************************************************************/ 251 ******************************************************************************/
282 252
283acpi_status 253acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
284acpi_ex_opcode_1A_1T_1R (
285 struct acpi_walk_state *walk_state)
286{ 254{
287 acpi_status status = AE_OK; 255 acpi_status status = AE_OK;
288 union acpi_operand_object **operand = &walk_state->operands[0]; 256 union acpi_operand_object **operand = &walk_state->operands[0];
289 union acpi_operand_object *return_desc = NULL; 257 union acpi_operand_object *return_desc = NULL;
290 union acpi_operand_object *return_desc2 = NULL; 258 union acpi_operand_object *return_desc2 = NULL;
291 u32 temp32; 259 u32 temp32;
292 u32 i; 260 u32 i;
293 acpi_integer power_of_ten; 261 acpi_integer power_of_ten;
294 acpi_integer digit; 262 acpi_integer digit;
295 263
296 264 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_1R",
297 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", 265 acpi_ps_get_opcode_name(walk_state->opcode));
298 acpi_ps_get_opcode_name (walk_state->opcode));
299
300 266
301 /* Examine the AML opcode */ 267 /* Examine the AML opcode */
302 268
@@ -310,20 +276,19 @@ acpi_ex_opcode_1A_1T_1R (
310 276
311 /* Create a return object of type Integer for these opcodes */ 277 /* Create a return object of type Integer for these opcodes */
312 278
313 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 279 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
314 if (!return_desc) { 280 if (!return_desc) {
315 status = AE_NO_MEMORY; 281 status = AE_NO_MEMORY;
316 goto cleanup; 282 goto cleanup;
317 } 283 }
318 284
319 switch (walk_state->opcode) { 285 switch (walk_state->opcode) {
320 case AML_BIT_NOT_OP: /* Not (Operand, Result) */ 286 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
321 287
322 return_desc->integer.value = ~operand[0]->integer.value; 288 return_desc->integer.value = ~operand[0]->integer.value;
323 break; 289 break;
324 290
325 291 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
326 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
327 292
328 return_desc->integer.value = operand[0]->integer.value; 293 return_desc->integer.value = operand[0]->integer.value;
329 294
@@ -332,15 +297,14 @@ acpi_ex_opcode_1A_1T_1R (
332 * endian unsigned value, so this boundary condition is valid. 297 * endian unsigned value, so this boundary condition is valid.
333 */ 298 */
334 for (temp32 = 0; return_desc->integer.value && 299 for (temp32 = 0; return_desc->integer.value &&
335 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { 300 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
336 return_desc->integer.value >>= 1; 301 return_desc->integer.value >>= 1;
337 } 302 }
338 303
339 return_desc->integer.value = temp32; 304 return_desc->integer.value = temp32;
340 break; 305 break;
341 306
342 307 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
343 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
344 308
345 return_desc->integer.value = operand[0]->integer.value; 309 return_desc->integer.value = operand[0]->integer.value;
346 310
@@ -349,18 +313,17 @@ acpi_ex_opcode_1A_1T_1R (
349 * endian unsigned value, so this boundary condition is valid. 313 * endian unsigned value, so this boundary condition is valid.
350 */ 314 */
351 for (temp32 = 0; return_desc->integer.value && 315 for (temp32 = 0; return_desc->integer.value &&
352 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { 316 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
353 return_desc->integer.value <<= 1; 317 return_desc->integer.value <<= 1;
354 } 318 }
355 319
356 /* Since the bit position is one-based, subtract from 33 (65) */ 320 /* Since the bit position is one-based, subtract from 33 (65) */
357 321
358 return_desc->integer.value = temp32 == 0 ? 0 : 322 return_desc->integer.value = temp32 == 0 ? 0 :
359 (ACPI_INTEGER_BIT_SIZE + 1) - temp32; 323 (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
360 break; 324 break;
361 325
362 326 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
363 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
364 327
365 /* 328 /*
366 * 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
@@ -373,7 +336,9 @@ acpi_ex_opcode_1A_1T_1R (
373 336
374 /* Convert each BCD digit (each is one nybble wide) */ 337 /* Convert each BCD digit (each is one nybble wide) */
375 338
376 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++) {
377 /* Get the least significant 4-bit BCD digit */ 342 /* Get the least significant 4-bit BCD digit */
378 343
379 temp32 = ((u32) digit) & 0xF; 344 temp32 = ((u32) digit) & 0xF;
@@ -381,9 +346,9 @@ acpi_ex_opcode_1A_1T_1R (
381 /* Check the range of the digit */ 346 /* Check the range of the digit */
382 347
383 if (temp32 > 9) { 348 if (temp32 > 9) {
384 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 349 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "BCD digit too large (not decimal): 0x%X\n", 350 "BCD digit too large (not decimal): 0x%X\n",
386 temp32)); 351 temp32));
387 352
388 status = AE_AML_NUMERIC_OVERFLOW; 353 status = AE_AML_NUMERIC_OVERFLOW;
389 goto cleanup; 354 goto cleanup;
@@ -391,8 +356,8 @@ acpi_ex_opcode_1A_1T_1R (
391 356
392 /* 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 */
393 358
394 return_desc->integer.value += (((acpi_integer) temp32) * 359 return_desc->integer.value +=
395 power_of_ten); 360 (((acpi_integer) temp32) * power_of_ten);
396 361
397 /* Shift to next BCD digit */ 362 /* Shift to next BCD digit */
398 363
@@ -404,45 +369,50 @@ acpi_ex_opcode_1A_1T_1R (
404 } 369 }
405 break; 370 break;
406 371
407 372 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
408 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
409 373
410 return_desc->integer.value = 0; 374 return_desc->integer.value = 0;
411 digit = operand[0]->integer.value; 375 digit = operand[0]->integer.value;
412 376
413 /* Each BCD digit is one nybble wide */ 377 /* Each BCD digit is one nybble wide */
414 378
415 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { 379 for (i = 0;
416 (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);
417 384
418 /* 385 /*
419 * Insert the BCD digit that resides in the 386 * Insert the BCD digit that resides in the
420 * remainder from above 387 * remainder from above
421 */ 388 */
422 return_desc->integer.value |= (((acpi_integer) temp32) << 389 return_desc->integer.value |=
423 ACPI_MUL_4 (i)); 390 (((acpi_integer) temp32) << ACPI_MUL_4(i));
424 } 391 }
425 392
426 /* Overflow if there is any data left in Digit */ 393 /* Overflow if there is any data left in Digit */
427 394
428 if (digit > 0) { 395 if (digit > 0) {
429 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
430 "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",
431 ACPI_FORMAT_UINT64 (operand[0]->integer.value))); 398 ACPI_FORMAT_UINT64(operand
399 [0]->
400 integer.
401 value)));
432 status = AE_AML_NUMERIC_OVERFLOW; 402 status = AE_AML_NUMERIC_OVERFLOW;
433 goto cleanup; 403 goto cleanup;
434 } 404 }
435 break; 405 break;
436 406
437 407 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
438 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
439 408
440 /* 409 /*
441 * 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
442 * different than the return value stored in the result descriptor 411 * different than the return value stored in the result descriptor
443 * (There are really two return values) 412 * (There are really two return values)
444 */ 413 */
445 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) { 414 if ((struct acpi_namespace_node *)operand[0] ==
415 acpi_gbl_root_node) {
446 /* 416 /*
447 * This means that the object does not exist in the namespace, 417 * This means that the object does not exist in the namespace,
448 * return FALSE 418 * return FALSE
@@ -453,38 +423,38 @@ acpi_ex_opcode_1A_1T_1R (
453 423
454 /* Get the object reference, store it, and remove our reference */ 424 /* Get the object reference, store it, and remove our reference */
455 425
456 status = acpi_ex_get_object_reference (operand[0], 426 status = acpi_ex_get_object_reference(operand[0],
457 &return_desc2, walk_state); 427 &return_desc2,
458 if (ACPI_FAILURE (status)) { 428 walk_state);
429 if (ACPI_FAILURE(status)) {
459 goto cleanup; 430 goto cleanup;
460 } 431 }
461 432
462 status = acpi_ex_store (return_desc2, operand[1], walk_state); 433 status =
463 acpi_ut_remove_reference (return_desc2); 434 acpi_ex_store(return_desc2, operand[1], walk_state);
435 acpi_ut_remove_reference(return_desc2);
464 436
465 /* The object exists in the namespace, return TRUE */ 437 /* The object exists in the namespace, return TRUE */
466 438
467 return_desc->integer.value = ACPI_INTEGER_MAX; 439 return_desc->integer.value = ACPI_INTEGER_MAX;
468 goto cleanup; 440 goto cleanup;
469 441
470
471 default: 442 default:
472 /* No other opcodes get here */ 443 /* No other opcodes get here */
473 break; 444 break;
474 } 445 }
475 break; 446 break;
476 447
477 448 case AML_STORE_OP: /* Store (Source, Target) */
478 case AML_STORE_OP: /* Store (Source, Target) */
479 449
480 /* 450 /*
481 * A store operand is typically a number, string, buffer or lvalue 451 * A store operand is typically a number, string, buffer or lvalue
482 * Be careful about deleting the source object, 452 * Be careful about deleting the source object,
483 * since the object itself may have been stored. 453 * since the object itself may have been stored.
484 */ 454 */
485 status = acpi_ex_store (operand[0], operand[1], walk_state); 455 status = acpi_ex_store(operand[0], operand[1], walk_state);
486 if (ACPI_FAILURE (status)) { 456 if (ACPI_FAILURE(status)) {
487 return_ACPI_STATUS (status); 457 return_ACPI_STATUS(status);
488 } 458 }
489 459
490 /* It is possible that the Store already produced a return object */ 460 /* It is possible that the Store already produced a return object */
@@ -497,92 +467,84 @@ acpi_ex_opcode_1A_1T_1R (
497 * cancel out, and we simply don't do anything. 467 * cancel out, and we simply don't do anything.
498 */ 468 */
499 walk_state->result_obj = operand[0]; 469 walk_state->result_obj = operand[0];
500 walk_state->operands[0] = NULL; /* Prevent deletion */ 470 walk_state->operands[0] = NULL; /* Prevent deletion */
501 } 471 }
502 return_ACPI_STATUS (status); 472 return_ACPI_STATUS(status);
503
504 473
505 /* 474 /*
506 * ACPI 2.0 Opcodes 475 * ACPI 2.0 Opcodes
507 */ 476 */
508 case AML_COPY_OP: /* Copy (Source, Target) */ 477 case AML_COPY_OP: /* Copy (Source, Target) */
509 478
510 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, 479 status =
511 walk_state); 480 acpi_ut_copy_iobject_to_iobject(operand[0], &return_desc,
481 walk_state);
512 break; 482 break;
513 483
484 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
514 485
515 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */ 486 status = acpi_ex_convert_to_string(operand[0], &return_desc,
516 487 ACPI_EXPLICIT_CONVERT_DECIMAL);
517 status = acpi_ex_convert_to_string (operand[0], &return_desc,
518 ACPI_EXPLICIT_CONVERT_DECIMAL);
519 if (return_desc == operand[0]) { 488 if (return_desc == operand[0]) {
520 /* No conversion performed, add ref to handle return value */ 489 /* No conversion performed, add ref to handle return value */
521 acpi_ut_add_reference (return_desc); 490 acpi_ut_add_reference(return_desc);
522 } 491 }
523 break; 492 break;
524 493
494 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
525 495
526 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */ 496 status = acpi_ex_convert_to_string(operand[0], &return_desc,
527 497 ACPI_EXPLICIT_CONVERT_HEX);
528 status = acpi_ex_convert_to_string (operand[0], &return_desc,
529 ACPI_EXPLICIT_CONVERT_HEX);
530 if (return_desc == operand[0]) { 498 if (return_desc == operand[0]) {
531 /* No conversion performed, add ref to handle return value */ 499 /* No conversion performed, add ref to handle return value */
532 acpi_ut_add_reference (return_desc); 500 acpi_ut_add_reference(return_desc);
533 } 501 }
534 break; 502 break;
535 503
504 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
536 505
537 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */ 506 status = acpi_ex_convert_to_buffer(operand[0], &return_desc);
538
539 status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
540 if (return_desc == operand[0]) { 507 if (return_desc == operand[0]) {
541 /* No conversion performed, add ref to handle return value */ 508 /* No conversion performed, add ref to handle return value */
542 acpi_ut_add_reference (return_desc); 509 acpi_ut_add_reference(return_desc);
543 } 510 }
544 break; 511 break;
545 512
513 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
546 514
547 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */ 515 status = acpi_ex_convert_to_integer(operand[0], &return_desc,
548 516 ACPI_ANY_BASE);
549 status = acpi_ex_convert_to_integer (operand[0], &return_desc,
550 ACPI_ANY_BASE);
551 if (return_desc == operand[0]) { 517 if (return_desc == operand[0]) {
552 /* No conversion performed, add ref to handle return value */ 518 /* No conversion performed, add ref to handle return value */
553 acpi_ut_add_reference (return_desc); 519 acpi_ut_add_reference(return_desc);
554 } 520 }
555 break; 521 break;
556 522
557 523 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
558 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) */
559 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
560 525
561 /* These are two obsolete opcodes */ 526 /* These are two obsolete opcodes */
562 527
563 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 528 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
564 "%s is obsolete and not implemented\n", 529 "%s is obsolete and not implemented\n",
565 acpi_ps_get_opcode_name (walk_state->opcode))); 530 acpi_ps_get_opcode_name(walk_state->opcode)));
566 status = AE_SUPPORT; 531 status = AE_SUPPORT;
567 goto cleanup; 532 goto cleanup;
568 533
534 default: /* Unknown opcode */
569 535
570 default: /* Unknown opcode */ 536 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode));
571
572 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
573 walk_state->opcode));
574 status = AE_AML_BAD_OPCODE; 537 status = AE_AML_BAD_OPCODE;
575 goto cleanup; 538 goto cleanup;
576 } 539 }
577 540
578 if (ACPI_SUCCESS (status)) { 541 if (ACPI_SUCCESS(status)) {
579 /* Store the return value computed above into the target object */ 542 /* Store the return value computed above into the target object */
580 543
581 status = acpi_ex_store (return_desc, operand[1], walk_state); 544 status = acpi_ex_store(return_desc, operand[1], walk_state);
582 } 545 }
583 546
584 547 cleanup:
585cleanup:
586 548
587 if (!walk_state->result_obj) { 549 if (!walk_state->result_obj) {
588 walk_state->result_obj = return_desc; 550 walk_state->result_obj = return_desc;
@@ -590,14 +552,13 @@ cleanup:
590 552
591 /* Delete return object on error */ 553 /* Delete return object on error */
592 554
593 if (ACPI_FAILURE (status)) { 555 if (ACPI_FAILURE(status)) {
594 acpi_ut_remove_reference (return_desc); 556 acpi_ut_remove_reference(return_desc);
595 } 557 }
596 558
597 return_ACPI_STATUS (status); 559 return_ACPI_STATUS(status);
598} 560}
599 561
600
601/******************************************************************************* 562/*******************************************************************************
602 * 563 *
603 * FUNCTION: acpi_ex_opcode_1A_0T_1R 564 * FUNCTION: acpi_ex_opcode_1A_0T_1R
@@ -610,28 +571,24 @@ cleanup:
610 * 571 *
611 ******************************************************************************/ 572 ******************************************************************************/
612 573
613acpi_status 574acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
614acpi_ex_opcode_1A_0T_1R (
615 struct acpi_walk_state *walk_state)
616{ 575{
617 union acpi_operand_object **operand = &walk_state->operands[0]; 576 union acpi_operand_object **operand = &walk_state->operands[0];
618 union acpi_operand_object *temp_desc; 577 union acpi_operand_object *temp_desc;
619 union acpi_operand_object *return_desc = NULL; 578 union acpi_operand_object *return_desc = NULL;
620 acpi_status status = AE_OK; 579 acpi_status status = AE_OK;
621 u32 type; 580 u32 type;
622 acpi_integer value; 581 acpi_integer value;
623
624
625 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
626 acpi_ps_get_opcode_name (walk_state->opcode));
627 582
583 ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_1R",
584 acpi_ps_get_opcode_name(walk_state->opcode));
628 585
629 /* Examine the AML opcode */ 586 /* Examine the AML opcode */
630 587
631 switch (walk_state->opcode) { 588 switch (walk_state->opcode) {
632 case AML_LNOT_OP: /* LNot (Operand) */ 589 case AML_LNOT_OP: /* LNot (Operand) */
633 590
634 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 591 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
635 if (!return_desc) { 592 if (!return_desc) {
636 status = AE_NO_MEMORY; 593 status = AE_NO_MEMORY;
637 goto cleanup; 594 goto cleanup;
@@ -646,15 +603,14 @@ acpi_ex_opcode_1A_0T_1R (
646 } 603 }
647 break; 604 break;
648 605
649 606 case AML_DECREMENT_OP: /* Decrement (Operand) */
650 case AML_DECREMENT_OP: /* Decrement (Operand) */ 607 case AML_INCREMENT_OP: /* Increment (Operand) */
651 case AML_INCREMENT_OP: /* Increment (Operand) */
652 608
653 /* 609 /*
654 * 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
655 * increment it because it may be an Arg or Field. 611 * increment it because it may be an Arg or Field.
656 */ 612 */
657 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 613 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
658 if (!return_desc) { 614 if (!return_desc) {
659 status = AE_NO_MEMORY; 615 status = AE_NO_MEMORY;
660 goto cleanup; 616 goto cleanup;
@@ -665,10 +621,11 @@ acpi_ex_opcode_1A_0T_1R (
665 * NS Node or an internal object. 621 * NS Node or an internal object.
666 */ 622 */
667 temp_desc = operand[0]; 623 temp_desc = operand[0];
668 if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) { 624 if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) ==
625 ACPI_DESC_TYPE_OPERAND) {
669 /* Internal reference object - prevent deletion */ 626 /* Internal reference object - prevent deletion */
670 627
671 acpi_ut_add_reference (temp_desc); 628 acpi_ut_add_reference(temp_desc);
672 } 629 }
673 630
674 /* 631 /*
@@ -678,11 +635,15 @@ acpi_ex_opcode_1A_0T_1R (
678 * 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
679 * reference operand to an actual integer. 636 * reference operand to an actual integer.
680 */ 637 */
681 status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state); 638 status =
682 if (ACPI_FAILURE (status)) { 639 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc,
683 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", 640 walk_state);
684 acpi_ps_get_opcode_name (walk_state->opcode), 641 if (ACPI_FAILURE(status)) {
685 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)));
686 647
687 goto cleanup; 648 goto cleanup;
688 } 649 }
@@ -692,25 +653,25 @@ acpi_ex_opcode_1A_0T_1R (
692 * Perform the actual increment or decrement 653 * Perform the actual increment or decrement
693 */ 654 */
694 if (walk_state->opcode == AML_INCREMENT_OP) { 655 if (walk_state->opcode == AML_INCREMENT_OP) {
695 return_desc->integer.value = temp_desc->integer.value +1; 656 return_desc->integer.value =
696 } 657 temp_desc->integer.value + 1;
697 else { 658 } else {
698 return_desc->integer.value = temp_desc->integer.value -1; 659 return_desc->integer.value =
660 temp_desc->integer.value - 1;
699 } 661 }
700 662
701 /* Finished with this Integer object */ 663 /* Finished with this Integer object */
702 664
703 acpi_ut_remove_reference (temp_desc); 665 acpi_ut_remove_reference(temp_desc);
704 666
705 /* 667 /*
706 * Store the result back (indirectly) through the original 668 * Store the result back (indirectly) through the original
707 * Reference object 669 * Reference object
708 */ 670 */
709 status = acpi_ex_store (return_desc, operand[0], walk_state); 671 status = acpi_ex_store(return_desc, operand[0], walk_state);
710 break; 672 break;
711 673
712 674 case AML_TYPE_OP: /* object_type (source_object) */
713 case AML_TYPE_OP: /* object_type (source_object) */
714 675
715 /* 676 /*
716 * 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
@@ -721,13 +682,15 @@ acpi_ex_opcode_1A_0T_1R (
721 682
722 /* Get the type of the base object */ 683 /* Get the type of the base object */
723 684
724 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL); 685 status =
725 if (ACPI_FAILURE (status)) { 686 acpi_ex_resolve_multiple(walk_state, operand[0], &type,
687 NULL);
688 if (ACPI_FAILURE(status)) {
726 goto cleanup; 689 goto cleanup;
727 } 690 }
728 /* Allocate a descriptor to hold the type. */ 691 /* Allocate a descriptor to hold the type. */
729 692
730 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 693 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
731 if (!return_desc) { 694 if (!return_desc) {
732 status = AE_NO_MEMORY; 695 status = AE_NO_MEMORY;
733 goto cleanup; 696 goto cleanup;
@@ -736,8 +699,7 @@ acpi_ex_opcode_1A_0T_1R (
736 return_desc->integer.value = type; 699 return_desc->integer.value = type;
737 break; 700 break;
738 701
739 702 case AML_SIZE_OF_OP: /* size_of (source_object) */
740 case AML_SIZE_OF_OP: /* size_of (source_object) */
741 703
742 /* 704 /*
743 * 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
@@ -746,9 +708,10 @@ acpi_ex_opcode_1A_0T_1R (
746 708
747 /* Get the base object */ 709 /* Get the base object */
748 710
749 status = acpi_ex_resolve_multiple (walk_state, 711 status = acpi_ex_resolve_multiple(walk_state,
750 operand[0], &type, &temp_desc); 712 operand[0], &type,
751 if (ACPI_FAILURE (status)) { 713 &temp_desc);
714 if (ACPI_FAILURE(status)) {
752 goto cleanup; 715 goto cleanup;
753 } 716 }
754 717
@@ -779,9 +742,9 @@ acpi_ex_opcode_1A_0T_1R (
779 break; 742 break;
780 743
781 default: 744 default:
782 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 745 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
783 "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",
784 acpi_ut_get_type_name (type))); 747 acpi_ut_get_type_name(type)));
785 status = AE_AML_OPERAND_TYPE; 748 status = AE_AML_OPERAND_TYPE;
786 goto cleanup; 749 goto cleanup;
787 } 750 }
@@ -790,7 +753,7 @@ acpi_ex_opcode_1A_0T_1R (
790 * 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
791 * object to hold the value 754 * object to hold the value
792 */ 755 */
793 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 756 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
794 if (!return_desc) { 757 if (!return_desc) {
795 status = AE_NO_MEMORY; 758 status = AE_NO_MEMORY;
796 goto cleanup; 759 goto cleanup;
@@ -799,22 +762,23 @@ acpi_ex_opcode_1A_0T_1R (
799 return_desc->integer.value = value; 762 return_desc->integer.value = value;
800 break; 763 break;
801 764
765 case AML_REF_OF_OP: /* ref_of (source_object) */
802 766
803 case AML_REF_OF_OP: /* ref_of (source_object) */ 767 status =
804 768 acpi_ex_get_object_reference(operand[0], &return_desc,
805 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state); 769 walk_state);
806 if (ACPI_FAILURE (status)) { 770 if (ACPI_FAILURE(status)) {
807 goto cleanup; 771 goto cleanup;
808 } 772 }
809 break; 773 break;
810 774
811 775 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
812 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
813 776
814 /* Check for a method local or argument, or standalone String */ 777 /* Check for a method local or argument, or standalone String */
815 778
816 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) { 779 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
817 switch (ACPI_GET_OBJECT_TYPE (operand[0])) { 780 ACPI_DESC_TYPE_NAMED) {
781 switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
818 case ACPI_TYPE_LOCAL_REFERENCE: 782 case ACPI_TYPE_LOCAL_REFERENCE:
819 /* 783 /*
820 * This is a deref_of (local_x | arg_x) 784 * This is a deref_of (local_x | arg_x)
@@ -827,11 +791,12 @@ acpi_ex_opcode_1A_0T_1R (
827 791
828 /* Set Operand[0] to the value of the local/arg */ 792 /* Set Operand[0] to the value of the local/arg */
829 793
830 status = acpi_ds_method_data_get_value ( 794 status =
831 operand[0]->reference.opcode, 795 acpi_ds_method_data_get_value
832 operand[0]->reference.offset, 796 (operand[0]->reference.opcode,
833 walk_state, &temp_desc); 797 operand[0]->reference.offset,
834 if (ACPI_FAILURE (status)) { 798 walk_state, &temp_desc);
799 if (ACPI_FAILURE(status)) {
835 goto cleanup; 800 goto cleanup;
836 } 801 }
837 802
@@ -839,7 +804,7 @@ acpi_ex_opcode_1A_0T_1R (
839 * Delete our reference to the input object and 804 * Delete our reference to the input object and
840 * point to the object just retrieved 805 * point to the object just retrieved
841 */ 806 */
842 acpi_ut_remove_reference (operand[0]); 807 acpi_ut_remove_reference(operand[0]);
843 operand[0] = temp_desc; 808 operand[0] = temp_desc;
844 break; 809 break;
845 810
@@ -847,8 +812,9 @@ acpi_ex_opcode_1A_0T_1R (
847 812
848 /* Get the object to which the reference refers */ 813 /* Get the object to which the reference refers */
849 814
850 temp_desc = operand[0]->reference.object; 815 temp_desc =
851 acpi_ut_remove_reference (operand[0]); 816 operand[0]->reference.object;
817 acpi_ut_remove_reference(operand[0]);
852 operand[0] = temp_desc; 818 operand[0] = temp_desc;
853 break; 819 break;
854 820
@@ -859,7 +825,6 @@ acpi_ex_opcode_1A_0T_1R (
859 } 825 }
860 break; 826 break;
861 827
862
863 case ACPI_TYPE_STRING: 828 case ACPI_TYPE_STRING:
864 829
865 /* 830 /*
@@ -870,22 +835,28 @@ acpi_ex_opcode_1A_0T_1R (
870 * 2) Dereference the node to an actual object. Could be a 835 * 2) Dereference the node to an actual object. Could be a
871 * Field, so we need to resolve the node to a value. 836 * Field, so we need to resolve the node to a value.
872 */ 837 */
873 status = acpi_ns_get_node_by_path (operand[0]->string.pointer, 838 status =
874 walk_state->scope_info->scope.node, 839 acpi_ns_get_node_by_path(operand[0]->string.
875 ACPI_NS_SEARCH_PARENT, 840 pointer,
876 ACPI_CAST_INDIRECT_PTR ( 841 walk_state->
877 struct acpi_namespace_node, &return_desc)); 842 scope_info->scope.
878 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)) {
879 goto cleanup; 850 goto cleanup;
880 } 851 }
881 852
882 status = acpi_ex_resolve_node_to_value ( 853 status =
883 ACPI_CAST_INDIRECT_PTR ( 854 acpi_ex_resolve_node_to_value
884 struct acpi_namespace_node, &return_desc), 855 (ACPI_CAST_INDIRECT_PTR
885 walk_state); 856 (struct acpi_namespace_node, &return_desc),
857 walk_state);
886 goto cleanup; 858 goto cleanup;
887 859
888
889 default: 860 default:
890 861
891 status = AE_AML_OPERAND_TYPE; 862 status = AE_AML_OPERAND_TYPE;
@@ -895,18 +866,20 @@ acpi_ex_opcode_1A_0T_1R (
895 866
896 /* Operand[0] may have changed from the code above */ 867 /* Operand[0] may have changed from the code above */
897 868
898 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) { 869 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) ==
870 ACPI_DESC_TYPE_NAMED) {
899 /* 871 /*
900 * This is a deref_of (object_reference) 872 * This is a deref_of (object_reference)
901 * Get the actual object from the Node (This is the dereference). 873 * Get the actual object from the Node (This is the dereference).
902 * 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
903 * dereferenced above. 875 * dereferenced above.
904 */ 876 */
905 return_desc = acpi_ns_get_attached_object ( 877 return_desc = acpi_ns_get_attached_object((struct
906 (struct acpi_namespace_node *) operand[0]); 878 acpi_namespace_node
907 acpi_ut_add_reference (return_desc); 879 *)
908 } 880 operand[0]);
909 else { 881 acpi_ut_add_reference(return_desc);
882 } else {
910 /* 883 /*
911 * This must be a reference object produced by either the 884 * This must be a reference object produced by either the
912 * Index() or ref_of() operator 885 * Index() or ref_of() operator
@@ -921,7 +894,8 @@ acpi_ex_opcode_1A_0T_1R (
921 switch (operand[0]->reference.target_type) { 894 switch (operand[0]->reference.target_type) {
922 case ACPI_TYPE_BUFFER_FIELD: 895 case ACPI_TYPE_BUFFER_FIELD:
923 896
924 temp_desc = operand[0]->reference.object; 897 temp_desc =
898 operand[0]->reference.object;
925 899
926 /* 900 /*
927 * Create a new object that contains one element of the 901 * Create a new object that contains one element of the
@@ -931,7 +905,9 @@ acpi_ex_opcode_1A_0T_1R (
931 * 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
932 * single element (byte) of the buffer! 906 * single element (byte) of the buffer!
933 */ 907 */
934 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 908 return_desc =
909 acpi_ut_create_internal_object
910 (ACPI_TYPE_INTEGER);
935 if (!return_desc) { 911 if (!return_desc) {
936 status = AE_NO_MEMORY; 912 status = AE_NO_MEMORY;
937 goto cleanup; 913 goto cleanup;
@@ -943,56 +919,63 @@ acpi_ex_opcode_1A_0T_1R (
943 * reference to the buffer itself. 919 * reference to the buffer itself.
944 */ 920 */
945 return_desc->integer.value = 921 return_desc->integer.value =
946 temp_desc->buffer.pointer[operand[0]->reference.offset]; 922 temp_desc->buffer.
923 pointer[operand[0]->reference.
924 offset];
947 break; 925 break;
948 926
949
950 case ACPI_TYPE_PACKAGE: 927 case ACPI_TYPE_PACKAGE:
951 928
952 /* 929 /*
953 * Return the referenced element of the package. We must 930 * Return the referenced element of the package. We must
954 * add another reference to the referenced object, however. 931 * add another reference to the referenced object, however.
955 */ 932 */
956 return_desc = *(operand[0]->reference.where); 933 return_desc =
934 *(operand[0]->reference.where);
957 if (return_desc) { 935 if (return_desc) {
958 acpi_ut_add_reference (return_desc); 936 acpi_ut_add_reference
937 (return_desc);
959 } 938 }
960 939
961 break; 940 break;
962 941
963
964 default: 942 default:
965 943
966 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 944 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
967 "Unknown Index target_type %X in obj %p\n", 945 "Unknown Index target_type %X in obj %p\n",
968 operand[0]->reference.target_type, operand[0])); 946 operand[0]->reference.
947 target_type,
948 operand[0]));
969 status = AE_AML_OPERAND_TYPE; 949 status = AE_AML_OPERAND_TYPE;
970 goto cleanup; 950 goto cleanup;
971 } 951 }
972 break; 952 break;
973 953
974
975 case AML_REF_OF_OP: 954 case AML_REF_OF_OP:
976 955
977 return_desc = operand[0]->reference.object; 956 return_desc = operand[0]->reference.object;
978 957
979 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == 958 if (ACPI_GET_DESCRIPTOR_TYPE(return_desc) ==
980 ACPI_DESC_TYPE_NAMED) { 959 ACPI_DESC_TYPE_NAMED) {
981 960
982 return_desc = acpi_ns_get_attached_object ( 961 return_desc =
983 (struct acpi_namespace_node *) return_desc); 962 acpi_ns_get_attached_object((struct
963 acpi_namespace_node
964 *)
965 return_desc);
984 } 966 }
985 967
986 /* Add another reference to the object! */ 968 /* Add another reference to the object! */
987 969
988 acpi_ut_add_reference (return_desc); 970 acpi_ut_add_reference(return_desc);
989 break; 971 break;
990 972
991
992 default: 973 default:
993 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 974 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
994 "Unknown opcode in ref(%p) - %X\n", 975 "Unknown opcode in ref(%p) - %X\n",
995 operand[0], operand[0]->reference.opcode)); 976 operand[0],
977 operand[0]->reference.
978 opcode));
996 979
997 status = AE_TYPE; 980 status = AE_TYPE;
998 goto cleanup; 981 goto cleanup;
@@ -1000,25 +983,21 @@ acpi_ex_opcode_1A_0T_1R (
1000 } 983 }
1001 break; 984 break;
1002 985
1003
1004 default: 986 default:
1005 987
1006 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));
1007 walk_state->opcode));
1008 status = AE_AML_BAD_OPCODE; 989 status = AE_AML_BAD_OPCODE;
1009 goto cleanup; 990 goto cleanup;
1010 } 991 }
1011 992
1012 993 cleanup:
1013cleanup:
1014 994
1015 /* Delete return object on error */ 995 /* Delete return object on error */
1016 996
1017 if (ACPI_FAILURE (status)) { 997 if (ACPI_FAILURE(status)) {
1018 acpi_ut_remove_reference (return_desc); 998 acpi_ut_remove_reference(return_desc);
1019 } 999 }
1020 1000
1021 walk_state->result_obj = return_desc; 1001 walk_state->result_obj = return_desc;
1022 return_ACPI_STATUS (status); 1002 return_ACPI_STATUS(status);
1023} 1003}
1024
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 197890f443b5..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 = NULL; 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;
@@ -201,17 +185,17 @@ acpi_ex_opcode_3A_1T_1R (
201 185
202 else if ((index + length) > operand[0]->string.length) { 186 else if ((index + length) > operand[0]->string.length) {
203 length = (acpi_size) operand[0]->string.length - 187 length = (acpi_size) operand[0]->string.length -
204 (acpi_size) index; 188 (acpi_size) index;
205 } 189 }
206 190
207 /* Strings always have a sub-pointer, not so for buffers */ 191 /* Strings always have a sub-pointer, not so for buffers */
208 192
209 switch (ACPI_GET_OBJECT_TYPE (operand[0])) { 193 switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
210 case ACPI_TYPE_STRING: 194 case ACPI_TYPE_STRING:
211 195
212 /* Always allocate a new buffer for the String */ 196 /* Always allocate a new buffer for the String */
213 197
214 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 198 buffer = ACPI_MEM_CALLOCATE((acpi_size) length + 1);
215 if (!buffer) { 199 if (!buffer) {
216 status = AE_NO_MEMORY; 200 status = AE_NO_MEMORY;
217 goto cleanup; 201 goto cleanup;
@@ -225,7 +209,7 @@ acpi_ex_opcode_3A_1T_1R (
225 if (length > 0) { 209 if (length > 0) {
226 /* Allocate a new buffer for the Buffer */ 210 /* Allocate a new buffer for the Buffer */
227 211
228 buffer = ACPI_MEM_CALLOCATE (length); 212 buffer = ACPI_MEM_CALLOCATE(length);
229 if (!buffer) { 213 if (!buffer) {
230 status = AE_NO_MEMORY; 214 status = AE_NO_MEMORY;
231 goto cleanup; 215 goto cleanup;
@@ -233,7 +217,7 @@ acpi_ex_opcode_3A_1T_1R (
233 } 217 }
234 break; 218 break;
235 219
236 default: /* Should not happen */ 220 default: /* Should not happen */
237 221
238 status = AE_AML_OPERAND_TYPE; 222 status = AE_AML_OPERAND_TYPE;
239 goto cleanup; 223 goto cleanup;
@@ -242,8 +226,8 @@ acpi_ex_opcode_3A_1T_1R (
242 if (length > 0) { 226 if (length > 0) {
243 /* Copy the portion requested */ 227 /* Copy the portion requested */
244 228
245 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, 229 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
246 length); 230 length);
247 } 231 }
248 232
249 /* Set the length of the new String/Buffer */ 233 /* Set the length of the new String/Buffer */
@@ -256,25 +240,23 @@ acpi_ex_opcode_3A_1T_1R (
256 return_desc->buffer.flags |= AOPOBJ_DATA_VALID; 240 return_desc->buffer.flags |= AOPOBJ_DATA_VALID;
257 break; 241 break;
258 242
259
260 default: 243 default:
261 244
262 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));
263 walk_state->opcode));
264 status = AE_AML_BAD_OPCODE; 246 status = AE_AML_BAD_OPCODE;
265 goto cleanup; 247 goto cleanup;
266 } 248 }
267 249
268 /* Store the result in the target */ 250 /* Store the result in the target */
269 251
270 status = acpi_ex_store (return_desc, operand[3], walk_state); 252 status = acpi_ex_store(return_desc, operand[3], walk_state);
271 253
272cleanup: 254 cleanup:
273 255
274 /* Delete return object on error */ 256 /* Delete return object on error */
275 257
276 if (ACPI_FAILURE (status) || walk_state->result_obj) { 258 if (ACPI_FAILURE(status) || walk_state->result_obj) {
277 acpi_ut_remove_reference (return_desc); 259 acpi_ut_remove_reference(return_desc);
278 } 260 }
279 261
280 /* Set the return object and exit */ 262 /* Set the return object and exit */
@@ -282,7 +264,5 @@ cleanup:
282 else { 264 else {
283 walk_state->result_obj = return_desc; 265 walk_state->result_obj = return_desc;
284 } 266 }
285 return_ACPI_STATUS (status); 267 return_ACPI_STATUS(status);
286} 268}
287
288
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 aaba7abcb52d..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,25 +413,27 @@ 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 431
430 if (obj_desc != *stack_ptr) { 432 if (obj_desc != *stack_ptr) {
431 acpi_ut_remove_reference (obj_desc); 433 acpi_ut_remove_reference(obj_desc);
432 } 434 }
433 goto next_operand; 435 goto next_operand;
434 436
435
436 case ARGI_BUFFER: 437 case ARGI_BUFFER:
437 438
438 /* 439 /*
@@ -440,25 +441,26 @@ acpi_ex_resolve_operands (
440 * But we can implicitly convert from a STRING or INTEGER 441 * But we can implicitly convert from a STRING or INTEGER
441 * Aka - "Implicit Source Operand Conversion" 442 * Aka - "Implicit Source Operand Conversion"
442 */ 443 */
443 status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); 444 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
444 if (ACPI_FAILURE (status)) { 445 if (ACPI_FAILURE(status)) {
445 if (status == AE_TYPE) { 446 if (status == AE_TYPE) {
446 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 447 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
447 "Needed [Integer/String/Buffer], found [%s] %p\n", 448 "Needed [Integer/String/Buffer], found [%s] %p\n",
448 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 449 acpi_ut_get_object_type_name
450 (obj_desc),
451 obj_desc));
449 452
450 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 453 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
451 } 454 }
452 455
453 return_ACPI_STATUS (status); 456 return_ACPI_STATUS(status);
454 } 457 }
455 458
456 if (obj_desc != *stack_ptr) { 459 if (obj_desc != *stack_ptr) {
457 acpi_ut_remove_reference (obj_desc); 460 acpi_ut_remove_reference(obj_desc);
458 } 461 }
459 goto next_operand; 462 goto next_operand;
460 463
461
462 case ARGI_STRING: 464 case ARGI_STRING:
463 465
464 /* 466 /*
@@ -466,83 +468,86 @@ acpi_ex_resolve_operands (
466 * But we can implicitly convert from a BUFFER or INTEGER 468 * But we can implicitly convert from a BUFFER or INTEGER
467 * Aka - "Implicit Source Operand Conversion" 469 * Aka - "Implicit Source Operand Conversion"
468 */ 470 */
469 status = acpi_ex_convert_to_string (obj_desc, stack_ptr, 471 status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
470 ACPI_IMPLICIT_CONVERT_HEX); 472 ACPI_IMPLICIT_CONVERT_HEX);
471 if (ACPI_FAILURE (status)) { 473 if (ACPI_FAILURE(status)) {
472 if (status == AE_TYPE) { 474 if (status == AE_TYPE) {
473 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 475 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
474 "Needed [Integer/String/Buffer], found [%s] %p\n", 476 "Needed [Integer/String/Buffer], found [%s] %p\n",
475 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 477 acpi_ut_get_object_type_name
478 (obj_desc),
479 obj_desc));
476 480
477 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 481 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
478 } 482 }
479 483
480 return_ACPI_STATUS (status); 484 return_ACPI_STATUS(status);
481 } 485 }
482 486
483 if (obj_desc != *stack_ptr) { 487 if (obj_desc != *stack_ptr) {
484 acpi_ut_remove_reference (obj_desc); 488 acpi_ut_remove_reference(obj_desc);
485 } 489 }
486 goto next_operand; 490 goto next_operand;
487 491
488
489 case ARGI_COMPUTEDATA: 492 case ARGI_COMPUTEDATA:
490 493
491 /* Need an operand of type INTEGER, STRING or BUFFER */ 494 /* Need an operand of type INTEGER, STRING or BUFFER */
492 495
493 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 496 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
494 case ACPI_TYPE_INTEGER: 497 case ACPI_TYPE_INTEGER:
495 case ACPI_TYPE_STRING: 498 case ACPI_TYPE_STRING:
496 case ACPI_TYPE_BUFFER: 499 case ACPI_TYPE_BUFFER:
497 500
498 /* Valid operand */ 501 /* Valid operand */
499 break; 502 break;
500 503
501 default: 504 default:
502 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
503 "Needed [Integer/String/Buffer], found [%s] %p\n", 506 "Needed [Integer/String/Buffer], found [%s] %p\n",
504 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 507 acpi_ut_get_object_type_name
508 (obj_desc), obj_desc));
505 509
506 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 510 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
507 } 511 }
508 goto next_operand; 512 goto next_operand;
509 513
510
511 case ARGI_BUFFER_OR_STRING: 514 case ARGI_BUFFER_OR_STRING:
512 515
513 /* Need an operand of type STRING or BUFFER */ 516 /* Need an operand of type STRING or BUFFER */
514 517
515 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 518 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
516 case ACPI_TYPE_STRING: 519 case ACPI_TYPE_STRING:
517 case ACPI_TYPE_BUFFER: 520 case ACPI_TYPE_BUFFER:
518 521
519 /* Valid operand */ 522 /* Valid operand */
520 break; 523 break;
521 524
522 case ACPI_TYPE_INTEGER: 525 case ACPI_TYPE_INTEGER:
523 526
524 /* Highest priority conversion is to type Buffer */ 527 /* Highest priority conversion is to type Buffer */
525 528
526 status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); 529 status =
527 if (ACPI_FAILURE (status)) { 530 acpi_ex_convert_to_buffer(obj_desc,
528 return_ACPI_STATUS (status); 531 stack_ptr);
532 if (ACPI_FAILURE(status)) {
533 return_ACPI_STATUS(status);
529 } 534 }
530 535
531 if (obj_desc != *stack_ptr) { 536 if (obj_desc != *stack_ptr) {
532 acpi_ut_remove_reference (obj_desc); 537 acpi_ut_remove_reference(obj_desc);
533 } 538 }
534 break; 539 break;
535 540
536 default: 541 default:
537 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 542 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
538 "Needed [Integer/String/Buffer], found [%s] %p\n", 543 "Needed [Integer/String/Buffer], found [%s] %p\n",
539 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 544 acpi_ut_get_object_type_name
545 (obj_desc), obj_desc));
540 546
541 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 547 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
542 } 548 }
543 goto next_operand; 549 goto next_operand;
544 550
545
546 case ARGI_DATAOBJECT: 551 case ARGI_DATAOBJECT:
547 /* 552 /*
548 * ARGI_DATAOBJECT is only used by the size_of operator. 553 * ARGI_DATAOBJECT is only used by the size_of operator.
@@ -551,7 +556,7 @@ acpi_ex_resolve_operands (
551 * The only reference allowed here is a direct reference to 556 * The only reference allowed here is a direct reference to
552 * a namespace node. 557 * a namespace node.
553 */ 558 */
554 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 559 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
555 case ACPI_TYPE_PACKAGE: 560 case ACPI_TYPE_PACKAGE:
556 case ACPI_TYPE_STRING: 561 case ACPI_TYPE_STRING:
557 case ACPI_TYPE_BUFFER: 562 case ACPI_TYPE_BUFFER:
@@ -561,20 +566,20 @@ acpi_ex_resolve_operands (
561 break; 566 break;
562 567
563 default: 568 default:
564 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 569 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
565 "Needed [Buffer/String/Package/Reference], found [%s] %p\n", 570 "Needed [Buffer/String/Package/Reference], found [%s] %p\n",
566 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 571 acpi_ut_get_object_type_name
572 (obj_desc), obj_desc));
567 573
568 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 574 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
569 } 575 }
570 goto next_operand; 576 goto next_operand;
571 577
572
573 case ARGI_COMPLEXOBJ: 578 case ARGI_COMPLEXOBJ:
574 579
575 /* Need a buffer or package or (ACPI 2.0) String */ 580 /* Need a buffer or package or (ACPI 2.0) String */
576 581
577 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 582 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
578 case ACPI_TYPE_PACKAGE: 583 case ACPI_TYPE_PACKAGE:
579 case ACPI_TYPE_STRING: 584 case ACPI_TYPE_STRING:
580 case ACPI_TYPE_BUFFER: 585 case ACPI_TYPE_BUFFER:
@@ -583,20 +588,20 @@ acpi_ex_resolve_operands (
583 break; 588 break;
584 589
585 default: 590 default:
586 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 591 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
587 "Needed [Buffer/String/Package], found [%s] %p\n", 592 "Needed [Buffer/String/Package], found [%s] %p\n",
588 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 593 acpi_ut_get_object_type_name
594 (obj_desc), obj_desc));
589 595
590 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 596 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
591 } 597 }
592 goto next_operand; 598 goto next_operand;
593 599
594
595 case ARGI_REGION_OR_FIELD: 600 case ARGI_REGION_OR_FIELD:
596 601
597 /* 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 */
598 603
599 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 604 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
600 case ACPI_TYPE_REGION: 605 case ACPI_TYPE_REGION:
601 case ACPI_TYPE_LOCAL_REGION_FIELD: 606 case ACPI_TYPE_LOCAL_REGION_FIELD:
602 case ACPI_TYPE_LOCAL_BANK_FIELD: 607 case ACPI_TYPE_LOCAL_BANK_FIELD:
@@ -606,20 +611,20 @@ acpi_ex_resolve_operands (
606 break; 611 break;
607 612
608 default: 613 default:
609 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
610 "Needed [Region/region_field], found [%s] %p\n", 615 "Needed [Region/region_field], found [%s] %p\n",
611 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 616 acpi_ut_get_object_type_name
617 (obj_desc), obj_desc));
612 618
613 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 619 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
614 } 620 }
615 goto next_operand; 621 goto next_operand;
616 622
617
618 case ARGI_DATAREFOBJ: 623 case ARGI_DATAREFOBJ:
619 624
620 /* Used by the Store() operator only */ 625 /* Used by the Store() operator only */
621 626
622 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 627 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
623 case ACPI_TYPE_INTEGER: 628 case ACPI_TYPE_INTEGER:
624 case ACPI_TYPE_PACKAGE: 629 case ACPI_TYPE_PACKAGE:
625 case ACPI_TYPE_STRING: 630 case ACPI_TYPE_STRING:
@@ -651,47 +656,46 @@ acpi_ex_resolve_operands (
651 break; 656 break;
652 } 657 }
653 658
654 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 659 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
655 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", 660 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
656 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 661 acpi_ut_get_object_type_name
662 (obj_desc), obj_desc));
657 663
658 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 664 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
659 } 665 }
660 goto next_operand; 666 goto next_operand;
661 667
662
663 default: 668 default:
664 669
665 /* Unknown type */ 670 /* Unknown type */
666 671
667 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
668 "Internal - Unknown ARGI (required operand) type %X\n", 673 "Internal - Unknown ARGI (required operand) type %X\n",
669 this_arg_type)); 674 this_arg_type));
670 675
671 return_ACPI_STATUS (AE_BAD_PARAMETER); 676 return_ACPI_STATUS(AE_BAD_PARAMETER);
672 } 677 }
673 678
674 /* 679 /*
675 * Make sure that the original object was resolved to the 680 * Make sure that the original object was resolved to the
676 * required object type (Simple cases only). 681 * required object type (Simple cases only).
677 */ 682 */
678 status = acpi_ex_check_object_type (type_needed, 683 status = acpi_ex_check_object_type(type_needed,
679 ACPI_GET_OBJECT_TYPE (*stack_ptr), *stack_ptr); 684 ACPI_GET_OBJECT_TYPE
680 if (ACPI_FAILURE (status)) { 685 (*stack_ptr), *stack_ptr);
681 return_ACPI_STATUS (status); 686 if (ACPI_FAILURE(status)) {
687 return_ACPI_STATUS(status);
682 } 688 }
683 689
684next_operand: 690 next_operand:
685 /* 691 /*
686 * If more operands needed, decrement stack_ptr to point 692 * If more operands needed, decrement stack_ptr to point
687 * to next operand on stack 693 * to next operand on stack
688 */ 694 */
689 if (GET_CURRENT_ARG_TYPE (arg_types)) { 695 if (GET_CURRENT_ARG_TYPE(arg_types)) {
690 stack_ptr--; 696 stack_ptr--;
691 } 697 }
692 } 698 }
693 699
694 return_ACPI_STATUS (status); 700 return_ACPI_STATUS(status);
695} 701}
696
697
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 59dbfeaa54c0..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]\n", 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,37 +539,35 @@ 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 */
@@ -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) with 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 433588ab432a..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,38 +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 status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); 268 status =
269 acpi_ex_store_buffer_to_buffer(actual_src_desc, dest_desc);
269 break; 270 break;
270 271
271 case ACPI_TYPE_PACKAGE: 272 case ACPI_TYPE_PACKAGE:
272 273
273 status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc, 274 status =
274 walk_state); 275 acpi_ut_copy_iobject_to_iobject(actual_src_desc, &dest_desc,
276 walk_state);
275 break; 277 break;
276 278
277 default: 279 default:
278 /* 280 /*
279 * All other types come here. 281 * All other types come here.
280 */ 282 */
281 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", 283 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
282 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)));
283 286
284 status = AE_NOT_IMPLEMENTED; 287 status = AE_NOT_IMPLEMENTED;
285 break; 288 break;
@@ -288,11 +291,9 @@ acpi_ex_store_object_to_object (
288 if (actual_src_desc != source_desc) { 291 if (actual_src_desc != source_desc) {
289 /* Delete the intermediate (temporary) source object */ 292 /* Delete the intermediate (temporary) source object */
290 293
291 acpi_ut_remove_reference (actual_src_desc); 294 acpi_ut_remove_reference(actual_src_desc);
292 } 295 }
293 296
294 *new_desc = dest_desc; 297 *new_desc = dest_desc;
295 return_ACPI_STATUS (status); 298 return_ACPI_STATUS(status);
296} 299}
297
298
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 d00b0dcba96a..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
@@ -374,25 +332,20 @@ acpi_ex_eisa_id_to_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 2ee1d061013f..e8165c4f162a 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -34,49 +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_DRIVER_NAME "ACPI Fan Driver" 39#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver"
41#define ACPI_FAN_FILE_STATE "state" 40#define ACPI_FAN_FILE_STATE "state"
42 41
43#define _COMPONENT ACPI_FAN_COMPONENT 42#define _COMPONENT ACPI_FAN_COMPONENT
44ACPI_MODULE_NAME ("acpi_fan") 43ACPI_MODULE_NAME("acpi_fan")
45 44
46MODULE_AUTHOR("Paul Diefenbaugh"); 45 MODULE_AUTHOR("Paul Diefenbaugh");
47MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME); 46MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
48MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
49 48
50static int acpi_fan_add (struct acpi_device *device); 49static int acpi_fan_add(struct acpi_device *device);
51static int acpi_fan_remove (struct acpi_device *device, int type); 50static int acpi_fan_remove(struct acpi_device *device, int type);
52 51
53static struct acpi_driver acpi_fan_driver = { 52static struct acpi_driver acpi_fan_driver = {
54 .name = ACPI_FAN_DRIVER_NAME, 53 .name = ACPI_FAN_DRIVER_NAME,
55 .class = ACPI_FAN_CLASS, 54 .class = ACPI_FAN_CLASS,
56 .ids = "PNP0C0B", 55 .ids = "PNP0C0B",
57 .ops = { 56 .ops = {
58 .add = acpi_fan_add, 57 .add = acpi_fan_add,
59 .remove = acpi_fan_remove, 58 .remove = acpi_fan_remove,
60 }, 59 },
61}; 60};
62 61
63struct acpi_fan { 62struct acpi_fan {
64 acpi_handle handle; 63 acpi_handle handle;
65}; 64};
66 65
67
68/* -------------------------------------------------------------------------- 66/* --------------------------------------------------------------------------
69 FS Interface (/proc) 67 FS Interface (/proc)
70 -------------------------------------------------------------------------- */ 68 -------------------------------------------------------------------------- */
71 69
72static struct proc_dir_entry *acpi_fan_dir; 70static struct proc_dir_entry *acpi_fan_dir;
73
74 71
75static int 72static int acpi_fan_read_state(struct seq_file *seq, void *offset)
76acpi_fan_read_state(struct seq_file *seq, void *offset)
77{ 73{
78 struct acpi_fan *fan = seq->private; 74 struct acpi_fan *fan = seq->private;
79 int state = 0; 75 int state = 0;
80 76
81 ACPI_FUNCTION_TRACE("acpi_fan_read_state"); 77 ACPI_FUNCTION_TRACE("acpi_fan_read_state");
82 78
@@ -85,7 +81,7 @@ acpi_fan_read_state(struct seq_file *seq, void *offset)
85 seq_printf(seq, "status: ERROR\n"); 81 seq_printf(seq, "status: ERROR\n");
86 else 82 else
87 seq_printf(seq, "status: %s\n", 83 seq_printf(seq, "status: %s\n",
88 !state?"on":"off"); 84 !state ? "on" : "off");
89 } 85 }
90 return_VALUE(0); 86 return_VALUE(0);
91} 87}
@@ -96,26 +92,26 @@ static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
96} 92}
97 93
98static ssize_t 94static ssize_t
99acpi_fan_write_state(struct file *file, const char __user *buffer, 95acpi_fan_write_state(struct file *file, const char __user * buffer,
100 size_t count, loff_t *ppos) 96 size_t count, loff_t * ppos)
101{ 97{
102 int result = 0; 98 int result = 0;
103 struct seq_file *m = (struct seq_file *)file->private_data; 99 struct seq_file *m = (struct seq_file *)file->private_data;
104 struct acpi_fan *fan = (struct acpi_fan *) m->private; 100 struct acpi_fan *fan = (struct acpi_fan *)m->private;
105 char state_string[12] = {'\0'}; 101 char state_string[12] = { '\0' };
106 102
107 ACPI_FUNCTION_TRACE("acpi_fan_write_state"); 103 ACPI_FUNCTION_TRACE("acpi_fan_write_state");
108 104
109 if (!fan || (count > sizeof(state_string) - 1)) 105 if (!fan || (count > sizeof(state_string) - 1))
110 return_VALUE(-EINVAL); 106 return_VALUE(-EINVAL);
111 107
112 if (copy_from_user(state_string, buffer, count)) 108 if (copy_from_user(state_string, buffer, count))
113 return_VALUE(-EFAULT); 109 return_VALUE(-EFAULT);
114 110
115 state_string[count] = '\0'; 111 state_string[count] = '\0';
116 112
117 result = acpi_bus_set_power(fan->handle, 113 result = acpi_bus_set_power(fan->handle,
118 simple_strtoul(state_string, NULL, 0)); 114 simple_strtoul(state_string, NULL, 0));
119 if (result) 115 if (result)
120 return_VALUE(result); 116 return_VALUE(result);
121 117
@@ -123,18 +119,17 @@ acpi_fan_write_state(struct file *file, const char __user *buffer,
123} 119}
124 120
125static struct file_operations acpi_fan_state_ops = { 121static struct file_operations acpi_fan_state_ops = {
126 .open = acpi_fan_state_open_fs, 122 .open = acpi_fan_state_open_fs,
127 .read = seq_read, 123 .read = seq_read,
128 .write = acpi_fan_write_state, 124 .write = acpi_fan_write_state,
129 .llseek = seq_lseek, 125 .llseek = seq_lseek,
130 .release = single_release, 126 .release = single_release,
131 .owner = THIS_MODULE, 127 .owner = THIS_MODULE,
132}; 128};
133 129
134static int 130static int acpi_fan_add_fs(struct acpi_device *device)
135acpi_fan_add_fs(struct acpi_device *device)
136{ 131{
137 struct proc_dir_entry *entry = NULL; 132 struct proc_dir_entry *entry = NULL;
138 133
139 ACPI_FUNCTION_TRACE("acpi_fan_add_fs"); 134 ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
140 135
@@ -143,7 +138,7 @@ acpi_fan_add_fs(struct acpi_device *device)
143 138
144 if (!acpi_device_dir(device)) { 139 if (!acpi_device_dir(device)) {
145 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 140 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
146 acpi_fan_dir); 141 acpi_fan_dir);
147 if (!acpi_device_dir(device)) 142 if (!acpi_device_dir(device))
148 return_VALUE(-ENODEV); 143 return_VALUE(-ENODEV);
149 acpi_device_dir(device)->owner = THIS_MODULE; 144 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -151,11 +146,12 @@ acpi_fan_add_fs(struct acpi_device *device)
151 146
152 /* 'status' [R/W] */ 147 /* 'status' [R/W] */
153 entry = create_proc_entry(ACPI_FAN_FILE_STATE, 148 entry = create_proc_entry(ACPI_FAN_FILE_STATE,
154 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 149 S_IFREG | S_IRUGO | S_IWUSR,
150 acpi_device_dir(device));
155 if (!entry) 151 if (!entry)
156 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 152 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
157 "Unable to create '%s' fs entry\n", 153 "Unable to create '%s' fs entry\n",
158 ACPI_FAN_FILE_STATE)); 154 ACPI_FAN_FILE_STATE));
159 else { 155 else {
160 entry->proc_fops = &acpi_fan_state_ops; 156 entry->proc_fops = &acpi_fan_state_ops;
161 entry->data = acpi_driver_data(device); 157 entry->data = acpi_driver_data(device);
@@ -165,15 +161,12 @@ acpi_fan_add_fs(struct acpi_device *device)
165 return_VALUE(0); 161 return_VALUE(0);
166} 162}
167 163
168 164static int acpi_fan_remove_fs(struct acpi_device *device)
169static int
170acpi_fan_remove_fs(struct acpi_device *device)
171{ 165{
172 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); 166 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
173 167
174 if (acpi_device_dir(device)) { 168 if (acpi_device_dir(device)) {
175 remove_proc_entry(ACPI_FAN_FILE_STATE, 169 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
176 acpi_device_dir(device));
177 remove_proc_entry(acpi_device_bid(device), acpi_fan_dir); 170 remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
178 acpi_device_dir(device) = NULL; 171 acpi_device_dir(device) = NULL;
179 } 172 }
@@ -181,17 +174,15 @@ acpi_fan_remove_fs(struct acpi_device *device)
181 return_VALUE(0); 174 return_VALUE(0);
182} 175}
183 176
184
185/* -------------------------------------------------------------------------- 177/* --------------------------------------------------------------------------
186 Driver Interface 178 Driver Interface
187 -------------------------------------------------------------------------- */ 179 -------------------------------------------------------------------------- */
188 180
189static int 181static int acpi_fan_add(struct acpi_device *device)
190acpi_fan_add(struct acpi_device *device)
191{ 182{
192 int result = 0; 183 int result = 0;
193 struct acpi_fan *fan = NULL; 184 struct acpi_fan *fan = NULL;
194 int state = 0; 185 int state = 0;
195 186
196 ACPI_FUNCTION_TRACE("acpi_fan_add"); 187 ACPI_FUNCTION_TRACE("acpi_fan_add");
197 188
@@ -211,7 +202,7 @@ acpi_fan_add(struct acpi_device *device)
211 result = acpi_bus_get_power(fan->handle, &state); 202 result = acpi_bus_get_power(fan->handle, &state);
212 if (result) { 203 if (result) {
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
214 "Error reading power state\n")); 205 "Error reading power state\n"));
215 goto end; 206 goto end;
216 } 207 }
217 208
@@ -220,19 +211,17 @@ acpi_fan_add(struct acpi_device *device)
220 goto end; 211 goto end;
221 212
222 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 213 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
223 acpi_device_name(device), acpi_device_bid(device), 214 acpi_device_name(device), acpi_device_bid(device),
224 !device->power.state?"on":"off"); 215 !device->power.state ? "on" : "off");
225 216
226end: 217 end:
227 if (result) 218 if (result)
228 kfree(fan); 219 kfree(fan);
229 220
230 return_VALUE(result); 221 return_VALUE(result);
231} 222}
232 223
233 224static int acpi_fan_remove(struct acpi_device *device, int type)
234static int
235acpi_fan_remove(struct acpi_device *device, int type)
236{ 225{
237 struct acpi_fan *fan = NULL; 226 struct acpi_fan *fan = NULL;
238 227
@@ -241,7 +230,7 @@ acpi_fan_remove(struct acpi_device *device, int type)
241 if (!device || !acpi_driver_data(device)) 230 if (!device || !acpi_driver_data(device))
242 return_VALUE(-EINVAL); 231 return_VALUE(-EINVAL);
243 232
244 fan = (struct acpi_fan *) acpi_driver_data(device); 233 fan = (struct acpi_fan *)acpi_driver_data(device);
245 234
246 acpi_fan_remove_fs(device); 235 acpi_fan_remove_fs(device);
247 236
@@ -250,9 +239,7 @@ acpi_fan_remove(struct acpi_device *device, int type)
250 return_VALUE(0); 239 return_VALUE(0);
251} 240}
252 241
253 242static int __init acpi_fan_init(void)
254static int __init
255acpi_fan_init(void)
256{ 243{
257 int result = 0; 244 int result = 0;
258 245
@@ -272,9 +259,7 @@ acpi_fan_init(void)
272 return_VALUE(0); 259 return_VALUE(0);
273} 260}
274 261
275 262static void __exit acpi_fan_exit(void)
276static void __exit
277acpi_fan_exit(void)
278{ 263{
279 ACPI_FUNCTION_TRACE("acpi_fan_exit"); 264 ACPI_FUNCTION_TRACE("acpi_fan_exit");
280 265
@@ -285,7 +270,5 @@ acpi_fan_exit(void)
285 return_VOID; 270 return_VOID;
286} 271}
287 272
288
289module_init(acpi_fan_init); 273module_init(acpi_fan_init);
290module_exit(acpi_fan_exit); 274module_exit(acpi_fan_exit);
291
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 770cfc8b17e0..1943461489c2 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;
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 3536bbb990c3..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,7 +352,6 @@ 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
@@ -382,22 +364,17 @@ 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 void)
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); 374 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
396 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); 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
@@ -410,21 +387,16 @@ 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 void)
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); 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
@@ -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 void)
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); 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 04a058565d8d..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); 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 cedee0c43b5f..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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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..62233bd7147c 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -86,52 +86,46 @@ static acpi_handle root_handle = NULL;
86 static acpi_handle *object##_parent = &parent##_handle; \ 86 static acpi_handle *object##_parent = &parent##_handle; \
87 static char *object##_paths[] = { paths } 87 static char *object##_paths[] = { paths }
88 88
89IBM_HANDLE(ec, root, 89IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */
90 "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ 90 "\\_SB.PCI0.LPC.EC", /* all others */
91 "\\_SB.PCI0.LPC.EC", /* all others */ 91 );
92); 92
93 93IBM_HANDLE(vid, root, "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */
94IBM_HANDLE(vid, root, 94 "\\_SB.PCI0.AGP.VID", /* all others */
95 "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ 95 );
96 "\\_SB.PCI0.AGP.VID", /* all others */ 96
97); 97IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */
98 98 "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */
99IBM_HANDLE(cmos, root, 99 "\\CMS", /* R40, R40e */
100 "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ 100 ); /* A21e, A22p, T20, T21, X20 */
101 "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ 101
102 "\\CMS", /* R40, R40e */ 102IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
103); /* A21e, A22p, T20, T21, X20 */ 103 "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */
104 104 "\\_SB.PCI0.PCI1.DOCK", /* all others */
105IBM_HANDLE(dock, root, 105 ); /* A21e, G40, R32, R40, R40e */
106 "\\_SB.GDCK", /* X30, X31, X40 */ 106
107 "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ 107IBM_HANDLE(bay, root, "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */
108 "\\_SB.PCI0.PCI1.DOCK", /* all others */ 108IBM_HANDLE(bayej, root, "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */
109); /* A21e, G40, R32, R40, R40e */ 109
110 110IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */
111IBM_HANDLE(bay, root, 111IBM_HANDLE(hkey, ec, "HKEY"); /* all */
112 "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ 112IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */
113IBM_HANDLE(bayej, root, 113IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */
114 "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ 114IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */
115 115IBM_HANDLE(beep, ec, "BEEP"); /* all models */
116IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */
117IBM_HANDLE(hkey, ec, "HKEY"); /* all */
118IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */
119IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */
120IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */
121IBM_HANDLE(beep, ec, "BEEP"); /* all models */
122 116
123struct ibm_struct { 117struct ibm_struct {
124 char *name; 118 char *name;
125 119
126 char *hid; 120 char *hid;
127 struct acpi_driver *driver; 121 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 122
134 void (*notify) (struct ibm_struct *, u32); 123 int (*init) (struct ibm_struct *);
124 int (*read) (struct ibm_struct *, char *);
125 int (*write) (struct ibm_struct *, char *);
126 void (*exit) (struct ibm_struct *);
127
128 void (*notify) (struct ibm_struct *, u32);
135 acpi_handle *handle; 129 acpi_handle *handle;
136 int type; 130 int type;
137 struct acpi_device *device; 131 struct acpi_device *device;
@@ -165,15 +159,15 @@ static int acpi_evalf(acpi_handle handle,
165 void *res, char *method, char *fmt, ...) 159 void *res, char *method, char *fmt, ...)
166{ 160{
167 char *fmt0 = fmt; 161 char *fmt0 = fmt;
168 struct acpi_object_list params; 162 struct acpi_object_list params;
169 union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; 163 union acpi_object in_objs[IBM_MAX_ACPI_ARGS];
170 struct acpi_buffer result; 164 struct acpi_buffer result;
171 union acpi_object out_obj; 165 union acpi_object out_obj;
172 acpi_status status; 166 acpi_status status;
173 va_list ap; 167 va_list ap;
174 char res_type; 168 char res_type;
175 int success; 169 int success;
176 int quiet; 170 int quiet;
177 171
178 if (!*fmt) { 172 if (!*fmt) {
179 printk(IBM_ERR "acpi_evalf() called with empty format\n"); 173 printk(IBM_ERR "acpi_evalf() called with empty format\n");
@@ -199,7 +193,7 @@ static int acpi_evalf(acpi_handle handle,
199 in_objs[params.count].integer.value = va_arg(ap, int); 193 in_objs[params.count].integer.value = va_arg(ap, int);
200 in_objs[params.count++].type = ACPI_TYPE_INTEGER; 194 in_objs[params.count++].type = ACPI_TYPE_INTEGER;
201 break; 195 break;
202 /* add more types as needed */ 196 /* add more types as needed */
203 default: 197 default:
204 printk(IBM_ERR "acpi_evalf() called " 198 printk(IBM_ERR "acpi_evalf() called "
205 "with invalid format character '%c'\n", c); 199 "with invalid format character '%c'\n", c);
@@ -214,15 +208,15 @@ static int acpi_evalf(acpi_handle handle,
214 status = acpi_evaluate_object(handle, method, &params, &result); 208 status = acpi_evaluate_object(handle, method, &params, &result);
215 209
216 switch (res_type) { 210 switch (res_type) {
217 case 'd': /* int */ 211 case 'd': /* int */
218 if (res) 212 if (res)
219 *(int *)res = out_obj.integer.value; 213 *(int *)res = out_obj.integer.value;
220 success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; 214 success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER;
221 break; 215 break;
222 case 'v': /* void */ 216 case 'v': /* void */
223 success = status == AE_OK; 217 success = status == AE_OK;
224 break; 218 break;
225 /* add more types as needed */ 219 /* add more types as needed */
226 default: 220 default:
227 printk(IBM_ERR "acpi_evalf() called " 221 printk(IBM_ERR "acpi_evalf() called "
228 "with invalid format character '%c'\n", res_type); 222 "with invalid format character '%c'\n", res_type);
@@ -303,9 +297,9 @@ static int hotkey_set(struct ibm_struct *ibm, int status, int mask)
303 if (!ibm->supported) 297 if (!ibm->supported)
304 return 0; 298 return 0;
305 299
306 for (i=0; i<32; i++) { 300 for (i = 0; i < 32; i++) {
307 int bit = ((1 << i) & mask) != 0; 301 int bit = ((1 << i) & mask) != 0;
308 if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit)) 302 if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i + 1, bit))
309 return -EIO; 303 return -EIO;
310 } 304 }
311 305
@@ -318,8 +312,7 @@ static int hotkey_init(struct ibm_struct *ibm)
318 312
319 ibm->supported = 1; 313 ibm->supported = 1;
320 ret = hotkey_get(ibm, 314 ret = hotkey_get(ibm,
321 &ibm->state.hotkey.status, 315 &ibm->state.hotkey.status, &ibm->state.hotkey.mask);
322 &ibm->state.hotkey.mask);
323 if (ret < 0) { 316 if (ret < 0) {
324 /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ 317 /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */
325 ibm->supported = 0; 318 ibm->supported = 0;
@@ -329,7 +322,7 @@ static int hotkey_init(struct ibm_struct *ibm)
329 } 322 }
330 323
331 return ret; 324 return ret;
332} 325}
333 326
334static int hotkey_read(struct ibm_struct *ibm, char *p) 327static int hotkey_read(struct ibm_struct *ibm, char *p)
335{ 328{
@@ -368,7 +361,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf)
368 status = 0; 361 status = 0;
369 } else if (strlencmp(cmd, "reset") == 0) { 362 } else if (strlencmp(cmd, "reset") == 0) {
370 status = ibm->state.hotkey.status; 363 status = ibm->state.hotkey.status;
371 mask = ibm->state.hotkey.mask; 364 mask = ibm->state.hotkey.mask;
372 } else if (sscanf(cmd, "0x%x", &mask) == 1) { 365 } else if (sscanf(cmd, "0x%x", &mask) == 1) {
373 /* mask set */ 366 /* mask set */
374 } else if (sscanf(cmd, "%x", &mask) == 1) { 367 } else if (sscanf(cmd, "%x", &mask) == 1) {
@@ -382,7 +375,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf)
382 return -EIO; 375 return -EIO;
383 376
384 return 0; 377 return 0;
385} 378}
386 379
387static void hotkey_exit(struct ibm_struct *ibm) 380static void hotkey_exit(struct ibm_struct *ibm)
388{ 381{
@@ -398,7 +391,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
398 else { 391 else {
399 printk(IBM_ERR "unknown hotkey event %d\n", event); 392 printk(IBM_ERR "unknown hotkey event %d\n", event);
400 acpi_bus_generate_event(ibm->device, event, 0); 393 acpi_bus_generate_event(ibm->device, event, 0);
401 } 394 }
402} 395}
403 396
404static int bluetooth_init(struct ibm_struct *ibm) 397static int bluetooth_init(struct ibm_struct *ibm)
@@ -456,15 +449,14 @@ static int bluetooth_write(struct ibm_struct *ibm, char *buf)
456 } 449 }
457 450
458 if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) 451 if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
459 return -EIO; 452 return -EIO;
460 453
461 return 0; 454 return 0;
462} 455}
463 456
464static int video_init(struct ibm_struct *ibm) 457static int video_init(struct ibm_struct *ibm)
465{ 458{
466 if (!acpi_evalf(vid_handle, 459 if (!acpi_evalf(vid_handle, &ibm->state.video.autoswitch, "^VDEE", "d"))
467 &ibm->state.video.autoswitch, "^VDEE", "d"))
468 return -ENODEV; 460 return -ENODEV;
469 461
470 return 0; 462 return 0;
@@ -566,8 +558,7 @@ static int video_write(struct ibm_struct *ibm, char *buf)
566 558
567static void video_exit(struct ibm_struct *ibm) 559static void video_exit(struct ibm_struct *ibm)
568{ 560{
569 acpi_evalf(vid_handle, NULL, "_DOS", "vd", 561 acpi_evalf(vid_handle, NULL, "_DOS", "vd", ibm->state.video.autoswitch);
570 ibm->state.video.autoswitch);
571} 562}
572 563
573static int light_init(struct ibm_struct *ibm) 564static int light_init(struct ibm_struct *ibm)
@@ -600,7 +591,7 @@ static int light_write(struct ibm_struct *ibm, char *buf)
600 int cmos_cmd, lght_cmd; 591 int cmos_cmd, lght_cmd;
601 char *cmd; 592 char *cmd;
602 int success; 593 int success;
603 594
604 while ((cmd = next_cmd(&buf))) { 595 while ((cmd = next_cmd(&buf))) {
605 if (strlencmp(cmd, "on") == 0) { 596 if (strlencmp(cmd, "on") == 0) {
606 cmos_cmd = 0x0c; 597 cmos_cmd = 0x0c;
@@ -610,10 +601,10 @@ static int light_write(struct ibm_struct *ibm, char *buf)
610 lght_cmd = 0; 601 lght_cmd = 0;
611 } else 602 } else
612 return -EINVAL; 603 return -EINVAL;
613 604
614 success = cmos_handle ? 605 success = cmos_handle ?
615 acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : 606 acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) :
616 acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); 607 acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd);
617 if (!success) 608 if (!success)
618 return -EIO; 609 return -EIO;
619 } 610 }
@@ -671,22 +662,22 @@ static int dock_write(struct ibm_struct *ibm, char *buf)
671 } 662 }
672 663
673 return 0; 664 return 0;
674} 665}
675 666
676static void dock_notify(struct ibm_struct *ibm, u32 event) 667static void dock_notify(struct ibm_struct *ibm, u32 event)
677{ 668{
678 int docked = dock_docked(); 669 int docked = dock_docked();
679 670
680 if (event == 3 && docked) 671 if (event == 3 && docked)
681 acpi_bus_generate_event(ibm->device, event, 1); /* button */ 672 acpi_bus_generate_event(ibm->device, event, 1); /* button */
682 else if (event == 3 && !docked) 673 else if (event == 3 && !docked)
683 acpi_bus_generate_event(ibm->device, event, 2); /* undock */ 674 acpi_bus_generate_event(ibm->device, event, 2); /* undock */
684 else if (event == 0 && docked) 675 else if (event == 0 && docked)
685 acpi_bus_generate_event(ibm->device, event, 3); /* dock */ 676 acpi_bus_generate_event(ibm->device, event, 3); /* dock */
686 else { 677 else {
687 printk(IBM_ERR "unknown dock event %d, status %d\n", 678 printk(IBM_ERR "unknown dock event %d, status %d\n",
688 event, _sta(dock_handle)); 679 event, _sta(dock_handle));
689 acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ 680 acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
690 } 681 }
691} 682}
692 683
@@ -696,7 +687,7 @@ static int bay_init(struct ibm_struct *ibm)
696{ 687{
697 /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ 688 /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */
698 ibm->supported = bay_handle && bayej_handle && 689 ibm->supported = bay_handle && bayej_handle &&
699 acpi_evalf(bay_handle, NULL, "_STA", "qv"); 690 acpi_evalf(bay_handle, NULL, "_STA", "qv");
700 691
701 return 0; 692 return 0;
702} 693}
@@ -705,7 +696,7 @@ static int bay_read(struct ibm_struct *ibm, char *p)
705{ 696{
706 int len = 0; 697 int len = 0;
707 int occupied = bay_occupied(); 698 int occupied = bay_occupied();
708 699
709 if (!ibm->supported) 700 if (!ibm->supported)
710 len += sprintf(p + len, "status:\t\tnot supported\n"); 701 len += sprintf(p + len, "status:\t\tnot supported\n");
711 else if (!occupied) 702 else if (!occupied)
@@ -732,7 +723,7 @@ static int bay_write(struct ibm_struct *ibm, char *buf)
732 } 723 }
733 724
734 return 0; 725 return 0;
735} 726}
736 727
737static void bay_notify(struct ibm_struct *ibm, u32 event) 728static void bay_notify(struct ibm_struct *ibm, u32 event)
738{ 729{
@@ -773,8 +764,8 @@ static int cmos_write(struct ibm_struct *ibm, char *buf)
773 } 764 }
774 765
775 return 0; 766 return 0;
776} 767}
777 768
778static int led_read(struct ibm_struct *ibm, char *p) 769static int led_read(struct ibm_struct *ibm, char *p)
779{ 770{
780 int len = 0; 771 int len = 0;
@@ -809,7 +800,7 @@ static int led_write(struct ibm_struct *ibm, char *buf)
809 led_cmd = sysl_cmd = bled_a = bled_b = 0; 800 led_cmd = sysl_cmd = bled_a = bled_b = 0;
810 } else 801 } else
811 return -EINVAL; 802 return -EINVAL;
812 803
813 if (led_handle) { 804 if (led_handle) {
814 if (!acpi_evalf(led_handle, NULL, NULL, "vdd", 805 if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
815 led, led_cmd)) 806 led, led_cmd))
@@ -827,8 +818,8 @@ static int led_write(struct ibm_struct *ibm, char *buf)
827 } 818 }
828 819
829 return 0; 820 return 0;
830} 821}
831 822
832static int beep_read(struct ibm_struct *ibm, char *p) 823static int beep_read(struct ibm_struct *ibm, char *p)
833{ 824{
834 int len = 0; 825 int len = 0;
@@ -854,80 +845,81 @@ static int beep_write(struct ibm_struct *ibm, char *buf)
854 } 845 }
855 846
856 return 0; 847 return 0;
857} 848}
858 849
859static struct ibm_struct ibms[] = { 850static struct ibm_struct ibms[] = {
860 { 851 {
861 .name = "driver", 852 .name = "driver",
862 .init = driver_init, 853 .init = driver_init,
863 .read = driver_read, 854 .read = driver_read,
864 }, 855 },
865 { 856 {
866 .name = "hotkey", 857 .name = "hotkey",
867 .hid = "IBM0068", 858 .hid = "IBM0068",
868 .init = hotkey_init, 859 .init = hotkey_init,
869 .read = hotkey_read, 860 .read = hotkey_read,
870 .write = hotkey_write, 861 .write = hotkey_write,
871 .exit = hotkey_exit, 862 .exit = hotkey_exit,
872 .notify = hotkey_notify, 863 .notify = hotkey_notify,
873 .handle = &hkey_handle, 864 .handle = &hkey_handle,
874 .type = ACPI_DEVICE_NOTIFY, 865 .type = ACPI_DEVICE_NOTIFY,
875 }, 866 },
876 { 867 {
877 .name = "bluetooth", 868 .name = "bluetooth",
878 .init = bluetooth_init, 869 .init = bluetooth_init,
879 .read = bluetooth_read, 870 .read = bluetooth_read,
880 .write = bluetooth_write, 871 .write = bluetooth_write,
881 }, 872 },
882 { 873 {
883 .name = "video", 874 .name = "video",
884 .init = video_init, 875 .init = video_init,
885 .read = video_read, 876 .read = video_read,
886 .write = video_write, 877 .write = video_write,
887 .exit = video_exit, 878 .exit = video_exit,
888 }, 879 },
889 { 880 {
890 .name = "light", 881 .name = "light",
891 .init = light_init, 882 .init = light_init,
892 .read = light_read, 883 .read = light_read,
893 .write = light_write, 884 .write = light_write,
894 }, 885 },
895 { 886 {
896 .name = "dock", 887 .name = "dock",
897 .read = dock_read, 888 .read = dock_read,
898 .write = dock_write, 889 .write = dock_write,
899 .notify = dock_notify, 890 .notify = dock_notify,
900 .handle = &dock_handle, 891 .handle = &dock_handle,
901 .type = ACPI_SYSTEM_NOTIFY, 892 .type = ACPI_SYSTEM_NOTIFY,
902 }, 893 },
903 { 894 {
904 .name = "bay", 895 .name = "bay",
905 .init = bay_init, 896 .init = bay_init,
906 .read = bay_read, 897 .read = bay_read,
907 .write = bay_write, 898 .write = bay_write,
908 .notify = bay_notify, 899 .notify = bay_notify,
909 .handle = &bay_handle, 900 .handle = &bay_handle,
910 .type = ACPI_SYSTEM_NOTIFY, 901 .type = ACPI_SYSTEM_NOTIFY,
911 }, 902 },
912 { 903 {
913 .name = "cmos", 904 .name = "cmos",
914 .read = cmos_read, 905 .read = cmos_read,
915 .write = cmos_write, 906 .write = cmos_write,
916 .experimental = 1, 907 .experimental = 1,
917 }, 908 },
918 { 909 {
919 .name = "led", 910 .name = "led",
920 .read = led_read, 911 .read = led_read,
921 .write = led_write, 912 .write = led_write,
922 .experimental = 1, 913 .experimental = 1,
923 }, 914 },
924 { 915 {
925 .name = "beep", 916 .name = "beep",
926 .read = beep_read, 917 .read = beep_read,
927 .write = beep_write, 918 .write = beep_write,
928 .experimental = 1, 919 .experimental = 1,
929 }, 920 },
930}; 921};
922
931#define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0])) 923#define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0]))
932 924
933static int dispatch_read(char *page, char **start, off_t off, int count, 925static int dispatch_read(char *page, char **start, off_t off, int count,
@@ -935,7 +927,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count,
935{ 927{
936 struct ibm_struct *ibm = (struct ibm_struct *)data; 928 struct ibm_struct *ibm = (struct ibm_struct *)data;
937 int len; 929 int len;
938 930
939 if (!ibm || !ibm->read) 931 if (!ibm || !ibm->read)
940 return -EINVAL; 932 return -EINVAL;
941 933
@@ -955,7 +947,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count,
955 return len; 947 return len;
956} 948}
957 949
958static int dispatch_write(struct file *file, const char __user *userbuf, 950static int dispatch_write(struct file *file, const char __user * userbuf,
959 unsigned long count, void *data) 951 unsigned long count, void *data)
960{ 952{
961 struct ibm_struct *ibm = (struct ibm_struct *)data; 953 struct ibm_struct *ibm = (struct ibm_struct *)data;
@@ -969,9 +961,9 @@ static int dispatch_write(struct file *file, const char __user *userbuf,
969 if (!kernbuf) 961 if (!kernbuf)
970 return -ENOMEM; 962 return -ENOMEM;
971 963
972 if (copy_from_user(kernbuf, userbuf, count)) { 964 if (copy_from_user(kernbuf, userbuf, count)) {
973 kfree(kernbuf); 965 kfree(kernbuf);
974 return -EFAULT; 966 return -EFAULT;
975 } 967 }
976 968
977 kernbuf[count] = 0; 969 kernbuf[count] = 0;
@@ -982,7 +974,7 @@ static int dispatch_write(struct file *file, const char __user *userbuf,
982 974
983 kfree(kernbuf); 975 kfree(kernbuf);
984 976
985 return ret; 977 return ret;
986} 978}
987 979
988static void dispatch_notify(acpi_handle handle, u32 event, void *data) 980static void dispatch_notify(acpi_handle handle, u32 event, void *data)
@@ -1085,7 +1077,7 @@ static int ibm_init(struct ibm_struct *ibm)
1085 } 1077 }
1086 entry->owner = THIS_MODULE; 1078 entry->owner = THIS_MODULE;
1087 ibm->proc_created = 1; 1079 ibm->proc_created = 1;
1088 1080
1089 entry->data = ibm; 1081 entry->data = ibm;
1090 if (ibm->read) 1082 if (ibm->read)
1091 entry->read_proc = &dispatch_read; 1083 entry->read_proc = &dispatch_read;
@@ -1120,18 +1112,18 @@ static void ibm_exit(struct ibm_struct *ibm)
1120} 1112}
1121 1113
1122static int ibm_handle_init(char *name, 1114static int ibm_handle_init(char *name,
1123 acpi_handle *handle, acpi_handle parent, 1115 acpi_handle * handle, acpi_handle parent,
1124 char **paths, int num_paths, int required) 1116 char **paths, int num_paths, int required)
1125{ 1117{
1126 int i; 1118 int i;
1127 acpi_status status; 1119 acpi_status status;
1128 1120
1129 for (i=0; i<num_paths; i++) { 1121 for (i = 0; i < num_paths; i++) {
1130 status = acpi_get_handle(parent, paths[i], handle); 1122 status = acpi_get_handle(parent, paths[i], handle);
1131 if (ACPI_SUCCESS(status)) 1123 if (ACPI_SUCCESS(status))
1132 return 0; 1124 return 0;
1133 } 1125 }
1134 1126
1135 *handle = NULL; 1127 *handle = NULL;
1136 1128
1137 if (required) { 1129 if (required) {
@@ -1146,7 +1138,6 @@ static int ibm_handle_init(char *name,
1146 ibm_handle_init(#object, &object##_handle, *object##_parent, \ 1138 ibm_handle_init(#object, &object##_handle, *object##_parent, \
1147 object##_paths, sizeof(object##_paths)/sizeof(char*), required) 1139 object##_paths, sizeof(object##_paths)/sizeof(char*), required)
1148 1140
1149
1150static int set_ibm_param(const char *val, struct kernel_param *kp) 1141static int set_ibm_param(const char *val, struct kernel_param *kp)
1151{ 1142{
1152 unsigned int i; 1143 unsigned int i;
@@ -1158,7 +1149,7 @@ static int set_ibm_param(const char *val, struct kernel_param *kp)
1158 strcpy(arg_with_comma, val); 1149 strcpy(arg_with_comma, val);
1159 strcat(arg_with_comma, ","); 1150 strcat(arg_with_comma, ",");
1160 1151
1161 for (i=0; i<NUM_IBMS; i++) 1152 for (i = 0; i < NUM_IBMS; i++)
1162 if (strcmp(ibms[i].name, kp->name) == 0) 1153 if (strcmp(ibms[i].name, kp->name) == 0)
1163 return ibms[i].write(&ibms[i], arg_with_comma); 1154 return ibms[i].write(&ibms[i], arg_with_comma);
1164 BUG(); 1155 BUG();
@@ -1172,7 +1163,7 @@ static void acpi_ibm_exit(void)
1172{ 1163{
1173 int i; 1164 int i;
1174 1165
1175 for (i=NUM_IBMS-1; i>=0; i--) 1166 for (i = NUM_IBMS - 1; i >= 0; i--)
1176 ibm_exit(&ibms[i]); 1167 ibm_exit(&ibms[i]);
1177 1168
1178 remove_proc_entry(IBM_DIR, acpi_root_dir); 1169 remove_proc_entry(IBM_DIR, acpi_root_dir);
@@ -1185,15 +1176,14 @@ static int __init acpi_ibm_init(void)
1185 if (acpi_disabled) 1176 if (acpi_disabled)
1186 return -ENODEV; 1177 return -ENODEV;
1187 1178
1188 if (!acpi_specific_hotkey_enabled){ 1179 if (!acpi_specific_hotkey_enabled) {
1189 printk(IBM_ERR "Using generic hotkey driver\n"); 1180 printk(IBM_ERR "Using generic hotkey driver\n");
1190 return -ENODEV; 1181 return -ENODEV;
1191 } 1182 }
1192 /* these handles are required */ 1183 /* these handles are required */
1193 if (IBM_HANDLE_INIT(ec, 1) < 0 || 1184 if (IBM_HANDLE_INIT(ec, 1) < 0 ||
1194 IBM_HANDLE_INIT(hkey, 1) < 0 || 1185 IBM_HANDLE_INIT(hkey, 1) < 0 ||
1195 IBM_HANDLE_INIT(vid, 1) < 0 || 1186 IBM_HANDLE_INIT(vid, 1) < 0 || IBM_HANDLE_INIT(beep, 1) < 0)
1196 IBM_HANDLE_INIT(beep, 1) < 0)
1197 return -ENODEV; 1187 return -ENODEV;
1198 1188
1199 /* these handles have alternatives */ 1189 /* these handles have alternatives */
@@ -1205,10 +1195,10 @@ static int __init acpi_ibm_init(void)
1205 return -ENODEV; 1195 return -ENODEV;
1206 1196
1207 /* these handles are not required */ 1197 /* these handles are not required */
1208 IBM_HANDLE_INIT(dock, 0); 1198 IBM_HANDLE_INIT(dock, 0);
1209 IBM_HANDLE_INIT(bay, 0); 1199 IBM_HANDLE_INIT(bay, 0);
1210 IBM_HANDLE_INIT(bayej, 0); 1200 IBM_HANDLE_INIT(bayej, 0);
1211 IBM_HANDLE_INIT(bled, 0); 1201 IBM_HANDLE_INIT(bled, 0);
1212 1202
1213 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); 1203 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
1214 if (!proc_dir) { 1204 if (!proc_dir) {
@@ -1216,8 +1206,8 @@ static int __init acpi_ibm_init(void)
1216 return -ENODEV; 1206 return -ENODEV;
1217 } 1207 }
1218 proc_dir->owner = THIS_MODULE; 1208 proc_dir->owner = THIS_MODULE;
1219 1209
1220 for (i=0; i<NUM_IBMS; i++) { 1210 for (i = 0; i < NUM_IBMS; i++) {
1221 ret = ibm_init(&ibms[i]); 1211 ret = ibm_init(&ibms[i]);
1222 if (ret < 0) { 1212 if (ret < 0) {
1223 acpi_ibm_exit(); 1213 acpi_ibm_exit();
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index 2934475d67d6..e10fb4f842b1 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) > 0x1000)) 45 && ((base) + (len) > 0x1000))
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 7589e1fdf25a..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 72
80 ACPI_FUNCTION_TRACE ("ns_root_initialize"); 73 ACPI_FUNCTION_TRACE("ns_root_initialize");
81 74
82 75 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
83 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 76 if (ACPI_FAILURE(status)) {
84 if (ACPI_FAILURE (status)) { 77 return_ACPI_STATUS(status);
85 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,7 +151,8 @@ 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) 158#if defined (ACPI_ASL_COMPILER)
@@ -167,45 +163,50 @@ acpi_ns_root_initialize (
167#else 163#else
168 /* Mark this as a very SPECIAL method */ 164 /* Mark this as a very SPECIAL method */
169 165
170 obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY; 166 obj_desc->method.method_flags =
167 AML_METHOD_INTERNAL_ONLY;
171 168
172#ifndef ACPI_DUMP_APP 169#ifndef ACPI_DUMP_APP
173 obj_desc->method.implementation = acpi_ut_osi_implementation; 170 obj_desc->method.implementation =
171 acpi_ut_osi_implementation;
174#endif 172#endif
175#endif 173#endif
176 break; 174 break;
177 175
178 case ACPI_TYPE_INTEGER: 176 case ACPI_TYPE_INTEGER:
179 177
180 obj_desc->integer.value = ACPI_TO_INTEGER (val); 178 obj_desc->integer.value = ACPI_TO_INTEGER(val);
181 break; 179 break;
182 180
183
184 case ACPI_TYPE_STRING: 181 case ACPI_TYPE_STRING:
185 182
186 /* 183 /*
187 * Build an object around the static string 184 * Build an object around the static string
188 */ 185 */
189 obj_desc->string.length = (u32) ACPI_STRLEN (val); 186 obj_desc->string.length =
187 (u32) ACPI_STRLEN(val);
190 obj_desc->string.pointer = val; 188 obj_desc->string.pointer = val;
191 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 189 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
192 break; 190 break;
193 191
194
195 case ACPI_TYPE_MUTEX: 192 case ACPI_TYPE_MUTEX:
196 193
197 obj_desc->mutex.node = new_node; 194 obj_desc->mutex.node = new_node;
198 obj_desc->mutex.sync_level = (u8) (ACPI_TO_INTEGER (val) - 1); 195 obj_desc->mutex.sync_level =
196 (u8) (ACPI_TO_INTEGER(val) - 1);
199 197
200 if (ACPI_STRCMP (init_val->name, "_GL_") == 0) { 198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
201 /* 199 /*
202 * Create a counting semaphore for the 200 * Create a counting semaphore for the
203 * global lock 201 * global lock
204 */ 202 */
205 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 203 status =
206 1, &obj_desc->mutex.semaphore); 204 acpi_os_create_semaphore
207 if (ACPI_FAILURE (status)) { 205 (ACPI_NO_UNIT_LIMIT, 1,
208 acpi_ut_remove_reference (obj_desc); 206 &obj_desc->mutex.semaphore);
207 if (ACPI_FAILURE(status)) {
208 acpi_ut_remove_reference
209 (obj_desc);
209 goto unlock_and_exit; 210 goto unlock_and_exit;
210 } 211 }
211 212
@@ -213,56 +214,58 @@ acpi_ns_root_initialize (
213 * We just created the mutex for the 214 * We just created the mutex for the
214 * global lock, save it 215 * global lock, save it
215 */ 216 */
216 acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; 217 acpi_gbl_global_lock_semaphore =
217 } 218 obj_desc->mutex.semaphore;
218 else { 219 } else {
219 /* Create a mutex */ 220 /* Create a mutex */
220 221
221 status = acpi_os_create_semaphore (1, 1, 222 status = acpi_os_create_semaphore(1, 1,
222 &obj_desc->mutex.semaphore); 223 &obj_desc->
223 if (ACPI_FAILURE (status)) { 224 mutex.
224 acpi_ut_remove_reference (obj_desc); 225 semaphore);
226 if (ACPI_FAILURE(status)) {
227 acpi_ut_remove_reference
228 (obj_desc);
225 goto unlock_and_exit; 229 goto unlock_and_exit;
226 } 230 }
227 } 231 }
228 break; 232 break;
229 233
230
231 default: 234 default:
232 235
233 ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", 236 ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type));
234 init_val->type)); 237 acpi_ut_remove_reference(obj_desc);
235 acpi_ut_remove_reference (obj_desc);
236 obj_desc = NULL; 238 obj_desc = NULL;
237 continue; 239 continue;
238 } 240 }
239 241
240 /* Store pointer to value descriptor in the Node */ 242 /* Store pointer to value descriptor in the Node */
241 243
242 status = acpi_ns_attach_object (new_node, obj_desc, 244 status = acpi_ns_attach_object(new_node, obj_desc,
243 ACPI_GET_OBJECT_TYPE (obj_desc)); 245 ACPI_GET_OBJECT_TYPE
246 (obj_desc));
244 247
245 /* Remove local reference to the object */ 248 /* Remove local reference to the object */
246 249
247 acpi_ut_remove_reference (obj_desc); 250 acpi_ut_remove_reference(obj_desc);
248 } 251 }
249 } 252 }
250 253
251 254 unlock_and_exit:
252unlock_and_exit: 255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
253 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
254 256
255 /* Save a handle to "_GPE", it is always present */ 257 /* Save a handle to "_GPE", it is always present */
256 258
257 if (ACPI_SUCCESS (status)) { 259 if (ACPI_SUCCESS(status)) {
258 status = acpi_ns_get_node_by_path ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, 260 status =
259 &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);
260 } 264 }
261 265
262 return_ACPI_STATUS (status); 266 return_ACPI_STATUS(status);
263} 267}
264 268
265
266/******************************************************************************* 269/*******************************************************************************
267 * 270 *
268 * FUNCTION: acpi_ns_lookup 271 * FUNCTION: acpi_ns_lookup
@@ -287,62 +290,57 @@ unlock_and_exit:
287 ******************************************************************************/ 290 ******************************************************************************/
288 291
289acpi_status 292acpi_status
290acpi_ns_lookup ( 293acpi_ns_lookup(union acpi_generic_state *scope_info,
291 union acpi_generic_state *scope_info, 294 char *pathname,
292 char *pathname, 295 acpi_object_type type,
293 acpi_object_type type, 296 acpi_interpreter_mode interpreter_mode,
294 acpi_interpreter_mode interpreter_mode, 297 u32 flags,
295 u32 flags, 298 struct acpi_walk_state *walk_state,
296 struct acpi_walk_state *walk_state, 299 struct acpi_namespace_node **return_node)
297 struct acpi_namespace_node **return_node)
298{ 300{
299 acpi_status status; 301 acpi_status status;
300 char *path = pathname; 302 char *path = pathname;
301 struct acpi_namespace_node *prefix_node; 303 struct acpi_namespace_node *prefix_node;
302 struct acpi_namespace_node *current_node = NULL; 304 struct acpi_namespace_node *current_node = NULL;
303 struct acpi_namespace_node *this_node = NULL; 305 struct acpi_namespace_node *this_node = NULL;
304 u32 num_segments; 306 u32 num_segments;
305 u32 num_carats; 307 u32 num_carats;
306 acpi_name simple_name; 308 acpi_name simple_name;
307 acpi_object_type type_to_check_for; 309 acpi_object_type type_to_check_for;
308 acpi_object_type this_search_type; 310 acpi_object_type this_search_type;
309 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; 311 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
310 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | 312 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND |
311 ACPI_NS_SEARCH_PARENT); 313 ACPI_NS_SEARCH_PARENT);
312 314
313 315 ACPI_FUNCTION_TRACE("ns_lookup");
314 ACPI_FUNCTION_TRACE ("ns_lookup");
315
316 316
317 if (!return_node) { 317 if (!return_node) {
318 return_ACPI_STATUS (AE_BAD_PARAMETER); 318 return_ACPI_STATUS(AE_BAD_PARAMETER);
319 } 319 }
320 320
321 acpi_gbl_ns_lookup_count++; 321 acpi_gbl_ns_lookup_count++;
322 *return_node = ACPI_ENTRY_NOT_FOUND; 322 *return_node = ACPI_ENTRY_NOT_FOUND;
323 323
324 if (!acpi_gbl_root_node) { 324 if (!acpi_gbl_root_node) {
325 return_ACPI_STATUS (AE_NO_NAMESPACE); 325 return_ACPI_STATUS(AE_NO_NAMESPACE);
326 } 326 }
327 327
328 /* 328 /*
329 * Get the prefix scope. 329 * Get the prefix scope.
330 * A null scope means use the root scope 330 * A null scope means use the root scope
331 */ 331 */
332 if ((!scope_info) || 332 if ((!scope_info) || (!scope_info->scope.node)) {
333 (!scope_info->scope.node)) { 333 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
334 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 334 "Null scope prefix, using root node (%p)\n",
335 "Null scope prefix, using root node (%p)\n", 335 acpi_gbl_root_node));
336 acpi_gbl_root_node));
337 336
338 prefix_node = acpi_gbl_root_node; 337 prefix_node = acpi_gbl_root_node;
339 } 338 } else {
340 else {
341 prefix_node = scope_info->scope.node; 339 prefix_node = scope_info->scope.node;
342 if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) { 340 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
343 ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n", 341 ACPI_DESC_TYPE_NAMED) {
344 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)));
345 return_ACPI_STATUS (AE_AML_INTERNAL); 343 return_ACPI_STATUS(AE_AML_INTERNAL);
346 } 344 }
347 345
348 /* 346 /*
@@ -350,9 +348,9 @@ acpi_ns_lookup (
350 * 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.
351 * Backup up the tree to find the containing scope node. 349 * Backup up the tree to find the containing scope node.
352 */ 350 */
353 while (!acpi_ns_opens_scope (prefix_node->type) && 351 while (!acpi_ns_opens_scope(prefix_node->type) &&
354 prefix_node->type != ACPI_TYPE_ANY) { 352 prefix_node->type != ACPI_TYPE_ANY) {
355 prefix_node = acpi_ns_get_parent_node (prefix_node); 353 prefix_node = acpi_ns_get_parent_node(prefix_node);
356 } 354 }
357 } 355 }
358 356
@@ -367,13 +365,13 @@ acpi_ns_lookup (
367 /* A Null name_path is allowed and refers to the root */ 365 /* A Null name_path is allowed and refers to the root */
368 366
369 num_segments = 0; 367 num_segments = 0;
370 this_node = acpi_gbl_root_node; 368 this_node = acpi_gbl_root_node;
371 path = ""; 369 path = "";
372 370
373 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 371 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
374 "Null Pathname (Zero segments), Flags=%X\n", flags)); 372 "Null Pathname (Zero segments), Flags=%X\n",
375 } 373 flags));
376 else { 374 } else {
377 /* 375 /*
378 * Name pointer is valid (and must be in internal name format) 376 * Name pointer is valid (and must be in internal name format)
379 * 377 *
@@ -397,15 +395,16 @@ acpi_ns_lookup (
397 395
398 path++; 396 path++;
399 397
400 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 398 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
401 "Path is absolute from root [%p]\n", this_node)); 399 "Path is absolute from root [%p]\n",
402 } 400 this_node));
403 else { 401 } else {
404 /* Pathname is relative to current scope, start there */ 402 /* Pathname is relative to current scope, start there */
405 403
406 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 404 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
407 "Searching relative to prefix scope [%4.4s] (%p)\n", 405 "Searching relative to prefix scope [%4.4s] (%p)\n",
408 acpi_ut_get_node_name (prefix_node), prefix_node)); 406 acpi_ut_get_node_name(prefix_node),
407 prefix_node));
409 408
410 /* 409 /*
411 * Handle multiple Parent Prefixes (carat) by just getting 410 * Handle multiple Parent Prefixes (carat) by just getting
@@ -426,20 +425,20 @@ acpi_ns_lookup (
426 /* Backup to the parent node */ 425 /* Backup to the parent node */
427 426
428 num_carats++; 427 num_carats++;
429 this_node = acpi_ns_get_parent_node (this_node); 428 this_node = acpi_ns_get_parent_node(this_node);
430 if (!this_node) { 429 if (!this_node) {
431 /* Current scope has no parent scope */ 430 /* Current scope has no parent scope */
432 431
433 ACPI_REPORT_ERROR ( 432 ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
434 ("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); 433 return_ACPI_STATUS(AE_NOT_FOUND);
435 return_ACPI_STATUS (AE_NOT_FOUND);
436 } 434 }
437 } 435 }
438 436
439 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) { 437 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
440 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 438 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
441 "Search scope is [%4.4s], path has %d carat(s)\n", 439 "Search scope is [%4.4s], path has %d carat(s)\n",
442 acpi_ut_get_node_name (this_node), num_carats)); 440 acpi_ut_get_node_name
441 (this_node), num_carats));
443 } 442 }
444 } 443 }
445 444
@@ -465,9 +464,9 @@ acpi_ns_lookup (
465 num_segments = 0; 464 num_segments = 0;
466 type = this_node->type; 465 type = this_node->type;
467 466
468 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 467 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
469 "Prefix-only Pathname (Zero name segments), Flags=%X\n", 468 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
470 flags)); 469 flags));
471 break; 470 break;
472 471
473 case AML_DUAL_NAME_PREFIX: 472 case AML_DUAL_NAME_PREFIX:
@@ -481,8 +480,9 @@ acpi_ns_lookup (
481 num_segments = 2; 480 num_segments = 2;
482 path++; 481 path++;
483 482
484 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 483 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
485 "Dual Pathname (2 segments, Flags=%X)\n", flags)); 484 "Dual Pathname (2 segments, Flags=%X)\n",
485 flags));
486 break; 486 break;
487 487
488 case AML_MULTI_NAME_PREFIX_OP: 488 case AML_MULTI_NAME_PREFIX_OP:
@@ -494,12 +494,12 @@ acpi_ns_lookup (
494 /* Extract segment count, point to first name segment */ 494 /* Extract segment count, point to first name segment */
495 495
496 path++; 496 path++;
497 num_segments = (u32) (u8) *path; 497 num_segments = (u32) (u8) * path;
498 path++; 498 path++;
499 499
500 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
501 "Multi Pathname (%d Segments, Flags=%X) \n", 501 "Multi Pathname (%d Segments, Flags=%X) \n",
502 num_segments, flags)); 502 num_segments, flags));
503 break; 503 break;
504 504
505 default: 505 default:
@@ -509,15 +509,15 @@ acpi_ns_lookup (
509 */ 509 */
510 num_segments = 1; 510 num_segments = 1;
511 511
512 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 512 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
513 "Simple Pathname (1 segment, Flags=%X)\n", flags)); 513 "Simple Pathname (1 segment, Flags=%X)\n",
514 flags));
514 break; 515 break;
515 } 516 }
516 517
517 ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, path)); 518 ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
518 } 519 }
519 520
520
521 /* 521 /*
522 * Search namespace for each segment of the name. Loop through and 522 * Search namespace for each segment of the name. Loop through and
523 * verify (or add to the namespace) each name segment. 523 * verify (or add to the namespace) each name segment.
@@ -541,7 +541,7 @@ acpi_ns_lookup (
541 * 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
542 */ 542 */
543 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) && 543 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
544 (flags & ACPI_NS_SEARCH_PARENT)) { 544 (flags & ACPI_NS_SEARCH_PARENT)) {
545 local_flags |= ACPI_NS_SEARCH_PARENT; 545 local_flags |= ACPI_NS_SEARCH_PARENT;
546 } 546 }
547 547
@@ -554,24 +554,28 @@ acpi_ns_lookup (
554 554
555 /* Extract one ACPI name from the front of the pathname */ 555 /* Extract one ACPI name from the front of the pathname */
556 556
557 ACPI_MOVE_32_TO_32 (&simple_name, path); 557 ACPI_MOVE_32_TO_32(&simple_name, path);
558 558
559 /* Try to find the single (4 character) ACPI name */ 559 /* Try to find the single (4 character) ACPI name */
560 560
561 status = acpi_ns_search_and_enter (simple_name, walk_state, current_node, 561 status =
562 interpreter_mode, this_search_type, local_flags, &this_node); 562 acpi_ns_search_and_enter(simple_name, walk_state,
563 if (ACPI_FAILURE (status)) { 563 current_node, interpreter_mode,
564 this_search_type, local_flags,
565 &this_node);
566 if (ACPI_FAILURE(status)) {
564 if (status == AE_NOT_FOUND) { 567 if (status == AE_NOT_FOUND) {
565 /* Name not found in ACPI namespace */ 568 /* Name not found in ACPI namespace */
566 569
567 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 570 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
568 "Name [%4.4s] not found in scope [%4.4s] %p\n", 571 "Name [%4.4s] not found in scope [%4.4s] %p\n",
569 (char *) &simple_name, (char *) &current_node->name, 572 (char *)&simple_name,
570 current_node)); 573 (char *)&current_node->name,
574 current_node));
571 } 575 }
572 576
573 *return_node = this_node; 577 *return_node = this_node;
574 return_ACPI_STATUS (status); 578 return_ACPI_STATUS(status);
575 } 579 }
576 580
577 /* 581 /*
@@ -587,19 +591,16 @@ acpi_ns_lookup (
587 * 591 *
588 * Then we have a type mismatch. Just warn and ignore it. 592 * Then we have a type mismatch. Just warn and ignore it.
589 */ 593 */
590 if ((num_segments == 0) && 594 if ((num_segments == 0) &&
591 (type_to_check_for != ACPI_TYPE_ANY) && 595 (type_to_check_for != ACPI_TYPE_ANY) &&
592 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) && 596 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
593 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 597 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
594 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && 598 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) &&
595 (this_node->type != ACPI_TYPE_ANY) && 599 (this_node->type != ACPI_TYPE_ANY) &&
596 (this_node->type != type_to_check_for)) { 600 (this_node->type != type_to_check_for)) {
597 /* Complain about a type mismatch */ 601 /* Complain about a type mismatch */
598 602
599 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)));
600 ("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n",
601 (char *) &simple_name, acpi_ut_get_type_name (this_node->type),
602 acpi_ut_get_type_name (type_to_check_for)));
603 } 604 }
604 605
605 /* 606 /*
@@ -625,15 +626,16 @@ acpi_ns_lookup (
625 * 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
626 * scope stack. 627 * scope stack.
627 */ 628 */
628 if (acpi_ns_opens_scope (type)) { 629 if (acpi_ns_opens_scope(type)) {
629 status = acpi_ds_scope_stack_push (this_node, type, walk_state); 630 status =
630 if (ACPI_FAILURE (status)) { 631 acpi_ds_scope_stack_push(this_node, type,
631 return_ACPI_STATUS (status); 632 walk_state);
633 if (ACPI_FAILURE(status)) {
634 return_ACPI_STATUS(status);
632 } 635 }
633 } 636 }
634 } 637 }
635 638
636 *return_node = this_node; 639 *return_node = this_node;
637 return_ACPI_STATUS (AE_OK); 640 return_ACPI_STATUS(AE_OK);
638} 641}
639
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 21d560decbf9..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_ns_node_list->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
117 ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node);
118 102
103 ACPI_FUNCTION_TRACE_PTR("ns_delete_node", node);
119 104
120 parent_node = acpi_ns_get_parent_node (node); 105 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_ns_node_list->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
@@ -182,19 +164,14 @@ acpi_ns_delete_node (
182 * 164 *
183 ******************************************************************************/ 165 ******************************************************************************/
184 166
185void 167void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
186acpi_ns_install_node ( 168 struct acpi_namespace_node *node, /* New Child */
187 struct acpi_walk_state *walk_state, 169 acpi_object_type type)
188 struct acpi_namespace_node *parent_node, /* Parent */
189 struct acpi_namespace_node *node, /* New Child*/
190 acpi_object_type type)
191{ 170{
192 acpi_owner_id owner_id = 0; 171 acpi_owner_id owner_id = 0;
193 struct acpi_namespace_node *child_node; 172 struct acpi_namespace_node *child_node;
194
195
196 ACPI_FUNCTION_TRACE ("ns_install_node");
197 173
174 ACPI_FUNCTION_TRACE("ns_install_node");
198 175
199 /* 176 /*
200 * Get the owner ID from the Walk state 177 * Get the owner ID from the Walk state
@@ -212,8 +189,7 @@ acpi_ns_install_node (
212 parent_node->child = node; 189 parent_node->child = node;
213 node->flags |= ANOBJ_END_OF_PEER_LIST; 190 node->flags |= ANOBJ_END_OF_PEER_LIST;
214 node->peer = parent_node; 191 node->peer = parent_node;
215 } 192 } else {
216 else {
217 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { 193 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
218 child_node = child_node->peer; 194 child_node = child_node->peer;
219 } 195 }
@@ -232,24 +208,25 @@ acpi_ns_install_node (
232 node->owner_id = owner_id; 208 node->owner_id = owner_id;
233 node->type = (u8) type; 209 node->type = (u8) type;
234 210
235 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 211 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
236 "%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",
237 acpi_ut_get_node_name (node), acpi_ut_get_type_name (node->type), node, owner_id, 213 acpi_ut_get_node_name(node),
238 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,
239 parent_node)); 215 acpi_ut_get_node_name(parent_node),
216 acpi_ut_get_type_name(parent_node->type),
217 parent_node));
240 218
241 /* 219 /*
242 * Increment the reference count(s) of all parents up to 220 * Increment the reference count(s) of all parents up to
243 * the root! 221 * the root!
244 */ 222 */
245 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 223 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
246 node->reference_count++; 224 node->reference_count++;
247 } 225 }
248 226
249 return_VOID; 227 return_VOID;
250} 228}
251 229
252
253/******************************************************************************* 230/*******************************************************************************
254 * 231 *
255 * FUNCTION: acpi_ns_delete_children 232 * FUNCTION: acpi_ns_delete_children
@@ -263,18 +240,14 @@ acpi_ns_install_node (
263 * 240 *
264 ******************************************************************************/ 241 ******************************************************************************/
265 242
266void 243void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
267acpi_ns_delete_children (
268 struct acpi_namespace_node *parent_node)
269{ 244{
270 struct acpi_namespace_node *child_node; 245 struct acpi_namespace_node *child_node;
271 struct acpi_namespace_node *next_node; 246 struct acpi_namespace_node *next_node;
272 struct acpi_namespace_node *node; 247 struct acpi_namespace_node *node;
273 u8 flags; 248 u8 flags;
274
275
276 ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node);
277 249
250 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
278 251
279 if (!parent_node) { 252 if (!parent_node) {
280 return_VOID; 253 return_VOID;
@@ -293,48 +266,48 @@ acpi_ns_delete_children (
293 do { 266 do {
294 /* Get the things we need */ 267 /* Get the things we need */
295 268
296 next_node = child_node->peer; 269 next_node = child_node->peer;
297 flags = child_node->flags; 270 flags = child_node->flags;
298 271
299 /* Grandchildren should have all been deleted already */ 272 /* Grandchildren should have all been deleted already */
300 273
301 if (child_node->child) { 274 if (child_node->child) {
302 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", 275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
303 parent_node, child_node)); 276 "Found a grandchild! P=%p C=%p\n",
277 parent_node, child_node));
304 } 278 }
305 279
306 /* Now we can free this child object */ 280 /* Now we can free this child object */
307 281
308 ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); 282 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
309 283
310 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", 284 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
311 child_node, acpi_gbl_current_node_count)); 285 "Object %p, Remaining %X\n", child_node,
286 acpi_gbl_current_node_count));
312 287
313 /* 288 /*
314 * 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
315 */ 290 */
316 acpi_ns_detach_object (child_node); 291 acpi_ns_detach_object(child_node);
317 292
318 /* 293 /*
319 * Decrement the reference count(s) of all parents up to 294 * Decrement the reference count(s) of all parents up to
320 * the root! (counts were incremented when the node was created) 295 * the root! (counts were incremented when the node was created)
321 */ 296 */
322 node = child_node; 297 node = child_node;
323 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 298 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
324 node->reference_count--; 299 node->reference_count--;
325 } 300 }
326 301
327 /* There should be only one reference remaining on this node */ 302 /* There should be only one reference remaining on this node */
328 303
329 if (child_node->reference_count != 1) { 304 if (child_node->reference_count != 1) {
330 ACPI_REPORT_WARNING (( 305 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node));
331 "Existing references (%d) on node being deleted (%p)\n",
332 child_node->reference_count, child_node));
333 } 306 }
334 307
335 /* Now we can delete the node */ 308 /* Now we can delete the node */
336 309
337 ACPI_MEM_FREE (child_node); 310 ACPI_MEM_FREE(child_node);
338 311
339 /* And move on to the next child in the list */ 312 /* And move on to the next child in the list */
340 313
@@ -342,7 +315,6 @@ acpi_ns_delete_children (
342 315
343 } while (!(flags & ANOBJ_END_OF_PEER_LIST)); 316 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
344 317
345
346 /* Clear the parent's child pointer */ 318 /* Clear the parent's child pointer */
347 319
348 parent_node->child = NULL; 320 parent_node->child = NULL;
@@ -350,7 +322,6 @@ acpi_ns_delete_children (
350 return_VOID; 322 return_VOID;
351} 323}
352 324
353
354/******************************************************************************* 325/*******************************************************************************
355 * 326 *
356 * FUNCTION: acpi_ns_delete_namespace_subtree 327 * FUNCTION: acpi_ns_delete_namespace_subtree
@@ -364,16 +335,12 @@ acpi_ns_delete_children (
364 * 335 *
365 ******************************************************************************/ 336 ******************************************************************************/
366 337
367void 338void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
368acpi_ns_delete_namespace_subtree (
369 struct acpi_namespace_node *parent_node)
370{ 339{
371 struct acpi_namespace_node *child_node = NULL; 340 struct acpi_namespace_node *child_node = NULL;
372 u32 level = 1; 341 u32 level = 1;
373
374
375 ACPI_FUNCTION_TRACE ("ns_delete_namespace_subtree");
376 342
343 ACPI_FUNCTION_TRACE("ns_delete_namespace_subtree");
377 344
378 if (!parent_node) { 345 if (!parent_node) {
379 return_VOID; 346 return_VOID;
@@ -386,16 +353,17 @@ acpi_ns_delete_namespace_subtree (
386 while (level > 0) { 353 while (level > 0) {
387 /* Get the next node in this scope (NULL if none) */ 354 /* Get the next node in this scope (NULL if none) */
388 355
389 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,
390 child_node); 357 child_node);
391 if (child_node) { 358 if (child_node) {
392 /* Found a child node - detach any attached object */ 359 /* Found a child node - detach any attached object */
393 360
394 acpi_ns_detach_object (child_node); 361 acpi_ns_detach_object(child_node);
395 362
396 /* Check if this node has any children */ 363 /* Check if this node has any children */
397 364
398 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)) {
399 /* 367 /*
400 * There is at least one child of this node, 368 * There is at least one child of this node,
401 * visit the node 369 * visit the node
@@ -404,8 +372,7 @@ acpi_ns_delete_namespace_subtree (
404 parent_node = child_node; 372 parent_node = child_node;
405 child_node = NULL; 373 child_node = NULL;
406 } 374 }
407 } 375 } else {
408 else {
409 /* 376 /*
410 * No more children of this parent node. 377 * No more children of this parent node.
411 * Move up to the grandparent. 378 * Move up to the grandparent.
@@ -416,7 +383,7 @@ acpi_ns_delete_namespace_subtree (
416 * Now delete all of the children of this parent 383 * Now delete all of the children of this parent
417 * all at the same time. 384 * all at the same time.
418 */ 385 */
419 acpi_ns_delete_children (parent_node); 386 acpi_ns_delete_children(parent_node);
420 387
421 /* New "last child" is this parent node */ 388 /* New "last child" is this parent node */
422 389
@@ -424,14 +391,13 @@ acpi_ns_delete_namespace_subtree (
424 391
425 /* Move up the tree to the grandparent */ 392 /* Move up the tree to the grandparent */
426 393
427 parent_node = acpi_ns_get_parent_node (parent_node); 394 parent_node = acpi_ns_get_parent_node(parent_node);
428 } 395 }
429 } 396 }
430 397
431 return_VOID; 398 return_VOID;
432} 399}
433 400
434
435/******************************************************************************* 401/*******************************************************************************
436 * 402 *
437 * FUNCTION: acpi_ns_remove_reference 403 * FUNCTION: acpi_ns_remove_reference
@@ -447,16 +413,12 @@ acpi_ns_delete_namespace_subtree (
447 * 413 *
448 ******************************************************************************/ 414 ******************************************************************************/
449 415
450static void 416static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
451acpi_ns_remove_reference (
452 struct acpi_namespace_node *node)
453{ 417{
454 struct acpi_namespace_node *parent_node; 418 struct acpi_namespace_node *parent_node;
455 struct acpi_namespace_node *this_node; 419 struct acpi_namespace_node *this_node;
456
457
458 ACPI_FUNCTION_ENTRY ();
459 420
421 ACPI_FUNCTION_ENTRY();
460 422
461 /* 423 /*
462 * Decrement the reference count(s) of this node and all 424 * Decrement the reference count(s) of this node and all
@@ -466,7 +428,7 @@ acpi_ns_remove_reference (
466 while (this_node) { 428 while (this_node) {
467 /* Prepare to move up to parent */ 429 /* Prepare to move up to parent */
468 430
469 parent_node = acpi_ns_get_parent_node (this_node); 431 parent_node = acpi_ns_get_parent_node(this_node);
470 432
471 /* Decrement the reference count on this node */ 433 /* Decrement the reference count on this node */
472 434
@@ -477,15 +439,14 @@ acpi_ns_remove_reference (
477 if (!this_node->reference_count) { 439 if (!this_node->reference_count) {
478 /* Delete all children and delete the node */ 440 /* Delete all children and delete the node */
479 441
480 acpi_ns_delete_children (this_node); 442 acpi_ns_delete_children(this_node);
481 acpi_ns_delete_node (this_node); 443 acpi_ns_delete_node(this_node);
482 } 444 }
483 445
484 this_node = parent_node; 446 this_node = parent_node;
485 } 447 }
486} 448}
487 449
488
489/******************************************************************************* 450/*******************************************************************************
490 * 451 *
491 * FUNCTION: acpi_ns_delete_namespace_by_owner 452 * FUNCTION: acpi_ns_delete_namespace_by_owner
@@ -500,27 +461,23 @@ acpi_ns_remove_reference (
500 * 461 *
501 ******************************************************************************/ 462 ******************************************************************************/
502 463
503void 464void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
504acpi_ns_delete_namespace_by_owner (
505 acpi_owner_id owner_id)
506{ 465{
507 struct acpi_namespace_node *child_node; 466 struct acpi_namespace_node *child_node;
508 struct acpi_namespace_node *deletion_node; 467 struct acpi_namespace_node *deletion_node;
509 u32 level; 468 u32 level;
510 struct acpi_namespace_node *parent_node; 469 struct acpi_namespace_node *parent_node;
511
512
513 ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id);
514 470
471 ACPI_FUNCTION_TRACE_U32("ns_delete_namespace_by_owner", owner_id);
515 472
516 if (owner_id == 0) { 473 if (owner_id == 0) {
517 return_VOID; 474 return_VOID;
518 } 475 }
519 476
520 parent_node = acpi_gbl_root_node; 477 parent_node = acpi_gbl_root_node;
521 child_node = NULL; 478 child_node = NULL;
522 deletion_node = NULL; 479 deletion_node = NULL;
523 level = 1; 480 level = 1;
524 481
525 /* 482 /*
526 * Traverse the tree of nodes until we bubble back up 483 * Traverse the tree of nodes until we bubble back up
@@ -531,10 +488,12 @@ acpi_ns_delete_namespace_by_owner (
531 * 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,
532 * the first child of the parent is returned 489 * the first child of the parent is returned
533 */ 490 */
534 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);
535 494
536 if (deletion_node) { 495 if (deletion_node) {
537 acpi_ns_remove_reference (deletion_node); 496 acpi_ns_remove_reference(deletion_node);
538 deletion_node = NULL; 497 deletion_node = NULL;
539 } 498 }
540 499
@@ -542,12 +501,13 @@ acpi_ns_delete_namespace_by_owner (
542 if (child_node->owner_id == owner_id) { 501 if (child_node->owner_id == owner_id) {
543 /* Found a matching child node - detach any attached object */ 502 /* Found a matching child node - detach any attached object */
544 503
545 acpi_ns_detach_object (child_node); 504 acpi_ns_detach_object(child_node);
546 } 505 }
547 506
548 /* Check if this node has any children */ 507 /* Check if this node has any children */
549 508
550 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)) {
551 /* 511 /*
552 * There is at least one child of this node, 512 * There is at least one child of this node,
553 * visit the node 513 * visit the node
@@ -555,12 +515,10 @@ acpi_ns_delete_namespace_by_owner (
555 level++; 515 level++;
556 parent_node = child_node; 516 parent_node = child_node;
557 child_node = NULL; 517 child_node = NULL;
558 } 518 } else if (child_node->owner_id == owner_id) {
559 else if (child_node->owner_id == owner_id) {
560 deletion_node = child_node; 519 deletion_node = child_node;
561 } 520 }
562 } 521 } else {
563 else {
564 /* 522 /*
565 * No more children of this parent node. 523 * No more children of this parent node.
566 * Move up to the grandparent. 524 * Move up to the grandparent.
@@ -578,11 +536,9 @@ acpi_ns_delete_namespace_by_owner (
578 536
579 /* Move up the tree to the grandparent */ 537 /* Move up the tree to the grandparent */
580 538
581 parent_node = acpi_ns_get_parent_node (parent_node); 539 parent_node = acpi_ns_get_parent_node(parent_node);
582 } 540 }
583 } 541 }
584 542
585 return_VOID; 543 return_VOID;
586} 544}
587
588
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 5d25add6b031..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,43 +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_native_uint i; 76 acpi_native_uint i;
89 77
78 ACPI_FUNCTION_NAME("ns_print_pathname");
90 79
91 ACPI_FUNCTION_NAME ("ns_print_pathname"); 80 if (!(acpi_dbg_level & ACPI_LV_NAMES)
92 81 || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
93
94 if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
95 return; 82 return;
96 } 83 }
97 84
98 /* Print the entire name */ 85 /* Print the entire name */
99 86
100 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); 87 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
101 88
102 while (num_segments) { 89 while (num_segments) {
103 for (i = 0; i < 4; i++) { 90 for (i = 0; i < 4; i++) {
104 ACPI_IS_PRINT (pathname[i]) ? 91 ACPI_IS_PRINT(pathname[i]) ?
105 acpi_os_printf ("%c", pathname[i]) : 92 acpi_os_printf("%c", pathname[i]) :
106 acpi_os_printf ("?"); 93 acpi_os_printf("?");
107 } 94 }
108 95
109 pathname += ACPI_NAME_SIZE; 96 pathname += ACPI_NAME_SIZE;
110 num_segments--; 97 num_segments--;
111 if (num_segments) { 98 if (num_segments) {
112 acpi_os_printf ("."); 99 acpi_os_printf(".");
113 } 100 }
114 } 101 }
115 102
116 acpi_os_printf ("]\n"); 103 acpi_os_printf("]\n");
117} 104}
118 105
119
120/******************************************************************************* 106/*******************************************************************************
121 * 107 *
122 * FUNCTION: acpi_ns_dump_pathname 108 * FUNCTION: acpi_ns_dump_pathname
@@ -134,15 +120,10 @@ acpi_ns_print_pathname (
134 ******************************************************************************/ 120 ******************************************************************************/
135 121
136void 122void
137acpi_ns_dump_pathname ( 123acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
138 acpi_handle handle,
139 char *msg,
140 u32 level,
141 u32 component)
142{ 124{
143 125
144 ACPI_FUNCTION_TRACE ("ns_dump_pathname"); 126 ACPI_FUNCTION_TRACE("ns_dump_pathname");
145
146 127
147 /* 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 */
148 129
@@ -152,12 +133,11 @@ acpi_ns_dump_pathname (
152 133
153 /* 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) */
154 135
155 acpi_ns_print_node_pathname (handle, msg); 136 acpi_ns_print_node_pathname(handle, msg);
156 acpi_os_printf ("\n"); 137 acpi_os_printf("\n");
157 return_VOID; 138 return_VOID;
158} 139}
159 140
160
161/******************************************************************************* 141/*******************************************************************************
162 * 142 *
163 * FUNCTION: acpi_ns_dump_one_object 143 * FUNCTION: acpi_ns_dump_one_object
@@ -175,24 +155,19 @@ acpi_ns_dump_pathname (
175 ******************************************************************************/ 155 ******************************************************************************/
176 156
177acpi_status 157acpi_status
178acpi_ns_dump_one_object ( 158acpi_ns_dump_one_object(acpi_handle obj_handle,
179 acpi_handle obj_handle, 159 u32 level, void *context, void **return_value)
180 u32 level,
181 void *context,
182 void **return_value)
183{ 160{
184 struct acpi_walk_info *info = (struct acpi_walk_info *) context; 161 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
185 struct acpi_namespace_node *this_node; 162 struct acpi_namespace_node *this_node;
186 union acpi_operand_object *obj_desc = NULL; 163 union acpi_operand_object *obj_desc = NULL;
187 acpi_object_type obj_type; 164 acpi_object_type obj_type;
188 acpi_object_type type; 165 acpi_object_type type;
189 u32 bytes_to_dump; 166 u32 bytes_to_dump;
190 u32 dbg_level; 167 u32 dbg_level;
191 u32 i; 168 u32 i;
192
193
194 ACPI_FUNCTION_NAME ("ns_dump_one_object");
195 169
170 ACPI_FUNCTION_NAME("ns_dump_one_object");
196 171
197 /* Is output enabled? */ 172 /* Is output enabled? */
198 173
@@ -201,48 +176,47 @@ acpi_ns_dump_one_object (
201 } 176 }
202 177
203 if (!obj_handle) { 178 if (!obj_handle) {
204 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
205 return (AE_OK); 180 return (AE_OK);
206 } 181 }
207 182
208 this_node = acpi_ns_map_handle_to_node (obj_handle); 183 this_node = acpi_ns_map_handle_to_node(obj_handle);
209 type = this_node->type; 184 type = this_node->type;
210 185
211 /* Check if the owner matches */ 186 /* Check if the owner matches */
212 187
213 if ((info->owner_id != ACPI_OWNER_ID_MAX) && 188 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
214 (info->owner_id != this_node->owner_id)) { 189 (info->owner_id != this_node->owner_id)) {
215 return (AE_OK); 190 return (AE_OK);
216 } 191 }
217 192
218 if (!(info->display_type & ACPI_DISPLAY_SHORT)) { 193 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
219 /* Indent the object according to the level */ 194 /* Indent the object according to the level */
220 195
221 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); 196 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
222 197
223 /* Check the node type and name */ 198 /* Check the node type and name */
224 199
225 if (type > ACPI_TYPE_LOCAL_MAX) { 200 if (type > ACPI_TYPE_LOCAL_MAX) {
226 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); 201 ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type));
227 } 202 }
228 203
229 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { 204 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
230 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", 205 ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n",
231 this_node->name.integer)); 206 this_node->name.integer));
232 } 207 }
233 208
234 acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node)); 209 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
235 } 210 }
236 211
237 /* 212 /*
238 * Now we can print out the pertinent information 213 * Now we can print out the pertinent information
239 */ 214 */
240 acpi_os_printf (" %-12s %p ", 215 acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node);
241 acpi_ut_get_type_name (type), this_node);
242 216
243 dbg_level = acpi_dbg_level; 217 dbg_level = acpi_dbg_level;
244 acpi_dbg_level = 0; 218 acpi_dbg_level = 0;
245 obj_desc = acpi_ns_get_attached_object (this_node); 219 obj_desc = acpi_ns_get_attached_object(this_node);
246 acpi_dbg_level = dbg_level; 220 acpi_dbg_level = dbg_level;
247 221
248 switch (info->display_type & ACPI_DISPLAY_MASK) { 222 switch (info->display_type & ACPI_DISPLAY_MASK) {
@@ -251,147 +225,166 @@ acpi_ns_dump_one_object (
251 if (!obj_desc) { 225 if (!obj_desc) {
252 /* No attached object, we are done */ 226 /* No attached object, we are done */
253 227
254 acpi_os_printf ("\n"); 228 acpi_os_printf("\n");
255 return (AE_OK); 229 return (AE_OK);
256 } 230 }
257 231
258 switch (type) { 232 switch (type) {
259 case ACPI_TYPE_PROCESSOR: 233 case ACPI_TYPE_PROCESSOR:
260 234
261 acpi_os_printf ("ID %X Len %.4X Addr %p\n", 235 acpi_os_printf("ID %X Len %.4X Addr %p\n",
262 obj_desc->processor.proc_id, obj_desc->processor.length, 236 obj_desc->processor.proc_id,
263 (char *) obj_desc->processor.address); 237 obj_desc->processor.length,
238 (char *)obj_desc->processor.address);
264 break; 239 break;
265 240
266
267 case ACPI_TYPE_DEVICE: 241 case ACPI_TYPE_DEVICE:
268 242
269 acpi_os_printf ("Notify Object: %p\n", obj_desc); 243 acpi_os_printf("Notify Object: %p\n", obj_desc);
270 break; 244 break;
271 245
272
273 case ACPI_TYPE_METHOD: 246 case ACPI_TYPE_METHOD:
274 247
275 acpi_os_printf ("Args %X Len %.4X Aml %p\n", 248 acpi_os_printf("Args %X Len %.4X Aml %p\n",
276 (u32) obj_desc->method.param_count, 249 (u32) obj_desc->method.param_count,
277 obj_desc->method.aml_length, obj_desc->method.aml_start); 250 obj_desc->method.aml_length,
251 obj_desc->method.aml_start);
278 break; 252 break;
279 253
280
281 case ACPI_TYPE_INTEGER: 254 case ACPI_TYPE_INTEGER:
282 255
283 acpi_os_printf ("= %8.8X%8.8X\n", 256 acpi_os_printf("= %8.8X%8.8X\n",
284 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 257 ACPI_FORMAT_UINT64(obj_desc->integer.
258 value));
285 break; 259 break;
286 260
287
288 case ACPI_TYPE_PACKAGE: 261 case ACPI_TYPE_PACKAGE:
289 262
290 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 263 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
291 acpi_os_printf ("Elements %.2X\n", 264 acpi_os_printf("Elements %.2X\n",
292 obj_desc->package.count); 265 obj_desc->package.count);
293 } 266 } else {
294 else { 267 acpi_os_printf("[Length not yet evaluated]\n");
295 acpi_os_printf ("[Length not yet evaluated]\n");
296 } 268 }
297 break; 269 break;
298 270
299
300 case ACPI_TYPE_BUFFER: 271 case ACPI_TYPE_BUFFER:
301 272
302 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 273 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
303 acpi_os_printf ("Len %.2X", 274 acpi_os_printf("Len %.2X",
304 obj_desc->buffer.length); 275 obj_desc->buffer.length);
305 276
306 /* Dump some of the buffer */ 277 /* Dump some of the buffer */
307 278
308 if (obj_desc->buffer.length > 0) { 279 if (obj_desc->buffer.length > 0) {
309 acpi_os_printf (" ="); 280 acpi_os_printf(" =");
310 for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) { 281 for (i = 0;
311 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]);
312 } 287 }
313 } 288 }
314 acpi_os_printf ("\n"); 289 acpi_os_printf("\n");
315 } 290 } else {
316 else { 291 acpi_os_printf("[Length not yet evaluated]\n");
317 acpi_os_printf ("[Length not yet evaluated]\n");
318 } 292 }
319 break; 293 break;
320 294
321
322 case ACPI_TYPE_STRING: 295 case ACPI_TYPE_STRING:
323 296
324 acpi_os_printf ("Len %.2X ", obj_desc->string.length); 297 acpi_os_printf("Len %.2X ", obj_desc->string.length);
325 acpi_ut_print_string (obj_desc->string.pointer, 32); 298 acpi_ut_print_string(obj_desc->string.pointer, 32);
326 acpi_os_printf ("\n"); 299 acpi_os_printf("\n");
327 break; 300 break;
328 301
329
330 case ACPI_TYPE_REGION: 302 case ACPI_TYPE_REGION:
331 303
332 acpi_os_printf ("[%s]", 304 acpi_os_printf("[%s]",
333 acpi_ut_get_region_name (obj_desc->region.space_id)); 305 acpi_ut_get_region_name(obj_desc->region.
306 space_id));
334 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 307 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
335 acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n", 308 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
336 ACPI_FORMAT_UINT64 (obj_desc->region.address), 309 ACPI_FORMAT_UINT64(obj_desc->
337 obj_desc->region.length); 310 region.
338 } 311 address),
339 else { 312 obj_desc->region.length);
340 acpi_os_printf (" [Address/Length not yet evaluated]\n"); 313 } else {
314 acpi_os_printf
315 (" [Address/Length not yet evaluated]\n");
341 } 316 }
342 break; 317 break;
343 318
344
345 case ACPI_TYPE_LOCAL_REFERENCE: 319 case ACPI_TYPE_LOCAL_REFERENCE:
346 320
347 acpi_os_printf ("[%s]\n", 321 acpi_os_printf("[%s]\n",
348 acpi_ps_get_opcode_name (obj_desc->reference.opcode)); 322 acpi_ps_get_opcode_name(obj_desc->
323 reference.
324 opcode));
349 break; 325 break;
350 326
351
352 case ACPI_TYPE_BUFFER_FIELD: 327 case ACPI_TYPE_BUFFER_FIELD:
353 328
354 if (obj_desc->buffer_field.buffer_obj && 329 if (obj_desc->buffer_field.buffer_obj &&
355 obj_desc->buffer_field.buffer_obj->buffer.node) { 330 obj_desc->buffer_field.buffer_obj->buffer.node) {
356 acpi_os_printf ("Buf [%4.4s]", 331 acpi_os_printf("Buf [%4.4s]",
357 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));
358 } 337 }
359 break; 338 break;
360 339
361
362 case ACPI_TYPE_LOCAL_REGION_FIELD: 340 case ACPI_TYPE_LOCAL_REGION_FIELD:
363 341
364 acpi_os_printf ("Rgn [%4.4s]", 342 acpi_os_printf("Rgn [%4.4s]",
365 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));
366 break; 347 break;
367 348
368
369 case ACPI_TYPE_LOCAL_BANK_FIELD: 349 case ACPI_TYPE_LOCAL_BANK_FIELD:
370 350
371 acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]", 351 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
372 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node), 352 acpi_ut_get_node_name(obj_desc->
373 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));
374 break; 361 break;
375 362
376
377 case ACPI_TYPE_LOCAL_INDEX_FIELD: 363 case ACPI_TYPE_LOCAL_INDEX_FIELD:
378 364
379 acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]", 365 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
380 acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node), 366 acpi_ut_get_node_name(obj_desc->
381 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));
382 break; 375 break;
383 376
384
385 case ACPI_TYPE_LOCAL_ALIAS: 377 case ACPI_TYPE_LOCAL_ALIAS:
386 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 378 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
387 379
388 acpi_os_printf ("Target %4.4s (%p)\n", 380 acpi_os_printf("Target %4.4s (%p)\n",
389 acpi_ut_get_node_name (obj_desc), obj_desc); 381 acpi_ut_get_node_name(obj_desc),
382 obj_desc);
390 break; 383 break;
391 384
392 default: 385 default:
393 386
394 acpi_os_printf ("Object %p\n", obj_desc); 387 acpi_os_printf("Object %p\n", obj_desc);
395 break; 388 break;
396 } 389 }
397 390
@@ -403,11 +396,15 @@ acpi_ns_dump_one_object (
403 case ACPI_TYPE_LOCAL_BANK_FIELD: 396 case ACPI_TYPE_LOCAL_BANK_FIELD:
404 case ACPI_TYPE_LOCAL_INDEX_FIELD: 397 case ACPI_TYPE_LOCAL_INDEX_FIELD:
405 398
406 acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n", 399 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
407 (obj_desc->common_field.base_byte_offset * 8) 400 (obj_desc->common_field.
408 + obj_desc->common_field.start_field_bit_offset, 401 base_byte_offset * 8)
409 obj_desc->common_field.bit_length, 402 +
410 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);
411 break; 408 break;
412 409
413 default: 410 default:
@@ -415,56 +412,55 @@ acpi_ns_dump_one_object (
415 } 412 }
416 break; 413 break;
417 414
418
419 case ACPI_DISPLAY_OBJECTS: 415 case ACPI_DISPLAY_OBJECTS:
420 416
421 acpi_os_printf ("O:%p", obj_desc); 417 acpi_os_printf("O:%p", obj_desc);
422 if (!obj_desc) { 418 if (!obj_desc) {
423 /* No attached object, we are done */ 419 /* No attached object, we are done */
424 420
425 acpi_os_printf ("\n"); 421 acpi_os_printf("\n");
426 return (AE_OK); 422 return (AE_OK);
427 } 423 }
428 424
429 acpi_os_printf ("(R%d)", obj_desc->common.reference_count); 425 acpi_os_printf("(R%d)", obj_desc->common.reference_count);
430 426
431 switch (type) { 427 switch (type) {
432 case ACPI_TYPE_METHOD: 428 case ACPI_TYPE_METHOD:
433 429
434 /* Name is a Method and its AML offset/length are set */ 430 /* Name is a Method and its AML offset/length are set */
435 431
436 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,
437 obj_desc->method.aml_length); 433 obj_desc->method.aml_length);
438 break; 434 break;
439 435
440 case ACPI_TYPE_INTEGER: 436 case ACPI_TYPE_INTEGER:
441 437
442 acpi_os_printf (" I:%8.8X8.8%X\n", 438 acpi_os_printf(" I:%8.8X8.8%X\n",
443 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 439 ACPI_FORMAT_UINT64(obj_desc->integer.
440 value));
444 break; 441 break;
445 442
446 case ACPI_TYPE_STRING: 443 case ACPI_TYPE_STRING:
447 444
448 acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer, 445 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
449 obj_desc->string.length); 446 obj_desc->string.length);
450 break; 447 break;
451 448
452 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
453 450
454 acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer, 451 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
455 obj_desc->buffer.length); 452 obj_desc->buffer.length);
456 break; 453 break;
457 454
458 default: 455 default:
459 456
460 acpi_os_printf ("\n"); 457 acpi_os_printf("\n");
461 break; 458 break;
462 } 459 }
463 break; 460 break;
464 461
465
466 default: 462 default:
467 acpi_os_printf ("\n"); 463 acpi_os_printf("\n");
468 break; 464 break;
469 } 465 }
470 466
@@ -474,46 +470,47 @@ acpi_ns_dump_one_object (
474 return (AE_OK); 470 return (AE_OK);
475 } 471 }
476 472
477
478 /* If there is an attached object, display it */ 473 /* If there is an attached object, display it */
479 474
480 dbg_level = acpi_dbg_level; 475 dbg_level = acpi_dbg_level;
481 acpi_dbg_level = 0; 476 acpi_dbg_level = 0;
482 obj_desc = acpi_ns_get_attached_object (this_node); 477 obj_desc = acpi_ns_get_attached_object(this_node);
483 acpi_dbg_level = dbg_level; 478 acpi_dbg_level = dbg_level;
484 479
485 /* Dump attached objects */ 480 /* Dump attached objects */
486 481
487 while (obj_desc) { 482 while (obj_desc) {
488 obj_type = ACPI_TYPE_INVALID; 483 obj_type = ACPI_TYPE_INVALID;
489 acpi_os_printf ("Attached Object %p: ", obj_desc); 484 acpi_os_printf("Attached Object %p: ", obj_desc);
490 485
491 /* Decode the type of attached object and dump the contents */ 486 /* Decode the type of attached object and dump the contents */
492 487
493 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 488 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
494 case ACPI_DESC_TYPE_NAMED: 489 case ACPI_DESC_TYPE_NAMED:
495 490
496 acpi_os_printf ("(Ptr to Node)\n"); 491 acpi_os_printf("(Ptr to Node)\n");
497 bytes_to_dump = sizeof (struct acpi_namespace_node); 492 bytes_to_dump = sizeof(struct acpi_namespace_node);
498 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); 493 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
499 break; 494 break;
500 495
501 case ACPI_DESC_TYPE_OPERAND: 496 case ACPI_DESC_TYPE_OPERAND:
502 497
503 obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); 498 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
504 499
505 if (obj_type > ACPI_TYPE_LOCAL_MAX) { 500 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
506 acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", 501 acpi_os_printf
507 obj_type); 502 ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
503 obj_type);
508 bytes_to_dump = 32; 504 bytes_to_dump = 32;
509 } 505 } else {
510 else { 506 acpi_os_printf
511 acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n", 507 ("(Ptr to ACPI Object type %X [%s])\n",
512 obj_type, acpi_ut_get_type_name (obj_type)); 508 obj_type, acpi_ut_get_type_name(obj_type));
513 bytes_to_dump = sizeof (union acpi_operand_object); 509 bytes_to_dump =
510 sizeof(union acpi_operand_object);
514 } 511 }
515 512
516 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); 513 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
517 break; 514 break;
518 515
519 default: 516 default:
@@ -523,7 +520,8 @@ acpi_ns_dump_one_object (
523 520
524 /* If value is NOT an internal object, we are done */ 521 /* If value is NOT an internal object, we are done */
525 522
526 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 523 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
524 ACPI_DESC_TYPE_OPERAND) {
527 goto cleanup; 525 goto cleanup;
528 } 526 }
529 527
@@ -537,49 +535,50 @@ acpi_ns_dump_one_object (
537 * NOTE: takes advantage of common fields between string/buffer 535 * NOTE: takes advantage of common fields between string/buffer
538 */ 536 */
539 bytes_to_dump = obj_desc->string.length; 537 bytes_to_dump = obj_desc->string.length;
540 obj_desc = (void *) obj_desc->string.pointer; 538 obj_desc = (void *)obj_desc->string.pointer;
541 acpi_os_printf ( "(Buffer/String pointer %p length %X)\n", 539 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
542 obj_desc, bytes_to_dump); 540 obj_desc, bytes_to_dump);
543 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); 541 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
544 goto cleanup; 542 goto cleanup;
545 543
546 case ACPI_TYPE_BUFFER_FIELD: 544 case ACPI_TYPE_BUFFER_FIELD:
547 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;
548 break; 548 break;
549 549
550 case ACPI_TYPE_PACKAGE: 550 case ACPI_TYPE_PACKAGE:
551 obj_desc = (void *) obj_desc->package.elements; 551 obj_desc = (void *)obj_desc->package.elements;
552 break; 552 break;
553 553
554 case ACPI_TYPE_METHOD: 554 case ACPI_TYPE_METHOD:
555 obj_desc = (void *) obj_desc->method.aml_start; 555 obj_desc = (void *)obj_desc->method.aml_start;
556 break; 556 break;
557 557
558 case ACPI_TYPE_LOCAL_REGION_FIELD: 558 case ACPI_TYPE_LOCAL_REGION_FIELD:
559 obj_desc = (void *) obj_desc->field.region_obj; 559 obj_desc = (void *)obj_desc->field.region_obj;
560 break; 560 break;
561 561
562 case ACPI_TYPE_LOCAL_BANK_FIELD: 562 case ACPI_TYPE_LOCAL_BANK_FIELD:
563 obj_desc = (void *) obj_desc->bank_field.region_obj; 563 obj_desc = (void *)obj_desc->bank_field.region_obj;
564 break; 564 break;
565 565
566 case ACPI_TYPE_LOCAL_INDEX_FIELD: 566 case ACPI_TYPE_LOCAL_INDEX_FIELD:
567 obj_desc = (void *) obj_desc->index_field.index_obj; 567 obj_desc = (void *)obj_desc->index_field.index_obj;
568 break; 568 break;
569 569
570 default: 570 default:
571 goto cleanup; 571 goto cleanup;
572 } 572 }
573 573
574 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ 574 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
575 } 575 }
576 576
577cleanup: 577 cleanup:
578 acpi_os_printf ("\n"); 578 acpi_os_printf("\n");
579 return (AE_OK); 579 return (AE_OK);
580} 580}
581 581
582
583#ifdef ACPI_FUTURE_USAGE 582#ifdef ACPI_FUTURE_USAGE
584/******************************************************************************* 583/*******************************************************************************
585 * 584 *
@@ -601,29 +600,25 @@ cleanup:
601 ******************************************************************************/ 600 ******************************************************************************/
602 601
603void 602void
604acpi_ns_dump_objects ( 603acpi_ns_dump_objects(acpi_object_type type,
605 acpi_object_type type, 604 u8 display_type,
606 u8 display_type, 605 u32 max_depth,
607 u32 max_depth, 606 acpi_owner_id owner_id, acpi_handle start_handle)
608 acpi_owner_id owner_id,
609 acpi_handle start_handle)
610{ 607{
611 struct acpi_walk_info info; 608 struct acpi_walk_info info;
612
613
614 ACPI_FUNCTION_ENTRY ();
615 609
610 ACPI_FUNCTION_ENTRY();
616 611
617 info.debug_level = ACPI_LV_TABLES; 612 info.debug_level = ACPI_LV_TABLES;
618 info.owner_id = owner_id; 613 info.owner_id = owner_id;
619 info.display_type = display_type; 614 info.display_type = display_type;
620 615
621 (void) acpi_ns_walk_namespace (type, start_handle, max_depth, 616 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
622 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, 617 ACPI_NS_WALK_NO_UNLOCK,
623 (void *) &info, NULL); 618 acpi_ns_dump_one_object, (void *)&info,
619 NULL);
624} 620}
625#endif /* ACPI_FUTURE_USAGE */ 621#endif /* ACPI_FUTURE_USAGE */
626
627 622
628/******************************************************************************* 623/*******************************************************************************
629 * 624 *
@@ -638,25 +633,19 @@ acpi_ns_dump_objects (
638 * 633 *
639 ******************************************************************************/ 634 ******************************************************************************/
640 635
641void 636void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
642acpi_ns_dump_entry (
643 acpi_handle handle,
644 u32 debug_level)
645{ 637{
646 struct acpi_walk_info info; 638 struct acpi_walk_info info;
647
648
649 ACPI_FUNCTION_ENTRY ();
650 639
640 ACPI_FUNCTION_ENTRY();
651 641
652 info.debug_level = debug_level; 642 info.debug_level = debug_level;
653 info.owner_id = ACPI_OWNER_ID_MAX; 643 info.owner_id = ACPI_OWNER_ID_MAX;
654 info.display_type = ACPI_DISPLAY_SUMMARY; 644 info.display_type = ACPI_DISPLAY_SUMMARY;
655 645
656 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); 646 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
657} 647}
658 648
659
660#ifdef ACPI_ASL_COMPILER 649#ifdef ACPI_ASL_COMPILER
661/******************************************************************************* 650/*******************************************************************************
662 * 651 *
@@ -673,23 +662,19 @@ acpi_ns_dump_entry (
673 * 662 *
674 ******************************************************************************/ 663 ******************************************************************************/
675 664
676void 665void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
677acpi_ns_dump_tables (
678 acpi_handle search_base,
679 u32 max_depth)
680{ 666{
681 acpi_handle search_handle = search_base; 667 acpi_handle search_handle = search_base;
682
683
684 ACPI_FUNCTION_TRACE ("ns_dump_tables");
685 668
669 ACPI_FUNCTION_TRACE("ns_dump_tables");
686 670
687 if (!acpi_gbl_root_node) { 671 if (!acpi_gbl_root_node) {
688 /* 672 /*
689 * If the name space has not been initialized, 673 * If the name space has not been initialized,
690 * there is nothing to dump. 674 * there is nothing to dump.
691 */ 675 */
692 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); 676 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
677 "namespace not initialized!\n"));
693 return_VOID; 678 return_VOID;
694 } 679 }
695 680
@@ -697,12 +682,12 @@ acpi_ns_dump_tables (
697 /* Entire namespace */ 682 /* Entire namespace */
698 683
699 search_handle = acpi_gbl_root_node; 684 search_handle = acpi_gbl_root_node;
700 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); 685 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
701 } 686 }
702 687
703 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,
704 ACPI_OWNER_ID_MAX, search_handle); 689 ACPI_OWNER_ID_MAX, search_handle);
705 return_VOID; 690 return_VOID;
706} 691}
707#endif /* _ACPI_ASL_COMPILER */ 692#endif /* _ACPI_ASL_COMPILER */
708#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 908cffd5e720..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,10 +335,9 @@ 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
@@ -384,30 +363,29 @@ acpi_ns_evaluate_by_handle (
384 ******************************************************************************/ 363 ******************************************************************************/
385 364
386static acpi_status 365static acpi_status
387acpi_ns_execute_control_method ( 366acpi_ns_execute_control_method(struct acpi_parameter_info *info)
388 struct acpi_parameter_info *info)
389{ 367{
390 acpi_status status; 368 acpi_status status;
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 info->obj_desc = acpi_ns_get_attached_object (info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
399 if (!info->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 info->obj_desc->method.aml_start + 1, info->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_ps_execute_method (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 1428a84a31e6..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
186 ACPI_FUNCTION_TRACE ("ns_load_table_by_type");
187 170
171 ACPI_FUNCTION_TRACE("ns_load_table_by_type");
188 172
189 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 173 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
190 if (ACPI_FAILURE (status)) { 174 if (ACPI_FAILURE(status)) {
191 return_ACPI_STATUS (status); 175 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, "Namespace load: 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,18 +194,18 @@ 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:
221 case ACPI_TABLE_PSDT: 204 case ACPI_TABLE_PSDT:
222 205
223 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: %d SSDT or PSDTs\n", 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
224 acpi_gbl_table_lists[table_type].count)); 207 "Namespace load: %d SSDT or PSDTs\n",
208 acpi_gbl_table_lists[table_type].count));
225 209
226 /* 210 /*
227 * Traverse list of SSDT or PSDT tables 211 * Traverse list of SSDT or PSDT tables
@@ -233,8 +217,10 @@ acpi_ns_load_table_by_type (
233 * already loaded! 217 * already loaded!
234 */ 218 */
235 if (!table_desc->loaded_into_namespace) { 219 if (!table_desc->loaded_into_namespace) {
236 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); 220 status =
237 if (ACPI_FAILURE (status)) { 221 acpi_ns_load_table(table_desc,
222 acpi_gbl_root_node);
223 if (ACPI_FAILURE(status)) {
238 break; 224 break;
239 } 225 }
240 226
@@ -245,19 +231,16 @@ acpi_ns_load_table_by_type (
245 } 231 }
246 break; 232 break;
247 233
248
249 default: 234 default:
250 status = AE_SUPPORT; 235 status = AE_SUPPORT;
251 break; 236 break;
252 } 237 }
253 238
254 239 unlock_and_exit:
255unlock_and_exit: 240 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
256 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 241 return_ACPI_STATUS(status);
257 return_ACPI_STATUS (status);
258} 242}
259 243
260
261/******************************************************************************* 244/*******************************************************************************
262 * 245 *
263 * FUNCTION: acpi_load_namespace 246 * FUNCTION: acpi_load_namespace
@@ -271,45 +254,40 @@ unlock_and_exit:
271 * 254 *
272 ******************************************************************************/ 255 ******************************************************************************/
273 256
274acpi_status 257acpi_status acpi_ns_load_namespace(void)
275acpi_ns_load_namespace (
276 void)
277{ 258{
278 acpi_status status; 259 acpi_status status;
279
280
281 ACPI_FUNCTION_TRACE ("acpi_load_name_space");
282 260
261 ACPI_FUNCTION_TRACE("acpi_load_name_space");
283 262
284 /* There must be at least a DSDT installed */ 263 /* There must be at least a DSDT installed */
285 264
286 if (acpi_gbl_DSDT == NULL) { 265 if (acpi_gbl_DSDT == NULL) {
287 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"));
288 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 267 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
289 } 268 }
290 269
291 /* 270 /*
292 * Load the namespace. The DSDT is required, 271 * Load the namespace. The DSDT is required,
293 * but the SSDT and PSDT tables are optional. 272 * but the SSDT and PSDT tables are optional.
294 */ 273 */
295 status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT); 274 status = acpi_ns_load_table_by_type(ACPI_TABLE_DSDT);
296 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
297 return_ACPI_STATUS (status); 276 return_ACPI_STATUS(status);
298 } 277 }
299 278
300 /* Ignore exceptions from these */ 279 /* Ignore exceptions from these */
301 280
302 (void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT); 281 (void)acpi_ns_load_table_by_type(ACPI_TABLE_SSDT);
303 (void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT); 282 (void)acpi_ns_load_table_by_type(ACPI_TABLE_PSDT);
304 283
305 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 284 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
306 "ACPI Namespace successfully loaded at root %p\n", 285 "ACPI Namespace successfully loaded at root %p\n",
307 acpi_gbl_root_node)); 286 acpi_gbl_root_node));
308 287
309 return_ACPI_STATUS (status); 288 return_ACPI_STATUS(status);
310} 289}
311 290
312
313#ifdef ACPI_FUTURE_IMPLEMENTATION 291#ifdef ACPI_FUTURE_IMPLEMENTATION
314/******************************************************************************* 292/*******************************************************************************
315 * 293 *
@@ -327,24 +305,20 @@ acpi_ns_load_namespace (
327 * 305 *
328 ******************************************************************************/ 306 ******************************************************************************/
329 307
330static acpi_status 308static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
331acpi_ns_delete_subtree (
332 acpi_handle start_handle)
333{ 309{
334 acpi_status status; 310 acpi_status status;
335 acpi_handle child_handle; 311 acpi_handle child_handle;
336 acpi_handle parent_handle; 312 acpi_handle parent_handle;
337 acpi_handle next_child_handle; 313 acpi_handle next_child_handle;
338 acpi_handle dummy; 314 acpi_handle dummy;
339 u32 level; 315 u32 level;
340
341
342 ACPI_FUNCTION_TRACE ("ns_delete_subtree");
343 316
317 ACPI_FUNCTION_TRACE("ns_delete_subtree");
344 318
345 parent_handle = start_handle; 319 parent_handle = start_handle;
346 child_handle = NULL; 320 child_handle = NULL;
347 level = 1; 321 level = 1;
348 322
349 /* 323 /*
350 * Traverse the tree of objects until we bubble back up 324 * Traverse the tree of objects until we bubble back up
@@ -353,18 +327,19 @@ acpi_ns_delete_subtree (
353 while (level > 0) { 327 while (level > 0) {
354 /* Attempt to get the next object in this scope */ 328 /* Attempt to get the next object in this scope */
355 329
356 status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle, 330 status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle,
357 child_handle, &next_child_handle); 331 child_handle, &next_child_handle);
358 332
359 child_handle = next_child_handle; 333 child_handle = next_child_handle;
360 334
361 /* Did we get a new object? */ 335 /* Did we get a new object? */
362 336
363 if (ACPI_SUCCESS (status)) { 337 if (ACPI_SUCCESS(status)) {
364 /* Check if this object has any children */ 338 /* Check if this object has any children */
365 339
366 if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, 340 if (ACPI_SUCCESS
367 NULL, &dummy))) { 341 (acpi_get_next_object
342 (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) {
368 /* 343 /*
369 * There is at least one child of this object, 344 * There is at least one child of this object,
370 * visit the object 345 * visit the object
@@ -373,8 +348,7 @@ acpi_ns_delete_subtree (
373 parent_handle = child_handle; 348 parent_handle = child_handle;
374 child_handle = NULL; 349 child_handle = NULL;
375 } 350 }
376 } 351 } else {
377 else {
378 /* 352 /*
379 * No more children in this object, go back up to 353 * No more children in this object, go back up to
380 * the object's parent 354 * the object's parent
@@ -383,24 +357,23 @@ acpi_ns_delete_subtree (
383 357
384 /* Delete all children now */ 358 /* Delete all children now */
385 359
386 acpi_ns_delete_children (child_handle); 360 acpi_ns_delete_children(child_handle);
387 361
388 child_handle = parent_handle; 362 child_handle = parent_handle;
389 status = acpi_get_parent (parent_handle, &parent_handle); 363 status = acpi_get_parent(parent_handle, &parent_handle);
390 if (ACPI_FAILURE (status)) { 364 if (ACPI_FAILURE(status)) {
391 return_ACPI_STATUS (status); 365 return_ACPI_STATUS(status);
392 } 366 }
393 } 367 }
394 } 368 }
395 369
396 /* Now delete the starting object, and we are done */ 370 /* Now delete the starting object, and we are done */
397 371
398 acpi_ns_delete_node (child_handle); 372 acpi_ns_delete_node(child_handle);
399 373
400 return_ACPI_STATUS (AE_OK); 374 return_ACPI_STATUS(AE_OK);
401} 375}
402 376
403
404/******************************************************************************* 377/*******************************************************************************
405 * 378 *
406 * FUNCTION: acpi_ns_unload_name_space 379 * FUNCTION: acpi_ns_unload_name_space
@@ -415,32 +388,27 @@ acpi_ns_delete_subtree (
415 * 388 *
416 ******************************************************************************/ 389 ******************************************************************************/
417 390
418acpi_status 391acpi_status acpi_ns_unload_namespace(acpi_handle handle)
419acpi_ns_unload_namespace (
420 acpi_handle handle)
421{ 392{
422 acpi_status status; 393 acpi_status status;
423
424
425 ACPI_FUNCTION_TRACE ("ns_unload_name_space");
426 394
395 ACPI_FUNCTION_TRACE("ns_unload_name_space");
427 396
428 /* Parameter validation */ 397 /* Parameter validation */
429 398
430 if (!acpi_gbl_root_node) { 399 if (!acpi_gbl_root_node) {
431 return_ACPI_STATUS (AE_NO_NAMESPACE); 400 return_ACPI_STATUS(AE_NO_NAMESPACE);
432 } 401 }
433 402
434 if (!handle) { 403 if (!handle) {
435 return_ACPI_STATUS (AE_BAD_PARAMETER); 404 return_ACPI_STATUS(AE_BAD_PARAMETER);
436 } 405 }
437 406
438 /* This function does the real work */ 407 /* This function does the real work */
439 408
440 status = acpi_ns_delete_subtree (handle); 409 status = acpi_ns_delete_subtree(handle);
441 410
442 return_ACPI_STATUS (status); 411 return_ACPI_STATUS(status);
443} 412}
444#endif 413#endif
445#endif 414#endif
446
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 24bed931d39d..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 u8 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->owner_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,10 +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 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); 139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
150 status = acpi_ns_one_complete_parse (1, table_desc); 140 status = acpi_ns_one_complete_parse(1, table_desc);
151 if (ACPI_FAILURE (status)) { 141 if (ACPI_FAILURE(status)) {
152 return_ACPI_STATUS (status); 142 return_ACPI_STATUS(status);
153 } 143 }
154 144
155 /* 145 /*
@@ -161,13 +151,11 @@ acpi_ns_parse_table (
161 * overhead of this is compensated for by the fact that the 151 * overhead of this is compensated for by the fact that the
162 * parse objects are all cached. 152 * parse objects are all cached.
163 */ 153 */
164 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); 154 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
165 status = acpi_ns_one_complete_parse (2, table_desc); 155 status = acpi_ns_one_complete_parse(2, table_desc);
166 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS (status); 157 return_ACPI_STATUS(status);
168 } 158 }
169 159
170 return_ACPI_STATUS (status); 160 return_ACPI_STATUS(status);
171} 161}
172
173
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 f3a807c342c0..9127760d36c5 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; 70int acpi_specific_hotkey_enabled;
75EXPORT_SYMBOL(acpi_specific_hotkey_enabled); 71EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
@@ -79,14 +75,12 @@ 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
@@ -94,7 +88,8 @@ acpi_os_initialize1(void)
94 */ 88 */
95#ifdef CONFIG_ACPI_PCI 89#ifdef CONFIG_ACPI_PCI
96 if (!raw_pci_ops) { 90 if (!raw_pci_ops) {
97 printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); 91 printk(KERN_ERR PREFIX
92 "Access to PCI configuration space unavailable\n");
98 return AE_NULL_ENTRY; 93 return AE_NULL_ENTRY;
99 } 94 }
100#endif 95#endif
@@ -104,8 +99,7 @@ acpi_os_initialize1(void)
104 return AE_OK; 99 return AE_OK;
105} 100}
106 101
107acpi_status 102acpi_status acpi_os_terminate(void)
108acpi_os_terminate(void)
109{ 103{
110 if (acpi_irq_handler) { 104 if (acpi_irq_handler) {
111 acpi_os_remove_interrupt_handler(acpi_irq_irq, 105 acpi_os_remove_interrupt_handler(acpi_irq_irq,
@@ -117,21 +111,20 @@ acpi_os_terminate(void)
117 return AE_OK; 111 return AE_OK;
118} 112}
119 113
120void 114void acpi_os_printf(const char *fmt, ...)
121acpi_os_printf(const char *fmt,...)
122{ 115{
123 va_list args; 116 va_list args;
124 va_start(args, fmt); 117 va_start(args, fmt);
125 acpi_os_vprintf(fmt, args); 118 acpi_os_vprintf(fmt, args);
126 va_end(args); 119 va_end(args);
127} 120}
121
128EXPORT_SYMBOL(acpi_os_printf); 122EXPORT_SYMBOL(acpi_os_printf);
129 123
130void 124void acpi_os_vprintf(const char *fmt, va_list args)
131acpi_os_vprintf(const char *fmt, va_list args)
132{ 125{
133 static char buffer[512]; 126 static char buffer[512];
134 127
135 vsprintf(buffer, fmt, args); 128 vsprintf(buffer, fmt, args);
136 129
137#ifdef ENABLE_DEBUGGER 130#ifdef ENABLE_DEBUGGER
@@ -146,8 +139,7 @@ acpi_os_vprintf(const char *fmt, va_list args)
146} 139}
147 140
148extern int acpi_in_resume; 141extern int acpi_in_resume;
149void * 142void *acpi_os_allocate(acpi_size size)
150acpi_os_allocate(acpi_size size)
151{ 143{
152 if (acpi_in_resume) 144 if (acpi_in_resume)
153 return kmalloc(size, GFP_ATOMIC); 145 return kmalloc(size, GFP_ATOMIC);
@@ -155,31 +147,32 @@ acpi_os_allocate(acpi_size size)
155 return kmalloc(size, GFP_KERNEL); 147 return kmalloc(size, GFP_KERNEL);
156} 148}
157 149
158void 150void acpi_os_free(void *ptr)
159acpi_os_free(void *ptr)
160{ 151{
161 kfree(ptr); 152 kfree(ptr);
162} 153}
154
163EXPORT_SYMBOL(acpi_os_free); 155EXPORT_SYMBOL(acpi_os_free);
164 156
165acpi_status 157acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
166acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
167{ 158{
168 if (efi_enabled) { 159 if (efi_enabled) {
169 addr->pointer_type = ACPI_PHYSICAL_POINTER; 160 addr->pointer_type = ACPI_PHYSICAL_POINTER;
170 if (efi.acpi20) 161 if (efi.acpi20)
171 addr->pointer.physical = 162 addr->pointer.physical =
172 (acpi_physical_address) virt_to_phys(efi.acpi20); 163 (acpi_physical_address) virt_to_phys(efi.acpi20);
173 else if (efi.acpi) 164 else if (efi.acpi)
174 addr->pointer.physical = 165 addr->pointer.physical =
175 (acpi_physical_address) virt_to_phys(efi.acpi); 166 (acpi_physical_address) virt_to_phys(efi.acpi);
176 else { 167 else {
177 printk(KERN_ERR PREFIX "System description tables not found\n"); 168 printk(KERN_ERR PREFIX
169 "System description tables not found\n");
178 return AE_NOT_FOUND; 170 return AE_NOT_FOUND;
179 } 171 }
180 } else { 172 } else {
181 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) { 173 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
182 printk(KERN_ERR PREFIX "System description tables not found\n"); 174 printk(KERN_ERR PREFIX
175 "System description tables not found\n");
183 return AE_NOT_FOUND; 176 return AE_NOT_FOUND;
184 } 177 }
185 } 178 }
@@ -188,11 +181,12 @@ acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
188} 181}
189 182
190acpi_status 183acpi_status
191acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **virt) 184acpi_os_map_memory(acpi_physical_address phys, acpi_size size,
185 void __iomem ** virt)
192{ 186{
193 if (efi_enabled) { 187 if (efi_enabled) {
194 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { 188 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) {
195 *virt = (void __iomem *) phys_to_virt(phys); 189 *virt = (void __iomem *)phys_to_virt(phys);
196 } else { 190 } else {
197 *virt = ioremap(phys, size); 191 *virt = ioremap(phys, size);
198 } 192 }
@@ -202,9 +196,9 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi
202 return AE_BAD_PARAMETER; 196 return AE_BAD_PARAMETER;
203 } 197 }
204 /* 198 /*
205 * ioremap checks to ensure this is in reserved space 199 * ioremap checks to ensure this is in reserved space
206 */ 200 */
207 *virt = ioremap((unsigned long) phys, size); 201 *virt = ioremap((unsigned long)phys, size);
208 } 202 }
209 203
210 if (!*virt) 204 if (!*virt)
@@ -213,17 +207,16 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi
213 return AE_OK; 207 return AE_OK;
214} 208}
215 209
216void 210void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
217acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
218{ 211{
219 iounmap(virt); 212 iounmap(virt);
220} 213}
221 214
222#ifdef ACPI_FUTURE_USAGE 215#ifdef ACPI_FUTURE_USAGE
223acpi_status 216acpi_status
224acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) 217acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
225{ 218{
226 if(!phys || !virt) 219 if (!phys || !virt)
227 return AE_BAD_PARAMETER; 220 return AE_BAD_PARAMETER;
228 221
229 *phys = virt_to_phys(virt); 222 *phys = virt_to_phys(virt);
@@ -237,16 +230,16 @@ acpi_os_get_physical_address(void *virt, acpi_physical_address *phys)
237static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; 230static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
238 231
239acpi_status 232acpi_status
240acpi_os_predefined_override (const struct acpi_predefined_names *init_val, 233acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
241 acpi_string *new_val) 234 acpi_string * new_val)
242{ 235{
243 if (!init_val || !new_val) 236 if (!init_val || !new_val)
244 return AE_BAD_PARAMETER; 237 return AE_BAD_PARAMETER;
245 238
246 *new_val = NULL; 239 *new_val = NULL;
247 if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { 240 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
248 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", 241 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
249 acpi_os_name); 242 acpi_os_name);
250 *new_val = acpi_os_name; 243 *new_val = acpi_os_name;
251 } 244 }
252 245
@@ -254,15 +247,15 @@ acpi_os_predefined_override (const struct acpi_predefined_names *init_val,
254} 247}
255 248
256acpi_status 249acpi_status
257acpi_os_table_override (struct acpi_table_header *existing_table, 250acpi_os_table_override(struct acpi_table_header * existing_table,
258 struct acpi_table_header **new_table) 251 struct acpi_table_header ** new_table)
259{ 252{
260 if (!existing_table || !new_table) 253 if (!existing_table || !new_table)
261 return AE_BAD_PARAMETER; 254 return AE_BAD_PARAMETER;
262 255
263#ifdef CONFIG_ACPI_CUSTOM_DSDT 256#ifdef CONFIG_ACPI_CUSTOM_DSDT
264 if (strncmp(existing_table->signature, "DSDT", 4) == 0) 257 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
265 *new_table = (struct acpi_table_header*)AmlCode; 258 *new_table = (struct acpi_table_header *)AmlCode;
266 else 259 else
267 *new_table = NULL; 260 *new_table = NULL;
268#else 261#else
@@ -271,14 +264,14 @@ acpi_os_table_override (struct acpi_table_header *existing_table,
271 return AE_OK; 264 return AE_OK;
272} 265}
273 266
274static irqreturn_t 267static 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{ 268{
277 return (*acpi_irq_handler)(acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; 269 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
278} 270}
279 271
280acpi_status 272acpi_status
281acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *context) 273acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
274 void *context)
282{ 275{
283 unsigned int irq; 276 unsigned int irq;
284 277
@@ -305,8 +298,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *conte
305 return AE_OK; 298 return AE_OK;
306} 299}
307 300
308acpi_status 301acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
309acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
310{ 302{
311 if (irq) { 303 if (irq) {
312 free_irq(irq, acpi_irq); 304 free_irq(irq, acpi_irq);
@@ -321,16 +313,15 @@ acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
321 * Running in interpreter thread context, safe to sleep 313 * Running in interpreter thread context, safe to sleep
322 */ 314 */
323 315
324void 316void acpi_os_sleep(acpi_integer ms)
325acpi_os_sleep(acpi_integer ms)
326{ 317{
327 current->state = TASK_INTERRUPTIBLE; 318 current->state = TASK_INTERRUPTIBLE;
328 schedule_timeout(((signed long) ms * HZ) / 1000); 319 schedule_timeout(((signed long)ms * HZ) / 1000);
329} 320}
321
330EXPORT_SYMBOL(acpi_os_sleep); 322EXPORT_SYMBOL(acpi_os_sleep);
331 323
332void 324void acpi_os_stall(u32 us)
333acpi_os_stall(u32 us)
334{ 325{
335 while (us) { 326 while (us) {
336 u32 delay = 1000; 327 u32 delay = 1000;
@@ -342,6 +333,7 @@ acpi_os_stall(u32 us)
342 us -= delay; 333 us -= delay;
343 } 334 }
344} 335}
336
345EXPORT_SYMBOL(acpi_os_stall); 337EXPORT_SYMBOL(acpi_os_stall);
346 338
347/* 339/*
@@ -349,8 +341,7 @@ EXPORT_SYMBOL(acpi_os_stall);
349 * Returns 64-bit free-running, monotonically increasing timer 341 * Returns 64-bit free-running, monotonically increasing timer
350 * with 100ns granularity 342 * with 100ns granularity
351 */ 343 */
352u64 344u64 acpi_os_get_timer(void)
353acpi_os_get_timer (void)
354{ 345{
355 static u64 t; 346 static u64 t;
356 347
@@ -367,27 +358,22 @@ acpi_os_get_timer (void)
367 return ++t; 358 return ++t;
368} 359}
369 360
370acpi_status 361acpi_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{ 362{
376 u32 dummy; 363 u32 dummy;
377 364
378 if (!value) 365 if (!value)
379 value = &dummy; 366 value = &dummy;
380 367
381 switch (width) 368 switch (width) {
382 {
383 case 8: 369 case 8:
384 *(u8*) value = inb(port); 370 *(u8 *) value = inb(port);
385 break; 371 break;
386 case 16: 372 case 16:
387 *(u16*) value = inw(port); 373 *(u16 *) value = inw(port);
388 break; 374 break;
389 case 32: 375 case 32:
390 *(u32*) value = inl(port); 376 *(u32 *) value = inl(port);
391 break; 377 break;
392 default: 378 default:
393 BUG(); 379 BUG();
@@ -395,16 +381,12 @@ acpi_os_read_port(
395 381
396 return AE_OK; 382 return AE_OK;
397} 383}
384
398EXPORT_SYMBOL(acpi_os_read_port); 385EXPORT_SYMBOL(acpi_os_read_port);
399 386
400acpi_status 387acpi_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{ 388{
406 switch (width) 389 switch (width) {
407 {
408 case 8: 390 case 8:
409 outb(value, port); 391 outb(value, port);
410 break; 392 break;
@@ -420,40 +402,38 @@ acpi_os_write_port(
420 402
421 return AE_OK; 403 return AE_OK;
422} 404}
405
423EXPORT_SYMBOL(acpi_os_write_port); 406EXPORT_SYMBOL(acpi_os_write_port);
424 407
425acpi_status 408acpi_status
426acpi_os_read_memory( 409acpi_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{ 410{
431 u32 dummy; 411 u32 dummy;
432 void __iomem *virt_addr; 412 void __iomem *virt_addr;
433 int iomem = 0; 413 int iomem = 0;
434 414
435 if (efi_enabled) { 415 if (efi_enabled) {
436 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { 416 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
437 /* HACK ALERT! We can use readb/w/l on real memory too.. */ 417 /* HACK ALERT! We can use readb/w/l on real memory too.. */
438 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 418 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
439 } else { 419 } else {
440 iomem = 1; 420 iomem = 1;
441 virt_addr = ioremap(phys_addr, width); 421 virt_addr = ioremap(phys_addr, width);
442 } 422 }
443 } else 423 } else
444 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 424 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
445 if (!value) 425 if (!value)
446 value = &dummy; 426 value = &dummy;
447 427
448 switch (width) { 428 switch (width) {
449 case 8: 429 case 8:
450 *(u8*) value = readb(virt_addr); 430 *(u8 *) value = readb(virt_addr);
451 break; 431 break;
452 case 16: 432 case 16:
453 *(u16*) value = readw(virt_addr); 433 *(u16 *) value = readw(virt_addr);
454 break; 434 break;
455 case 32: 435 case 32:
456 *(u32*) value = readl(virt_addr); 436 *(u32 *) value = readl(virt_addr);
457 break; 437 break;
458 default: 438 default:
459 BUG(); 439 BUG();
@@ -468,24 +448,21 @@ acpi_os_read_memory(
468} 448}
469 449
470acpi_status 450acpi_status
471acpi_os_write_memory( 451acpi_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{ 452{
476 void __iomem *virt_addr; 453 void __iomem *virt_addr;
477 int iomem = 0; 454 int iomem = 0;
478 455
479 if (efi_enabled) { 456 if (efi_enabled) {
480 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { 457 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
481 /* HACK ALERT! We can use writeb/w/l on real memory too */ 458 /* HACK ALERT! We can use writeb/w/l on real memory too */
482 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 459 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
483 } else { 460 } else {
484 iomem = 1; 461 iomem = 1;
485 virt_addr = ioremap(phys_addr, width); 462 virt_addr = ioremap(phys_addr, width);
486 } 463 }
487 } else 464 } else
488 virt_addr = (void __iomem *) phys_to_virt(phys_addr); 465 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
489 466
490 switch (width) { 467 switch (width) {
491 case 8: 468 case 8:
@@ -510,7 +487,8 @@ acpi_os_write_memory(
510#ifdef CONFIG_ACPI_PCI 487#ifdef CONFIG_ACPI_PCI
511 488
512acpi_status 489acpi_status
513acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value, u32 width) 490acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
491 void *value, u32 width)
514{ 492{
515 int result, size; 493 int result, size;
516 494
@@ -534,15 +512,17 @@ acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value
534 BUG_ON(!raw_pci_ops); 512 BUG_ON(!raw_pci_ops);
535 513
536 result = raw_pci_ops->read(pci_id->segment, pci_id->bus, 514 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
537 PCI_DEVFN(pci_id->device, pci_id->function), 515 PCI_DEVFN(pci_id->device, pci_id->function),
538 reg, size, value); 516 reg, size, value);
539 517
540 return (result ? AE_ERROR : AE_OK); 518 return (result ? AE_ERROR : AE_OK);
541} 519}
520
542EXPORT_SYMBOL(acpi_os_read_pci_configuration); 521EXPORT_SYMBOL(acpi_os_read_pci_configuration);
543 522
544acpi_status 523acpi_status
545acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integer value, u32 width) 524acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
525 acpi_integer value, u32 width)
546{ 526{
547 int result, size; 527 int result, size;
548 528
@@ -563,56 +543,62 @@ acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integ
563 BUG_ON(!raw_pci_ops); 543 BUG_ON(!raw_pci_ops);
564 544
565 result = raw_pci_ops->write(pci_id->segment, pci_id->bus, 545 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
566 PCI_DEVFN(pci_id->device, pci_id->function), 546 PCI_DEVFN(pci_id->device, pci_id->function),
567 reg, size, value); 547 reg, size, value);
568 548
569 return (result ? AE_ERROR : AE_OK); 549 return (result ? AE_ERROR : AE_OK);
570} 550}
571 551
572/* TODO: Change code to take advantage of driver model more */ 552/* TODO: Change code to take advantage of driver model more */
573static void 553static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
574acpi_os_derive_pci_id_2 ( 554 acpi_handle chandle, /* current node */
575 acpi_handle rhandle, /* upper bound */ 555 struct acpi_pci_id **id,
576 acpi_handle chandle, /* current node */ 556 int *is_bridge, u8 * bus_number)
577 struct acpi_pci_id **id,
578 int *is_bridge,
579 u8 *bus_number)
580{ 557{
581 acpi_handle handle; 558 acpi_handle handle;
582 struct acpi_pci_id *pci_id = *id; 559 struct acpi_pci_id *pci_id = *id;
583 acpi_status status; 560 acpi_status status;
584 unsigned long temp; 561 unsigned long temp;
585 acpi_object_type type; 562 acpi_object_type type;
586 u8 tu8; 563 u8 tu8;
587 564
588 acpi_get_parent(chandle, &handle); 565 acpi_get_parent(chandle, &handle);
589 if (handle != rhandle) { 566 if (handle != rhandle) {
590 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, bus_number); 567 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
568 bus_number);
591 569
592 status = acpi_get_type(handle, &type); 570 status = acpi_get_type(handle, &type);
593 if ( (ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE) ) 571 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
594 return; 572 return;
595 573
596 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &temp); 574 status =
575 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
576 &temp);
597 if (ACPI_SUCCESS(status)) { 577 if (ACPI_SUCCESS(status)) {
598 pci_id->device = ACPI_HIWORD (ACPI_LODWORD (temp)); 578 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
599 pci_id->function = ACPI_LOWORD (ACPI_LODWORD (temp)); 579 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
600 580
601 if (*is_bridge) 581 if (*is_bridge)
602 pci_id->bus = *bus_number; 582 pci_id->bus = *bus_number;
603 583
604 /* any nicer way to get bus number of bridge ? */ 584 /* any nicer way to get bus number of bridge ? */
605 status = acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, 8); 585 status =
606 if (ACPI_SUCCESS(status) && 586 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
607 ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { 587 8);
608 status = acpi_os_read_pci_configuration(pci_id, 0x18, &tu8, 8); 588 if (ACPI_SUCCESS(status)
589 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
590 status =
591 acpi_os_read_pci_configuration(pci_id, 0x18,
592 &tu8, 8);
609 if (!ACPI_SUCCESS(status)) { 593 if (!ACPI_SUCCESS(status)) {
610 /* Certainly broken... FIX ME */ 594 /* Certainly broken... FIX ME */
611 return; 595 return;
612 } 596 }
613 *is_bridge = 1; 597 *is_bridge = 1;
614 pci_id->bus = tu8; 598 pci_id->bus = tu8;
615 status = acpi_os_read_pci_configuration(pci_id, 0x19, &tu8, 8); 599 status =
600 acpi_os_read_pci_configuration(pci_id, 0x19,
601 &tu8, 8);
616 if (ACPI_SUCCESS(status)) { 602 if (ACPI_SUCCESS(status)) {
617 *bus_number = tu8; 603 *bus_number = tu8;
618 } 604 }
@@ -622,11 +608,9 @@ acpi_os_derive_pci_id_2 (
622 } 608 }
623} 609}
624 610
625void 611void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
626acpi_os_derive_pci_id ( 612 acpi_handle chandle, /* current node */
627 acpi_handle rhandle, /* upper bound */ 613 struct acpi_pci_id **id)
628 acpi_handle chandle, /* current node */
629 struct acpi_pci_id **id)
630{ 614{
631 int is_bridge = 1; 615 int is_bridge = 1;
632 u8 bus_number = (*id)->bus; 616 u8 bus_number = (*id)->bus;
@@ -634,49 +618,39 @@ acpi_os_derive_pci_id (
634 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); 618 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
635} 619}
636 620
637#else /*!CONFIG_ACPI_PCI*/ 621#else /*!CONFIG_ACPI_PCI */
638 622
639acpi_status 623acpi_status
640acpi_os_write_pci_configuration ( 624acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id,
641 struct acpi_pci_id *pci_id, 625 u32 reg, acpi_integer value, u32 width)
642 u32 reg,
643 acpi_integer value,
644 u32 width)
645{ 626{
646 return AE_SUPPORT; 627 return AE_SUPPORT;
647} 628}
648 629
649acpi_status 630acpi_status
650acpi_os_read_pci_configuration ( 631acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id,
651 struct acpi_pci_id *pci_id, 632 u32 reg, void *value, u32 width)
652 u32 reg,
653 void *value,
654 u32 width)
655{ 633{
656 return AE_SUPPORT; 634 return AE_SUPPORT;
657} 635}
658 636
659void 637void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
660acpi_os_derive_pci_id ( 638 acpi_handle chandle, /* current node */
661 acpi_handle rhandle, /* upper bound */ 639 struct acpi_pci_id **id)
662 acpi_handle chandle, /* current node */
663 struct acpi_pci_id **id)
664{ 640{
665} 641}
666 642
667#endif /*CONFIG_ACPI_PCI*/ 643#endif /*CONFIG_ACPI_PCI */
668 644
669static void 645static void acpi_os_execute_deferred(void *context)
670acpi_os_execute_deferred (
671 void *context)
672{ 646{
673 struct acpi_os_dpc *dpc = NULL; 647 struct acpi_os_dpc *dpc = NULL;
674 648
675 ACPI_FUNCTION_TRACE ("os_execute_deferred"); 649 ACPI_FUNCTION_TRACE("os_execute_deferred");
676 650
677 dpc = (struct acpi_os_dpc *) context; 651 dpc = (struct acpi_os_dpc *)context;
678 if (!dpc) { 652 if (!dpc) {
679 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 653 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
680 return_VOID; 654 return_VOID;
681 } 655 }
682 656
@@ -688,21 +662,21 @@ acpi_os_execute_deferred (
688} 662}
689 663
690acpi_status 664acpi_status
691acpi_os_queue_for_execution( 665acpi_os_queue_for_execution(u32 priority,
692 u32 priority, 666 acpi_osd_exec_callback function, void *context)
693 acpi_osd_exec_callback function,
694 void *context)
695{ 667{
696 acpi_status status = AE_OK; 668 acpi_status status = AE_OK;
697 struct acpi_os_dpc *dpc; 669 struct acpi_os_dpc *dpc;
698 struct work_struct *task; 670 struct work_struct *task;
699 671
700 ACPI_FUNCTION_TRACE ("os_queue_for_execution"); 672 ACPI_FUNCTION_TRACE("os_queue_for_execution");
701 673
702 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); 674 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
675 "Scheduling function [%p(%p)] for deferred execution.\n",
676 function, context));
703 677
704 if (!function) 678 if (!function)
705 return_ACPI_STATUS (AE_BAD_PARAMETER); 679 return_ACPI_STATUS(AE_BAD_PARAMETER);
706 680
707 /* 681 /*
708 * Allocate/initialize DPC structure. Note that this memory will be 682 * Allocate/initialize DPC structure. Note that this memory will be
@@ -715,67 +689,65 @@ acpi_os_queue_for_execution(
715 * from the same memory. 689 * from the same memory.
716 */ 690 */
717 691
718 dpc = kmalloc(sizeof(struct acpi_os_dpc)+sizeof(struct work_struct), GFP_ATOMIC); 692 dpc =
693 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
694 GFP_ATOMIC);
719 if (!dpc) 695 if (!dpc)
720 return_ACPI_STATUS (AE_NO_MEMORY); 696 return_ACPI_STATUS(AE_NO_MEMORY);
721 697
722 dpc->function = function; 698 dpc->function = function;
723 dpc->context = context; 699 dpc->context = context;
724 700
725 task = (void *)(dpc+1); 701 task = (void *)(dpc + 1);
726 INIT_WORK(task, acpi_os_execute_deferred, (void*)dpc); 702 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
727 703
728 if (!queue_work(kacpid_wq, task)) { 704 if (!queue_work(kacpid_wq, task)) {
729 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to queue_work() failed.\n")); 705 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
706 "Call to queue_work() failed.\n"));
730 kfree(dpc); 707 kfree(dpc);
731 status = AE_ERROR; 708 status = AE_ERROR;
732 } 709 }
733 710
734 return_ACPI_STATUS (status); 711 return_ACPI_STATUS(status);
735} 712}
713
736EXPORT_SYMBOL(acpi_os_queue_for_execution); 714EXPORT_SYMBOL(acpi_os_queue_for_execution);
737 715
738void 716void acpi_os_wait_events_complete(void *context)
739acpi_os_wait_events_complete(
740 void *context)
741{ 717{
742 flush_workqueue(kacpid_wq); 718 flush_workqueue(kacpid_wq);
743} 719}
720
744EXPORT_SYMBOL(acpi_os_wait_events_complete); 721EXPORT_SYMBOL(acpi_os_wait_events_complete);
745 722
746/* 723/*
747 * Allocate the memory for a spinlock and initialize it. 724 * Allocate the memory for a spinlock and initialize it.
748 */ 725 */
749acpi_status 726acpi_status acpi_os_create_lock(acpi_handle * out_handle)
750acpi_os_create_lock (
751 acpi_handle *out_handle)
752{ 727{
753 spinlock_t *lock_ptr; 728 spinlock_t *lock_ptr;
754 729
755 ACPI_FUNCTION_TRACE ("os_create_lock"); 730 ACPI_FUNCTION_TRACE("os_create_lock");
756 731
757 lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); 732 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
758 733
759 spin_lock_init(lock_ptr); 734 spin_lock_init(lock_ptr);
760 735
761 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); 736 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
762 737
763 *out_handle = lock_ptr; 738 *out_handle = lock_ptr;
764 739
765 return_ACPI_STATUS (AE_OK); 740 return_ACPI_STATUS(AE_OK);
766} 741}
767 742
768
769/* 743/*
770 * Deallocate the memory for a spinlock. 744 * Deallocate the memory for a spinlock.
771 */ 745 */
772void 746void acpi_os_delete_lock(acpi_handle handle)
773acpi_os_delete_lock (
774 acpi_handle handle)
775{ 747{
776 ACPI_FUNCTION_TRACE ("os_create_lock"); 748 ACPI_FUNCTION_TRACE("os_create_lock");
777 749
778 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); 750 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
779 751
780 acpi_os_free(handle); 752 acpi_os_free(handle);
781 753
@@ -783,30 +755,28 @@ acpi_os_delete_lock (
783} 755}
784 756
785acpi_status 757acpi_status
786acpi_os_create_semaphore( 758acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
787 u32 max_units,
788 u32 initial_units,
789 acpi_handle *handle)
790{ 759{
791 struct semaphore *sem = NULL; 760 struct semaphore *sem = NULL;
792 761
793 ACPI_FUNCTION_TRACE ("os_create_semaphore"); 762 ACPI_FUNCTION_TRACE("os_create_semaphore");
794 763
795 sem = acpi_os_allocate(sizeof(struct semaphore)); 764 sem = acpi_os_allocate(sizeof(struct semaphore));
796 if (!sem) 765 if (!sem)
797 return_ACPI_STATUS (AE_NO_MEMORY); 766 return_ACPI_STATUS(AE_NO_MEMORY);
798 memset(sem, 0, sizeof(struct semaphore)); 767 memset(sem, 0, sizeof(struct semaphore));
799 768
800 sema_init(sem, initial_units); 769 sema_init(sem, initial_units);
801 770
802 *handle = (acpi_handle*)sem; 771 *handle = (acpi_handle *) sem;
803 772
804 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); 773 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
774 *handle, initial_units));
805 775
806 return_ACPI_STATUS (AE_OK); 776 return_ACPI_STATUS(AE_OK);
807} 777}
808EXPORT_SYMBOL(acpi_os_create_semaphore);
809 778
779EXPORT_SYMBOL(acpi_os_create_semaphore);
810 780
811/* 781/*
812 * TODO: A better way to delete semaphores? Linux doesn't have a 782 * TODO: A better way to delete semaphores? Linux doesn't have a
@@ -815,25 +785,24 @@ EXPORT_SYMBOL(acpi_os_create_semaphore);
815 * we at least check for blocked threads and signal/cancel them? 785 * we at least check for blocked threads and signal/cancel them?
816 */ 786 */
817 787
818acpi_status 788acpi_status acpi_os_delete_semaphore(acpi_handle handle)
819acpi_os_delete_semaphore(
820 acpi_handle handle)
821{ 789{
822 struct semaphore *sem = (struct semaphore*) handle; 790 struct semaphore *sem = (struct semaphore *)handle;
823 791
824 ACPI_FUNCTION_TRACE ("os_delete_semaphore"); 792 ACPI_FUNCTION_TRACE("os_delete_semaphore");
825 793
826 if (!sem) 794 if (!sem)
827 return_ACPI_STATUS (AE_BAD_PARAMETER); 795 return_ACPI_STATUS(AE_BAD_PARAMETER);
828 796
829 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); 797 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
830 798
831 acpi_os_free(sem); sem = NULL; 799 acpi_os_free(sem);
800 sem = NULL;
832 801
833 return_ACPI_STATUS (AE_OK); 802 return_ACPI_STATUS(AE_OK);
834} 803}
835EXPORT_SYMBOL(acpi_os_delete_semaphore);
836 804
805EXPORT_SYMBOL(acpi_os_delete_semaphore);
837 806
838/* 807/*
839 * TODO: The kernel doesn't have a 'down_timeout' function -- had to 808 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
@@ -844,31 +813,27 @@ EXPORT_SYMBOL(acpi_os_delete_semaphore);
844 * 813 *
845 * TODO: Support for units > 1? 814 * TODO: Support for units > 1?
846 */ 815 */
847acpi_status 816acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
848acpi_os_wait_semaphore(
849 acpi_handle handle,
850 u32 units,
851 u16 timeout)
852{ 817{
853 acpi_status status = AE_OK; 818 acpi_status status = AE_OK;
854 struct semaphore *sem = (struct semaphore*)handle; 819 struct semaphore *sem = (struct semaphore *)handle;
855 int ret = 0; 820 int ret = 0;
856 821
857 ACPI_FUNCTION_TRACE ("os_wait_semaphore"); 822 ACPI_FUNCTION_TRACE("os_wait_semaphore");
858 823
859 if (!sem || (units < 1)) 824 if (!sem || (units < 1))
860 return_ACPI_STATUS (AE_BAD_PARAMETER); 825 return_ACPI_STATUS(AE_BAD_PARAMETER);
861 826
862 if (units > 1) 827 if (units > 1)
863 return_ACPI_STATUS (AE_SUPPORT); 828 return_ACPI_STATUS(AE_SUPPORT);
864 829
865 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); 830 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
831 handle, units, timeout));
866 832
867 if (in_atomic()) 833 if (in_atomic())
868 timeout = 0; 834 timeout = 0;
869 835
870 switch (timeout) 836 switch (timeout) {
871 {
872 /* 837 /*
873 * No Wait: 838 * No Wait:
874 * -------- 839 * --------
@@ -876,8 +841,8 @@ acpi_os_wait_semaphore(
876 * acquire the semaphore if available otherwise return AE_TIME 841 * acquire the semaphore if available otherwise return AE_TIME
877 * (a.k.a. 'would block'). 842 * (a.k.a. 'would block').
878 */ 843 */
879 case 0: 844 case 0:
880 if(down_trylock(sem)) 845 if (down_trylock(sem))
881 status = AE_TIME; 846 status = AE_TIME;
882 break; 847 break;
883 848
@@ -885,7 +850,7 @@ acpi_os_wait_semaphore(
885 * Wait Indefinitely: 850 * Wait Indefinitely:
886 * ------------------ 851 * ------------------
887 */ 852 */
888 case ACPI_WAIT_FOREVER: 853 case ACPI_WAIT_FOREVER:
889 down(sem); 854 down(sem);
890 break; 855 break;
891 856
@@ -893,11 +858,11 @@ acpi_os_wait_semaphore(
893 * Wait w/ Timeout: 858 * Wait w/ Timeout:
894 * ---------------- 859 * ----------------
895 */ 860 */
896 default: 861 default:
897 // TODO: A better timeout algorithm? 862 // TODO: A better timeout algorithm?
898 { 863 {
899 int i = 0; 864 int i = 0;
900 static const int quantum_ms = 1000/HZ; 865 static const int quantum_ms = 1000 / HZ;
901 866
902 ret = down_trylock(sem); 867 ret = down_trylock(sem);
903 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 868 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
@@ -905,7 +870,7 @@ acpi_os_wait_semaphore(
905 schedule_timeout(1); 870 schedule_timeout(1);
906 ret = down_trylock(sem); 871 ret = down_trylock(sem);
907 } 872 }
908 873
909 if (ret != 0) 874 if (ret != 0)
910 status = AE_TIME; 875 status = AE_TIME;
911 } 876 }
@@ -913,47 +878,48 @@ acpi_os_wait_semaphore(
913 } 878 }
914 879
915 if (ACPI_FAILURE(status)) { 880 if (ACPI_FAILURE(status)) {
916 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failed to acquire semaphore[%p|%d|%d], %s\n", 881 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
917 handle, units, timeout, acpi_format_exception(status))); 882 "Failed to acquire semaphore[%p|%d|%d], %s\n",
918 } 883 handle, units, timeout,
919 else { 884 acpi_format_exception(status)));
920 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout)); 885 } else {
886 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
887 "Acquired semaphore[%p|%d|%d]\n", handle,
888 units, timeout));
921 } 889 }
922 890
923 return_ACPI_STATUS (status); 891 return_ACPI_STATUS(status);
924} 892}
925EXPORT_SYMBOL(acpi_os_wait_semaphore);
926 893
894EXPORT_SYMBOL(acpi_os_wait_semaphore);
927 895
928/* 896/*
929 * TODO: Support for units > 1? 897 * TODO: Support for units > 1?
930 */ 898 */
931acpi_status 899acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
932acpi_os_signal_semaphore(
933 acpi_handle handle,
934 u32 units)
935{ 900{
936 struct semaphore *sem = (struct semaphore *) handle; 901 struct semaphore *sem = (struct semaphore *)handle;
937 902
938 ACPI_FUNCTION_TRACE ("os_signal_semaphore"); 903 ACPI_FUNCTION_TRACE("os_signal_semaphore");
939 904
940 if (!sem || (units < 1)) 905 if (!sem || (units < 1))
941 return_ACPI_STATUS (AE_BAD_PARAMETER); 906 return_ACPI_STATUS(AE_BAD_PARAMETER);
942 907
943 if (units > 1) 908 if (units > 1)
944 return_ACPI_STATUS (AE_SUPPORT); 909 return_ACPI_STATUS(AE_SUPPORT);
945 910
946 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); 911 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
912 units));
947 913
948 up(sem); 914 up(sem);
949 915
950 return_ACPI_STATUS (AE_OK); 916 return_ACPI_STATUS(AE_OK);
951} 917}
918
952EXPORT_SYMBOL(acpi_os_signal_semaphore); 919EXPORT_SYMBOL(acpi_os_signal_semaphore);
953 920
954#ifdef ACPI_FUTURE_USAGE 921#ifdef ACPI_FUTURE_USAGE
955u32 922u32 acpi_os_get_line(char *buffer)
956acpi_os_get_line(char *buffer)
957{ 923{
958 924
959#ifdef ENABLE_DEBUGGER 925#ifdef ENABLE_DEBUGGER
@@ -970,22 +936,21 @@ acpi_os_get_line(char *buffer)
970 936
971 return 0; 937 return 0;
972} 938}
973#endif /* ACPI_FUTURE_USAGE */ 939#endif /* ACPI_FUTURE_USAGE */
974 940
975/* Assumes no unreadable holes inbetween */ 941/* Assumes no unreadable holes inbetween */
976u8 942u8 acpi_os_readable(void *ptr, acpi_size len)
977acpi_os_readable(void *ptr, acpi_size len)
978{ 943{
979#if defined(__i386__) || defined(__x86_64__) 944#if defined(__i386__) || defined(__x86_64__)
980 char tmp; 945 char tmp;
981 return !__get_user(tmp, (char __user *)ptr) && !__get_user(tmp, (char __user *)ptr + len - 1); 946 return !__get_user(tmp, (char __user *)ptr)
947 && !__get_user(tmp, (char __user *)ptr + len - 1);
982#endif 948#endif
983 return 1; 949 return 1;
984} 950}
985 951
986#ifdef ACPI_FUTURE_USAGE 952#ifdef ACPI_FUTURE_USAGE
987u8 953u8 acpi_os_writable(void *ptr, acpi_size len)
988acpi_os_writable(void *ptr, acpi_size len)
989{ 954{
990 /* could do dummy write (racy) or a kernel page table lookup. 955 /* could do dummy write (racy) or a kernel page table lookup.
991 The later may be difficult at early boot when kmap doesn't work yet. */ 956 The later may be difficult at early boot when kmap doesn't work yet. */
@@ -993,8 +958,7 @@ acpi_os_writable(void *ptr, acpi_size len)
993} 958}
994#endif 959#endif
995 960
996u32 961u32 acpi_os_get_thread_id(void)
997acpi_os_get_thread_id (void)
998{ 962{
999 if (!in_atomic()) 963 if (!in_atomic())
1000 return current->pid; 964 return current->pid;
@@ -1002,13 +966,9 @@ acpi_os_get_thread_id (void)
1002 return 0; 966 return 0;
1003} 967}
1004 968
1005acpi_status 969acpi_status acpi_os_signal(u32 function, void *info)
1006acpi_os_signal (
1007 u32 function,
1008 void *info)
1009{ 970{
1010 switch (function) 971 switch (function) {
1011 {
1012 case ACPI_SIGNAL_FATAL: 972 case ACPI_SIGNAL_FATAL:
1013 printk(KERN_ERR PREFIX "Fatal opcode executed\n"); 973 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
1014 break; 974 break;
@@ -1028,13 +988,13 @@ acpi_os_signal (
1028 988
1029 return AE_OK; 989 return AE_OK;
1030} 990}
991
1031EXPORT_SYMBOL(acpi_os_signal); 992EXPORT_SYMBOL(acpi_os_signal);
1032 993
1033static int __init 994static int __init acpi_os_name_setup(char *str)
1034acpi_os_name_setup(char *str)
1035{ 995{
1036 char *p = acpi_os_name; 996 char *p = acpi_os_name;
1037 int count = ACPI_MAX_OVERRIDE_LEN-1; 997 int count = ACPI_MAX_OVERRIDE_LEN - 1;
1038 998
1039 if (!str || !*str) 999 if (!str || !*str)
1040 return 0; 1000 return 0;
@@ -1050,7 +1010,7 @@ acpi_os_name_setup(char *str)
1050 *p = 0; 1010 *p = 0;
1051 1011
1052 return 1; 1012 return 1;
1053 1013
1054} 1014}
1055 1015
1056__setup("acpi_os_name=", acpi_os_name_setup); 1016__setup("acpi_os_name=", acpi_os_name_setup);
@@ -1060,16 +1020,15 @@ __setup("acpi_os_name=", acpi_os_name_setup);
1060 * empty string disables _OSI 1020 * empty string disables _OSI
1061 * TBD additional string adds to _OSI 1021 * TBD additional string adds to _OSI
1062 */ 1022 */
1063static int __init 1023static int __init acpi_osi_setup(char *str)
1064acpi_osi_setup(char *str)
1065{ 1024{
1066 if (str == NULL || *str == '\0') { 1025 if (str == NULL || *str == '\0') {
1067 printk(KERN_INFO PREFIX "_OSI method disabled\n"); 1026 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1068 acpi_gbl_create_osi_method = FALSE; 1027 acpi_gbl_create_osi_method = FALSE;
1069 } else 1028 } else {
1070 {
1071 /* TBD */ 1029 /* TBD */
1072 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", str); 1030 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
1031 str);
1073 } 1032 }
1074 1033
1075 return 1; 1034 return 1;
@@ -1078,8 +1037,7 @@ acpi_osi_setup(char *str)
1078__setup("acpi_osi=", acpi_osi_setup); 1037__setup("acpi_osi=", acpi_osi_setup);
1079 1038
1080/* enable serialization to combat AE_ALREADY_EXISTS errors */ 1039/* enable serialization to combat AE_ALREADY_EXISTS errors */
1081static int __init 1040static int __init acpi_serialize_setup(char *str)
1082acpi_serialize_setup(char *str)
1083{ 1041{
1084 printk(KERN_INFO PREFIX "serialize enabled\n"); 1042 printk(KERN_INFO PREFIX "serialize enabled\n");
1085 1043
@@ -1099,8 +1057,7 @@ __setup("acpi_serialize", acpi_serialize_setup);
1099 * Run-time events on the same GPE this flag is available 1057 * Run-time events on the same GPE this flag is available
1100 * to tell Linux to keep the wake-time GPEs enabled at run-time. 1058 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1101 */ 1059 */
1102static int __init 1060static int __init acpi_wake_gpes_always_on_setup(char *str)
1103acpi_wake_gpes_always_on_setup(char *str)
1104{ 1061{
1105 printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); 1062 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1106 1063
@@ -1111,8 +1068,7 @@ acpi_wake_gpes_always_on_setup(char *str)
1111 1068
1112__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); 1069__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1113 1070
1114int __init 1071int __init acpi_hotkey_setup(char *str)
1115acpi_hotkey_setup(char *str)
1116{ 1072{
1117 acpi_specific_hotkey_enabled = TRUE; 1073 acpi_specific_hotkey_enabled = TRUE;
1118 return 1; 1074 return 1;
@@ -1126,7 +1082,6 @@ __setup("acpi_specific_hotkey", acpi_hotkey_setup);
1126 */ 1082 */
1127unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; 1083unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1128 1084
1129
1130EXPORT_SYMBOL(max_cstate); 1085EXPORT_SYMBOL(max_cstate);
1131 1086
1132/* 1087/*
@@ -1137,12 +1092,10 @@ EXPORT_SYMBOL(max_cstate);
1137 * that indicates whether we are at interrupt level. 1092 * that indicates whether we are at interrupt level.
1138 */ 1093 */
1139 1094
1140unsigned long 1095unsigned long acpi_os_acquire_lock(acpi_handle handle)
1141acpi_os_acquire_lock (
1142 acpi_handle handle)
1143{ 1096{
1144 unsigned long flags; 1097 unsigned long flags;
1145 spin_lock_irqsave((spinlock_t *)handle, flags); 1098 spin_lock_irqsave((spinlock_t *) handle, flags);
1146 return flags; 1099 return flags;
1147} 1100}
1148 1101
@@ -1150,15 +1103,11 @@ acpi_os_acquire_lock (
1150 * Release a spinlock. See above. 1103 * Release a spinlock. See above.
1151 */ 1104 */
1152 1105
1153void 1106void acpi_os_release_lock(acpi_handle handle, unsigned long flags)
1154acpi_os_release_lock (
1155 acpi_handle handle,
1156 unsigned long flags)
1157{ 1107{
1158 spin_unlock_irqrestore((spinlock_t *)handle, flags); 1108 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1159} 1109}
1160 1110
1161
1162#ifndef ACPI_USE_LOCAL_CACHE 1111#ifndef ACPI_USE_LOCAL_CACHE
1163 1112
1164/******************************************************************************* 1113/*******************************************************************************
@@ -1177,13 +1126,9 @@ acpi_os_release_lock (
1177 ******************************************************************************/ 1126 ******************************************************************************/
1178 1127
1179acpi_status 1128acpi_status
1180acpi_os_create_cache ( 1129acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1181 char *name,
1182 u16 size,
1183 u16 depth,
1184 acpi_cache_t **cache)
1185{ 1130{
1186 *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL); 1131 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1187 return AE_OK; 1132 return AE_OK;
1188} 1133}
1189 1134
@@ -1199,12 +1144,10 @@ acpi_os_create_cache (
1199 * 1144 *
1200 ******************************************************************************/ 1145 ******************************************************************************/
1201 1146
1202acpi_status 1147acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1203acpi_os_purge_cache (
1204 acpi_cache_t *cache)
1205{ 1148{
1206 (void) kmem_cache_shrink(cache); 1149 (void)kmem_cache_shrink(cache);
1207 return (AE_OK); 1150 return (AE_OK);
1208} 1151}
1209 1152
1210/******************************************************************************* 1153/*******************************************************************************
@@ -1220,12 +1163,10 @@ acpi_os_purge_cache (
1220 * 1163 *
1221 ******************************************************************************/ 1164 ******************************************************************************/
1222 1165
1223acpi_status 1166acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1224acpi_os_delete_cache (
1225 acpi_cache_t *cache)
1226{ 1167{
1227 (void)kmem_cache_destroy(cache); 1168 (void)kmem_cache_destroy(cache);
1228 return (AE_OK); 1169 return (AE_OK);
1229} 1170}
1230 1171
1231/******************************************************************************* 1172/*******************************************************************************
@@ -1242,13 +1183,10 @@ acpi_os_delete_cache (
1242 * 1183 *
1243 ******************************************************************************/ 1184 ******************************************************************************/
1244 1185
1245acpi_status 1186acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1246acpi_os_release_object (
1247 acpi_cache_t *cache,
1248 void *object)
1249{ 1187{
1250 kmem_cache_free(cache, object); 1188 kmem_cache_free(cache, object);
1251 return (AE_OK); 1189 return (AE_OK);
1252} 1190}
1253 1191
1254/******************************************************************************* 1192/*******************************************************************************
@@ -1265,14 +1203,11 @@ acpi_os_release_object (
1265 * 1203 *
1266 ******************************************************************************/ 1204 ******************************************************************************/
1267 1205
1268void * 1206void *acpi_os_acquire_object(acpi_cache_t * cache)
1269acpi_os_acquire_object (
1270 acpi_cache_t *cache)
1271{ 1207{
1272 void *object = kmem_cache_alloc(cache, GFP_KERNEL); 1208 void *object = kmem_cache_alloc(cache, GFP_KERNEL);
1273 WARN_ON(!object); 1209 WARN_ON(!object);
1274 return object; 1210 return object;
1275} 1211}
1276 1212
1277#endif 1213#endif
1278
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
index 551d54bdbec3..088d33999d90 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/parser/psloop.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
@@ -57,10 +56,9 @@
57#include <acpi/amlcode.h> 56#include <acpi/amlcode.h>
58 57
59#define _COMPONENT ACPI_PARSER 58#define _COMPONENT ACPI_PARSER
60 ACPI_MODULE_NAME ("psloop") 59ACPI_MODULE_NAME("psloop")
61
62static u32 acpi_gbl_depth = 0;
63 60
61static u32 acpi_gbl_depth = 0;
64 62
65/******************************************************************************* 63/*******************************************************************************
66 * 64 *
@@ -75,23 +73,20 @@ static u32 acpi_gbl_depth = 0;
75 * 73 *
76 ******************************************************************************/ 74 ******************************************************************************/
77 75
78acpi_status 76acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
79acpi_ps_parse_loop (
80 struct acpi_walk_state *walk_state)
81{ 77{
82 acpi_status status = AE_OK; 78 acpi_status status = AE_OK;
83 acpi_status status2; 79 acpi_status status2;
84 union acpi_parse_object *op = NULL; /* current op */ 80 union acpi_parse_object *op = NULL; /* current op */
85 union acpi_parse_object *arg = NULL; 81 union acpi_parse_object *arg = NULL;
86 union acpi_parse_object *pre_op = NULL; 82 union acpi_parse_object *pre_op = NULL;
87 struct acpi_parse_state *parser_state; 83 struct acpi_parse_state *parser_state;
88 u8 *aml_op_start = NULL; 84 u8 *aml_op_start = NULL;
89
90 85
91 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); 86 ACPI_FUNCTION_TRACE_PTR("ps_parse_loop", walk_state);
92 87
93 if (walk_state->descending_callback == NULL) { 88 if (walk_state->descending_callback == NULL) {
94 return_ACPI_STATUS (AE_BAD_PARAMETER); 89 return_ACPI_STATUS(AE_BAD_PARAMETER);
95 } 90 }
96 91
97 parser_state = &walk_state->parser_state; 92 parser_state = &walk_state->parser_state;
@@ -102,45 +97,56 @@ acpi_ps_parse_loop (
102 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { 97 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
103 /* We are restarting a preempted control method */ 98 /* We are restarting a preempted control method */
104 99
105 if (acpi_ps_has_completed_scope (parser_state)) { 100 if (acpi_ps_has_completed_scope(parser_state)) {
106 /* 101 /*
107 * We must check if a predicate to an IF or WHILE statement 102 * We must check if a predicate to an IF or WHILE statement
108 * was just completed 103 * was just completed
109 */ 104 */
110 if ((parser_state->scope->parse_scope.op) && 105 if ((parser_state->scope->parse_scope.op) &&
111 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || 106 ((parser_state->scope->parse_scope.op->common.
112 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && 107 aml_opcode == AML_IF_OP)
113 (walk_state->control_state) && 108 || (parser_state->scope->parse_scope.op->common.
114 (walk_state->control_state->common.state == 109 aml_opcode == AML_WHILE_OP))
115 ACPI_CONTROL_PREDICATE_EXECUTING)) { 110 && (walk_state->control_state)
111 && (walk_state->control_state->common.state ==
112 ACPI_CONTROL_PREDICATE_EXECUTING)) {
116 /* 113 /*
117 * A predicate was just completed, get the value of the 114 * A predicate was just completed, get the value of the
118 * predicate and branch based on that value 115 * predicate and branch based on that value
119 */ 116 */
120 walk_state->op = NULL; 117 walk_state->op = NULL;
121 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); 118 status =
122 if (ACPI_FAILURE (status) && 119 acpi_ds_get_predicate_value(walk_state,
123 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { 120 ACPI_TO_POINTER
121 (TRUE));
122 if (ACPI_FAILURE(status)
123 && ((status & AE_CODE_MASK) !=
124 AE_CODE_CONTROL)) {
124 if (status == AE_AML_NO_RETURN_VALUE) { 125 if (status == AE_AML_NO_RETURN_VALUE) {
125 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
126 "Invoked method did not return a value, %s\n", 127 "Invoked method did not return a value, %s\n",
127 acpi_format_exception (status))); 128 acpi_format_exception
129 (status)));
128 130
129 } 131 }
130 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
131 "get_predicate Failed, %s\n", 133 "get_predicate Failed, %s\n",
132 acpi_format_exception (status))); 134 acpi_format_exception
133 return_ACPI_STATUS (status); 135 (status)));
136 return_ACPI_STATUS(status);
134 } 137 }
135 138
136 status = acpi_ps_next_parse_state (walk_state, op, status); 139 status =
140 acpi_ps_next_parse_state(walk_state, op,
141 status);
137 } 142 }
138 143
139 acpi_ps_pop_scope (parser_state, &op, 144 acpi_ps_pop_scope(parser_state, &op,
140 &walk_state->arg_types, &walk_state->arg_count); 145 &walk_state->arg_types,
141 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); 146 &walk_state->arg_count);
142 } 147 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
143 else if (walk_state->prev_op) { 148 "Popped scope, Op=%p\n", op));
149 } else if (walk_state->prev_op) {
144 /* We were in the middle of an op */ 150 /* We were in the middle of an op */
145 151
146 op = walk_state->prev_op; 152 op = walk_state->prev_op;
@@ -156,9 +162,10 @@ acpi_ps_parse_loop (
156 if (!op) { 162 if (!op) {
157 /* Get the next opcode from the AML stream */ 163 /* Get the next opcode from the AML stream */
158 164
159 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, 165 walk_state->aml_offset =
160 parser_state->aml_start); 166 (u32) ACPI_PTR_DIFF(parser_state->aml,
161 walk_state->opcode = acpi_ps_peek_opcode (parser_state); 167 parser_state->aml_start);
168 walk_state->opcode = acpi_ps_peek_opcode(parser_state);
162 169
163 /* 170 /*
164 * First cut to determine what we have found: 171 * First cut to determine what we have found:
@@ -166,7 +173,8 @@ acpi_ps_parse_loop (
166 * 2) A name string 173 * 2) A name string
167 * 3) An unknown/invalid opcode 174 * 3) An unknown/invalid opcode
168 */ 175 */
169 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); 176 walk_state->op_info =
177 acpi_ps_get_opcode_info(walk_state->opcode);
170 switch (walk_state->op_info->class) { 178 switch (walk_state->op_info->class) {
171 case AML_CLASS_ASCII: 179 case AML_CLASS_ASCII:
172 case AML_CLASS_PREFIX: 180 case AML_CLASS_PREFIX:
@@ -182,11 +190,13 @@ acpi_ps_parse_loop (
182 190
183 /* The opcode is unrecognized. Just skip unknown opcodes */ 191 /* The opcode is unrecognized. Just skip unknown opcodes */
184 192
185 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 193 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
186 "Found unknown opcode %X at AML address %p offset %X, ignoring\n", 194 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
187 walk_state->opcode, parser_state->aml, walk_state->aml_offset)); 195 walk_state->opcode,
196 parser_state->aml,
197 walk_state->aml_offset));
188 198
189 ACPI_DUMP_BUFFER (parser_state->aml, 128); 199 ACPI_DUMP_BUFFER(parser_state->aml, 128);
190 200
191 /* Assume one-byte bad opcode */ 201 /* Assume one-byte bad opcode */
192 202
@@ -197,8 +207,10 @@ acpi_ps_parse_loop (
197 207
198 /* Found opcode info, this is a normal opcode */ 208 /* Found opcode info, this is a normal opcode */
199 209
200 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); 210 parser_state->aml +=
201 walk_state->arg_types = walk_state->op_info->parse_args; 211 acpi_ps_get_opcode_size(walk_state->opcode);
212 walk_state->arg_types =
213 walk_state->op_info->parse_args;
202 break; 214 break;
203 } 215 }
204 216
@@ -208,7 +220,9 @@ acpi_ps_parse_loop (
208 /* Allocate a new pre_op if necessary */ 220 /* Allocate a new pre_op if necessary */
209 221
210 if (!pre_op) { 222 if (!pre_op) {
211 pre_op = acpi_ps_alloc_op (walk_state->opcode); 223 pre_op =
224 acpi_ps_alloc_op(walk_state->
225 opcode);
212 if (!pre_op) { 226 if (!pre_op) {
213 status = AE_NO_MEMORY; 227 status = AE_NO_MEMORY;
214 goto close_this_op; 228 goto close_this_op;
@@ -222,30 +236,40 @@ acpi_ps_parse_loop (
222 * Get and append arguments until we find the node that contains 236 * Get and append arguments until we find the node that contains
223 * the name (the type ARGP_NAME). 237 * the name (the type ARGP_NAME).
224 */ 238 */
225 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && 239 while (GET_CURRENT_ARG_TYPE
226 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { 240 (walk_state->arg_types)
227 status = acpi_ps_get_next_arg (walk_state, parser_state, 241 &&
228 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); 242 (GET_CURRENT_ARG_TYPE
229 if (ACPI_FAILURE (status)) { 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)) {
230 goto close_this_op; 252 goto close_this_op;
231 } 253 }
232 254
233 acpi_ps_append_arg (pre_op, arg); 255 acpi_ps_append_arg(pre_op, arg);
234 INCREMENT_ARG_LIST (walk_state->arg_types); 256 INCREMENT_ARG_LIST(walk_state->
257 arg_types);
235 } 258 }
236 259
237 /* 260 /*
238 * Make sure that we found a NAME and didn't run out of 261 * Make sure that we found a NAME and didn't run out of
239 * arguments 262 * arguments
240 */ 263 */
241 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { 264 if (!GET_CURRENT_ARG_TYPE
265 (walk_state->arg_types)) {
242 status = AE_AML_NO_OPERAND; 266 status = AE_AML_NO_OPERAND;
243 goto close_this_op; 267 goto close_this_op;
244 } 268 }
245 269
246 /* We know that this arg is a name, move to next arg */ 270 /* We know that this arg is a name, move to next arg */
247 271
248 INCREMENT_ARG_LIST (walk_state->arg_types); 272 INCREMENT_ARG_LIST(walk_state->arg_types);
249 273
250 /* 274 /*
251 * Find the object. This will either insert the object into 275 * Find the object. This will either insert the object into
@@ -253,11 +277,14 @@ acpi_ps_parse_loop (
253 */ 277 */
254 walk_state->op = NULL; 278 walk_state->op = NULL;
255 279
256 status = walk_state->descending_callback (walk_state, &op); 280 status =
257 if (ACPI_FAILURE (status)) { 281 walk_state->descending_callback(walk_state,
258 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 282 &op);
259 "During name lookup/catalog, %s\n", 283 if (ACPI_FAILURE(status)) {
260 acpi_format_exception (status))); 284 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
285 "During name lookup/catalog, %s\n",
286 acpi_format_exception
287 (status)));
261 goto close_this_op; 288 goto close_this_op;
262 } 289 }
263 290
@@ -265,17 +292,20 @@ acpi_ps_parse_loop (
265 continue; 292 continue;
266 } 293 }
267 294
268 status = acpi_ps_next_parse_state (walk_state, op, status); 295 status =
296 acpi_ps_next_parse_state(walk_state, op,
297 status);
269 if (status == AE_CTRL_PENDING) { 298 if (status == AE_CTRL_PENDING) {
270 status = AE_OK; 299 status = AE_OK;
271 goto close_this_op; 300 goto close_this_op;
272 } 301 }
273 302
274 if (ACPI_FAILURE (status)) { 303 if (ACPI_FAILURE(status)) {
275 goto close_this_op; 304 goto close_this_op;
276 } 305 }
277 306
278 acpi_ps_append_arg (op, pre_op->common.value.arg); 307 acpi_ps_append_arg(op,
308 pre_op->common.value.arg);
279 acpi_gbl_depth++; 309 acpi_gbl_depth++;
280 310
281 if (op->common.aml_opcode == AML_REGION_OP) { 311 if (op->common.aml_opcode == AML_REGION_OP) {
@@ -291,15 +321,15 @@ acpi_ps_parse_loop (
291 * 321 *
292 * (Length is unknown until parse of the body complete) 322 * (Length is unknown until parse of the body complete)
293 */ 323 */
294 op->named.data = aml_op_start; 324 op->named.data = aml_op_start;
295 op->named.length = 0; 325 op->named.length = 0;
296 } 326 }
297 } 327 } else {
298 else {
299 /* Not a named opcode, just allocate Op and append to parent */ 328 /* Not a named opcode, just allocate Op and append to parent */
300 329
301 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); 330 walk_state->op_info =
302 op = acpi_ps_alloc_op (walk_state->opcode); 331 acpi_ps_get_opcode_info(walk_state->opcode);
332 op = acpi_ps_alloc_op(walk_state->opcode);
303 if (!op) { 333 if (!op) {
304 status = AE_NO_MEMORY; 334 status = AE_NO_MEMORY;
305 goto close_this_op; 335 goto close_this_op;
@@ -310,11 +340,12 @@ acpi_ps_parse_loop (
310 * Backup to beginning of create_xXXfield declaration 340 * Backup to beginning of create_xXXfield declaration
311 * body_length is unknown until we parse the body 341 * body_length is unknown until we parse the body
312 */ 342 */
313 op->named.data = aml_op_start; 343 op->named.data = aml_op_start;
314 op->named.length = 0; 344 op->named.length = 0;
315 } 345 }
316 346
317 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); 347 acpi_ps_append_arg(acpi_ps_get_parent_scope
348 (parser_state), op);
318 349
319 if ((walk_state->descending_callback != NULL)) { 350 if ((walk_state->descending_callback != NULL)) {
320 /* 351 /*
@@ -323,14 +354,20 @@ acpi_ps_parse_loop (
323 */ 354 */
324 walk_state->op = op; 355 walk_state->op = op;
325 356
326 status = walk_state->descending_callback (walk_state, &op); 357 status =
327 status = acpi_ps_next_parse_state (walk_state, op, 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);
328 if (status == AE_CTRL_PENDING) { 365 if (status == AE_CTRL_PENDING) {
329 status = AE_OK; 366 status = AE_OK;
330 goto close_this_op; 367 goto close_this_op;
331 } 368 }
332 369
333 if (ACPI_FAILURE (status)) { 370 if (ACPI_FAILURE(status)) {
334 goto close_this_op; 371 goto close_this_op;
335 } 372 }
336 } 373 }
@@ -339,14 +376,15 @@ acpi_ps_parse_loop (
339 op->common.aml_offset = walk_state->aml_offset; 376 op->common.aml_offset = walk_state->aml_offset;
340 377
341 if (walk_state->op_info) { 378 if (walk_state->op_info) {
342 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 379 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
343 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", 380 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
344 (u32) op->common.aml_opcode, walk_state->op_info->name, 381 (u32) op->common.aml_opcode,
345 op, parser_state->aml, op->common.aml_offset)); 382 walk_state->op_info->name, op,
383 parser_state->aml,
384 op->common.aml_offset));
346 } 385 }
347 } 386 }
348 387
349
350 /* 388 /*
351 * Start arg_count at zero because we don't know if there are 389 * Start arg_count at zero because we don't know if there are
352 * any args yet 390 * any args yet
@@ -359,22 +397,27 @@ acpi_ps_parse_loop (
359 /* Get arguments */ 397 /* Get arguments */
360 398
361 switch (op->common.aml_opcode) { 399 switch (op->common.aml_opcode) {
362 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ 400 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
363 case AML_WORD_OP: /* AML_WORDDATA_ARG */ 401 case AML_WORD_OP: /* AML_WORDDATA_ARG */
364 case AML_DWORD_OP: /* AML_DWORDATA_ARG */ 402 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
365 case AML_QWORD_OP: /* AML_QWORDATA_ARG */ 403 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
366 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ 404 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
367 405
368 /* Fill in constant or string argument directly */ 406 /* Fill in constant or string argument directly */
369 407
370 acpi_ps_get_next_simple_arg (parser_state, 408 acpi_ps_get_next_simple_arg(parser_state,
371 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); 409 GET_CURRENT_ARG_TYPE
410 (walk_state->
411 arg_types), op);
372 break; 412 break;
373 413
374 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ 414 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
375 415
376 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); 416 status =
377 if (ACPI_FAILURE (status)) { 417 acpi_ps_get_next_namepath(walk_state,
418 parser_state, op,
419 1);
420 if (ACPI_FAILURE(status)) {
378 goto close_this_op; 421 goto close_this_op;
379 } 422 }
380 423
@@ -386,34 +429,46 @@ acpi_ps_parse_loop (
386 * Op is not a constant or string, append each argument 429 * Op is not a constant or string, append each argument
387 * to the Op 430 * to the Op
388 */ 431 */
389 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && 432 while (GET_CURRENT_ARG_TYPE
390 !walk_state->arg_count) { 433 (walk_state->arg_types)
434 && !walk_state->arg_count) {
391 walk_state->aml_offset = (u32) 435 walk_state->aml_offset = (u32)
392 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); 436 ACPI_PTR_DIFF(parser_state->aml,
393 437 parser_state->
394 status = acpi_ps_get_next_arg (walk_state, parser_state, 438 aml_start);
395 GET_CURRENT_ARG_TYPE (walk_state->arg_types), 439
396 &arg); 440 status =
397 if (ACPI_FAILURE (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)) {
398 goto close_this_op; 448 goto close_this_op;
399 } 449 }
400 450
401 if (arg) { 451 if (arg) {
402 arg->common.aml_offset = walk_state->aml_offset; 452 arg->common.aml_offset =
403 acpi_ps_append_arg (op, arg); 453 walk_state->aml_offset;
454 acpi_ps_append_arg(op, arg);
404 } 455 }
405 INCREMENT_ARG_LIST (walk_state->arg_types); 456 INCREMENT_ARG_LIST(walk_state->
457 arg_types);
406 } 458 }
407 459
408
409 /* Special processing for certain opcodes */ 460 /* Special processing for certain opcodes */
410 461
411 /* TBD (remove): Temporary mechanism to disable this code if needed */ 462 /* TBD (remove): Temporary mechanism to disable this code if needed */
412 463
413#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE 464#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
414 465
415 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && 466 if ((walk_state->pass_number <=
416 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { 467 ACPI_IMODE_LOAD_PASS1)
468 &&
469 ((walk_state->
470 parse_flags & ACPI_PARSE_DISASSEMBLE) ==
471 0)) {
417 /* 472 /*
418 * We want to skip If/Else/While constructs during Pass1 473 * We want to skip If/Else/While constructs during Pass1
419 * because we want to actually conditionally execute the 474 * because we want to actually conditionally execute the
@@ -427,12 +482,13 @@ acpi_ps_parse_loop (
427 case AML_ELSE_OP: 482 case AML_ELSE_OP:
428 case AML_WHILE_OP: 483 case AML_WHILE_OP:
429 484
430 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 485 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
431 "Pass1: Skipping an If/Else/While body\n")); 486 "Pass1: Skipping an If/Else/While body\n"));
432 487
433 /* Skip body of if/else/while in pass 1 */ 488 /* Skip body of if/else/while in pass 1 */
434 489
435 parser_state->aml = parser_state->pkg_end; 490 parser_state->aml =
491 parser_state->pkg_end;
436 walk_state->arg_count = 0; 492 walk_state->arg_count = 0;
437 break; 493 break;
438 494
@@ -451,13 +507,15 @@ acpi_ps_parse_loop (
451 * 507 *
452 * Save the length and address of the body 508 * Save the length and address of the body
453 */ 509 */
454 op->named.data = parser_state->aml; 510 op->named.data = parser_state->aml;
455 op->named.length = (u32) (parser_state->pkg_end - 511 op->named.length =
456 parser_state->aml); 512 (u32) (parser_state->pkg_end -
513 parser_state->aml);
457 514
458 /* Skip body of method */ 515 /* Skip body of method */
459 516
460 parser_state->aml = parser_state->pkg_end; 517 parser_state->aml =
518 parser_state->pkg_end;
461 walk_state->arg_count = 0; 519 walk_state->arg_count = 0;
462 break; 520 break;
463 521
@@ -466,20 +524,25 @@ acpi_ps_parse_loop (
466 case AML_VAR_PACKAGE_OP: 524 case AML_VAR_PACKAGE_OP:
467 525
468 if ((op->common.parent) && 526 if ((op->common.parent) &&
469 (op->common.parent->common.aml_opcode == AML_NAME_OP) && 527 (op->common.parent->common.
470 (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { 528 aml_opcode == AML_NAME_OP)
529 && (walk_state->pass_number <=
530 ACPI_IMODE_LOAD_PASS2)) {
471 /* 531 /*
472 * Skip parsing of Buffers and Packages 532 * Skip parsing of Buffers and Packages
473 * because we don't have enough info in the first pass 533 * because we don't have enough info in the first pass
474 * to parse them correctly. 534 * to parse them correctly.
475 */ 535 */
476 op->named.data = aml_op_start; 536 op->named.data = aml_op_start;
477 op->named.length = (u32) (parser_state->pkg_end - 537 op->named.length =
478 aml_op_start); 538 (u32) (parser_state->
539 pkg_end -
540 aml_op_start);
479 541
480 /* Skip body */ 542 /* Skip body */
481 543
482 parser_state->aml = parser_state->pkg_end; 544 parser_state->aml =
545 parser_state->pkg_end;
483 walk_state->arg_count = 0; 546 walk_state->arg_count = 0;
484 } 547 }
485 break; 548 break;
@@ -487,8 +550,9 @@ acpi_ps_parse_loop (
487 case AML_WHILE_OP: 550 case AML_WHILE_OP:
488 551
489 if (walk_state->control_state) { 552 if (walk_state->control_state) {
490 walk_state->control_state->control.package_end = 553 walk_state->control_state->
491 parser_state->pkg_end; 554 control.package_end =
555 parser_state->pkg_end;
492 } 556 }
493 break; 557 break;
494 558
@@ -508,9 +572,10 @@ acpi_ps_parse_loop (
508 * There are arguments (complex ones), push Op and 572 * There are arguments (complex ones), push Op and
509 * prepare for argument 573 * prepare for argument
510 */ 574 */
511 status = acpi_ps_push_scope (parser_state, op, 575 status = acpi_ps_push_scope(parser_state, op,
512 walk_state->arg_types, walk_state->arg_count); 576 walk_state->arg_types,
513 if (ACPI_FAILURE (status)) { 577 walk_state->arg_count);
578 if (ACPI_FAILURE(status)) {
514 goto close_this_op; 579 goto close_this_op;
515 } 580 }
516 op = NULL; 581 op = NULL;
@@ -521,7 +586,8 @@ acpi_ps_parse_loop (
521 * All arguments have been processed -- Op is complete, 586 * All arguments have been processed -- Op is complete,
522 * prepare for next 587 * prepare for next
523 */ 588 */
524 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 589 walk_state->op_info =
590 acpi_ps_get_opcode_info(op->common.aml_opcode);
525 if (walk_state->op_info->flags & AML_NAMED) { 591 if (walk_state->op_info->flags & AML_NAMED) {
526 if (acpi_gbl_depth) { 592 if (acpi_gbl_depth) {
527 acpi_gbl_depth--; 593 acpi_gbl_depth--;
@@ -536,7 +602,8 @@ acpi_ps_parse_loop (
536 * Completed parsing an op_region declaration, we now 602 * Completed parsing an op_region declaration, we now
537 * know the length. 603 * know the length.
538 */ 604 */
539 op->named.length = (u32) (parser_state->aml - op->named.data); 605 op->named.length =
606 (u32) (parser_state->aml - op->named.data);
540 } 607 }
541 } 608 }
542 609
@@ -547,25 +614,26 @@ acpi_ps_parse_loop (
547 * 614 *
548 * body_length is unknown until we parse the body 615 * body_length is unknown until we parse the body
549 */ 616 */
550 op->named.length = (u32) (parser_state->aml - op->named.data); 617 op->named.length =
618 (u32) (parser_state->aml - op->named.data);
551 } 619 }
552 620
553 /* This op complete, notify the dispatcher */ 621 /* This op complete, notify the dispatcher */
554 622
555 if (walk_state->ascending_callback != NULL) { 623 if (walk_state->ascending_callback != NULL) {
556 walk_state->op = op; 624 walk_state->op = op;
557 walk_state->opcode = op->common.aml_opcode; 625 walk_state->opcode = op->common.aml_opcode;
558 626
559 status = walk_state->ascending_callback (walk_state); 627 status = walk_state->ascending_callback(walk_state);
560 status = acpi_ps_next_parse_state (walk_state, op, status); 628 status =
629 acpi_ps_next_parse_state(walk_state, op, status);
561 if (status == AE_CTRL_PENDING) { 630 if (status == AE_CTRL_PENDING) {
562 status = AE_OK; 631 status = AE_OK;
563 goto close_this_op; 632 goto close_this_op;
564 } 633 }
565 } 634 }
566 635
567 636 close_this_op:
568close_this_op:
569 /* 637 /*
570 * Finished one argument of the containing scope 638 * Finished one argument of the containing scope
571 */ 639 */
@@ -574,15 +642,15 @@ close_this_op:
574 /* Finished with pre_op */ 642 /* Finished with pre_op */
575 643
576 if (pre_op) { 644 if (pre_op) {
577 acpi_ps_free_op (pre_op); 645 acpi_ps_free_op(pre_op);
578 pre_op = NULL; 646 pre_op = NULL;
579 } 647 }
580 648
581 /* Close this Op (will result in parse subtree deletion) */ 649 /* Close this Op (will result in parse subtree deletion) */
582 650
583 status2 = acpi_ps_complete_this_op (walk_state, op); 651 status2 = acpi_ps_complete_this_op(walk_state, op);
584 if (ACPI_FAILURE (status2)) { 652 if (ACPI_FAILURE(status2)) {
585 return_ACPI_STATUS (status2); 653 return_ACPI_STATUS(status2);
586 } 654 }
587 op = NULL; 655 op = NULL;
588 656
@@ -590,68 +658,74 @@ close_this_op:
590 case AE_OK: 658 case AE_OK:
591 break; 659 break;
592 660
593
594 case AE_CTRL_TRANSFER: 661 case AE_CTRL_TRANSFER:
595 662
596 /* We are about to transfer to a called method. */ 663 /* We are about to transfer to a called method. */
597 664
598 walk_state->prev_op = op; 665 walk_state->prev_op = op;
599 walk_state->prev_arg_types = walk_state->arg_types; 666 walk_state->prev_arg_types = walk_state->arg_types;
600 return_ACPI_STATUS (status); 667 return_ACPI_STATUS(status);
601
602 668
603 case AE_CTRL_END: 669 case AE_CTRL_END:
604 670
605 acpi_ps_pop_scope (parser_state, &op, 671 acpi_ps_pop_scope(parser_state, &op,
606 &walk_state->arg_types, &walk_state->arg_count); 672 &walk_state->arg_types,
673 &walk_state->arg_count);
607 674
608 if (op) { 675 if (op) {
609 walk_state->op = op; 676 walk_state->op = op;
610 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 677 walk_state->op_info =
678 acpi_ps_get_opcode_info(op->common.
679 aml_opcode);
611 walk_state->opcode = op->common.aml_opcode; 680 walk_state->opcode = op->common.aml_opcode;
612 681
613 status = walk_state->ascending_callback (walk_state); 682 status =
614 status = acpi_ps_next_parse_state (walk_state, op, status); 683 walk_state->ascending_callback(walk_state);
684 status =
685 acpi_ps_next_parse_state(walk_state, op,
686 status);
615 687
616 status2 = acpi_ps_complete_this_op (walk_state, op); 688 status2 =
617 if (ACPI_FAILURE (status2)) { 689 acpi_ps_complete_this_op(walk_state, op);
618 return_ACPI_STATUS (status2); 690 if (ACPI_FAILURE(status2)) {
691 return_ACPI_STATUS(status2);
619 } 692 }
620 op = NULL; 693 op = NULL;
621 } 694 }
622 status = AE_OK; 695 status = AE_OK;
623 break; 696 break;
624 697
625
626 case AE_CTRL_BREAK: 698 case AE_CTRL_BREAK:
627 case AE_CTRL_CONTINUE: 699 case AE_CTRL_CONTINUE:
628 700
629 /* Pop off scopes until we find the While */ 701 /* Pop off scopes until we find the While */
630 702
631 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { 703 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
632 acpi_ps_pop_scope (parser_state, &op, 704 acpi_ps_pop_scope(parser_state, &op,
633 &walk_state->arg_types, &walk_state->arg_count); 705 &walk_state->arg_types,
706 &walk_state->arg_count);
634 } 707 }
635 708
636 /* Close this iteration of the While loop */ 709 /* Close this iteration of the While loop */
637 710
638 walk_state->op = op; 711 walk_state->op = op;
639 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 712 walk_state->op_info =
713 acpi_ps_get_opcode_info(op->common.aml_opcode);
640 walk_state->opcode = op->common.aml_opcode; 714 walk_state->opcode = op->common.aml_opcode;
641 715
642 status = walk_state->ascending_callback (walk_state); 716 status = walk_state->ascending_callback(walk_state);
643 status = acpi_ps_next_parse_state (walk_state, op, status); 717 status =
718 acpi_ps_next_parse_state(walk_state, op, status);
644 719
645 status2 = acpi_ps_complete_this_op (walk_state, op); 720 status2 = acpi_ps_complete_this_op(walk_state, op);
646 if (ACPI_FAILURE (status2)) { 721 if (ACPI_FAILURE(status2)) {
647 return_ACPI_STATUS (status2); 722 return_ACPI_STATUS(status2);
648 } 723 }
649 op = NULL; 724 op = NULL;
650 725
651 status = AE_OK; 726 status = AE_OK;
652 break; 727 break;
653 728
654
655 case AE_CTRL_TERMINATE: 729 case AE_CTRL_TERMINATE:
656 730
657 status = AE_OK; 731 status = AE_OK;
@@ -659,61 +733,66 @@ close_this_op:
659 /* Clean up */ 733 /* Clean up */
660 do { 734 do {
661 if (op) { 735 if (op) {
662 status2 = acpi_ps_complete_this_op (walk_state, op); 736 status2 =
663 if (ACPI_FAILURE (status2)) { 737 acpi_ps_complete_this_op(walk_state,
664 return_ACPI_STATUS (status2); 738 op);
739 if (ACPI_FAILURE(status2)) {
740 return_ACPI_STATUS(status2);
665 } 741 }
666 } 742 }
667 acpi_ps_pop_scope (parser_state, &op, 743 acpi_ps_pop_scope(parser_state, &op,
668 &walk_state->arg_types, &walk_state->arg_count); 744 &walk_state->arg_types,
745 &walk_state->arg_count);
669 746
670 } while (op); 747 } while (op);
671 748
672 return_ACPI_STATUS (status); 749 return_ACPI_STATUS(status);
673 750
674 751 default: /* All other non-AE_OK status */
675 default: /* All other non-AE_OK status */
676 752
677 do { 753 do {
678 if (op) { 754 if (op) {
679 status2 = acpi_ps_complete_this_op (walk_state, op); 755 status2 =
680 if (ACPI_FAILURE (status2)) { 756 acpi_ps_complete_this_op(walk_state,
681 return_ACPI_STATUS (status2); 757 op);
758 if (ACPI_FAILURE(status2)) {
759 return_ACPI_STATUS(status2);
682 } 760 }
683 } 761 }
684 acpi_ps_pop_scope (parser_state, &op, 762 acpi_ps_pop_scope(parser_state, &op,
685 &walk_state->arg_types, &walk_state->arg_count); 763 &walk_state->arg_types,
764 &walk_state->arg_count);
686 765
687 } while (op); 766 } while (op);
688 767
689
690 /* 768 /*
691 * TBD: Cleanup parse ops on error 769 * TBD: Cleanup parse ops on error
692 */ 770 */
693#if 0 771#if 0
694 if (op == NULL) { 772 if (op == NULL) {
695 acpi_ps_pop_scope (parser_state, &op, 773 acpi_ps_pop_scope(parser_state, &op,
696 &walk_state->arg_types, &walk_state->arg_count); 774 &walk_state->arg_types,
775 &walk_state->arg_count);
697 } 776 }
698#endif 777#endif
699 walk_state->prev_op = op; 778 walk_state->prev_op = op;
700 walk_state->prev_arg_types = walk_state->arg_types; 779 walk_state->prev_arg_types = walk_state->arg_types;
701 return_ACPI_STATUS (status); 780 return_ACPI_STATUS(status);
702 } 781 }
703 782
704 /* This scope complete? */ 783 /* This scope complete? */
705 784
706 if (acpi_ps_has_completed_scope (parser_state)) { 785 if (acpi_ps_has_completed_scope(parser_state)) {
707 acpi_ps_pop_scope (parser_state, &op, 786 acpi_ps_pop_scope(parser_state, &op,
708 &walk_state->arg_types, &walk_state->arg_count); 787 &walk_state->arg_types,
709 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); 788 &walk_state->arg_count);
710 } 789 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
711 else { 790 "Popped scope, Op=%p\n", op));
791 } else {
712 op = NULL; 792 op = NULL;
713 } 793 }
714 794
715 } /* while parser_state->Aml */ 795 } /* while parser_state->Aml */
716
717 796
718 /* 797 /*
719 * Complete the last Op (if not completed), and clear the scope stack. 798 * Complete the last Op (if not completed), and clear the scope stack.
@@ -721,16 +800,22 @@ close_this_op:
721 * of open scopes (such as when several ASL blocks are closed with 800 * of open scopes (such as when several ASL blocks are closed with
722 * sequential closing braces). We want to terminate each one cleanly. 801 * sequential closing braces). We want to terminate each one cleanly.
723 */ 802 */
724 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); 803 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
804 op));
725 do { 805 do {
726 if (op) { 806 if (op) {
727 if (walk_state->ascending_callback != NULL) { 807 if (walk_state->ascending_callback != NULL) {
728 walk_state->op = op; 808 walk_state->op = op;
729 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 809 walk_state->op_info =
810 acpi_ps_get_opcode_info(op->common.
811 aml_opcode);
730 walk_state->opcode = op->common.aml_opcode; 812 walk_state->opcode = op->common.aml_opcode;
731 813
732 status = walk_state->ascending_callback (walk_state); 814 status =
733 status = acpi_ps_next_parse_state (walk_state, op, status); 815 walk_state->ascending_callback(walk_state);
816 status =
817 acpi_ps_next_parse_state(walk_state, op,
818 status);
734 if (status == AE_CTRL_PENDING) { 819 if (status == AE_CTRL_PENDING) {
735 status = AE_OK; 820 status = AE_OK;
736 goto close_this_op; 821 goto close_this_op;
@@ -742,40 +827,48 @@ close_this_op:
742 /* Clean up */ 827 /* Clean up */
743 do { 828 do {
744 if (op) { 829 if (op) {
745 status2 = acpi_ps_complete_this_op (walk_state, op); 830 status2 =
746 if (ACPI_FAILURE (status2)) { 831 acpi_ps_complete_this_op
747 return_ACPI_STATUS (status2); 832 (walk_state, op);
833 if (ACPI_FAILURE
834 (status2)) {
835 return_ACPI_STATUS
836 (status2);
748 } 837 }
749 } 838 }
750 839
751 acpi_ps_pop_scope (parser_state, &op, 840 acpi_ps_pop_scope(parser_state,
752 &walk_state->arg_types, &walk_state->arg_count); 841 &op,
842 &walk_state->
843 arg_types,
844 &walk_state->
845 arg_count);
753 846
754 } while (op); 847 } while (op);
755 848
756 return_ACPI_STATUS (status); 849 return_ACPI_STATUS(status);
757 } 850 }
758 851
759 else if (ACPI_FAILURE (status)) { 852 else if (ACPI_FAILURE(status)) {
760 /* First error is most important */ 853 /* First error is most important */
761 854
762 (void) acpi_ps_complete_this_op (walk_state, op); 855 (void)
763 return_ACPI_STATUS (status); 856 acpi_ps_complete_this_op(walk_state,
857 op);
858 return_ACPI_STATUS(status);
764 } 859 }
765 } 860 }
766 861
767 status2 = acpi_ps_complete_this_op (walk_state, op); 862 status2 = acpi_ps_complete_this_op(walk_state, op);
768 if (ACPI_FAILURE (status2)) { 863 if (ACPI_FAILURE(status2)) {
769 return_ACPI_STATUS (status2); 864 return_ACPI_STATUS(status2);
770 } 865 }
771 } 866 }
772 867
773 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, 868 acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types,
774 &walk_state->arg_count); 869 &walk_state->arg_count);
775 870
776 } while (op); 871 } while (op);
777 872
778 return_ACPI_STATUS (status); 873 return_ACPI_STATUS(status);
779} 874}
780
781
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 6f7594a516d2..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,12 +723,9 @@ 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
@@ -431,25 +733,26 @@ acpi_ps_get_opcode_info (
431 if (!(opcode & 0xFF00)) { 733 if (!(opcode & 0xFF00)) {
432 /* Simple (8-bit) opcode: 0-255, can't index beyond table */ 734 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
433 735
434 return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); 736 return (&acpi_gbl_aml_op_info
737 [acpi_gbl_short_op_index[(u8) opcode]]);
435 } 738 }
436 739
437 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && 740 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
438 (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { 741 (((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
439 /* Valid extended (16-bit) opcode */ 742 /* Valid extended (16-bit) opcode */
440 743
441 return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); 744 return (&acpi_gbl_aml_op_info
745 [acpi_gbl_long_op_index[(u8) opcode]]);
442 } 746 }
443 747
444 /* Unknown AML opcode */ 748 /* Unknown AML opcode */
445 749
446 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 750 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
447 "Unknown AML opcode [%4.4X]\n", opcode)); 751 "Unknown AML opcode [%4.4X]\n", opcode));
448 752
449 return (&acpi_gbl_aml_op_info [_UNK]); 753 return (&acpi_gbl_aml_op_info[_UNK]);
450} 754}
451 755
452
453/******************************************************************************* 756/*******************************************************************************
454 * 757 *
455 * FUNCTION: acpi_ps_get_opcode_name 758 * FUNCTION: acpi_ps_get_opcode_name
@@ -463,16 +766,13 @@ acpi_ps_get_opcode_info (
463 * 766 *
464 ******************************************************************************/ 767 ******************************************************************************/
465 768
466char * 769char *acpi_ps_get_opcode_name(u16 opcode)
467acpi_ps_get_opcode_name (
468 u16 opcode)
469{ 770{
470#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) 771#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
471 772
472 const struct acpi_opcode_info *op; 773 const struct acpi_opcode_info *op;
473
474 774
475 op = acpi_ps_get_opcode_info (opcode); 775 op = acpi_ps_get_opcode_info(opcode);
476 776
477 /* Always guaranteed to return a valid pointer */ 777 /* Always guaranteed to return a valid pointer */
478 778
@@ -483,4 +783,3 @@ acpi_ps_get_opcode_name (
483 783
484#endif 784#endif
485} 785}
486
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 16b84a3d0436..3248051d77ee 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,8 +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 62
65/******************************************************************************* 63/*******************************************************************************
66 * 64 *
@@ -73,10 +71,7 @@
73 * DESCRIPTION: Get the size of the current opcode. 71 * DESCRIPTION: Get the size of the current opcode.
74 * 72 *
75 ******************************************************************************/ 73 ******************************************************************************/
76 74u32 acpi_ps_get_opcode_size(u32 opcode)
77u32
78acpi_ps_get_opcode_size (
79 u32 opcode)
80{ 75{
81 76
82 /* Extended (2-byte) opcode if > 255 */ 77 /* Extended (2-byte) opcode if > 255 */
@@ -90,7 +85,6 @@ acpi_ps_get_opcode_size (
90 return (1); 85 return (1);
91} 86}
92 87
93
94/******************************************************************************* 88/*******************************************************************************
95 * 89 *
96 * FUNCTION: acpi_ps_peek_opcode 90 * FUNCTION: acpi_ps_peek_opcode
@@ -103,28 +97,24 @@ acpi_ps_get_opcode_size (
103 * 97 *
104 ******************************************************************************/ 98 ******************************************************************************/
105 99
106u16 100u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
107acpi_ps_peek_opcode (
108 struct acpi_parse_state *parser_state)
109{ 101{
110 u8 *aml; 102 u8 *aml;
111 u16 opcode; 103 u16 opcode;
112
113 104
114 aml = parser_state->aml; 105 aml = parser_state->aml;
115 opcode = (u16) ACPI_GET8 (aml); 106 opcode = (u16) ACPI_GET8(aml);
116 107
117 if (opcode == AML_EXTENDED_OP_PREFIX) { 108 if (opcode == AML_EXTENDED_OP_PREFIX) {
118 /* Extended opcode, get the second opcode byte */ 109 /* Extended opcode, get the second opcode byte */
119 110
120 aml++; 111 aml++;
121 opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); 112 opcode = (u16) ((opcode << 8) | ACPI_GET8(aml));
122 } 113 }
123 114
124 return (opcode); 115 return (opcode);
125} 116}
126 117
127
128/******************************************************************************* 118/*******************************************************************************
129 * 119 *
130 * FUNCTION: acpi_ps_complete_this_op 120 * FUNCTION: acpi_ps_complete_this_op
@@ -139,30 +129,28 @@ acpi_ps_peek_opcode (
139 ******************************************************************************/ 129 ******************************************************************************/
140 130
141acpi_status 131acpi_status
142acpi_ps_complete_this_op ( 132acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
143 struct acpi_walk_state *walk_state, 133 union acpi_parse_object * op)
144 union acpi_parse_object *op)
145{ 134{
146 union acpi_parse_object *prev; 135 union acpi_parse_object *prev;
147 union acpi_parse_object *next; 136 union acpi_parse_object *next;
148 const struct acpi_opcode_info *parent_info; 137 const struct acpi_opcode_info *parent_info;
149 union acpi_parse_object *replacement_op = NULL; 138 union acpi_parse_object *replacement_op = NULL;
150
151
152 ACPI_FUNCTION_TRACE_PTR ("ps_complete_this_op", op);
153 139
140 ACPI_FUNCTION_TRACE_PTR("ps_complete_this_op", op);
154 141
155 /* Check for null Op, can happen if AML code is corrupt */ 142 /* Check for null Op, can happen if AML code is corrupt */
156 143
157 if (!op) { 144 if (!op) {
158 return_ACPI_STATUS (AE_OK); /* OK for now */ 145 return_ACPI_STATUS(AE_OK); /* OK for now */
159 } 146 }
160 147
161 /* Delete this op and the subtree below it if asked to */ 148 /* Delete this op and the subtree below it if asked to */
162 149
163 if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || 150 if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) !=
164 (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { 151 ACPI_PARSE_DELETE_TREE)
165 return_ACPI_STATUS (AE_OK); 152 || (walk_state->op_info->class == AML_CLASS_ARGUMENT)) {
153 return_ACPI_STATUS(AE_OK);
166 } 154 }
167 155
168 /* Make sure that we only delete this subtree */ 156 /* Make sure that we only delete this subtree */
@@ -179,7 +167,9 @@ acpi_ps_complete_this_op (
179 * Check if we need to replace the operator and its subtree 167 * Check if we need to replace the operator and its subtree
180 * with a return value op (placeholder op) 168 * with a return value op (placeholder op)
181 */ 169 */
182 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);
183 173
184 switch (parent_info->class) { 174 switch (parent_info->class) {
185 case AML_CLASS_CONTROL: 175 case AML_CLASS_CONTROL:
@@ -191,7 +181,8 @@ acpi_ps_complete_this_op (
191 * These opcodes contain term_arg operands. The current 181 * These opcodes contain term_arg operands. The current
192 * op must be replaced by a placeholder return op 182 * op must be replaced by a placeholder return op
193 */ 183 */
194 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); 184 replacement_op =
185 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
195 if (!replacement_op) { 186 if (!replacement_op) {
196 goto allocate_error; 187 goto allocate_error;
197 } 188 }
@@ -203,35 +194,49 @@ acpi_ps_complete_this_op (
203 * These opcodes contain term_arg operands. The current 194 * These opcodes contain term_arg operands. The current
204 * op must be replaced by a placeholder return op 195 * op must be replaced by a placeholder return op
205 */ 196 */
206 if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || 197 if ((op->common.parent->common.aml_opcode ==
207 (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) || 198 AML_REGION_OP)
208 (op->common.parent->common.aml_opcode == AML_BUFFER_OP) || 199 || (op->common.parent->common.aml_opcode ==
209 (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || 200 AML_DATA_REGION_OP)
210 (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { 201 || (op->common.parent->common.aml_opcode ==
211 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);
212 if (!replacement_op) { 209 if (!replacement_op) {
213 goto allocate_error; 210 goto allocate_error;
214 } 211 }
215 } 212 } else
216 else if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && 213 if ((op->common.parent->common.aml_opcode ==
217 (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { 214 AML_NAME_OP)
218 if ((op->common.aml_opcode == AML_BUFFER_OP) || 215 && (walk_state->pass_number <=
219 (op->common.aml_opcode == AML_PACKAGE_OP) || 216 ACPI_IMODE_LOAD_PASS2)) {
220 (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { 217 if ((op->common.aml_opcode == AML_BUFFER_OP)
221 replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); 218 || (op->common.aml_opcode == AML_PACKAGE_OP)
219 || (op->common.aml_opcode ==
220 AML_VAR_PACKAGE_OP)) {
221 replacement_op =
222 acpi_ps_alloc_op(op->common.
223 aml_opcode);
222 if (!replacement_op) { 224 if (!replacement_op) {
223 goto allocate_error; 225 goto allocate_error;
224 } 226 }
225 227
226 replacement_op->named.data = op->named.data; 228 replacement_op->named.data =
227 replacement_op->named.length = op->named.length; 229 op->named.data;
230 replacement_op->named.length =
231 op->named.length;
228 } 232 }
229 } 233 }
230 break; 234 break;
231 235
232 default: 236 default:
233 237
234 replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); 238 replacement_op =
239 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
235 if (!replacement_op) { 240 if (!replacement_op) {
236 goto allocate_error; 241 goto allocate_error;
237 } 242 }
@@ -243,59 +248,64 @@ acpi_ps_complete_this_op (
243 /* This op is the first in the list */ 248 /* This op is the first in the list */
244 249
245 if (replacement_op) { 250 if (replacement_op) {
246 replacement_op->common.parent = op->common.parent; 251 replacement_op->common.parent =
247 replacement_op->common.value.arg = NULL; 252 op->common.parent;
248 replacement_op->common.node = op->common.node; 253 replacement_op->common.value.arg = NULL;
249 op->common.parent->common.value.arg = replacement_op; 254 replacement_op->common.node = op->common.node;
250 replacement_op->common.next = op->common.next; 255 op->common.parent->common.value.arg =
251 } 256 replacement_op;
252 else { 257 replacement_op->common.next = op->common.next;
253 op->common.parent->common.value.arg = op->common.next; 258 } else {
259 op->common.parent->common.value.arg =
260 op->common.next;
254 } 261 }
255 } 262 }
256 263
257 /* Search the parent list */ 264 /* Search the parent list */
258 265
259 else while (prev) { 266 else
260 /* Traverse all siblings in the parent's argument list */ 267 while (prev) {
261 268 /* Traverse all siblings in the parent's argument list */
262 next = prev->common.next; 269
263 if (next == op) { 270 next = prev->common.next;
264 if (replacement_op) { 271 if (next == op) {
265 replacement_op->common.parent = op->common.parent; 272 if (replacement_op) {
266 replacement_op->common.value.arg = NULL; 273 replacement_op->common.parent =
267 replacement_op->common.node = op->common.node; 274 op->common.parent;
268 prev->common.next = replacement_op; 275 replacement_op->common.value.
269 replacement_op->common.next = op->common.next; 276 arg = NULL;
270 next = NULL; 277 replacement_op->common.node =
271 } 278 op->common.node;
272 else { 279 prev->common.next =
273 prev->common.next = op->common.next; 280 replacement_op;
274 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 }
275 } 289 }
290 prev = next;
276 } 291 }
277 prev = next;
278 }
279 } 292 }
280 293
281 294 cleanup:
282cleanup:
283 295
284 /* Now we can actually delete the subtree rooted at Op */ 296 /* Now we can actually delete the subtree rooted at Op */
285 297
286 acpi_ps_delete_parse_tree (op); 298 acpi_ps_delete_parse_tree(op);
287 return_ACPI_STATUS (AE_OK); 299 return_ACPI_STATUS(AE_OK);
288 300
289 301 allocate_error:
290allocate_error:
291 302
292 /* Always delete the subtree, even on error */ 303 /* Always delete the subtree, even on error */
293 304
294 acpi_ps_delete_parse_tree (op); 305 acpi_ps_delete_parse_tree(op);
295 return_ACPI_STATUS (AE_NO_MEMORY); 306 return_ACPI_STATUS(AE_NO_MEMORY);
296} 307}
297 308
298
299/******************************************************************************* 309/*******************************************************************************
300 * 310 *
301 * FUNCTION: acpi_ps_next_parse_state 311 * FUNCTION: acpi_ps_next_parse_state
@@ -312,17 +322,14 @@ allocate_error:
312 ******************************************************************************/ 322 ******************************************************************************/
313 323
314acpi_status 324acpi_status
315acpi_ps_next_parse_state ( 325acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
316 struct acpi_walk_state *walk_state, 326 union acpi_parse_object *op,
317 union acpi_parse_object *op, 327 acpi_status callback_status)
318 acpi_status callback_status)
319{ 328{
320 struct acpi_parse_state *parser_state = &walk_state->parser_state; 329 struct acpi_parse_state *parser_state = &walk_state->parser_state;
321 acpi_status status = AE_CTRL_PENDING; 330 acpi_status status = AE_CTRL_PENDING;
322
323
324 ACPI_FUNCTION_TRACE_PTR ("ps_next_parse_state", op);
325 331
332 ACPI_FUNCTION_TRACE_PTR("ps_next_parse_state", op);
326 333
327 switch (callback_status) { 334 switch (callback_status) {
328 case AE_CTRL_TERMINATE: 335 case AE_CTRL_TERMINATE:
@@ -335,7 +342,6 @@ acpi_ps_next_parse_state (
335 status = AE_CTRL_TERMINATE; 342 status = AE_CTRL_TERMINATE;
336 break; 343 break;
337 344
338
339 case AE_CTRL_BREAK: 345 case AE_CTRL_BREAK:
340 346
341 parser_state->aml = walk_state->aml_last_while; 347 parser_state->aml = walk_state->aml_last_while;
@@ -345,7 +351,6 @@ acpi_ps_next_parse_state (
345 351
346 case AE_CTRL_CONTINUE: 352 case AE_CTRL_CONTINUE:
347 353
348
349 parser_state->aml = walk_state->aml_last_while; 354 parser_state->aml = walk_state->aml_last_while;
350 status = AE_CTRL_CONTINUE; 355 status = AE_CTRL_CONTINUE;
351 break; 356 break;
@@ -369,10 +374,9 @@ acpi_ps_next_parse_state (
369 * 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.
370 * Just close out this package 375 * Just close out this package
371 */ 376 */
372 parser_state->aml = acpi_ps_get_next_package_end (parser_state); 377 parser_state->aml = acpi_ps_get_next_package_end(parser_state);
373 break; 378 break;
374 379
375
376 case AE_CTRL_FALSE: 380 case AE_CTRL_FALSE:
377 381
378 /* 382 /*
@@ -390,7 +394,6 @@ acpi_ps_next_parse_state (
390 status = AE_CTRL_END; 394 status = AE_CTRL_END;
391 break; 395 break;
392 396
393
394 case AE_CTRL_TRANSFER: 397 case AE_CTRL_TRANSFER:
395 398
396 /* A method call (invocation) -- transfer control */ 399 /* A method call (invocation) -- transfer control */
@@ -398,14 +401,15 @@ acpi_ps_next_parse_state (
398 status = AE_CTRL_TRANSFER; 401 status = AE_CTRL_TRANSFER;
399 walk_state->prev_op = op; 402 walk_state->prev_op = op;
400 walk_state->method_call_op = op; 403 walk_state->method_call_op = op;
401 walk_state->method_call_node = (op->common.value.arg)->common.node; 404 walk_state->method_call_node =
405 (op->common.value.arg)->common.node;
402 406
403 /* Will return value (if any) be used by the caller? */ 407 /* Will return value (if any) be used by the caller? */
404 408
405 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);
406 break; 411 break;
407 412
408
409 default: 413 default:
410 414
411 status = callback_status; 415 status = callback_status;
@@ -415,10 +419,9 @@ acpi_ps_next_parse_state (
415 break; 419 break;
416 } 420 }
417 421
418 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
419} 423}
420 424
421
422/******************************************************************************* 425/*******************************************************************************
423 * 426 *
424 * FUNCTION: acpi_ps_parse_aml 427 * FUNCTION: acpi_ps_parse_aml
@@ -432,34 +435,30 @@ acpi_ps_next_parse_state (
432 * 435 *
433 ******************************************************************************/ 436 ******************************************************************************/
434 437
435acpi_status 438acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
436acpi_ps_parse_aml (
437 struct acpi_walk_state *walk_state)
438{ 439{
439 acpi_status status; 440 acpi_status status;
440 acpi_status terminate_status; 441 acpi_status terminate_status;
441 struct acpi_thread_state *thread; 442 struct acpi_thread_state *thread;
442 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; 443 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list;
443 struct acpi_walk_state *previous_walk_state; 444 struct acpi_walk_state *previous_walk_state;
444
445
446 ACPI_FUNCTION_TRACE ("ps_parse_aml");
447 445
448 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 446 ACPI_FUNCTION_TRACE("ps_parse_aml");
449 "Entered with walk_state=%p Aml=%p size=%X\n",
450 walk_state, walk_state->parser_state.aml,
451 walk_state->parser_state.aml_size));
452 447
448 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
449 "Entered with walk_state=%p Aml=%p size=%X\n",
450 walk_state, walk_state->parser_state.aml,
451 walk_state->parser_state.aml_size));
453 452
454 /* Create and initialize a new thread state */ 453 /* Create and initialize a new thread state */
455 454
456 thread = acpi_ut_create_thread_state (); 455 thread = acpi_ut_create_thread_state();
457 if (!thread) { 456 if (!thread) {
458 return_ACPI_STATUS (AE_NO_MEMORY); 457 return_ACPI_STATUS(AE_NO_MEMORY);
459 } 458 }
460 459
461 walk_state->thread = thread; 460 walk_state->thread = thread;
462 acpi_ds_push_walk_state (walk_state, thread); 461 acpi_ds_push_walk_state(walk_state, thread);
463 462
464 /* 463 /*
465 * This global allows the AML debugger to get a handle to the currently 464 * This global allows the AML debugger to get a handle to the currently
@@ -471,54 +470,56 @@ acpi_ps_parse_aml (
471 * Execute the walk loop as long as there is a valid Walk State. This 470 * Execute the walk loop as long as there is a valid Walk State. This
472 * handles nested control method invocations without recursion. 471 * handles nested control method invocations without recursion.
473 */ 472 */
474 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", walk_state)); 473 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state));
475 474
476 status = AE_OK; 475 status = AE_OK;
477 while (walk_state) { 476 while (walk_state) {
478 if (ACPI_SUCCESS (status)) { 477 if (ACPI_SUCCESS(status)) {
479 /* 478 /*
480 * The parse_loop executes AML until the method terminates 479 * The parse_loop executes AML until the method terminates
481 * or calls another method. 480 * or calls another method.
482 */ 481 */
483 status = acpi_ps_parse_loop (walk_state); 482 status = acpi_ps_parse_loop(walk_state);
484 } 483 }
485 484
486 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 485 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
487 "Completed one call to walk loop, %s State=%p\n", 486 "Completed one call to walk loop, %s State=%p\n",
488 acpi_format_exception (status), walk_state)); 487 acpi_format_exception(status), walk_state));
489 488
490 if (status == AE_CTRL_TRANSFER) { 489 if (status == AE_CTRL_TRANSFER) {
491 /* 490 /*
492 * A method call was detected. 491 * A method call was detected.
493 * Transfer control to the called control method 492 * Transfer control to the called control method
494 */ 493 */
495 status = acpi_ds_call_control_method (thread, walk_state, NULL); 494 status =
495 acpi_ds_call_control_method(thread, walk_state,
496 NULL);
496 497
497 /* 498 /*
498 * If the transfer to the new method method call worked, a new walk 499 * If the transfer to the new method method call worked, a new walk
499 * state was created -- get it 500 * state was created -- get it
500 */ 501 */
501 walk_state = acpi_ds_get_current_walk_state (thread); 502 walk_state = acpi_ds_get_current_walk_state(thread);
502 continue; 503 continue;
503 } 504 } else if (status == AE_CTRL_TERMINATE) {
504 else if (status == AE_CTRL_TERMINATE) {
505 status = AE_OK; 505 status = AE_OK;
506 } 506 } else if ((status != AE_OK) && (walk_state->method_desc)) {
507 else if ((status != AE_OK) && (walk_state->method_desc)) { 507 ACPI_REPORT_METHOD_ERROR("Method execution failed",
508 ACPI_REPORT_METHOD_ERROR ("Method execution failed", 508 walk_state->method_node, NULL,
509 walk_state->method_node, NULL, status); 509 status);
510 510
511 /* Check for possible multi-thread reentrancy problem */ 511 /* Check for possible multi-thread reentrancy problem */
512 512
513 if ((status == AE_ALREADY_EXISTS) && 513 if ((status == AE_ALREADY_EXISTS) &&
514 (!walk_state->method_desc->method.semaphore)) { 514 (!walk_state->method_desc->method.semaphore)) {
515 /* 515 /*
516 * This method is marked not_serialized, but it tried to create 516 * This method is marked not_serialized, but it tried to create
517 * a named object, causing the second thread entrance to fail. 517 * a named object, causing the second thread entrance to fail.
518 * We will workaround this by marking the method permanently 518 * We will workaround this by marking the method permanently
519 * as Serialized. 519 * as Serialized.
520 */ 520 */
521 walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED; 521 walk_state->method_desc->method.method_flags |=
522 AML_METHOD_SERIALIZED;
522 walk_state->method_desc->method.concurrency = 1; 523 walk_state->method_desc->method.concurrency = 1;
523 } 524 }
524 } 525 }
@@ -533,21 +534,22 @@ acpi_ps_parse_aml (
533 534
534 /* We are done with this walk, move on to the parent if any */ 535 /* We are done with this walk, move on to the parent if any */
535 536
536 walk_state = acpi_ds_pop_walk_state (thread); 537 walk_state = acpi_ds_pop_walk_state(thread);
537 538
538 /* Reset the current scope to the beginning of scope stack */ 539 /* Reset the current scope to the beginning of scope stack */
539 540
540 acpi_ds_scope_stack_clear (walk_state); 541 acpi_ds_scope_stack_clear(walk_state);
541 542
542 /* 543 /*
543 * If we just returned from the execution of a control method, 544 * If we just returned from the execution of a control method,
544 * there's lots of cleanup to do 545 * there's lots of cleanup to do
545 */ 546 */
546 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { 547 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
547 terminate_status = acpi_ds_terminate_control_method (walk_state); 548 ACPI_PARSE_EXECUTE) {
548 if (ACPI_FAILURE (terminate_status)) { 549 terminate_status =
549 ACPI_REPORT_ERROR (( 550 acpi_ds_terminate_control_method(walk_state);
550 "Could not terminate control method properly\n")); 551 if (ACPI_FAILURE(terminate_status)) {
552 ACPI_REPORT_ERROR(("Could not terminate control method properly\n"));
551 553
552 /* Ignore error and continue */ 554 /* Ignore error and continue */
553 } 555 }
@@ -555,46 +557,53 @@ acpi_ps_parse_aml (
555 557
556 /* Delete this walk state and all linked control states */ 558 /* Delete this walk state and all linked control states */
557 559
558 acpi_ps_cleanup_scope (&walk_state->parser_state); 560 acpi_ps_cleanup_scope(&walk_state->parser_state);
559 561
560 previous_walk_state = walk_state; 562 previous_walk_state = walk_state;
561 563
562 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 564 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
563 "return_value=%p, implicit_value=%p State=%p\n", 565 "return_value=%p, implicit_value=%p State=%p\n",
564 walk_state->return_desc, walk_state->implicit_return_obj, walk_state)); 566 walk_state->return_desc,
567 walk_state->implicit_return_obj, walk_state));
565 568
566 /* Check if we have restarted a preempted walk */ 569 /* Check if we have restarted a preempted walk */
567 570
568 walk_state = acpi_ds_get_current_walk_state (thread); 571 walk_state = acpi_ds_get_current_walk_state(thread);
569 if (walk_state) { 572 if (walk_state) {
570 if (ACPI_SUCCESS (status)) { 573 if (ACPI_SUCCESS(status)) {
571 /* 574 /*
572 * There is another walk state, restart it. 575 * There is another walk state, restart it.
573 * If the method return value is not used by the parent, 576 * If the method return value is not used by the parent,
574 * The object is deleted 577 * The object is deleted
575 */ 578 */
576 if (!previous_walk_state->return_desc) { 579 if (!previous_walk_state->return_desc) {
577 status = acpi_ds_restart_control_method (walk_state, 580 status =
578 previous_walk_state->implicit_return_obj); 581 acpi_ds_restart_control_method
579 } 582 (walk_state,
580 else { 583 previous_walk_state->
584 implicit_return_obj);
585 } else {
581 /* 586 /*
582 * We have a valid return value, delete any implicit 587 * We have a valid return value, delete any implicit
583 * return value. 588 * return value.
584 */ 589 */
585 acpi_ds_clear_implicit_return (previous_walk_state); 590 acpi_ds_clear_implicit_return
591 (previous_walk_state);
586 592
587 status = acpi_ds_restart_control_method (walk_state, 593 status =
588 previous_walk_state->return_desc); 594 acpi_ds_restart_control_method
595 (walk_state,
596 previous_walk_state->return_desc);
589 } 597 }
590 if (ACPI_SUCCESS (status)) { 598 if (ACPI_SUCCESS(status)) {
591 walk_state->walk_type |= ACPI_WALK_METHOD_RESTART; 599 walk_state->walk_type |=
600 ACPI_WALK_METHOD_RESTART;
592 } 601 }
593 } 602 } else {
594 else {
595 /* On error, delete any return object */ 603 /* On error, delete any return object */
596 604
597 acpi_ut_remove_reference (previous_walk_state->return_desc); 605 acpi_ut_remove_reference(previous_walk_state->
606 return_desc);
598 } 607 }
599 } 608 }
600 609
@@ -605,37 +614,36 @@ acpi_ps_parse_aml (
605 else if (previous_walk_state->caller_return_desc) { 614 else if (previous_walk_state->caller_return_desc) {
606 if (previous_walk_state->implicit_return_obj) { 615 if (previous_walk_state->implicit_return_obj) {
607 *(previous_walk_state->caller_return_desc) = 616 *(previous_walk_state->caller_return_desc) =
608 previous_walk_state->implicit_return_obj; 617 previous_walk_state->implicit_return_obj;
609 } 618 } else {
610 else { 619 /* NULL if no return value */
611 /* NULL if no return value */
612 620
613 *(previous_walk_state->caller_return_desc) = 621 *(previous_walk_state->caller_return_desc) =
614 previous_walk_state->return_desc; 622 previous_walk_state->return_desc;
615 } 623 }
616 } 624 } else {
617 else {
618 if (previous_walk_state->return_desc) { 625 if (previous_walk_state->return_desc) {
619 /* Caller doesn't want it, must delete it */ 626 /* Caller doesn't want it, must delete it */
620 627
621 acpi_ut_remove_reference (previous_walk_state->return_desc); 628 acpi_ut_remove_reference(previous_walk_state->
629 return_desc);
622 } 630 }
623 if (previous_walk_state->implicit_return_obj) { 631 if (previous_walk_state->implicit_return_obj) {
624 /* Caller doesn't want it, must delete it */ 632 /* Caller doesn't want it, must delete it */
625 633
626 acpi_ut_remove_reference (previous_walk_state->implicit_return_obj); 634 acpi_ut_remove_reference(previous_walk_state->
635 implicit_return_obj);
627 } 636 }
628 } 637 }
629 638
630 acpi_ds_delete_walk_state (previous_walk_state); 639 acpi_ds_delete_walk_state(previous_walk_state);
631 } 640 }
632 641
633 /* Normal exit */ 642 /* Normal exit */
634 643
635 acpi_ex_release_all_mutexes (thread); 644 acpi_ex_release_all_mutexes(thread);
636 acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread)); 645 acpi_ut_delete_generic_state(ACPI_CAST_PTR
646 (union acpi_generic_state, thread));
637 acpi_gbl_current_walk_list = prev_walk_list; 647 acpi_gbl_current_walk_list = prev_walk_list;
638 return_ACPI_STATUS (status); 648 return_ACPI_STATUS(status);
639} 649}
640
641
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 4221b41ae1a6..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
135 ACPI_FUNCTION_ENTRY ();
136 120
121 ACPI_FUNCTION_ENTRY();
137 122
138 op_info = acpi_ps_get_opcode_info (opcode); 123 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,27 +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_os_acquire_object (acpi_gbl_ps_node_cache); 140 op = acpi_os_acquire_object(acpi_gbl_ps_node_cache);
158 memset(op, 0, sizeof(struct acpi_parse_obj_common)); 141 memset(op, 0, sizeof(struct acpi_parse_obj_common));
159 } 142 } else {
160 else {
161 /* Extended parseop */ 143 /* Extended parseop */
162 144
163 op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache); 145 op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache);
164 memset(op, 0, sizeof(struct acpi_parse_obj_named)); 146 memset(op, 0, sizeof(struct acpi_parse_obj_named));
165 } 147 }
166 148
167 /* Initialize the Op */ 149 /* Initialize the Op */
168 150
169 if (op) { 151 if (op) {
170 acpi_ps_init_op (op, opcode); 152 acpi_ps_init_op(op, opcode);
171 op->common.flags = flags; 153 op->common.flags = flags;
172 } 154 }
173 155
174 return (op); 156 return (op);
175} 157}
176 158
177
178/******************************************************************************* 159/*******************************************************************************
179 * 160 *
180 * FUNCTION: acpi_ps_free_op 161 * FUNCTION: acpi_ps_free_op
@@ -188,26 +169,22 @@ acpi_ps_alloc_op (
188 * 169 *
189 ******************************************************************************/ 170 ******************************************************************************/
190 171
191void 172void acpi_ps_free_op(union acpi_parse_object *op)
192acpi_ps_free_op (
193 union acpi_parse_object *op)
194{ 173{
195 ACPI_FUNCTION_NAME ("ps_free_op"); 174 ACPI_FUNCTION_NAME("ps_free_op");
196
197 175
198 if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 176 if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
199 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));
200 } 179 }
201 180
202 if (op->common.flags & ACPI_PARSEOP_GENERIC) { 181 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
203 (void) acpi_os_release_object (acpi_gbl_ps_node_cache, op); 182 (void)acpi_os_release_object(acpi_gbl_ps_node_cache, op);
204 } 183 } else {
205 else { 184 (void)acpi_os_release_object(acpi_gbl_ps_node_ext_cache, op);
206 (void) acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op);
207 } 185 }
208} 186}
209 187
210
211/******************************************************************************* 188/*******************************************************************************
212 * 189 *
213 * FUNCTION: Utility functions 190 * FUNCTION: Utility functions
@@ -216,36 +193,27 @@ acpi_ps_free_op (
216 * 193 *
217 ******************************************************************************/ 194 ******************************************************************************/
218 195
219
220/* 196/*
221 * Is "c" a namestring lead character? 197 * Is "c" a namestring lead character?
222 */ 198 */
223u8 199u8 acpi_ps_is_leading_char(u32 c)
224acpi_ps_is_leading_char (
225 u32 c)
226{ 200{
227 return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); 201 return ((u8) (c == '_' || (c >= 'A' && c <= 'Z')));
228} 202}
229 203
230
231/* 204/*
232 * Is "c" a namestring prefix character? 205 * Is "c" a namestring prefix character?
233 */ 206 */
234u8 207u8 acpi_ps_is_prefix_char(u32 c)
235acpi_ps_is_prefix_char (
236 u32 c)
237{ 208{
238 return ((u8) (c == '\\' || c == '^')); 209 return ((u8) (c == '\\' || c == '^'));
239} 210}
240 211
241
242/* 212/*
243 * 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
244 */ 214 */
245#ifdef ACPI_FUTURE_USAGE 215#ifdef ACPI_FUTURE_USAGE
246u32 216u32 acpi_ps_get_name(union acpi_parse_object * op)
247acpi_ps_get_name (
248 union acpi_parse_object *op)
249{ 217{
250 218
251 /* The "generic" object has no name associated with it */ 219 /* The "generic" object has no name associated with it */
@@ -258,16 +226,12 @@ acpi_ps_get_name (
258 226
259 return (op->named.name); 227 return (op->named.name);
260} 228}
261#endif /* ACPI_FUTURE_USAGE */ 229#endif /* ACPI_FUTURE_USAGE */
262
263 230
264/* 231/*
265 * Set op's name 232 * Set op's name
266 */ 233 */
267void 234void acpi_ps_set_name(union acpi_parse_object *op, u32 name)
268acpi_ps_set_name (
269 union acpi_parse_object *op,
270 u32 name)
271{ 235{
272 236
273 /* The "generic" object has no name associated with it */ 237 /* The "generic" object has no name associated with it */
@@ -278,4 +242,3 @@ acpi_ps_set_name (
278 242
279 op->named.name = name; 243 op->named.name = name;
280} 244}
281
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 d1541fabaf0a..80c67f2d3dd2 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -41,27 +41,19 @@
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 48
50
51#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
52 ACPI_MODULE_NAME ("psxface") 50ACPI_MODULE_NAME("psxface")
53 51
54/* Local Prototypes */ 52/* Local Prototypes */
55 53static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
56static acpi_status
57acpi_ps_execute_pass (
58 struct acpi_parameter_info *info);
59 54
60static void 55static void
61acpi_ps_update_parameter_list ( 56acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
62 struct acpi_parameter_info *info,
63 u16 action);
64
65 57
66/******************************************************************************* 58/*******************************************************************************
67 * 59 *
@@ -86,27 +78,24 @@ acpi_ps_update_parameter_list (
86 * 78 *
87 ******************************************************************************/ 79 ******************************************************************************/
88 80
89acpi_status 81acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
90acpi_ps_execute_method (
91 struct acpi_parameter_info *info)
92{ 82{
93 acpi_status status; 83 acpi_status status;
94
95
96 ACPI_FUNCTION_TRACE ("ps_execute_method");
97 84
85 ACPI_FUNCTION_TRACE("ps_execute_method");
98 86
99 /* Validate the Info and method Node */ 87 /* Validate the Info and method Node */
100 88
101 if (!info || !info->node) { 89 if (!info || !info->node) {
102 return_ACPI_STATUS (AE_NULL_ENTRY); 90 return_ACPI_STATUS(AE_NULL_ENTRY);
103 } 91 }
104 92
105 /* Init for new method, wait on concurrency semaphore */ 93 /* Init for new method, wait on concurrency semaphore */
106 94
107 status = acpi_ds_begin_method_execution (info->node, info->obj_desc, NULL); 95 status =
108 if (ACPI_FAILURE (status)) { 96 acpi_ds_begin_method_execution(info->node, info->obj_desc, NULL);
109 return_ACPI_STATUS (status); 97 if (ACPI_FAILURE(status)) {
98 return_ACPI_STATUS(status);
110 } 99 }
111 100
112 /* 101 /*
@@ -114,55 +103,54 @@ acpi_ps_execute_method (
114 * objects (such as Operation Regions) can be created during the 103 * objects (such as Operation Regions) can be created during the
115 * first pass parse. 104 * first pass parse.
116 */ 105 */
117 status = acpi_ut_allocate_owner_id (&info->obj_desc->method.owner_id); 106 status = acpi_ut_allocate_owner_id(&info->obj_desc->method.owner_id);
118 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
119 return_ACPI_STATUS (status); 108 return_ACPI_STATUS(status);
120 } 109 }
121 110
122 /* 111 /*
123 * The caller "owns" the parameters, so give each one an extra 112 * The caller "owns" the parameters, so give each one an extra
124 * reference 113 * reference
125 */ 114 */
126 acpi_ps_update_parameter_list (info, REF_INCREMENT); 115 acpi_ps_update_parameter_list(info, REF_INCREMENT);
127 116
128 /* 117 /*
129 * 1) Perform the first pass parse of the method to enter any 118 * 1) Perform the first pass parse of the method to enter any
130 * named objects that it creates into the namespace 119 * named objects that it creates into the namespace
131 */ 120 */
132 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 121 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
133 "**** Begin Method Parse **** Entry=%p obj=%p\n", 122 "**** Begin Method Parse **** Entry=%p obj=%p\n",
134 info->node, info->obj_desc)); 123 info->node, info->obj_desc));
135 124
136 info->pass_number = 1; 125 info->pass_number = 1;
137 status = acpi_ps_execute_pass (info); 126 status = acpi_ps_execute_pass(info);
138 if (ACPI_FAILURE (status)) { 127 if (ACPI_FAILURE(status)) {
139 goto cleanup; 128 goto cleanup;
140 } 129 }
141 130
142 /* 131 /*
143 * 2) Execute the method. Performs second pass parse simultaneously 132 * 2) Execute the method. Performs second pass parse simultaneously
144 */ 133 */
145 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 134 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
146 "**** Begin Method Execution **** Entry=%p obj=%p\n", 135 "**** Begin Method Execution **** Entry=%p obj=%p\n",
147 info->node, info->obj_desc)); 136 info->node, info->obj_desc));
148 137
149 info->pass_number = 3; 138 info->pass_number = 3;
150 status = acpi_ps_execute_pass (info); 139 status = acpi_ps_execute_pass(info);
151
152 140
153cleanup: 141 cleanup:
154 if (info->obj_desc->method.owner_id) { 142 if (info->obj_desc->method.owner_id) {
155 acpi_ut_release_owner_id (&info->obj_desc->method.owner_id); 143 acpi_ut_release_owner_id(&info->obj_desc->method.owner_id);
156 } 144 }
157 145
158 /* Take away the extra reference that we gave the parameters above */ 146 /* Take away the extra reference that we gave the parameters above */
159 147
160 acpi_ps_update_parameter_list (info, REF_DECREMENT); 148 acpi_ps_update_parameter_list(info, REF_DECREMENT);
161 149
162 /* Exit now if error above */ 150 /* Exit now if error above */
163 151
164 if (ACPI_FAILURE (status)) { 152 if (ACPI_FAILURE(status)) {
165 return_ACPI_STATUS (status); 153 return_ACPI_STATUS(status);
166 } 154 }
167 155
168 /* 156 /*
@@ -170,17 +158,17 @@ cleanup:
170 * a control exception code 158 * a control exception code
171 */ 159 */
172 if (info->return_object) { 160 if (info->return_object) {
173 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n", 161 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
174 info->return_object)); 162 "Method returned obj_desc=%p\n",
175 ACPI_DUMP_STACK_ENTRY (info->return_object); 163 info->return_object));
164 ACPI_DUMP_STACK_ENTRY(info->return_object);
176 165
177 status = AE_CTRL_RETURN_VALUE; 166 status = AE_CTRL_RETURN_VALUE;
178 } 167 }
179 168
180 return_ACPI_STATUS (status); 169 return_ACPI_STATUS(status);
181} 170}
182 171
183
184/******************************************************************************* 172/*******************************************************************************
185 * 173 *
186 * FUNCTION: acpi_ps_update_parameter_list 174 * FUNCTION: acpi_ps_update_parameter_list
@@ -196,26 +184,23 @@ cleanup:
196 ******************************************************************************/ 184 ******************************************************************************/
197 185
198static void 186static void
199acpi_ps_update_parameter_list ( 187acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action)
200 struct acpi_parameter_info *info,
201 u16 action)
202{ 188{
203 acpi_native_uint i; 189 acpi_native_uint i;
204
205 190
206 if ((info->parameter_type == ACPI_PARAM_ARGS) && 191 if ((info->parameter_type == ACPI_PARAM_ARGS) && (info->parameters)) {
207 (info->parameters)) {
208 /* Update reference count for each parameter */ 192 /* Update reference count for each parameter */
209 193
210 for (i = 0; info->parameters[i]; i++) { 194 for (i = 0; info->parameters[i]; i++) {
211 /* Ignore errors, just do them all */ 195 /* Ignore errors, just do them all */
212 196
213 (void) acpi_ut_update_object_reference (info->parameters[i], action); 197 (void)acpi_ut_update_object_reference(info->
198 parameters[i],
199 action);
214 } 200 }
215 } 201 }
216} 202}
217 203
218
219/******************************************************************************* 204/*******************************************************************************
220 * 205 *
221 * FUNCTION: acpi_ps_execute_pass 206 * FUNCTION: acpi_ps_execute_pass
@@ -229,53 +214,48 @@ acpi_ps_update_parameter_list (
229 * 214 *
230 ******************************************************************************/ 215 ******************************************************************************/
231 216
232static acpi_status 217static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info)
233acpi_ps_execute_pass (
234 struct acpi_parameter_info *info)
235{ 218{
236 acpi_status status; 219 acpi_status status;
237 union acpi_parse_object *op; 220 union acpi_parse_object *op;
238 struct acpi_walk_state *walk_state; 221 struct acpi_walk_state *walk_state;
239
240
241 ACPI_FUNCTION_TRACE ("ps_execute_pass");
242 222
223 ACPI_FUNCTION_TRACE("ps_execute_pass");
243 224
244 /* Create and init a Root Node */ 225 /* Create and init a Root Node */
245 226
246 op = acpi_ps_create_scope_op (); 227 op = acpi_ps_create_scope_op();
247 if (!op) { 228 if (!op) {
248 return_ACPI_STATUS (AE_NO_MEMORY); 229 return_ACPI_STATUS(AE_NO_MEMORY);
249 } 230 }
250 231
251 /* Create and initialize a new walk state */ 232 /* Create and initialize a new walk state */
252 233
253 walk_state = acpi_ds_create_walk_state ( 234 walk_state =
254 info->obj_desc->method.owner_id, NULL, NULL, NULL); 235 acpi_ds_create_walk_state(info->obj_desc->method.owner_id, NULL,
236 NULL, NULL);
255 if (!walk_state) { 237 if (!walk_state) {
256 status = AE_NO_MEMORY; 238 status = AE_NO_MEMORY;
257 goto cleanup; 239 goto cleanup;
258 } 240 }
259 241
260 status = acpi_ds_init_aml_walk (walk_state, op, info->node, 242 status = acpi_ds_init_aml_walk(walk_state, op, info->node,
261 info->obj_desc->method.aml_start, 243 info->obj_desc->method.aml_start,
262 info->obj_desc->method.aml_length, 244 info->obj_desc->method.aml_length,
263 info->pass_number == 1 ? NULL : info, 245 info->pass_number == 1 ? NULL : info,
264 info->pass_number); 246 info->pass_number);
265 if (ACPI_FAILURE (status)) { 247 if (ACPI_FAILURE(status)) {
266 acpi_ds_delete_walk_state (walk_state); 248 acpi_ds_delete_walk_state(walk_state);
267 goto cleanup; 249 goto cleanup;
268 } 250 }
269 251
270 /* Parse the AML */ 252 /* Parse the AML */
271 253
272 status = acpi_ps_parse_aml (walk_state); 254 status = acpi_ps_parse_aml(walk_state);
273 255
274 /* Walk state was deleted by parse_aml */ 256 /* Walk state was deleted by parse_aml */
275 257
276cleanup: 258 cleanup:
277 acpi_ps_delete_parse_tree (op); 259 acpi_ps_delete_parse_tree(op);
278 return_ACPI_STATUS (status); 260 return_ACPI_STATUS(status);
279} 261}
280
281
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 5148f3c10b5c..a4955685e4c0 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -35,22 +35,16 @@
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 47void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context)
49void
50acpi_pci_data_handler (
51 acpi_handle handle,
52 u32 function,
53 void *context)
54{ 48{
55 ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); 49 ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
56 50
@@ -59,7 +53,6 @@ acpi_pci_data_handler (
59 return_VOID; 53 return_VOID;
60} 54}
61 55
62
63/** 56/**
64 * acpi_get_pci_id 57 * acpi_get_pci_id
65 * ------------------ 58 * ------------------
@@ -67,15 +60,12 @@ acpi_pci_data_handler (
67 * to resolve PCI information for ACPI-PCI devices defined in the namespace. 60 * to resolve PCI information for ACPI-PCI devices defined in the namespace.
68 * This typically occurs when resolving PCI operation region information. 61 * This typically occurs when resolving PCI operation region information.
69 */ 62 */
70acpi_status 63acpi_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{ 64{
75 int result = 0; 65 int result = 0;
76 acpi_status status = AE_OK; 66 acpi_status status = AE_OK;
77 struct acpi_device *device = NULL; 67 struct acpi_device *device = NULL;
78 struct acpi_pci_data *data = NULL; 68 struct acpi_pci_data *data = NULL;
79 69
80 ACPI_FUNCTION_TRACE("acpi_get_pci_id"); 70 ACPI_FUNCTION_TRACE("acpi_get_pci_id");
81 71
@@ -84,52 +74,50 @@ acpi_get_pci_id (
84 74
85 result = acpi_bus_get_device(handle, &device); 75 result = acpi_bus_get_device(handle, &device);
86 if (result) { 76 if (result) {
87 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 77 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
88 "Invalid ACPI Bus context for device %s\n", 78 "Invalid ACPI Bus context for device %s\n",
89 acpi_device_bid(device))); 79 acpi_device_bid(device)));
90 return_ACPI_STATUS(AE_NOT_EXIST); 80 return_ACPI_STATUS(AE_NOT_EXIST);
91 } 81 }
92 82
93 status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); 83 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
94 if (ACPI_FAILURE(status) || !data) { 84 if (ACPI_FAILURE(status) || !data) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
96 "Invalid ACPI-PCI context for device %s\n", 86 "Invalid ACPI-PCI context for device %s\n",
97 acpi_device_bid(device))); 87 acpi_device_bid(device)));
98 return_ACPI_STATUS(status); 88 return_ACPI_STATUS(status);
99 } 89 }
100 90
101 *id = data->id; 91 *id = data->id;
102 92
103 /* 93 /*
104 id->segment = data->id.segment; 94 id->segment = data->id.segment;
105 id->bus = data->id.bus; 95 id->bus = data->id.bus;
106 id->device = data->id.device; 96 id->device = data->id.device;
107 id->function = data->id.function; 97 id->function = data->id.function;
108 */ 98 */
109 99
110 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 100 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
111 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 101 "Device %s has PCI address %02x:%02x:%02x.%02x\n",
112 acpi_device_bid(device), id->segment, id->bus, 102 acpi_device_bid(device), id->segment, id->bus,
113 id->device, id->function)); 103 id->device, id->function));
114 104
115 return_ACPI_STATUS(AE_OK); 105 return_ACPI_STATUS(AE_OK);
116} 106}
107
117EXPORT_SYMBOL(acpi_get_pci_id); 108EXPORT_SYMBOL(acpi_get_pci_id);
118 109
119 110int acpi_pci_bind(struct acpi_device *device)
120int
121acpi_pci_bind (
122 struct acpi_device *device)
123{ 111{
124 int result = 0; 112 int result = 0;
125 acpi_status status = AE_OK; 113 acpi_status status = AE_OK;
126 struct acpi_pci_data *data = NULL; 114 struct acpi_pci_data *data = NULL;
127 struct acpi_pci_data *pdata = NULL; 115 struct acpi_pci_data *pdata = NULL;
128 char *pathname = NULL; 116 char *pathname = NULL;
129 struct acpi_buffer buffer = {0, NULL}; 117 struct acpi_buffer buffer = { 0, NULL };
130 acpi_handle handle = NULL; 118 acpi_handle handle = NULL;
131 struct pci_dev *dev; 119 struct pci_dev *dev;
132 struct pci_bus *bus; 120 struct pci_bus *bus;
133 121
134 ACPI_FUNCTION_TRACE("acpi_pci_bind"); 122 ACPI_FUNCTION_TRACE("acpi_pci_bind");
135 123
@@ -137,34 +125,34 @@ acpi_pci_bind (
137 return_VALUE(-EINVAL); 125 return_VALUE(-EINVAL);
138 126
139 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 127 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
140 if(!pathname) 128 if (!pathname)
141 return_VALUE(-ENOMEM); 129 return_VALUE(-ENOMEM);
142 memset(pathname, 0, ACPI_PATHNAME_MAX); 130 memset(pathname, 0, ACPI_PATHNAME_MAX);
143 buffer.length = ACPI_PATHNAME_MAX; 131 buffer.length = ACPI_PATHNAME_MAX;
144 buffer.pointer = pathname; 132 buffer.pointer = pathname;
145 133
146 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 134 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
147 if (!data){ 135 if (!data) {
148 kfree (pathname); 136 kfree(pathname);
149 return_VALUE(-ENOMEM); 137 return_VALUE(-ENOMEM);
150 } 138 }
151 memset(data, 0, sizeof(struct acpi_pci_data)); 139 memset(data, 0, sizeof(struct acpi_pci_data));
152 140
153 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 141 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 142 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
155 pathname)); 143 pathname));
156 144
157 /* 145 /*
158 * Segment & Bus 146 * Segment & Bus
159 * ------------- 147 * -------------
160 * These are obtained via the parent device's ACPI-PCI context. 148 * These are obtained via the parent device's ACPI-PCI context.
161 */ 149 */
162 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 150 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
163 (void**) &pdata); 151 (void **)&pdata);
164 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { 152 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
166 "Invalid ACPI-PCI context for parent device %s\n", 154 "Invalid ACPI-PCI context for parent device %s\n",
167 acpi_device_bid(device->parent))); 155 acpi_device_bid(device->parent)));
168 result = -ENODEV; 156 result = -ENODEV;
169 goto end; 157 goto end;
170 } 158 }
@@ -181,8 +169,8 @@ acpi_pci_bind (
181 data->id.function = device->pnp.bus_address & 0xFFFF; 169 data->id.function = device->pnp.bus_address & 0xFFFF;
182 170
183 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 171 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n",
184 data->id.segment, data->id.bus, data->id.device, 172 data->id.segment, data->id.bus, data->id.device,
185 data->id.function)); 173 data->id.function));
186 174
187 /* 175 /*
188 * TBD: Support slot devices (e.g. function=0xFFFF). 176 * TBD: Support slot devices (e.g. function=0xFFFF).
@@ -202,25 +190,25 @@ acpi_pci_bind (
202 if (bus) { 190 if (bus) {
203 list_for_each_entry(dev, &bus->devices, bus_list) { 191 list_for_each_entry(dev, &bus->devices, bus_list) {
204 if (dev->devfn == PCI_DEVFN(data->id.device, 192 if (dev->devfn == PCI_DEVFN(data->id.device,
205 data->id.function)) { 193 data->id.function)) {
206 data->dev = dev; 194 data->dev = dev;
207 break; 195 break;
208 } 196 }
209 } 197 }
210 } 198 }
211 if (!data->dev) { 199 if (!data->dev) {
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 200 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
213 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 201 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
214 data->id.segment, data->id.bus, 202 data->id.segment, data->id.bus,
215 data->id.device, data->id.function)); 203 data->id.device, data->id.function));
216 result = -ENODEV; 204 result = -ENODEV;
217 goto end; 205 goto end;
218 } 206 }
219 if (!data->dev->bus) { 207 if (!data->dev->bus) {
220 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
221 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 209 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
222 data->id.segment, data->id.bus, 210 data->id.segment, data->id.bus,
223 data->id.device, data->id.function)); 211 data->id.device, data->id.function));
224 result = -ENODEV; 212 result = -ENODEV;
225 goto end; 213 goto end;
226 } 214 }
@@ -232,10 +220,10 @@ acpi_pci_bind (
232 * facilitate callbacks for all of its children. 220 * facilitate callbacks for all of its children.
233 */ 221 */
234 if (data->dev->subordinate) { 222 if (data->dev->subordinate) {
235 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 223 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
236 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 224 "Device %02x:%02x:%02x.%02x is a PCI bridge\n",
237 data->id.segment, data->id.bus, 225 data->id.segment, data->id.bus,
238 data->id.device, data->id.function)); 226 data->id.device, data->id.function));
239 data->bus = data->dev->subordinate; 227 data->bus = data->dev->subordinate;
240 device->ops.bind = acpi_pci_bind; 228 device->ops.bind = acpi_pci_bind;
241 device->ops.unbind = acpi_pci_unbind; 229 device->ops.unbind = acpi_pci_unbind;
@@ -249,8 +237,8 @@ acpi_pci_bind (
249 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 237 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
250 if (ACPI_FAILURE(status)) { 238 if (ACPI_FAILURE(status)) {
251 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
252 "Unable to attach ACPI-PCI context to device %s\n", 240 "Unable to attach ACPI-PCI context to device %s\n",
253 acpi_device_bid(device))); 241 acpi_device_bid(device)));
254 result = -ENODEV; 242 result = -ENODEV;
255 goto end; 243 goto end;
256 } 244 }
@@ -267,15 +255,15 @@ acpi_pci_bind (
267 */ 255 */
268 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 256 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
269 if (ACPI_SUCCESS(status)) { 257 if (ACPI_SUCCESS(status)) {
270 if (data->bus) /* PCI-PCI bridge */ 258 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, 259 acpi_pci_irq_add_prt(device->handle, data->id.segment,
275 data->id.bus); 260 data->bus->number);
261 else /* non-bridge PCI device */
262 acpi_pci_irq_add_prt(device->handle, data->id.segment,
263 data->id.bus);
276 } 264 }
277 265
278end: 266 end:
279 kfree(pathname); 267 kfree(pathname);
280 if (result) 268 if (result)
281 kfree(data); 269 kfree(data);
@@ -283,22 +271,21 @@ end:
283 return_VALUE(result); 271 return_VALUE(result);
284} 272}
285 273
286int acpi_pci_unbind( 274int acpi_pci_unbind(struct acpi_device *device)
287 struct acpi_device *device)
288{ 275{
289 int result = 0; 276 int result = 0;
290 acpi_status status = AE_OK; 277 acpi_status status = AE_OK;
291 struct acpi_pci_data *data = NULL; 278 struct acpi_pci_data *data = NULL;
292 char *pathname = NULL; 279 char *pathname = NULL;
293 struct acpi_buffer buffer = {0, NULL}; 280 struct acpi_buffer buffer = { 0, NULL };
294 281
295 ACPI_FUNCTION_TRACE("acpi_pci_unbind"); 282 ACPI_FUNCTION_TRACE("acpi_pci_unbind");
296 283
297 if (!device || !device->parent) 284 if (!device || !device->parent)
298 return_VALUE(-EINVAL); 285 return_VALUE(-EINVAL);
299 286
300 pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 287 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
301 if(!pathname) 288 if (!pathname)
302 return_VALUE(-ENOMEM); 289 return_VALUE(-ENOMEM);
303 memset(pathname, 0, ACPI_PATHNAME_MAX); 290 memset(pathname, 0, ACPI_PATHNAME_MAX);
304 291
@@ -306,14 +293,16 @@ int acpi_pci_unbind(
306 buffer.pointer = pathname; 293 buffer.pointer = pathname;
307 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 294 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
308 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
309 pathname)); 296 pathname));
310 kfree(pathname); 297 kfree(pathname);
311 298
312 status = acpi_get_data(device->handle, acpi_pci_data_handler, (void**)&data); 299 status =
300 acpi_get_data(device->handle, acpi_pci_data_handler,
301 (void **)&data);
313 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 303 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
315 "Unable to get data from device %s\n", 304 "Unable to get data from device %s\n",
316 acpi_device_bid(device))); 305 acpi_device_bid(device)));
317 result = -ENODEV; 306 result = -ENODEV;
318 goto end; 307 goto end;
319 } 308 }
@@ -321,8 +310,8 @@ int acpi_pci_unbind(
321 status = acpi_detach_data(device->handle, acpi_pci_data_handler); 310 status = acpi_detach_data(device->handle, acpi_pci_data_handler);
322 if (ACPI_FAILURE(status)) { 311 if (ACPI_FAILURE(status)) {
323 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 312 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Unable to detach data from device %s\n", 313 "Unable to detach data from device %s\n",
325 acpi_device_bid(device))); 314 acpi_device_bid(device)));
326 result = -ENODEV; 315 result = -ENODEV;
327 goto end; 316 goto end;
328 } 317 }
@@ -331,39 +320,37 @@ int acpi_pci_unbind(
331 } 320 }
332 kfree(data); 321 kfree(data);
333 322
334end: 323 end:
335 return_VALUE(result); 324 return_VALUE(result);
336} 325}
337 326
338int 327int
339acpi_pci_bind_root ( 328acpi_pci_bind_root(struct acpi_device *device,
340 struct acpi_device *device, 329 struct acpi_pci_id *id, struct pci_bus *bus)
341 struct acpi_pci_id *id,
342 struct pci_bus *bus)
343{ 330{
344 int result = 0; 331 int result = 0;
345 acpi_status status = AE_OK; 332 acpi_status status = AE_OK;
346 struct acpi_pci_data *data = NULL; 333 struct acpi_pci_data *data = NULL;
347 char *pathname = NULL; 334 char *pathname = NULL;
348 struct acpi_buffer buffer = {0, NULL}; 335 struct acpi_buffer buffer = { 0, NULL };
349 336
350 ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); 337 ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
351 338
352 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 339 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
353 if(!pathname) 340 if (!pathname)
354 return_VALUE(-ENOMEM); 341 return_VALUE(-ENOMEM);
355 memset(pathname, 0, ACPI_PATHNAME_MAX); 342 memset(pathname, 0, ACPI_PATHNAME_MAX);
356 343
357 buffer.length = ACPI_PATHNAME_MAX; 344 buffer.length = ACPI_PATHNAME_MAX;
358 buffer.pointer = pathname; 345 buffer.pointer = pathname;
359 346
360 if (!device || !id || !bus){ 347 if (!device || !id || !bus) {
361 kfree(pathname); 348 kfree(pathname);
362 return_VALUE(-EINVAL); 349 return_VALUE(-EINVAL);
363 } 350 }
364 351
365 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 352 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
366 if (!data){ 353 if (!data) {
367 kfree(pathname); 354 kfree(pathname);
368 return_VALUE(-ENOMEM); 355 return_VALUE(-ENOMEM);
369 } 356 }
@@ -377,18 +364,18 @@ acpi_pci_bind_root (
377 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 364 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
378 365
379 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 366 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
380 "%02x:%02x\n", pathname, id->segment, id->bus)); 367 "%02x:%02x\n", pathname, id->segment, id->bus));
381 368
382 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 369 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
383 if (ACPI_FAILURE(status)) { 370 if (ACPI_FAILURE(status)) {
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 371 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "Unable to attach ACPI-PCI context to device %s\n", 372 "Unable to attach ACPI-PCI context to device %s\n",
386 pathname)); 373 pathname));
387 result = -ENODEV; 374 result = -ENODEV;
388 goto end; 375 goto end;
389 } 376 }
390 377
391end: 378 end:
392 kfree(pathname); 379 kfree(pathname);
393 if (result != 0) 380 if (result != 0)
394 kfree(data); 381 kfree(data);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index c885300579ec..2bbfba8e8c6d 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,31 +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;
427 int rc; 408 int rc;
428 409
429 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); 410 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
430 411
431 if (!dev) 412 if (!dev)
432 return_VALUE(-EINVAL); 413 return_VALUE(-EINVAL);
433 414
434 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 415 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
435 if (!pin) { 416 if (!pin) {
436 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)));
437 return_VALUE(0); 420 return_VALUE(0);
438 } 421 }
439 pin--; 422 pin--;
440 423
441 if (!dev->bus) { 424 if (!dev->bus) {
442 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) 'bus' field\n")); 425 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
426 "Invalid (NULL) 'bus' field\n"));
443 return_VALUE(-ENODEV); 427 return_VALUE(-ENODEV);
444 } 428 }
445 429
@@ -447,35 +431,37 @@ acpi_pci_irq_enable (
447 * 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
448 * values override any BIOS-assigned IRQs set during boot. 432 * values override any BIOS-assigned IRQs set during boot.
449 */ 433 */
450 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,
451 &edge_level, &active_high_low, &link, acpi_pci_allocate_irq); 435 &edge_level, &active_high_low, &link,
436 acpi_pci_allocate_irq);
452 437
453 /* 438 /*
454 * 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
455 * device's parent bridge. 440 * device's parent bridge.
456 */ 441 */
457 if (irq < 0) 442 if (irq < 0)
458 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 443 irq = acpi_pci_irq_derive(dev, pin, &edge_level,
459 &active_high_low, &link, acpi_pci_allocate_irq); 444 &active_high_low, &link,
460 445 acpi_pci_allocate_irq);
446
461 /* 447 /*
462 * No IRQ known to the ACPI subsystem - maybe the BIOS / 448 * No IRQ known to the ACPI subsystem - maybe the BIOS /
463 * driver reported one, then use it. Exit in any case. 449 * driver reported one, then use it. Exit in any case.
464 */ 450 */
465 if (irq < 0) { 451 if (irq < 0) {
466 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI", 452 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI",
467 pci_name(dev), ('A' + pin)); 453 pci_name(dev), ('A' + pin));
468 /* Interrupt Line values above 0xF are forbidden */ 454 /* Interrupt Line values above 0xF are forbidden */
469 if (dev->irq > 0 && (dev->irq <= 0xF)) { 455 if (dev->irq > 0 && (dev->irq <= 0xF)) {
470 printk(" - using IRQ %d\n", dev->irq); 456 printk(" - using IRQ %d\n", dev->irq);
471 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); 457 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
458 ACPI_ACTIVE_LOW);
472 return_VALUE(0); 459 return_VALUE(0);
473 } 460 } else {
474 else {
475 printk("\n"); 461 printk("\n");
476 return_VALUE(0); 462 return_VALUE(0);
477 } 463 }
478 } 464 }
479 465
480 rc = acpi_register_gsi(irq, edge_level, active_high_low); 466 rc = acpi_register_gsi(irq, edge_level, active_high_low);
481 if (rc < 0) { 467 if (rc < 0) {
@@ -486,32 +472,31 @@ acpi_pci_irq_enable (
486 dev->irq = rc; 472 dev->irq = rc;
487 473
488 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", 474 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ",
489 pci_name(dev), 'A' + pin); 475 pci_name(dev), 'A' + pin);
490 476
491 if (link) 477 if (link)
492 printk("Link [%s] -> ", link); 478 printk("Link [%s] -> ", link);
493 479
494 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 480 printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
495 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 481 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
496 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", 482 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
497 dev->irq);
498 483
499 return_VALUE(0); 484 return_VALUE(0);
500} 485}
501EXPORT_SYMBOL(acpi_pci_irq_enable);
502 486
487EXPORT_SYMBOL(acpi_pci_irq_enable);
503 488
504/* FIXME: implement x86/x86_64 version */ 489/* FIXME: implement x86/x86_64 version */
505void __attribute__((weak)) acpi_unregister_gsi(u32 i) {} 490void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
491{
492}
506 493
507void 494void acpi_pci_irq_disable(struct pci_dev *dev)
508acpi_pci_irq_disable (
509 struct pci_dev *dev)
510{ 495{
511 int gsi = 0; 496 int gsi = 0;
512 u8 pin = 0; 497 u8 pin = 0;
513 int edge_level = ACPI_LEVEL_SENSITIVE; 498 int edge_level = ACPI_LEVEL_SENSITIVE;
514 int active_high_low = ACPI_ACTIVE_LOW; 499 int active_high_low = ACPI_ACTIVE_LOW;
515 500
516 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 501 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
517 502
@@ -529,15 +514,17 @@ acpi_pci_irq_disable (
529 /* 514 /*
530 * First we check the PCI IRQ routing table (PRT) for an IRQ. 515 * First we check the PCI IRQ routing table (PRT) for an IRQ.
531 */ 516 */
532 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 517 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
533 &edge_level, &active_high_low, NULL, acpi_pci_free_irq); 518 &edge_level, &active_high_low, NULL,
519 acpi_pci_free_irq);
534 /* 520 /*
535 * If no PRT entry was found, we'll try to derive an IRQ from the 521 * If no PRT entry was found, we'll try to derive an IRQ from the
536 * device's parent bridge. 522 * device's parent bridge.
537 */ 523 */
538 if (gsi < 0) 524 if (gsi < 0)
539 gsi = acpi_pci_irq_derive(dev, pin, 525 gsi = acpi_pci_irq_derive(dev, pin,
540 &edge_level, &active_high_low, NULL, acpi_pci_free_irq); 526 &edge_level, &active_high_low, NULL,
527 acpi_pci_free_irq);
541 if (gsi < 0) 528 if (gsi < 0)
542 return_VOID; 529 return_VOID;
543 530
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index e8334ce84d84..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,10 +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(struct acpi_pci_link *link) 535static int acpi_pci_link_allocate(struct acpi_pci_link *link)
533{ 536{
534 int irq; 537 int irq;
535 int i; 538 int i;
536 539
537 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); 540 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
538 541
@@ -556,7 +559,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
556 if (i == link->irq.possible_count) { 559 if (i == link->irq.possible_count) {
557 if (acpi_strict) 560 if (acpi_strict)
558 printk(KERN_WARNING PREFIX "_CRS %d not found" 561 printk(KERN_WARNING PREFIX "_CRS %d not found"
559 " in _PRS\n", link->irq.active); 562 " in _PRS\n", link->irq.active);
560 link->irq.active = 0; 563 link->irq.active = 0;
561 } 564 }
562 565
@@ -575,23 +578,25 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
575 * the use of IRQs 9, 10, 11, and >15. 578 * the use of IRQs 9, 10, 11, and >15.
576 */ 579 */
577 for (i = (link->irq.possible_count - 1); i >= 0; i--) { 580 for (i = (link->irq.possible_count - 1); i >= 0; i--) {
578 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]])
579 irq = link->irq.possible[i]; 583 irq = link->irq.possible[i];
580 } 584 }
581 } 585 }
582 586
583 /* Attempt to enable the link device at this IRQ. */ 587 /* Attempt to enable the link device at this IRQ. */
584 if (acpi_pci_link_set(link, irq)) { 588 if (acpi_pci_link_set(link, irq)) {
585 printk(PREFIX "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" 589 printk(PREFIX
586 "Try pci=noacpi or acpi=off\n", 590 "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
587 acpi_device_name(link->device), 591 "Try pci=noacpi or acpi=off\n",
588 acpi_device_bid(link->device)); 592 acpi_device_name(link->device),
593 acpi_device_bid(link->device));
589 return_VALUE(-ENODEV); 594 return_VALUE(-ENODEV);
590 } else { 595 } else {
591 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 596 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
592 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 597 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
593 acpi_device_name(link->device), 598 acpi_device_name(link->device),
594 acpi_device_bid(link->device), link->irq.active); 599 acpi_device_bid(link->device), link->irq.active);
595 } 600 }
596 601
597 link->irq.initialized = 1; 602 link->irq.initialized = 1;
@@ -606,16 +611,13 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
606 */ 611 */
607 612
608int 613int
609acpi_pci_link_allocate_irq ( 614acpi_pci_link_allocate_irq(acpi_handle handle,
610 acpi_handle handle, 615 int index,
611 int index, 616 int *edge_level, int *active_high_low, char **name)
612 int *edge_level,
613 int *active_high_low,
614 char **name)
615{ 617{
616 int result = 0; 618 int result = 0;
617 struct acpi_device *device = NULL; 619 struct acpi_device *device = NULL;
618 struct acpi_pci_link *link = NULL; 620 struct acpi_pci_link *link = NULL;
619 621
620 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); 622 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
621 623
@@ -625,7 +627,7 @@ acpi_pci_link_allocate_irq (
625 return_VALUE(-1); 627 return_VALUE(-1);
626 } 628 }
627 629
628 link = (struct acpi_pci_link *) acpi_driver_data(device); 630 link = (struct acpi_pci_link *)acpi_driver_data(device);
629 if (!link) { 631 if (!link) {
630 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
631 return_VALUE(-1); 633 return_VALUE(-1);
@@ -642,20 +644,24 @@ acpi_pci_link_allocate_irq (
642 up(&acpi_link_lock); 644 up(&acpi_link_lock);
643 return_VALUE(-1); 645 return_VALUE(-1);
644 } 646 }
645 647
646 if (!link->irq.active) { 648 if (!link->irq.active) {
647 up(&acpi_link_lock); 649 up(&acpi_link_lock);
648 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"));
649 return_VALUE(-1); 651 return_VALUE(-1);
650 } 652 }
651 link->refcnt ++; 653 link->refcnt++;
652 up(&acpi_link_lock); 654 up(&acpi_link_lock);
653 655
654 if (edge_level) *edge_level = link->irq.edge_level; 656 if (edge_level)
655 if (active_high_low) *active_high_low = link->irq.active_high_low; 657 *edge_level = link->irq.edge_level;
656 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);
657 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 662 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
658 "Link %s is referenced\n", acpi_device_bid(link->device))); 663 "Link %s is referenced\n",
664 acpi_device_bid(link->device)));
659 return_VALUE(link->irq.active); 665 return_VALUE(link->irq.active);
660} 666}
661 667
@@ -663,12 +669,11 @@ acpi_pci_link_allocate_irq (
663 * 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
664 * continue use the info 670 * continue use the info
665 */ 671 */
666int 672int acpi_pci_link_free_irq(acpi_handle handle)
667acpi_pci_link_free_irq(acpi_handle handle)
668{ 673{
669 struct acpi_device *device = NULL; 674 struct acpi_device *device = NULL;
670 struct acpi_pci_link *link = NULL; 675 struct acpi_pci_link *link = NULL;
671 acpi_status result; 676 acpi_status result;
672 677
673 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); 678 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
674 679
@@ -678,7 +683,7 @@ acpi_pci_link_free_irq(acpi_handle handle)
678 return_VALUE(-1); 683 return_VALUE(-1);
679 } 684 }
680 685
681 link = (struct acpi_pci_link *) acpi_driver_data(device); 686 link = (struct acpi_pci_link *)acpi_driver_data(device);
682 if (!link) { 687 if (!link) {
683 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 688 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
684 return_VALUE(-1); 689 return_VALUE(-1);
@@ -690,7 +695,6 @@ acpi_pci_link_free_irq(acpi_handle handle)
690 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); 695 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
691 return_VALUE(-1); 696 return_VALUE(-1);
692 } 697 }
693
694#ifdef FUTURE_USE 698#ifdef FUTURE_USE
695 /* 699 /*
696 * The Link reference count allows us to _DISable an unused link 700 * The Link reference count allows us to _DISable an unused link
@@ -701,10 +705,11 @@ acpi_pci_link_free_irq(acpi_handle handle)
701 * to prevent duplicate acpi_pci_link_set() 705 * to prevent duplicate acpi_pci_link_set()
702 * which would harm some systems 706 * which would harm some systems
703 */ 707 */
704 link->refcnt --; 708 link->refcnt--;
705#endif 709#endif
706 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 710 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
707 "Link %s is dereferenced\n", acpi_device_bid(link->device))); 711 "Link %s is dereferenced\n",
712 acpi_device_bid(link->device)));
708 713
709 if (link->refcnt == 0) { 714 if (link->refcnt == 0) {
710 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 715 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
@@ -712,17 +717,17 @@ acpi_pci_link_free_irq(acpi_handle handle)
712 up(&acpi_link_lock); 717 up(&acpi_link_lock);
713 return_VALUE(link->irq.active); 718 return_VALUE(link->irq.active);
714} 719}
720
715/* -------------------------------------------------------------------------- 721/* --------------------------------------------------------------------------
716 Driver Interface 722 Driver Interface
717 -------------------------------------------------------------------------- */ 723 -------------------------------------------------------------------------- */
718 724
719static int 725static int acpi_pci_link_add(struct acpi_device *device)
720acpi_pci_link_add(struct acpi_device *device)
721{ 726{
722 int result = 0; 727 int result = 0;
723 struct acpi_pci_link *link = NULL; 728 struct acpi_pci_link *link = NULL;
724 int i = 0; 729 int i = 0;
725 int found = 0; 730 int found = 0;
726 731
727 ACPI_FUNCTION_TRACE("acpi_pci_link_add"); 732 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
728 733
@@ -749,13 +754,12 @@ acpi_pci_link_add(struct acpi_device *device)
749 acpi_pci_link_get_current(link); 754 acpi_pci_link_get_current(link);
750 755
751 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), 756 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
752 acpi_device_bid(device)); 757 acpi_device_bid(device));
753 for (i = 0; i < link->irq.possible_count; i++) { 758 for (i = 0; i < link->irq.possible_count; i++) {
754 if (link->irq.active == link->irq.possible[i]) { 759 if (link->irq.active == link->irq.possible[i]) {
755 printk(" *%d", link->irq.possible[i]); 760 printk(" *%d", link->irq.possible[i]);
756 found = 1; 761 found = 1;
757 } 762 } else
758 else
759 printk(" %d", link->irq.possible[i]); 763 printk(" %d", link->irq.possible[i]);
760 } 764 }
761 765
@@ -764,7 +768,7 @@ acpi_pci_link_add(struct acpi_device *device)
764 if (!found) 768 if (!found)
765 printk(" *%d", link->irq.active); 769 printk(" *%d", link->irq.active);
766 770
767 if(!link->device->status.enabled) 771 if (!link->device->status.enabled)
768 printk(", disabled."); 772 printk(", disabled.");
769 773
770 printk("\n"); 774 printk("\n");
@@ -773,7 +777,7 @@ acpi_pci_link_add(struct acpi_device *device)
773 list_add_tail(&link->node, &acpi_link.entries); 777 list_add_tail(&link->node, &acpi_link.entries);
774 acpi_link.count++; 778 acpi_link.count++;
775 779
776end: 780 end:
777 /* disable all links -- to be activated on use */ 781 /* disable all links -- to be activated on use */
778 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 782 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
779 up(&acpi_link_lock); 783 up(&acpi_link_lock);
@@ -784,9 +788,7 @@ end:
784 return_VALUE(result); 788 return_VALUE(result);
785} 789}
786 790
787static int 791static int acpi_pci_link_resume(struct acpi_pci_link *link)
788acpi_pci_link_resume(
789 struct acpi_pci_link *link)
790{ 792{
791 ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); 793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
792 794
@@ -801,11 +803,10 @@ acpi_pci_link_resume(
801 * after every device calls pci_disable_device in .resume. 803 * after every device calls pci_disable_device in .resume.
802 */ 804 */
803int acpi_in_resume; 805int acpi_in_resume;
804static int 806static int irqrouter_resume(struct sys_device *dev)
805irqrouter_resume(struct sys_device *dev)
806{ 807{
807 struct list_head *node = NULL; 808 struct list_head *node = NULL;
808 struct acpi_pci_link *link = NULL; 809 struct acpi_pci_link *link = NULL;
809 810
810 ACPI_FUNCTION_TRACE("irqrouter_resume"); 811 ACPI_FUNCTION_TRACE("irqrouter_resume");
811 812
@@ -814,7 +815,7 @@ irqrouter_resume(struct sys_device *dev)
814 link = list_entry(node, struct acpi_pci_link, node); 815 link = list_entry(node, struct acpi_pci_link, node);
815 if (!link) { 816 if (!link) {
816 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 817 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
817 "Invalid link context\n")); 818 "Invalid link context\n"));
818 continue; 819 continue;
819 } 820 }
820 acpi_pci_link_resume(link); 821 acpi_pci_link_resume(link);
@@ -823,9 +824,7 @@ irqrouter_resume(struct sys_device *dev)
823 return_VALUE(0); 824 return_VALUE(0);
824} 825}
825 826
826 827static int acpi_pci_link_remove(struct acpi_device *device, int type)
827static int
828acpi_pci_link_remove(struct acpi_device *device, int type)
829{ 828{
830 struct acpi_pci_link *link = NULL; 829 struct acpi_pci_link *link = NULL;
831 830
@@ -834,7 +833,7 @@ acpi_pci_link_remove(struct acpi_device *device, int type)
834 if (!device || !acpi_driver_data(device)) 833 if (!device || !acpi_driver_data(device))
835 return_VALUE(-EINVAL); 834 return_VALUE(-EINVAL);
836 835
837 link = (struct acpi_pci_link *) acpi_driver_data(device); 836 link = (struct acpi_pci_link *)acpi_driver_data(device);
838 837
839 down(&acpi_link_lock); 838 down(&acpi_link_lock);
840 list_del(&link->node); 839 list_del(&link->node);
@@ -856,14 +855,14 @@ static int __init acpi_irq_penalty_update(char *str, int used)
856 int retval; 855 int retval;
857 int irq; 856 int irq;
858 857
859 retval = get_option(&str,&irq); 858 retval = get_option(&str, &irq);
860 859
861 if (!retval) 860 if (!retval)
862 break; /* no number found */ 861 break; /* no number found */
863 862
864 if (irq < 0) 863 if (irq < 0)
865 continue; 864 continue;
866 865
867 if (irq >= ACPI_MAX_IRQS) 866 if (irq >= ACPI_MAX_IRQS)
868 continue; 867 continue;
869 868
@@ -902,6 +901,7 @@ static int __init acpi_irq_isa(char *str)
902{ 901{
903 return acpi_irq_penalty_update(str, 1); 902 return acpi_irq_penalty_update(str, 1);
904} 903}
904
905__setup("acpi_irq_isa=", acpi_irq_isa); 905__setup("acpi_irq_isa=", acpi_irq_isa);
906 906
907/* 907/*
@@ -913,6 +913,7 @@ static int __init acpi_irq_pci(char *str)
913{ 913{
914 return acpi_irq_penalty_update(str, 0); 914 return acpi_irq_penalty_update(str, 0);
915} 915}
916
916__setup("acpi_irq_pci=", acpi_irq_pci); 917__setup("acpi_irq_pci=", acpi_irq_pci);
917 918
918static int __init acpi_irq_nobalance_set(char *str) 919static int __init acpi_irq_nobalance_set(char *str)
@@ -920,6 +921,7 @@ static int __init acpi_irq_nobalance_set(char *str)
920 acpi_irq_balance = 0; 921 acpi_irq_balance = 0;
921 return 1; 922 return 1;
922} 923}
924
923__setup("acpi_irq_nobalance", acpi_irq_nobalance_set); 925__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
924 926
925int __init acpi_irq_balance_set(char *str) 927int __init acpi_irq_balance_set(char *str)
@@ -927,22 +929,20 @@ int __init acpi_irq_balance_set(char *str)
927 acpi_irq_balance = 1; 929 acpi_irq_balance = 1;
928 return 1; 930 return 1;
929} 931}
930__setup("acpi_irq_balance", acpi_irq_balance_set);
931 932
933__setup("acpi_irq_balance", acpi_irq_balance_set);
932 934
933/* 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 */
934static struct sysdev_class irqrouter_sysdev_class = { 936static struct sysdev_class irqrouter_sysdev_class = {
935 set_kset_name("irqrouter"), 937 set_kset_name("irqrouter"),
936 .resume = irqrouter_resume, 938 .resume = irqrouter_resume,
937}; 939};
938 940
939
940static struct sys_device device_irqrouter = { 941static struct sys_device device_irqrouter = {
941 .id = 0, 942 .id = 0,
942 .cls = &irqrouter_sysdev_class, 943 .cls = &irqrouter_sysdev_class,
943}; 944};
944 945
945
946static int __init irqrouter_init_sysfs(void) 946static int __init irqrouter_init_sysfs(void)
947{ 947{
948 int error; 948 int error;
@@ -957,12 +957,11 @@ static int __init irqrouter_init_sysfs(void)
957 error = sysdev_register(&device_irqrouter); 957 error = sysdev_register(&device_irqrouter);
958 958
959 return_VALUE(error); 959 return_VALUE(error);
960} 960}
961 961
962device_initcall(irqrouter_init_sysfs); 962device_initcall(irqrouter_init_sysfs);
963 963
964 964static int __init acpi_pci_link_init(void)
965static int __init acpi_pci_link_init (void)
966{ 965{
967 ACPI_FUNCTION_TRACE("acpi_pci_link_init"); 966 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
968 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..819cb0b453fc 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 224int 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 }
@@ -446,15 +434,13 @@ static u8 convert_acpiid_to_cpu(u8 acpi_id)
446 Driver Interface 434 Driver Interface
447 -------------------------------------------------------------------------- */ 435 -------------------------------------------------------------------------- */
448 436
449static int 437static int acpi_processor_get_info(struct acpi_processor *pr)
450acpi_processor_get_info (
451 struct acpi_processor *pr)
452{ 438{
453 acpi_status status = 0; 439 acpi_status status = 0;
454 union acpi_object object = {0}; 440 union acpi_object object = { 0 };
455 struct acpi_buffer buffer = {sizeof(union acpi_object), &object}; 441 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
456 u8 cpu_index; 442 u8 cpu_index;
457 static int cpu0_initialized; 443 static int cpu0_initialized;
458 444
459 ACPI_FUNCTION_TRACE("acpi_processor_get_info"); 445 ACPI_FUNCTION_TRACE("acpi_processor_get_info");
460 446
@@ -473,11 +459,10 @@ acpi_processor_get_info (
473 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) { 459 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) {
474 pr->flags.bm_control = 1; 460 pr->flags.bm_control = 1;
475 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 461 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
476 "Bus mastering arbitration control present\n")); 462 "Bus mastering arbitration control present\n"));
477 } 463 } else
478 else
479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 464 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
480 "No bus mastering arbitration control\n")); 465 "No bus mastering arbitration control\n"));
481 466
482 /* 467 /*
483 * Evalute the processor object. Note that it is common on SMP to 468 * Evalute the processor object. Note that it is common on SMP to
@@ -487,50 +472,51 @@ acpi_processor_get_info (
487 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 472 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
488 if (ACPI_FAILURE(status)) { 473 if (ACPI_FAILURE(status)) {
489 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 474 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
490 "Error evaluating processor object\n")); 475 "Error evaluating processor object\n"));
491 return_VALUE(-ENODEV); 476 return_VALUE(-ENODEV);
492 } 477 }
493 478
494 /* 479 /*
495 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. 480 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
496 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c 481 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c
497 */ 482 */
498 pr->acpi_id = object.processor.proc_id; 483 pr->acpi_id = object.processor.proc_id;
499 484
500 cpu_index = convert_acpiid_to_cpu(pr->acpi_id); 485 cpu_index = convert_acpiid_to_cpu(pr->acpi_id);
501 486
502 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 487 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
503 if ( !cpu0_initialized && (cpu_index == 0xff) && 488 if (!cpu0_initialized && (cpu_index == 0xff) &&
504 (num_online_cpus() == 1)) { 489 (num_online_cpus() == 1)) {
505 cpu_index = 0; 490 cpu_index = 0;
506 } 491 }
507 492
508 cpu0_initialized = 1; 493 cpu0_initialized = 1;
509 494
510 pr->id = cpu_index; 495 pr->id = cpu_index;
511 496
512 /* 497 /*
513 * Extra Processor objects may be enumerated on MP systems with 498 * Extra Processor objects may be enumerated on MP systems with
514 * less than the max # of CPUs. They should be ignored _iff 499 * less than the max # of CPUs. They should be ignored _iff
515 * they are physically not present. 500 * they are physically not present.
516 */ 501 */
517 if (cpu_index >= NR_CPUS) { 502 if (cpu_index >= NR_CPUS) {
518 if (ACPI_FAILURE(acpi_processor_hotadd_init(pr->handle, &pr->id))) { 503 if (ACPI_FAILURE
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 504 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
520 "Error getting cpuindex for acpiid 0x%x\n", 505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
521 pr->acpi_id)); 506 "Error getting cpuindex for acpiid 0x%x\n",
522 return_VALUE(-ENODEV); 507 pr->acpi_id));
523 } 508 return_VALUE(-ENODEV);
524 } 509 }
510 }
525 511
526 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, 512 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
527 pr->acpi_id)); 513 pr->acpi_id));
528 514
529 if (!object.processor.pblk_address) 515 if (!object.processor.pblk_address)
530 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 516 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
531 else if (object.processor.pblk_length != 6) 517 else if (object.processor.pblk_length != 6)
532 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", 518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n",
533 object.processor.pblk_length)); 519 object.processor.pblk_length));
534 else { 520 else {
535 pr->throttling.address = object.processor.pblk_address; 521 pr->throttling.address = object.processor.pblk_address;
536 pr->throttling.duty_offset = acpi_fadt.duty_offset; 522 pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -557,13 +543,11 @@ acpi_processor_get_info (
557 return_VALUE(0); 543 return_VALUE(0);
558} 544}
559 545
560static int 546static int acpi_processor_start(struct acpi_device *device)
561acpi_processor_start(
562 struct acpi_device *device)
563{ 547{
564 int result = 0; 548 int result = 0;
565 acpi_status status = AE_OK; 549 acpi_status status = AE_OK;
566 struct acpi_processor *pr; 550 struct acpi_processor *pr;
567 551
568 ACPI_FUNCTION_TRACE("acpi_processor_start"); 552 ACPI_FUNCTION_TRACE("acpi_processor_start");
569 553
@@ -584,36 +568,30 @@ acpi_processor_start(
584 goto end; 568 goto end;
585 569
586 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 570 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
587 acpi_processor_notify, pr); 571 acpi_processor_notify, pr);
588 if (ACPI_FAILURE(status)) { 572 if (ACPI_FAILURE(status)) {
589 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
590 "Error installing device notify handler\n")); 574 "Error installing device notify handler\n"));
591 } 575 }
592 576
593 acpi_processor_power_init(pr, device); 577 acpi_processor_power_init(pr, device);
594 578
595 if (pr->flags.throttling) { 579 if (pr->flags.throttling) {
596 printk(KERN_INFO PREFIX "%s [%s] (supports", 580 printk(KERN_INFO PREFIX "%s [%s] (supports",
597 acpi_device_name(device), acpi_device_bid(device)); 581 acpi_device_name(device), acpi_device_bid(device));
598 printk(" %d throttling states", pr->throttling.state_count); 582 printk(" %d throttling states", pr->throttling.state_count);
599 printk(")\n"); 583 printk(")\n");
600 } 584 }
601 585
602end: 586 end:
603 587
604 return_VALUE(result); 588 return_VALUE(result);
605} 589}
606 590
607 591static 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{ 592{
615 struct acpi_processor *pr = (struct acpi_processor *) data; 593 struct acpi_processor *pr = (struct acpi_processor *)data;
616 struct acpi_device *device = NULL; 594 struct acpi_device *device = NULL;
617 595
618 ACPI_FUNCTION_TRACE("acpi_processor_notify"); 596 ACPI_FUNCTION_TRACE("acpi_processor_notify");
619 597
@@ -627,7 +605,7 @@ acpi_processor_notify (
627 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 605 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
628 acpi_processor_ppc_has_changed(pr); 606 acpi_processor_ppc_has_changed(pr);
629 acpi_bus_generate_event(device, event, 607 acpi_bus_generate_event(device, event,
630 pr->performance_platform_limit); 608 pr->performance_platform_limit);
631 break; 609 break;
632 case ACPI_PROCESSOR_NOTIFY_POWER: 610 case ACPI_PROCESSOR_NOTIFY_POWER:
633 acpi_processor_cst_has_changed(pr); 611 acpi_processor_cst_has_changed(pr);
@@ -635,19 +613,16 @@ acpi_processor_notify (
635 break; 613 break;
636 default: 614 default:
637 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 615 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
638 "Unsupported event [0x%x]\n", event)); 616 "Unsupported event [0x%x]\n", event));
639 break; 617 break;
640 } 618 }
641 619
642 return_VOID; 620 return_VOID;
643} 621}
644 622
645 623static int acpi_processor_add(struct acpi_device *device)
646static int
647acpi_processor_add (
648 struct acpi_device *device)
649{ 624{
650 struct acpi_processor *pr = NULL; 625 struct acpi_processor *pr = NULL;
651 626
652 ACPI_FUNCTION_TRACE("acpi_processor_add"); 627 ACPI_FUNCTION_TRACE("acpi_processor_add");
653 628
@@ -667,21 +642,17 @@ acpi_processor_add (
667 return_VALUE(0); 642 return_VALUE(0);
668} 643}
669 644
670 645static int acpi_processor_remove(struct acpi_device *device, int type)
671static int
672acpi_processor_remove (
673 struct acpi_device *device,
674 int type)
675{ 646{
676 acpi_status status = AE_OK; 647 acpi_status status = AE_OK;
677 struct acpi_processor *pr = NULL; 648 struct acpi_processor *pr = NULL;
678 649
679 ACPI_FUNCTION_TRACE("acpi_processor_remove"); 650 ACPI_FUNCTION_TRACE("acpi_processor_remove");
680 651
681 if (!device || !acpi_driver_data(device)) 652 if (!device || !acpi_driver_data(device))
682 return_VALUE(-EINVAL); 653 return_VALUE(-EINVAL);
683 654
684 pr = (struct acpi_processor *) acpi_driver_data(device); 655 pr = (struct acpi_processor *)acpi_driver_data(device);
685 656
686 if (pr->id >= NR_CPUS) { 657 if (pr->id >= NR_CPUS) {
687 kfree(pr); 658 kfree(pr);
@@ -696,10 +667,10 @@ acpi_processor_remove (
696 acpi_processor_power_exit(pr, device); 667 acpi_processor_power_exit(pr, device);
697 668
698 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 669 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
699 acpi_processor_notify); 670 acpi_processor_notify);
700 if (ACPI_FAILURE(status)) { 671 if (ACPI_FAILURE(status)) {
701 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
702 "Error removing notify handler\n")); 673 "Error removing notify handler\n"));
703 } 674 }
704 675
705 acpi_processor_remove_fs(device); 676 acpi_processor_remove_fs(device);
@@ -718,33 +689,28 @@ acpi_processor_remove (
718 689
719static int is_processor_present(acpi_handle handle); 690static int is_processor_present(acpi_handle handle);
720 691
721static int 692static int is_processor_present(acpi_handle handle)
722is_processor_present(
723 acpi_handle handle)
724{ 693{
725 acpi_status status; 694 acpi_status status;
726 unsigned long sta = 0; 695 unsigned long sta = 0;
727 696
728 ACPI_FUNCTION_TRACE("is_processor_present"); 697 ACPI_FUNCTION_TRACE("is_processor_present");
729 698
730 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 699 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
731 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { 700 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
732 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 701 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
733 "Processor Device is not present\n")); 702 "Processor Device is not present\n"));
734 return_VALUE(0); 703 return_VALUE(0);
735 } 704 }
736 return_VALUE(1); 705 return_VALUE(1);
737} 706}
738 707
739
740static 708static
741int acpi_processor_device_add( 709int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
742 acpi_handle handle,
743 struct acpi_device **device)
744{ 710{
745 acpi_handle phandle; 711 acpi_handle phandle;
746 struct acpi_device *pdev; 712 struct acpi_device *pdev;
747 struct acpi_processor *pr; 713 struct acpi_processor *pr;
748 714
749 ACPI_FUNCTION_TRACE("acpi_processor_device_add"); 715 ACPI_FUNCTION_TRACE("acpi_processor_device_add");
750 716
@@ -766,21 +732,17 @@ int acpi_processor_device_add(
766 if (!pr) 732 if (!pr)
767 return_VALUE(-ENODEV); 733 return_VALUE(-ENODEV);
768 734
769 if ((pr->id >=0) && (pr->id < NR_CPUS)) { 735 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
770 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); 736 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE);
771 } 737 }
772 return_VALUE(0); 738 return_VALUE(0);
773} 739}
774 740
775
776static void 741static void
777acpi_processor_hotplug_notify ( 742acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
778 acpi_handle handle,
779 u32 event,
780 void *data)
781{ 743{
782 struct acpi_processor *pr; 744 struct acpi_processor *pr;
783 struct acpi_device *device = NULL; 745 struct acpi_device *device = NULL;
784 int result; 746 int result;
785 747
786 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); 748 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
@@ -789,8 +751,8 @@ acpi_processor_hotplug_notify (
789 case ACPI_NOTIFY_BUS_CHECK: 751 case ACPI_NOTIFY_BUS_CHECK:
790 case ACPI_NOTIFY_DEVICE_CHECK: 752 case ACPI_NOTIFY_DEVICE_CHECK:
791 printk("Processor driver received %s event\n", 753 printk("Processor driver received %s event\n",
792 (event==ACPI_NOTIFY_BUS_CHECK)? 754 (event == ACPI_NOTIFY_BUS_CHECK) ?
793 "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); 755 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
794 756
795 if (!is_processor_present(handle)) 757 if (!is_processor_present(handle))
796 break; 758 break;
@@ -799,14 +761,14 @@ acpi_processor_hotplug_notify (
799 result = acpi_processor_device_add(handle, &device); 761 result = acpi_processor_device_add(handle, &device);
800 if (result) 762 if (result)
801 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 763 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
802 "Unable to add the device\n")); 764 "Unable to add the device\n"));
803 break; 765 break;
804 } 766 }
805 767
806 pr = acpi_driver_data(device); 768 pr = acpi_driver_data(device);
807 if (!pr) { 769 if (!pr) {
808 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
809 "Driver data is NULL\n")); 771 "Driver data is NULL\n"));
810 break; 772 break;
811 } 773 }
812 774
@@ -816,24 +778,27 @@ acpi_processor_hotplug_notify (
816 } 778 }
817 779
818 result = acpi_processor_start(device); 780 result = acpi_processor_start(device);
819 if ((!result) && ((pr->id >=0) && (pr->id < NR_CPUS))) { 781 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
820 kobject_hotplug(&device->kobj, KOBJ_ONLINE); 782 kobject_hotplug(&device->kobj, KOBJ_ONLINE);
821 } else { 783 } else {
822 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 784 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
823 "Device [%s] failed to start\n", 785 "Device [%s] failed to start\n",
824 acpi_device_bid(device))); 786 acpi_device_bid(device)));
825 } 787 }
826 break; 788 break;
827 case ACPI_NOTIFY_EJECT_REQUEST: 789 case ACPI_NOTIFY_EJECT_REQUEST:
828 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"received ACPI_NOTIFY_EJECT_REQUEST\n")); 790 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
791 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
829 792
830 if (acpi_bus_get_device(handle, &device)) { 793 if (acpi_bus_get_device(handle, &device)) {
831 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Device don't exist, dropping EJECT\n")); 794 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
795 "Device don't exist, dropping EJECT\n"));
832 break; 796 break;
833 } 797 }
834 pr = acpi_driver_data(device); 798 pr = acpi_driver_data(device);
835 if (!pr) { 799 if (!pr) {
836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Driver data is NULL, dropping EJECT\n")); 800 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
801 "Driver data is NULL, dropping EJECT\n"));
837 return_VOID; 802 return_VOID;
838 } 803 }
839 804
@@ -842,7 +807,7 @@ acpi_processor_hotplug_notify (
842 break; 807 break;
843 default: 808 default:
844 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 809 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
845 "Unsupported event [0x%x]\n", event)); 810 "Unsupported event [0x%x]\n", event));
846 break; 811 break;
847 } 812 }
848 813
@@ -851,45 +816,39 @@ acpi_processor_hotplug_notify (
851 816
852static acpi_status 817static acpi_status
853processor_walk_namespace_cb(acpi_handle handle, 818processor_walk_namespace_cb(acpi_handle handle,
854 u32 lvl, 819 u32 lvl, void *context, void **rv)
855 void *context,
856 void **rv)
857{ 820{
858 acpi_status status; 821 acpi_status status;
859 int *action = context; 822 int *action = context;
860 acpi_object_type type = 0; 823 acpi_object_type type = 0;
861 824
862 status = acpi_get_type(handle, &type); 825 status = acpi_get_type(handle, &type);
863 if (ACPI_FAILURE(status)) 826 if (ACPI_FAILURE(status))
864 return(AE_OK); 827 return (AE_OK);
865 828
866 if (type != ACPI_TYPE_PROCESSOR) 829 if (type != ACPI_TYPE_PROCESSOR)
867 return(AE_OK); 830 return (AE_OK);
868 831
869 switch(*action) { 832 switch (*action) {
870 case INSTALL_NOTIFY_HANDLER: 833 case INSTALL_NOTIFY_HANDLER:
871 acpi_install_notify_handler(handle, 834 acpi_install_notify_handler(handle,
872 ACPI_SYSTEM_NOTIFY, 835 ACPI_SYSTEM_NOTIFY,
873 acpi_processor_hotplug_notify, 836 acpi_processor_hotplug_notify,
874 NULL); 837 NULL);
875 break; 838 break;
876 case UNINSTALL_NOTIFY_HANDLER: 839 case UNINSTALL_NOTIFY_HANDLER:
877 acpi_remove_notify_handler(handle, 840 acpi_remove_notify_handler(handle,
878 ACPI_SYSTEM_NOTIFY, 841 ACPI_SYSTEM_NOTIFY,
879 acpi_processor_hotplug_notify); 842 acpi_processor_hotplug_notify);
880 break; 843 break;
881 default: 844 default:
882 break; 845 break;
883 } 846 }
884 847
885 return(AE_OK); 848 return (AE_OK);
886} 849}
887 850
888 851static 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{ 852{
894 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); 853 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
895 854
@@ -908,57 +867,47 @@ acpi_processor_hotadd_init(
908 return_VALUE(AE_OK); 867 return_VALUE(AE_OK);
909} 868}
910 869
911 870static int acpi_processor_handle_eject(struct acpi_processor *pr)
912static int
913acpi_processor_handle_eject(struct acpi_processor *pr)
914{ 871{
915 if (cpu_online(pr->id)) { 872 if (cpu_online(pr->id)) {
916 return(-EINVAL); 873 return (-EINVAL);
917 } 874 }
918 arch_unregister_cpu(pr->id); 875 arch_unregister_cpu(pr->id);
919 acpi_unmap_lsapic(pr->id); 876 acpi_unmap_lsapic(pr->id);
920 return(0); 877 return (0);
921} 878}
922#else 879#else
923static acpi_status 880static 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{ 881{
928 return AE_ERROR; 882 return AE_ERROR;
929} 883}
930static int 884static int acpi_processor_handle_eject(struct acpi_processor *pr)
931acpi_processor_handle_eject(struct acpi_processor *pr)
932{ 885{
933 return(-EINVAL); 886 return (-EINVAL);
934} 887}
935#endif 888#endif
936 889
937
938static 890static
939void acpi_processor_install_hotplug_notify(void) 891void acpi_processor_install_hotplug_notify(void)
940{ 892{
941#ifdef CONFIG_ACPI_HOTPLUG_CPU 893#ifdef CONFIG_ACPI_HOTPLUG_CPU
942 int action = INSTALL_NOTIFY_HANDLER; 894 int action = INSTALL_NOTIFY_HANDLER;
943 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 895 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
944 ACPI_ROOT_OBJECT, 896 ACPI_ROOT_OBJECT,
945 ACPI_UINT32_MAX, 897 ACPI_UINT32_MAX,
946 processor_walk_namespace_cb, 898 processor_walk_namespace_cb, &action, NULL);
947 &action, NULL);
948#endif 899#endif
949} 900}
950 901
951
952static 902static
953void acpi_processor_uninstall_hotplug_notify(void) 903void acpi_processor_uninstall_hotplug_notify(void)
954{ 904{
955#ifdef CONFIG_ACPI_HOTPLUG_CPU 905#ifdef CONFIG_ACPI_HOTPLUG_CPU
956 int action = UNINSTALL_NOTIFY_HANDLER; 906 int action = UNINSTALL_NOTIFY_HANDLER;
957 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 907 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
958 ACPI_ROOT_OBJECT, 908 ACPI_ROOT_OBJECT,
959 ACPI_UINT32_MAX, 909 ACPI_UINT32_MAX,
960 processor_walk_namespace_cb, 910 processor_walk_namespace_cb, &action, NULL);
961 &action, NULL);
962#endif 911#endif
963} 912}
964 913
@@ -968,10 +917,9 @@ void acpi_processor_uninstall_hotplug_notify(void)
968 * ACPI, but needs symbols from this driver 917 * ACPI, but needs symbols from this driver
969 */ 918 */
970 919
971static int __init 920static int __init acpi_processor_init(void)
972acpi_processor_init (void)
973{ 921{
974 int result = 0; 922 int result = 0;
975 923
976 ACPI_FUNCTION_TRACE("acpi_processor_init"); 924 ACPI_FUNCTION_TRACE("acpi_processor_init");
977 925
@@ -998,9 +946,7 @@ acpi_processor_init (void)
998 return_VALUE(0); 946 return_VALUE(0);
999} 947}
1000 948
1001 949static void __exit acpi_processor_exit(void)
1002static void __exit
1003acpi_processor_exit (void)
1004{ 950{
1005 ACPI_FUNCTION_TRACE("acpi_processor_exit"); 951 ACPI_FUNCTION_TRACE("acpi_processor_exit");
1006 952
@@ -1017,7 +963,6 @@ acpi_processor_exit (void)
1017 return_VOID; 963 return_VOID;
1018} 964}
1019 965
1020
1021module_init(acpi_processor_init); 966module_init(acpi_processor_init);
1022module_exit(acpi_processor_exit); 967module_exit(acpi_processor_exit);
1023 968
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..4cf46e1ee01b 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.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 ("rsaddr") 48ACPI_MODULE_NAME("rsaddr")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,36 +67,31 @@
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_address16_resource ( 71acpi_rs_address16_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 u32 index; 75 u32 index;
81 u16 temp16; 76 u16 temp16;
82 u8 temp8; 77 u8 temp8;
83 u8 *temp_ptr; 78 u8 *temp_ptr;
84 u8 *buffer = byte_stream_buffer; 79 u8 *buffer = byte_stream_buffer;
85 struct acpi_resource *output_struct = (void *) *output_buffer; 80 struct acpi_resource *output_struct = (void *)*output_buffer;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 81 acpi_size struct_size =
87 struct acpi_resource_address16); 82 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
88
89
90 ACPI_FUNCTION_TRACE ("rs_address16_resource");
91 83
84 ACPI_FUNCTION_TRACE("rs_address16_resource");
92 85
93 /* Point past the Descriptor to get the number of bytes consumed */ 86 /* Point past the Descriptor to get the number of bytes consumed */
94 87
95 buffer += 1; 88 buffer += 1;
96 ACPI_MOVE_16_TO_16 (&temp16, buffer); 89 ACPI_MOVE_16_TO_16(&temp16, buffer);
97 90
98 /* Validate minimum descriptor length */ 91 /* Validate minimum descriptor length */
99 92
100 if (temp16 < 13) { 93 if (temp16 < 13) {
101 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 94 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
102 } 95 }
103 96
104 *bytes_consumed = temp16 + 3; 97 *bytes_consumed = temp16 + 3;
@@ -112,7 +105,7 @@ acpi_rs_address16_resource (
112 /* Values 0-2 and 0xC0-0xFF are valid */ 105 /* Values 0-2 and 0xC0-0xFF are valid */
113 106
114 if ((temp8 > 2) && (temp8 < 0xC0)) { 107 if ((temp8 > 2) && (temp8 < 0xC0)) {
115 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 108 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
116 } 109 }
117 110
118 output_struct->data.address16.resource_type = temp8; 111 output_struct->data.address16.resource_type = temp8;
@@ -144,19 +137,18 @@ acpi_rs_address16_resource (
144 temp8 = *buffer; 137 temp8 = *buffer;
145 138
146 if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) { 139 if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) {
147 output_struct->data.address16.attribute.memory.read_write_attribute = 140 output_struct->data.address16.attribute.memory.
148 (u16) (temp8 & 0x01); 141 read_write_attribute = (u16) (temp8 & 0x01);
149 output_struct->data.address16.attribute.memory.cache_attribute = 142 output_struct->data.address16.attribute.memory.cache_attribute =
150 (u16) ((temp8 >> 1) & 0x03); 143 (u16) ((temp8 >> 1) & 0x03);
151 } 144 } else {
152 else { 145 if (ACPI_IO_RANGE ==
153 if (ACPI_IO_RANGE == output_struct->data.address16.resource_type) { 146 output_struct->data.address16.resource_type) {
154 output_struct->data.address16.attribute.io.range_attribute = 147 output_struct->data.address16.attribute.io.
155 (u16) (temp8 & 0x03); 148 range_attribute = (u16) (temp8 & 0x03);
156 output_struct->data.address16.attribute.io.translation_attribute = 149 output_struct->data.address16.attribute.io.
157 (u16) ((temp8 >> 4) & 0x03); 150 translation_attribute = (u16) ((temp8 >> 4) & 0x03);
158 } 151 } else {
159 else {
160 /* BUS_NUMBER_RANGE == Address16.Data->resource_type */ 152 /* BUS_NUMBER_RANGE == Address16.Data->resource_type */
161 /* Nothing needs to be filled in */ 153 /* Nothing needs to be filled in */
162 } 154 }
@@ -165,28 +157,31 @@ acpi_rs_address16_resource (
165 /* Get Granularity (Bytes 6-7) */ 157 /* Get Granularity (Bytes 6-7) */
166 158
167 buffer += 1; 159 buffer += 1;
168 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer); 160 ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
169 161
170 /* Get min_address_range (Bytes 8-9) */ 162 /* Get min_address_range (Bytes 8-9) */
171 163
172 buffer += 2; 164 buffer += 2;
173 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer); 165 ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
166 buffer);
174 167
175 /* Get max_address_range (Bytes 10-11) */ 168 /* Get max_address_range (Bytes 10-11) */
176 169
177 buffer += 2; 170 buffer += 2;
178 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer); 171 ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
172 buffer);
179 173
180 /* Get address_translation_offset (Bytes 12-13) */ 174 /* Get address_translation_offset (Bytes 12-13) */
181 175
182 buffer += 2; 176 buffer += 2;
183 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, 177 ACPI_MOVE_16_TO_32(&output_struct->data.address16.
184 buffer); 178 address_translation_offset, buffer);
185 179
186 /* Get address_length (Bytes 14-15) */ 180 /* Get address_length (Bytes 14-15) */
187 181
188 buffer += 2; 182 buffer += 2;
189 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer); 183 ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length,
184 buffer);
190 185
191 /* Resource Source Index (if present) */ 186 /* Resource Source Index (if present) */
192 187
@@ -206,7 +201,8 @@ acpi_rs_address16_resource (
206 /* Dereference the Index */ 201 /* Dereference the Index */
207 202
208 temp8 = *buffer; 203 temp8 = *buffer;
209 output_struct->data.address16.resource_source.index = (u32) temp8; 204 output_struct->data.address16.resource_source.index =
205 (u32) temp8;
210 206
211 /* Point to the String */ 207 /* Point to the String */
212 208
@@ -215,10 +211,10 @@ acpi_rs_address16_resource (
215 /* Point the String pointer to the end of this structure */ 211 /* Point the String pointer to the end of this structure */
216 212
217 output_struct->data.address16.resource_source.string_ptr = 213 output_struct->data.address16.resource_source.string_ptr =
218 (char *)((u8 * )output_struct + struct_size); 214 (char *)((u8 *) output_struct + struct_size);
219 215
220 temp_ptr = (u8 *) 216 temp_ptr = (u8 *)
221 output_struct->data.address16.resource_source.string_ptr; 217 output_struct->data.address16.resource_source.string_ptr;
222 218
223 /* Copy the string into the buffer */ 219 /* Copy the string into the buffer */
224 220
@@ -236,7 +232,8 @@ acpi_rs_address16_resource (
236 232
237 *temp_ptr = 0x00; 233 *temp_ptr = 0x00;
238 234
239 output_struct->data.address16.resource_source.string_length = index + 1; 235 output_struct->data.address16.resource_source.string_length =
236 index + 1;
240 237
241 /* 238 /*
242 * In order for the struct_size to fall on a 32-bit boundary, 239 * In order for the struct_size to fall on a 32-bit boundary,
@@ -244,9 +241,8 @@ acpi_rs_address16_resource (
244 * struct_size to the next 32-bit boundary. 241 * struct_size to the next 32-bit boundary.
245 */ 242 */
246 temp8 = (u8) (index + 1); 243 temp8 = (u8) (index + 1);
247 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 244 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
248 } 245 } else {
249 else {
250 output_struct->data.address16.resource_source.index = 0x00; 246 output_struct->data.address16.resource_source.index = 0x00;
251 output_struct->data.address16.resource_source.string_length = 0; 247 output_struct->data.address16.resource_source.string_length = 0;
252 output_struct->data.address16.resource_source.string_ptr = NULL; 248 output_struct->data.address16.resource_source.string_ptr = NULL;
@@ -259,10 +255,9 @@ acpi_rs_address16_resource (
259 /* Return the final size of the structure */ 255 /* Return the final size of the structure */
260 256
261 *structure_size = struct_size; 257 *structure_size = struct_size;
262 return_ACPI_STATUS (AE_OK); 258 return_ACPI_STATUS(AE_OK);
263} 259}
264 260
265
266/******************************************************************************* 261/*******************************************************************************
267 * 262 *
268 * FUNCTION: acpi_rs_address16_stream 263 * FUNCTION: acpi_rs_address16_stream
@@ -280,20 +275,16 @@ acpi_rs_address16_resource (
280 ******************************************************************************/ 275 ******************************************************************************/
281 276
282acpi_status 277acpi_status
283acpi_rs_address16_stream ( 278acpi_rs_address16_stream(struct acpi_resource *linked_list,
284 struct acpi_resource *linked_list, 279 u8 ** output_buffer, acpi_size * bytes_consumed)
285 u8 **output_buffer,
286 acpi_size *bytes_consumed)
287{ 280{
288 u8 *buffer = *output_buffer; 281 u8 *buffer = *output_buffer;
289 u8 *length_field; 282 u8 *length_field;
290 u8 temp8; 283 u8 temp8;
291 char *temp_pointer = NULL; 284 char *temp_pointer = NULL;
292 acpi_size actual_bytes; 285 acpi_size actual_bytes;
293
294
295 ACPI_FUNCTION_TRACE ("rs_address16_stream");
296 286
287 ACPI_FUNCTION_TRACE("rs_address16_stream");
297 288
298 /* The descriptor field is static */ 289 /* The descriptor field is static */
299 290
@@ -328,20 +319,19 @@ acpi_rs_address16_stream (
328 319
329 if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { 320 if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
330 temp8 = (u8) 321 temp8 = (u8)
331 (linked_list->data.address16.attribute.memory.read_write_attribute & 322 (linked_list->data.address16.attribute.memory.
332 0x01); 323 read_write_attribute & 0x01);
333 324
334 temp8 |= 325 temp8 |=
335 (linked_list->data.address16.attribute.memory.cache_attribute & 326 (linked_list->data.address16.attribute.memory.
336 0x03) << 1; 327 cache_attribute & 0x03) << 1;
337 } 328 } else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) {
338 else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) {
339 temp8 = (u8) 329 temp8 = (u8)
340 (linked_list->data.address16.attribute.io.range_attribute & 330 (linked_list->data.address16.attribute.io.range_attribute &
341 0x03); 331 0x03);
342 temp8 |= 332 temp8 |=
343 (linked_list->data.address16.attribute.io.translation_attribute & 333 (linked_list->data.address16.attribute.io.
344 0x03) << 4; 334 translation_attribute & 0x03) << 4;
345 } 335 }
346 336
347 *buffer = temp8; 337 *buffer = temp8;
@@ -349,28 +339,31 @@ acpi_rs_address16_stream (
349 339
350 /* Set the address space granularity */ 340 /* Set the address space granularity */
351 341
352 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity); 342 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.granularity);
353 buffer += 2; 343 buffer += 2;
354 344
355 /* Set the address range minimum */ 345 /* Set the address range minimum */
356 346
357 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range); 347 ACPI_MOVE_32_TO_16(buffer,
348 &linked_list->data.address16.min_address_range);
358 buffer += 2; 349 buffer += 2;
359 350
360 /* Set the address range maximum */ 351 /* Set the address range maximum */
361 352
362 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range); 353 ACPI_MOVE_32_TO_16(buffer,
354 &linked_list->data.address16.max_address_range);
363 buffer += 2; 355 buffer += 2;
364 356
365 /* Set the address translation offset */ 357 /* Set the address translation offset */
366 358
367 ACPI_MOVE_32_TO_16 (buffer, 359 ACPI_MOVE_32_TO_16(buffer,
368 &linked_list->data.address16.address_translation_offset); 360 &linked_list->data.address16.
361 address_translation_offset);
369 buffer += 2; 362 buffer += 2;
370 363
371 /* Set the address length */ 364 /* Set the address length */
372 365
373 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length); 366 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.address_length);
374 buffer += 2; 367 buffer += 2;
375 368
376 /* Resource Source Index and Resource Source are optional */ 369 /* Resource Source Index and Resource Source are optional */
@@ -381,24 +374,27 @@ acpi_rs_address16_stream (
381 *buffer = temp8; 374 *buffer = temp8;
382 buffer += 1; 375 buffer += 1;
383 376
384 temp_pointer = (char *) buffer; 377 temp_pointer = (char *)buffer;
385 378
386 /* Copy the string */ 379 /* Copy the string */
387 380
388 ACPI_STRCPY (temp_pointer, 381 ACPI_STRCPY(temp_pointer,
389 linked_list->data.address16.resource_source.string_ptr); 382 linked_list->data.address16.resource_source.
383 string_ptr);
390 384
391 /* 385 /*
392 * Buffer needs to be set to the length of the sting + one for the 386 * Buffer needs to be set to the length of the sting + one for the
393 * terminating null 387 * terminating null
394 */ 388 */
395 buffer += (acpi_size)(ACPI_STRLEN ( 389 buffer +=
396 linked_list->data.address16.resource_source.string_ptr) + 1); 390 (acpi_size) (ACPI_STRLEN
391 (linked_list->data.address16.resource_source.
392 string_ptr) + 1);
397 } 393 }
398 394
399 /* Return the number of bytes consumed in this operation */ 395 /* Return the number of bytes consumed in this operation */
400 396
401 actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer); 397 actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
402 *bytes_consumed = actual_bytes; 398 *bytes_consumed = actual_bytes;
403 399
404 /* 400 /*
@@ -406,11 +402,10 @@ acpi_rs_address16_stream (
406 * minus the header size (3 bytes) 402 * minus the header size (3 bytes)
407 */ 403 */
408 actual_bytes -= 3; 404 actual_bytes -= 3;
409 ACPI_MOVE_SIZE_TO_16 (length_field, &actual_bytes); 405 ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
410 return_ACPI_STATUS (AE_OK); 406 return_ACPI_STATUS(AE_OK);
411} 407}
412 408
413
414/******************************************************************************* 409/*******************************************************************************
415 * 410 *
416 * FUNCTION: acpi_rs_address32_resource 411 * FUNCTION: acpi_rs_address32_resource
@@ -433,36 +428,32 @@ acpi_rs_address16_stream (
433 ******************************************************************************/ 428 ******************************************************************************/
434 429
435acpi_status 430acpi_status
436acpi_rs_address32_resource ( 431acpi_rs_address32_resource(u8 * byte_stream_buffer,
437 u8 *byte_stream_buffer, 432 acpi_size * bytes_consumed,
438 acpi_size *bytes_consumed, 433 u8 ** output_buffer, acpi_size * structure_size)
439 u8 **output_buffer,
440 acpi_size *structure_size)
441{ 434{
442 u8 *buffer; 435 u8 *buffer;
443 struct acpi_resource *output_struct= (void *) *output_buffer; 436 struct acpi_resource *output_struct = (void *)*output_buffer;
444 u16 temp16; 437 u16 temp16;
445 u8 temp8; 438 u8 temp8;
446 u8 *temp_ptr; 439 u8 *temp_ptr;
447 acpi_size struct_size; 440 acpi_size struct_size;
448 u32 index; 441 u32 index;
449
450
451 ACPI_FUNCTION_TRACE ("rs_address32_resource");
452 442
443 ACPI_FUNCTION_TRACE("rs_address32_resource");
453 444
454 buffer = byte_stream_buffer; 445 buffer = byte_stream_buffer;
455 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32); 446 struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
456 447
457 /* Point past the Descriptor to get the number of bytes consumed */ 448 /* Point past the Descriptor to get the number of bytes consumed */
458 449
459 buffer += 1; 450 buffer += 1;
460 ACPI_MOVE_16_TO_16 (&temp16, buffer); 451 ACPI_MOVE_16_TO_16(&temp16, buffer);
461 452
462 /* Validate minimum descriptor length */ 453 /* Validate minimum descriptor length */
463 454
464 if (temp16 < 23) { 455 if (temp16 < 23) {
465 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 456 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
466 } 457 }
467 458
468 *bytes_consumed = temp16 + 3; 459 *bytes_consumed = temp16 + 3;
@@ -476,7 +467,7 @@ acpi_rs_address32_resource (
476 /* Values 0-2 and 0xC0-0xFF are valid */ 467 /* Values 0-2 and 0xC0-0xFF are valid */
477 468
478 if ((temp8 > 2) && (temp8 < 0xC0)) { 469 if ((temp8 > 2) && (temp8 < 0xC0)) {
479 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 470 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
480 } 471 }
481 472
482 output_struct->data.address32.resource_type = temp8; 473 output_struct->data.address32.resource_type = temp8;
@@ -508,20 +499,19 @@ acpi_rs_address32_resource (
508 temp8 = *buffer; 499 temp8 = *buffer;
509 500
510 if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) { 501 if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) {
511 output_struct->data.address32.attribute.memory.read_write_attribute = 502 output_struct->data.address32.attribute.memory.
512 (u16) (temp8 & 0x01); 503 read_write_attribute = (u16) (temp8 & 0x01);
513 504
514 output_struct->data.address32.attribute.memory.cache_attribute = 505 output_struct->data.address32.attribute.memory.cache_attribute =
515 (u16) ((temp8 >> 1) & 0x03); 506 (u16) ((temp8 >> 1) & 0x03);
516 } 507 } else {
517 else { 508 if (ACPI_IO_RANGE ==
518 if (ACPI_IO_RANGE == output_struct->data.address32.resource_type) { 509 output_struct->data.address32.resource_type) {
519 output_struct->data.address32.attribute.io.range_attribute = 510 output_struct->data.address32.attribute.io.
520 (u16) (temp8 & 0x03); 511 range_attribute = (u16) (temp8 & 0x03);
521 output_struct->data.address32.attribute.io.translation_attribute = 512 output_struct->data.address32.attribute.io.
522 (u16) ((temp8 >> 4) & 0x03); 513 translation_attribute = (u16) ((temp8 >> 4) & 0x03);
523 } 514 } else {
524 else {
525 /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */ 515 /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */
526 /* Nothing needs to be filled in */ 516 /* Nothing needs to be filled in */
527 } 517 }
@@ -530,28 +520,31 @@ acpi_rs_address32_resource (
530 /* Get Granularity (Bytes 6-9) */ 520 /* Get Granularity (Bytes 6-9) */
531 521
532 buffer += 1; 522 buffer += 1;
533 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer); 523 ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
534 524
535 /* Get min_address_range (Bytes 10-13) */ 525 /* Get min_address_range (Bytes 10-13) */
536 526
537 buffer += 4; 527 buffer += 4;
538 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer); 528 ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
529 buffer);
539 530
540 /* Get max_address_range (Bytes 14-17) */ 531 /* Get max_address_range (Bytes 14-17) */
541 532
542 buffer += 4; 533 buffer += 4;
543 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer); 534 ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
535 buffer);
544 536
545 /* Get address_translation_offset (Bytes 18-21) */ 537 /* Get address_translation_offset (Bytes 18-21) */
546 538
547 buffer += 4; 539 buffer += 4;
548 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, 540 ACPI_MOVE_32_TO_32(&output_struct->data.address32.
549 buffer); 541 address_translation_offset, buffer);
550 542
551 /* Get address_length (Bytes 22-25) */ 543 /* Get address_length (Bytes 22-25) */
552 544
553 buffer += 4; 545 buffer += 4;
554 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer); 546 ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
547 buffer);
555 548
556 /* Resource Source Index (if present) */ 549 /* Resource Source Index (if present) */
557 550
@@ -570,7 +563,7 @@ acpi_rs_address32_resource (
570 563
571 temp8 = *buffer; 564 temp8 = *buffer;
572 output_struct->data.address32.resource_source.index = 565 output_struct->data.address32.resource_source.index =
573 (u32) temp8; 566 (u32) temp8;
574 567
575 /* Point to the String */ 568 /* Point to the String */
576 569
@@ -579,10 +572,10 @@ acpi_rs_address32_resource (
579 /* Point the String pointer to the end of this structure */ 572 /* Point the String pointer to the end of this structure */
580 573
581 output_struct->data.address32.resource_source.string_ptr = 574 output_struct->data.address32.resource_source.string_ptr =
582 (char *)((u8 *)output_struct + struct_size); 575 (char *)((u8 *) output_struct + struct_size);
583 576
584 temp_ptr = (u8 *) 577 temp_ptr = (u8 *)
585 output_struct->data.address32.resource_source.string_ptr; 578 output_struct->data.address32.resource_source.string_ptr;
586 579
587 /* Copy the string into the buffer */ 580 /* Copy the string into the buffer */
588 581
@@ -598,7 +591,8 @@ acpi_rs_address32_resource (
598 /* Add the terminating null */ 591 /* Add the terminating null */
599 592
600 *temp_ptr = 0x00; 593 *temp_ptr = 0x00;
601 output_struct->data.address32.resource_source.string_length = index + 1; 594 output_struct->data.address32.resource_source.string_length =
595 index + 1;
602 596
603 /* 597 /*
604 * In order for the struct_size to fall on a 32-bit boundary, 598 * In order for the struct_size to fall on a 32-bit boundary,
@@ -606,9 +600,8 @@ acpi_rs_address32_resource (
606 * struct_size to the next 32-bit boundary. 600 * struct_size to the next 32-bit boundary.
607 */ 601 */
608 temp8 = (u8) (index + 1); 602 temp8 = (u8) (index + 1);
609 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 603 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
610 } 604 } else {
611 else {
612 output_struct->data.address32.resource_source.index = 0x00; 605 output_struct->data.address32.resource_source.index = 0x00;
613 output_struct->data.address32.resource_source.string_length = 0; 606 output_struct->data.address32.resource_source.string_length = 0;
614 output_struct->data.address32.resource_source.string_ptr = NULL; 607 output_struct->data.address32.resource_source.string_ptr = NULL;
@@ -621,10 +614,9 @@ acpi_rs_address32_resource (
621 /* Return the final size of the structure */ 614 /* Return the final size of the structure */
622 615
623 *structure_size = struct_size; 616 *structure_size = struct_size;
624 return_ACPI_STATUS (AE_OK); 617 return_ACPI_STATUS(AE_OK);
625} 618}
626 619
627
628/******************************************************************************* 620/*******************************************************************************
629 * 621 *
630 * FUNCTION: acpi_rs_address32_stream 622 * FUNCTION: acpi_rs_address32_stream
@@ -642,19 +634,15 @@ acpi_rs_address32_resource (
642 ******************************************************************************/ 634 ******************************************************************************/
643 635
644acpi_status 636acpi_status
645acpi_rs_address32_stream ( 637acpi_rs_address32_stream(struct acpi_resource *linked_list,
646 struct acpi_resource *linked_list, 638 u8 ** output_buffer, acpi_size * bytes_consumed)
647 u8 **output_buffer,
648 acpi_size *bytes_consumed)
649{ 639{
650 u8 *buffer; 640 u8 *buffer;
651 u16 *length_field; 641 u16 *length_field;
652 u8 temp8; 642 u8 temp8;
653 char *temp_pointer; 643 char *temp_pointer;
654
655
656 ACPI_FUNCTION_TRACE ("rs_address32_stream");
657 644
645 ACPI_FUNCTION_TRACE("rs_address32_stream");
658 646
659 buffer = *output_buffer; 647 buffer = *output_buffer;
660 648
@@ -665,7 +653,7 @@ acpi_rs_address32_stream (
665 653
666 /* Set a pointer to the Length field - to be filled in later */ 654 /* Set a pointer to the Length field - to be filled in later */
667 655
668 length_field = ACPI_CAST_PTR (u16, buffer); 656 length_field = ACPI_CAST_PTR(u16, buffer);
669 buffer += 2; 657 buffer += 2;
670 658
671 /* Set the Resource Type (Memory, Io, bus_number) */ 659 /* Set the Resource Type (Memory, Io, bus_number) */
@@ -691,20 +679,19 @@ acpi_rs_address32_stream (
691 679
692 if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { 680 if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
693 temp8 = (u8) 681 temp8 = (u8)
694 (linked_list->data.address32.attribute.memory.read_write_attribute & 682 (linked_list->data.address32.attribute.memory.
695 0x01); 683 read_write_attribute & 0x01);
696 684
697 temp8 |= 685 temp8 |=
698 (linked_list->data.address32.attribute.memory.cache_attribute & 686 (linked_list->data.address32.attribute.memory.
699 0x03) << 1; 687 cache_attribute & 0x03) << 1;
700 } 688 } else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) {
701 else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) {
702 temp8 = (u8) 689 temp8 = (u8)
703 (linked_list->data.address32.attribute.io.range_attribute & 690 (linked_list->data.address32.attribute.io.range_attribute &
704 0x03); 691 0x03);
705 temp8 |= 692 temp8 |=
706 (linked_list->data.address32.attribute.io.translation_attribute & 693 (linked_list->data.address32.attribute.io.
707 0x03) << 4; 694 translation_attribute & 0x03) << 4;
708 } 695 }
709 696
710 *buffer = temp8; 697 *buffer = temp8;
@@ -712,28 +699,31 @@ acpi_rs_address32_stream (
712 699
713 /* Set the address space granularity */ 700 /* Set the address space granularity */
714 701
715 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity); 702 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.granularity);
716 buffer += 4; 703 buffer += 4;
717 704
718 /* Set the address range minimum */ 705 /* Set the address range minimum */
719 706
720 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range); 707 ACPI_MOVE_32_TO_32(buffer,
708 &linked_list->data.address32.min_address_range);
721 buffer += 4; 709 buffer += 4;
722 710
723 /* Set the address range maximum */ 711 /* Set the address range maximum */
724 712
725 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range); 713 ACPI_MOVE_32_TO_32(buffer,
714 &linked_list->data.address32.max_address_range);
726 buffer += 4; 715 buffer += 4;
727 716
728 /* Set the address translation offset */ 717 /* Set the address translation offset */
729 718
730 ACPI_MOVE_32_TO_32 (buffer, 719 ACPI_MOVE_32_TO_32(buffer,
731 &linked_list->data.address32.address_translation_offset); 720 &linked_list->data.address32.
721 address_translation_offset);
732 buffer += 4; 722 buffer += 4;
733 723
734 /* Set the address length */ 724 /* Set the address length */
735 725
736 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length); 726 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.address_length);
737 buffer += 4; 727 buffer += 4;
738 728
739 /* Resource Source Index and Resource Source are optional */ 729 /* Resource Source Index and Resource Source are optional */
@@ -744,34 +734,36 @@ acpi_rs_address32_stream (
744 *buffer = temp8; 734 *buffer = temp8;
745 buffer += 1; 735 buffer += 1;
746 736
747 temp_pointer = (char *) buffer; 737 temp_pointer = (char *)buffer;
748 738
749 /* Copy the string */ 739 /* Copy the string */
750 740
751 ACPI_STRCPY (temp_pointer, 741 ACPI_STRCPY(temp_pointer,
752 linked_list->data.address32.resource_source.string_ptr); 742 linked_list->data.address32.resource_source.
743 string_ptr);
753 744
754 /* 745 /*
755 * Buffer needs to be set to the length of the sting + one for the 746 * Buffer needs to be set to the length of the sting + one for the
756 * terminating null 747 * terminating null
757 */ 748 */
758 buffer += (acpi_size)(ACPI_STRLEN ( 749 buffer +=
759 linked_list->data.address32.resource_source.string_ptr) + 1); 750 (acpi_size) (ACPI_STRLEN
751 (linked_list->data.address32.resource_source.
752 string_ptr) + 1);
760 } 753 }
761 754
762 /* Return the number of bytes consumed in this operation */ 755 /* Return the number of bytes consumed in this operation */
763 756
764 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 757 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
765 758
766 /* 759 /*
767 * Set the length field to the number of bytes consumed 760 * Set the length field to the number of bytes consumed
768 * minus the header size (3 bytes) 761 * minus the header size (3 bytes)
769 */ 762 */
770 *length_field = (u16) (*bytes_consumed - 3); 763 *length_field = (u16) (*bytes_consumed - 3);
771 return_ACPI_STATUS (AE_OK); 764 return_ACPI_STATUS(AE_OK);
772} 765}
773 766
774
775/******************************************************************************* 767/*******************************************************************************
776 * 768 *
777 * FUNCTION: acpi_rs_address64_resource 769 * FUNCTION: acpi_rs_address64_resource
@@ -794,38 +786,34 @@ acpi_rs_address32_stream (
794 ******************************************************************************/ 786 ******************************************************************************/
795 787
796acpi_status 788acpi_status
797acpi_rs_address64_resource ( 789acpi_rs_address64_resource(u8 * byte_stream_buffer,
798 u8 *byte_stream_buffer, 790 acpi_size * bytes_consumed,
799 acpi_size *bytes_consumed, 791 u8 ** output_buffer, acpi_size * structure_size)
800 u8 **output_buffer,
801 acpi_size *structure_size)
802{ 792{
803 u8 *buffer; 793 u8 *buffer;
804 struct acpi_resource *output_struct = (void *) *output_buffer; 794 struct acpi_resource *output_struct = (void *)*output_buffer;
805 u16 temp16; 795 u16 temp16;
806 u8 temp8; 796 u8 temp8;
807 u8 resource_type; 797 u8 resource_type;
808 u8 *temp_ptr; 798 u8 *temp_ptr;
809 acpi_size struct_size; 799 acpi_size struct_size;
810 u32 index; 800 u32 index;
811
812
813 ACPI_FUNCTION_TRACE ("rs_address64_resource");
814 801
802 ACPI_FUNCTION_TRACE("rs_address64_resource");
815 803
816 buffer = byte_stream_buffer; 804 buffer = byte_stream_buffer;
817 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); 805 struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
818 resource_type = *buffer; 806 resource_type = *buffer;
819 807
820 /* Point past the Descriptor to get the number of bytes consumed */ 808 /* Point past the Descriptor to get the number of bytes consumed */
821 809
822 buffer += 1; 810 buffer += 1;
823 ACPI_MOVE_16_TO_16 (&temp16, buffer); 811 ACPI_MOVE_16_TO_16(&temp16, buffer);
824 812
825 /* Validate minimum descriptor length */ 813 /* Validate minimum descriptor length */
826 814
827 if (temp16 < 43) { 815 if (temp16 < 43) {
828 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 816 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
829 } 817 }
830 818
831 *bytes_consumed = temp16 + 3; 819 *bytes_consumed = temp16 + 3;
@@ -839,7 +827,7 @@ acpi_rs_address64_resource (
839 /* Values 0-2 and 0xC0-0xFF are valid */ 827 /* Values 0-2 and 0xC0-0xFF are valid */
840 828
841 if ((temp8 > 2) && (temp8 < 0xC0)) { 829 if ((temp8 > 2) && (temp8 < 0xC0)) {
842 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 830 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
843 } 831 }
844 832
845 output_struct->data.address64.resource_type = temp8; 833 output_struct->data.address64.resource_type = temp8;
@@ -871,20 +859,19 @@ acpi_rs_address64_resource (
871 temp8 = *buffer; 859 temp8 = *buffer;
872 860
873 if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) { 861 if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) {
874 output_struct->data.address64.attribute.memory.read_write_attribute = 862 output_struct->data.address64.attribute.memory.
875 (u16) (temp8 & 0x01); 863 read_write_attribute = (u16) (temp8 & 0x01);
876 864
877 output_struct->data.address64.attribute.memory.cache_attribute = 865 output_struct->data.address64.attribute.memory.cache_attribute =
878 (u16) ((temp8 >> 1) & 0x03); 866 (u16) ((temp8 >> 1) & 0x03);
879 } 867 } else {
880 else { 868 if (ACPI_IO_RANGE ==
881 if (ACPI_IO_RANGE == output_struct->data.address64.resource_type) { 869 output_struct->data.address64.resource_type) {
882 output_struct->data.address64.attribute.io.range_attribute = 870 output_struct->data.address64.attribute.io.
883 (u16) (temp8 & 0x03); 871 range_attribute = (u16) (temp8 & 0x03);
884 output_struct->data.address64.attribute.io.translation_attribute = 872 output_struct->data.address64.attribute.io.
885 (u16) ((temp8 >> 4) & 0x03); 873 translation_attribute = (u16) ((temp8 >> 4) & 0x03);
886 } 874 } else {
887 else {
888 /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */ 875 /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */
889 /* Nothing needs to be filled in */ 876 /* Nothing needs to be filled in */
890 } 877 }
@@ -899,28 +886,31 @@ acpi_rs_address64_resource (
899 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ 886 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
900 887
901 buffer += 1; 888 buffer += 1;
902 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer); 889 ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
903 890
904 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ 891 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
905 892
906 buffer += 8; 893 buffer += 8;
907 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer); 894 ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
895 buffer);
908 896
909 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ 897 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
910 898
911 buffer += 8; 899 buffer += 8;
912 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer); 900 ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
901 buffer);
913 902
914 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ 903 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
915 904
916 buffer += 8; 905 buffer += 8;
917 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, 906 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
918 buffer); 907 address_translation_offset, buffer);
919 908
920 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 909 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
921 910
922 buffer += 8; 911 buffer += 8;
923 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer); 912 ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length,
913 buffer);
924 914
925 output_struct->data.address64.resource_source.index = 0x00; 915 output_struct->data.address64.resource_source.index = 0x00;
926 output_struct->data.address64.resource_source.string_length = 0; 916 output_struct->data.address64.resource_source.string_length = 0;
@@ -930,11 +920,9 @@ acpi_rs_address64_resource (
930 /* Get type_specific_attribute (Bytes 48-55) */ 920 /* Get type_specific_attribute (Bytes 48-55) */
931 921
932 buffer += 8; 922 buffer += 8;
933 ACPI_MOVE_64_TO_64 ( 923 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
934 &output_struct->data.address64.type_specific_attributes, 924 type_specific_attributes, buffer);
935 buffer); 925 } else {
936 }
937 else {
938 output_struct->data.address64.type_specific_attributes = 0; 926 output_struct->data.address64.type_specific_attributes = 0;
939 927
940 /* Resource Source Index (if present) */ 928 /* Resource Source Index (if present) */
@@ -956,7 +944,7 @@ acpi_rs_address64_resource (
956 944
957 temp8 = *buffer; 945 temp8 = *buffer;
958 output_struct->data.address64.resource_source.index = 946 output_struct->data.address64.resource_source.index =
959 (u32) temp8; 947 (u32) temp8;
960 948
961 /* Point to the String */ 949 /* Point to the String */
962 950
@@ -964,11 +952,13 @@ acpi_rs_address64_resource (
964 952
965 /* Point the String pointer to the end of this structure */ 953 /* Point the String pointer to the end of this structure */
966 954
967 output_struct->data.address64.resource_source.string_ptr = 955 output_struct->data.address64.resource_source.
968 (char *)((u8 *)output_struct + struct_size); 956 string_ptr =
957 (char *)((u8 *) output_struct + struct_size);
969 958
970 temp_ptr = (u8 *) 959 temp_ptr = (u8 *)
971 output_struct->data.address64.resource_source.string_ptr; 960 output_struct->data.address64.resource_source.
961 string_ptr;
972 962
973 /* Copy the string into the buffer */ 963 /* Copy the string into the buffer */
974 964
@@ -985,8 +975,8 @@ acpi_rs_address64_resource (
985 * Add the terminating null 975 * Add the terminating null
986 */ 976 */
987 *temp_ptr = 0x00; 977 *temp_ptr = 0x00;
988 output_struct->data.address64.resource_source.string_length = 978 output_struct->data.address64.resource_source.
989 index + 1; 979 string_length = index + 1;
990 980
991 /* 981 /*
992 * In order for the struct_size to fall on a 32-bit boundary, 982 * In order for the struct_size to fall on a 32-bit boundary,
@@ -994,7 +984,7 @@ acpi_rs_address64_resource (
994 * struct_size to the next 32-bit boundary. 984 * struct_size to the next 32-bit boundary.
995 */ 985 */
996 temp8 = (u8) (index + 1); 986 temp8 = (u8) (index + 1);
997 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 987 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
998 } 988 }
999 } 989 }
1000 990
@@ -1005,10 +995,9 @@ acpi_rs_address64_resource (
1005 /* Return the final size of the structure */ 995 /* Return the final size of the structure */
1006 996
1007 *structure_size = struct_size; 997 *structure_size = struct_size;
1008 return_ACPI_STATUS (AE_OK); 998 return_ACPI_STATUS(AE_OK);
1009} 999}
1010 1000
1011
1012/******************************************************************************* 1001/*******************************************************************************
1013 * 1002 *
1014 * FUNCTION: acpi_rs_address64_stream 1003 * FUNCTION: acpi_rs_address64_stream
@@ -1026,19 +1015,15 @@ acpi_rs_address64_resource (
1026 ******************************************************************************/ 1015 ******************************************************************************/
1027 1016
1028acpi_status 1017acpi_status
1029acpi_rs_address64_stream ( 1018acpi_rs_address64_stream(struct acpi_resource *linked_list,
1030 struct acpi_resource *linked_list, 1019 u8 ** output_buffer, acpi_size * bytes_consumed)
1031 u8 **output_buffer,
1032 acpi_size *bytes_consumed)
1033{ 1020{
1034 u8 *buffer; 1021 u8 *buffer;
1035 u16 *length_field; 1022 u16 *length_field;
1036 u8 temp8; 1023 u8 temp8;
1037 char *temp_pointer; 1024 char *temp_pointer;
1038
1039
1040 ACPI_FUNCTION_TRACE ("rs_address64_stream");
1041 1025
1026 ACPI_FUNCTION_TRACE("rs_address64_stream");
1042 1027
1043 buffer = *output_buffer; 1028 buffer = *output_buffer;
1044 1029
@@ -1049,7 +1034,7 @@ acpi_rs_address64_stream (
1049 1034
1050 /* Set a pointer to the Length field - to be filled in later */ 1035 /* Set a pointer to the Length field - to be filled in later */
1051 1036
1052 length_field = ACPI_CAST_PTR (u16, buffer); 1037 length_field = ACPI_CAST_PTR(u16, buffer);
1053 buffer += 2; 1038 buffer += 2;
1054 1039
1055 /* Set the Resource Type (Memory, Io, bus_number) */ 1040 /* Set the Resource Type (Memory, Io, bus_number) */
@@ -1075,20 +1060,19 @@ acpi_rs_address64_stream (
1075 1060
1076 if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { 1061 if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
1077 temp8 = (u8) 1062 temp8 = (u8)
1078 (linked_list->data.address64.attribute.memory.read_write_attribute & 1063 (linked_list->data.address64.attribute.memory.
1079 0x01); 1064 read_write_attribute & 0x01);
1080 1065
1081 temp8 |= 1066 temp8 |=
1082 (linked_list->data.address64.attribute.memory.cache_attribute & 1067 (linked_list->data.address64.attribute.memory.
1083 0x03) << 1; 1068 cache_attribute & 0x03) << 1;
1084 } 1069 } else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) {
1085 else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) {
1086 temp8 = (u8) 1070 temp8 = (u8)
1087 (linked_list->data.address64.attribute.io.range_attribute & 1071 (linked_list->data.address64.attribute.io.range_attribute &
1088 0x03); 1072 0x03);
1089 temp8 |= 1073 temp8 |=
1090 (linked_list->data.address64.attribute.io.range_attribute & 1074 (linked_list->data.address64.attribute.io.range_attribute &
1091 0x03) << 4; 1075 0x03) << 4;
1092 } 1076 }
1093 1077
1094 *buffer = temp8; 1078 *buffer = temp8;
@@ -1096,28 +1080,31 @@ acpi_rs_address64_stream (
1096 1080
1097 /* Set the address space granularity */ 1081 /* Set the address space granularity */
1098 1082
1099 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity); 1083 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.granularity);
1100 buffer += 8; 1084 buffer += 8;
1101 1085
1102 /* Set the address range minimum */ 1086 /* Set the address range minimum */
1103 1087
1104 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range); 1088 ACPI_MOVE_64_TO_64(buffer,
1089 &linked_list->data.address64.min_address_range);
1105 buffer += 8; 1090 buffer += 8;
1106 1091
1107 /* Set the address range maximum */ 1092 /* Set the address range maximum */
1108 1093
1109 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range); 1094 ACPI_MOVE_64_TO_64(buffer,
1095 &linked_list->data.address64.max_address_range);
1110 buffer += 8; 1096 buffer += 8;
1111 1097
1112 /* Set the address translation offset */ 1098 /* Set the address translation offset */
1113 1099
1114 ACPI_MOVE_64_TO_64 (buffer, 1100 ACPI_MOVE_64_TO_64(buffer,
1115 &linked_list->data.address64.address_translation_offset); 1101 &linked_list->data.address64.
1102 address_translation_offset);
1116 buffer += 8; 1103 buffer += 8;
1117 1104
1118 /* Set the address length */ 1105 /* Set the address length */
1119 1106
1120 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length); 1107 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.address_length);
1121 buffer += 8; 1108 buffer += 8;
1122 1109
1123 /* Resource Source Index and Resource Source are optional */ 1110 /* Resource Source Index and Resource Source are optional */
@@ -1128,30 +1115,32 @@ acpi_rs_address64_stream (
1128 *buffer = temp8; 1115 *buffer = temp8;
1129 buffer += 1; 1116 buffer += 1;
1130 1117
1131 temp_pointer = (char *) buffer; 1118 temp_pointer = (char *)buffer;
1132 1119
1133 /* Copy the string */ 1120 /* Copy the string */
1134 1121
1135 ACPI_STRCPY (temp_pointer, 1122 ACPI_STRCPY(temp_pointer,
1136 linked_list->data.address64.resource_source.string_ptr); 1123 linked_list->data.address64.resource_source.
1124 string_ptr);
1137 1125
1138 /* 1126 /*
1139 * Buffer needs to be set to the length of the sting + one for the 1127 * Buffer needs to be set to the length of the sting + one for the
1140 * terminating null 1128 * terminating null
1141 */ 1129 */
1142 buffer += (acpi_size)(ACPI_STRLEN ( 1130 buffer +=
1143 linked_list->data.address64.resource_source.string_ptr) + 1); 1131 (acpi_size) (ACPI_STRLEN
1132 (linked_list->data.address64.resource_source.
1133 string_ptr) + 1);
1144 } 1134 }
1145 1135
1146 /* Return the number of bytes consumed in this operation */ 1136 /* Return the number of bytes consumed in this operation */
1147 1137
1148 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 1138 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
1149 1139
1150 /* 1140 /*
1151 * Set the length field to the number of bytes consumed 1141 * Set the length field to the number of bytes consumed
1152 * minus the header size (3 bytes) 1142 * minus the header size (3 bytes)
1153 */ 1143 */
1154 *length_field = (u16) (*bytes_consumed - 3); 1144 *length_field = (u16) (*bytes_consumed - 3);
1155 return_ACPI_STATUS (AE_OK); 1145 return_ACPI_STATUS(AE_OK);
1156} 1146}
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 2c3bb8c35741..75bd34d1783f 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -41,70 +41,39 @@
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
51 49
52#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
53
54/* Local prototypes */ 51/* Local prototypes */
52static void acpi_rs_dump_irq(union acpi_resource_data *data);
55 53
56static void 54static void acpi_rs_dump_address16(union acpi_resource_data *data);
57acpi_rs_dump_irq (
58 union acpi_resource_data *data);
59
60static void
61acpi_rs_dump_address16 (
62 union acpi_resource_data *data);
63 55
64static void 56static void acpi_rs_dump_address32(union acpi_resource_data *data);
65acpi_rs_dump_address32 (
66 union acpi_resource_data *data);
67 57
68static void 58static void acpi_rs_dump_address64(union acpi_resource_data *data);
69acpi_rs_dump_address64 (
70 union acpi_resource_data *data);
71 59
72static void 60static void acpi_rs_dump_dma(union acpi_resource_data *data);
73acpi_rs_dump_dma (
74 union acpi_resource_data *data);
75 61
76static void 62static void acpi_rs_dump_io(union acpi_resource_data *data);
77acpi_rs_dump_io (
78 union acpi_resource_data *data);
79 63
80static void 64static void acpi_rs_dump_extended_irq(union acpi_resource_data *data);
81acpi_rs_dump_extended_irq (
82 union acpi_resource_data *data);
83 65
84static void 66static void acpi_rs_dump_fixed_io(union acpi_resource_data *data);
85acpi_rs_dump_fixed_io (
86 union acpi_resource_data *data);
87 67
88static void 68static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data);
89acpi_rs_dump_fixed_memory32 (
90 union acpi_resource_data *data);
91 69
92static void 70static void acpi_rs_dump_memory24(union acpi_resource_data *data);
93acpi_rs_dump_memory24 (
94 union acpi_resource_data *data);
95 71
96static void 72static void acpi_rs_dump_memory32(union acpi_resource_data *data);
97acpi_rs_dump_memory32 (
98 union acpi_resource_data *data);
99 73
100static void 74static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data);
101acpi_rs_dump_start_depend_fns (
102 union acpi_resource_data *data);
103
104static void
105acpi_rs_dump_vendor_specific (
106 union acpi_resource_data *data);
107 75
76static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data);
108 77
109/******************************************************************************* 78/*******************************************************************************
110 * 79 *
@@ -118,39 +87,37 @@ acpi_rs_dump_vendor_specific (
118 * 87 *
119 ******************************************************************************/ 88 ******************************************************************************/
120 89
121static void 90static void acpi_rs_dump_irq(union acpi_resource_data *data)
122acpi_rs_dump_irq (
123 union acpi_resource_data *data)
124{ 91{
125 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *) data; 92 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *)data;
126 u8 index = 0; 93 u8 index = 0;
127
128
129 ACPI_FUNCTION_ENTRY ();
130 94
95 ACPI_FUNCTION_ENTRY();
131 96
132 acpi_os_printf ("IRQ Resource\n"); 97 acpi_os_printf("IRQ Resource\n");
133 98
134 acpi_os_printf (" %s Triggered\n", 99 acpi_os_printf(" %s Triggered\n",
135 ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); 100 ACPI_LEVEL_SENSITIVE ==
101 irq_data->edge_level ? "Level" : "Edge");
136 102
137 acpi_os_printf (" Active %s\n", 103 acpi_os_printf(" Active %s\n",
138 ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); 104 ACPI_ACTIVE_LOW ==
105 irq_data->active_high_low ? "Low" : "High");
139 106
140 acpi_os_printf (" %s\n", 107 acpi_os_printf(" %s\n",
141 ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); 108 ACPI_SHARED ==
109 irq_data->shared_exclusive ? "Shared" : "Exclusive");
142 110
143 acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts); 111 acpi_os_printf(" %X Interrupts ( ", irq_data->number_of_interrupts);
144 112
145 for (index = 0; index < irq_data->number_of_interrupts; index++) { 113 for (index = 0; index < irq_data->number_of_interrupts; index++) {
146 acpi_os_printf ("%X ", irq_data->interrupts[index]); 114 acpi_os_printf("%X ", irq_data->interrupts[index]);
147 } 115 }
148 116
149 acpi_os_printf (")\n"); 117 acpi_os_printf(")\n");
150 return; 118 return;
151} 119}
152 120
153
154/******************************************************************************* 121/*******************************************************************************
155 * 122 *
156 * FUNCTION: acpi_rs_dump_dma 123 * FUNCTION: acpi_rs_dump_dma
@@ -163,75 +130,69 @@ acpi_rs_dump_irq (
163 * 130 *
164 ******************************************************************************/ 131 ******************************************************************************/
165 132
166static void 133static void acpi_rs_dump_dma(union acpi_resource_data *data)
167acpi_rs_dump_dma (
168 union acpi_resource_data *data)
169{ 134{
170 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *) data; 135 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *)data;
171 u8 index = 0; 136 u8 index = 0;
172
173
174 ACPI_FUNCTION_ENTRY ();
175 137
138 ACPI_FUNCTION_ENTRY();
176 139
177 acpi_os_printf ("DMA Resource\n"); 140 acpi_os_printf("DMA Resource\n");
178 141
179 switch (dma_data->type) { 142 switch (dma_data->type) {
180 case ACPI_COMPATIBILITY: 143 case ACPI_COMPATIBILITY:
181 acpi_os_printf (" Compatibility mode\n"); 144 acpi_os_printf(" Compatibility mode\n");
182 break; 145 break;
183 146
184 case ACPI_TYPE_A: 147 case ACPI_TYPE_A:
185 acpi_os_printf (" Type A\n"); 148 acpi_os_printf(" Type A\n");
186 break; 149 break;
187 150
188 case ACPI_TYPE_B: 151 case ACPI_TYPE_B:
189 acpi_os_printf (" Type B\n"); 152 acpi_os_printf(" Type B\n");
190 break; 153 break;
191 154
192 case ACPI_TYPE_F: 155 case ACPI_TYPE_F:
193 acpi_os_printf (" Type F\n"); 156 acpi_os_printf(" Type F\n");
194 break; 157 break;
195 158
196 default: 159 default:
197 acpi_os_printf (" Invalid DMA type\n"); 160 acpi_os_printf(" Invalid DMA type\n");
198 break; 161 break;
199 } 162 }
200 163
201 acpi_os_printf (" %sBus Master\n", 164 acpi_os_printf(" %sBus Master\n",
202 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); 165 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
203
204 166
205 switch (dma_data->transfer) { 167 switch (dma_data->transfer) {
206 case ACPI_TRANSFER_8: 168 case ACPI_TRANSFER_8:
207 acpi_os_printf (" 8-bit only transfer\n"); 169 acpi_os_printf(" 8-bit only transfer\n");
208 break; 170 break;
209 171
210 case ACPI_TRANSFER_8_16: 172 case ACPI_TRANSFER_8_16:
211 acpi_os_printf (" 8 and 16-bit transfer\n"); 173 acpi_os_printf(" 8 and 16-bit transfer\n");
212 break; 174 break;
213 175
214 case ACPI_TRANSFER_16: 176 case ACPI_TRANSFER_16:
215 acpi_os_printf (" 16 bit only transfer\n"); 177 acpi_os_printf(" 16 bit only transfer\n");
216 break; 178 break;
217 179
218 default: 180 default:
219 acpi_os_printf (" Invalid transfer preference\n"); 181 acpi_os_printf(" Invalid transfer preference\n");
220 break; 182 break;
221 } 183 }
222 184
223 acpi_os_printf (" Number of Channels: %X ( ", 185 acpi_os_printf(" Number of Channels: %X ( ",
224 dma_data->number_of_channels); 186 dma_data->number_of_channels);
225 187
226 for (index = 0; index < dma_data->number_of_channels; index++) { 188 for (index = 0; index < dma_data->number_of_channels; index++) {
227 acpi_os_printf ("%X ", dma_data->channels[index]); 189 acpi_os_printf("%X ", dma_data->channels[index]);
228 } 190 }
229 191
230 acpi_os_printf (")\n"); 192 acpi_os_printf(")\n");
231 return; 193 return;
232} 194}
233 195
234
235/******************************************************************************* 196/*******************************************************************************
236 * 197 *
237 * FUNCTION: acpi_rs_dump_start_depend_fns 198 * FUNCTION: acpi_rs_dump_start_depend_fns
@@ -244,58 +205,54 @@ acpi_rs_dump_dma (
244 * 205 *
245 ******************************************************************************/ 206 ******************************************************************************/
246 207
247static void 208static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data)
248acpi_rs_dump_start_depend_fns (
249 union acpi_resource_data *data)
250{ 209{
251 struct acpi_resource_start_dpf *sdf_data = (struct acpi_resource_start_dpf *) data; 210 struct acpi_resource_start_dpf *sdf_data =
252 211 (struct acpi_resource_start_dpf *)data;
253 212
254 ACPI_FUNCTION_ENTRY (); 213 ACPI_FUNCTION_ENTRY();
255 214
256 215 acpi_os_printf("Start Dependent Functions Resource\n");
257 acpi_os_printf ("Start Dependent Functions Resource\n");
258 216
259 switch (sdf_data->compatibility_priority) { 217 switch (sdf_data->compatibility_priority) {
260 case ACPI_GOOD_CONFIGURATION: 218 case ACPI_GOOD_CONFIGURATION:
261 acpi_os_printf (" Good configuration\n"); 219 acpi_os_printf(" Good configuration\n");
262 break; 220 break;
263 221
264 case ACPI_ACCEPTABLE_CONFIGURATION: 222 case ACPI_ACCEPTABLE_CONFIGURATION:
265 acpi_os_printf (" Acceptable configuration\n"); 223 acpi_os_printf(" Acceptable configuration\n");
266 break; 224 break;
267 225
268 case ACPI_SUB_OPTIMAL_CONFIGURATION: 226 case ACPI_SUB_OPTIMAL_CONFIGURATION:
269 acpi_os_printf (" Sub-optimal configuration\n"); 227 acpi_os_printf(" Sub-optimal configuration\n");
270 break; 228 break;
271 229
272 default: 230 default:
273 acpi_os_printf (" Invalid compatibility priority\n"); 231 acpi_os_printf(" Invalid compatibility priority\n");
274 break; 232 break;
275 } 233 }
276 234
277 switch(sdf_data->performance_robustness) { 235 switch (sdf_data->performance_robustness) {
278 case ACPI_GOOD_CONFIGURATION: 236 case ACPI_GOOD_CONFIGURATION:
279 acpi_os_printf (" Good configuration\n"); 237 acpi_os_printf(" Good configuration\n");
280 break; 238 break;
281 239
282 case ACPI_ACCEPTABLE_CONFIGURATION: 240 case ACPI_ACCEPTABLE_CONFIGURATION:
283 acpi_os_printf (" Acceptable configuration\n"); 241 acpi_os_printf(" Acceptable configuration\n");
284 break; 242 break;
285 243
286 case ACPI_SUB_OPTIMAL_CONFIGURATION: 244 case ACPI_SUB_OPTIMAL_CONFIGURATION:
287 acpi_os_printf (" Sub-optimal configuration\n"); 245 acpi_os_printf(" Sub-optimal configuration\n");
288 break; 246 break;
289 247
290 default: 248 default:
291 acpi_os_printf (" Invalid performance robustness preference\n"); 249 acpi_os_printf(" Invalid performance robustness preference\n");
292 break; 250 break;
293 } 251 }
294 252
295 return; 253 return;
296} 254}
297 255
298
299/******************************************************************************* 256/*******************************************************************************
300 * 257 *
301 * FUNCTION: acpi_rs_dump_io 258 * FUNCTION: acpi_rs_dump_io
@@ -308,33 +265,30 @@ acpi_rs_dump_start_depend_fns (
308 * 265 *
309 ******************************************************************************/ 266 ******************************************************************************/
310 267
311static void 268static void acpi_rs_dump_io(union acpi_resource_data *data)
312acpi_rs_dump_io (
313 union acpi_resource_data *data)
314{ 269{
315 struct acpi_resource_io *io_data = (struct acpi_resource_io *) data; 270 struct acpi_resource_io *io_data = (struct acpi_resource_io *)data;
316
317 271
318 ACPI_FUNCTION_ENTRY (); 272 ACPI_FUNCTION_ENTRY();
319 273
274 acpi_os_printf("Io Resource\n");
320 275
321 acpi_os_printf ("Io Resource\n"); 276 acpi_os_printf(" %d bit decode\n",
277 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
322 278
323 acpi_os_printf (" %d bit decode\n", 279 acpi_os_printf(" Range minimum base: %08X\n",
324 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); 280 io_data->min_base_address);
325 281
326 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);
327 284
328 acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address); 285 acpi_os_printf(" Alignment: %08X\n", io_data->alignment);
329 286
330 acpi_os_printf (" Alignment: %08X\n", io_data->alignment); 287 acpi_os_printf(" Range Length: %08X\n", io_data->range_length);
331
332 acpi_os_printf (" Range Length: %08X\n", io_data->range_length);
333 288
334 return; 289 return;
335} 290}
336 291
337
338/******************************************************************************* 292/*******************************************************************************
339 * 293 *
340 * FUNCTION: acpi_rs_dump_fixed_io 294 * FUNCTION: acpi_rs_dump_fixed_io
@@ -347,25 +301,22 @@ acpi_rs_dump_io (
347 * 301 *
348 ******************************************************************************/ 302 ******************************************************************************/
349 303
350static void 304static void acpi_rs_dump_fixed_io(union acpi_resource_data *data)
351acpi_rs_dump_fixed_io (
352 union acpi_resource_data *data)
353{ 305{
354 struct acpi_resource_fixed_io *fixed_io_data = (struct acpi_resource_fixed_io *) data; 306 struct acpi_resource_fixed_io *fixed_io_data =
355 307 (struct acpi_resource_fixed_io *)data;
356 308
357 ACPI_FUNCTION_ENTRY (); 309 ACPI_FUNCTION_ENTRY();
358 310
311 acpi_os_printf("Fixed Io Resource\n");
312 acpi_os_printf(" Range base address: %08X",
313 fixed_io_data->base_address);
359 314
360 acpi_os_printf ("Fixed Io Resource\n"); 315 acpi_os_printf(" Range length: %08X", fixed_io_data->range_length);
361 acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address);
362
363 acpi_os_printf (" Range length: %08X", fixed_io_data->range_length);
364 316
365 return; 317 return;
366} 318}
367 319
368
369/******************************************************************************* 320/*******************************************************************************
370 * 321 *
371 * FUNCTION: acpi_rs_dump_vendor_specific 322 * FUNCTION: acpi_rs_dump_vendor_specific
@@ -378,30 +329,26 @@ acpi_rs_dump_fixed_io (
378 * 329 *
379 ******************************************************************************/ 330 ******************************************************************************/
380 331
381static void 332static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data)
382acpi_rs_dump_vendor_specific (
383 union acpi_resource_data *data)
384{ 333{
385 struct acpi_resource_vendor *vendor_data = (struct acpi_resource_vendor *) data; 334 struct acpi_resource_vendor *vendor_data =
386 u16 index = 0; 335 (struct acpi_resource_vendor *)data;
387 336 u16 index = 0;
388 337
389 ACPI_FUNCTION_ENTRY (); 338 ACPI_FUNCTION_ENTRY();
390 339
340 acpi_os_printf("Vendor Specific Resource\n");
391 341
392 acpi_os_printf ("Vendor Specific Resource\n"); 342 acpi_os_printf(" Length: %08X\n", vendor_data->length);
393
394 acpi_os_printf (" Length: %08X\n", vendor_data->length);
395 343
396 for (index = 0; index < vendor_data->length; index++) { 344 for (index = 0; index < vendor_data->length; index++) {
397 acpi_os_printf (" Byte %X: %08X\n", 345 acpi_os_printf(" Byte %X: %08X\n",
398 index, vendor_data->reserved[index]); 346 index, vendor_data->reserved[index]);
399 } 347 }
400 348
401 return; 349 return;
402} 350}
403 351
404
405/******************************************************************************* 352/*******************************************************************************
406 * 353 *
407 * FUNCTION: acpi_rs_dump_memory24 354 * FUNCTION: acpi_rs_dump_memory24
@@ -414,37 +361,33 @@ acpi_rs_dump_vendor_specific (
414 * 361 *
415 ******************************************************************************/ 362 ******************************************************************************/
416 363
417static void 364static void acpi_rs_dump_memory24(union acpi_resource_data *data)
418acpi_rs_dump_memory24 (
419 union acpi_resource_data *data)
420{ 365{
421 struct acpi_resource_mem24 *memory24_data = (struct acpi_resource_mem24 *) data; 366 struct acpi_resource_mem24 *memory24_data =
422 367 (struct acpi_resource_mem24 *)data;
423 368
424 ACPI_FUNCTION_ENTRY (); 369 ACPI_FUNCTION_ENTRY();
425 370
371 acpi_os_printf("24-Bit Memory Range Resource\n");
426 372
427 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");
428 377
429 acpi_os_printf (" Read%s\n", 378 acpi_os_printf(" Range minimum base: %08X\n",
430 ACPI_READ_WRITE_MEMORY == 379 memory24_data->min_base_address);
431 memory24_data->read_write_attribute ?
432 "/Write" : " only");
433 380
434 acpi_os_printf (" Range minimum base: %08X\n", 381 acpi_os_printf(" Range maximum base: %08X\n",
435 memory24_data->min_base_address); 382 memory24_data->max_base_address);
436 383
437 acpi_os_printf (" Range maximum base: %08X\n", 384 acpi_os_printf(" Alignment: %08X\n", memory24_data->alignment);
438 memory24_data->max_base_address);
439 385
440 acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment); 386 acpi_os_printf(" Range length: %08X\n", memory24_data->range_length);
441
442 acpi_os_printf (" Range length: %08X\n", memory24_data->range_length);
443 387
444 return; 388 return;
445} 389}
446 390
447
448/******************************************************************************* 391/*******************************************************************************
449 * 392 *
450 * FUNCTION: acpi_rs_dump_memory32 393 * FUNCTION: acpi_rs_dump_memory32
@@ -457,37 +400,33 @@ acpi_rs_dump_memory24 (
457 * 400 *
458 ******************************************************************************/ 401 ******************************************************************************/
459 402
460static void 403static void acpi_rs_dump_memory32(union acpi_resource_data *data)
461acpi_rs_dump_memory32 (
462 union acpi_resource_data *data)
463{ 404{
464 struct acpi_resource_mem32 *memory32_data = (struct acpi_resource_mem32 *) data; 405 struct acpi_resource_mem32 *memory32_data =
465 406 (struct acpi_resource_mem32 *)data;
466
467 ACPI_FUNCTION_ENTRY ();
468 407
408 ACPI_FUNCTION_ENTRY();
469 409
470 acpi_os_printf ("32-Bit Memory Range Resource\n"); 410 acpi_os_printf("32-Bit Memory Range Resource\n");
471 411
472 acpi_os_printf (" Read%s\n", 412 acpi_os_printf(" Read%s\n",
473 ACPI_READ_WRITE_MEMORY == 413 ACPI_READ_WRITE_MEMORY ==
474 memory32_data->read_write_attribute ? 414 memory32_data->read_write_attribute ?
475 "/Write" : " only"); 415 "/Write" : " only");
476 416
477 acpi_os_printf (" Range minimum base: %08X\n", 417 acpi_os_printf(" Range minimum base: %08X\n",
478 memory32_data->min_base_address); 418 memory32_data->min_base_address);
479 419
480 acpi_os_printf (" Range maximum base: %08X\n", 420 acpi_os_printf(" Range maximum base: %08X\n",
481 memory32_data->max_base_address); 421 memory32_data->max_base_address);
482 422
483 acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment); 423 acpi_os_printf(" Alignment: %08X\n", memory32_data->alignment);
484 424
485 acpi_os_printf (" Range length: %08X\n", memory32_data->range_length); 425 acpi_os_printf(" Range length: %08X\n", memory32_data->range_length);
486 426
487 return; 427 return;
488} 428}
489 429
490
491/******************************************************************************* 430/*******************************************************************************
492 * 431 *
493 * FUNCTION: acpi_rs_dump_fixed_memory32 432 * FUNCTION: acpi_rs_dump_fixed_memory32
@@ -500,33 +439,29 @@ acpi_rs_dump_memory32 (
500 * 439 *
501 ******************************************************************************/ 440 ******************************************************************************/
502 441
503static void 442static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data)
504acpi_rs_dump_fixed_memory32 (
505 union acpi_resource_data *data)
506{ 443{
507 struct acpi_resource_fixed_mem32 *fixed_memory32_data = 444 struct acpi_resource_fixed_mem32 *fixed_memory32_data =
508 (struct acpi_resource_fixed_mem32 *) data; 445 (struct acpi_resource_fixed_mem32 *)data;
509
510
511 ACPI_FUNCTION_ENTRY ();
512 446
447 ACPI_FUNCTION_ENTRY();
513 448
514 acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n"); 449 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
515 450
516 acpi_os_printf (" Read%s\n", 451 acpi_os_printf(" Read%s\n",
517 ACPI_READ_WRITE_MEMORY == 452 ACPI_READ_WRITE_MEMORY ==
518 fixed_memory32_data->read_write_attribute ? "/Write" : " Only"); 453 fixed_memory32_data->
454 read_write_attribute ? "/Write" : " Only");
519 455
520 acpi_os_printf (" Range base address: %08X\n", 456 acpi_os_printf(" Range base address: %08X\n",
521 fixed_memory32_data->range_base_address); 457 fixed_memory32_data->range_base_address);
522 458
523 acpi_os_printf (" Range length: %08X\n", 459 acpi_os_printf(" Range length: %08X\n",
524 fixed_memory32_data->range_length); 460 fixed_memory32_data->range_length);
525 461
526 return; 462 return;
527} 463}
528 464
529
530/******************************************************************************* 465/*******************************************************************************
531 * 466 *
532 * FUNCTION: acpi_rs_dump_address16 467 * FUNCTION: acpi_rs_dump_address16
@@ -539,134 +474,136 @@ acpi_rs_dump_fixed_memory32 (
539 * 474 *
540 ******************************************************************************/ 475 ******************************************************************************/
541 476
542static void 477static void acpi_rs_dump_address16(union acpi_resource_data *data)
543acpi_rs_dump_address16 (
544 union acpi_resource_data *data)
545{ 478{
546 struct acpi_resource_address16 *address16_data = (struct acpi_resource_address16 *) data; 479 struct acpi_resource_address16 *address16_data =
547 480 (struct acpi_resource_address16 *)data;
548
549 ACPI_FUNCTION_ENTRY ();
550 481
482 ACPI_FUNCTION_ENTRY();
551 483
552 acpi_os_printf ("16-Bit Address Space Resource\n"); 484 acpi_os_printf("16-Bit Address Space Resource\n");
553 acpi_os_printf (" Resource Type: "); 485 acpi_os_printf(" Resource Type: ");
554 486
555 switch (address16_data->resource_type) { 487 switch (address16_data->resource_type) {
556 case ACPI_MEMORY_RANGE: 488 case ACPI_MEMORY_RANGE:
557 489
558 acpi_os_printf ("Memory Range\n"); 490 acpi_os_printf("Memory Range\n");
559 491
560 switch (address16_data->attribute.memory.cache_attribute) { 492 switch (address16_data->attribute.memory.cache_attribute) {
561 case ACPI_NON_CACHEABLE_MEMORY: 493 case ACPI_NON_CACHEABLE_MEMORY:
562 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 494 acpi_os_printf
495 (" Type Specific: Noncacheable memory\n");
563 break; 496 break;
564 497
565 case ACPI_CACHABLE_MEMORY: 498 case ACPI_CACHABLE_MEMORY:
566 acpi_os_printf (" Type Specific: Cacheable memory\n"); 499 acpi_os_printf(" Type Specific: Cacheable memory\n");
567 break; 500 break;
568 501
569 case ACPI_WRITE_COMBINING_MEMORY: 502 case ACPI_WRITE_COMBINING_MEMORY:
570 acpi_os_printf (" Type Specific: Write-combining memory\n"); 503 acpi_os_printf
504 (" Type Specific: Write-combining memory\n");
571 break; 505 break;
572 506
573 case ACPI_PREFETCHABLE_MEMORY: 507 case ACPI_PREFETCHABLE_MEMORY:
574 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 508 acpi_os_printf
509 (" Type Specific: Prefetchable memory\n");
575 break; 510 break;
576 511
577 default: 512 default:
578 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 513 acpi_os_printf
514 (" Type Specific: Invalid cache attribute\n");
579 break; 515 break;
580 } 516 }
581 517
582 acpi_os_printf (" Type Specific: Read%s\n", 518 acpi_os_printf(" Type Specific: Read%s\n",
583 ACPI_READ_WRITE_MEMORY == 519 ACPI_READ_WRITE_MEMORY ==
584 address16_data->attribute.memory.read_write_attribute ? 520 address16_data->attribute.memory.
585 "/Write" : " Only"); 521 read_write_attribute ? "/Write" : " Only");
586 break; 522 break;
587 523
588 case ACPI_IO_RANGE: 524 case ACPI_IO_RANGE:
589 525
590 acpi_os_printf ("I/O Range\n"); 526 acpi_os_printf("I/O Range\n");
591 527
592 switch (address16_data->attribute.io.range_attribute) { 528 switch (address16_data->attribute.io.range_attribute) {
593 case ACPI_NON_ISA_ONLY_RANGES: 529 case ACPI_NON_ISA_ONLY_RANGES:
594 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 530 acpi_os_printf
531 (" Type Specific: Non-ISA Io Addresses\n");
595 break; 532 break;
596 533
597 case ACPI_ISA_ONLY_RANGES: 534 case ACPI_ISA_ONLY_RANGES:
598 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 535 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
599 break; 536 break;
600 537
601 case ACPI_ENTIRE_RANGE: 538 case ACPI_ENTIRE_RANGE:
602 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");
603 break; 541 break;
604 542
605 default: 543 default:
606 acpi_os_printf (" Type Specific: Invalid range attribute\n"); 544 acpi_os_printf
545 (" Type Specific: Invalid range attribute\n");
607 break; 546 break;
608 } 547 }
609 548
610 acpi_os_printf (" Type Specific: %s Translation\n", 549 acpi_os_printf(" Type Specific: %s Translation\n",
611 ACPI_SPARSE_TRANSLATION == 550 ACPI_SPARSE_TRANSLATION ==
612 address16_data->attribute.io.translation_attribute ? 551 address16_data->attribute.io.
613 "Sparse" : "Dense"); 552 translation_attribute ? "Sparse" : "Dense");
614 break; 553 break;
615 554
616 case ACPI_BUS_NUMBER_RANGE: 555 case ACPI_BUS_NUMBER_RANGE:
617 556
618 acpi_os_printf ("Bus Number Range\n"); 557 acpi_os_printf("Bus Number Range\n");
619 break; 558 break;
620 559
621 default: 560 default:
622 561
623 acpi_os_printf ("0x%2.2X\n", address16_data->resource_type); 562 acpi_os_printf("0x%2.2X\n", address16_data->resource_type);
624 break; 563 break;
625 } 564 }
626 565
627 acpi_os_printf (" Resource %s\n", 566 acpi_os_printf(" Resource %s\n",
628 ACPI_CONSUMER == address16_data->producer_consumer ? 567 ACPI_CONSUMER == address16_data->producer_consumer ?
629 "Consumer" : "Producer"); 568 "Consumer" : "Producer");
630 569
631 acpi_os_printf (" %s decode\n", 570 acpi_os_printf(" %s decode\n",
632 ACPI_SUB_DECODE == address16_data->decode ? 571 ACPI_SUB_DECODE == address16_data->decode ?
633 "Subtractive" : "Positive"); 572 "Subtractive" : "Positive");
634 573
635 acpi_os_printf (" Min address is %s fixed\n", 574 acpi_os_printf(" Min address is %s fixed\n",
636 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? 575 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
637 "" : "not"); 576 "" : "not");
638 577
639 acpi_os_printf (" Max address is %s fixed\n", 578 acpi_os_printf(" Max address is %s fixed\n",
640 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? 579 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
641 "" : "not"); 580 "" : "not");
642 581
643 acpi_os_printf (" Granularity: %08X\n", 582 acpi_os_printf(" Granularity: %08X\n", address16_data->granularity);
644 address16_data->granularity);
645 583
646 acpi_os_printf (" Address range min: %08X\n", 584 acpi_os_printf(" Address range min: %08X\n",
647 address16_data->min_address_range); 585 address16_data->min_address_range);
648 586
649 acpi_os_printf (" Address range max: %08X\n", 587 acpi_os_printf(" Address range max: %08X\n",
650 address16_data->max_address_range); 588 address16_data->max_address_range);
651 589
652 acpi_os_printf (" Address translation offset: %08X\n", 590 acpi_os_printf(" Address translation offset: %08X\n",
653 address16_data->address_translation_offset); 591 address16_data->address_translation_offset);
654 592
655 acpi_os_printf (" Address Length: %08X\n", 593 acpi_os_printf(" Address Length: %08X\n",
656 address16_data->address_length); 594 address16_data->address_length);
657 595
658 if (0xFF != address16_data->resource_source.index) { 596 if (0xFF != address16_data->resource_source.index) {
659 acpi_os_printf (" Resource Source Index: %X\n", 597 acpi_os_printf(" Resource Source Index: %X\n",
660 address16_data->resource_source.index); 598 address16_data->resource_source.index);
661 599
662 acpi_os_printf (" Resource Source: %s\n", 600 acpi_os_printf(" Resource Source: %s\n",
663 address16_data->resource_source.string_ptr); 601 address16_data->resource_source.string_ptr);
664 } 602 }
665 603
666 return; 604 return;
667} 605}
668 606
669
670/******************************************************************************* 607/*******************************************************************************
671 * 608 *
672 * FUNCTION: acpi_rs_dump_address32 609 * FUNCTION: acpi_rs_dump_address32
@@ -679,134 +616,136 @@ acpi_rs_dump_address16 (
679 * 616 *
680 ******************************************************************************/ 617 ******************************************************************************/
681 618
682static void 619static void acpi_rs_dump_address32(union acpi_resource_data *data)
683acpi_rs_dump_address32 (
684 union acpi_resource_data *data)
685{ 620{
686 struct acpi_resource_address32 *address32_data = (struct acpi_resource_address32 *) data; 621 struct acpi_resource_address32 *address32_data =
687 622 (struct acpi_resource_address32 *)data;
688
689 ACPI_FUNCTION_ENTRY ();
690 623
624 ACPI_FUNCTION_ENTRY();
691 625
692 acpi_os_printf ("32-Bit Address Space Resource\n"); 626 acpi_os_printf("32-Bit Address Space Resource\n");
693 627
694 switch (address32_data->resource_type) { 628 switch (address32_data->resource_type) {
695 case ACPI_MEMORY_RANGE: 629 case ACPI_MEMORY_RANGE:
696 630
697 acpi_os_printf (" Resource Type: Memory Range\n"); 631 acpi_os_printf(" Resource Type: Memory Range\n");
698 632
699 switch (address32_data->attribute.memory.cache_attribute) { 633 switch (address32_data->attribute.memory.cache_attribute) {
700 case ACPI_NON_CACHEABLE_MEMORY: 634 case ACPI_NON_CACHEABLE_MEMORY:
701 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 635 acpi_os_printf
636 (" Type Specific: Noncacheable memory\n");
702 break; 637 break;
703 638
704 case ACPI_CACHABLE_MEMORY: 639 case ACPI_CACHABLE_MEMORY:
705 acpi_os_printf (" Type Specific: Cacheable memory\n"); 640 acpi_os_printf(" Type Specific: Cacheable memory\n");
706 break; 641 break;
707 642
708 case ACPI_WRITE_COMBINING_MEMORY: 643 case ACPI_WRITE_COMBINING_MEMORY:
709 acpi_os_printf (" Type Specific: Write-combining memory\n"); 644 acpi_os_printf
645 (" Type Specific: Write-combining memory\n");
710 break; 646 break;
711 647
712 case ACPI_PREFETCHABLE_MEMORY: 648 case ACPI_PREFETCHABLE_MEMORY:
713 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 649 acpi_os_printf
650 (" Type Specific: Prefetchable memory\n");
714 break; 651 break;
715 652
716 default: 653 default:
717 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 654 acpi_os_printf
655 (" Type Specific: Invalid cache attribute\n");
718 break; 656 break;
719 } 657 }
720 658
721 acpi_os_printf (" Type Specific: Read%s\n", 659 acpi_os_printf(" Type Specific: Read%s\n",
722 ACPI_READ_WRITE_MEMORY == 660 ACPI_READ_WRITE_MEMORY ==
723 address32_data->attribute.memory.read_write_attribute ? 661 address32_data->attribute.memory.
724 "/Write" : " Only"); 662 read_write_attribute ? "/Write" : " Only");
725 break; 663 break;
726 664
727 case ACPI_IO_RANGE: 665 case ACPI_IO_RANGE:
728 666
729 acpi_os_printf (" Resource Type: Io Range\n"); 667 acpi_os_printf(" Resource Type: Io Range\n");
730 668
731 switch (address32_data->attribute.io.range_attribute) { 669 switch (address32_data->attribute.io.range_attribute) {
732 case ACPI_NON_ISA_ONLY_RANGES: 670 case ACPI_NON_ISA_ONLY_RANGES:
733 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 671 acpi_os_printf
672 (" Type Specific: Non-ISA Io Addresses\n");
734 break; 673 break;
735 674
736 case ACPI_ISA_ONLY_RANGES: 675 case ACPI_ISA_ONLY_RANGES:
737 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 676 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
738 break; 677 break;
739 678
740 case ACPI_ENTIRE_RANGE: 679 case ACPI_ENTIRE_RANGE:
741 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");
742 break; 682 break;
743 683
744 default: 684 default:
745 acpi_os_printf (" Type Specific: Invalid Range attribute"); 685 acpi_os_printf
686 (" Type Specific: Invalid Range attribute");
746 break; 687 break;
747 } 688 }
748 689
749 acpi_os_printf (" Type Specific: %s Translation\n", 690 acpi_os_printf(" Type Specific: %s Translation\n",
750 ACPI_SPARSE_TRANSLATION == 691 ACPI_SPARSE_TRANSLATION ==
751 address32_data->attribute.io.translation_attribute ? 692 address32_data->attribute.io.
752 "Sparse" : "Dense"); 693 translation_attribute ? "Sparse" : "Dense");
753 break; 694 break;
754 695
755 case ACPI_BUS_NUMBER_RANGE: 696 case ACPI_BUS_NUMBER_RANGE:
756 697
757 acpi_os_printf (" Resource Type: Bus Number Range\n"); 698 acpi_os_printf(" Resource Type: Bus Number Range\n");
758 break; 699 break;
759 700
760 default: 701 default:
761 702
762 acpi_os_printf (" Resource Type: 0x%2.2X\n", 703 acpi_os_printf(" Resource Type: 0x%2.2X\n",
763 address32_data->resource_type); 704 address32_data->resource_type);
764 break; 705 break;
765 } 706 }
766 707
767 acpi_os_printf (" Resource %s\n", 708 acpi_os_printf(" Resource %s\n",
768 ACPI_CONSUMER == address32_data->producer_consumer ? 709 ACPI_CONSUMER == address32_data->producer_consumer ?
769 "Consumer" : "Producer"); 710 "Consumer" : "Producer");
770 711
771 acpi_os_printf (" %s decode\n", 712 acpi_os_printf(" %s decode\n",
772 ACPI_SUB_DECODE == address32_data->decode ? 713 ACPI_SUB_DECODE == address32_data->decode ?
773 "Subtractive" : "Positive"); 714 "Subtractive" : "Positive");
774 715
775 acpi_os_printf (" Min address is %s fixed\n", 716 acpi_os_printf(" Min address is %s fixed\n",
776 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? 717 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
777 "" : "not "); 718 "" : "not ");
778 719
779 acpi_os_printf (" Max address is %s fixed\n", 720 acpi_os_printf(" Max address is %s fixed\n",
780 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? 721 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
781 "" : "not "); 722 "" : "not ");
782 723
783 acpi_os_printf (" Granularity: %08X\n", 724 acpi_os_printf(" Granularity: %08X\n", address32_data->granularity);
784 address32_data->granularity);
785 725
786 acpi_os_printf (" Address range min: %08X\n", 726 acpi_os_printf(" Address range min: %08X\n",
787 address32_data->min_address_range); 727 address32_data->min_address_range);
788 728
789 acpi_os_printf (" Address range max: %08X\n", 729 acpi_os_printf(" Address range max: %08X\n",
790 address32_data->max_address_range); 730 address32_data->max_address_range);
791 731
792 acpi_os_printf (" Address translation offset: %08X\n", 732 acpi_os_printf(" Address translation offset: %08X\n",
793 address32_data->address_translation_offset); 733 address32_data->address_translation_offset);
794 734
795 acpi_os_printf (" Address Length: %08X\n", 735 acpi_os_printf(" Address Length: %08X\n",
796 address32_data->address_length); 736 address32_data->address_length);
797 737
798 if(0xFF != address32_data->resource_source.index) { 738 if (0xFF != address32_data->resource_source.index) {
799 acpi_os_printf (" Resource Source Index: %X\n", 739 acpi_os_printf(" Resource Source Index: %X\n",
800 address32_data->resource_source.index); 740 address32_data->resource_source.index);
801 741
802 acpi_os_printf (" Resource Source: %s\n", 742 acpi_os_printf(" Resource Source: %s\n",
803 address32_data->resource_source.string_ptr); 743 address32_data->resource_source.string_ptr);
804 } 744 }
805 745
806 return; 746 return;
807} 747}
808 748
809
810/******************************************************************************* 749/*******************************************************************************
811 * 750 *
812 * FUNCTION: acpi_rs_dump_address64 751 * FUNCTION: acpi_rs_dump_address64
@@ -819,137 +758,142 @@ acpi_rs_dump_address32 (
819 * 758 *
820 ******************************************************************************/ 759 ******************************************************************************/
821 760
822static void 761static void acpi_rs_dump_address64(union acpi_resource_data *data)
823acpi_rs_dump_address64 (
824 union acpi_resource_data *data)
825{ 762{
826 struct acpi_resource_address64 *address64_data = (struct acpi_resource_address64 *) data; 763 struct acpi_resource_address64 *address64_data =
827 764 (struct acpi_resource_address64 *)data;
828
829 ACPI_FUNCTION_ENTRY ();
830 765
766 ACPI_FUNCTION_ENTRY();
831 767
832 acpi_os_printf ("64-Bit Address Space Resource\n"); 768 acpi_os_printf("64-Bit Address Space Resource\n");
833 769
834 switch (address64_data->resource_type) { 770 switch (address64_data->resource_type) {
835 case ACPI_MEMORY_RANGE: 771 case ACPI_MEMORY_RANGE:
836 772
837 acpi_os_printf (" Resource Type: Memory Range\n"); 773 acpi_os_printf(" Resource Type: Memory Range\n");
838 774
839 switch (address64_data->attribute.memory.cache_attribute) { 775 switch (address64_data->attribute.memory.cache_attribute) {
840 case ACPI_NON_CACHEABLE_MEMORY: 776 case ACPI_NON_CACHEABLE_MEMORY:
841 acpi_os_printf (" Type Specific: Noncacheable memory\n"); 777 acpi_os_printf
778 (" Type Specific: Noncacheable memory\n");
842 break; 779 break;
843 780
844 case ACPI_CACHABLE_MEMORY: 781 case ACPI_CACHABLE_MEMORY:
845 acpi_os_printf (" Type Specific: Cacheable memory\n"); 782 acpi_os_printf(" Type Specific: Cacheable memory\n");
846 break; 783 break;
847 784
848 case ACPI_WRITE_COMBINING_MEMORY: 785 case ACPI_WRITE_COMBINING_MEMORY:
849 acpi_os_printf (" Type Specific: Write-combining memory\n"); 786 acpi_os_printf
787 (" Type Specific: Write-combining memory\n");
850 break; 788 break;
851 789
852 case ACPI_PREFETCHABLE_MEMORY: 790 case ACPI_PREFETCHABLE_MEMORY:
853 acpi_os_printf (" Type Specific: Prefetchable memory\n"); 791 acpi_os_printf
792 (" Type Specific: Prefetchable memory\n");
854 break; 793 break;
855 794
856 default: 795 default:
857 acpi_os_printf (" Type Specific: Invalid cache attribute\n"); 796 acpi_os_printf
797 (" Type Specific: Invalid cache attribute\n");
858 break; 798 break;
859 } 799 }
860 800
861 acpi_os_printf (" Type Specific: Read%s\n", 801 acpi_os_printf(" Type Specific: Read%s\n",
862 ACPI_READ_WRITE_MEMORY == 802 ACPI_READ_WRITE_MEMORY ==
863 address64_data->attribute.memory.read_write_attribute ? 803 address64_data->attribute.memory.
864 "/Write" : " Only"); 804 read_write_attribute ? "/Write" : " Only");
865 break; 805 break;
866 806
867 case ACPI_IO_RANGE: 807 case ACPI_IO_RANGE:
868 808
869 acpi_os_printf (" Resource Type: Io Range\n"); 809 acpi_os_printf(" Resource Type: Io Range\n");
870 810
871 switch (address64_data->attribute.io.range_attribute) { 811 switch (address64_data->attribute.io.range_attribute) {
872 case ACPI_NON_ISA_ONLY_RANGES: 812 case ACPI_NON_ISA_ONLY_RANGES:
873 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); 813 acpi_os_printf
814 (" Type Specific: Non-ISA Io Addresses\n");
874 break; 815 break;
875 816
876 case ACPI_ISA_ONLY_RANGES: 817 case ACPI_ISA_ONLY_RANGES:
877 acpi_os_printf (" Type Specific: ISA Io Addresses\n"); 818 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
878 break; 819 break;
879 820
880 case ACPI_ENTIRE_RANGE: 821 case ACPI_ENTIRE_RANGE:
881 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");
882 break; 824 break;
883 825
884 default: 826 default:
885 acpi_os_printf (" Type Specific: Invalid Range attribute"); 827 acpi_os_printf
828 (" Type Specific: Invalid Range attribute");
886 break; 829 break;
887 } 830 }
888 831
889 acpi_os_printf (" Type Specific: %s Translation\n", 832 acpi_os_printf(" Type Specific: %s Translation\n",
890 ACPI_SPARSE_TRANSLATION == 833 ACPI_SPARSE_TRANSLATION ==
891 address64_data->attribute.io.translation_attribute ? 834 address64_data->attribute.io.
892 "Sparse" : "Dense"); 835 translation_attribute ? "Sparse" : "Dense");
893 break; 836 break;
894 837
895 case ACPI_BUS_NUMBER_RANGE: 838 case ACPI_BUS_NUMBER_RANGE:
896 839
897 acpi_os_printf (" Resource Type: Bus Number Range\n"); 840 acpi_os_printf(" Resource Type: Bus Number Range\n");
898 break; 841 break;
899 842
900 default: 843 default:
901 844
902 acpi_os_printf (" Resource Type: 0x%2.2X\n", 845 acpi_os_printf(" Resource Type: 0x%2.2X\n",
903 address64_data->resource_type); 846 address64_data->resource_type);
904 break; 847 break;
905 } 848 }
906 849
907 acpi_os_printf (" Resource %s\n", 850 acpi_os_printf(" Resource %s\n",
908 ACPI_CONSUMER == address64_data->producer_consumer ? 851 ACPI_CONSUMER == address64_data->producer_consumer ?
909 "Consumer" : "Producer"); 852 "Consumer" : "Producer");
910 853
911 acpi_os_printf (" %s decode\n", 854 acpi_os_printf(" %s decode\n",
912 ACPI_SUB_DECODE == address64_data->decode ? 855 ACPI_SUB_DECODE == address64_data->decode ?
913 "Subtractive" : "Positive"); 856 "Subtractive" : "Positive");
914 857
915 acpi_os_printf (" Min address is %s fixed\n", 858 acpi_os_printf(" Min address is %s fixed\n",
916 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? 859 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
917 "" : "not "); 860 "" : "not ");
918 861
919 acpi_os_printf (" Max address is %s fixed\n", 862 acpi_os_printf(" Max address is %s fixed\n",
920 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? 863 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
921 "" : "not "); 864 "" : "not ");
922 865
923 acpi_os_printf (" Granularity: %8.8X%8.8X\n", 866 acpi_os_printf(" Granularity: %8.8X%8.8X\n",
924 ACPI_FORMAT_UINT64 (address64_data->granularity)); 867 ACPI_FORMAT_UINT64(address64_data->granularity));
925 868
926 acpi_os_printf (" Address range min: %8.8X%8.8X\n", 869 acpi_os_printf(" Address range min: %8.8X%8.8X\n",
927 ACPI_FORMAT_UINT64 (address64_data->min_address_range)); 870 ACPI_FORMAT_UINT64(address64_data->min_address_range));
928 871
929 acpi_os_printf (" Address range max: %8.8X%8.8X\n", 872 acpi_os_printf(" Address range max: %8.8X%8.8X\n",
930 ACPI_FORMAT_UINT64 (address64_data->max_address_range)); 873 ACPI_FORMAT_UINT64(address64_data->max_address_range));
931 874
932 acpi_os_printf (" Address translation offset: %8.8X%8.8X\n", 875 acpi_os_printf(" Address translation offset: %8.8X%8.8X\n",
933 ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); 876 ACPI_FORMAT_UINT64(address64_data->
877 address_translation_offset));
934 878
935 acpi_os_printf (" Address Length: %8.8X%8.8X\n", 879 acpi_os_printf(" Address Length: %8.8X%8.8X\n",
936 ACPI_FORMAT_UINT64 (address64_data->address_length)); 880 ACPI_FORMAT_UINT64(address64_data->address_length));
937 881
938 acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n", 882 acpi_os_printf(" Type Specific Attributes: %8.8X%8.8X\n",
939 ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); 883 ACPI_FORMAT_UINT64(address64_data->
884 type_specific_attributes));
940 885
941 if (0xFF != address64_data->resource_source.index) { 886 if (0xFF != address64_data->resource_source.index) {
942 acpi_os_printf (" Resource Source Index: %X\n", 887 acpi_os_printf(" Resource Source Index: %X\n",
943 address64_data->resource_source.index); 888 address64_data->resource_source.index);
944 889
945 acpi_os_printf (" Resource Source: %s\n", 890 acpi_os_printf(" Resource Source: %s\n",
946 address64_data->resource_source.string_ptr); 891 address64_data->resource_source.string_ptr);
947 } 892 }
948 893
949 return; 894 return;
950} 895}
951 896
952
953/******************************************************************************* 897/*******************************************************************************
954 * 898 *
955 * FUNCTION: acpi_rs_dump_extended_irq 899 * FUNCTION: acpi_rs_dump_extended_irq
@@ -962,55 +906,52 @@ acpi_rs_dump_address64 (
962 * 906 *
963 ******************************************************************************/ 907 ******************************************************************************/
964 908
965static void 909static void acpi_rs_dump_extended_irq(union acpi_resource_data *data)
966acpi_rs_dump_extended_irq (
967 union acpi_resource_data *data)
968{ 910{
969 struct acpi_resource_ext_irq *ext_irq_data = (struct acpi_resource_ext_irq *) data; 911 struct acpi_resource_ext_irq *ext_irq_data =
970 u8 index = 0; 912 (struct acpi_resource_ext_irq *)data;
971 913 u8 index = 0;
972
973 ACPI_FUNCTION_ENTRY ();
974 914
915 ACPI_FUNCTION_ENTRY();
975 916
976 acpi_os_printf ("Extended IRQ Resource\n"); 917 acpi_os_printf("Extended IRQ Resource\n");
977 918
978 acpi_os_printf (" Resource %s\n", 919 acpi_os_printf(" Resource %s\n",
979 ACPI_CONSUMER == ext_irq_data->producer_consumer ? 920 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
980 "Consumer" : "Producer"); 921 "Consumer" : "Producer");
981 922
982 acpi_os_printf (" %s\n", 923 acpi_os_printf(" %s\n",
983 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? 924 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
984 "Level" : "Edge"); 925 "Level" : "Edge");
985 926
986 acpi_os_printf (" Active %s\n", 927 acpi_os_printf(" Active %s\n",
987 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? 928 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
988 "low" : "high"); 929 "low" : "high");
989 930
990 acpi_os_printf (" %s\n", 931 acpi_os_printf(" %s\n",
991 ACPI_SHARED == ext_irq_data->shared_exclusive ? 932 ACPI_SHARED == ext_irq_data->shared_exclusive ?
992 "Shared" : "Exclusive"); 933 "Shared" : "Exclusive");
993 934
994 acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts); 935 acpi_os_printf(" Interrupts : %X ( ",
936 ext_irq_data->number_of_interrupts);
995 937
996 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { 938 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
997 acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); 939 acpi_os_printf("%X ", ext_irq_data->interrupts[index]);
998 } 940 }
999 941
1000 acpi_os_printf (")\n"); 942 acpi_os_printf(")\n");
1001 943
1002 if(0xFF != ext_irq_data->resource_source.index) { 944 if (0xFF != ext_irq_data->resource_source.index) {
1003 acpi_os_printf (" Resource Source Index: %X", 945 acpi_os_printf(" Resource Source Index: %X",
1004 ext_irq_data->resource_source.index); 946 ext_irq_data->resource_source.index);
1005 947
1006 acpi_os_printf (" Resource Source: %s", 948 acpi_os_printf(" Resource Source: %s",
1007 ext_irq_data->resource_source.string_ptr); 949 ext_irq_data->resource_source.string_ptr);
1008 } 950 }
1009 951
1010 return; 952 return;
1011} 953}
1012 954
1013
1014/******************************************************************************* 955/*******************************************************************************
1015 * 956 *
1016 * FUNCTION: acpi_rs_dump_resource_list 957 * FUNCTION: acpi_rs_dump_resource_list
@@ -1023,92 +964,91 @@ acpi_rs_dump_extended_irq (
1023 * 964 *
1024 ******************************************************************************/ 965 ******************************************************************************/
1025 966
1026void 967void acpi_rs_dump_resource_list(struct acpi_resource *resource)
1027acpi_rs_dump_resource_list (
1028 struct acpi_resource *resource)
1029{ 968{
1030 u8 count = 0; 969 u8 count = 0;
1031 u8 done = FALSE; 970 u8 done = FALSE;
1032
1033
1034 ACPI_FUNCTION_ENTRY ();
1035 971
972 ACPI_FUNCTION_ENTRY();
1036 973
1037 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 974 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
1038 while (!done) { 975 while (!done) {
1039 acpi_os_printf ("Resource structure %X.\n", count++); 976 acpi_os_printf("Resource structure %X.\n", count++);
1040 977
1041 switch (resource->id) { 978 switch (resource->id) {
1042 case ACPI_RSTYPE_IRQ: 979 case ACPI_RSTYPE_IRQ:
1043 acpi_rs_dump_irq (&resource->data); 980 acpi_rs_dump_irq(&resource->data);
1044 break; 981 break;
1045 982
1046 case ACPI_RSTYPE_DMA: 983 case ACPI_RSTYPE_DMA:
1047 acpi_rs_dump_dma (&resource->data); 984 acpi_rs_dump_dma(&resource->data);
1048 break; 985 break;
1049 986
1050 case ACPI_RSTYPE_START_DPF: 987 case ACPI_RSTYPE_START_DPF:
1051 acpi_rs_dump_start_depend_fns (&resource->data); 988 acpi_rs_dump_start_depend_fns(&resource->data);
1052 break; 989 break;
1053 990
1054 case ACPI_RSTYPE_END_DPF: 991 case ACPI_RSTYPE_END_DPF:
1055 acpi_os_printf ("end_dependent_functions Resource\n"); 992 acpi_os_printf
1056 /* acpi_rs_dump_end_dependent_functions (Resource->Data);*/ 993 ("end_dependent_functions Resource\n");
994 /* acpi_rs_dump_end_dependent_functions (Resource->Data); */
1057 break; 995 break;
1058 996
1059 case ACPI_RSTYPE_IO: 997 case ACPI_RSTYPE_IO:
1060 acpi_rs_dump_io (&resource->data); 998 acpi_rs_dump_io(&resource->data);
1061 break; 999 break;
1062 1000
1063 case ACPI_RSTYPE_FIXED_IO: 1001 case ACPI_RSTYPE_FIXED_IO:
1064 acpi_rs_dump_fixed_io (&resource->data); 1002 acpi_rs_dump_fixed_io(&resource->data);
1065 break; 1003 break;
1066 1004
1067 case ACPI_RSTYPE_VENDOR: 1005 case ACPI_RSTYPE_VENDOR:
1068 acpi_rs_dump_vendor_specific (&resource->data); 1006 acpi_rs_dump_vendor_specific(&resource->data);
1069 break; 1007 break;
1070 1008
1071 case ACPI_RSTYPE_END_TAG: 1009 case ACPI_RSTYPE_END_TAG:
1072 /*rs_dump_end_tag (Resource->Data);*/ 1010 /*rs_dump_end_tag (Resource->Data); */
1073 acpi_os_printf ("end_tag Resource\n"); 1011 acpi_os_printf("end_tag Resource\n");
1074 done = TRUE; 1012 done = TRUE;
1075 break; 1013 break;
1076 1014
1077 case ACPI_RSTYPE_MEM24: 1015 case ACPI_RSTYPE_MEM24:
1078 acpi_rs_dump_memory24 (&resource->data); 1016 acpi_rs_dump_memory24(&resource->data);
1079 break; 1017 break;
1080 1018
1081 case ACPI_RSTYPE_MEM32: 1019 case ACPI_RSTYPE_MEM32:
1082 acpi_rs_dump_memory32 (&resource->data); 1020 acpi_rs_dump_memory32(&resource->data);
1083 break; 1021 break;
1084 1022
1085 case ACPI_RSTYPE_FIXED_MEM32: 1023 case ACPI_RSTYPE_FIXED_MEM32:
1086 acpi_rs_dump_fixed_memory32 (&resource->data); 1024 acpi_rs_dump_fixed_memory32(&resource->data);
1087 break; 1025 break;
1088 1026
1089 case ACPI_RSTYPE_ADDRESS16: 1027 case ACPI_RSTYPE_ADDRESS16:
1090 acpi_rs_dump_address16 (&resource->data); 1028 acpi_rs_dump_address16(&resource->data);
1091 break; 1029 break;
1092 1030
1093 case ACPI_RSTYPE_ADDRESS32: 1031 case ACPI_RSTYPE_ADDRESS32:
1094 acpi_rs_dump_address32 (&resource->data); 1032 acpi_rs_dump_address32(&resource->data);
1095 break; 1033 break;
1096 1034
1097 case ACPI_RSTYPE_ADDRESS64: 1035 case ACPI_RSTYPE_ADDRESS64:
1098 acpi_rs_dump_address64 (&resource->data); 1036 acpi_rs_dump_address64(&resource->data);
1099 break; 1037 break;
1100 1038
1101 case ACPI_RSTYPE_EXT_IRQ: 1039 case ACPI_RSTYPE_EXT_IRQ:
1102 acpi_rs_dump_extended_irq (&resource->data); 1040 acpi_rs_dump_extended_irq(&resource->data);
1103 break; 1041 break;
1104 1042
1105 default: 1043 default:
1106 acpi_os_printf ("Invalid resource type\n"); 1044 acpi_os_printf("Invalid resource type\n");
1107 break; 1045 break;
1108 1046
1109 } 1047 }
1110 1048
1111 resource = ACPI_PTR_ADD (struct acpi_resource, resource, resource->length); 1049 resource =
1050 ACPI_PTR_ADD(struct acpi_resource, resource,
1051 resource->length);
1112 } 1052 }
1113 } 1053 }
1114 1054
@@ -1127,36 +1067,38 @@ acpi_rs_dump_resource_list (
1127 * 1067 *
1128 ******************************************************************************/ 1068 ******************************************************************************/
1129 1069
1130void 1070void acpi_rs_dump_irq_list(u8 * route_table)
1131acpi_rs_dump_irq_list (
1132 u8 *route_table)
1133{ 1071{
1134 u8 *buffer = route_table; 1072 u8 *buffer = route_table;
1135 u8 count = 0; 1073 u8 count = 0;
1136 u8 done = FALSE; 1074 u8 done = FALSE;
1137 struct acpi_pci_routing_table *prt_element; 1075 struct acpi_pci_routing_table *prt_element;
1138
1139
1140 ACPI_FUNCTION_ENTRY ();
1141 1076
1077 ACPI_FUNCTION_ENTRY();
1142 1078
1143 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 1079 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
1144 prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 1080 prt_element =
1081 ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
1145 1082
1146 while (!done) { 1083 while (!done) {
1147 acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++); 1084 acpi_os_printf("PCI IRQ Routing Table structure %X.\n",
1085 count++);
1148 1086
1149 acpi_os_printf (" Address: %8.8X%8.8X\n", 1087 acpi_os_printf(" Address: %8.8X%8.8X\n",
1150 ACPI_FORMAT_UINT64 (prt_element->address)); 1088 ACPI_FORMAT_UINT64(prt_element->
1089 address));
1151 1090
1152 acpi_os_printf (" Pin: %X\n", prt_element->pin); 1091 acpi_os_printf(" Pin: %X\n", prt_element->pin);
1153 1092
1154 acpi_os_printf (" Source: %s\n", prt_element->source); 1093 acpi_os_printf(" Source: %s\n", prt_element->source);
1155 1094
1156 acpi_os_printf (" source_index: %X\n", prt_element->source_index); 1095 acpi_os_printf(" source_index: %X\n",
1096 prt_element->source_index);
1157 1097
1158 buffer += prt_element->length; 1098 buffer += prt_element->length;
1159 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);
1160 if (0 == prt_element->length) { 1102 if (0 == prt_element->length) {
1161 done = TRUE; 1103 done = TRUE;
1162 } 1104 }
@@ -1167,4 +1109,3 @@ acpi_rs_dump_irq_list (
1167} 1109}
1168 1110
1169#endif 1111#endif
1170
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..7179b6243f5b 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 /* Point past the Descriptor to get the number of bytes consumed */
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,10 +390,10 @@ 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
@@ -426,7 +409,8 @@ acpi_rs_extended_irq_resource (
426 /* Add the terminating null */ 409 /* Add the terminating null */
427 410
428 *temp_ptr = 0x00; 411 *temp_ptr = 0x00;
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 {
440 output_struct->data.extended_irq.resource_source.index = 0x00; 423 output_struct->data.extended_irq.resource_source.index = 0x00;
441 output_struct->data.extended_irq.resource_source.string_length = 0; 424 output_struct->data.extended_irq.resource_source.string_length =
442 output_struct->data.extended_irq.resource_source.string_ptr = NULL; 425 0;
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,20 +454,16 @@ 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; 464 char *temp_pointer = NULL;
483
484
485 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
486 465
466 ACPI_FUNCTION_TRACE("rs_extended_irq_stream");
487 467
488 /* The descriptor field is static */ 468 /* The descriptor field is static */
489 469
@@ -492,13 +472,14 @@ acpi_rs_extended_irq_stream (
492 472
493 /* Set a pointer to the Length field - to be filled in later */ 473 /* Set a pointer to the Length field - to be filled in later */
494 474
495 length_field = ACPI_CAST_PTR (u16, buffer); 475 length_field = ACPI_CAST_PTR(u16, buffer);
496 buffer += 2; 476 buffer += 2;
497 477
498 /* Set the Interrupt vector flags */ 478 /* Set the Interrupt vector flags */
499 479
500 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); 480 temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01);
501 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); 481 temp8 |=
482 ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
502 483
503 /* 484 /*
504 * Set the Interrupt Mode 485 * Set the Interrupt Mode
@@ -527,43 +508,48 @@ acpi_rs_extended_irq_stream (
527 *buffer = temp8; 508 *buffer = temp8;
528 buffer += 1; 509 buffer += 1;
529 510
530 for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts; 511 for (index = 0;
531 index++) { 512 index < linked_list->data.extended_irq.number_of_interrupts;
532 ACPI_MOVE_32_TO_32 (buffer, 513 index++) {
533 &linked_list->data.extended_irq.interrupts[index]); 514 ACPI_MOVE_32_TO_32(buffer,
515 &linked_list->data.extended_irq.
516 interrupts[index]);
534 buffer += 4; 517 buffer += 4;
535 } 518 }
536 519
537 /* Resource Source Index and Resource Source are optional */ 520 /* Resource Source Index and Resource Source are optional */
538 521
539 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 522 if (0 != linked_list->data.extended_irq.resource_source.string_length) {
540 *buffer = (u8) linked_list->data.extended_irq.resource_source.index; 523 *buffer =
524 (u8) linked_list->data.extended_irq.resource_source.index;
541 buffer += 1; 525 buffer += 1;
542 526
543 temp_pointer = (char *) buffer; 527 temp_pointer = (char *)buffer;
544 528
545 /* Copy the string */ 529 /* Copy the string */
546 530
547 ACPI_STRCPY (temp_pointer, 531 ACPI_STRCPY(temp_pointer,
548 linked_list->data.extended_irq.resource_source.string_ptr); 532 linked_list->data.extended_irq.resource_source.
533 string_ptr);
549 534
550 /* 535 /*
551 * Buffer needs to be set to the length of the sting + one for the 536 * Buffer needs to be set to the length of the sting + one for the
552 * terminating null 537 * terminating null
553 */ 538 */
554 buffer += (acpi_size) (ACPI_STRLEN ( 539 buffer +=
555 linked_list->data.extended_irq.resource_source.string_ptr) + 1); 540 (acpi_size) (ACPI_STRLEN
541 (linked_list->data.extended_irq.
542 resource_source.string_ptr) + 1);
556 } 543 }
557 544
558 /* Return the number of bytes consumed in this operation */ 545 /* Return the number of bytes consumed in this operation */
559 546
560 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 547 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
561 548
562 /* 549 /*
563 * Set the length field to the number of bytes consumed 550 * Set the length field to the number of bytes consumed
564 * minus the header size (3 bytes) 551 * minus the header size (3 bytes)
565 */ 552 */
566 *length_field = (u16) (*bytes_consumed - 3); 553 *length_field = (u16) (*bytes_consumed - 3);
567 return_ACPI_STATUS (AE_OK); 554 return_ACPI_STATUS(AE_OK);
568} 555}
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..8a3ea41063ec 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 530int 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 186b182c5825..f8538b5b893e 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -91,4 +91,4 @@ static int acpi_poweroff_init(void)
91 91
92late_initcall(acpi_poweroff_init); 92late_initcall(acpi_poweroff_init);
93 93
94#endif /* CONFIG_PM */ 94#endif /* CONFIG_PM */
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index a962fc24f704..09a603f3523e 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -14,19 +14,17 @@
14#include "sleep.h" 14#include "sleep.h"
15 15
16#define _COMPONENT ACPI_SYSTEM_COMPONENT 16#define _COMPONENT ACPI_SYSTEM_COMPONENT
17ACPI_MODULE_NAME ("sleep") 17ACPI_MODULE_NAME("sleep")
18
19#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 18#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
20
21static 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)
22{ 20{
23 int i; 21 int i;
24 22
25 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show"); 23 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
26 24
27 for (i = 0; i <= ACPI_STATE_S5; i++) { 25 for (i = 0; i <= ACPI_STATE_S5; i++) {
28 if (sleep_states[i]) { 26 if (sleep_states[i]) {
29 seq_printf(seq,"S%d ", i); 27 seq_printf(seq, "S%d ", i);
30 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) 28 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f)
31 seq_printf(seq, "S4bios "); 29 seq_printf(seq, "S4bios ");
32 } 30 }
@@ -43,24 +41,21 @@ static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file)
43} 41}
44 42
45static ssize_t 43static ssize_t
46acpi_system_write_sleep ( 44acpi_system_write_sleep(struct file *file,
47 struct file *file, 45 const char __user * buffer, size_t count, loff_t * ppos)
48 const char __user *buffer,
49 size_t count,
50 loff_t *ppos)
51{ 46{
52 char str[12]; 47 char str[12];
53 u32 state = 0; 48 u32 state = 0;
54 int error = 0; 49 int error = 0;
55 50
56 if (count > sizeof(str) - 1) 51 if (count > sizeof(str) - 1)
57 goto Done; 52 goto Done;
58 memset(str,0,sizeof(str)); 53 memset(str, 0, sizeof(str));
59 if (copy_from_user(str, buffer, count)) 54 if (copy_from_user(str, buffer, count))
60 return -EFAULT; 55 return -EFAULT;
61 56
62 /* Check for S4 bios request */ 57 /* Check for S4 bios request */
63 if (!strcmp(str,"4b")) { 58 if (!strcmp(str, "4b")) {
64 error = acpi_suspend(4); 59 error = acpi_suspend(4);
65 goto Done; 60 goto Done;
66 } 61 }
@@ -72,17 +67,17 @@ acpi_system_write_sleep (
72 } 67 }
73#endif 68#endif
74 error = acpi_suspend(state); 69 error = acpi_suspend(state);
75 Done: 70 Done:
76 return error ? error : count; 71 return error ? error : count;
77} 72}
78#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 73#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
79 74
80static 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)
81{ 76{
82 u32 sec, min, hr; 77 u32 sec, min, hr;
83 u32 day, mo, yr; 78 u32 day, mo, yr;
84 unsigned char rtc_control = 0; 79 unsigned char rtc_control = 0;
85 unsigned long flags; 80 unsigned long flags;
86 81
87 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show"); 82 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
88 83
@@ -98,13 +93,14 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
98 /* ACPI spec: only low 6 its should be cared */ 93 /* ACPI spec: only low 6 its should be cared */
99 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F; 94 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F;
100 else 95 else
101 day = CMOS_READ(RTC_DAY_OF_MONTH); 96 day = CMOS_READ(RTC_DAY_OF_MONTH);
102 if (acpi_gbl_FADT->mon_alrm) 97 if (acpi_gbl_FADT->mon_alrm)
103 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm); 98 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
104 else 99 else
105 mo = CMOS_READ(RTC_MONTH); 100 mo = CMOS_READ(RTC_MONTH);
106 if (acpi_gbl_FADT->century) 101 if (acpi_gbl_FADT->century)
107 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);
108 else 104 else
109 yr = CMOS_READ(RTC_YEAR); 105 yr = CMOS_READ(RTC_YEAR);
110 106
@@ -119,33 +115,33 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
119 BCD_TO_BIN(yr); 115 BCD_TO_BIN(yr);
120 } 116 }
121 117
122 /* we're trusting the FADT (see above)*/ 118 /* we're trusting the FADT (see above) */
123 if (!acpi_gbl_FADT->century) 119 if (!acpi_gbl_FADT->century)
124 /* 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
125 * right for _this_ century... ehm, what is _this_ century? 121 * right for _this_ century... ehm, what is _this_ century?
126 * 122 *
127 * TBD: 123 * TBD:
128 * 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,
129 * which we can trust to determine the century correctly. Atom 125 * which we can trust to determine the century correctly. Atom
130 * watch driver would be nice, too... 126 * watch driver would be nice, too...
131 * 127 *
132 * if that has not happened, change for first release in 2050: 128 * if that has not happened, change for first release in 2050:
133 * if (yr<50) 129 * if (yr<50)
134 * yr += 2100; 130 * yr += 2100;
135 * else 131 * else
136 * yr += 2000; // current line of code 132 * yr += 2000; // current line of code
137 * 133 *
138 * 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
139 * s/2000/2100 135 * s/2000/2100
140 * 136 *
141 */ 137 */
142 yr += 2000; 138 yr += 2000;
143 139
144 seq_printf(seq,"%4.4u-", yr); 140 seq_printf(seq, "%4.4u-", yr);
145 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 141 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
146 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 142 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
147 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); 143 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
148 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); 144 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
149 (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);
150 146
151 return 0; 147 return 0;
@@ -156,15 +152,11 @@ static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
156 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);
157} 153}
158 154
159 155static int get_date_field(char **p, u32 * value)
160static int
161get_date_field (
162 char **p,
163 u32 *value)
164{ 156{
165 char *next = NULL; 157 char *next = NULL;
166 char *string_end = NULL; 158 char *string_end = NULL;
167 int result = -EINVAL; 159 int result = -EINVAL;
168 160
169 /* 161 /*
170 * 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
@@ -186,26 +178,22 @@ get_date_field (
186 return result; 178 return result;
187} 179}
188 180
189
190static ssize_t 181static ssize_t
191acpi_system_write_alarm ( 182acpi_system_write_alarm(struct file *file,
192 struct file *file, 183 const char __user * buffer, size_t count, loff_t * ppos)
193 const char __user *buffer,
194 size_t count,
195 loff_t *ppos)
196{ 184{
197 int result = 0; 185 int result = 0;
198 char alarm_string[30] = {'\0'}; 186 char alarm_string[30] = { '\0' };
199 char *p = alarm_string; 187 char *p = alarm_string;
200 u32 sec, min, hr, day, mo, yr; 188 u32 sec, min, hr, day, mo, yr;
201 int adjust = 0; 189 int adjust = 0;
202 unsigned char rtc_control = 0; 190 unsigned char rtc_control = 0;
203 191
204 ACPI_FUNCTION_TRACE("acpi_system_write_alarm"); 192 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
205 193
206 if (count > sizeof(alarm_string) - 1) 194 if (count > sizeof(alarm_string) - 1)
207 return_VALUE(-EINVAL); 195 return_VALUE(-EINVAL);
208 196
209 if (copy_from_user(alarm_string, buffer, count)) 197 if (copy_from_user(alarm_string, buffer, count))
210 return_VALUE(-EFAULT); 198 return_VALUE(-EFAULT);
211 199
@@ -264,10 +252,10 @@ acpi_system_write_alarm (
264 } 252 }
265 253
266 if (adjust) { 254 if (adjust) {
267 yr += CMOS_READ(RTC_YEAR); 255 yr += CMOS_READ(RTC_YEAR);
268 mo += CMOS_READ(RTC_MONTH); 256 mo += CMOS_READ(RTC_MONTH);
269 day += CMOS_READ(RTC_DAY_OF_MONTH); 257 day += CMOS_READ(RTC_DAY_OF_MONTH);
270 hr += CMOS_READ(RTC_HOURS); 258 hr += CMOS_READ(RTC_HOURS);
271 min += CMOS_READ(RTC_MINUTES); 259 min += CMOS_READ(RTC_MINUTES);
272 sec += CMOS_READ(RTC_SECONDS); 260 sec += CMOS_READ(RTC_SECONDS);
273 } 261 }
@@ -336,7 +324,7 @@ acpi_system_write_alarm (
336 if (acpi_gbl_FADT->mon_alrm) 324 if (acpi_gbl_FADT->mon_alrm)
337 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm); 325 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm);
338 if (acpi_gbl_FADT->century) 326 if (acpi_gbl_FADT->century)
339 CMOS_WRITE(yr/100, acpi_gbl_FADT->century); 327 CMOS_WRITE(yr / 100, acpi_gbl_FADT->century);
340 /* enable the rtc alarm interrupt */ 328 /* enable the rtc alarm interrupt */
341 rtc_control |= RTC_AIE; 329 rtc_control |= RTC_AIE;
342 CMOS_WRITE(rtc_control, RTC_CONTROL); 330 CMOS_WRITE(rtc_control, RTC_CONTROL);
@@ -350,29 +338,31 @@ acpi_system_write_alarm (
350 *ppos += count; 338 *ppos += count;
351 339
352 result = 0; 340 result = 0;
353end: 341 end:
354 return_VALUE(result ? result : count); 342 return_VALUE(result ? result : count);
355} 343}
356 344
357extern struct list_head acpi_wakeup_device_list; 345extern struct list_head acpi_wakeup_device_list;
358extern spinlock_t acpi_device_lock; 346extern spinlock_t acpi_device_lock;
359 347
360static int 348static int
361acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) 349acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
362{ 350{
363 struct list_head * node, * next; 351 struct list_head *node, *next;
364 352
365 seq_printf(seq, "Device Sleep state Status\n"); 353 seq_printf(seq, "Device Sleep state Status\n");
366 354
367 spin_lock(&acpi_device_lock); 355 spin_lock(&acpi_device_lock);
368 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 356 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
369 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);
370 359
371 if (!dev->wakeup.flags.valid) 360 if (!dev->wakeup.flags.valid)
372 continue; 361 continue;
373 spin_unlock(&acpi_device_lock); 362 spin_unlock(&acpi_device_lock);
374 seq_printf(seq, "%4s %4d %s%8s\n", 363 seq_printf(seq, "%4s %4d %s%8s\n",
375 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, 364 dev->pnp.bus_id,
365 (u32) dev->wakeup.sleep_state,
376 dev->wakeup.flags.run_wake ? "*" : "", 366 dev->wakeup.flags.run_wake ? "*" : "",
377 dev->wakeup.state.enabled ? "enabled" : "disabled"); 367 dev->wakeup.state.enabled ? "enabled" : "disabled");
378 spin_lock(&acpi_device_lock); 368 spin_lock(&acpi_device_lock);
@@ -382,19 +372,18 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
382} 372}
383 373
384static ssize_t 374static ssize_t
385acpi_system_write_wakeup_device ( 375acpi_system_write_wakeup_device(struct file *file,
386 struct file *file, 376 const char __user * buffer,
387 const char __user *buffer, 377 size_t count, loff_t * ppos)
388 size_t count,
389 loff_t *ppos)
390{ 378{
391 struct list_head * node, * next; 379 struct list_head *node, *next;
392 char strbuf[5]; 380 char strbuf[5];
393 char str[5] = ""; 381 char str[5] = "";
394 int len = count; 382 int len = count;
395 struct acpi_device *found_dev = NULL; 383 struct acpi_device *found_dev = NULL;
396 384
397 if (len > 4) len = 4; 385 if (len > 4)
386 len = 4;
398 387
399 if (copy_from_user(strbuf, buffer, len)) 388 if (copy_from_user(strbuf, buffer, len))
400 return -EFAULT; 389 return -EFAULT;
@@ -403,28 +392,36 @@ acpi_system_write_wakeup_device (
403 392
404 spin_lock(&acpi_device_lock); 393 spin_lock(&acpi_device_lock);
405 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 394 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
406 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);
407 if (!dev->wakeup.flags.valid) 397 if (!dev->wakeup.flags.valid)
408 continue; 398 continue;
409 399
410 if (!strncmp(dev->pnp.bus_id, str, 4)) { 400 if (!strncmp(dev->pnp.bus_id, str, 4)) {
411 dev->wakeup.state.enabled = dev->wakeup.state.enabled ? 0:1; 401 dev->wakeup.state.enabled =
402 dev->wakeup.state.enabled ? 0 : 1;
412 found_dev = dev; 403 found_dev = dev;
413 break; 404 break;
414 } 405 }
415 } 406 }
416 if (found_dev) { 407 if (found_dev) {
417 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 408 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
418 struct acpi_device * dev = container_of(node, 409 struct acpi_device *dev = container_of(node,
419 struct acpi_device, wakeup_list); 410 struct
411 acpi_device,
412 wakeup_list);
420 413
421 if ((dev != found_dev) && 414 if ((dev != found_dev) &&
422 (dev->wakeup.gpe_number == found_dev->wakeup.gpe_number) && 415 (dev->wakeup.gpe_number ==
423 (dev->wakeup.gpe_device == found_dev->wakeup.gpe_device)) { 416 found_dev->wakeup.gpe_number)
424 printk(KERN_WARNING "ACPI: '%s' and '%s' have the same GPE, " 417 && (dev->wakeup.gpe_device ==
425 "can't disable/enable one seperately\n", 418 found_dev->wakeup.gpe_device)) {
426 dev->pnp.bus_id, found_dev->pnp.bus_id); 419 printk(KERN_WARNING
427 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;
428 } 425 }
429 } 426 }
430 } 427 }
@@ -435,37 +432,37 @@ acpi_system_write_wakeup_device (
435static int 432static int
436acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) 433acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
437{ 434{
438 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);
439} 437}
440 438
441static struct file_operations acpi_system_wakeup_device_fops = { 439static struct file_operations acpi_system_wakeup_device_fops = {
442 .open = acpi_system_wakeup_device_open_fs, 440 .open = acpi_system_wakeup_device_open_fs,
443 .read = seq_read, 441 .read = seq_read,
444 .write = acpi_system_write_wakeup_device, 442 .write = acpi_system_write_wakeup_device,
445 .llseek = seq_lseek, 443 .llseek = seq_lseek,
446 .release = single_release, 444 .release = single_release,
447}; 445};
448 446
449#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 447#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
450static struct file_operations acpi_system_sleep_fops = { 448static struct file_operations acpi_system_sleep_fops = {
451 .open = acpi_system_sleep_open_fs, 449 .open = acpi_system_sleep_open_fs,
452 .read = seq_read, 450 .read = seq_read,
453 .write = acpi_system_write_sleep, 451 .write = acpi_system_write_sleep,
454 .llseek = seq_lseek, 452 .llseek = seq_lseek,
455 .release = single_release, 453 .release = single_release,
456}; 454};
457#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 455#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
458 456
459static struct file_operations acpi_system_alarm_fops = { 457static struct file_operations acpi_system_alarm_fops = {
460 .open = acpi_system_alarm_open_fs, 458 .open = acpi_system_alarm_open_fs,
461 .read = seq_read, 459 .read = seq_read,
462 .write = acpi_system_write_alarm, 460 .write = acpi_system_write_alarm,
463 .llseek = seq_lseek, 461 .llseek = seq_lseek,
464 .release = single_release, 462 .release = single_release,
465}; 463};
466 464
467 465static u32 rtc_handler(void *context)
468static u32 rtc_handler(void * context)
469{ 466{
470 acpi_clear_event(ACPI_EVENT_RTC); 467 acpi_clear_event(ACPI_EVENT_RTC);
471 acpi_disable_event(ACPI_EVENT_RTC, 0); 468 acpi_disable_event(ACPI_EVENT_RTC, 0);
@@ -479,21 +476,27 @@ static int acpi_sleep_proc_init(void)
479 476
480 if (acpi_disabled) 477 if (acpi_disabled)
481 return 0; 478 return 0;
482 479
483#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 480#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
484 /* 'sleep' [R/W] */ 481 /* 'sleep' [R/W] */
485 entry = create_proc_entry("sleep", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 482 entry =
483 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
484 acpi_root_dir);
486 if (entry) 485 if (entry)
487 entry->proc_fops = &acpi_system_sleep_fops; 486 entry->proc_fops = &acpi_system_sleep_fops;
488#endif 487#endif
489 488
490 /* 'alarm' [R/W] */ 489 /* 'alarm' [R/W] */
491 entry = create_proc_entry("alarm", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 490 entry =
491 create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
492 acpi_root_dir);
492 if (entry) 493 if (entry)
493 entry->proc_fops = &acpi_system_alarm_fops; 494 entry->proc_fops = &acpi_system_alarm_fops;
494 495
495 /* 'wakeup device' [R/W] */ 496 /* 'wakeup device' [R/W] */
496 entry = create_proc_entry("wakeup", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 497 entry =
498 create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
499 acpi_root_dir);
497 if (entry) 500 if (entry)
498 entry->proc_fops = &acpi_system_wakeup_device_fops; 501 entry->proc_fops = &acpi_system_wakeup_device_fops;
499 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 d4ff71f5fe5d..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,23 +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
96
97 ACPI_FUNCTION_ENTRY ();
98 88
89 ACPI_FUNCTION_ENTRY();
99 90
100 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ 91 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
101 92
102 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 93 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
103 pointer_size = sizeof (u32); 94 pointer_size = sizeof(u32);
104 } 95 } else {
105 else { 96 pointer_size = sizeof(u64);
106 pointer_size = sizeof (u64);
107 } 97 }
108 98
109 /* 99 /*
@@ -112,10 +102,10 @@ acpi_tb_get_table_count (
112 * pointers contained within the RSDT/XSDT. The size of the pointers 102 * pointers contained within the RSDT/XSDT. The size of the pointers
113 * is architecture-dependent. 103 * is architecture-dependent.
114 */ 104 */
115 return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size); 105 return ((RSDT->length -
106 sizeof(struct acpi_table_header)) / pointer_size);
116} 107}
117 108
118
119/******************************************************************************* 109/*******************************************************************************
120 * 110 *
121 * FUNCTION: acpi_tb_convert_to_xsdt 111 * FUNCTION: acpi_tb_convert_to_xsdt
@@ -128,33 +118,30 @@ acpi_tb_get_table_count (
128 * 118 *
129 ******************************************************************************/ 119 ******************************************************************************/
130 120
131acpi_status 121acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
132acpi_tb_convert_to_xsdt (
133 struct acpi_table_desc *table_info)
134{ 122{
135 acpi_size table_size; 123 acpi_size table_size;
136 u32 i; 124 u32 i;
137 XSDT_DESCRIPTOR *new_table; 125 XSDT_DESCRIPTOR *new_table;
138
139
140 ACPI_FUNCTION_ENTRY ();
141 126
127 ACPI_FUNCTION_ENTRY();
142 128
143 /* Compute size of the converted XSDT */ 129 /* Compute size of the converted XSDT */
144 130
145 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) + 131 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) +
146 sizeof (struct acpi_table_header); 132 sizeof(struct acpi_table_header);
147 133
148 /* Allocate an XSDT */ 134 /* Allocate an XSDT */
149 135
150 new_table = ACPI_MEM_CALLOCATE (table_size); 136 new_table = ACPI_MEM_CALLOCATE(table_size);
151 if (!new_table) { 137 if (!new_table) {
152 return (AE_NO_MEMORY); 138 return (AE_NO_MEMORY);
153 } 139 }
154 140
155 /* Copy the header and set the length */ 141 /* Copy the header and set the length */
156 142
157 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));
158 new_table->length = (u32) table_size; 145 new_table->length = (u32) table_size;
159 146
160 /* Copy the table pointers */ 147 /* Copy the table pointers */
@@ -163,31 +150,33 @@ acpi_tb_convert_to_xsdt (
163 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ 150 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
164 151
165 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 152 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
166 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], 153 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
167 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, 154 (ACPI_CAST_PTR
168 table_info->pointer))->table_offset_entry[i]); 155 (struct rsdt_descriptor_rev1,
169 } 156 table_info->pointer))->
170 else { 157 table_offset_entry[i]);
158 } else {
171 new_table->table_offset_entry[i] = 159 new_table->table_offset_entry[i] =
172 (ACPI_CAST_PTR (XSDT_DESCRIPTOR, 160 (ACPI_CAST_PTR(XSDT_DESCRIPTOR,
173 table_info->pointer))->table_offset_entry[i]; 161 table_info->pointer))->
162 table_offset_entry[i];
174 } 163 }
175 } 164 }
176 165
177 /* Delete the original table (either mapped or in a buffer) */ 166 /* Delete the original table (either mapped or in a buffer) */
178 167
179 acpi_tb_delete_single_table (table_info); 168 acpi_tb_delete_single_table(table_info);
180 169
181 /* Point the table descriptor to the new table */ 170 /* Point the table descriptor to the new table */
182 171
183 table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table); 172 table_info->pointer =
184 table_info->length = table_size; 173 ACPI_CAST_PTR(struct acpi_table_header, new_table);
185 table_info->allocation = ACPI_MEM_ALLOCATED; 174 table_info->length = table_size;
175 table_info->allocation = ACPI_MEM_ALLOCATED;
186 176
187 return (AE_OK); 177 return (AE_OK);
188} 178}
189 179
190
191/******************************************************************************* 180/*******************************************************************************
192 * 181 *
193 * FUNCTION: acpi_tb_init_generic_address 182 * FUNCTION: acpi_tb_init_generic_address
@@ -203,21 +192,19 @@ acpi_tb_convert_to_xsdt (
203 ******************************************************************************/ 192 ******************************************************************************/
204 193
205static void 194static void
206acpi_tb_init_generic_address ( 195acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
207 struct acpi_generic_address *new_gas_struct, 196 u8 register_bit_width,
208 u8 register_bit_width, 197 acpi_physical_address address)
209 acpi_physical_address address)
210{ 198{
211 199
212 ACPI_STORE_ADDRESS (new_gas_struct->address, address); 200 ACPI_STORE_ADDRESS(new_gas_struct->address, address);
213 201
214 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 202 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
215 new_gas_struct->register_bit_width = register_bit_width; 203 new_gas_struct->register_bit_width = register_bit_width;
216 new_gas_struct->register_bit_offset = 0; 204 new_gas_struct->register_bit_offset = 0;
217 new_gas_struct->access_width = 0; 205 new_gas_struct->access_width = 0;
218} 206}
219 207
220
221/******************************************************************************* 208/*******************************************************************************
222 * 209 *
223 * FUNCTION: acpi_tb_convert_fadt1 210 * FUNCTION: acpi_tb_convert_fadt1
@@ -232,9 +219,8 @@ acpi_tb_init_generic_address (
232 ******************************************************************************/ 219 ******************************************************************************/
233 220
234static void 221static void
235acpi_tb_convert_fadt1 ( 222acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
236 struct fadt_descriptor_rev2 *local_fadt, 223 struct fadt_descriptor_rev1 *original_fadt)
237 struct fadt_descriptor_rev1 *original_fadt)
238{ 224{
239 225
240 /* ACPI 1.0 FACS */ 226 /* ACPI 1.0 FACS */
@@ -247,12 +233,14 @@ acpi_tb_convert_fadt1 (
247 * 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
248 * 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.
249 */ 235 */
250 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1)); 236 ACPI_MEMCPY(local_fadt, original_fadt,
237 sizeof(struct fadt_descriptor_rev1));
251 238
252 /* Convert table pointers to 64-bit fields */ 239 /* Convert table pointers to 64-bit fields */
253 240
254 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); 241 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
255 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);
256 244
257 /* 245 /*
258 * System Interrupt Model isn't used in ACPI 2.0 246 * System Interrupt Model isn't used in ACPI 2.0
@@ -287,17 +275,17 @@ acpi_tb_convert_fadt1 (
287 * It primarily adds the FADT reset mechanism. 275 * It primarily adds the FADT reset mechanism.
288 */ 276 */
289 if ((original_fadt->revision == 2) && 277 if ((original_fadt->revision == 2) &&
290 (original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) { 278 (original_fadt->length ==
279 sizeof(struct fadt_descriptor_rev2_minus))) {
291 /* 280 /*
292 * 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
293 * that immediately follows. 282 * that immediately follows.
294 */ 283 */
295 ACPI_MEMCPY (&local_fadt->reset_register, 284 ACPI_MEMCPY(&local_fadt->reset_register,
296 &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, 285 &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus,
297 original_fadt))->reset_register, 286 original_fadt))->reset_register,
298 sizeof (struct acpi_generic_address) + 1); 287 sizeof(struct acpi_generic_address) + 1);
299 } 288 } else {
300 else {
301 /* 289 /*
302 * 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
303 * likely that a 1.0 system has legacy support. 291 * likely that a 1.0 system has legacy support.
@@ -308,43 +296,60 @@ acpi_tb_convert_fadt1 (
308 /* 296 /*
309 * Convert the V1.0 block addresses to V2.0 GAS structures 297 * Convert the V1.0 block addresses to V2.0 GAS structures
310 */ 298 */
311 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,
312 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 300 local_fadt->pm1_evt_len,
313 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len, 301 (acpi_physical_address) local_fadt->
314 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 302 V1_pm1a_evt_blk);
315 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,
316 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 304 local_fadt->pm1_evt_len,
317 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len, 305 (acpi_physical_address) local_fadt->
318 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 306 V1_pm1b_evt_blk);
319 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,
320 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 308 local_fadt->pm1_cnt_len,
321 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len, 309 (acpi_physical_address) local_fadt->
322 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 310 V1_pm1a_cnt_blk);
323 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0, 311 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
324 (acpi_physical_address) local_fadt->V1_gpe0_blk); 312 local_fadt->pm1_cnt_len,
325 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0, 313 (acpi_physical_address) local_fadt->
326 (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);
327 329
328 /* Create separate GAS structs for the PM1 Enable registers */ 330 /* Create separate GAS structs for the PM1 Enable registers */
329 331
330 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 332 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
331 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 333 (u8) ACPI_DIV_2(acpi_gbl_FADT->
332 (acpi_physical_address) 334 pm1_evt_len),
333 (local_fadt->xpm1a_evt_blk.address + 335 (acpi_physical_address)
334 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)));
335 338
336 /* PM1B is optional; leave null if not present */ 339 /* PM1B is optional; leave null if not present */
337 340
338 if (local_fadt->xpm1b_evt_blk.address) { 341 if (local_fadt->xpm1b_evt_blk.address) {
339 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 342 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
340 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 343 (u8) ACPI_DIV_2(acpi_gbl_FADT->
341 (acpi_physical_address) 344 pm1_evt_len),
342 (local_fadt->xpm1b_evt_blk.address + 345 (acpi_physical_address)
343 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)));
344 } 350 }
345} 351}
346 352
347
348/******************************************************************************* 353/*******************************************************************************
349 * 354 *
350 * FUNCTION: acpi_tb_convert_fadt2 355 * FUNCTION: acpi_tb_convert_fadt2
@@ -360,14 +365,14 @@ acpi_tb_convert_fadt1 (
360 ******************************************************************************/ 365 ******************************************************************************/
361 366
362static void 367static void
363acpi_tb_convert_fadt2 ( 368acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
364 struct fadt_descriptor_rev2 *local_fadt, 369 struct fadt_descriptor_rev2 *original_fadt)
365 struct fadt_descriptor_rev2 *original_fadt)
366{ 370{
367 371
368 /* 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 */
369 373
370 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2)); 374 ACPI_MEMCPY(local_fadt, original_fadt,
375 sizeof(struct fadt_descriptor_rev2));
371 376
372 /* 377 /*
373 * "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
@@ -375,86 +380,99 @@ acpi_tb_convert_fadt2 (
375 * is zero. 380 * is zero.
376 */ 381 */
377 if (!(local_fadt->xfirmware_ctrl)) { 382 if (!(local_fadt->xfirmware_ctrl)) {
378 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, 383 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
379 local_fadt->V1_firmware_ctrl); 384 local_fadt->V1_firmware_ctrl);
380 } 385 }
381 386
382 if (!(local_fadt->Xdsdt)) { 387 if (!(local_fadt->Xdsdt)) {
383 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 388 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
384 } 389 }
385 390
386 if (!(local_fadt->xpm1a_evt_blk.address)) { 391 if (!(local_fadt->xpm1a_evt_blk.address)) {
387 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, 392 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
388 local_fadt->pm1_evt_len, 393 local_fadt->pm1_evt_len,
389 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 394 (acpi_physical_address)
395 local_fadt->V1_pm1a_evt_blk);
390 } 396 }
391 397
392 if (!(local_fadt->xpm1b_evt_blk.address)) { 398 if (!(local_fadt->xpm1b_evt_blk.address)) {
393 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, 399 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
394 local_fadt->pm1_evt_len, 400 local_fadt->pm1_evt_len,
395 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 401 (acpi_physical_address)
402 local_fadt->V1_pm1b_evt_blk);
396 } 403 }
397 404
398 if (!(local_fadt->xpm1a_cnt_blk.address)) { 405 if (!(local_fadt->xpm1a_cnt_blk.address)) {
399 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, 406 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
400 local_fadt->pm1_cnt_len, 407 local_fadt->pm1_cnt_len,
401 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 408 (acpi_physical_address)
409 local_fadt->V1_pm1a_cnt_blk);
402 } 410 }
403 411
404 if (!(local_fadt->xpm1b_cnt_blk.address)) { 412 if (!(local_fadt->xpm1b_cnt_blk.address)) {
405 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, 413 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
406 local_fadt->pm1_cnt_len, 414 local_fadt->pm1_cnt_len,
407 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 415 (acpi_physical_address)
416 local_fadt->V1_pm1b_cnt_blk);
408 } 417 }
409 418
410 if (!(local_fadt->xpm2_cnt_blk.address)) { 419 if (!(local_fadt->xpm2_cnt_blk.address)) {
411 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, 420 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
412 local_fadt->pm2_cnt_len, 421 local_fadt->pm2_cnt_len,
413 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 422 (acpi_physical_address)
423 local_fadt->V1_pm2_cnt_blk);
414 } 424 }
415 425
416 if (!(local_fadt->xpm_tmr_blk.address)) { 426 if (!(local_fadt->xpm_tmr_blk.address)) {
417 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, 427 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
418 local_fadt->pm_tm_len, 428 local_fadt->pm_tm_len,
419 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 429 (acpi_physical_address)
430 local_fadt->V1_pm_tmr_blk);
420 } 431 }
421 432
422 if (!(local_fadt->xgpe0_blk.address)) { 433 if (!(local_fadt->xgpe0_blk.address)) {
423 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 434 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk,
424 0, (acpi_physical_address) local_fadt->V1_gpe0_blk); 435 0,
436 (acpi_physical_address)
437 local_fadt->V1_gpe0_blk);
425 } 438 }
426 439
427 if (!(local_fadt->xgpe1_blk.address)) { 440 if (!(local_fadt->xgpe1_blk.address)) {
428 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 441 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk,
429 0, (acpi_physical_address) local_fadt->V1_gpe1_blk); 442 0,
443 (acpi_physical_address)
444 local_fadt->V1_gpe1_blk);
430 } 445 }
431 446
432 /* Create separate GAS structs for the PM1 Enable registers */ 447 /* Create separate GAS structs for the PM1 Enable registers */
433 448
434 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 449 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
435 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 450 (u8) ACPI_DIV_2(acpi_gbl_FADT->
436 (acpi_physical_address) 451 pm1_evt_len),
437 (local_fadt->xpm1a_evt_blk.address + 452 (acpi_physical_address)
438 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)));
439 455
440 acpi_gbl_xpm1a_enable.address_space_id = 456 acpi_gbl_xpm1a_enable.address_space_id =
441 local_fadt->xpm1a_evt_blk.address_space_id; 457 local_fadt->xpm1a_evt_blk.address_space_id;
442 458
443 /* PM1B is optional; leave null if not present */ 459 /* PM1B is optional; leave null if not present */
444 460
445 if (local_fadt->xpm1b_evt_blk.address) { 461 if (local_fadt->xpm1b_evt_blk.address) {
446 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 462 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
447 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 463 (u8) ACPI_DIV_2(acpi_gbl_FADT->
448 (acpi_physical_address) 464 pm1_evt_len),
449 (local_fadt->xpm1b_evt_blk.address + 465 (acpi_physical_address)
450 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)));
451 470
452 acpi_gbl_xpm1b_enable.address_space_id = 471 acpi_gbl_xpm1b_enable.address_space_id =
453 local_fadt->xpm1b_evt_blk.address_space_id; 472 local_fadt->xpm1b_evt_blk.address_space_id;
454 } 473 }
455} 474}
456 475
457
458/******************************************************************************* 476/*******************************************************************************
459 * 477 *
460 * FUNCTION: acpi_tb_convert_table_fadt 478 * FUNCTION: acpi_tb_convert_table_fadt
@@ -471,83 +489,76 @@ acpi_tb_convert_fadt2 (
471 * 489 *
472 ******************************************************************************/ 490 ******************************************************************************/
473 491
474acpi_status 492acpi_status acpi_tb_convert_table_fadt(void)
475acpi_tb_convert_table_fadt (
476 void)
477{ 493{
478 struct fadt_descriptor_rev2 *local_fadt; 494 struct fadt_descriptor_rev2 *local_fadt;
479 struct acpi_table_desc *table_desc; 495 struct acpi_table_desc *table_desc;
480
481
482 ACPI_FUNCTION_TRACE ("tb_convert_table_fadt");
483 496
497 ACPI_FUNCTION_TRACE("tb_convert_table_fadt");
484 498
485 /* 499 /*
486 * 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
487 * at least as long as the version 1.0 FADT 501 * at least as long as the version 1.0 FADT
488 */ 502 */
489 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { 503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
490 ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", 504 ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n",
491 acpi_gbl_FADT->length)); 505 acpi_gbl_FADT->length));
492 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
493 } 507 }
494 508
495 /* Allocate buffer for the ACPI 2.0(+) FADT */ 509 /* Allocate buffer for the ACPI 2.0(+) FADT */
496 510
497 local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2)); 511 local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2));
498 if (!local_fadt) { 512 if (!local_fadt) {
499 return_ACPI_STATUS (AE_NO_MEMORY); 513 return_ACPI_STATUS(AE_NO_MEMORY);
500 } 514 }
501 515
502 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { 516 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
503 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { 517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) {
504 /* Length is too short to be a V2.0 table */ 518 /* Length is too short to be a V2.0 table */
505 519
506 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));
507 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
508 acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
509 521
510 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 522 acpi_tb_convert_fadt1(local_fadt,
511 } 523 (void *)acpi_gbl_FADT);
512 else { 524 } else {
513 /* Valid V2.0 table */ 525 /* Valid V2.0 table */
514 526
515 acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT); 527 acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT);
516 } 528 }
517 } 529 } else {
518 else {
519 /* Valid V1.0 table */ 530 /* Valid V1.0 table */
520 531
521 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 532 acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT);
522 } 533 }
523 534
524 /* 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 */
525 536
526 acpi_gbl_FADT = local_fadt; 537 acpi_gbl_FADT = local_fadt;
527 acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); 538 acpi_gbl_FADT->length = sizeof(FADT_DESCRIPTOR);
528 539
529 /* Free the original table */ 540 /* Free the original table */
530 541
531 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; 542 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next;
532 acpi_tb_delete_single_table (table_desc); 543 acpi_tb_delete_single_table(table_desc);
533 544
534 /* Install the new table */ 545 /* Install the new table */
535 546
536 table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT); 547 table_desc->pointer =
537 table_desc->allocation = ACPI_MEM_ALLOCATED; 548 ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
538 table_desc->length = sizeof (struct fadt_descriptor_rev2); 549 table_desc->allocation = ACPI_MEM_ALLOCATED;
550 table_desc->length = sizeof(struct fadt_descriptor_rev2);
539 551
540 /* Dump the entire FADT */ 552 /* Dump the entire FADT */
541 553
542 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
543 "Hex dump of common internal FADT, size %d (%X)\n", 555 "Hex dump of common internal FADT, size %d (%X)\n",
544 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 556 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
545 ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length);
546 558
547 return_ACPI_STATUS (AE_OK); 559 return_ACPI_STATUS(AE_OK);
548} 560}
549 561
550
551/******************************************************************************* 562/*******************************************************************************
552 * 563 *
553 * FUNCTION: acpi_tb_build_common_facs 564 * FUNCTION: acpi_tb_build_common_facs
@@ -561,26 +572,21 @@ acpi_tb_convert_table_fadt (
561 * 572 *
562 ******************************************************************************/ 573 ******************************************************************************/
563 574
564acpi_status 575acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
565acpi_tb_build_common_facs (
566 struct acpi_table_desc *table_info)
567{ 576{
568 577
569 ACPI_FUNCTION_TRACE ("tb_build_common_facs"); 578 ACPI_FUNCTION_TRACE("tb_build_common_facs");
570
571 579
572 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 580 /* Absolute minimum length is 24, but the ACPI spec says 64 */
573 581
574 if (acpi_gbl_FACS->length < 24) { 582 if (acpi_gbl_FACS->length < 24) {
575 ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", 583 ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n",
576 acpi_gbl_FACS->length)); 584 acpi_gbl_FACS->length));
577 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 585 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
578 } 586 }
579 587
580 if (acpi_gbl_FACS->length < 64) { 588 if (acpi_gbl_FACS->length < 64) {
581 ACPI_REPORT_WARNING (( 589 ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length));
582 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
583 acpi_gbl_FACS->length));
584 } 590 }
585 591
586 /* Copy fields to the new FACS */ 592 /* Copy fields to the new FACS */
@@ -588,22 +594,22 @@ acpi_tb_build_common_facs (
588 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock); 594 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
589 595
590 if ((acpi_gbl_RSDP->revision < 2) || 596 if ((acpi_gbl_RSDP->revision < 2) ||
591 (acpi_gbl_FACS->length < 32) || 597 (acpi_gbl_FACS->length < 32) ||
592 (!(acpi_gbl_FACS->xfirmware_waking_vector))) { 598 (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
593 /* 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 */
594 600
595 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, 601 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
596 &(acpi_gbl_FACS->firmware_waking_vector)); 602 &
603 (acpi_gbl_FACS->
604 firmware_waking_vector));
597 acpi_gbl_common_fACS.vector_width = 32; 605 acpi_gbl_common_fACS.vector_width = 32;
598 } 606 } else {
599 else {
600 /* ACPI 2.0 FACS with valid X_ field */ 607 /* ACPI 2.0 FACS with valid X_ field */
601 608
602 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;
603 acpi_gbl_common_fACS.vector_width = 64; 611 acpi_gbl_common_fACS.vector_width = 64;
604 } 612 }
605 613
606 return_ACPI_STATUS (AE_OK); 614 return_ACPI_STATUS(AE_OK);
607} 615}
608
609
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 698799901f55..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
@@ -128,52 +118,48 @@ acpi_tb_match_signature (
128 * 118 *
129 ******************************************************************************/ 119 ******************************************************************************/
130 120
131acpi_status 121acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
132acpi_tb_install_table (
133 struct acpi_table_desc *table_info)
134{ 122{
135 acpi_status status; 123 acpi_status status;
136
137
138 ACPI_FUNCTION_TRACE ("tb_install_table");
139 124
125 ACPI_FUNCTION_TRACE("tb_install_table");
140 126
141 /* Lock tables while installing */ 127 /* Lock tables while installing */
142 128
143 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
144 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
145 ACPI_REPORT_ERROR (("Could not acquire table mutex, %s\n", 131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n",
146 acpi_format_exception (status))); 132 acpi_format_exception(status)));
147 return_ACPI_STATUS (status); 133 return_ACPI_STATUS(status);
148 } 134 }
149 135
150 /* 136 /*
151 * Ignore a table that is already installed. For example, some BIOS 137 * Ignore a table that is already installed. For example, some BIOS
152 * ASL code will repeatedly attempt to load the same SSDT. 138 * ASL code will repeatedly attempt to load the same SSDT.
153 */ 139 */
154 status = acpi_tb_is_table_installed (table_info); 140 status = acpi_tb_is_table_installed(table_info);
155 if (ACPI_FAILURE (status)) { 141 if (ACPI_FAILURE(status)) {
156 goto unlock_and_exit; 142 goto unlock_and_exit;
157 } 143 }
158 144
159 /* Install the table into the global data structure */ 145 /* Install the table into the global data structure */
160 146
161 status = acpi_tb_init_table_descriptor (table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
162 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
163 ACPI_REPORT_ERROR (("Could not install table [%4.4s], %s\n", 149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n",
164 table_info->pointer->signature, acpi_format_exception (status))); 150 table_info->pointer->signature,
151 acpi_format_exception(status)));
165 } 152 }
166 153
167 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
168 acpi_gbl_table_data[table_info->type].name, table_info->pointer)); 155 acpi_gbl_table_data[table_info->type].name,
156 table_info->pointer));
169 157
170 158 unlock_and_exit:
171unlock_and_exit: 159 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
172 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 160 return_ACPI_STATUS(status);
173 return_ACPI_STATUS (status);
174} 161}
175 162
176
177/******************************************************************************* 163/*******************************************************************************
178 * 164 *
179 * FUNCTION: acpi_tb_recognize_table 165 * FUNCTION: acpi_tb_recognize_table
@@ -196,22 +182,18 @@ unlock_and_exit:
196 ******************************************************************************/ 182 ******************************************************************************/
197 183
198acpi_status 184acpi_status
199acpi_tb_recognize_table ( 185acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
200 struct acpi_table_desc *table_info,
201 u8 search_type)
202{ 186{
203 struct acpi_table_header *table_header; 187 struct acpi_table_header *table_header;
204 acpi_status status; 188 acpi_status status;
205
206
207 ACPI_FUNCTION_TRACE ("tb_recognize_table");
208 189
190 ACPI_FUNCTION_TRACE("tb_recognize_table");
209 191
210 /* Ensure that we have a valid table pointer */ 192 /* Ensure that we have a valid table pointer */
211 193
212 table_header = (struct acpi_table_header *) table_info->pointer; 194 table_header = (struct acpi_table_header *)table_info->pointer;
213 if (!table_header) { 195 if (!table_header) {
214 return_ACPI_STATUS (AE_BAD_PARAMETER); 196 return_ACPI_STATUS(AE_BAD_PARAMETER);
215 } 197 }
216 198
217 /* 199 /*
@@ -222,25 +204,24 @@ acpi_tb_recognize_table (
222 * 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
223 * the tables that is consumed by the core subsystem 205 * the tables that is consumed by the core subsystem
224 */ 206 */
225 status = acpi_tb_match_signature (table_header->signature, 207 status = acpi_tb_match_signature(table_header->signature,
226 table_info, search_type); 208 table_info, search_type);
227 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
228 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
229 } 211 }
230 212
231 status = acpi_tb_validate_table_header (table_header); 213 status = acpi_tb_validate_table_header(table_header);
232 if (ACPI_FAILURE (status)) { 214 if (ACPI_FAILURE(status)) {
233 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
234 } 216 }
235 217
236 /* Return the table type and length via the info struct */ 218 /* Return the table type and length via the info struct */
237 219
238 table_info->length = (acpi_size) table_header->length; 220 table_info->length = (acpi_size) table_header->length;
239 221
240 return_ACPI_STATUS (status); 222 return_ACPI_STATUS(status);
241} 223}
242 224
243
244/******************************************************************************* 225/*******************************************************************************
245 * 226 *
246 * FUNCTION: acpi_tb_init_table_descriptor 227 * FUNCTION: acpi_tb_init_table_descriptor
@@ -255,30 +236,27 @@ acpi_tb_recognize_table (
255 ******************************************************************************/ 236 ******************************************************************************/
256 237
257acpi_status 238acpi_status
258acpi_tb_init_table_descriptor ( 239acpi_tb_init_table_descriptor(acpi_table_type table_type,
259 acpi_table_type table_type, 240 struct acpi_table_desc *table_info)
260 struct acpi_table_desc *table_info)
261{ 241{
262 struct acpi_table_list *list_head; 242 struct acpi_table_list *list_head;
263 struct acpi_table_desc *table_desc; 243 struct acpi_table_desc *table_desc;
264 acpi_status status; 244 acpi_status status;
265
266
267 ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type);
268 245
246 ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type);
269 247
270 /* Allocate a descriptor for this table */ 248 /* Allocate a descriptor for this table */
271 249
272 table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 250 table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
273 if (!table_desc) { 251 if (!table_desc) {
274 return_ACPI_STATUS (AE_NO_MEMORY); 252 return_ACPI_STATUS(AE_NO_MEMORY);
275 } 253 }
276 254
277 /* Get a new owner ID for the table */ 255 /* Get a new owner ID for the table */
278 256
279 status = acpi_ut_allocate_owner_id (&table_desc->owner_id); 257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id);
280 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE(status)) {
281 return_ACPI_STATUS (status); 259 return_ACPI_STATUS(status);
282 } 260 }
283 261
284 /* Install the table into the global data structure */ 262 /* Install the table into the global data structure */
@@ -290,14 +268,14 @@ acpi_tb_init_table_descriptor (
290 * 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
291 * the table are allowed. This includes SSDT and PSDTs. 269 * the table are allowed. This includes SSDT and PSDTs.
292 */ 270 */
293 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)) {
294 /* 272 /*
295 * Only one table allowed, and a table has alread been installed 273 * Only one table allowed, and a table has alread been installed
296 * at this location, so return an error. 274 * at this location, so return an error.
297 */ 275 */
298 if (list_head->next) { 276 if (list_head->next) {
299 ACPI_MEM_FREE (table_desc); 277 ACPI_MEM_FREE(table_desc);
300 return_ACPI_STATUS (AE_ALREADY_EXISTS); 278 return_ACPI_STATUS(AE_ALREADY_EXISTS);
301 } 279 }
302 280
303 table_desc->next = list_head->next; 281 table_desc->next = list_head->next;
@@ -308,8 +286,7 @@ acpi_tb_init_table_descriptor (
308 } 286 }
309 287
310 list_head->count++; 288 list_head->count++;
311 } 289 } else {
312 else {
313 /* 290 /*
314 * 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.
315 * Insert at the end of the list, order IS IMPORTANT. 292 * Insert at the end of the list, order IS IMPORTANT.
@@ -320,8 +297,7 @@ acpi_tb_init_table_descriptor (
320 297
321 if (!list_head->next) { 298 if (!list_head->next) {
322 list_head->next = table_desc; 299 list_head->next = table_desc;
323 } 300 } else {
324 else {
325 table_desc->next = list_head->next; 301 table_desc->next = list_head->next;
326 302
327 while (table_desc->next->next) { 303 while (table_desc->next->next) {
@@ -336,13 +312,14 @@ acpi_tb_init_table_descriptor (
336 312
337 /* Finish initialization of the table descriptor */ 313 /* Finish initialization of the table descriptor */
338 314
339 table_desc->type = (u8) table_type; 315 table_desc->type = (u8) table_type;
340 table_desc->pointer = table_info->pointer; 316 table_desc->pointer = table_info->pointer;
341 table_desc->length = table_info->length; 317 table_desc->length = table_info->length;
342 table_desc->allocation = table_info->allocation; 318 table_desc->allocation = table_info->allocation;
343 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 319 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
344 table_desc->aml_length = (u32) (table_desc->length - 320 table_desc->aml_length = (u32) (table_desc->length -
345 (u32) sizeof (struct acpi_table_header)); 321 (u32) sizeof(struct
322 acpi_table_header));
346 table_desc->loaded_into_namespace = FALSE; 323 table_desc->loaded_into_namespace = FALSE;
347 324
348 /* 325 /*
@@ -350,18 +327,18 @@ acpi_tb_init_table_descriptor (
350 * newly installed table 327 * newly installed table
351 */ 328 */
352 if (acpi_gbl_table_data[table_type].global_ptr) { 329 if (acpi_gbl_table_data[table_type].global_ptr) {
353 *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; 330 *(acpi_gbl_table_data[table_type].global_ptr) =
331 table_info->pointer;
354 } 332 }
355 333
356 /* Return Data */ 334 /* Return Data */
357 335
358 table_info->owner_id = table_desc->owner_id; 336 table_info->owner_id = table_desc->owner_id;
359 table_info->installed_desc = table_desc; 337 table_info->installed_desc = table_desc;
360 338
361 return_ACPI_STATUS (AE_OK); 339 return_ACPI_STATUS(AE_OK);
362} 340}
363 341
364
365/******************************************************************************* 342/*******************************************************************************
366 * 343 *
367 * FUNCTION: acpi_tb_delete_all_tables 344 * FUNCTION: acpi_tb_delete_all_tables
@@ -374,23 +351,19 @@ acpi_tb_init_table_descriptor (
374 * 351 *
375 ******************************************************************************/ 352 ******************************************************************************/
376 353
377void 354void acpi_tb_delete_all_tables(void)
378acpi_tb_delete_all_tables (
379 void)
380{ 355{
381 acpi_table_type type; 356 acpi_table_type type;
382
383 357
384 /* 358 /*
385 * Free memory allocated for ACPI tables 359 * Free memory allocated for ACPI tables
386 * Memory can either be mapped or allocated 360 * Memory can either be mapped or allocated
387 */ 361 */
388 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { 362 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) {
389 acpi_tb_delete_tables_by_type (type); 363 acpi_tb_delete_tables_by_type(type);
390 } 364 }
391} 365}
392 366
393
394/******************************************************************************* 367/*******************************************************************************
395 * 368 *
396 * FUNCTION: acpi_tb_delete_tables_by_type 369 * FUNCTION: acpi_tb_delete_tables_by_type
@@ -404,23 +377,19 @@ acpi_tb_delete_all_tables (
404 * 377 *
405 ******************************************************************************/ 378 ******************************************************************************/
406 379
407void 380void acpi_tb_delete_tables_by_type(acpi_table_type type)
408acpi_tb_delete_tables_by_type (
409 acpi_table_type type)
410{ 381{
411 struct acpi_table_desc *table_desc; 382 struct acpi_table_desc *table_desc;
412 u32 count; 383 u32 count;
413 u32 i; 384 u32 i;
414
415
416 ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type);
417 385
386 ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type);
418 387
419 if (type > ACPI_TABLE_MAX) { 388 if (type > ACPI_TABLE_MAX) {
420 return_VOID; 389 return_VOID;
421 } 390 }
422 391
423 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { 392 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) {
424 return; 393 return;
425 } 394 }
426 395
@@ -458,21 +427,20 @@ acpi_tb_delete_tables_by_type (
458 * 1) Get the head of the list 427 * 1) Get the head of the list
459 */ 428 */
460 table_desc = acpi_gbl_table_lists[type].next; 429 table_desc = acpi_gbl_table_lists[type].next;
461 count = acpi_gbl_table_lists[type].count; 430 count = acpi_gbl_table_lists[type].count;
462 431
463 /* 432 /*
464 * 2) Walk the entire list, deleting both the allocated tables 433 * 2) Walk the entire list, deleting both the allocated tables
465 * and the table descriptors 434 * and the table descriptors
466 */ 435 */
467 for (i = 0; i < count; i++) { 436 for (i = 0; i < count; i++) {
468 table_desc = acpi_tb_uninstall_table (table_desc); 437 table_desc = acpi_tb_uninstall_table(table_desc);
469 } 438 }
470 439
471 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 440 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
472 return_VOID; 441 return_VOID;
473} 442}
474 443
475
476/******************************************************************************* 444/*******************************************************************************
477 * 445 *
478 * FUNCTION: acpi_tb_delete_single_table 446 * FUNCTION: acpi_tb_delete_single_table
@@ -486,15 +454,12 @@ acpi_tb_delete_tables_by_type (
486 * 454 *
487 ******************************************************************************/ 455 ******************************************************************************/
488 456
489void 457void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc)
490acpi_tb_delete_single_table (
491 struct acpi_table_desc *table_desc)
492{ 458{
493 459
494 /* Must have a valid table descriptor and pointer */ 460 /* Must have a valid table descriptor and pointer */
495 461
496 if ((!table_desc) || 462 if ((!table_desc) || (!table_desc->pointer)) {
497 (!table_desc->pointer)) {
498 return; 463 return;
499 } 464 }
500 465
@@ -506,12 +471,12 @@ acpi_tb_delete_single_table (
506 471
507 case ACPI_MEM_ALLOCATED: 472 case ACPI_MEM_ALLOCATED:
508 473
509 ACPI_MEM_FREE (table_desc->pointer); 474 ACPI_MEM_FREE(table_desc->pointer);
510 break; 475 break;
511 476
512 case ACPI_MEM_MAPPED: 477 case ACPI_MEM_MAPPED:
513 478
514 acpi_os_unmap_memory (table_desc->pointer, table_desc->length); 479 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
515 break; 480 break;
516 481
517 default: 482 default:
@@ -519,7 +484,6 @@ acpi_tb_delete_single_table (
519 } 484 }
520} 485}
521 486
522
523/******************************************************************************* 487/*******************************************************************************
524 * 488 *
525 * FUNCTION: acpi_tb_uninstall_table 489 * FUNCTION: acpi_tb_uninstall_table
@@ -534,26 +498,22 @@ acpi_tb_delete_single_table (
534 * 498 *
535 ******************************************************************************/ 499 ******************************************************************************/
536 500
537struct acpi_table_desc * 501struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
538acpi_tb_uninstall_table ( 502 *table_desc)
539 struct acpi_table_desc *table_desc)
540{ 503{
541 struct acpi_table_desc *next_desc; 504 struct acpi_table_desc *next_desc;
542
543
544 ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc);
545 505
506 ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc);
546 507
547 if (!table_desc) { 508 if (!table_desc) {
548 return_PTR (NULL); 509 return_PTR(NULL);
549 } 510 }
550 511
551 /* Unlink the descriptor from the doubly linked list */ 512 /* Unlink the descriptor from the doubly linked list */
552 513
553 if (table_desc->prev) { 514 if (table_desc->prev) {
554 table_desc->prev->next = table_desc->next; 515 table_desc->prev->next = table_desc->next;
555 } 516 } else {
556 else {
557 /* Is first on list, update list head */ 517 /* Is first on list, update list head */
558 518
559 acpi_gbl_table_lists[table_desc->type].next = table_desc->next; 519 acpi_gbl_table_lists[table_desc->type].next = table_desc->next;
@@ -565,16 +525,14 @@ acpi_tb_uninstall_table (
565 525
566 /* Free the memory allocated for the table itself */ 526 /* Free the memory allocated for the table itself */
567 527
568 acpi_tb_delete_single_table (table_desc); 528 acpi_tb_delete_single_table(table_desc);
569 529
570 /* Free the table descriptor */ 530 /* Free the table descriptor */
571 531
572 next_desc = table_desc->next; 532 next_desc = table_desc->next;
573 ACPI_MEM_FREE (table_desc); 533 ACPI_MEM_FREE(table_desc);
574 534
575 /* Return pointer to the next descriptor */ 535 /* Return pointer to the next descriptor */
576 536
577 return_PTR (next_desc); 537 return_PTR(next_desc);
578} 538}
579
580
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 069d498465d0..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,54 +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 /* Verify RSDP signature and checksum */ 91 /* Verify RSDP signature and checksum */
100 92
101 status = acpi_tb_validate_rsdp (rsdp); 93 status = acpi_tb_validate_rsdp(rsdp);
102 if (ACPI_FAILURE (status)) { 94 if (ACPI_FAILURE(status)) {
103 goto cleanup; 95 goto cleanup;
104 } 96 }
105 97
106 /* The RSDP supplied is OK */ 98 /* The RSDP supplied is OK */
107 99
108 table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); 100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp);
109 table_info.length = sizeof (struct rsdp_descriptor); 101 table_info.length = sizeof(struct rsdp_descriptor);
110 table_info.allocation = ACPI_MEM_MAPPED; 102 table_info.allocation = ACPI_MEM_MAPPED;
111 103
112 /* Save the table pointers and allocation info */ 104 /* Save the table pointers and allocation info */
113 105
114 status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); 106 status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info);
115 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
116 goto cleanup; 108 goto cleanup;
117 } 109 }
118 110
119 /* Save the RSDP in a global for easy access */ 111 /* Save the RSDP in a global for easy access */
120 112
121 acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer); 113 acpi_gbl_RSDP =
122 return_ACPI_STATUS (status); 114 ACPI_CAST_PTR(struct rsdp_descriptor, table_info.pointer);
123 115 return_ACPI_STATUS(status);
124 116
125 /* Error exit */ 117 /* Error exit */
126cleanup: 118 cleanup:
127 119
128 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) { 120 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) {
129 acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor)); 121 acpi_os_unmap_memory(rsdp, sizeof(struct rsdp_descriptor));
130 } 122 }
131 return_ACPI_STATUS (status); 123 return_ACPI_STATUS(status);
132} 124}
133 125
134
135/******************************************************************************* 126/*******************************************************************************
136 * 127 *
137 * FUNCTION: acpi_tb_get_rsdt_address 128 * FUNCTION: acpi_tb_get_rsdt_address
@@ -145,33 +136,30 @@ cleanup:
145 * 136 *
146 ******************************************************************************/ 137 ******************************************************************************/
147 138
148void 139void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address)
149acpi_tb_get_rsdt_address (
150 struct acpi_pointer *out_address)
151{ 140{
152 141
153 ACPI_FUNCTION_ENTRY (); 142 ACPI_FUNCTION_ENTRY();
154
155 143
156 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; 144 out_address->pointer_type =
145 acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
157 146
158 /* Use XSDT if it is present */ 147 /* Use XSDT if it is present */
159 148
160 if ((acpi_gbl_RSDP->revision >= 2) && 149 if ((acpi_gbl_RSDP->revision >= 2) &&
161 acpi_gbl_RSDP->xsdt_physical_address) { 150 acpi_gbl_RSDP->xsdt_physical_address) {
162 out_address->pointer.value = 151 out_address->pointer.value =
163 acpi_gbl_RSDP->xsdt_physical_address; 152 acpi_gbl_RSDP->xsdt_physical_address;
164 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT; 153 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
165 } 154 } else {
166 else {
167 /* No XSDT, use the RSDT */ 155 /* No XSDT, use the RSDT */
168 156
169 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; 157 out_address->pointer.value =
158 acpi_gbl_RSDP->rsdt_physical_address;
170 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT; 159 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
171 } 160 }
172} 161}
173 162
174
175/******************************************************************************* 163/*******************************************************************************
176 * 164 *
177 * FUNCTION: acpi_tb_validate_rsdt 165 * FUNCTION: acpi_tb_validate_rsdt
@@ -184,49 +172,43 @@ acpi_tb_get_rsdt_address (
184 * 172 *
185 ******************************************************************************/ 173 ******************************************************************************/
186 174
187acpi_status 175acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
188acpi_tb_validate_rsdt (
189 struct acpi_table_header *table_ptr)
190{ 176{
191 int no_match; 177 int no_match;
192
193
194 ACPI_FUNCTION_NAME ("tb_validate_rsdt");
195 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt");
196 180
197 /* 181 /*
198 * Search for appropriate signature, RSDT or XSDT 182 * Search for appropriate signature, RSDT or XSDT
199 */ 183 */
200 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 184 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
201 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, 185 no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG,
202 sizeof (RSDT_SIG) -1); 186 sizeof(RSDT_SIG) - 1);
203 } 187 } else {
204 else { 188 no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG,
205 no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG, 189 sizeof(XSDT_SIG) - 1);
206 sizeof (XSDT_SIG) -1);
207 } 190 }
208 191
209 if (no_match) { 192 if (no_match) {
210 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
211 194
212 ACPI_REPORT_ERROR (( 195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
213 "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
214 196
215 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); 197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
216 198
217 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, 199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR,
218 "RSDT/XSDT signature at %X (%p) is invalid\n", 200 "RSDT/XSDT signature at %X (%p) is invalid\n",
219 acpi_gbl_RSDP->rsdt_physical_address, 201 acpi_gbl_RSDP->rsdt_physical_address,
220 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); 202 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address));
221 204
222 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
223 ACPI_REPORT_ERROR (("Looking for RSDT\n")) 206 ACPI_REPORT_ERROR(("Looking for RSDT\n"))
224 } 207 } else {
225 else { 208 ACPI_REPORT_ERROR(("Looking for XSDT\n"))
226 ACPI_REPORT_ERROR (("Looking for XSDT\n"))
227 } 209 }
228 210
229 ACPI_DUMP_BUFFER ((char *) table_ptr, 48); 211 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
230 212
231 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
232 } 214 }
@@ -234,7 +216,6 @@ acpi_tb_validate_rsdt (
234 return (AE_OK); 216 return (AE_OK);
235} 217}
236 218
237
238/******************************************************************************* 219/*******************************************************************************
239 * 220 *
240 * FUNCTION: acpi_tb_get_table_rsdt 221 * FUNCTION: acpi_tb_get_table_rsdt
@@ -247,66 +228,61 @@ acpi_tb_validate_rsdt (
247 * 228 *
248 ******************************************************************************/ 229 ******************************************************************************/
249 230
250acpi_status 231acpi_status acpi_tb_get_table_rsdt(void)
251acpi_tb_get_table_rsdt (
252 void)
253{ 232{
254 struct acpi_table_desc table_info; 233 struct acpi_table_desc table_info;
255 acpi_status status; 234 acpi_status status;
256 struct acpi_pointer address; 235 struct acpi_pointer address;
257
258
259 ACPI_FUNCTION_TRACE ("tb_get_table_rsdt");
260 236
237 ACPI_FUNCTION_TRACE("tb_get_table_rsdt");
261 238
262 /* Get the RSDT/XSDT via the RSDP */ 239 /* Get the RSDT/XSDT via the RSDP */
263 240
264 acpi_tb_get_rsdt_address (&address); 241 acpi_tb_get_rsdt_address(&address);
265 242
266 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
267 status = acpi_tb_get_table (&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
268 if (ACPI_FAILURE (status)) { 245 if (ACPI_FAILURE(status)) {
269 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", 246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
270 acpi_format_exception (status))); 247 "Could not get the RSDT/XSDT, %s\n",
248 acpi_format_exception(status)));
271 249
272 return_ACPI_STATUS (status); 250 return_ACPI_STATUS(status);
273 } 251 }
274 252
275 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
276 "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",
277 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
278 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
279 257
280 /* Check the RSDT or XSDT signature */ 258 /* Check the RSDT or XSDT signature */
281 259
282 status = acpi_tb_validate_rsdt (table_info.pointer); 260 status = acpi_tb_validate_rsdt(table_info.pointer);
283 if (ACPI_FAILURE (status)) { 261 if (ACPI_FAILURE(status)) {
284 return_ACPI_STATUS (status); 262 return_ACPI_STATUS(status);
285 } 263 }
286 264
287 /* Get the number of tables defined in the RSDT or XSDT */ 265 /* Get the number of tables defined in the RSDT or XSDT */
288 266
289 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,
290 table_info.pointer); 268 table_info.pointer);
291 269
292 /* Convert and/or copy to an XSDT structure */ 270 /* Convert and/or copy to an XSDT structure */
293 271
294 status = acpi_tb_convert_to_xsdt (&table_info); 272 status = acpi_tb_convert_to_xsdt(&table_info);
295 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE(status)) {
296 return_ACPI_STATUS (status); 274 return_ACPI_STATUS(status);
297 } 275 }
298 276
299 /* Save the table pointers and allocation info */ 277 /* Save the table pointers and allocation info */
300 278
301 status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); 279 status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info);
302 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
303 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
304 } 282 }
305 283
306 acpi_gbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info.pointer); 284 acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer);
307 285
308 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));
309 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
310} 288}
311
312
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 6fc1e36e6042..5bcafebb9ddf 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -41,24 +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/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
61
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
64 * FUNCTION: acpi_tb_is_table_installed 58 * FUNCTION: acpi_tb_is_table_installed
@@ -73,15 +67,11 @@ acpi_tb_handle_to_object (
73 * 67 *
74 ******************************************************************************/ 68 ******************************************************************************/
75 69
76acpi_status 70acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
77acpi_tb_is_table_installed (
78 struct acpi_table_desc *new_table_desc)
79{ 71{
80 struct acpi_table_desc *table_desc; 72 struct acpi_table_desc *table_desc;
81
82
83 ACPI_FUNCTION_TRACE ("tb_is_table_installed");
84 73
74 ACPI_FUNCTION_TRACE("tb_is_table_installed");
85 75
86 /* Get the list descriptor and first table descriptor */ 76 /* Get the list descriptor and first table descriptor */
87 77
@@ -93,22 +83,23 @@ acpi_tb_is_table_installed (
93 /* Compare Revision and oem_table_id */ 83 /* Compare Revision and oem_table_id */
94 84
95 if ((table_desc->loaded_into_namespace) && 85 if ((table_desc->loaded_into_namespace) &&
96 (table_desc->pointer->revision == 86 (table_desc->pointer->revision ==
97 new_table_desc->pointer->revision) && 87 new_table_desc->pointer->revision) &&
98 (!ACPI_MEMCMP (table_desc->pointer->oem_table_id, 88 (!ACPI_MEMCMP(table_desc->pointer->oem_table_id,
99 new_table_desc->pointer->oem_table_id, 8))) { 89 new_table_desc->pointer->oem_table_id, 8))) {
100 /* This table is already installed */ 90 /* This table is already installed */
101 91
102 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 92 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
103 "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", 93 "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n",
104 new_table_desc->pointer->signature, 94 new_table_desc->pointer->signature,
105 new_table_desc->pointer->revision, 95 new_table_desc->pointer->revision,
106 new_table_desc->pointer->oem_table_id)); 96 new_table_desc->pointer->
97 oem_table_id));
107 98
108 new_table_desc->owner_id = table_desc->owner_id; 99 new_table_desc->owner_id = table_desc->owner_id;
109 new_table_desc->installed_desc = table_desc; 100 new_table_desc->installed_desc = table_desc;
110 101
111 return_ACPI_STATUS (AE_ALREADY_EXISTS); 102 return_ACPI_STATUS(AE_ALREADY_EXISTS);
112 } 103 }
113 104
114 /* Get next table on the list */ 105 /* Get next table on the list */
@@ -116,10 +107,9 @@ acpi_tb_is_table_installed (
116 table_desc = table_desc->next; 107 table_desc = table_desc->next;
117 } 108 }
118 109
119 return_ACPI_STATUS (AE_OK); 110 return_ACPI_STATUS(AE_OK);
120} 111}
121 112
122
123/******************************************************************************* 113/*******************************************************************************
124 * 114 *
125 * FUNCTION: acpi_tb_validate_table_header 115 * FUNCTION: acpi_tb_validate_table_header
@@ -141,57 +131,55 @@ acpi_tb_is_table_installed (
141 ******************************************************************************/ 131 ******************************************************************************/
142 132
143acpi_status 133acpi_status
144acpi_tb_validate_table_header ( 134acpi_tb_validate_table_header(struct acpi_table_header *table_header)
145 struct acpi_table_header *table_header)
146{ 135{
147 acpi_name signature; 136 acpi_name signature;
148
149
150 ACPI_FUNCTION_NAME ("tb_validate_table_header");
151 137
138 ACPI_FUNCTION_NAME("tb_validate_table_header");
152 139
153 /* Verify that this is a valid address */ 140 /* Verify that this is a valid address */
154 141
155 if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) { 142 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
156 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 143 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
157 "Cannot read table header at %p\n", table_header)); 144 "Cannot read table header at %p\n",
145 table_header));
158 146
159 return (AE_BAD_ADDRESS); 147 return (AE_BAD_ADDRESS);
160 } 148 }
161 149
162 /* Ensure that the signature is 4 ASCII characters */ 150 /* Ensure that the signature is 4 ASCII characters */
163 151
164 ACPI_MOVE_32_TO_32 (&signature, table_header->signature); 152 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
165 if (!acpi_ut_valid_acpi_name (signature)) { 153 if (!acpi_ut_valid_acpi_name(signature)) {
166 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
167 "Table signature at %p [%p] has invalid characters\n", 155 "Table signature at %p [%p] has invalid characters\n",
168 table_header, &signature)); 156 table_header, &signature));
169 157
170 ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", 158 ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n",
171 (char *) &signature)); 159 (char *)&signature));
172 160
173 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 161 ACPI_DUMP_BUFFER(table_header,
162 sizeof(struct acpi_table_header));
174 return (AE_BAD_SIGNATURE); 163 return (AE_BAD_SIGNATURE);
175 } 164 }
176 165
177 /* Validate the table length */ 166 /* Validate the table length */
178 167
179 if (table_header->length < sizeof (struct acpi_table_header)) { 168 if (table_header->length < sizeof(struct acpi_table_header)) {
180 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 169 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
181 "Invalid length in table header %p name %4.4s\n", 170 "Invalid length in table header %p name %4.4s\n",
182 table_header, (char *) &signature)); 171 table_header, (char *)&signature));
183 172
184 ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", 173 ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length));
185 (u32) table_header->length));
186 174
187 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 175 ACPI_DUMP_BUFFER(table_header,
176 sizeof(struct acpi_table_header));
188 return (AE_BAD_HEADER); 177 return (AE_BAD_HEADER);
189 } 178 }
190 179
191 return (AE_OK); 180 return (AE_OK);
192} 181}
193 182
194
195/******************************************************************************* 183/*******************************************************************************
196 * 184 *
197 * FUNCTION: acpi_tb_verify_table_checksum 185 * FUNCTION: acpi_tb_verify_table_checksum
@@ -206,34 +194,28 @@ acpi_tb_validate_table_header (
206 ******************************************************************************/ 194 ******************************************************************************/
207 195
208acpi_status 196acpi_status
209acpi_tb_verify_table_checksum ( 197acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
210 struct acpi_table_header *table_header)
211{ 198{
212 u8 checksum; 199 u8 checksum;
213 acpi_status status = AE_OK; 200 acpi_status status = AE_OK;
214
215
216 ACPI_FUNCTION_TRACE ("tb_verify_table_checksum");
217 201
202 ACPI_FUNCTION_TRACE("tb_verify_table_checksum");
218 203
219 /* Compute the checksum on the table */ 204 /* Compute the checksum on the table */
220 205
221 checksum = acpi_tb_generate_checksum (table_header, table_header->length); 206 checksum =
207 acpi_tb_generate_checksum(table_header, table_header->length);
222 208
223 /* Return the appropriate exception */ 209 /* Return the appropriate exception */
224 210
225 if (checksum) { 211 if (checksum) {
226 ACPI_REPORT_WARNING (( 212 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));
227 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
228 table_header->signature, (u32) table_header->checksum,
229 (u32) checksum));
230 213
231 status = AE_BAD_CHECKSUM; 214 status = AE_BAD_CHECKSUM;
232 } 215 }
233 return_ACPI_STATUS (status); 216 return_ACPI_STATUS(status);
234} 217}
235 218
236
237/******************************************************************************* 219/*******************************************************************************
238 * 220 *
239 * FUNCTION: acpi_tb_generate_checksum 221 * FUNCTION: acpi_tb_generate_checksum
@@ -247,15 +229,11 @@ acpi_tb_verify_table_checksum (
247 * 229 *
248 ******************************************************************************/ 230 ******************************************************************************/
249 231
250u8 232u8 acpi_tb_generate_checksum(void *buffer, u32 length)
251acpi_tb_generate_checksum (
252 void *buffer,
253 u32 length)
254{ 233{
255 const u8 *limit; 234 const u8 *limit;
256 const u8 *rover; 235 const u8 *rover;
257 u8 sum = 0; 236 u8 sum = 0;
258
259 237
260 if (buffer && length) { 238 if (buffer && length) {
261 /* Buffer and Length are valid */ 239 /* Buffer and Length are valid */
@@ -269,7 +247,6 @@ acpi_tb_generate_checksum (
269 return (sum); 247 return (sum);
270} 248}
271 249
272
273#ifdef ACPI_OBSOLETE_FUNCTIONS 250#ifdef ACPI_OBSOLETE_FUNCTIONS
274/******************************************************************************* 251/*******************************************************************************
275 * 252 *
@@ -285,16 +262,13 @@ acpi_tb_generate_checksum (
285 ******************************************************************************/ 262 ******************************************************************************/
286 263
287acpi_status 264acpi_status
288acpi_tb_handle_to_object ( 265acpi_tb_handle_to_object(u16 table_id,
289 u16 table_id, 266 struct acpi_table_desc ** return_table_desc)
290 struct acpi_table_desc **return_table_desc)
291{ 267{
292 u32 i; 268 u32 i;
293 struct acpi_table_desc *table_desc; 269 struct acpi_table_desc *table_desc;
294
295
296 ACPI_FUNCTION_NAME ("tb_handle_to_object");
297 270
271 ACPI_FUNCTION_NAME("tb_handle_to_object");
298 272
299 for (i = 0; i < ACPI_TABLE_MAX; i++) { 273 for (i = 0; i < ACPI_TABLE_MAX; i++) {
300 table_desc = acpi_gbl_table_lists[i].next; 274 table_desc = acpi_gbl_table_lists[i].next;
@@ -308,9 +282,8 @@ acpi_tb_handle_to_object (
308 } 282 }
309 } 283 }
310 284
311 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id)); 285 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n",
286 table_id));
312 return (AE_BAD_PARAMETER); 287 return (AE_BAD_PARAMETER);
313} 288}
314#endif 289#endif
315
316
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index e18a05d1b9b3..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,43 +142,39 @@ 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);
183 } 165 }
184 166
185 /* Check signature for a valid table type */ 167 /* Check signature for a valid table type */
186 168
187 status = acpi_tb_recognize_table (&table_info, ACPI_TABLE_ALL); 169 status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL);
188 if (ACPI_FAILURE (status)) { 170 if (ACPI_FAILURE(status)) {
189 return_ACPI_STATUS (status); 171 return_ACPI_STATUS(status);
190 } 172 }
191 173
192 /* Install the new table into the local data structures */ 174 /* Install the new table into the local data structures */
193 175
194 status = acpi_tb_install_table (&table_info); 176 status = acpi_tb_install_table(&table_info);
195 if (ACPI_FAILURE (status)) { 177 if (ACPI_FAILURE(status)) {
196 if (status == AE_ALREADY_EXISTS) { 178 if (status == AE_ALREADY_EXISTS) {
197 /* Table already exists, no error */ 179 /* Table already exists, no error */
198 180
@@ -201,8 +183,8 @@ acpi_load_table (
201 183
202 /* Free table allocated by acpi_tb_get_table_body */ 184 /* Free table allocated by acpi_tb_get_table_body */
203 185
204 acpi_tb_delete_single_table (&table_info); 186 acpi_tb_delete_single_table(&table_info);
205 return_ACPI_STATUS (status); 187 return_ACPI_STATUS(status);
206 } 188 }
207 189
208 /* Convert the table to common format if necessary */ 190 /* Convert the table to common format if necessary */
@@ -210,31 +192,32 @@ acpi_load_table (
210 switch (table_info.type) { 192 switch (table_info.type) {
211 case ACPI_TABLE_FADT: 193 case ACPI_TABLE_FADT:
212 194
213 status = acpi_tb_convert_table_fadt (); 195 status = acpi_tb_convert_table_fadt();
214 break; 196 break;
215 197
216 case ACPI_TABLE_FACS: 198 case ACPI_TABLE_FACS:
217 199
218 status = acpi_tb_build_common_facs (&table_info); 200 status = acpi_tb_build_common_facs(&table_info);
219 break; 201 break;
220 202
221 default: 203 default:
222 /* Load table into namespace if it contains executable AML */ 204 /* Load table into namespace if it contains executable AML */
223 205
224 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);
225 break; 209 break;
226 } 210 }
227 211
228 if (ACPI_FAILURE (status)) { 212 if (ACPI_FAILURE(status)) {
229 /* Uninstall table and free the buffer */ 213 /* Uninstall table and free the buffer */
230 214
231 (void) acpi_tb_uninstall_table (table_info.installed_desc); 215 (void)acpi_tb_uninstall_table(table_info.installed_desc);
232 } 216 }
233 217
234 return_ACPI_STATUS (status); 218 return_ACPI_STATUS(status);
235} 219}
236 220
237
238/******************************************************************************* 221/*******************************************************************************
239 * 222 *
240 * FUNCTION: acpi_unload_table 223 * FUNCTION: acpi_unload_table
@@ -247,20 +230,16 @@ acpi_load_table (
247 * 230 *
248 ******************************************************************************/ 231 ******************************************************************************/
249 232
250acpi_status 233acpi_status acpi_unload_table(acpi_table_type table_type)
251acpi_unload_table (
252 acpi_table_type table_type)
253{ 234{
254 struct acpi_table_desc *table_desc; 235 struct acpi_table_desc *table_desc;
255
256
257 ACPI_FUNCTION_TRACE ("acpi_unload_table");
258 236
237 ACPI_FUNCTION_TRACE("acpi_unload_table");
259 238
260 /* Parameter validation */ 239 /* Parameter validation */
261 240
262 if (table_type > ACPI_TABLE_MAX) { 241 if (table_type > ACPI_TABLE_MAX) {
263 return_ACPI_STATUS (AE_BAD_PARAMETER); 242 return_ACPI_STATUS(AE_BAD_PARAMETER);
264 } 243 }
265 244
266 /* Find all tables of the requested type */ 245 /* Find all tables of the requested type */
@@ -273,18 +252,17 @@ acpi_unload_table (
273 * "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
274 * simply a position within the hierarchy 253 * simply a position within the hierarchy
275 */ 254 */
276 acpi_ns_delete_namespace_by_owner (table_desc->owner_id); 255 acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
277 acpi_ut_release_owner_id (&table_desc->owner_id); 256 acpi_ut_release_owner_id(&table_desc->owner_id);
278 table_desc = table_desc->next; 257 table_desc = table_desc->next;
279 } 258 }
280 259
281 /* Delete (or unmap) all tables of this type */ 260 /* Delete (or unmap) all tables of this type */
282 261
283 acpi_tb_delete_tables_by_type (table_type); 262 acpi_tb_delete_tables_by_type(table_type);
284 return_ACPI_STATUS (AE_OK); 263 return_ACPI_STATUS(AE_OK);
285} 264}
286 265
287
288/******************************************************************************* 266/*******************************************************************************
289 * 267 *
290 * FUNCTION: acpi_get_table_header 268 * FUNCTION: acpi_get_table_header
@@ -307,54 +285,49 @@ acpi_unload_table (
307 ******************************************************************************/ 285 ******************************************************************************/
308 286
309acpi_status 287acpi_status
310acpi_get_table_header ( 288acpi_get_table_header(acpi_table_type table_type,
311 acpi_table_type table_type, 289 u32 instance, struct acpi_table_header *out_table_header)
312 u32 instance,
313 struct acpi_table_header *out_table_header)
314{ 290{
315 struct acpi_table_header *tbl_ptr; 291 struct acpi_table_header *tbl_ptr;
316 acpi_status status; 292 acpi_status status;
317
318
319 ACPI_FUNCTION_TRACE ("acpi_get_table_header");
320 293
294 ACPI_FUNCTION_TRACE("acpi_get_table_header");
321 295
322 if ((instance == 0) || 296 if ((instance == 0) ||
323 (table_type == ACPI_TABLE_RSDP) || 297 (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) {
324 (!out_table_header)) { 298 return_ACPI_STATUS(AE_BAD_PARAMETER);
325 return_ACPI_STATUS (AE_BAD_PARAMETER);
326 } 299 }
327 300
328 /* Check the table type and instance */ 301 /* Check the table type and instance */
329 302
330 if ((table_type > ACPI_TABLE_MAX) || 303 if ((table_type > ACPI_TABLE_MAX) ||
331 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 304 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
332 instance > 1)) { 305 instance > 1)) {
333 return_ACPI_STATUS (AE_BAD_PARAMETER); 306 return_ACPI_STATUS(AE_BAD_PARAMETER);
334 } 307 }
335 308
336 /* Get a pointer to the entire table */ 309 /* Get a pointer to the entire table */
337 310
338 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 311 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
339 if (ACPI_FAILURE (status)) { 312 if (ACPI_FAILURE(status)) {
340 return_ACPI_STATUS (status); 313 return_ACPI_STATUS(status);
341 } 314 }
342 315
343 /* 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 */
344 317
345 if (tbl_ptr == NULL) { 318 if (tbl_ptr == NULL) {
346 return_ACPI_STATUS (AE_NOT_EXIST); 319 return_ACPI_STATUS(AE_NOT_EXIST);
347 } 320 }
348 321
349 /* Copy the header to the caller's buffer */ 322 /* Copy the header to the caller's buffer */
350 323
351 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, 324 ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr,
352 sizeof (struct acpi_table_header)); 325 sizeof(struct acpi_table_header));
353 326
354 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
355} 328}
356 329
357#endif /* ACPI_FUTURE_USAGE */ 330#endif /* ACPI_FUTURE_USAGE */
358 331
359/******************************************************************************* 332/*******************************************************************************
360 * 333 *
@@ -380,43 +353,39 @@ acpi_get_table_header (
380 ******************************************************************************/ 353 ******************************************************************************/
381 354
382acpi_status 355acpi_status
383acpi_get_table ( 356acpi_get_table(acpi_table_type table_type,
384 acpi_table_type table_type, 357 u32 instance, struct acpi_buffer *ret_buffer)
385 u32 instance,
386 struct acpi_buffer *ret_buffer)
387{ 358{
388 struct acpi_table_header *tbl_ptr; 359 struct acpi_table_header *tbl_ptr;
389 acpi_status status; 360 acpi_status status;
390 acpi_size table_length; 361 acpi_size table_length;
391
392
393 ACPI_FUNCTION_TRACE ("acpi_get_table");
394 362
363 ACPI_FUNCTION_TRACE("acpi_get_table");
395 364
396 /* Parameter validation */ 365 /* Parameter validation */
397 366
398 if (instance == 0) { 367 if (instance == 0) {
399 return_ACPI_STATUS (AE_BAD_PARAMETER); 368 return_ACPI_STATUS(AE_BAD_PARAMETER);
400 } 369 }
401 370
402 status = acpi_ut_validate_buffer (ret_buffer); 371 status = acpi_ut_validate_buffer(ret_buffer);
403 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS (status); 373 return_ACPI_STATUS(status);
405 } 374 }
406 375
407 /* Check the table type and instance */ 376 /* Check the table type and instance */
408 377
409 if ((table_type > ACPI_TABLE_MAX) || 378 if ((table_type > ACPI_TABLE_MAX) ||
410 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 379 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
411 instance > 1)) { 380 instance > 1)) {
412 return_ACPI_STATUS (AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
413 } 382 }
414 383
415 /* Get a pointer to the entire table */ 384 /* Get a pointer to the entire table */
416 385
417 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 386 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
418 if (ACPI_FAILURE (status)) { 387 if (ACPI_FAILURE(status)) {
419 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
420 } 389 }
421 390
422 /* 391 /*
@@ -424,7 +393,7 @@ acpi_get_table (
424 * table is not loaded. 393 * table is not loaded.
425 */ 394 */
426 if (tbl_ptr == NULL) { 395 if (tbl_ptr == NULL) {
427 return_ACPI_STATUS (AE_NOT_EXIST); 396 return_ACPI_STATUS(AE_NOT_EXIST);
428 } 397 }
429 398
430 /* Get the table length */ 399 /* Get the table length */
@@ -432,23 +401,22 @@ acpi_get_table (
432 if (table_type == ACPI_TABLE_RSDP) { 401 if (table_type == ACPI_TABLE_RSDP) {
433 /* RSD PTR is the only "table" without a header */ 402 /* RSD PTR is the only "table" without a header */
434 403
435 table_length = sizeof (struct rsdp_descriptor); 404 table_length = sizeof(struct rsdp_descriptor);
436 } 405 } else {
437 else {
438 table_length = (acpi_size) tbl_ptr->length; 406 table_length = (acpi_size) tbl_ptr->length;
439 } 407 }
440 408
441 /* Validate/Allocate/Clear caller buffer */ 409 /* Validate/Allocate/Clear caller buffer */
442 410
443 status = acpi_ut_initialize_buffer (ret_buffer, table_length); 411 status = acpi_ut_initialize_buffer(ret_buffer, table_length);
444 if (ACPI_FAILURE (status)) { 412 if (ACPI_FAILURE(status)) {
445 return_ACPI_STATUS (status); 413 return_ACPI_STATUS(status);
446 } 414 }
447 415
448 /* Copy the table to the buffer */ 416 /* Copy the table to the buffer */
449 417
450 ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); 418 ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length);
451 return_ACPI_STATUS (AE_OK); 419 return_ACPI_STATUS(AE_OK);
452} 420}
453EXPORT_SYMBOL(acpi_get_table);
454 421
422EXPORT_SYMBOL(acpi_get_table);
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 87dccdda9ae2..3b8a7e063e8a 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -46,22 +46,14 @@
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
60static u8 *
61acpi_tb_scan_memory_for_rsdp (
62 u8 *start_address,
63 u32 length);
64 55
56static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
65 57
66/******************************************************************************* 58/*******************************************************************************
67 * 59 *
@@ -75,17 +67,14 @@ acpi_tb_scan_memory_for_rsdp (
75 * 67 *
76 ******************************************************************************/ 68 ******************************************************************************/
77 69
78acpi_status 70acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
79acpi_tb_validate_rsdp (
80 struct rsdp_descriptor *rsdp)
81{ 71{
82 ACPI_FUNCTION_ENTRY (); 72 ACPI_FUNCTION_ENTRY();
83
84 73
85 /* 74 /*
86 * The signature and checksum must both be correct 75 * The signature and checksum must both be correct
87 */ 76 */
88 if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { 77 if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) {
89 /* Nope, BAD Signature */ 78 /* Nope, BAD Signature */
90 79
91 return (AE_BAD_SIGNATURE); 80 return (AE_BAD_SIGNATURE);
@@ -93,21 +82,21 @@ acpi_tb_validate_rsdp (
93 82
94 /* Check the standard checksum */ 83 /* Check the standard checksum */
95 84
96 if (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { 85 if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
97 return (AE_BAD_CHECKSUM); 86 return (AE_BAD_CHECKSUM);
98 } 87 }
99 88
100 /* Check extended checksum if table version >= 2 */ 89 /* Check extended checksum if table version >= 2 */
101 90
102 if ((rsdp->revision >= 2) && 91 if ((rsdp->revision >= 2) &&
103 (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { 92 (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) !=
93 0)) {
104 return (AE_BAD_CHECKSUM); 94 return (AE_BAD_CHECKSUM);
105 } 95 }
106 96
107 return (AE_OK); 97 return (AE_OK);
108} 98}
109 99
110
111/******************************************************************************* 100/*******************************************************************************
112 * 101 *
113 * FUNCTION: acpi_tb_find_table 102 * FUNCTION: acpi_tb_find_table
@@ -125,28 +114,24 @@ acpi_tb_validate_rsdp (
125 ******************************************************************************/ 114 ******************************************************************************/
126 115
127acpi_status 116acpi_status
128acpi_tb_find_table ( 117acpi_tb_find_table(char *signature,
129 char *signature, 118 char *oem_id,
130 char *oem_id, 119 char *oem_table_id, struct acpi_table_header ** table_ptr)
131 char *oem_table_id,
132 struct acpi_table_header **table_ptr)
133{ 120{
134 acpi_status status; 121 acpi_status status;
135 struct acpi_table_header *table; 122 struct acpi_table_header *table;
136
137
138 ACPI_FUNCTION_TRACE ("tb_find_table");
139 123
124 ACPI_FUNCTION_TRACE("tb_find_table");
140 125
141 /* Validate string lengths */ 126 /* Validate string lengths */
142 127
143 if ((ACPI_STRLEN (signature) > ACPI_NAME_SIZE) || 128 if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) ||
144 (ACPI_STRLEN (oem_id) > sizeof (table->oem_id)) || 129 (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) ||
145 (ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) { 130 (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) {
146 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 131 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
147 } 132 }
148 133
149 if (!ACPI_STRNCMP (signature, DSDT_SIG, ACPI_NAME_SIZE)) { 134 if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) {
150 /* 135 /*
151 * The DSDT pointer is contained in the FADT, not the RSDT. 136 * The DSDT pointer is contained in the FADT, not the RSDT.
152 * This code should suffice, because the only code that would perform 137 * This code should suffice, because the only code that would perform
@@ -155,40 +140,36 @@ acpi_tb_find_table (
155 * 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.
156 */ 141 */
157 if (!acpi_gbl_DSDT) { 142 if (!acpi_gbl_DSDT) {
158 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 143 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
159 } 144 }
160 table = acpi_gbl_DSDT; 145 table = acpi_gbl_DSDT;
161 } 146 } else {
162 else {
163 /* Find the table */ 147 /* Find the table */
164 148
165 status = acpi_get_firmware_table (signature, 1, 149 status = acpi_get_firmware_table(signature, 1,
166 ACPI_LOGICAL_ADDRESSING, &table); 150 ACPI_LOGICAL_ADDRESSING,
167 if (ACPI_FAILURE (status)) { 151 &table);
168 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
169 } 154 }
170 } 155 }
171 156
172 /* Check oem_id and oem_table_id */ 157 /* Check oem_id and oem_table_id */
173 158
174 if ((oem_id[0] && ACPI_STRNCMP ( 159 if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id,
175 oem_id, table->oem_id, 160 sizeof(table->oem_id))) ||
176 sizeof (table->oem_id))) || 161 (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id,
177 162 sizeof(table->oem_table_id)))) {
178 (oem_table_id[0] && ACPI_STRNCMP ( 163 return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
179 oem_table_id, table->oem_table_id,
180 sizeof (table->oem_table_id)))) {
181 return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
182 } 164 }
183 165
184 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", 166 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n",
185 table->signature)); 167 table->signature));
186 168
187 *table_ptr = table; 169 *table_ptr = table;
188 return_ACPI_STATUS (AE_OK); 170 return_ACPI_STATUS(AE_OK);
189} 171}
190 172
191
192/******************************************************************************* 173/*******************************************************************************
193 * 174 *
194 * FUNCTION: acpi_get_firmware_table 175 * FUNCTION: acpi_get_firmware_table
@@ -209,34 +190,28 @@ acpi_tb_find_table (
209 ******************************************************************************/ 190 ******************************************************************************/
210 191
211acpi_status 192acpi_status
212acpi_get_firmware_table ( 193acpi_get_firmware_table(acpi_string signature,
213 acpi_string signature, 194 u32 instance,
214 u32 instance, 195 u32 flags, struct acpi_table_header **table_pointer)
215 u32 flags,
216 struct acpi_table_header **table_pointer)
217{ 196{
218 acpi_status status; 197 acpi_status status;
219 struct acpi_pointer address; 198 struct acpi_pointer address;
220 struct acpi_table_header *header = NULL; 199 struct acpi_table_header *header = NULL;
221 struct acpi_table_desc *table_info = NULL; 200 struct acpi_table_desc *table_info = NULL;
222 struct acpi_table_desc *rsdt_info; 201 struct acpi_table_desc *rsdt_info;
223 u32 table_count; 202 u32 table_count;
224 u32 i; 203 u32 i;
225 u32 j; 204 u32 j;
226
227
228 ACPI_FUNCTION_TRACE ("acpi_get_firmware_table");
229 205
206 ACPI_FUNCTION_TRACE("acpi_get_firmware_table");
230 207
231 /* 208 /*
232 * 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
233 * require that the entire ACPI subsystem is up for this interface. 210 * require that the entire ACPI subsystem is up for this interface.
234 * If we have a buffer, we must have a length too 211 * If we have a buffer, we must have a length too
235 */ 212 */
236 if ((instance == 0) || 213 if ((instance == 0) || (!signature) || (!table_pointer)) {
237 (!signature) || 214 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 (!table_pointer)) {
239 return_ACPI_STATUS (AE_BAD_PARAMETER);
240 } 215 }
241 216
242 /* Ensure that we have a RSDP */ 217 /* Ensure that we have a RSDP */
@@ -244,40 +219,41 @@ acpi_get_firmware_table (
244 if (!acpi_gbl_RSDP) { 219 if (!acpi_gbl_RSDP) {
245 /* Get the RSDP */ 220 /* Get the RSDP */
246 221
247 status = acpi_os_get_root_pointer (flags, &address); 222 status = acpi_os_get_root_pointer(flags, &address);
248 if (ACPI_FAILURE (status)) { 223 if (ACPI_FAILURE(status)) {
249 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n"));
250 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 225 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
251 } 226 }
252 227
253 /* Map and validate the RSDP */ 228 /* Map and validate the RSDP */
254 229
255 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 230 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
256 status = acpi_os_map_memory (address.pointer.physical, 231 status = acpi_os_map_memory(address.pointer.physical,
257 sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP); 232 sizeof(struct
258 if (ACPI_FAILURE (status)) { 233 rsdp_descriptor),
259 return_ACPI_STATUS (status); 234 (void *)&acpi_gbl_RSDP);
235 if (ACPI_FAILURE(status)) {
236 return_ACPI_STATUS(status);
260 } 237 }
261 } 238 } else {
262 else {
263 acpi_gbl_RSDP = address.pointer.logical; 239 acpi_gbl_RSDP = address.pointer.logical;
264 } 240 }
265 241
266 /* The RDSP signature and checksum must both be correct */ 242 /* The RDSP signature and checksum must both be correct */
267 243
268 status = acpi_tb_validate_rsdp (acpi_gbl_RSDP); 244 status = acpi_tb_validate_rsdp(acpi_gbl_RSDP);
269 if (ACPI_FAILURE (status)) { 245 if (ACPI_FAILURE(status)) {
270 return_ACPI_STATUS (status); 246 return_ACPI_STATUS(status);
271 } 247 }
272 } 248 }
273 249
274 /* Get the RSDT address via the RSDP */ 250 /* Get the RSDT address via the RSDP */
275 251
276 acpi_tb_get_rsdt_address (&address); 252 acpi_tb_get_rsdt_address(&address);
277 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
278 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
279 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
280 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
281 257
282 /* Insert processor_mode flags */ 258 /* Insert processor_mode flags */
283 259
@@ -285,30 +261,30 @@ acpi_get_firmware_table (
285 261
286 /* Get and validate the RSDT */ 262 /* Get and validate the RSDT */
287 263
288 rsdt_info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 264 rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
289 if (!rsdt_info) { 265 if (!rsdt_info) {
290 return_ACPI_STATUS (AE_NO_MEMORY); 266 return_ACPI_STATUS(AE_NO_MEMORY);
291 } 267 }
292 268
293 status = acpi_tb_get_table (&address, rsdt_info); 269 status = acpi_tb_get_table(&address, rsdt_info);
294 if (ACPI_FAILURE (status)) { 270 if (ACPI_FAILURE(status)) {
295 goto cleanup; 271 goto cleanup;
296 } 272 }
297 273
298 status = acpi_tb_validate_rsdt (rsdt_info->pointer); 274 status = acpi_tb_validate_rsdt(rsdt_info->pointer);
299 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
300 goto cleanup; 276 goto cleanup;
301 } 277 }
302 278
303 /* Allocate a scratch table header and table descriptor */ 279 /* Allocate a scratch table header and table descriptor */
304 280
305 header = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_header)); 281 header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header));
306 if (!header) { 282 if (!header) {
307 status = AE_NO_MEMORY; 283 status = AE_NO_MEMORY;
308 goto cleanup; 284 goto cleanup;
309 } 285 }
310 286
311 table_info = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_desc)); 287 table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc));
312 if (!table_info) { 288 if (!table_info) {
313 status = AE_NO_MEMORY; 289 status = AE_NO_MEMORY;
314 goto cleanup; 290 goto cleanup;
@@ -316,7 +292,8 @@ acpi_get_firmware_table (
316 292
317 /* Get the number of table pointers within the RSDT */ 293 /* Get the number of table pointers within the RSDT */
318 294
319 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);
320 address.pointer_type = acpi_gbl_table_flags | flags; 297 address.pointer_type = acpi_gbl_table_flags | flags;
321 298
322 /* 299 /*
@@ -329,32 +306,37 @@ acpi_get_firmware_table (
329 * RSDT pointers are 32 bits, XSDT pointers are 64 bits 306 * RSDT pointers are 32 bits, XSDT pointers are 64 bits
330 */ 307 */
331 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 308 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
332 address.pointer.value = (ACPI_CAST_PTR ( 309 address.pointer.value =
333 RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 310 (ACPI_CAST_PTR
334 } 311 (RSDT_DESCRIPTOR,
335 else { 312 rsdt_info->pointer))->table_offset_entry[i];
336 address.pointer.value = (ACPI_CAST_PTR ( 313 } else {
337 XSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 314 address.pointer.value =
315 (ACPI_CAST_PTR
316 (XSDT_DESCRIPTOR,
317 rsdt_info->pointer))->table_offset_entry[i];
338 } 318 }
339 319
340 /* Get the table header */ 320 /* Get the table header */
341 321
342 status = acpi_tb_get_table_header (&address, header); 322 status = acpi_tb_get_table_header(&address, header);
343 if (ACPI_FAILURE (status)) { 323 if (ACPI_FAILURE(status)) {
344 goto cleanup; 324 goto cleanup;
345 } 325 }
346 326
347 /* Compare table signatures and table instance */ 327 /* Compare table signatures and table instance */
348 328
349 if (!ACPI_STRNCMP (header->signature, signature, ACPI_NAME_SIZE)) { 329 if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) {
350 /* An instance of the table was found */ 330 /* An instance of the table was found */
351 331
352 j++; 332 j++;
353 if (j >= instance) { 333 if (j >= instance) {
354 /* Found the correct instance, get the entire table */ 334 /* Found the correct instance, get the entire table */
355 335
356 status = acpi_tb_get_table_body (&address, header, table_info); 336 status =
357 if (ACPI_FAILURE (status)) { 337 acpi_tb_get_table_body(&address, header,
338 table_info);
339 if (ACPI_FAILURE(status)) {
358 goto cleanup; 340 goto cleanup;
359 } 341 }
360 342
@@ -368,24 +350,23 @@ acpi_get_firmware_table (
368 350
369 status = AE_NOT_EXIST; 351 status = AE_NOT_EXIST;
370 352
371 353 cleanup:
372cleanup:
373 if (rsdt_info->pointer) { 354 if (rsdt_info->pointer) {
374 acpi_os_unmap_memory (rsdt_info->pointer, 355 acpi_os_unmap_memory(rsdt_info->pointer,
375 (acpi_size) rsdt_info->pointer->length); 356 (acpi_size) rsdt_info->pointer->length);
376 } 357 }
377 ACPI_MEM_FREE (rsdt_info); 358 ACPI_MEM_FREE(rsdt_info);
378 359
379 if (header) { 360 if (header) {
380 ACPI_MEM_FREE (header); 361 ACPI_MEM_FREE(header);
381 } 362 }
382 if (table_info) { 363 if (table_info) {
383 ACPI_MEM_FREE (table_info); 364 ACPI_MEM_FREE(table_info);
384 } 365 }
385 return_ACPI_STATUS (status); 366 return_ACPI_STATUS(status);
386} 367}
387EXPORT_SYMBOL(acpi_get_firmware_table);
388 368
369EXPORT_SYMBOL(acpi_get_firmware_table);
389 370
390/* TBD: Move to a new file */ 371/* TBD: Move to a new file */
391 372
@@ -404,35 +385,29 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
404 * 385 *
405 ******************************************************************************/ 386 ******************************************************************************/
406 387
407acpi_status 388acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
408acpi_find_root_pointer (
409 u32 flags,
410 struct acpi_pointer *rsdp_address)
411{ 389{
412 struct acpi_table_desc table_info; 390 struct acpi_table_desc table_info;
413 acpi_status status; 391 acpi_status status;
414
415
416 ACPI_FUNCTION_TRACE ("acpi_find_root_pointer");
417 392
393 ACPI_FUNCTION_TRACE("acpi_find_root_pointer");
418 394
419 /* Get the RSDP */ 395 /* Get the RSDP */
420 396
421 status = acpi_tb_find_rsdp (&table_info, flags); 397 status = acpi_tb_find_rsdp(&table_info, flags);
422 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
423 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 399 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
424 "RSDP structure not found, %s Flags=%X\n", 400 "RSDP structure not found, %s Flags=%X\n",
425 acpi_format_exception (status), flags)); 401 acpi_format_exception(status), flags));
426 402
427 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 403 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
428 } 404 }
429 405
430 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER; 406 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER;
431 rsdp_address->pointer.physical = table_info.physical_address; 407 rsdp_address->pointer.physical = table_info.physical_address;
432 return_ACPI_STATUS (AE_OK); 408 return_ACPI_STATUS(AE_OK);
433} 409}
434 410
435
436/******************************************************************************* 411/*******************************************************************************
437 * 412 *
438 * FUNCTION: acpi_tb_scan_memory_for_rsdp 413 * FUNCTION: acpi_tb_scan_memory_for_rsdp
@@ -446,34 +421,32 @@ acpi_find_root_pointer (
446 * 421 *
447 ******************************************************************************/ 422 ******************************************************************************/
448 423
449static u8 * 424static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
450acpi_tb_scan_memory_for_rsdp (
451 u8 *start_address,
452 u32 length)
453{ 425{
454 acpi_status status; 426 acpi_status status;
455 u8 *mem_rover; 427 u8 *mem_rover;
456 u8 *end_address; 428 u8 *end_address;
457
458
459 ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp");
460 429
430 ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp");
461 431
462 end_address = start_address + length; 432 end_address = start_address + length;
463 433
464 /* Search from given start address for the requested length */ 434 /* Search from given start address for the requested length */
465 435
466 for (mem_rover = start_address; mem_rover < end_address; 436 for (mem_rover = start_address; mem_rover < end_address;
467 mem_rover += ACPI_RSDP_SCAN_STEP) { 437 mem_rover += ACPI_RSDP_SCAN_STEP) {
468 /* The RSDP signature and checksum must both be correct */ 438 /* The RSDP signature and checksum must both be correct */
469 439
470 status = acpi_tb_validate_rsdp (ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover)); 440 status =
471 if (ACPI_SUCCESS (status)) { 441 acpi_tb_validate_rsdp(ACPI_CAST_PTR
442 (struct rsdp_descriptor, mem_rover));
443 if (ACPI_SUCCESS(status)) {
472 /* Sig and checksum valid, we have found a real RSDP */ 444 /* Sig and checksum valid, we have found a real RSDP */
473 445
474 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 446 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
475 "RSDP located at physical address %p\n", mem_rover)); 447 "RSDP located at physical address %p\n",
476 return_PTR (mem_rover); 448 mem_rover));
449 return_PTR(mem_rover);
477 } 450 }
478 451
479 /* No sig match or bad checksum, keep searching */ 452 /* No sig match or bad checksum, keep searching */
@@ -481,13 +454,12 @@ acpi_tb_scan_memory_for_rsdp (
481 454
482 /* Searched entire block, no RSDP was found */ 455 /* Searched entire block, no RSDP was found */
483 456
484 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 457 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
485 "Searched entire block from %p, valid RSDP was not found\n", 458 "Searched entire block from %p, valid RSDP was not found\n",
486 start_address)); 459 start_address));
487 return_PTR (NULL); 460 return_PTR(NULL);
488} 461}
489 462
490
491/******************************************************************************* 463/*******************************************************************************
492 * 464 *
493 * FUNCTION: acpi_tb_find_rsdp 465 * FUNCTION: acpi_tb_find_rsdp
@@ -511,18 +483,14 @@ acpi_tb_scan_memory_for_rsdp (
511 ******************************************************************************/ 483 ******************************************************************************/
512 484
513static acpi_status 485static acpi_status
514acpi_tb_find_rsdp ( 486acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
515 struct acpi_table_desc *table_info,
516 u32 flags)
517{ 487{
518 u8 *table_ptr; 488 u8 *table_ptr;
519 u8 *mem_rover; 489 u8 *mem_rover;
520 u32 physical_address; 490 u32 physical_address;
521 acpi_status status; 491 acpi_status status;
522
523
524 ACPI_FUNCTION_TRACE ("tb_find_rsdp");
525 492
493 ACPI_FUNCTION_TRACE("tb_find_rsdp");
526 494
527 /* 495 /*
528 * Scan supports either logical addressing or physical addressing 496 * Scan supports either logical addressing or physical addressing
@@ -530,23 +498,25 @@ acpi_tb_find_rsdp (
530 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 498 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
531 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ 499 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
532 500
533 status = acpi_os_map_memory ( 501 status = acpi_os_map_memory((acpi_physical_address)
534 (acpi_physical_address) ACPI_EBDA_PTR_LOCATION, 502 ACPI_EBDA_PTR_LOCATION,
535 ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr); 503 ACPI_EBDA_PTR_LENGTH,
536 if (ACPI_FAILURE (status)) { 504 (void *)&table_ptr);
537 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 505 if (ACPI_FAILURE(status)) {
538 "Could not map memory at %8.8X for length %X\n", 506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
539 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); 507 "Could not map memory at %8.8X for length %X\n",
540 508 ACPI_EBDA_PTR_LOCATION,
541 return_ACPI_STATUS (status); 509 ACPI_EBDA_PTR_LENGTH));
510
511 return_ACPI_STATUS(status);
542 } 512 }
543 513
544 ACPI_MOVE_16_TO_32 (&physical_address, table_ptr); 514 ACPI_MOVE_16_TO_32(&physical_address, table_ptr);
545 515
546 /* Convert segment part to physical address */ 516 /* Convert segment part to physical address */
547 517
548 physical_address <<= 4; 518 physical_address <<= 4;
549 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH); 519 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH);
550 520
551 /* EBDA present? */ 521 /* EBDA present? */
552 522
@@ -555,59 +525,67 @@ acpi_tb_find_rsdp (
555 * 1b) Search EBDA paragraphs (EBDa is required to be a 525 * 1b) Search EBDA paragraphs (EBDa is required to be a
556 * minimum of 1_k length) 526 * minimum of 1_k length)
557 */ 527 */
558 status = acpi_os_map_memory ( 528 status = acpi_os_map_memory((acpi_physical_address)
559 (acpi_physical_address) physical_address, 529 physical_address,
560 ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr); 530 ACPI_EBDA_WINDOW_SIZE,
561 if (ACPI_FAILURE (status)) { 531 (void *)&table_ptr);
562 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 532 if (ACPI_FAILURE(status)) {
563 "Could not map memory at %8.8X for length %X\n", 533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
564 physical_address, ACPI_EBDA_WINDOW_SIZE)); 534 "Could not map memory at %8.8X for length %X\n",
565 535 physical_address,
566 return_ACPI_STATUS (status); 536 ACPI_EBDA_WINDOW_SIZE));
537
538 return_ACPI_STATUS(status);
567 } 539 }
568 540
569 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, 541 mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr,
570 ACPI_EBDA_WINDOW_SIZE); 542 ACPI_EBDA_WINDOW_SIZE);
571 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); 543 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
572 544
573 if (mem_rover) { 545 if (mem_rover) {
574 /* Return the physical address */ 546 /* Return the physical address */
575 547
576 physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); 548 physical_address +=
549 ACPI_PTR_DIFF(mem_rover, table_ptr);
577 550
578 table_info->physical_address = 551 table_info->physical_address =
579 (acpi_physical_address) physical_address; 552 (acpi_physical_address) physical_address;
580 return_ACPI_STATUS (AE_OK); 553 return_ACPI_STATUS(AE_OK);
581 } 554 }
582 } 555 }
583 556
584 /* 557 /*
585 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 558 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
586 */ 559 */
587 status = acpi_os_map_memory ( 560 status = acpi_os_map_memory((acpi_physical_address)
588 (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE, 561 ACPI_HI_RSDP_WINDOW_BASE,
589 ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr); 562 ACPI_HI_RSDP_WINDOW_SIZE,
590 563 (void *)&table_ptr);
591 if (ACPI_FAILURE (status)) { 564
592 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 565 if (ACPI_FAILURE(status)) {
593 "Could not map memory at %8.8X for length %X\n", 566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
594 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); 567 "Could not map memory at %8.8X for length %X\n",
595 568 ACPI_HI_RSDP_WINDOW_BASE,
596 return_ACPI_STATUS (status); 569 ACPI_HI_RSDP_WINDOW_SIZE));
570
571 return_ACPI_STATUS(status);
597 } 572 }
598 573
599 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 574 mem_rover =
600 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);
601 578
602 if (mem_rover) { 579 if (mem_rover) {
603 /* Return the physical address */ 580 /* Return the physical address */
604 581
605 physical_address = 582 physical_address =
606 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);
607 585
608 table_info->physical_address = 586 table_info->physical_address =
609 (acpi_physical_address) physical_address; 587 (acpi_physical_address) physical_address;
610 return_ACPI_STATUS (AE_OK); 588 return_ACPI_STATUS(AE_OK);
611 } 589 }
612 } 590 }
613 591
@@ -617,8 +595,8 @@ acpi_tb_find_rsdp (
617 else { 595 else {
618 /* 1a) Get the location of the EBDA */ 596 /* 1a) Get the location of the EBDA */
619 597
620 ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION); 598 ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION);
621 physical_address <<= 4; /* Convert segment to physical address */ 599 physical_address <<= 4; /* Convert segment to physical address */
622 600
623 /* EBDA present? */ 601 /* EBDA present? */
624 602
@@ -627,35 +605,38 @@ acpi_tb_find_rsdp (
627 * 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
628 * 1_k length) 606 * 1_k length)
629 */ 607 */
630 mem_rover = acpi_tb_scan_memory_for_rsdp ( 608 mem_rover =
631 ACPI_PHYSADDR_TO_PTR (physical_address), 609 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
632 ACPI_EBDA_WINDOW_SIZE); 610 (physical_address),
611 ACPI_EBDA_WINDOW_SIZE);
633 if (mem_rover) { 612 if (mem_rover) {
634 /* Return the physical address */ 613 /* Return the physical address */
635 614
636 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 615 table_info->physical_address =
637 return_ACPI_STATUS (AE_OK); 616 ACPI_TO_INTEGER(mem_rover);
617 return_ACPI_STATUS(AE_OK);
638 } 618 }
639 } 619 }
640 620
641 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ 621 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
642 622
643 mem_rover = acpi_tb_scan_memory_for_rsdp ( 623 mem_rover =
644 ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), 624 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
645 ACPI_HI_RSDP_WINDOW_SIZE); 625 (ACPI_HI_RSDP_WINDOW_BASE),
626 ACPI_HI_RSDP_WINDOW_SIZE);
646 if (mem_rover) { 627 if (mem_rover) {
647 /* Found it, return the physical address */ 628 /* Found it, return the physical address */
648 629
649 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 630 table_info->physical_address =
650 return_ACPI_STATUS (AE_OK); 631 ACPI_TO_INTEGER(mem_rover);
632 return_ACPI_STATUS(AE_OK);
651 } 633 }
652 } 634 }
653 635
654 /* A valid RSDP was not found */ 636 /* A valid RSDP was not found */
655 637
656 ACPI_REPORT_ERROR (("No valid RSDP was found\n")); 638 ACPI_REPORT_ERROR(("No valid RSDP was found\n"));
657 return_ACPI_STATUS (AE_NOT_FOUND); 639 return_ACPI_STATUS(AE_NOT_FOUND);
658} 640}
659 641
660#endif 642#endif
661
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/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 78270f50e625..068450b36475 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -41,45 +41,31 @@
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 void *allocation);
56 52
57static acpi_status 53static acpi_status
58acpi_ut_track_allocation ( 54acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
59 struct acpi_debug_mem_block *address, 55 acpi_size size,
60 acpi_size size, 56 u8 alloc_type, u32 component, char *module, u32 line);
61 u8 alloc_type,
62 u32 component,
63 char *module,
64 u32 line);
65 57
66static acpi_status 58static acpi_status
67acpi_ut_remove_allocation ( 59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
68 struct acpi_debug_mem_block *address, 60 u32 component, char *module, u32 line);
69 u32 component, 61#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
70 char *module,
71 u32 line);
72#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
73 62
74#ifdef ACPI_DBG_TRACK_ALLOCATIONS 63#ifdef ACPI_DBG_TRACK_ALLOCATIONS
75static acpi_status 64static acpi_status
76acpi_ut_create_list ( 65acpi_ut_create_list(char *list_name,
77 char *list_name, 66 u16 object_size, struct acpi_memory_list **return_cache);
78 u16 object_size,
79 struct acpi_memory_list **return_cache);
80#endif 67#endif
81 68
82
83/******************************************************************************* 69/*******************************************************************************
84 * 70 *
85 * FUNCTION: acpi_ut_create_caches 71 * FUNCTION: acpi_ut_create_caches
@@ -92,60 +78,68 @@ acpi_ut_create_list (
92 * 78 *
93 ******************************************************************************/ 79 ******************************************************************************/
94 80
95acpi_status 81acpi_status acpi_ut_create_caches(void)
96acpi_ut_create_caches (
97 void)
98{ 82{
99 acpi_status status; 83 acpi_status status;
100
101 84
102#ifdef ACPI_DBG_TRACK_ALLOCATIONS 85#ifdef ACPI_DBG_TRACK_ALLOCATIONS
103 86
104 /* Memory allocation lists */ 87 /* Memory allocation lists */
105 88
106 status = acpi_ut_create_list ("Acpi-Global", 0, 89 status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list);
107 &acpi_gbl_global_list); 90 if (ACPI_FAILURE(status)) {
108 if (ACPI_FAILURE (status)) {
109 return (status); 91 return (status);
110 } 92 }
111 93
112 status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), 94 status =
113 &acpi_gbl_ns_node_list); 95 acpi_ut_create_list("Acpi-Namespace",
114 if (ACPI_FAILURE (status)) { 96 sizeof(struct acpi_namespace_node),
97 &acpi_gbl_ns_node_list);
98 if (ACPI_FAILURE(status)) {
115 return (status); 99 return (status);
116 } 100 }
117#endif 101#endif
118 102
119 /* Object Caches, for frequently used objects */ 103 /* Object Caches, for frequently used objects */
120 104
121 status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), 105 status =
122 ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); 106 acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state),
123 if (ACPI_FAILURE (status)) { 107 ACPI_MAX_STATE_CACHE_DEPTH,
108 &acpi_gbl_state_cache);
109 if (ACPI_FAILURE(status)) {
124 return (status); 110 return (status);
125 } 111 }
126 112
127 status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), 113 status =
128 ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); 114 acpi_os_create_cache("acpi_parse",
129 if (ACPI_FAILURE (status)) { 115 sizeof(struct acpi_parse_obj_common),
116 ACPI_MAX_PARSE_CACHE_DEPTH,
117 &acpi_gbl_ps_node_cache);
118 if (ACPI_FAILURE(status)) {
130 return (status); 119 return (status);
131 } 120 }
132 121
133 status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), 122 status =
134 ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); 123 acpi_os_create_cache("acpi_parse_ext",
135 if (ACPI_FAILURE (status)) { 124 sizeof(struct acpi_parse_obj_named),
125 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
126 &acpi_gbl_ps_node_ext_cache);
127 if (ACPI_FAILURE(status)) {
136 return (status); 128 return (status);
137 } 129 }
138 130
139 status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), 131 status =
140 ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); 132 acpi_os_create_cache("acpi_operand",
141 if (ACPI_FAILURE (status)) { 133 sizeof(union acpi_operand_object),
134 ACPI_MAX_OBJECT_CACHE_DEPTH,
135 &acpi_gbl_operand_cache);
136 if (ACPI_FAILURE(status)) {
142 return (status); 137 return (status);
143 } 138 }
144 139
145 return (AE_OK); 140 return (AE_OK);
146} 141}
147 142
148
149/******************************************************************************* 143/*******************************************************************************
150 * 144 *
151 * FUNCTION: acpi_ut_delete_caches 145 * FUNCTION: acpi_ut_delete_caches
@@ -158,21 +152,19 @@ acpi_ut_create_caches (
158 * 152 *
159 ******************************************************************************/ 153 ******************************************************************************/
160 154
161acpi_status 155acpi_status acpi_ut_delete_caches(void)
162acpi_ut_delete_caches (
163 void)
164{ 156{
165 157
166 (void) acpi_os_delete_cache (acpi_gbl_state_cache); 158 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
167 acpi_gbl_state_cache = NULL; 159 acpi_gbl_state_cache = NULL;
168 160
169 (void) acpi_os_delete_cache (acpi_gbl_operand_cache); 161 (void)acpi_os_delete_cache(acpi_gbl_operand_cache);
170 acpi_gbl_operand_cache = NULL; 162 acpi_gbl_operand_cache = NULL;
171 163
172 (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); 164 (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache);
173 acpi_gbl_ps_node_cache = NULL; 165 acpi_gbl_ps_node_cache = NULL;
174 166
175 (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); 167 (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache);
176 acpi_gbl_ps_node_ext_cache = NULL; 168 acpi_gbl_ps_node_ext_cache = NULL;
177 169
178 return (AE_OK); 170 return (AE_OK);
@@ -190,9 +182,7 @@ acpi_ut_delete_caches (
190 * 182 *
191 ******************************************************************************/ 183 ******************************************************************************/
192 184
193acpi_status 185acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
194acpi_ut_validate_buffer (
195 struct acpi_buffer *buffer)
196{ 186{
197 187
198 /* Obviously, the structure pointer must be valid */ 188 /* Obviously, the structure pointer must be valid */
@@ -203,9 +193,9 @@ acpi_ut_validate_buffer (
203 193
204 /* Special semantics for the length */ 194 /* Special semantics for the length */
205 195
206 if ((buffer->length == ACPI_NO_BUFFER) || 196 if ((buffer->length == ACPI_NO_BUFFER) ||
207 (buffer->length == ACPI_ALLOCATE_BUFFER) || 197 (buffer->length == ACPI_ALLOCATE_BUFFER) ||
208 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { 198 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
209 return (AE_OK); 199 return (AE_OK);
210 } 200 }
211 201
@@ -218,7 +208,6 @@ acpi_ut_validate_buffer (
218 return (AE_OK); 208 return (AE_OK);
219} 209}
220 210
221
222/******************************************************************************* 211/*******************************************************************************
223 * 212 *
224 * FUNCTION: acpi_ut_initialize_buffer 213 * FUNCTION: acpi_ut_initialize_buffer
@@ -234,12 +223,10 @@ acpi_ut_validate_buffer (
234 ******************************************************************************/ 223 ******************************************************************************/
235 224
236acpi_status 225acpi_status
237acpi_ut_initialize_buffer ( 226acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
238 struct acpi_buffer *buffer, 227 acpi_size required_length)
239 acpi_size required_length)
240{ 228{
241 acpi_status status = AE_OK; 229 acpi_status status = AE_OK;
242
243 230
244 switch (buffer->length) { 231 switch (buffer->length) {
245 case ACPI_NO_BUFFER: 232 case ACPI_NO_BUFFER:
@@ -249,33 +236,30 @@ acpi_ut_initialize_buffer (
249 status = AE_BUFFER_OVERFLOW; 236 status = AE_BUFFER_OVERFLOW;
250 break; 237 break;
251 238
252
253 case ACPI_ALLOCATE_BUFFER: 239 case ACPI_ALLOCATE_BUFFER:
254 240
255 /* Allocate a new buffer */ 241 /* Allocate a new buffer */
256 242
257 buffer->pointer = acpi_os_allocate (required_length); 243 buffer->pointer = acpi_os_allocate(required_length);
258 if (!buffer->pointer) { 244 if (!buffer->pointer) {
259 return (AE_NO_MEMORY); 245 return (AE_NO_MEMORY);
260 } 246 }
261 247
262 /* Clear the buffer */ 248 /* Clear the buffer */
263 249
264 ACPI_MEMSET (buffer->pointer, 0, required_length); 250 ACPI_MEMSET(buffer->pointer, 0, required_length);
265 break; 251 break;
266 252
267
268 case ACPI_ALLOCATE_LOCAL_BUFFER: 253 case ACPI_ALLOCATE_LOCAL_BUFFER:
269 254
270 /* Allocate a new buffer with local interface to allow tracking */ 255 /* Allocate a new buffer with local interface to allow tracking */
271 256
272 buffer->pointer = ACPI_MEM_CALLOCATE (required_length); 257 buffer->pointer = ACPI_MEM_CALLOCATE(required_length);
273 if (!buffer->pointer) { 258 if (!buffer->pointer) {
274 return (AE_NO_MEMORY); 259 return (AE_NO_MEMORY);
275 } 260 }
276 break; 261 break;
277 262
278
279 default: 263 default:
280 264
281 /* Existing buffer: Validate the size of the buffer */ 265 /* Existing buffer: Validate the size of the buffer */
@@ -287,7 +271,7 @@ acpi_ut_initialize_buffer (
287 271
288 /* Clear the buffer */ 272 /* Clear the buffer */
289 273
290 ACPI_MEMSET (buffer->pointer, 0, required_length); 274 ACPI_MEMSET(buffer->pointer, 0, required_length);
291 break; 275 break;
292 } 276 }
293 277
@@ -295,7 +279,6 @@ acpi_ut_initialize_buffer (
295 return (status); 279 return (status);
296} 280}
297 281
298
299/******************************************************************************* 282/*******************************************************************************
300 * 283 *
301 * FUNCTION: acpi_ut_allocate 284 * FUNCTION: acpi_ut_allocate
@@ -311,41 +294,34 @@ acpi_ut_initialize_buffer (
311 * 294 *
312 ******************************************************************************/ 295 ******************************************************************************/
313 296
314void * 297void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
315acpi_ut_allocate (
316 acpi_size size,
317 u32 component,
318 char *module,
319 u32 line)
320{ 298{
321 void *allocation; 299 void *allocation;
322
323
324 ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size);
325 300
301 ACPI_FUNCTION_TRACE_U32("ut_allocate", size);
326 302
327 /* Check for an inadvertent size of zero bytes */ 303 /* Check for an inadvertent size of zero bytes */
328 304
329 if (!size) { 305 if (!size) {
330 _ACPI_REPORT_ERROR (module, line, component, 306 _ACPI_REPORT_ERROR(module, line, component,
331 ("ut_allocate: Attempt to allocate zero bytes\n")); 307 ("ut_allocate: Attempt to allocate zero bytes\n"));
332 size = 1; 308 size = 1;
333 } 309 }
334 310
335 allocation = acpi_os_allocate (size); 311 allocation = acpi_os_allocate(size);
336 if (!allocation) { 312 if (!allocation) {
337 /* Report allocation error */ 313 /* Report allocation error */
338 314
339 _ACPI_REPORT_ERROR (module, line, component, 315 _ACPI_REPORT_ERROR(module, line, component,
340 ("ut_allocate: Could not allocate size %X\n", (u32) size)); 316 ("ut_allocate: Could not allocate size %X\n",
317 (u32) size));
341 318
342 return_PTR (NULL); 319 return_PTR(NULL);
343 } 320 }
344 321
345 return_PTR (allocation); 322 return_PTR(allocation);
346} 323}
347 324
348
349/******************************************************************************* 325/*******************************************************************************
350 * 326 *
351 * FUNCTION: acpi_ut_callocate 327 * FUNCTION: acpi_ut_callocate
@@ -361,43 +337,36 @@ acpi_ut_allocate (
361 * 337 *
362 ******************************************************************************/ 338 ******************************************************************************/
363 339
364void * 340void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
365acpi_ut_callocate (
366 acpi_size size,
367 u32 component,
368 char *module,
369 u32 line)
370{ 341{
371 void *allocation; 342 void *allocation;
372
373
374 ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size);
375 343
344 ACPI_FUNCTION_TRACE_U32("ut_callocate", size);
376 345
377 /* Check for an inadvertent size of zero bytes */ 346 /* Check for an inadvertent size of zero bytes */
378 347
379 if (!size) { 348 if (!size) {
380 _ACPI_REPORT_ERROR (module, line, component, 349 _ACPI_REPORT_ERROR(module, line, component,
381 ("ut_callocate: Attempt to allocate zero bytes\n")); 350 ("ut_callocate: Attempt to allocate zero bytes\n"));
382 return_PTR (NULL); 351 return_PTR(NULL);
383 } 352 }
384 353
385 allocation = acpi_os_allocate (size); 354 allocation = acpi_os_allocate(size);
386 if (!allocation) { 355 if (!allocation) {
387 /* Report allocation error */ 356 /* Report allocation error */
388 357
389 _ACPI_REPORT_ERROR (module, line, component, 358 _ACPI_REPORT_ERROR(module, line, component,
390 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 359 ("ut_callocate: Could not allocate size %X\n",
391 return_PTR (NULL); 360 (u32) size));
361 return_PTR(NULL);
392 } 362 }
393 363
394 /* Clear the memory block */ 364 /* Clear the memory block */
395 365
396 ACPI_MEMSET (allocation, 0, size); 366 ACPI_MEMSET(allocation, 0, size);
397 return_PTR (allocation); 367 return_PTR(allocation);
398} 368}
399 369
400
401#ifdef ACPI_DBG_TRACK_ALLOCATIONS 370#ifdef ACPI_DBG_TRACK_ALLOCATIONS
402/* 371/*
403 * 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
@@ -425,29 +394,25 @@ acpi_ut_callocate (
425 ******************************************************************************/ 394 ******************************************************************************/
426 395
427static acpi_status 396static acpi_status
428acpi_ut_create_list ( 397acpi_ut_create_list(char *list_name,
429 char *list_name, 398 u16 object_size, struct acpi_memory_list **return_cache)
430 u16 object_size,
431 struct acpi_memory_list **return_cache)
432{ 399{
433 struct acpi_memory_list *cache; 400 struct acpi_memory_list *cache;
434 401
435 402 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
436 cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
437 if (!cache) { 403 if (!cache) {
438 return (AE_NO_MEMORY); 404 return (AE_NO_MEMORY);
439 } 405 }
440 406
441 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); 407 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
442 408
443 cache->list_name = list_name; 409 cache->list_name = list_name;
444 cache->object_size = object_size; 410 cache->object_size = object_size;
445 411
446 *return_cache = cache; 412 *return_cache = cache;
447 return (AE_OK); 413 return (AE_OK);
448} 414}
449 415
450
451/******************************************************************************* 416/*******************************************************************************
452 * 417 *
453 * FUNCTION: acpi_ut_allocate_and_track 418 * FUNCTION: acpi_ut_allocate_and_track
@@ -463,37 +428,33 @@ acpi_ut_create_list (
463 * 428 *
464 ******************************************************************************/ 429 ******************************************************************************/
465 430
466void * 431void *acpi_ut_allocate_and_track(acpi_size size,
467acpi_ut_allocate_and_track ( 432 u32 component, char *module, u32 line)
468 acpi_size size,
469 u32 component,
470 char *module,
471 u32 line)
472{ 433{
473 struct acpi_debug_mem_block *allocation; 434 struct acpi_debug_mem_block *allocation;
474 acpi_status status; 435 acpi_status status;
475
476 436
477 allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), 437 allocation =
478 component, module, line); 438 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
439 component, module, line);
479 if (!allocation) { 440 if (!allocation) {
480 return (NULL); 441 return (NULL);
481 } 442 }
482 443
483 status = acpi_ut_track_allocation (allocation, size, 444 status = acpi_ut_track_allocation(allocation, size,
484 ACPI_MEM_MALLOC, component, module, line); 445 ACPI_MEM_MALLOC, component, module,
485 if (ACPI_FAILURE (status)) { 446 line);
486 acpi_os_free (allocation); 447 if (ACPI_FAILURE(status)) {
448 acpi_os_free(allocation);
487 return (NULL); 449 return (NULL);
488 } 450 }
489 451
490 acpi_gbl_global_list->total_allocated++; 452 acpi_gbl_global_list->total_allocated++;
491 acpi_gbl_global_list->current_total_size += (u32) size; 453 acpi_gbl_global_list->current_total_size += (u32) size;
492 454
493 return ((void *) &allocation->user_space); 455 return ((void *)&allocation->user_space);
494} 456}
495 457
496
497/******************************************************************************* 458/*******************************************************************************
498 * 459 *
499 * FUNCTION: acpi_ut_callocate_and_track 460 * FUNCTION: acpi_ut_callocate_and_track
@@ -509,41 +470,38 @@ acpi_ut_allocate_and_track (
509 * 470 *
510 ******************************************************************************/ 471 ******************************************************************************/
511 472
512void * 473void *acpi_ut_callocate_and_track(acpi_size size,
513acpi_ut_callocate_and_track ( 474 u32 component, char *module, u32 line)
514 acpi_size size,
515 u32 component,
516 char *module,
517 u32 line)
518{ 475{
519 struct acpi_debug_mem_block *allocation; 476 struct acpi_debug_mem_block *allocation;
520 acpi_status status; 477 acpi_status status;
521
522 478
523 allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), 479 allocation =
524 component, module, line); 480 acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header),
481 component, module, line);
525 if (!allocation) { 482 if (!allocation) {
526 /* Report allocation error */ 483 /* Report allocation error */
527 484
528 _ACPI_REPORT_ERROR (module, line, component, 485 _ACPI_REPORT_ERROR(module, line, component,
529 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 486 ("ut_callocate: Could not allocate size %X\n",
487 (u32) size));
530 return (NULL); 488 return (NULL);
531 } 489 }
532 490
533 status = acpi_ut_track_allocation (allocation, size, 491 status = acpi_ut_track_allocation(allocation, size,
534 ACPI_MEM_CALLOC, component, module, line); 492 ACPI_MEM_CALLOC, component, module,
535 if (ACPI_FAILURE (status)) { 493 line);
536 acpi_os_free (allocation); 494 if (ACPI_FAILURE(status)) {
495 acpi_os_free(allocation);
537 return (NULL); 496 return (NULL);
538 } 497 }
539 498
540 acpi_gbl_global_list->total_allocated++; 499 acpi_gbl_global_list->total_allocated++;
541 acpi_gbl_global_list->current_total_size += (u32) size; 500 acpi_gbl_global_list->current_total_size += (u32) size;
542 501
543 return ((void *) &allocation->user_space); 502 return ((void *)&allocation->user_space);
544} 503}
545 504
546
547/******************************************************************************* 505/*******************************************************************************
548 * 506 *
549 * FUNCTION: acpi_ut_free_and_track 507 * FUNCTION: acpi_ut_free_and_track
@@ -560,47 +518,41 @@ acpi_ut_callocate_and_track (
560 ******************************************************************************/ 518 ******************************************************************************/
561 519
562void 520void
563acpi_ut_free_and_track ( 521acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
564 void *allocation,
565 u32 component,
566 char *module,
567 u32 line)
568{ 522{
569 struct acpi_debug_mem_block *debug_block; 523 struct acpi_debug_mem_block *debug_block;
570 acpi_status status; 524 acpi_status status;
571
572
573 ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation);
574 525
526 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
575 527
576 if (NULL == allocation) { 528 if (NULL == allocation) {
577 _ACPI_REPORT_ERROR (module, line, component, 529 _ACPI_REPORT_ERROR(module, line, component,
578 ("acpi_ut_free: Attempt to delete a NULL address\n")); 530 ("acpi_ut_free: Attempt to delete a NULL address\n"));
579 531
580 return_VOID; 532 return_VOID;
581 } 533 }
582 534
583 debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, 535 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
584 (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); 536 (((char *)allocation) -
537 sizeof(struct acpi_debug_mem_header)));
585 538
586 acpi_gbl_global_list->total_freed++; 539 acpi_gbl_global_list->total_freed++;
587 acpi_gbl_global_list->current_total_size -= debug_block->size; 540 acpi_gbl_global_list->current_total_size -= debug_block->size;
588 541
589 status = acpi_ut_remove_allocation (debug_block, 542 status = acpi_ut_remove_allocation(debug_block,
590 component, module, line); 543 component, module, line);
591 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
592 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",
593 acpi_format_exception (status))); 546 acpi_format_exception(status)));
594 } 547 }
595 548
596 acpi_os_free (debug_block); 549 acpi_os_free(debug_block);
597 550
598 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 551 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
599 552
600 return_VOID; 553 return_VOID;
601} 554}
602 555
603
604/******************************************************************************* 556/*******************************************************************************
605 * 557 *
606 * FUNCTION: acpi_ut_find_allocation 558 * FUNCTION: acpi_ut_find_allocation
@@ -613,15 +565,11 @@ acpi_ut_free_and_track (
613 * 565 *
614 ******************************************************************************/ 566 ******************************************************************************/
615 567
616static struct acpi_debug_mem_block * 568static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation)
617acpi_ut_find_allocation (
618 void *allocation)
619{ 569{
620 struct acpi_debug_mem_block *element; 570 struct acpi_debug_mem_block *element;
621
622
623 ACPI_FUNCTION_ENTRY ();
624 571
572 ACPI_FUNCTION_ENTRY();
625 573
626 element = acpi_gbl_global_list->list_head; 574 element = acpi_gbl_global_list->list_head;
627 575
@@ -638,7 +586,6 @@ acpi_ut_find_allocation (
638 return (NULL); 586 return (NULL);
639} 587}
640 588
641
642/******************************************************************************* 589/*******************************************************************************
643 * 590 *
644 * FUNCTION: acpi_ut_track_allocation 591 * FUNCTION: acpi_ut_track_allocation
@@ -657,58 +604,51 @@ acpi_ut_find_allocation (
657 ******************************************************************************/ 604 ******************************************************************************/
658 605
659static acpi_status 606static acpi_status
660acpi_ut_track_allocation ( 607acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
661 struct acpi_debug_mem_block *allocation, 608 acpi_size size,
662 acpi_size size, 609 u8 alloc_type, u32 component, char *module, u32 line)
663 u8 alloc_type,
664 u32 component,
665 char *module,
666 u32 line)
667{ 610{
668 struct acpi_memory_list *mem_list; 611 struct acpi_memory_list *mem_list;
669 struct acpi_debug_mem_block *element; 612 struct acpi_debug_mem_block *element;
670 acpi_status status = AE_OK; 613 acpi_status status = AE_OK;
671
672
673 ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
674 614
615 ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation);
675 616
676 mem_list = acpi_gbl_global_list; 617 mem_list = acpi_gbl_global_list;
677 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 618 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
678 if (ACPI_FAILURE (status)) { 619 if (ACPI_FAILURE(status)) {
679 return_ACPI_STATUS (status); 620 return_ACPI_STATUS(status);
680 } 621 }
681 622
682 /* 623 /*
683 * 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.
684 * This will catch several kinds of problems. 625 * This will catch several kinds of problems.
685 */ 626 */
686 element = acpi_ut_find_allocation (allocation); 627 element = acpi_ut_find_allocation(allocation);
687 if (element) { 628 if (element) {
688 ACPI_REPORT_ERROR (( 629 ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation));
689 "ut_track_allocation: Allocation already present in list! (%p)\n",
690 allocation));
691 630
692 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n",
693 element, allocation)); 632 element, allocation));
694 633
695 goto unlock_and_exit; 634 goto unlock_and_exit;
696 } 635 }
697 636
698 /* Fill in the instance data. */ 637 /* Fill in the instance data. */
699 638
700 allocation->size = (u32) size; 639 allocation->size = (u32) size;
701 allocation->alloc_type = alloc_type; 640 allocation->alloc_type = alloc_type;
702 allocation->component = component; 641 allocation->component = component;
703 allocation->line = line; 642 allocation->line = line;
704 643
705 ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME); 644 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
706 allocation->module[ACPI_MAX_MODULE_NAME-1] = 0; 645 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
707 646
708 /* Insert at list head */ 647 /* Insert at list head */
709 648
710 if (mem_list->list_head) { 649 if (mem_list->list_head) {
711 ((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation; 650 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
651 previous = allocation;
712 } 652 }
713 653
714 allocation->next = mem_list->list_head; 654 allocation->next = mem_list->list_head;
@@ -716,13 +656,11 @@ acpi_ut_track_allocation (
716 656
717 mem_list->list_head = allocation; 657 mem_list->list_head = allocation;
718 658
719 659 unlock_and_exit:
720unlock_and_exit: 660 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
721 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 661 return_ACPI_STATUS(status);
722 return_ACPI_STATUS (status);
723} 662}
724 663
725
726/******************************************************************************* 664/*******************************************************************************
727 * 665 *
728 * FUNCTION: acpi_ut_remove_allocation 666 * FUNCTION: acpi_ut_remove_allocation
@@ -739,40 +677,34 @@ unlock_and_exit:
739 ******************************************************************************/ 677 ******************************************************************************/
740 678
741static acpi_status 679static acpi_status
742acpi_ut_remove_allocation ( 680acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
743 struct acpi_debug_mem_block *allocation, 681 u32 component, char *module, u32 line)
744 u32 component,
745 char *module,
746 u32 line)
747{ 682{
748 struct acpi_memory_list *mem_list; 683 struct acpi_memory_list *mem_list;
749 acpi_status status; 684 acpi_status status;
750
751
752 ACPI_FUNCTION_TRACE ("ut_remove_allocation");
753 685
686 ACPI_FUNCTION_TRACE("ut_remove_allocation");
754 687
755 mem_list = acpi_gbl_global_list; 688 mem_list = acpi_gbl_global_list;
756 if (NULL == mem_list->list_head) { 689 if (NULL == mem_list->list_head) {
757 /* No allocations! */ 690 /* No allocations! */
758 691
759 _ACPI_REPORT_ERROR (module, line, component, 692 _ACPI_REPORT_ERROR(module, line, component,
760 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 693 ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
761 694
762 return_ACPI_STATUS (AE_OK); 695 return_ACPI_STATUS(AE_OK);
763 } 696 }
764 697
765 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 698 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
766 if (ACPI_FAILURE (status)) { 699 if (ACPI_FAILURE(status)) {
767 return_ACPI_STATUS (status); 700 return_ACPI_STATUS(status);
768 } 701 }
769 702
770 /* Unlink */ 703 /* Unlink */
771 704
772 if (allocation->previous) { 705 if (allocation->previous) {
773 (allocation->previous)->next = allocation->next; 706 (allocation->previous)->next = allocation->next;
774 } 707 } else {
775 else {
776 mem_list->list_head = allocation->next; 708 mem_list->list_head = allocation->next;
777 } 709 }
778 710
@@ -782,16 +714,15 @@ acpi_ut_remove_allocation (
782 714
783 /* Mark the segment as deleted */ 715 /* Mark the segment as deleted */
784 716
785 ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); 717 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
786 718
787 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", 719 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
788 allocation->size)); 720 allocation->size));
789 721
790 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 722 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
791 return_ACPI_STATUS (status); 723 return_ACPI_STATUS(status);
792} 724}
793 725
794
795/******************************************************************************* 726/*******************************************************************************
796 * 727 *
797 * FUNCTION: acpi_ut_dump_allocation_info 728 * FUNCTION: acpi_ut_dump_allocation_info
@@ -805,15 +736,13 @@ acpi_ut_remove_allocation (
805 ******************************************************************************/ 736 ******************************************************************************/
806 737
807#ifdef ACPI_FUTURE_USAGE 738#ifdef ACPI_FUTURE_USAGE
808void 739void acpi_ut_dump_allocation_info(void)
809acpi_ut_dump_allocation_info (
810 void)
811{ 740{
812/* 741/*
813 struct acpi_memory_list *mem_list; 742 struct acpi_memory_list *mem_list;
814*/ 743*/
815 744
816 ACPI_FUNCTION_TRACE ("ut_dump_allocation_info"); 745 ACPI_FUNCTION_TRACE("ut_dump_allocation_info");
817 746
818/* 747/*
819 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 748 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@@ -826,7 +755,6 @@ acpi_ut_dump_allocation_info (
826 mem_list->max_concurrent_count, 755 mem_list->max_concurrent_count,
827 ROUND_UP_TO_1K (mem_list->max_concurrent_size))); 756 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
828 757
829
830 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 758 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
831 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", 759 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
832 running_object_count, 760 running_object_count,
@@ -837,7 +765,6 @@ acpi_ut_dump_allocation_info (
837 running_alloc_count, 765 running_alloc_count,
838 ROUND_UP_TO_1K (running_alloc_size))); 766 ROUND_UP_TO_1K (running_alloc_size)));
839 767
840
841 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 768 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
842 ("%30s: %4d (%3d Kb)\n", "Current Nodes", 769 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
843 acpi_gbl_current_node_count, 770 acpi_gbl_current_node_count,
@@ -851,8 +778,7 @@ acpi_ut_dump_allocation_info (
851*/ 778*/
852 return_VOID; 779 return_VOID;
853} 780}
854#endif /* ACPI_FUTURE_USAGE */ 781#endif /* ACPI_FUTURE_USAGE */
855
856 782
857/******************************************************************************* 783/*******************************************************************************
858 * 784 *
@@ -867,84 +793,87 @@ acpi_ut_dump_allocation_info (
867 * 793 *
868 ******************************************************************************/ 794 ******************************************************************************/
869 795
870void 796void acpi_ut_dump_allocations(u32 component, char *module)
871acpi_ut_dump_allocations (
872 u32 component,
873 char *module)
874{ 797{
875 struct acpi_debug_mem_block *element; 798 struct acpi_debug_mem_block *element;
876 union acpi_descriptor *descriptor; 799 union acpi_descriptor *descriptor;
877 u32 num_outstanding = 0; 800 u32 num_outstanding = 0;
878
879
880 ACPI_FUNCTION_TRACE ("ut_dump_allocations");
881 801
802 ACPI_FUNCTION_TRACE("ut_dump_allocations");
882 803
883 /* 804 /*
884 * Walk the allocation list. 805 * Walk the allocation list.
885 */ 806 */
886 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) { 807 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
887 return; 808 return;
888 } 809 }
889 810
890 element = acpi_gbl_global_list->list_head; 811 element = acpi_gbl_global_list->list_head;
891 while (element) { 812 while (element) {
892 if ((element->component & component) && 813 if ((element->component & component) &&
893 ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { 814 ((module == NULL)
815 || (0 == ACPI_STRCMP(module, element->module)))) {
894 /* Ignore allocated objects that are in a cache */ 816 /* Ignore allocated objects that are in a cache */
895 817
896 descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); 818 descriptor =
819 ACPI_CAST_PTR(union acpi_descriptor,
820 &element->user_space);
897 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { 821 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
898 acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", 822 acpi_os_printf("%p Len %04X %9.9s-%d [%s] ",
899 descriptor, element->size, element->module, 823 descriptor, element->size,
900 element->line, acpi_ut_get_descriptor_name (descriptor)); 824 element->module, element->line,
825 acpi_ut_get_descriptor_name
826 (descriptor));
901 827
902 /* Most of the elements will be Operand objects. */ 828 /* Most of the elements will be Operand objects. */
903 829
904 switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { 830 switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) {
905 case ACPI_DESC_TYPE_OPERAND: 831 case ACPI_DESC_TYPE_OPERAND:
906 acpi_os_printf ("%12.12s R%hd", 832 acpi_os_printf("%12.12s R%hd",
907 acpi_ut_get_type_name (descriptor->object.common.type), 833 acpi_ut_get_type_name
908 descriptor->object.common.reference_count); 834 (descriptor->object.
835 common.type),
836 descriptor->object.
837 common.reference_count);
909 break; 838 break;
910 839
911 case ACPI_DESC_TYPE_PARSER: 840 case ACPI_DESC_TYPE_PARSER:
912 acpi_os_printf ("aml_opcode %04hX", 841 acpi_os_printf("aml_opcode %04hX",
913 descriptor->op.asl.aml_opcode); 842 descriptor->op.asl.
843 aml_opcode);
914 break; 844 break;
915 845
916 case ACPI_DESC_TYPE_NAMED: 846 case ACPI_DESC_TYPE_NAMED:
917 acpi_os_printf ("%4.4s", 847 acpi_os_printf("%4.4s",
918 acpi_ut_get_node_name (&descriptor->node)); 848 acpi_ut_get_node_name
849 (&descriptor->node));
919 break; 850 break;
920 851
921 default: 852 default:
922 break; 853 break;
923 } 854 }
924 855
925 acpi_os_printf ( "\n"); 856 acpi_os_printf("\n");
926 num_outstanding++; 857 num_outstanding++;
927 } 858 }
928 } 859 }
929 element = element->next; 860 element = element->next;
930 } 861 }
931 862
932 (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY); 863 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
933 864
934 /* Print summary */ 865 /* Print summary */
935 866
936 if (!num_outstanding) { 867 if (!num_outstanding) {
937 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
938 "No outstanding allocations.\n")); 869 "No outstanding allocations.\n"));
939 } 870 } else {
940 else { 871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
941 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 872 "%d(%X) Outstanding allocations\n",
942 "%d(%X) Outstanding allocations\n", 873 num_outstanding, num_outstanding));
943 num_outstanding, num_outstanding));
944 } 874 }
945 875
946 return_VOID; 876 return_VOID;
947} 877}
948 878
949#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ 879#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
950
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index c0df0585c683..93d48681d276 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -41,12 +41,10 @@
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 ("utcache") 47ACPI_MODULE_NAME("utcache")
49
50 48
51#ifdef ACPI_USE_LOCAL_CACHE 49#ifdef ACPI_USE_LOCAL_CACHE
52/******************************************************************************* 50/*******************************************************************************
@@ -63,19 +61,14 @@
63 * DESCRIPTION: Create a cache object 61 * DESCRIPTION: Create a cache object
64 * 62 *
65 ******************************************************************************/ 63 ******************************************************************************/
66
67acpi_status 64acpi_status
68acpi_os_create_cache ( 65acpi_os_create_cache(char *cache_name,
69 char *cache_name, 66 u16 object_size,
70 u16 object_size, 67 u16 max_depth, struct acpi_memory_list **return_cache)
71 u16 max_depth,
72 struct acpi_memory_list **return_cache)
73{ 68{
74 struct acpi_memory_list *cache; 69 struct acpi_memory_list *cache;
75
76
77 ACPI_FUNCTION_ENTRY ();
78 70
71 ACPI_FUNCTION_ENTRY();
79 72
80 if (!cache_name || !return_cache || (object_size < 16)) { 73 if (!cache_name || !return_cache || (object_size < 16)) {
81 return (AE_BAD_PARAMETER); 74 return (AE_BAD_PARAMETER);
@@ -83,24 +76,23 @@ acpi_os_create_cache (
83 76
84 /* Create the cache object */ 77 /* Create the cache object */
85 78
86 cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); 79 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
87 if (!cache) { 80 if (!cache) {
88 return (AE_NO_MEMORY); 81 return (AE_NO_MEMORY);
89 } 82 }
90 83
91 /* Populate the cache object and return it */ 84 /* Populate the cache object and return it */
92 85
93 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); 86 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
94 cache->link_offset = 8; 87 cache->link_offset = 8;
95 cache->list_name = cache_name; 88 cache->list_name = cache_name;
96 cache->object_size = object_size; 89 cache->object_size = object_size;
97 cache->max_depth = max_depth; 90 cache->max_depth = max_depth;
98 91
99 *return_cache = cache; 92 *return_cache = cache;
100 return (AE_OK); 93 return (AE_OK);
101} 94}
102 95
103
104/******************************************************************************* 96/*******************************************************************************
105 * 97 *
106 * FUNCTION: acpi_os_purge_cache 98 * FUNCTION: acpi_os_purge_cache
@@ -113,15 +105,11 @@ acpi_os_create_cache (
113 * 105 *
114 ******************************************************************************/ 106 ******************************************************************************/
115 107
116acpi_status 108acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
117acpi_os_purge_cache (
118 struct acpi_memory_list *cache)
119{ 109{
120 char *next; 110 char *next;
121
122
123 ACPI_FUNCTION_ENTRY ();
124 111
112 ACPI_FUNCTION_ENTRY();
125 113
126 if (!cache) { 114 if (!cache) {
127 return (AE_BAD_PARAMETER); 115 return (AE_BAD_PARAMETER);
@@ -132,9 +120,11 @@ acpi_os_purge_cache (
132 while (cache->list_head) { 120 while (cache->list_head) {
133 /* Delete and unlink one cached state object */ 121 /* Delete and unlink one cached state object */
134 122
135 next = *(ACPI_CAST_INDIRECT_PTR (char, 123 next = *(ACPI_CAST_INDIRECT_PTR(char,
136 &(((char *) cache->list_head)[cache->link_offset]))); 124 &(((char *)cache->
137 ACPI_MEM_FREE (cache->list_head); 125 list_head)[cache->
126 link_offset])));
127 ACPI_MEM_FREE(cache->list_head);
138 128
139 cache->list_head = next; 129 cache->list_head = next;
140 cache->current_depth--; 130 cache->current_depth--;
@@ -143,7 +133,6 @@ acpi_os_purge_cache (
143 return (AE_OK); 133 return (AE_OK);
144} 134}
145 135
146
147/******************************************************************************* 136/*******************************************************************************
148 * 137 *
149 * FUNCTION: acpi_os_delete_cache 138 * FUNCTION: acpi_os_delete_cache
@@ -157,30 +146,25 @@ acpi_os_purge_cache (
157 * 146 *
158 ******************************************************************************/ 147 ******************************************************************************/
159 148
160acpi_status 149acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
161acpi_os_delete_cache (
162 struct acpi_memory_list *cache)
163{ 150{
164 acpi_status status; 151 acpi_status status;
165
166 152
167 ACPI_FUNCTION_ENTRY (); 153 ACPI_FUNCTION_ENTRY();
168 154
155 /* Purge all objects in the cache */
169 156
170 /* Purge all objects in the cache */ 157 status = acpi_os_purge_cache(cache);
171 158 if (ACPI_FAILURE(status)) {
172 status = acpi_os_purge_cache (cache);
173 if (ACPI_FAILURE (status)) {
174 return (status); 159 return (status);
175 } 160 }
176 161
177 /* Now we can delete the cache object */ 162 /* Now we can delete the cache object */
178 163
179 acpi_os_free (cache); 164 acpi_os_free(cache);
180 return (AE_OK); 165 return (AE_OK);
181} 166}
182 167
183
184/******************************************************************************* 168/*******************************************************************************
185 * 169 *
186 * FUNCTION: acpi_os_release_object 170 * FUNCTION: acpi_os_release_object
@@ -196,15 +180,11 @@ acpi_os_delete_cache (
196 ******************************************************************************/ 180 ******************************************************************************/
197 181
198acpi_status 182acpi_status
199acpi_os_release_object ( 183acpi_os_release_object(struct acpi_memory_list * cache, void *object)
200 struct acpi_memory_list *cache,
201 void *object)
202{ 184{
203 acpi_status status; 185 acpi_status status;
204
205
206 ACPI_FUNCTION_ENTRY ();
207 186
187 ACPI_FUNCTION_ENTRY();
208 188
209 if (!cache || !object) { 189 if (!cache || !object) {
210 return (AE_BAD_PARAMETER); 190 return (AE_BAD_PARAMETER);
@@ -213,37 +193,38 @@ acpi_os_release_object (
213 /* If cache is full, just free this object */ 193 /* If cache is full, just free this object */
214 194
215 if (cache->current_depth >= cache->max_depth) { 195 if (cache->current_depth >= cache->max_depth) {
216 ACPI_MEM_FREE (object); 196 ACPI_MEM_FREE(object);
217 ACPI_MEM_TRACKING (cache->total_freed++); 197 ACPI_MEM_TRACKING(cache->total_freed++);
218 } 198 }
219 199
220 /* Otherwise put this object back into the cache */ 200 /* Otherwise put this object back into the cache */
221 201
222 else { 202 else {
223 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 203 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
224 if (ACPI_FAILURE (status)) { 204 if (ACPI_FAILURE(status)) {
225 return (status); 205 return (status);
226 } 206 }
227 207
228 /* Mark the object as cached */ 208 /* Mark the object as cached */
229 209
230 ACPI_MEMSET (object, 0xCA, cache->object_size); 210 ACPI_MEMSET(object, 0xCA, cache->object_size);
231 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); 211 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
232 212
233 /* Put the object at the head of the cache list */ 213 /* Put the object at the head of the cache list */
234 214
235 * (ACPI_CAST_INDIRECT_PTR (char, 215 *(ACPI_CAST_INDIRECT_PTR(char,
236 &(((char *) object)[cache->link_offset]))) = cache->list_head; 216 &(((char *)object)[cache->
217 link_offset]))) =
218 cache->list_head;
237 cache->list_head = object; 219 cache->list_head = object;
238 cache->current_depth++; 220 cache->current_depth++;
239 221
240 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 222 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
241 } 223 }
242 224
243 return (AE_OK); 225 return (AE_OK);
244} 226}
245 227
246
247/******************************************************************************* 228/*******************************************************************************
248 * 229 *
249 * FUNCTION: acpi_os_acquire_object 230 * FUNCTION: acpi_os_acquire_object
@@ -257,27 +238,23 @@ acpi_os_release_object (
257 * 238 *
258 ******************************************************************************/ 239 ******************************************************************************/
259 240
260void * 241void *acpi_os_acquire_object(struct acpi_memory_list *cache)
261acpi_os_acquire_object (
262 struct acpi_memory_list *cache)
263{ 242{
264 acpi_status status; 243 acpi_status status;
265 void *object; 244 void *object;
266
267
268 ACPI_FUNCTION_NAME ("os_acquire_object");
269 245
246 ACPI_FUNCTION_NAME("os_acquire_object");
270 247
271 if (!cache) { 248 if (!cache) {
272 return (NULL); 249 return (NULL);
273 } 250 }
274 251
275 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 252 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
276 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
277 return (NULL); 254 return (NULL);
278 } 255 }
279 256
280 ACPI_MEM_TRACKING (cache->requests++); 257 ACPI_MEM_TRACKING(cache->requests++);
281 258
282 /* Check the cache first */ 259 /* Check the cache first */
283 260
@@ -285,37 +262,39 @@ acpi_os_acquire_object (
285 /* There is an object available, use it */ 262 /* There is an object available, use it */
286 263
287 object = cache->list_head; 264 object = cache->list_head;
288 cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, 265 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
289 &(((char *) object)[cache->link_offset]))); 266 &(((char *)
267 object)[cache->
268 link_offset])));
290 269
291 cache->current_depth--; 270 cache->current_depth--;
292 271
293 ACPI_MEM_TRACKING (cache->hits++); 272 ACPI_MEM_TRACKING(cache->hits++);
294 ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 273 ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
295 "Object %p from %s cache\n", object, cache->list_name))); 274 "Object %p from %s cache\n",
275 object, cache->list_name)));
296 276
297 status = acpi_ut_release_mutex (ACPI_MTX_CACHES); 277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
298 if (ACPI_FAILURE (status)) { 278 if (ACPI_FAILURE(status)) {
299 return (NULL); 279 return (NULL);
300 } 280 }
301 281
302 /* Clear (zero) the previously used Object */ 282 /* Clear (zero) the previously used Object */
303 283
304 ACPI_MEMSET (object, 0, cache->object_size); 284 ACPI_MEMSET(object, 0, cache->object_size);
305 } 285 } else {
306 else {
307 /* The cache is empty, create a new object */ 286 /* The cache is empty, create a new object */
308 287
309 ACPI_MEM_TRACKING (cache->total_allocated++); 288 ACPI_MEM_TRACKING(cache->total_allocated++);
310 289
311 /* Avoid deadlock with ACPI_MEM_CALLOCATE */ 290 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
312 291
313 status = acpi_ut_release_mutex (ACPI_MTX_CACHES); 292 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
314 if (ACPI_FAILURE (status)) { 293 if (ACPI_FAILURE(status)) {
315 return (NULL); 294 return (NULL);
316 } 295 }
317 296
318 object = ACPI_MEM_CALLOCATE (cache->object_size); 297 object = ACPI_MEM_CALLOCATE(cache->object_size);
319 if (!object) { 298 if (!object) {
320 return (NULL); 299 return (NULL);
321 } 300 }
@@ -323,6 +302,4 @@ acpi_os_acquire_object (
323 302
324 return (object); 303 return (object);
325} 304}
326#endif /* ACPI_USE_LOCAL_CACHE */ 305#endif /* ACPI_USE_LOCAL_CACHE */
327
328
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 31c30a32e5c9..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
262 243
263 ACPI_FUNCTION_ENTRY (); 244 ACPI_FUNCTION_ENTRY();
264 245
265 246 this_index = state->pkg.index;
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,23 +636,21 @@ 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
@@ -700,7 +663,7 @@ acpi_ut_copy_simple_object (
700 663
701 /* Handle the objects with extra data */ 664 /* Handle the objects with extra data */
702 665
703 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 666 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
704 case ACPI_TYPE_BUFFER: 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:
@@ -708,18 +671,18 @@ acpi_ut_copy_simple_object (
708 * 2) The buffer has a length > 0 671 * 2) The buffer has a length > 0
709 */ 672 */
710 if ((source_desc->buffer.pointer) && 673 if ((source_desc->buffer.pointer) &&
711 (source_desc->buffer.length)) { 674 (source_desc->buffer.length)) {
712 dest_desc->buffer.pointer = 675 dest_desc->buffer.pointer =
713 ACPI_MEM_ALLOCATE (source_desc->buffer.length); 676 ACPI_MEM_ALLOCATE(source_desc->buffer.length);
714 if (!dest_desc->buffer.pointer) { 677 if (!dest_desc->buffer.pointer) {
715 return (AE_NO_MEMORY); 678 return (AE_NO_MEMORY);
716 } 679 }
717 680
718 /* Copy the actual buffer data */ 681 /* Copy the actual buffer data */
719 682
720 ACPI_MEMCPY (dest_desc->buffer.pointer, 683 ACPI_MEMCPY(dest_desc->buffer.pointer,
721 source_desc->buffer.pointer, 684 source_desc->buffer.pointer,
722 source_desc->buffer.length); 685 source_desc->buffer.length);
723 } 686 }
724 break; 687 break;
725 688
@@ -731,15 +694,17 @@ acpi_ut_copy_simple_object (
731 */ 694 */
732 if (source_desc->string.pointer) { 695 if (source_desc->string.pointer) {
733 dest_desc->string.pointer = 696 dest_desc->string.pointer =
734 ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); 697 ACPI_MEM_ALLOCATE((acpi_size) source_desc->string.
698 length + 1);
735 if (!dest_desc->string.pointer) { 699 if (!dest_desc->string.pointer) {
736 return (AE_NO_MEMORY); 700 return (AE_NO_MEMORY);
737 } 701 }
738 702
739 /* Copy the actual string data */ 703 /* Copy the actual string data */
740 704
741 ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, 705 ACPI_MEMCPY(dest_desc->string.pointer,
742 (acpi_size) source_desc->string.length + 1); 706 source_desc->string.pointer,
707 (acpi_size) source_desc->string.length + 1);
743 } 708 }
744 break; 709 break;
745 710
@@ -748,7 +713,7 @@ acpi_ut_copy_simple_object (
748 * 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
749 * to the object pointed to by the reference 714 * to the object pointed to by the reference
750 */ 715 */
751 acpi_ut_add_reference (source_desc->reference.object); 716 acpi_ut_add_reference(source_desc->reference.object);
752 break; 717 break;
753 718
754 default: 719 default:
@@ -759,7 +724,6 @@ acpi_ut_copy_simple_object (
759 return (AE_OK); 724 return (AE_OK);
760} 725}
761 726
762
763/******************************************************************************* 727/*******************************************************************************
764 * 728 *
765 * FUNCTION: acpi_ut_copy_ielement_to_ielement 729 * FUNCTION: acpi_ut_copy_ielement_to_ielement
@@ -773,24 +737,21 @@ acpi_ut_copy_simple_object (
773 ******************************************************************************/ 737 ******************************************************************************/
774 738
775static acpi_status 739static acpi_status
776acpi_ut_copy_ielement_to_ielement ( 740acpi_ut_copy_ielement_to_ielement(u8 object_type,
777 u8 object_type, 741 union acpi_operand_object *source_object,
778 union acpi_operand_object *source_object, 742 union acpi_generic_state *state,
779 union acpi_generic_state *state, 743 void *context)
780 void *context)
781{ 744{
782 acpi_status status = AE_OK; 745 acpi_status status = AE_OK;
783 u32 this_index; 746 u32 this_index;
784 union acpi_operand_object **this_target_ptr; 747 union acpi_operand_object **this_target_ptr;
785 union acpi_operand_object *target_object; 748 union acpi_operand_object *target_object;
786 749
750 ACPI_FUNCTION_ENTRY();
787 751
788 ACPI_FUNCTION_ENTRY (); 752 this_index = state->pkg.index;
789
790
791 this_index = state->pkg.index;
792 this_target_ptr = (union acpi_operand_object **) 753 this_target_ptr = (union acpi_operand_object **)
793 &state->pkg.dest_object->package.elements[this_index]; 754 &state->pkg.dest_object->package.elements[this_index];
794 755
795 switch (object_type) { 756 switch (object_type) {
796 case ACPI_COPY_TYPE_SIMPLE: 757 case ACPI_COPY_TYPE_SIMPLE:
@@ -801,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement (
801 /* 762 /*
802 * This is a simple object, just copy it 763 * This is a simple object, just copy it
803 */ 764 */
804 target_object = acpi_ut_create_internal_object ( 765 target_object =
805 ACPI_GET_OBJECT_TYPE (source_object)); 766 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
767 (source_object));
806 if (!target_object) { 768 if (!target_object) {
807 return (AE_NO_MEMORY); 769 return (AE_NO_MEMORY);
808 } 770 }
809 771
810 status = acpi_ut_copy_simple_object (source_object, target_object); 772 status =
811 if (ACPI_FAILURE (status)) { 773 acpi_ut_copy_simple_object(source_object,
774 target_object);
775 if (ACPI_FAILURE(status)) {
812 goto error_exit; 776 goto error_exit;
813 } 777 }
814 778
815 *this_target_ptr = target_object; 779 *this_target_ptr = target_object;
816 } 780 } else {
817 else {
818 /* Pass through a null element */ 781 /* Pass through a null element */
819 782
820 *this_target_ptr = NULL; 783 *this_target_ptr = NULL;
821 } 784 }
822 break; 785 break;
823 786
824
825 case ACPI_COPY_TYPE_PACKAGE: 787 case ACPI_COPY_TYPE_PACKAGE:
826 788
827 /* 789 /*
828 * This object is a package - go down another nesting level 790 * This object is a package - go down another nesting level
829 * Create and build the package object 791 * Create and build the package object
830 */ 792 */
831 target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); 793 target_object =
794 acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
832 if (!target_object) { 795 if (!target_object) {
833 return (AE_NO_MEMORY); 796 return (AE_NO_MEMORY);
834 } 797 }
@@ -840,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement (
840 * Create the object array 803 * Create the object array
841 */ 804 */
842 target_object->package.elements = 805 target_object->package.elements =
843 ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * 806 ACPI_MEM_CALLOCATE(((acpi_size) source_object->package.
844 sizeof (void *)); 807 count + 1) * sizeof(void *));
845 if (!target_object->package.elements) { 808 if (!target_object->package.elements) {
846 status = AE_NO_MEMORY; 809 status = AE_NO_MEMORY;
847 goto error_exit; 810 goto error_exit;
@@ -858,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement (
858 *this_target_ptr = target_object; 821 *this_target_ptr = target_object;
859 break; 822 break;
860 823
861
862 default: 824 default:
863 return (AE_BAD_PARAMETER); 825 return (AE_BAD_PARAMETER);
864 } 826 }
865 827
866 return (status); 828 return (status);
867 829
868error_exit: 830 error_exit:
869 acpi_ut_remove_reference (target_object); 831 acpi_ut_remove_reference(target_object);
870 return (status); 832 return (status);
871} 833}
872 834
873
874/******************************************************************************* 835/*******************************************************************************
875 * 836 *
876 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 837 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
@@ -886,49 +847,46 @@ error_exit:
886 ******************************************************************************/ 847 ******************************************************************************/
887 848
888static acpi_status 849static acpi_status
889acpi_ut_copy_ipackage_to_ipackage ( 850acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
890 union acpi_operand_object *source_obj, 851 union acpi_operand_object *dest_obj,
891 union acpi_operand_object *dest_obj, 852 struct acpi_walk_state *walk_state)
892 struct acpi_walk_state *walk_state)
893{ 853{
894 acpi_status status = AE_OK; 854 acpi_status status = AE_OK;
895
896
897 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");
898 855
856 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage");
899 857
900 dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); 858 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
901 dest_obj->common.flags = source_obj->common.flags; 859 dest_obj->common.flags = source_obj->common.flags;
902 dest_obj->package.count = source_obj->package.count; 860 dest_obj->package.count = source_obj->package.count;
903 861
904 /* 862 /*
905 * Create the object array and walk the source package tree 863 * Create the object array and walk the source package tree
906 */ 864 */
907 dest_obj->package.elements = ACPI_MEM_CALLOCATE ( 865 dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size)
908 ((acpi_size) source_obj->package.count + 1) * 866 source_obj->package.
909 sizeof (void *)); 867 count +
868 1) * sizeof(void *));
910 if (!dest_obj->package.elements) { 869 if (!dest_obj->package.elements) {
911 ACPI_REPORT_ERROR ( 870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n"));
912 ("aml_build_copy_internal_package_object: Package allocation failure\n")); 871 return_ACPI_STATUS(AE_NO_MEMORY);
913 return_ACPI_STATUS (AE_NO_MEMORY);
914 } 872 }
915 873
916 /* 874 /*
917 * Copy the package element-by-element by walking the package "tree". 875 * Copy the package element-by-element by walking the package "tree".
918 * This handles nested packages of arbitrary depth. 876 * This handles nested packages of arbitrary depth.
919 */ 877 */
920 status = acpi_ut_walk_package_tree (source_obj, dest_obj, 878 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
921 acpi_ut_copy_ielement_to_ielement, walk_state); 879 acpi_ut_copy_ielement_to_ielement,
922 if (ACPI_FAILURE (status)) { 880 walk_state);
881 if (ACPI_FAILURE(status)) {
923 /* On failure, delete the destination package object */ 882 /* On failure, delete the destination package object */
924 883
925 acpi_ut_remove_reference (dest_obj); 884 acpi_ut_remove_reference(dest_obj);
926 } 885 }
927 886
928 return_ACPI_STATUS (status); 887 return_ACPI_STATUS(status);
929} 888}
930 889
931
932/******************************************************************************* 890/*******************************************************************************
933 * 891 *
934 * FUNCTION: acpi_ut_copy_iobject_to_iobject 892 * FUNCTION: acpi_ut_copy_iobject_to_iobject
@@ -944,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage (
944 ******************************************************************************/ 902 ******************************************************************************/
945 903
946acpi_status 904acpi_status
947acpi_ut_copy_iobject_to_iobject ( 905acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
948 union acpi_operand_object *source_desc, 906 union acpi_operand_object **dest_desc,
949 union acpi_operand_object **dest_desc, 907 struct acpi_walk_state *walk_state)
950 struct acpi_walk_state *walk_state)
951{ 908{
952 acpi_status status = AE_OK; 909 acpi_status status = AE_OK;
953
954
955 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
956 910
911 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject");
957 912
958 /* Create the top level object */ 913 /* Create the top level object */
959 914
960 *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));
961 if (!*dest_desc) { 917 if (!*dest_desc) {
962 return_ACPI_STATUS (AE_NO_MEMORY); 918 return_ACPI_STATUS(AE_NO_MEMORY);
963 } 919 }
964 920
965 /* Copy the object and possible subobjects */ 921 /* Copy the object and possible subobjects */
966 922
967 if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { 923 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
968 status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, 924 status =
969 walk_state); 925 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
970 } 926 walk_state);
971 else { 927 } else {
972 status = acpi_ut_copy_simple_object (source_desc, *dest_desc); 928 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
973 } 929 }
974 930
975 return_ACPI_STATUS (status); 931 return_ACPI_STATUS(status);
976} 932}
977
978
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index c27cbb7f5c54..081a778aba88 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -46,21 +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
53 52static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
54static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; 53static char *acpi_gbl_fn_entry_str = "----Entry";
55static char *acpi_gbl_fn_entry_str = "----Entry"; 54static char *acpi_gbl_fn_exit_str = "----Exit-";
56static char *acpi_gbl_fn_exit_str = "----Exit-";
57 55
58/* Local prototypes */ 56/* Local prototypes */
59 57
60static const char * 58static const char *acpi_ut_trim_function_name(const char *function_name);
61acpi_ut_trim_function_name (
62 const char *function_name);
63
64 59
65/******************************************************************************* 60/*******************************************************************************
66 * 61 *
@@ -74,17 +69,13 @@ acpi_ut_trim_function_name (
74 * 69 *
75 ******************************************************************************/ 70 ******************************************************************************/
76 71
77void 72void acpi_ut_init_stack_ptr_trace(void)
78acpi_ut_init_stack_ptr_trace (
79 void)
80{ 73{
81 u32 current_sp; 74 u32 current_sp;
82
83 75
84 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL); 76 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(&current_sp, NULL);
85} 77}
86 78
87
88/******************************************************************************* 79/*******************************************************************************
89 * 80 *
90 * FUNCTION: acpi_ut_track_stack_ptr 81 * FUNCTION: acpi_ut_track_stack_ptr
@@ -97,14 +88,11 @@ acpi_ut_init_stack_ptr_trace (
97 * 88 *
98 ******************************************************************************/ 89 ******************************************************************************/
99 90
100void 91void acpi_ut_track_stack_ptr(void)
101acpi_ut_track_stack_ptr (
102 void)
103{ 92{
104 acpi_size current_sp; 93 acpi_size current_sp;
105 94
106 95 current_sp = ACPI_PTR_DIFF(&current_sp, NULL);
107 current_sp = ACPI_PTR_DIFF (&current_sp, NULL);
108 96
109 if (current_sp < acpi_gbl_lowest_stack_pointer) { 97 if (current_sp < acpi_gbl_lowest_stack_pointer) {
110 acpi_gbl_lowest_stack_pointer = current_sp; 98 acpi_gbl_lowest_stack_pointer = current_sp;
@@ -115,7 +103,6 @@ acpi_ut_track_stack_ptr (
115 } 103 }
116} 104}
117 105
118
119/******************************************************************************* 106/*******************************************************************************
120 * 107 *
121 * FUNCTION: acpi_ut_trim_function_name 108 * FUNCTION: acpi_ut_trim_function_name
@@ -130,20 +117,18 @@ acpi_ut_track_stack_ptr (
130 * 117 *
131 ******************************************************************************/ 118 ******************************************************************************/
132 119
133static const char * 120static const char *acpi_ut_trim_function_name(const char *function_name)
134acpi_ut_trim_function_name (
135 const char *function_name)
136{ 121{
137 122
138 /* All Function names are longer than 4 chars, check is safe */ 123 /* All Function names are longer than 4 chars, check is safe */
139 124
140 if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX1) { 125 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX1) {
141 /* This is the case where the original source has not been modified */ 126 /* This is the case where the original source has not been modified */
142 127
143 return (function_name + 4); 128 return (function_name + 4);
144 } 129 }
145 130
146 if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX2) { 131 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX2) {
147 /* This is the case where the source has been 'linuxized' */ 132 /* This is the case where the source has been 'linuxized' */
148 133
149 return (function_name + 5); 134 return (function_name + 5);
@@ -152,7 +137,6 @@ acpi_ut_trim_function_name (
152 return (function_name); 137 return (function_name);
153} 138}
154 139
155
156/******************************************************************************* 140/*******************************************************************************
157 * 141 *
158 * FUNCTION: acpi_ut_debug_print 142 * FUNCTION: acpi_ut_debug_print
@@ -172,38 +156,33 @@ acpi_ut_trim_function_name (
172 * 156 *
173 ******************************************************************************/ 157 ******************************************************************************/
174 158
175void ACPI_INTERNAL_VAR_XFACE 159void ACPI_INTERNAL_VAR_XFACE
176acpi_ut_debug_print ( 160acpi_ut_debug_print(u32 requested_debug_level,
177 u32 requested_debug_level, 161 u32 line_number,
178 u32 line_number, 162 const char *function_name,
179 const char *function_name, 163 char *module_name, u32 component_id, char *format, ...)
180 char *module_name,
181 u32 component_id,
182 char *format,
183 ...)
184{ 164{
185 u32 thread_id; 165 u32 thread_id;
186 va_list args; 166 va_list args;
187
188 167
189 /* 168 /*
190 * Stay silent if the debug level or component ID is disabled 169 * Stay silent if the debug level or component ID is disabled
191 */ 170 */
192 if (!(requested_debug_level & acpi_dbg_level) || 171 if (!(requested_debug_level & acpi_dbg_level) ||
193 !(component_id & acpi_dbg_layer)) { 172 !(component_id & acpi_dbg_layer)) {
194 return; 173 return;
195 } 174 }
196 175
197 /* 176 /*
198 * Thread tracking and context switch notification 177 * Thread tracking and context switch notification
199 */ 178 */
200 thread_id = acpi_os_get_thread_id (); 179 thread_id = acpi_os_get_thread_id();
201 180
202 if (thread_id != acpi_gbl_prev_thread_id) { 181 if (thread_id != acpi_gbl_prev_thread_id) {
203 if (ACPI_LV_THREADS & acpi_dbg_level) { 182 if (ACPI_LV_THREADS & acpi_dbg_level) {
204 acpi_os_printf ( 183 acpi_os_printf
205 "\n**** Context Switch from TID %X to TID %X ****\n\n", 184 ("\n**** Context Switch from TID %X to TID %X ****\n\n",
206 acpi_gbl_prev_thread_id, thread_id); 185 acpi_gbl_prev_thread_id, thread_id);
207 } 186 }
208 187
209 acpi_gbl_prev_thread_id = thread_id; 188 acpi_gbl_prev_thread_id = thread_id;
@@ -213,17 +192,18 @@ acpi_ut_debug_print (
213 * Display the module name, current line number, thread ID (if requested), 192 * Display the module name, current line number, thread ID (if requested),
214 * current procedure nesting level, and the current procedure name 193 * current procedure nesting level, and the current procedure name
215 */ 194 */
216 acpi_os_printf ("%8s-%04ld ", module_name, line_number); 195 acpi_os_printf("%8s-%04ld ", module_name, line_number);
217 196
218 if (ACPI_LV_THREADS & acpi_dbg_level) { 197 if (ACPI_LV_THREADS & acpi_dbg_level) {
219 acpi_os_printf ("[%04lX] ", thread_id); 198 acpi_os_printf("[%04lX] ", thread_id);
220 } 199 }
221 200
222 acpi_os_printf ("[%02ld] %-22.22s: ", 201 acpi_os_printf("[%02ld] %-22.22s: ",
223 acpi_gbl_nesting_level, acpi_ut_trim_function_name (function_name)); 202 acpi_gbl_nesting_level,
203 acpi_ut_trim_function_name(function_name));
224 204
225 va_start (args, format); 205 va_start(args, format);
226 acpi_os_vprintf (format, args); 206 acpi_os_vprintf(format, args);
227} 207}
228 208
229EXPORT_SYMBOL(acpi_ut_debug_print); 209EXPORT_SYMBOL(acpi_ut_debug_print);
@@ -247,29 +227,24 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
247 * 227 *
248 ******************************************************************************/ 228 ******************************************************************************/
249 229
250void ACPI_INTERNAL_VAR_XFACE 230void ACPI_INTERNAL_VAR_XFACE
251acpi_ut_debug_print_raw ( 231acpi_ut_debug_print_raw(u32 requested_debug_level,
252 u32 requested_debug_level, 232 u32 line_number,
253 u32 line_number, 233 const char *function_name,
254 const char *function_name, 234 char *module_name, u32 component_id, char *format, ...)
255 char *module_name,
256 u32 component_id,
257 char *format,
258 ...)
259{ 235{
260 va_list args; 236 va_list args;
261
262 237
263 if (!(requested_debug_level & acpi_dbg_level) || 238 if (!(requested_debug_level & acpi_dbg_level) ||
264 !(component_id & acpi_dbg_layer)) { 239 !(component_id & acpi_dbg_layer)) {
265 return; 240 return;
266 } 241 }
267 242
268 va_start (args, format); 243 va_start(args, format);
269 acpi_os_vprintf (format, args); 244 acpi_os_vprintf(format, args);
270} 245}
271EXPORT_SYMBOL(acpi_ut_debug_print_raw);
272 246
247EXPORT_SYMBOL(acpi_ut_debug_print_raw);
273 248
274/******************************************************************************* 249/*******************************************************************************
275 * 250 *
@@ -288,22 +263,19 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw);
288 ******************************************************************************/ 263 ******************************************************************************/
289 264
290void 265void
291acpi_ut_trace ( 266acpi_ut_trace(u32 line_number,
292 u32 line_number, 267 const char *function_name, char *module_name, u32 component_id)
293 const char *function_name,
294 char *module_name,
295 u32 component_id)
296{ 268{
297 269
298 acpi_gbl_nesting_level++; 270 acpi_gbl_nesting_level++;
299 acpi_ut_track_stack_ptr (); 271 acpi_ut_track_stack_ptr();
300 272
301 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
302 line_number, function_name, module_name, component_id, 274 line_number, function_name, module_name,
303 "%s\n", acpi_gbl_fn_entry_str); 275 component_id, "%s\n", acpi_gbl_fn_entry_str);
304} 276}
305EXPORT_SYMBOL(acpi_ut_trace);
306 277
278EXPORT_SYMBOL(acpi_ut_trace);
307 279
308/******************************************************************************* 280/*******************************************************************************
309 * 281 *
@@ -323,22 +295,19 @@ EXPORT_SYMBOL(acpi_ut_trace);
323 ******************************************************************************/ 295 ******************************************************************************/
324 296
325void 297void
326acpi_ut_trace_ptr ( 298acpi_ut_trace_ptr(u32 line_number,
327 u32 line_number, 299 const char *function_name,
328 const char *function_name, 300 char *module_name, u32 component_id, void *pointer)
329 char *module_name,
330 u32 component_id,
331 void *pointer)
332{ 301{
333 acpi_gbl_nesting_level++; 302 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr (); 303 acpi_ut_track_stack_ptr();
335 304
336 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 305 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, component_id, 306 line_number, function_name, module_name,
338 "%s %p\n", acpi_gbl_fn_entry_str, pointer); 307 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
308 pointer);
339} 309}
340 310
341
342/******************************************************************************* 311/*******************************************************************************
343 * 312 *
344 * FUNCTION: acpi_ut_trace_str 313 * FUNCTION: acpi_ut_trace_str
@@ -357,23 +326,20 @@ acpi_ut_trace_ptr (
357 ******************************************************************************/ 326 ******************************************************************************/
358 327
359void 328void
360acpi_ut_trace_str ( 329acpi_ut_trace_str(u32 line_number,
361 u32 line_number, 330 const char *function_name,
362 const char *function_name, 331 char *module_name, u32 component_id, char *string)
363 char *module_name,
364 u32 component_id,
365 char *string)
366{ 332{
367 333
368 acpi_gbl_nesting_level++; 334 acpi_gbl_nesting_level++;
369 acpi_ut_track_stack_ptr (); 335 acpi_ut_track_stack_ptr();
370 336
371 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 337 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
372 line_number, function_name, module_name, component_id, 338 line_number, function_name, module_name,
373 "%s %s\n", acpi_gbl_fn_entry_str, string); 339 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
340 string);
374} 341}
375 342
376
377/******************************************************************************* 343/*******************************************************************************
378 * 344 *
379 * FUNCTION: acpi_ut_trace_u32 345 * FUNCTION: acpi_ut_trace_u32
@@ -392,23 +358,20 @@ acpi_ut_trace_str (
392 ******************************************************************************/ 358 ******************************************************************************/
393 359
394void 360void
395acpi_ut_trace_u32 ( 361acpi_ut_trace_u32(u32 line_number,
396 u32 line_number, 362 const char *function_name,
397 const char *function_name, 363 char *module_name, u32 component_id, u32 integer)
398 char *module_name,
399 u32 component_id,
400 u32 integer)
401{ 364{
402 365
403 acpi_gbl_nesting_level++; 366 acpi_gbl_nesting_level++;
404 acpi_ut_track_stack_ptr (); 367 acpi_ut_track_stack_ptr();
405 368
406 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 369 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
407 line_number, function_name, module_name, component_id, 370 line_number, function_name, module_name,
408 "%s %08X\n", acpi_gbl_fn_entry_str, integer); 371 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
372 integer);
409} 373}
410 374
411
412/******************************************************************************* 375/*******************************************************************************
413 * 376 *
414 * FUNCTION: acpi_ut_exit 377 * FUNCTION: acpi_ut_exit
@@ -426,21 +389,18 @@ acpi_ut_trace_u32 (
426 ******************************************************************************/ 389 ******************************************************************************/
427 390
428void 391void
429acpi_ut_exit ( 392acpi_ut_exit(u32 line_number,
430 u32 line_number, 393 const char *function_name, char *module_name, u32 component_id)
431 const char *function_name,
432 char *module_name,
433 u32 component_id)
434{ 394{
435 395
436 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
437 line_number, function_name, module_name, component_id, 397 line_number, function_name, module_name,
438 "%s\n", acpi_gbl_fn_exit_str); 398 component_id, "%s\n", acpi_gbl_fn_exit_str);
439 399
440 acpi_gbl_nesting_level--; 400 acpi_gbl_nesting_level--;
441} 401}
442EXPORT_SYMBOL(acpi_ut_exit);
443 402
403EXPORT_SYMBOL(acpi_ut_exit);
444 404
445/******************************************************************************* 405/*******************************************************************************
446 * 406 *
@@ -460,31 +420,29 @@ EXPORT_SYMBOL(acpi_ut_exit);
460 ******************************************************************************/ 420 ******************************************************************************/
461 421
462void 422void
463acpi_ut_status_exit ( 423acpi_ut_status_exit(u32 line_number,
464 u32 line_number, 424 const char *function_name,
465 const char *function_name, 425 char *module_name, u32 component_id, acpi_status status)
466 char *module_name,
467 u32 component_id,
468 acpi_status status)
469{ 426{
470 427
471 if (ACPI_SUCCESS (status)) { 428 if (ACPI_SUCCESS(status)) {
472 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
473 line_number, function_name, module_name, component_id, 430 line_number, function_name, module_name,
474 "%s %s\n", acpi_gbl_fn_exit_str, 431 component_id, "%s %s\n",
475 acpi_format_exception (status)); 432 acpi_gbl_fn_exit_str,
476 } 433 acpi_format_exception(status));
477 else { 434 } else {
478 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
479 line_number, function_name, module_name, component_id, 436 line_number, function_name, module_name,
480 "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, 437 component_id, "%s ****Exception****: %s\n",
481 acpi_format_exception (status)); 438 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status));
482 } 440 }
483 441
484 acpi_gbl_nesting_level--; 442 acpi_gbl_nesting_level--;
485} 443}
486EXPORT_SYMBOL(acpi_ut_status_exit);
487 444
445EXPORT_SYMBOL(acpi_ut_status_exit);
488 446
489/******************************************************************************* 447/*******************************************************************************
490 * 448 *
@@ -504,23 +462,20 @@ EXPORT_SYMBOL(acpi_ut_status_exit);
504 ******************************************************************************/ 462 ******************************************************************************/
505 463
506void 464void
507acpi_ut_value_exit ( 465acpi_ut_value_exit(u32 line_number,
508 u32 line_number, 466 const char *function_name,
509 const char *function_name, 467 char *module_name, u32 component_id, acpi_integer value)
510 char *module_name,
511 u32 component_id,
512 acpi_integer value)
513{ 468{
514 469
515 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
516 line_number, function_name, module_name, component_id, 471 line_number, function_name, module_name,
517 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, 472 component_id, "%s %8.8X%8.8X\n",
518 ACPI_FORMAT_UINT64 (value)); 473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
519 474
520 acpi_gbl_nesting_level--; 475 acpi_gbl_nesting_level--;
521} 476}
522EXPORT_SYMBOL(acpi_ut_value_exit);
523 477
478EXPORT_SYMBOL(acpi_ut_value_exit);
524 479
525/******************************************************************************* 480/*******************************************************************************
526 * 481 *
@@ -540,24 +495,20 @@ EXPORT_SYMBOL(acpi_ut_value_exit);
540 ******************************************************************************/ 495 ******************************************************************************/
541 496
542void 497void
543acpi_ut_ptr_exit ( 498acpi_ut_ptr_exit(u32 line_number,
544 u32 line_number, 499 const char *function_name,
545 const char *function_name, 500 char *module_name, u32 component_id, u8 * ptr)
546 char *module_name,
547 u32 component_id,
548 u8 *ptr)
549{ 501{
550 502
551 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 503 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
552 line_number, function_name, module_name, component_id, 504 line_number, function_name, module_name,
553 "%s %p\n", acpi_gbl_fn_exit_str, ptr); 505 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
554 506
555 acpi_gbl_nesting_level--; 507 acpi_gbl_nesting_level--;
556} 508}
557 509
558#endif 510#endif
559 511
560
561/******************************************************************************* 512/*******************************************************************************
562 * 513 *
563 * FUNCTION: acpi_ut_dump_buffer 514 * FUNCTION: acpi_ut_dump_buffer
@@ -573,23 +524,17 @@ acpi_ut_ptr_exit (
573 * 524 *
574 ******************************************************************************/ 525 ******************************************************************************/
575 526
576void 527void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
577acpi_ut_dump_buffer (
578 u8 *buffer,
579 u32 count,
580 u32 display,
581 u32 component_id)
582{ 528{
583 acpi_native_uint i = 0; 529 acpi_native_uint i = 0;
584 acpi_native_uint j; 530 acpi_native_uint j;
585 u32 temp32; 531 u32 temp32;
586 u8 buf_char; 532 u8 buf_char;
587
588 533
589 /* Only dump the buffer if tracing is enabled */ 534 /* Only dump the buffer if tracing is enabled */
590 535
591 if (!((ACPI_LV_TABLES & acpi_dbg_level) && 536 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
592 (component_id & acpi_dbg_layer))) { 537 (component_id & acpi_dbg_layer))) {
593 return; 538 return;
594 } 539 }
595 540
@@ -602,7 +547,7 @@ acpi_ut_dump_buffer (
602 while (i < count) { 547 while (i < count) {
603 /* Print current offset */ 548 /* Print current offset */
604 549
605 acpi_os_printf ("%6.4X: ", (u32) i); 550 acpi_os_printf("%6.4X: ", (u32) i);
606 551
607 /* Print 16 hex chars */ 552 /* Print 16 hex chars */
608 553
@@ -610,39 +555,36 @@ acpi_ut_dump_buffer (
610 if (i + j >= count) { 555 if (i + j >= count) {
611 /* Dump fill spaces */ 556 /* Dump fill spaces */
612 557
613 acpi_os_printf ("%*s", ((display * 2) + 1), " "); 558 acpi_os_printf("%*s", ((display * 2) + 1), " ");
614 j += (acpi_native_uint) display; 559 j += (acpi_native_uint) display;
615 continue; 560 continue;
616 } 561 }
617 562
618 switch (display) { 563 switch (display) {
619 default: /* Default is BYTE display */ 564 default: /* Default is BYTE display */
620 565
621 acpi_os_printf ("%02X ", buffer[i + j]); 566 acpi_os_printf("%02X ", buffer[i + j]);
622 break; 567 break;
623 568
624
625 case DB_WORD_DISPLAY: 569 case DB_WORD_DISPLAY:
626 570
627 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); 571 ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]);
628 acpi_os_printf ("%04X ", temp32); 572 acpi_os_printf("%04X ", temp32);
629 break; 573 break;
630 574
631
632 case DB_DWORD_DISPLAY: 575 case DB_DWORD_DISPLAY:
633 576
634 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 577 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
635 acpi_os_printf ("%08X ", temp32); 578 acpi_os_printf("%08X ", temp32);
636 break; 579 break;
637 580
638
639 case DB_QWORD_DISPLAY: 581 case DB_QWORD_DISPLAY:
640 582
641 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 583 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
642 acpi_os_printf ("%08X", temp32); 584 acpi_os_printf("%08X", temp32);
643 585
644 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); 586 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]);
645 acpi_os_printf ("%08X ", temp32); 587 acpi_os_printf("%08X ", temp32);
646 break; 588 break;
647 } 589 }
648 590
@@ -653,28 +595,26 @@ acpi_ut_dump_buffer (
653 * Print the ASCII equivalent characters but watch out for the bad 595 * Print the ASCII equivalent characters but watch out for the bad
654 * unprintable ones (printable chars are 0x20 through 0x7E) 596 * unprintable ones (printable chars are 0x20 through 0x7E)
655 */ 597 */
656 acpi_os_printf (" "); 598 acpi_os_printf(" ");
657 for (j = 0; j < 16; j++) { 599 for (j = 0; j < 16; j++) {
658 if (i + j >= count) { 600 if (i + j >= count) {
659 acpi_os_printf ("\n"); 601 acpi_os_printf("\n");
660 return; 602 return;
661 } 603 }
662 604
663 buf_char = buffer[i + j]; 605 buf_char = buffer[i + j];
664 if (ACPI_IS_PRINT (buf_char)) { 606 if (ACPI_IS_PRINT(buf_char)) {
665 acpi_os_printf ("%c", buf_char); 607 acpi_os_printf("%c", buf_char);
666 } 608 } else {
667 else { 609 acpi_os_printf(".");
668 acpi_os_printf (".");
669 } 610 }
670 } 611 }
671 612
672 /* Done with that line. */ 613 /* Done with that line. */
673 614
674 acpi_os_printf ("\n"); 615 acpi_os_printf("\n");
675 i += 16; 616 i += 16;
676 } 617 }
677 618
678 return; 619 return;
679} 620}
680
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index eeafb324c504..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,38 +405,36 @@ 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 = AE_OK; 410 acpi_status status = AE_OK;
439 union acpi_generic_state *state_list = NULL; 411 union acpi_generic_state *state_list = NULL;
440 union acpi_operand_object *next_object = NULL; 412 union acpi_operand_object *next_object = NULL;
441 union acpi_generic_state *state; 413 union acpi_generic_state *state;
442 acpi_native_uint i; 414 acpi_native_uint i;
443
444
445 ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
446 415
416 ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object);
447 417
448 while (object) { 418 while (object) {
449 /* Make sure that this isn't a namespace handle */ 419 /* Make sure that this isn't a namespace handle */
450 420
451 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { 421 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
452 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 422 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
453 "Object %p is NS handle\n", object)); 423 "Object %p is NS handle\n", object));
454 return_ACPI_STATUS (AE_OK); 424 return_ACPI_STATUS(AE_OK);
455 } 425 }
456 426
457 /* 427 /*
458 * All sub-objects must have their reference count incremented also. 428 * All sub-objects must have their reference count incremented also.
459 * Different object types have different subobjects. 429 * Different object types have different subobjects.
460 */ 430 */
461 switch (ACPI_GET_OBJECT_TYPE (object)) { 431 switch (ACPI_GET_OBJECT_TYPE(object)) {
462 case ACPI_TYPE_DEVICE: 432 case ACPI_TYPE_DEVICE:
463 433
464 acpi_ut_update_ref_count (object->device.system_notify, action); 434 acpi_ut_update_ref_count(object->device.system_notify,
465 acpi_ut_update_ref_count (object->device.device_notify, action); 435 action);
436 acpi_ut_update_ref_count(object->device.device_notify,
437 action);
466 break; 438 break;
467 439
468 case ACPI_TYPE_PACKAGE: 440 case ACPI_TYPE_PACKAGE:
@@ -476,9 +448,11 @@ acpi_ut_update_object_reference (
476 * Note: There can be null elements within the package, 448 * Note: There can be null elements within the package,
477 * these are simply ignored 449 * these are simply ignored
478 */ 450 */
479 status = acpi_ut_create_update_state_and_push ( 451 status =
480 object->package.elements[i], action, &state_list); 452 acpi_ut_create_update_state_and_push
481 if (ACPI_FAILURE (status)) { 453 (object->package.elements[i], action,
454 &state_list);
455 if (ACPI_FAILURE(status)) {
482 goto error_exit; 456 goto error_exit;
483 } 457 }
484 } 458 }
@@ -497,9 +471,13 @@ acpi_ut_update_object_reference (
497 case ACPI_TYPE_LOCAL_BANK_FIELD: 471 case ACPI_TYPE_LOCAL_BANK_FIELD:
498 472
499 next_object = object->bank_field.bank_obj; 473 next_object = object->bank_field.bank_obj;
500 status = acpi_ut_create_update_state_and_push ( 474 status =
501 object->bank_field.region_obj, action, &state_list); 475 acpi_ut_create_update_state_and_push(object->
502 if (ACPI_FAILURE (status)) { 476 bank_field.
477 region_obj,
478 action,
479 &state_list);
480 if (ACPI_FAILURE(status)) {
503 goto error_exit; 481 goto error_exit;
504 } 482 }
505 break; 483 break;
@@ -507,9 +485,13 @@ acpi_ut_update_object_reference (
507 case ACPI_TYPE_LOCAL_INDEX_FIELD: 485 case ACPI_TYPE_LOCAL_INDEX_FIELD:
508 486
509 next_object = object->index_field.index_obj; 487 next_object = object->index_field.index_obj;
510 status = acpi_ut_create_update_state_and_push ( 488 status =
511 object->index_field.data_obj, action, &state_list); 489 acpi_ut_create_update_state_and_push(object->
512 if (ACPI_FAILURE (status)) { 490 index_field.
491 data_obj,
492 action,
493 &state_list);
494 if (ACPI_FAILURE(status)) {
513 goto error_exit; 495 goto error_exit;
514 } 496 }
515 break; 497 break;
@@ -526,7 +508,7 @@ acpi_ut_update_object_reference (
526 508
527 case ACPI_TYPE_REGION: 509 case ACPI_TYPE_REGION:
528 default: 510 default:
529 break;/* No subobjects */ 511 break; /* No subobjects */
530 } 512 }
531 513
532 /* 514 /*
@@ -534,7 +516,7 @@ acpi_ut_update_object_reference (
534 * 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
535 * main object to be deleted. 517 * main object to be deleted.
536 */ 518 */
537 acpi_ut_update_ref_count (object, action); 519 acpi_ut_update_ref_count(object, action);
538 object = NULL; 520 object = NULL;
539 521
540 /* Move on to the next object to be updated */ 522 /* Move on to the next object to be updated */
@@ -542,25 +524,23 @@ acpi_ut_update_object_reference (
542 if (next_object) { 524 if (next_object) {
543 object = next_object; 525 object = next_object;
544 next_object = NULL; 526 next_object = NULL;
545 } 527 } else if (state_list) {
546 else if (state_list) { 528 state = acpi_ut_pop_generic_state(&state_list);
547 state = acpi_ut_pop_generic_state (&state_list);
548 object = state->update.object; 529 object = state->update.object;
549 acpi_ut_delete_generic_state (state); 530 acpi_ut_delete_generic_state(state);
550 } 531 }
551 } 532 }
552 533
553 return_ACPI_STATUS (AE_OK); 534 return_ACPI_STATUS(AE_OK);
554 535
555error_exit: 536 error_exit:
556 537
557 ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", 538 ACPI_REPORT_ERROR(("Could not update object reference count, %s\n",
558 acpi_format_exception (status))); 539 acpi_format_exception(status)));
559 540
560 return_ACPI_STATUS (status); 541 return_ACPI_STATUS(status);
561} 542}
562 543
563
564/******************************************************************************* 544/*******************************************************************************
565 * 545 *
566 * FUNCTION: acpi_ut_add_reference 546 * FUNCTION: acpi_ut_add_reference
@@ -574,31 +554,27 @@ error_exit:
574 * 554 *
575 ******************************************************************************/ 555 ******************************************************************************/
576 556
577void 557void acpi_ut_add_reference(union acpi_operand_object *object)
578acpi_ut_add_reference (
579 union acpi_operand_object *object)
580{ 558{
581 559
582 ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object); 560 ACPI_FUNCTION_TRACE_PTR("ut_add_reference", object);
583
584 561
585 /* Ensure that we have a valid object */ 562 /* Ensure that we have a valid object */
586 563
587 if (!acpi_ut_valid_internal_object (object)) { 564 if (!acpi_ut_valid_internal_object(object)) {
588 return_VOID; 565 return_VOID;
589 } 566 }
590 567
591 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 568 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
592 "Obj %p Current Refs=%X [To Be Incremented]\n", 569 "Obj %p Current Refs=%X [To Be Incremented]\n",
593 object, object->common.reference_count)); 570 object, object->common.reference_count));
594 571
595 /* Increment the reference count */ 572 /* Increment the reference count */
596 573
597 (void) acpi_ut_update_object_reference (object, REF_INCREMENT); 574 (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
598 return_VOID; 575 return_VOID;
599} 576}
600 577
601
602/******************************************************************************* 578/*******************************************************************************
603 * 579 *
604 * FUNCTION: acpi_ut_remove_reference 580 * FUNCTION: acpi_ut_remove_reference
@@ -611,13 +587,10 @@ acpi_ut_add_reference (
611 * 587 *
612 ******************************************************************************/ 588 ******************************************************************************/
613 589
614void 590void acpi_ut_remove_reference(union acpi_operand_object *object)
615acpi_ut_remove_reference (
616 union acpi_operand_object *object)
617{ 591{
618 592
619 ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object); 593 ACPI_FUNCTION_TRACE_PTR("ut_remove_reference", object);
620
621 594
622 /* 595 /*
623 * 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
@@ -625,27 +598,25 @@ acpi_ut_remove_reference (
625 * 598 *
626 */ 599 */
627 if (!object || 600 if (!object ||
628 (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) { 601 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
629 return_VOID; 602 return_VOID;
630 } 603 }
631 604
632 /* Ensure that we have a valid object */ 605 /* Ensure that we have a valid object */
633 606
634 if (!acpi_ut_valid_internal_object (object)) { 607 if (!acpi_ut_valid_internal_object(object)) {
635 return_VOID; 608 return_VOID;
636 } 609 }
637 610
638 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 611 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
639 "Obj %p Current Refs=%X [To Be Decremented]\n", 612 "Obj %p Current Refs=%X [To Be Decremented]\n",
640 object, object->common.reference_count)); 613 object, object->common.reference_count));
641 614
642 /* 615 /*
643 * Decrement the reference count, and only actually delete the object 616 * Decrement the reference count, and only actually delete the object
644 * 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
645 * of all subobjects!) 618 * of all subobjects!)
646 */ 619 */
647 (void) acpi_ut_update_object_reference (object, REF_DECREMENT); 620 (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
648 return_VOID; 621 return_VOID;
649} 622}
650
651
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 0e4161c81076..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,7 +745,6 @@ acpi_ut_valid_object_type (
735 return (TRUE); 745 return (TRUE);
736} 746}
737 747
738
739/******************************************************************************* 748/*******************************************************************************
740 * 749 *
741 * FUNCTION: acpi_ut_init_globals 750 * FUNCTION: acpi_ut_init_globals
@@ -749,106 +758,96 @@ acpi_ut_valid_object_type (
749 * 758 *
750 ******************************************************************************/ 759 ******************************************************************************/
751 760
752void 761void acpi_ut_init_globals(void)
753acpi_ut_init_globals (
754 void)
755{ 762{
756 acpi_status status; 763 acpi_status status;
757 u32 i; 764 u32 i;
758
759
760 ACPI_FUNCTION_TRACE ("ut_init_globals");
761 765
766 ACPI_FUNCTION_TRACE("ut_init_globals");
762 767
763 /* Create all memory caches */ 768 /* Create all memory caches */
764 769
765 status = acpi_ut_create_caches (); 770 status = acpi_ut_create_caches();
766 if (ACPI_FAILURE (status)) 771 if (ACPI_FAILURE(status)) {
767 {
768 return; 772 return;
769 } 773 }
770 774
771 /* ACPI table structure */ 775 /* ACPI table structure */
772 776
773 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 777 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
774 { 778 acpi_gbl_table_lists[i].next = NULL;
775 acpi_gbl_table_lists[i].next = NULL; 779 acpi_gbl_table_lists[i].count = 0;
776 acpi_gbl_table_lists[i].count = 0;
777 } 780 }
778 781
779 /* Mutex locked flags */ 782 /* Mutex locked flags */
780 783
781 for (i = 0; i < NUM_MUTEX; i++) 784 for (i = 0; i < NUM_MUTEX; i++) {
782 { 785 acpi_gbl_mutex_info[i].mutex = NULL;
783 acpi_gbl_mutex_info[i].mutex = NULL; 786 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
784 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 787 acpi_gbl_mutex_info[i].use_count = 0;
785 acpi_gbl_mutex_info[i].use_count = 0;
786 } 788 }
787 789
788 /* GPE support */ 790 /* GPE support */
789 791
790 acpi_gbl_gpe_xrupt_list_head = NULL; 792 acpi_gbl_gpe_xrupt_list_head = NULL;
791 acpi_gbl_gpe_fadt_blocks[0] = NULL; 793 acpi_gbl_gpe_fadt_blocks[0] = NULL;
792 acpi_gbl_gpe_fadt_blocks[1] = NULL; 794 acpi_gbl_gpe_fadt_blocks[1] = NULL;
793 795
794 /* Global notify handlers */ 796 /* Global notify handlers */
795 797
796 acpi_gbl_system_notify.handler = NULL; 798 acpi_gbl_system_notify.handler = NULL;
797 acpi_gbl_device_notify.handler = NULL; 799 acpi_gbl_device_notify.handler = NULL;
798 acpi_gbl_exception_handler = NULL; 800 acpi_gbl_exception_handler = NULL;
799 acpi_gbl_init_handler = NULL; 801 acpi_gbl_init_handler = NULL;
800 802
801 /* Global "typed" ACPI table pointers */ 803 /* Global "typed" ACPI table pointers */
802 804
803 acpi_gbl_RSDP = NULL; 805 acpi_gbl_RSDP = NULL;
804 acpi_gbl_XSDT = NULL; 806 acpi_gbl_XSDT = NULL;
805 acpi_gbl_FACS = NULL; 807 acpi_gbl_FACS = NULL;
806 acpi_gbl_FADT = NULL; 808 acpi_gbl_FADT = NULL;
807 acpi_gbl_DSDT = NULL; 809 acpi_gbl_DSDT = NULL;
808 810
809 /* Global Lock support */ 811 /* Global Lock support */
810 812
811 acpi_gbl_global_lock_acquired = FALSE; 813 acpi_gbl_global_lock_acquired = FALSE;
812 acpi_gbl_global_lock_thread_count = 0; 814 acpi_gbl_global_lock_thread_count = 0;
813 acpi_gbl_global_lock_handle = 0; 815 acpi_gbl_global_lock_handle = 0;
814 816
815 /* Miscellaneous variables */ 817 /* Miscellaneous variables */
816 818
817 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; 819 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
818 acpi_gbl_rsdp_original_location = 0; 820 acpi_gbl_rsdp_original_location = 0;
819 acpi_gbl_cm_single_step = FALSE; 821 acpi_gbl_cm_single_step = FALSE;
820 acpi_gbl_db_terminate_threads = FALSE; 822 acpi_gbl_db_terminate_threads = FALSE;
821 acpi_gbl_shutdown = FALSE; 823 acpi_gbl_shutdown = FALSE;
822 acpi_gbl_ns_lookup_count = 0; 824 acpi_gbl_ns_lookup_count = 0;
823 acpi_gbl_ps_find_count = 0; 825 acpi_gbl_ps_find_count = 0;
824 acpi_gbl_acpi_hardware_present = TRUE; 826 acpi_gbl_acpi_hardware_present = TRUE;
825 acpi_gbl_owner_id_mask = 0; 827 acpi_gbl_owner_id_mask = 0;
826 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
827 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
828 830
829 /* Hardware oriented */ 831 /* Hardware oriented */
830 832
831 acpi_gbl_events_initialized = FALSE; 833 acpi_gbl_events_initialized = FALSE;
832 acpi_gbl_system_awake_and_running = TRUE; 834 acpi_gbl_system_awake_and_running = TRUE;
833 835
834 /* Namespace */ 836 /* Namespace */
835 837
836 acpi_gbl_root_node = NULL; 838 acpi_gbl_root_node = NULL;
837 839
838 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 840 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
839 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 841 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
840 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 842 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
841 acpi_gbl_root_node_struct.child = NULL; 843 acpi_gbl_root_node_struct.child = NULL;
842 acpi_gbl_root_node_struct.peer = NULL; 844 acpi_gbl_root_node_struct.peer = NULL;
843 acpi_gbl_root_node_struct.object = NULL; 845 acpi_gbl_root_node_struct.object = NULL;
844 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; 846 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
845
846 847
847#ifdef ACPI_DEBUG_OUTPUT 848#ifdef ACPI_DEBUG_OUTPUT
848 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; 849 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
849#endif 850#endif
850 851
851 return_VOID; 852 return_VOID;
852} 853}
853
854
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index fd7ceba83229..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_ut_delete_caches (); 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 1d350b302a34..474fe7cb6c09 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.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_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 48ACPI_MODULE_NAME("utmisc")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -63,23 +60,18 @@
63 * when the method exits or the table is unloaded. 60 * when the method exits or the table is unloaded.
64 * 61 *
65 ******************************************************************************/ 62 ******************************************************************************/
66 63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
67acpi_status
68acpi_ut_allocate_owner_id (
69 acpi_owner_id *owner_id)
70{ 64{
71 acpi_native_uint i; 65 acpi_native_uint i;
72 acpi_status status; 66 acpi_status status;
73
74
75 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
76 67
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
77 69
78 /* Mutex for the global ID mask */ 70 /* Mutex for the global ID mask */
79 71
80 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 72 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
81 if (ACPI_FAILURE (status)) { 73 if (ACPI_FAILURE(status)) {
82 return_ACPI_STATUS (status); 74 return_ACPI_STATUS(status);
83 } 75 }
84 76
85 /* Find a free owner ID */ 77 /* Find a free owner ID */
@@ -101,15 +93,13 @@ acpi_ut_allocate_owner_id (
101 */ 93 */
102 *owner_id = 0; 94 *owner_id = 0;
103 status = AE_OWNER_ID_LIMIT; 95 status = AE_OWNER_ID_LIMIT;
104 ACPI_REPORT_ERROR (( 96 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
105 "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
106 97
107exit: 98 exit:
108 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 99 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
109 return_ACPI_STATUS (status); 100 return_ACPI_STATUS(status);
110} 101}
111 102
112
113/******************************************************************************* 103/*******************************************************************************
114 * 104 *
115 * FUNCTION: acpi_ut_release_owner_id 105 * FUNCTION: acpi_ut_release_owner_id
@@ -124,16 +114,12 @@ exit:
124 * 114 *
125 ******************************************************************************/ 115 ******************************************************************************/
126 116
127void 117void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
128acpi_ut_release_owner_id (
129 acpi_owner_id *owner_id_ptr)
130{ 118{
131 acpi_owner_id owner_id = *owner_id_ptr; 119 acpi_owner_id owner_id = *owner_id_ptr;
132 acpi_status status; 120 acpi_status status;
133
134
135 ACPI_FUNCTION_TRACE ("ut_release_owner_id");
136 121
122 ACPI_FUNCTION_TRACE("ut_release_owner_id");
137 123
138 /* Always clear the input owner_id (zero is an invalid ID) */ 124 /* Always clear the input owner_id (zero is an invalid ID) */
139 125
@@ -142,18 +128,18 @@ acpi_ut_release_owner_id (
142 /* Zero is not a valid owner_iD */ 128 /* Zero is not a valid owner_iD */
143 129
144 if ((owner_id == 0) || (owner_id > 32)) { 130 if ((owner_id == 0) || (owner_id > 32)) {
145 ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id)); 131 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
146 return_VOID; 132 return_VOID;
147 } 133 }
148 134
149 /* Mutex for the global ID mask */ 135 /* Mutex for the global ID mask */
150 136
151 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 137 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
152 if (ACPI_FAILURE (status)) { 138 if (ACPI_FAILURE(status)) {
153 return_VOID; 139 return_VOID;
154 } 140 }
155 141
156 owner_id--; /* Normalize to zero */ 142 owner_id--; /* Normalize to zero */
157 143
158 /* Free the owner ID only if it is valid */ 144 /* Free the owner ID only if it is valid */
159 145
@@ -161,11 +147,10 @@ acpi_ut_release_owner_id (
161 acpi_gbl_owner_id_mask ^= (1 << owner_id); 147 acpi_gbl_owner_id_mask ^= (1 << owner_id);
162 } 148 }
163 149
164 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 150 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
165 return_VOID; 151 return_VOID;
166} 152}
167 153
168
169/******************************************************************************* 154/*******************************************************************************
170 * 155 *
171 * FUNCTION: acpi_ut_strupr (strupr) 156 * FUNCTION: acpi_ut_strupr (strupr)
@@ -180,15 +165,11 @@ acpi_ut_release_owner_id (
180 * 165 *
181 ******************************************************************************/ 166 ******************************************************************************/
182 167
183void 168void acpi_ut_strupr(char *src_string)
184acpi_ut_strupr (
185 char *src_string)
186{ 169{
187 char *string; 170 char *string;
188
189
190 ACPI_FUNCTION_ENTRY ();
191 171
172 ACPI_FUNCTION_ENTRY();
192 173
193 if (!src_string) { 174 if (!src_string) {
194 return; 175 return;
@@ -197,13 +178,12 @@ acpi_ut_strupr (
197 /* Walk entire string, uppercasing the letters */ 178 /* Walk entire string, uppercasing the letters */
198 179
199 for (string = src_string; *string; string++) { 180 for (string = src_string; *string; string++) {
200 *string = (char) ACPI_TOUPPER (*string); 181 *string = (char)ACPI_TOUPPER(*string);
201 } 182 }
202 183
203 return; 184 return;
204} 185}
205 186
206
207/******************************************************************************* 187/*******************************************************************************
208 * 188 *
209 * FUNCTION: acpi_ut_print_string 189 * FUNCTION: acpi_ut_print_string
@@ -218,85 +198,77 @@ acpi_ut_strupr (
218 * 198 *
219 ******************************************************************************/ 199 ******************************************************************************/
220 200
221void 201void acpi_ut_print_string(char *string, u8 max_length)
222acpi_ut_print_string (
223 char *string,
224 u8 max_length)
225{ 202{
226 u32 i; 203 u32 i;
227
228 204
229 if (!string) { 205 if (!string) {
230 acpi_os_printf ("<\"NULL STRING PTR\">"); 206 acpi_os_printf("<\"NULL STRING PTR\">");
231 return; 207 return;
232 } 208 }
233 209
234 acpi_os_printf ("\""); 210 acpi_os_printf("\"");
235 for (i = 0; string[i] && (i < max_length); i++) { 211 for (i = 0; string[i] && (i < max_length); i++) {
236 /* Escape sequences */ 212 /* Escape sequences */
237 213
238 switch (string[i]) { 214 switch (string[i]) {
239 case 0x07: 215 case 0x07:
240 acpi_os_printf ("\\a"); /* BELL */ 216 acpi_os_printf("\\a"); /* BELL */
241 break; 217 break;
242 218
243 case 0x08: 219 case 0x08:
244 acpi_os_printf ("\\b"); /* BACKSPACE */ 220 acpi_os_printf("\\b"); /* BACKSPACE */
245 break; 221 break;
246 222
247 case 0x0C: 223 case 0x0C:
248 acpi_os_printf ("\\f"); /* FORMFEED */ 224 acpi_os_printf("\\f"); /* FORMFEED */
249 break; 225 break;
250 226
251 case 0x0A: 227 case 0x0A:
252 acpi_os_printf ("\\n"); /* LINEFEED */ 228 acpi_os_printf("\\n"); /* LINEFEED */
253 break; 229 break;
254 230
255 case 0x0D: 231 case 0x0D:
256 acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ 232 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
257 break; 233 break;
258 234
259 case 0x09: 235 case 0x09:
260 acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ 236 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
261 break; 237 break;
262 238
263 case 0x0B: 239 case 0x0B:
264 acpi_os_printf ("\\v"); /* VERTICAL TAB */ 240 acpi_os_printf("\\v"); /* VERTICAL TAB */
265 break; 241 break;
266 242
267 case '\'': /* Single Quote */ 243 case '\'': /* Single Quote */
268 case '\"': /* Double Quote */ 244 case '\"': /* Double Quote */
269 case '\\': /* Backslash */ 245 case '\\': /* Backslash */
270 acpi_os_printf ("\\%c", (int) string[i]); 246 acpi_os_printf("\\%c", (int)string[i]);
271 break; 247 break;
272 248
273 default: 249 default:
274 250
275 /* Check for printable character or hex escape */ 251 /* Check for printable character or hex escape */
276 252
277 if (ACPI_IS_PRINT (string[i])) 253 if (ACPI_IS_PRINT(string[i])) {
278 {
279 /* This is a normal character */ 254 /* This is a normal character */
280 255
281 acpi_os_printf ("%c", (int) string[i]); 256 acpi_os_printf("%c", (int)string[i]);
282 } 257 } else {
283 else
284 {
285 /* All others will be Hex escapes */ 258 /* All others will be Hex escapes */
286 259
287 acpi_os_printf ("\\x%2.2X", (s32) string[i]); 260 acpi_os_printf("\\x%2.2X", (s32) string[i]);
288 } 261 }
289 break; 262 break;
290 } 263 }
291 } 264 }
292 acpi_os_printf ("\""); 265 acpi_os_printf("\"");
293 266
294 if (i == max_length && string[i]) { 267 if (i == max_length && string[i]) {
295 acpi_os_printf ("..."); 268 acpi_os_printf("...");
296 } 269 }
297} 270}
298 271
299
300/******************************************************************************* 272/*******************************************************************************
301 * 273 *
302 * FUNCTION: acpi_ut_dword_byte_swap 274 * FUNCTION: acpi_ut_dword_byte_swap
@@ -309,22 +281,18 @@ acpi_ut_print_string (
309 * 281 *
310 ******************************************************************************/ 282 ******************************************************************************/
311 283
312u32 284u32 acpi_ut_dword_byte_swap(u32 value)
313acpi_ut_dword_byte_swap (
314 u32 value)
315{ 285{
316 union { 286 union {
317 u32 value; 287 u32 value;
318 u8 bytes[4]; 288 u8 bytes[4];
319 } out; 289 } out;
320 union { 290 union {
321 u32 value; 291 u32 value;
322 u8 bytes[4]; 292 u8 bytes[4];
323 } in; 293 } in;
324 294
325 295 ACPI_FUNCTION_ENTRY();
326 ACPI_FUNCTION_ENTRY ();
327
328 296
329 in.value = value; 297 in.value = value;
330 298
@@ -336,7 +304,6 @@ acpi_ut_dword_byte_swap (
336 return (out.value); 304 return (out.value);
337} 305}
338 306
339
340/******************************************************************************* 307/*******************************************************************************
341 * 308 *
342 * FUNCTION: acpi_ut_set_integer_width 309 * FUNCTION: acpi_ut_set_integer_width
@@ -352,24 +319,20 @@ acpi_ut_dword_byte_swap (
352 * 319 *
353 ******************************************************************************/ 320 ******************************************************************************/
354 321
355void 322void acpi_ut_set_integer_width(u8 revision)
356acpi_ut_set_integer_width (
357 u8 revision)
358{ 323{
359 324
360 if (revision <= 1) { 325 if (revision <= 1) {
361 acpi_gbl_integer_bit_width = 32; 326 acpi_gbl_integer_bit_width = 32;
362 acpi_gbl_integer_nybble_width = 8; 327 acpi_gbl_integer_nybble_width = 8;
363 acpi_gbl_integer_byte_width = 4; 328 acpi_gbl_integer_byte_width = 4;
364 } 329 } else {
365 else {
366 acpi_gbl_integer_bit_width = 64; 330 acpi_gbl_integer_bit_width = 64;
367 acpi_gbl_integer_nybble_width = 16; 331 acpi_gbl_integer_nybble_width = 16;
368 acpi_gbl_integer_byte_width = 8; 332 acpi_gbl_integer_byte_width = 8;
369 } 333 }
370} 334}
371 335
372
373#ifdef ACPI_DEBUG_OUTPUT 336#ifdef ACPI_DEBUG_OUTPUT
374/******************************************************************************* 337/*******************************************************************************
375 * 338 *
@@ -387,17 +350,14 @@ acpi_ut_set_integer_width (
387 ******************************************************************************/ 350 ******************************************************************************/
388 351
389void 352void
390acpi_ut_display_init_pathname ( 353acpi_ut_display_init_pathname(u8 type,
391 u8 type, 354 struct acpi_namespace_node *obj_handle,
392 struct acpi_namespace_node *obj_handle, 355 char *path)
393 char *path)
394{ 356{
395 acpi_status status; 357 acpi_status status;
396 struct acpi_buffer buffer; 358 struct acpi_buffer buffer;
397
398
399 ACPI_FUNCTION_ENTRY ();
400 359
360 ACPI_FUNCTION_ENTRY();
401 361
402 /* Only print the path if the appropriate debug level is enabled */ 362 /* Only print the path if the appropriate debug level is enabled */
403 363
@@ -408,8 +368,8 @@ acpi_ut_display_init_pathname (
408 /* Get the full pathname to the node */ 368 /* Get the full pathname to the node */
409 369
410 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 370 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
411 status = acpi_ns_handle_to_pathname (obj_handle, &buffer); 371 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
412 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
413 return; 373 return;
414 } 374 }
415 375
@@ -417,31 +377,30 @@ acpi_ut_display_init_pathname (
417 377
418 switch (type) { 378 switch (type) {
419 case ACPI_TYPE_METHOD: 379 case ACPI_TYPE_METHOD:
420 acpi_os_printf ("Executing "); 380 acpi_os_printf("Executing ");
421 break; 381 break;
422 382
423 default: 383 default:
424 acpi_os_printf ("Initializing "); 384 acpi_os_printf("Initializing ");
425 break; 385 break;
426 } 386 }
427 387
428 /* Print the object type and pathname */ 388 /* Print the object type and pathname */
429 389
430 acpi_os_printf ("%-12s %s", 390 acpi_os_printf("%-12s %s",
431 acpi_ut_get_type_name (type), (char *) buffer.pointer); 391 acpi_ut_get_type_name(type), (char *)buffer.pointer);
432 392
433 /* Extra path is used to append names like _STA, _INI, etc. */ 393 /* Extra path is used to append names like _STA, _INI, etc. */
434 394
435 if (path) { 395 if (path) {
436 acpi_os_printf (".%s", path); 396 acpi_os_printf(".%s", path);
437 } 397 }
438 acpi_os_printf ("\n"); 398 acpi_os_printf("\n");
439 399
440 ACPI_MEM_FREE (buffer.pointer); 400 ACPI_MEM_FREE(buffer.pointer);
441} 401}
442#endif 402#endif
443 403
444
445/******************************************************************************* 404/*******************************************************************************
446 * 405 *
447 * FUNCTION: acpi_ut_valid_acpi_name 406 * FUNCTION: acpi_ut_valid_acpi_name
@@ -457,25 +416,21 @@ acpi_ut_display_init_pathname (
457 * 416 *
458 ******************************************************************************/ 417 ******************************************************************************/
459 418
460u8 419u8 acpi_ut_valid_acpi_name(u32 name)
461acpi_ut_valid_acpi_name (
462 u32 name)
463{ 420{
464 char *name_ptr = (char *) &name; 421 char *name_ptr = (char *)&name;
465 char character; 422 char character;
466 acpi_native_uint i; 423 acpi_native_uint i;
467
468
469 ACPI_FUNCTION_ENTRY ();
470 424
425 ACPI_FUNCTION_ENTRY();
471 426
472 for (i = 0; i < ACPI_NAME_SIZE; i++) { 427 for (i = 0; i < ACPI_NAME_SIZE; i++) {
473 character = *name_ptr; 428 character = *name_ptr;
474 name_ptr++; 429 name_ptr++;
475 430
476 if (!((character == '_') || 431 if (!((character == '_') ||
477 (character >= 'A' && character <= 'Z') || 432 (character >= 'A' && character <= 'Z') ||
478 (character >= '0' && character <= '9'))) { 433 (character >= '0' && character <= '9'))) {
479 return (FALSE); 434 return (FALSE);
480 } 435 }
481 } 436 }
@@ -483,7 +438,6 @@ acpi_ut_valid_acpi_name (
483 return (TRUE); 438 return (TRUE);
484} 439}
485 440
486
487/******************************************************************************* 441/*******************************************************************************
488 * 442 *
489 * FUNCTION: acpi_ut_valid_acpi_character 443 * FUNCTION: acpi_ut_valid_acpi_character
@@ -496,19 +450,16 @@ acpi_ut_valid_acpi_name (
496 * 450 *
497 ******************************************************************************/ 451 ******************************************************************************/
498 452
499u8 453u8 acpi_ut_valid_acpi_character(char character)
500acpi_ut_valid_acpi_character (
501 char character)
502{ 454{
503 455
504 ACPI_FUNCTION_ENTRY (); 456 ACPI_FUNCTION_ENTRY();
505 457
506 return ((u8) ((character == '_') || 458 return ((u8) ((character == '_') ||
507 (character >= 'A' && character <= 'Z') || 459 (character >= 'A' && character <= 'Z') ||
508 (character >= '0' && character <= '9'))); 460 (character >= '0' && character <= '9')));
509} 461}
510 462
511
512/******************************************************************************* 463/*******************************************************************************
513 * 464 *
514 * FUNCTION: acpi_ut_strtoul64 465 * FUNCTION: acpi_ut_strtoul64
@@ -525,18 +476,13 @@ acpi_ut_valid_acpi_character (
525 ******************************************************************************/ 476 ******************************************************************************/
526 477
527acpi_status 478acpi_status
528acpi_ut_strtoul64 ( 479acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
529 char *string,
530 u32 base,
531 acpi_integer *ret_integer)
532{ 480{
533 u32 this_digit = 0; 481 u32 this_digit = 0;
534 acpi_integer return_value = 0; 482 acpi_integer return_value = 0;
535 acpi_integer quotient; 483 acpi_integer quotient;
536
537
538 ACPI_FUNCTION_TRACE ("ut_stroul64");
539 484
485 ACPI_FUNCTION_TRACE("ut_stroul64");
540 486
541 if ((!string) || !(*string)) { 487 if ((!string) || !(*string)) {
542 goto error_exit; 488 goto error_exit;
@@ -550,12 +496,12 @@ acpi_ut_strtoul64 (
550 496
551 default: 497 default:
552 /* Invalid Base */ 498 /* Invalid Base */
553 return_ACPI_STATUS (AE_BAD_PARAMETER); 499 return_ACPI_STATUS(AE_BAD_PARAMETER);
554 } 500 }
555 501
556 /* Skip over any white space in the buffer */ 502 /* Skip over any white space in the buffer */
557 503
558 while (ACPI_IS_SPACE (*string) || *string == '\t') { 504 while (ACPI_IS_SPACE(*string) || *string == '\t') {
559 string++; 505 string++;
560 } 506 }
561 507
@@ -564,12 +510,10 @@ acpi_ut_strtoul64 (
564 * determine if it is decimal or hexadecimal: 510 * determine if it is decimal or hexadecimal:
565 */ 511 */
566 if (base == 0) { 512 if (base == 0) {
567 if ((*string == '0') && 513 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
568 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
569 base = 16; 514 base = 16;
570 string += 2; 515 string += 2;
571 } 516 } else {
572 else {
573 base = 10; 517 base = 10;
574 } 518 }
575 } 519 }
@@ -579,8 +523,7 @@ acpi_ut_strtoul64 (
579 * 0 or 0x, if they are present. 523 * 0 or 0x, if they are present.
580 */ 524 */
581 if ((base == 16) && 525 if ((base == 16) &&
582 (*string == '0') && 526 (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
583 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
584 string += 2; 527 string += 2;
585 } 528 }
586 529
@@ -593,25 +536,23 @@ acpi_ut_strtoul64 (
593 /* Main loop: convert the string to a 64-bit integer */ 536 /* Main loop: convert the string to a 64-bit integer */
594 537
595 while (*string) { 538 while (*string) {
596 if (ACPI_IS_DIGIT (*string)) { 539 if (ACPI_IS_DIGIT(*string)) {
597 /* Convert ASCII 0-9 to Decimal value */ 540 /* Convert ASCII 0-9 to Decimal value */
598 541
599 this_digit = ((u8) *string) - '0'; 542 this_digit = ((u8) * string) - '0';
600 } 543 } else {
601 else {
602 if (base == 10) { 544 if (base == 10) {
603 /* Digit is out of range */ 545 /* Digit is out of range */
604 546
605 goto error_exit; 547 goto error_exit;
606 } 548 }
607 549
608 this_digit = (u8) ACPI_TOUPPER (*string); 550 this_digit = (u8) ACPI_TOUPPER(*string);
609 if (ACPI_IS_XDIGIT ((char) this_digit)) { 551 if (ACPI_IS_XDIGIT((char)this_digit)) {
610 /* Convert ASCII Hex char to value */ 552 /* Convert ASCII Hex char to value */
611 553
612 this_digit = this_digit - 'A' + 10; 554 this_digit = this_digit - 'A' + 10;
613 } 555 } else {
614 else {
615 /* 556 /*
616 * We allow non-hex chars, just stop now, same as end-of-string. 557 * We allow non-hex chars, just stop now, same as end-of-string.
617 * See ACPI spec, string-to-integer conversion. 558 * See ACPI spec, string-to-integer conversion.
@@ -622,8 +563,10 @@ acpi_ut_strtoul64 (
622 563
623 /* Divide the digit into the correct position */ 564 /* Divide the digit into the correct position */
624 565
625 (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), 566 (void)
626 base, &quotient, NULL); 567 acpi_ut_short_divide((ACPI_INTEGER_MAX -
568 (acpi_integer) this_digit), base,
569 &quotient, NULL);
627 if (return_value > quotient) { 570 if (return_value > quotient) {
628 goto error_exit; 571 goto error_exit;
629 } 572 }
@@ -636,21 +579,18 @@ acpi_ut_strtoul64 (
636 /* All done, normal exit */ 579 /* All done, normal exit */
637 580
638 *ret_integer = return_value; 581 *ret_integer = return_value;
639 return_ACPI_STATUS (AE_OK); 582 return_ACPI_STATUS(AE_OK);
640 583
641 584 error_exit:
642error_exit:
643 /* Base was set/validated above */ 585 /* Base was set/validated above */
644 586
645 if (base == 10) { 587 if (base == 10) {
646 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); 588 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
647 } 589 } else {
648 else { 590 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
649 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
650 } 591 }
651} 592}
652 593
653
654/******************************************************************************* 594/*******************************************************************************
655 * 595 *
656 * FUNCTION: acpi_ut_create_update_state_and_push 596 * FUNCTION: acpi_ut_create_update_state_and_push
@@ -666,16 +606,13 @@ error_exit:
666 ******************************************************************************/ 606 ******************************************************************************/
667 607
668acpi_status 608acpi_status
669acpi_ut_create_update_state_and_push ( 609acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
670 union acpi_operand_object *object, 610 u16 action,
671 u16 action, 611 union acpi_generic_state **state_list)
672 union acpi_generic_state **state_list)
673{ 612{
674 union acpi_generic_state *state; 613 union acpi_generic_state *state;
675
676
677 ACPI_FUNCTION_ENTRY ();
678 614
615 ACPI_FUNCTION_ENTRY();
679 616
680 /* Ignore null objects; these are expected */ 617 /* Ignore null objects; these are expected */
681 618
@@ -683,16 +620,15 @@ acpi_ut_create_update_state_and_push (
683 return (AE_OK); 620 return (AE_OK);
684 } 621 }
685 622
686 state = acpi_ut_create_update_state (object, action); 623 state = acpi_ut_create_update_state(object, action);
687 if (!state) { 624 if (!state) {
688 return (AE_NO_MEMORY); 625 return (AE_NO_MEMORY);
689 } 626 }
690 627
691 acpi_ut_push_generic_state (state_list, state); 628 acpi_ut_push_generic_state(state_list, state);
692 return (AE_OK); 629 return (AE_OK);
693} 630}
694 631
695
696/******************************************************************************* 632/*******************************************************************************
697 * 633 *
698 * FUNCTION: acpi_ut_walk_package_tree 634 * FUNCTION: acpi_ut_walk_package_tree
@@ -709,33 +645,29 @@ acpi_ut_create_update_state_and_push (
709 ******************************************************************************/ 645 ******************************************************************************/
710 646
711acpi_status 647acpi_status
712acpi_ut_walk_package_tree ( 648acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
713 union acpi_operand_object *source_object, 649 void *target_object,
714 void *target_object, 650 acpi_pkg_callback walk_callback, void *context)
715 acpi_pkg_callback walk_callback,
716 void *context)
717{ 651{
718 acpi_status status = AE_OK; 652 acpi_status status = AE_OK;
719 union acpi_generic_state *state_list = NULL; 653 union acpi_generic_state *state_list = NULL;
720 union acpi_generic_state *state; 654 union acpi_generic_state *state;
721 u32 this_index; 655 u32 this_index;
722 union acpi_operand_object *this_source_obj; 656 union acpi_operand_object *this_source_obj;
723
724 657
725 ACPI_FUNCTION_TRACE ("ut_walk_package_tree"); 658 ACPI_FUNCTION_TRACE("ut_walk_package_tree");
726 659
727 660 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
728 state = acpi_ut_create_pkg_state (source_object, target_object, 0);
729 if (!state) { 661 if (!state) {
730 return_ACPI_STATUS (AE_NO_MEMORY); 662 return_ACPI_STATUS(AE_NO_MEMORY);
731 } 663 }
732 664
733 while (state) { 665 while (state) {
734 /* Get one element of the package */ 666 /* Get one element of the package */
735 667
736 this_index = state->pkg.index; 668 this_index = state->pkg.index;
737 this_source_obj = (union acpi_operand_object *) 669 this_source_obj = (union acpi_operand_object *)
738 state->pkg.source_object->package.elements[this_index]; 670 state->pkg.source_object->package.elements[this_index];
739 671
740 /* 672 /*
741 * Check for: 673 * Check for:
@@ -746,16 +678,20 @@ acpi_ut_walk_package_tree (
746 * case below. 678 * case below.
747 */ 679 */
748 if ((!this_source_obj) || 680 if ((!this_source_obj) ||
749 (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || 681 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
750 (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { 682 ACPI_DESC_TYPE_OPERAND)
751 status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, 683 || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
752 state, context); 684 ACPI_TYPE_PACKAGE)) {
753 if (ACPI_FAILURE (status)) { 685 status =
754 return_ACPI_STATUS (status); 686 walk_callback(ACPI_COPY_TYPE_SIMPLE,
687 this_source_obj, state, context);
688 if (ACPI_FAILURE(status)) {
689 return_ACPI_STATUS(status);
755 } 690 }
756 691
757 state->pkg.index++; 692 state->pkg.index++;
758 while (state->pkg.index >= state->pkg.source_object->package.count) { 693 while (state->pkg.index >=
694 state->pkg.source_object->package.count) {
759 /* 695 /*
760 * We've handled all of the objects at this level, This means 696 * We've handled all of the objects at this level, This means
761 * that we have just completed a package. That package may 697 * that we have just completed a package. That package may
@@ -763,8 +699,8 @@ acpi_ut_walk_package_tree (
763 * 699 *
764 * Delete this state and pop the previous state (package). 700 * Delete this state and pop the previous state (package).
765 */ 701 */
766 acpi_ut_delete_generic_state (state); 702 acpi_ut_delete_generic_state(state);
767 state = acpi_ut_pop_generic_state (&state_list); 703 state = acpi_ut_pop_generic_state(&state_list);
768 704
769 /* Finished when there are no more states */ 705 /* Finished when there are no more states */
770 706
@@ -774,7 +710,7 @@ acpi_ut_walk_package_tree (
774 * package just add the length of the package objects 710 * package just add the length of the package objects
775 * and exit 711 * and exit
776 */ 712 */
777 return_ACPI_STATUS (AE_OK); 713 return_ACPI_STATUS(AE_OK);
778 } 714 }
779 715
780 /* 716 /*
@@ -783,35 +719,35 @@ acpi_ut_walk_package_tree (
783 */ 719 */
784 state->pkg.index++; 720 state->pkg.index++;
785 } 721 }
786 } 722 } else {
787 else {
788 /* This is a subobject of type package */ 723 /* This is a subobject of type package */
789 724
790 status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, 725 status =
791 state, context); 726 walk_callback(ACPI_COPY_TYPE_PACKAGE,
792 if (ACPI_FAILURE (status)) { 727 this_source_obj, state, context);
793 return_ACPI_STATUS (status); 728 if (ACPI_FAILURE(status)) {
729 return_ACPI_STATUS(status);
794 } 730 }
795 731
796 /* 732 /*
797 * Push the current state and create a new one 733 * Push the current state and create a new one
798 * The callback above returned a new target package object. 734 * The callback above returned a new target package object.
799 */ 735 */
800 acpi_ut_push_generic_state (&state_list, state); 736 acpi_ut_push_generic_state(&state_list, state);
801 state = acpi_ut_create_pkg_state (this_source_obj, 737 state = acpi_ut_create_pkg_state(this_source_obj,
802 state->pkg.this_target_obj, 0); 738 state->pkg.
739 this_target_obj, 0);
803 if (!state) { 740 if (!state) {
804 return_ACPI_STATUS (AE_NO_MEMORY); 741 return_ACPI_STATUS(AE_NO_MEMORY);
805 } 742 }
806 } 743 }
807 } 744 }
808 745
809 /* We should never get here */ 746 /* We should never get here */
810 747
811 return_ACPI_STATUS (AE_AML_INTERNAL); 748 return_ACPI_STATUS(AE_AML_INTERNAL);
812} 749}
813 750
814
815/******************************************************************************* 751/*******************************************************************************
816 * 752 *
817 * FUNCTION: acpi_ut_generate_checksum 753 * FUNCTION: acpi_ut_generate_checksum
@@ -825,23 +761,18 @@ acpi_ut_walk_package_tree (
825 * 761 *
826 ******************************************************************************/ 762 ******************************************************************************/
827 763
828u8 764u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
829acpi_ut_generate_checksum (
830 u8 *buffer,
831 u32 length)
832{ 765{
833 u32 i; 766 u32 i;
834 signed char sum = 0; 767 signed char sum = 0;
835
836 768
837 for (i = 0; i < length; i++) { 769 for (i = 0; i < length; i++) {
838 sum = (signed char) (sum + buffer[i]); 770 sum = (signed char)(sum + buffer[i]);
839 } 771 }
840 772
841 return ((u8) (0 - sum)); 773 return ((u8) (0 - sum));
842} 774}
843 775
844
845/******************************************************************************* 776/*******************************************************************************
846 * 777 *
847 * FUNCTION: acpi_ut_get_resource_end_tag 778 * FUNCTION: acpi_ut_get_resource_end_tag
@@ -854,17 +785,13 @@ acpi_ut_generate_checksum (
854 * 785 *
855 ******************************************************************************/ 786 ******************************************************************************/
856 787
857 788u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
858u8 *
859acpi_ut_get_resource_end_tag (
860 union acpi_operand_object *obj_desc)
861{ 789{
862 u8 buffer_byte; 790 u8 buffer_byte;
863 u8 *buffer; 791 u8 *buffer;
864 u8 *end_buffer; 792 u8 *end_buffer;
865 793
866 794 buffer = obj_desc->buffer.pointer;
867 buffer = obj_desc->buffer.pointer;
868 end_buffer = buffer + obj_desc->buffer.length; 795 end_buffer = buffer + obj_desc->buffer.length;
869 796
870 while (buffer < end_buffer) { 797 while (buffer < end_buffer) {
@@ -872,12 +799,12 @@ acpi_ut_get_resource_end_tag (
872 if (buffer_byte & ACPI_RDESC_TYPE_MASK) { 799 if (buffer_byte & ACPI_RDESC_TYPE_MASK) {
873 /* Large Descriptor - Length is next 2 bytes */ 800 /* Large Descriptor - Length is next 2 bytes */
874 801
875 buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); 802 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3);
876 } 803 } else {
877 else {
878 /* Small Descriptor. End Tag will be found here */ 804 /* Small Descriptor. End Tag will be found here */
879 805
880 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { 806 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) ==
807 ACPI_RDESC_TYPE_END_TAG) {
881 /* Found the end tag descriptor, all done. */ 808 /* Found the end tag descriptor, all done. */
882 809
883 return (buffer); 810 return (buffer);
@@ -894,7 +821,6 @@ acpi_ut_get_resource_end_tag (
894 return (NULL); 821 return (NULL);
895} 822}
896 823
897
898/******************************************************************************* 824/*******************************************************************************
899 * 825 *
900 * FUNCTION: acpi_ut_report_error 826 * FUNCTION: acpi_ut_report_error
@@ -909,17 +835,12 @@ acpi_ut_get_resource_end_tag (
909 * 835 *
910 ******************************************************************************/ 836 ******************************************************************************/
911 837
912void 838void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id)
913acpi_ut_report_error (
914 char *module_name,
915 u32 line_number,
916 u32 component_id)
917{ 839{
918 840
919 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 841 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
920} 842}
921 843
922
923/******************************************************************************* 844/*******************************************************************************
924 * 845 *
925 * FUNCTION: acpi_ut_report_warning 846 * FUNCTION: acpi_ut_report_warning
@@ -935,16 +856,12 @@ acpi_ut_report_error (
935 ******************************************************************************/ 856 ******************************************************************************/
936 857
937void 858void
938acpi_ut_report_warning ( 859acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
939 char *module_name,
940 u32 line_number,
941 u32 component_id)
942{ 860{
943 861
944 acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); 862 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number);
945} 863}
946 864
947
948/******************************************************************************* 865/*******************************************************************************
949 * 866 *
950 * FUNCTION: acpi_ut_report_info 867 * FUNCTION: acpi_ut_report_info
@@ -959,14 +876,8 @@ acpi_ut_report_warning (
959 * 876 *
960 ******************************************************************************/ 877 ******************************************************************************/
961 878
962void 879void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
963acpi_ut_report_info (
964 char *module_name,
965 u32 line_number,
966 u32 component_id)
967{ 880{
968 881
969 acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); 882 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number);
970} 883}
971
972
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 0699b6be62b6..90134c56ece9 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -41,22 +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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utmutex") 47ACPI_MODULE_NAME("utmutex")
49 48
50/* Local prototypes */ 49/* Local prototypes */
50static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
51 51
52static acpi_status 52static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
53acpi_ut_create_mutex (
54 acpi_mutex_handle mutex_id);
55
56static acpi_status
57acpi_ut_delete_mutex (
58 acpi_mutex_handle mutex_id);
59
60 53
61/******************************************************************************* 54/*******************************************************************************
62 * 55 *
@@ -70,32 +63,27 @@ acpi_ut_delete_mutex (
70 * 63 *
71 ******************************************************************************/ 64 ******************************************************************************/
72 65
73acpi_status 66acpi_status acpi_ut_mutex_initialize(void)
74acpi_ut_mutex_initialize (
75 void)
76{ 67{
77 u32 i; 68 u32 i;
78 acpi_status status; 69 acpi_status status;
79
80
81 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
82 70
71 ACPI_FUNCTION_TRACE("ut_mutex_initialize");
83 72
84 /* 73 /*
85 * Create each of the predefined mutex objects 74 * Create each of the predefined mutex objects
86 */ 75 */
87 for (i = 0; i < NUM_MUTEX; i++) { 76 for (i = 0; i < NUM_MUTEX; i++) {
88 status = acpi_ut_create_mutex (i); 77 status = acpi_ut_create_mutex(i);
89 if (ACPI_FAILURE (status)) { 78 if (ACPI_FAILURE(status)) {
90 return_ACPI_STATUS (status); 79 return_ACPI_STATUS(status);
91 } 80 }
92 } 81 }
93 82
94 status = acpi_os_create_lock (&acpi_gbl_gpe_lock); 83 status = acpi_os_create_lock(&acpi_gbl_gpe_lock);
95 return_ACPI_STATUS (status); 84 return_ACPI_STATUS(status);
96} 85}
97 86
98
99/******************************************************************************* 87/*******************************************************************************
100 * 88 *
101 * FUNCTION: acpi_ut_mutex_terminate 89 * FUNCTION: acpi_ut_mutex_terminate
@@ -108,28 +96,23 @@ acpi_ut_mutex_initialize (
108 * 96 *
109 ******************************************************************************/ 97 ******************************************************************************/
110 98
111void 99void acpi_ut_mutex_terminate(void)
112acpi_ut_mutex_terminate (
113 void)
114{ 100{
115 u32 i; 101 u32 i;
116
117
118 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
119 102
103 ACPI_FUNCTION_TRACE("ut_mutex_terminate");
120 104
121 /* 105 /*
122 * Delete each predefined mutex object 106 * Delete each predefined mutex object
123 */ 107 */
124 for (i = 0; i < NUM_MUTEX; i++) { 108 for (i = 0; i < NUM_MUTEX; i++) {
125 (void) acpi_ut_delete_mutex (i); 109 (void)acpi_ut_delete_mutex(i);
126 } 110 }
127 111
128 acpi_os_delete_lock (acpi_gbl_gpe_lock); 112 acpi_os_delete_lock(acpi_gbl_gpe_lock);
129 return_VOID; 113 return_VOID;
130} 114}
131 115
132
133/******************************************************************************* 116/*******************************************************************************
134 * 117 *
135 * FUNCTION: acpi_ut_create_mutex 118 * FUNCTION: acpi_ut_create_mutex
@@ -142,31 +125,28 @@ acpi_ut_mutex_terminate (
142 * 125 *
143 ******************************************************************************/ 126 ******************************************************************************/
144 127
145static acpi_status 128static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146acpi_ut_create_mutex (
147 acpi_mutex_handle mutex_id)
148{ 129{
149 acpi_status status = AE_OK; 130 acpi_status status = AE_OK;
150
151
152 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
153 131
132 ACPI_FUNCTION_TRACE_U32("ut_create_mutex", mutex_id);
154 133
155 if (mutex_id > MAX_MUTEX) { 134 if (mutex_id > MAX_MUTEX) {
156 return_ACPI_STATUS (AE_BAD_PARAMETER); 135 return_ACPI_STATUS(AE_BAD_PARAMETER);
157 } 136 }
158 137
159 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 138 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
160 status = acpi_os_create_semaphore (1, 1, 139 status = acpi_os_create_semaphore(1, 1,
161 &acpi_gbl_mutex_info[mutex_id].mutex); 140 &acpi_gbl_mutex_info
162 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 141 [mutex_id].mutex);
142 acpi_gbl_mutex_info[mutex_id].thread_id =
143 ACPI_MUTEX_NOT_ACQUIRED;
163 acpi_gbl_mutex_info[mutex_id].use_count = 0; 144 acpi_gbl_mutex_info[mutex_id].use_count = 0;
164 } 145 }
165 146
166 return_ACPI_STATUS (status); 147 return_ACPI_STATUS(status);
167} 148}
168 149
169
170/******************************************************************************* 150/*******************************************************************************
171 * 151 *
172 * FUNCTION: acpi_ut_delete_mutex 152 * FUNCTION: acpi_ut_delete_mutex
@@ -179,29 +159,24 @@ acpi_ut_create_mutex (
179 * 159 *
180 ******************************************************************************/ 160 ******************************************************************************/
181 161
182static acpi_status 162static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
183acpi_ut_delete_mutex (
184 acpi_mutex_handle mutex_id)
185{ 163{
186 acpi_status status; 164 acpi_status status;
187
188
189 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
190 165
166 ACPI_FUNCTION_TRACE_U32("ut_delete_mutex", mutex_id);
191 167
192 if (mutex_id > MAX_MUTEX) { 168 if (mutex_id > MAX_MUTEX) {
193 return_ACPI_STATUS (AE_BAD_PARAMETER); 169 return_ACPI_STATUS(AE_BAD_PARAMETER);
194 } 170 }
195 171
196 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); 172 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);
197 173
198 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 174 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
199 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 175 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
200 176
201 return_ACPI_STATUS (status); 177 return_ACPI_STATUS(status);
202} 178}
203 179
204
205/******************************************************************************* 180/*******************************************************************************
206 * 181 *
207 * FUNCTION: acpi_ut_acquire_mutex 182 * FUNCTION: acpi_ut_acquire_mutex
@@ -214,26 +189,22 @@ acpi_ut_delete_mutex (
214 * 189 *
215 ******************************************************************************/ 190 ******************************************************************************/
216 191
217acpi_status 192acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
218acpi_ut_acquire_mutex (
219 acpi_mutex_handle mutex_id)
220{ 193{
221 acpi_status status; 194 acpi_status status;
222 u32 this_thread_id; 195 u32 this_thread_id;
223
224
225 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
226 196
197 ACPI_FUNCTION_NAME("ut_acquire_mutex");
227 198
228 if (mutex_id > MAX_MUTEX) { 199 if (mutex_id > MAX_MUTEX) {
229 return (AE_BAD_PARAMETER); 200 return (AE_BAD_PARAMETER);
230 } 201 }
231 202
232 this_thread_id = acpi_os_get_thread_id (); 203 this_thread_id = acpi_os_get_thread_id();
233 204
234#ifdef ACPI_MUTEX_DEBUG 205#ifdef ACPI_MUTEX_DEBUG
235 { 206 {
236 u32 i; 207 u32 i;
237 /* 208 /*
238 * Mutex debug code, for internal debugging only. 209 * Mutex debug code, for internal debugging only.
239 * 210 *
@@ -245,17 +216,21 @@ acpi_ut_acquire_mutex (
245 for (i = mutex_id; i < MAX_MUTEX; i++) { 216 for (i = mutex_id; i < MAX_MUTEX; i++) {
246 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
247 if (i == mutex_id) { 218 if (i == mutex_id) {
248 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
249 "Mutex [%s] already acquired by this thread [%X]\n", 220 "Mutex [%s] already acquired by this thread [%X]\n",
250 acpi_ut_get_mutex_name (mutex_id), this_thread_id)); 221 acpi_ut_get_mutex_name
222 (mutex_id),
223 this_thread_id));
251 224
252 return (AE_ALREADY_ACQUIRED); 225 return (AE_ALREADY_ACQUIRED);
253 } 226 }
254 227
255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
256 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
257 this_thread_id, acpi_ut_get_mutex_name (i), 230 this_thread_id,
258 acpi_ut_get_mutex_name (mutex_id))); 231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name
233 (mutex_id)));
259 234
260 return (AE_ACQUIRE_DEADLOCK); 235 return (AE_ACQUIRE_DEADLOCK);
261 } 236 }
@@ -263,30 +238,31 @@ acpi_ut_acquire_mutex (
263 } 238 }
264#endif 239#endif
265 240
266 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 241 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
267 "Thread %X attempting to acquire Mutex [%s]\n", 242 "Thread %X attempting to acquire Mutex [%s]\n",
268 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 243 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
269 244
270 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 245 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,
271 1, ACPI_WAIT_FOREVER); 246 1, ACPI_WAIT_FOREVER);
272 if (ACPI_SUCCESS (status)) { 247 if (ACPI_SUCCESS(status)) {
273 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 248 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
274 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 249 "Thread %X acquired Mutex [%s]\n",
250 this_thread_id,
251 acpi_ut_get_mutex_name(mutex_id)));
275 252
276 acpi_gbl_mutex_info[mutex_id].use_count++; 253 acpi_gbl_mutex_info[mutex_id].use_count++;
277 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
278 } 255 } else {
279 else { 256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
280 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 257 "Thread %X could not acquire Mutex [%s] %s\n",
281 "Thread %X could not acquire Mutex [%s] %s\n", 258 this_thread_id,
282 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 259 acpi_ut_get_mutex_name(mutex_id),
283 acpi_format_exception (status))); 260 acpi_format_exception(status)));
284 } 261 }
285 262
286 return (status); 263 return (status);
287} 264}
288 265
289
290/******************************************************************************* 266/*******************************************************************************
291 * 267 *
292 * FUNCTION: acpi_ut_release_mutex 268 * FUNCTION: acpi_ut_release_mutex
@@ -299,21 +275,17 @@ acpi_ut_acquire_mutex (
299 * 275 *
300 ******************************************************************************/ 276 ******************************************************************************/
301 277
302acpi_status 278acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
303acpi_ut_release_mutex (
304 acpi_mutex_handle mutex_id)
305{ 279{
306 acpi_status status; 280 acpi_status status;
307 u32 this_thread_id; 281 u32 this_thread_id;
308
309 282
310 ACPI_FUNCTION_NAME ("ut_release_mutex"); 283 ACPI_FUNCTION_NAME("ut_release_mutex");
311 284
312 285 this_thread_id = acpi_os_get_thread_id();
313 this_thread_id = acpi_os_get_thread_id (); 286 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
314 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 287 "Thread %X releasing Mutex [%s]\n", this_thread_id,
315 "Thread %X releasing Mutex [%s]\n", this_thread_id, 288 acpi_ut_get_mutex_name(mutex_id)));
316 acpi_ut_get_mutex_name (mutex_id)));
317 289
318 if (mutex_id > MAX_MUTEX) { 290 if (mutex_id > MAX_MUTEX) {
319 return (AE_BAD_PARAMETER); 291 return (AE_BAD_PARAMETER);
@@ -323,16 +295,15 @@ acpi_ut_release_mutex (
323 * Mutex must be acquired in order to release it! 295 * Mutex must be acquired in order to release it!
324 */ 296 */
325 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { 297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
326 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
327 "Mutex [%s] is not acquired, cannot release\n", 299 "Mutex [%s] is not acquired, cannot release\n",
328 acpi_ut_get_mutex_name (mutex_id))); 300 acpi_ut_get_mutex_name(mutex_id)));
329 301
330 return (AE_NOT_ACQUIRED); 302 return (AE_NOT_ACQUIRED);
331 } 303 }
332
333#ifdef ACPI_MUTEX_DEBUG 304#ifdef ACPI_MUTEX_DEBUG
334 { 305 {
335 u32 i; 306 u32 i;
336 /* 307 /*
337 * Mutex debug code, for internal debugging only. 308 * Mutex debug code, for internal debugging only.
338 * 309 *
@@ -347,9 +318,11 @@ acpi_ut_release_mutex (
347 continue; 318 continue;
348 } 319 }
349 320
350 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
351 "Invalid release order: owns [%s], releasing [%s]\n", 322 "Invalid release order: owns [%s], releasing [%s]\n",
352 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); 323 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name
325 (mutex_id)));
353 326
354 return (AE_RELEASE_DEADLOCK); 327 return (AE_RELEASE_DEADLOCK);
355 } 328 }
@@ -361,20 +334,21 @@ acpi_ut_release_mutex (
361 334
362 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
363 336
364 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); 337 status =
365 338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
366 if (ACPI_FAILURE (status)) { 339
367 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 340 if (ACPI_FAILURE(status)) {
368 "Thread %X could not release Mutex [%s] %s\n", 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 342 "Thread %X could not release Mutex [%s] %s\n",
370 acpi_format_exception (status))); 343 this_thread_id,
371 } 344 acpi_ut_get_mutex_name(mutex_id),
372 else { 345 acpi_format_exception(status)));
373 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", 346 } else {
374 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 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)));
375 } 351 }
376 352
377 return (status); 353 return (status);
378} 354}
379
380
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 19178e142951..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
337 308
338 ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); 309 ACPI_FUNCTION_TRACE("ut_allocate_object_desc_dbg");
339 310
340 311 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
341 object = acpi_os_acquire_object (acpi_gbl_operand_cache);
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 */
350 memset(object, 0, sizeof(union acpi_operand_object)); 320 memset(object, 0, sizeof(union acpi_operand_object));
351 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); 321 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND);
352 322
353 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", 323 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
354 object, (u32) sizeof (union acpi_operand_object))); 324 object, (u32) sizeof(union acpi_operand_object)));
355 325
356 return_PTR (object); 326 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,27 +338,23 @@ 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 (void) acpi_os_release_object (acpi_gbl_operand_cache, object); 354 (void)acpi_os_release_object(acpi_gbl_operand_cache, object);
389 return_VOID; 355 return_VOID;
390} 356}
391 357
392
393/******************************************************************************* 358/*******************************************************************************
394 * 359 *
395 * FUNCTION: acpi_ut_get_simple_object_size 360 * FUNCTION: acpi_ut_get_simple_object_size
@@ -408,16 +373,13 @@ acpi_ut_delete_object_desc (
408 ******************************************************************************/ 373 ******************************************************************************/
409 374
410static acpi_status 375static acpi_status
411acpi_ut_get_simple_object_size ( 376acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
412 union acpi_operand_object *internal_object, 377 acpi_size * obj_length)
413 acpi_size *obj_length)
414{ 378{
415 acpi_size length; 379 acpi_size length;
416 acpi_status status = AE_OK; 380 acpi_status status = AE_OK;
417
418
419 ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
420 381
382 ACPI_FUNCTION_TRACE_PTR("ut_get_simple_object_size", internal_object);
421 383
422 /* 384 /*
423 * Handle a null object (Could be a uninitialized package 385 * Handle a null object (Could be a uninitialized package
@@ -425,18 +387,18 @@ acpi_ut_get_simple_object_size (
425 */ 387 */
426 if (!internal_object) { 388 if (!internal_object) {
427 *obj_length = 0; 389 *obj_length = 0;
428 return_ACPI_STATUS (AE_OK); 390 return_ACPI_STATUS(AE_OK);
429 } 391 }
430 392
431 /* Start with the length of the Acpi object */ 393 /* Start with the length of the Acpi object */
432 394
433 length = sizeof (union acpi_object); 395 length = sizeof(union acpi_object);
434 396
435 if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) { 397 if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) {
436 /* Object is a named object (reference), just return the length */ 398 /* Object is a named object (reference), just return the length */
437 399
438 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 400 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
439 return_ACPI_STATUS (status); 401 return_ACPI_STATUS(status);
440 } 402 }
441 403
442 /* 404 /*
@@ -445,19 +407,17 @@ acpi_ut_get_simple_object_size (
445 * must be accessed bytewise or there may be alignment problems on 407 * must be accessed bytewise or there may be alignment problems on
446 * certain processors 408 * certain processors
447 */ 409 */
448 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 410 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
449 case ACPI_TYPE_STRING: 411 case ACPI_TYPE_STRING:
450 412
451 length += (acpi_size) internal_object->string.length + 1; 413 length += (acpi_size) internal_object->string.length + 1;
452 break; 414 break;
453 415
454
455 case ACPI_TYPE_BUFFER: 416 case ACPI_TYPE_BUFFER:
456 417
457 length += (acpi_size) internal_object->buffer.length; 418 length += (acpi_size) internal_object->buffer.length;
458 break; 419 break;
459 420
460
461 case ACPI_TYPE_INTEGER: 421 case ACPI_TYPE_INTEGER:
462 case ACPI_TYPE_PROCESSOR: 422 case ACPI_TYPE_PROCESSOR:
463 case ACPI_TYPE_POWER: 423 case ACPI_TYPE_POWER:
@@ -467,7 +427,6 @@ acpi_ut_get_simple_object_size (
467 */ 427 */
468 break; 428 break;
469 429
470
471 case ACPI_TYPE_LOCAL_REFERENCE: 430 case ACPI_TYPE_LOCAL_REFERENCE:
472 431
473 switch (internal_object->reference.opcode) { 432 switch (internal_object->reference.opcode) {
@@ -477,8 +436,10 @@ acpi_ut_get_simple_object_size (
477 * Get the actual length of the full pathname to this object. 436 * Get the actual length of the full pathname to this object.
478 * The reference will be converted to the pathname to the object 437 * The reference will be converted to the pathname to the object
479 */ 438 */
480 length += ACPI_ROUND_UP_TO_NATIVE_WORD ( 439 length +=
481 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));
482 break; 443 break;
483 444
484 default: 445 default:
@@ -488,19 +449,21 @@ acpi_ut_get_simple_object_size (
488 * Notably, Locals and Args are not supported, but this may be 449 * Notably, Locals and Args are not supported, but this may be
489 * required eventually. 450 * required eventually.
490 */ 451 */
491 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
492 "Unsupported Reference opcode=%X in object %p\n", 453 "Unsupported Reference opcode=%X in object %p\n",
493 internal_object->reference.opcode, internal_object)); 454 internal_object->reference.opcode,
455 internal_object));
494 status = AE_TYPE; 456 status = AE_TYPE;
495 break; 457 break;
496 } 458 }
497 break; 459 break;
498 460
499
500 default: 461 default:
501 462
502 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", 463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
503 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));
504 status = AE_TYPE; 467 status = AE_TYPE;
505 break; 468 break;
506 } 469 }
@@ -511,11 +474,10 @@ acpi_ut_get_simple_object_size (
511 * on a machine word boundary. (preventing alignment faults on some 474 * on a machine word boundary. (preventing alignment faults on some
512 * machines.) 475 * machines.)
513 */ 476 */
514 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 477 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
515 return_ACPI_STATUS (status); 478 return_ACPI_STATUS(status);
516} 479}
517 480
518
519/******************************************************************************* 481/*******************************************************************************
520 * 482 *
521 * FUNCTION: acpi_ut_get_element_length 483 * FUNCTION: acpi_ut_get_element_length
@@ -529,16 +491,13 @@ acpi_ut_get_simple_object_size (
529 ******************************************************************************/ 491 ******************************************************************************/
530 492
531static acpi_status 493static acpi_status
532acpi_ut_get_element_length ( 494acpi_ut_get_element_length(u8 object_type,
533 u8 object_type, 495 union acpi_operand_object *source_object,
534 union acpi_operand_object *source_object, 496 union acpi_generic_state *state, void *context)
535 union acpi_generic_state *state,
536 void *context)
537{ 497{
538 acpi_status status = AE_OK; 498 acpi_status status = AE_OK;
539 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 499 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
540 acpi_size object_space; 500 acpi_size object_space;
541
542 501
543 switch (object_type) { 502 switch (object_type) {
544 case ACPI_COPY_TYPE_SIMPLE: 503 case ACPI_COPY_TYPE_SIMPLE:
@@ -547,15 +506,16 @@ acpi_ut_get_element_length (
547 * Simple object - just get the size (Null object/entry is handled 506 * Simple object - just get the size (Null object/entry is handled
548 * here also) and sum it into the running package length 507 * here also) and sum it into the running package length
549 */ 508 */
550 status = acpi_ut_get_simple_object_size (source_object, &object_space); 509 status =
551 if (ACPI_FAILURE (status)) { 510 acpi_ut_get_simple_object_size(source_object,
511 &object_space);
512 if (ACPI_FAILURE(status)) {
552 return (status); 513 return (status);
553 } 514 }
554 515
555 info->length += object_space; 516 info->length += object_space;
556 break; 517 break;
557 518
558
559 case ACPI_COPY_TYPE_PACKAGE: 519 case ACPI_COPY_TYPE_PACKAGE:
560 520
561 /* 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 */
@@ -564,7 +524,6 @@ acpi_ut_get_element_length (
564 state->pkg.this_target_obj = NULL; 524 state->pkg.this_target_obj = NULL;
565 break; 525 break;
566 526
567
568 default: 527 default:
569 528
570 /* No other types allowed */ 529 /* No other types allowed */
@@ -575,7 +534,6 @@ acpi_ut_get_element_length (
575 return (status); 534 return (status);
576} 535}
577 536
578
579/******************************************************************************* 537/*******************************************************************************
580 * 538 *
581 * FUNCTION: acpi_ut_get_package_object_size 539 * FUNCTION: acpi_ut_get_package_object_size
@@ -594,25 +552,22 @@ acpi_ut_get_element_length (
594 ******************************************************************************/ 552 ******************************************************************************/
595 553
596static acpi_status 554static acpi_status
597acpi_ut_get_package_object_size ( 555acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
598 union acpi_operand_object *internal_object, 556 acpi_size * obj_length)
599 acpi_size *obj_length)
600{ 557{
601 acpi_status status; 558 acpi_status status;
602 struct acpi_pkg_info info; 559 struct acpi_pkg_info info;
603 560
561 ACPI_FUNCTION_TRACE_PTR("ut_get_package_object_size", internal_object);
604 562
605 ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object); 563 info.length = 0;
606
607
608 info.length = 0;
609 info.object_space = 0; 564 info.object_space = 0;
610 info.num_packages = 1; 565 info.num_packages = 1;
611 566
612 status = acpi_ut_walk_package_tree (internal_object, NULL, 567 status = acpi_ut_walk_package_tree(internal_object, NULL,
613 acpi_ut_get_element_length, &info); 568 acpi_ut_get_element_length, &info);
614 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
615 return_ACPI_STATUS (status); 570 return_ACPI_STATUS(status);
616 } 571 }
617 572
618 /* 573 /*
@@ -620,16 +575,15 @@ acpi_ut_get_package_object_size (
620 * just add the length of the package objects themselves. 575 * just add the length of the package objects themselves.
621 * Round up to the next machine word. 576 * Round up to the next machine word.
622 */ 577 */
623 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)) *
624 (acpi_size) info.num_packages; 579 (acpi_size) info.num_packages;
625 580
626 /* Return the total package length */ 581 /* Return the total package length */
627 582
628 *obj_length = info.length; 583 *obj_length = info.length;
629 return_ACPI_STATUS (status); 584 return_ACPI_STATUS(status);
630} 585}
631 586
632
633/******************************************************************************* 587/*******************************************************************************
634 * 588 *
635 * FUNCTION: acpi_ut_get_object_size 589 * FUNCTION: acpi_ut_get_object_size
@@ -645,25 +599,23 @@ acpi_ut_get_package_object_size (
645 ******************************************************************************/ 599 ******************************************************************************/
646 600
647acpi_status 601acpi_status
648acpi_ut_get_object_size ( 602acpi_ut_get_object_size(union acpi_operand_object *internal_object,
649 union acpi_operand_object *internal_object, 603 acpi_size * obj_length)
650 acpi_size *obj_length)
651{ 604{
652 acpi_status status; 605 acpi_status status;
653 606
654 607 ACPI_FUNCTION_ENTRY();
655 ACPI_FUNCTION_ENTRY (); 608
656 609 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
657 610 ACPI_DESC_TYPE_OPERAND)
658 if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) && 611 && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) {
659 (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) { 612 status =
660 status = acpi_ut_get_package_object_size (internal_object, obj_length); 613 acpi_ut_get_package_object_size(internal_object,
661 } 614 obj_length);
662 else { 615 } else {
663 status = acpi_ut_get_simple_object_size (internal_object, obj_length); 616 status =
617 acpi_ut_get_simple_object_size(internal_object, obj_length);
664 } 618 }
665 619
666 return (status); 620 return (status);
667} 621}
668
669
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index 192e7ac95690..c1cb27583be8 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -41,12 +41,10 @@
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 ("utstate") 47ACPI_MODULE_NAME("utstate")
49
50 48
51/******************************************************************************* 49/*******************************************************************************
52 * 50 *
@@ -61,30 +59,26 @@
61 * DESCRIPTION: Create a new state and push it 59 * DESCRIPTION: Create a new state and push it
62 * 60 *
63 ******************************************************************************/ 61 ******************************************************************************/
64
65acpi_status 62acpi_status
66acpi_ut_create_pkg_state_and_push ( 63acpi_ut_create_pkg_state_and_push(void *internal_object,
67 void *internal_object, 64 void *external_object,
68 void *external_object, 65 u16 index,
69 u16 index, 66 union acpi_generic_state ** state_list)
70 union acpi_generic_state **state_list)
71{ 67{
72 union acpi_generic_state *state; 68 union acpi_generic_state *state;
73
74 69
75 ACPI_FUNCTION_ENTRY (); 70 ACPI_FUNCTION_ENTRY();
76 71
77 72 state =
78 state = acpi_ut_create_pkg_state (internal_object, external_object, index); 73 acpi_ut_create_pkg_state(internal_object, external_object, index);
79 if (!state) { 74 if (!state) {
80 return (AE_NO_MEMORY); 75 return (AE_NO_MEMORY);
81 } 76 }
82 77
83 acpi_ut_push_generic_state (state_list, state); 78 acpi_ut_push_generic_state(state_list, state);
84 return (AE_OK); 79 return (AE_OK);
85} 80}
86 81
87
88/******************************************************************************* 82/*******************************************************************************
89 * 83 *
90 * FUNCTION: acpi_ut_push_generic_state 84 * FUNCTION: acpi_ut_push_generic_state
@@ -99,12 +93,10 @@ acpi_ut_create_pkg_state_and_push (
99 ******************************************************************************/ 93 ******************************************************************************/
100 94
101void 95void
102acpi_ut_push_generic_state ( 96acpi_ut_push_generic_state(union acpi_generic_state **list_head,
103 union acpi_generic_state **list_head, 97 union acpi_generic_state *state)
104 union acpi_generic_state *state)
105{ 98{
106 ACPI_FUNCTION_TRACE ("ut_push_generic_state"); 99 ACPI_FUNCTION_TRACE("ut_push_generic_state");
107
108 100
109 /* Push the state object onto the front of the list (stack) */ 101 /* Push the state object onto the front of the list (stack) */
110 102
@@ -114,7 +106,6 @@ acpi_ut_push_generic_state (
114 return_VOID; 106 return_VOID;
115} 107}
116 108
117
118/******************************************************************************* 109/*******************************************************************************
119 * 110 *
120 * FUNCTION: acpi_ut_pop_generic_state 111 * FUNCTION: acpi_ut_pop_generic_state
@@ -127,15 +118,12 @@ acpi_ut_push_generic_state (
127 * 118 *
128 ******************************************************************************/ 119 ******************************************************************************/
129 120
130union acpi_generic_state * 121union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
131acpi_ut_pop_generic_state ( 122 **list_head)
132 union acpi_generic_state **list_head)
133{ 123{
134 union acpi_generic_state *state; 124 union acpi_generic_state *state;
135
136
137 ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
138 125
126 ACPI_FUNCTION_TRACE("ut_pop_generic_state");
139 127
140 /* Remove the state object at the head of the list (stack) */ 128 /* Remove the state object at the head of the list (stack) */
141 129
@@ -146,10 +134,9 @@ acpi_ut_pop_generic_state (
146 *list_head = state->common.next; 134 *list_head = state->common.next;
147 } 135 }
148 136
149 return_PTR (state); 137 return_PTR(state);
150} 138}
151 139
152
153/******************************************************************************* 140/*******************************************************************************
154 * 141 *
155 * FUNCTION: acpi_ut_create_generic_state 142 * FUNCTION: acpi_ut_create_generic_state
@@ -163,17 +150,13 @@ acpi_ut_pop_generic_state (
163 * 150 *
164 ******************************************************************************/ 151 ******************************************************************************/
165 152
166union acpi_generic_state * 153union acpi_generic_state *acpi_ut_create_generic_state(void)
167acpi_ut_create_generic_state (
168 void)
169{ 154{
170 union acpi_generic_state *state; 155 union acpi_generic_state *state;
171
172 156
173 ACPI_FUNCTION_ENTRY (); 157 ACPI_FUNCTION_ENTRY();
174 158
175 159 state = acpi_os_acquire_object(acpi_gbl_state_cache);
176 state = acpi_os_acquire_object (acpi_gbl_state_cache);
177 if (state) { 160 if (state) {
178 /* Initialize */ 161 /* Initialize */
179 memset(state, 0, sizeof(union acpi_generic_state)); 162 memset(state, 0, sizeof(union acpi_generic_state));
@@ -183,7 +166,6 @@ acpi_ut_create_generic_state (
183 return (state); 166 return (state);
184} 167}
185 168
186
187/******************************************************************************* 169/*******************************************************************************
188 * 170 *
189 * FUNCTION: acpi_ut_create_thread_state 171 * FUNCTION: acpi_ut_create_thread_state
@@ -197,32 +179,27 @@ acpi_ut_create_generic_state (
197 * 179 *
198 ******************************************************************************/ 180 ******************************************************************************/
199 181
200struct acpi_thread_state * 182struct acpi_thread_state *acpi_ut_create_thread_state(void)
201acpi_ut_create_thread_state (
202 void)
203{ 183{
204 union acpi_generic_state *state; 184 union acpi_generic_state *state;
205
206
207 ACPI_FUNCTION_TRACE ("ut_create_thread_state");
208 185
186 ACPI_FUNCTION_TRACE("ut_create_thread_state");
209 187
210 /* Create the generic state object */ 188 /* Create the generic state object */
211 189
212 state = acpi_ut_create_generic_state (); 190 state = acpi_ut_create_generic_state();
213 if (!state) { 191 if (!state) {
214 return_PTR (NULL); 192 return_PTR(NULL);
215 } 193 }
216 194
217 /* Init fields specific to the update struct */ 195 /* Init fields specific to the update struct */
218 196
219 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; 197 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
220 state->thread.thread_id = acpi_os_get_thread_id (); 198 state->thread.thread_id = acpi_os_get_thread_id();
221 199
222 return_PTR ((struct acpi_thread_state *) state); 200 return_PTR((struct acpi_thread_state *)state);
223} 201}
224 202
225
226/******************************************************************************* 203/*******************************************************************************
227 * 204 *
228 * FUNCTION: acpi_ut_create_update_state 205 * FUNCTION: acpi_ut_create_update_state
@@ -238,34 +215,29 @@ acpi_ut_create_thread_state (
238 * 215 *
239 ******************************************************************************/ 216 ******************************************************************************/
240 217
241union acpi_generic_state * 218union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
242acpi_ut_create_update_state ( 219 *object, u16 action)
243 union acpi_operand_object *object,
244 u16 action)
245{ 220{
246 union acpi_generic_state *state; 221 union acpi_generic_state *state;
247
248
249 ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
250 222
223 ACPI_FUNCTION_TRACE_PTR("ut_create_update_state", object);
251 224
252 /* Create the generic state object */ 225 /* Create the generic state object */
253 226
254 state = acpi_ut_create_generic_state (); 227 state = acpi_ut_create_generic_state();
255 if (!state) { 228 if (!state) {
256 return_PTR (NULL); 229 return_PTR(NULL);
257 } 230 }
258 231
259 /* Init fields specific to the update struct */ 232 /* Init fields specific to the update struct */
260 233
261 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; 234 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
262 state->update.object = object; 235 state->update.object = object;
263 state->update.value = action; 236 state->update.value = action;
264 237
265 return_PTR (state); 238 return_PTR(state);
266} 239}
267 240
268
269/******************************************************************************* 241/*******************************************************************************
270 * 242 *
271 * FUNCTION: acpi_ut_create_pkg_state 243 * FUNCTION: acpi_ut_create_pkg_state
@@ -279,37 +251,32 @@ acpi_ut_create_update_state (
279 * 251 *
280 ******************************************************************************/ 252 ******************************************************************************/
281 253
282union acpi_generic_state * 254union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
283acpi_ut_create_pkg_state ( 255 void *external_object,
284 void *internal_object, 256 u16 index)
285 void *external_object,
286 u16 index)
287{ 257{
288 union acpi_generic_state *state; 258 union acpi_generic_state *state;
289
290
291 ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
292 259
260 ACPI_FUNCTION_TRACE_PTR("ut_create_pkg_state", internal_object);
293 261
294 /* Create the generic state object */ 262 /* Create the generic state object */
295 263
296 state = acpi_ut_create_generic_state (); 264 state = acpi_ut_create_generic_state();
297 if (!state) { 265 if (!state) {
298 return_PTR (NULL); 266 return_PTR(NULL);
299 } 267 }
300 268
301 /* Init fields specific to the update struct */ 269 /* Init fields specific to the update struct */
302 270
303 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; 271 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
304 state->pkg.source_object = (union acpi_operand_object *) internal_object; 272 state->pkg.source_object = (union acpi_operand_object *)internal_object;
305 state->pkg.dest_object = external_object; 273 state->pkg.dest_object = external_object;
306 state->pkg.index = index; 274 state->pkg.index = index;
307 state->pkg.num_packages = 1; 275 state->pkg.num_packages = 1;
308 276
309 return_PTR (state); 277 return_PTR(state);
310} 278}
311 279
312
313/******************************************************************************* 280/*******************************************************************************
314 * 281 *
315 * FUNCTION: acpi_ut_create_control_state 282 * FUNCTION: acpi_ut_create_control_state
@@ -323,32 +290,27 @@ acpi_ut_create_pkg_state (
323 * 290 *
324 ******************************************************************************/ 291 ******************************************************************************/
325 292
326union acpi_generic_state * 293union acpi_generic_state *acpi_ut_create_control_state(void)
327acpi_ut_create_control_state (
328 void)
329{ 294{
330 union acpi_generic_state *state; 295 union acpi_generic_state *state;
331
332
333 ACPI_FUNCTION_TRACE ("ut_create_control_state");
334 296
297 ACPI_FUNCTION_TRACE("ut_create_control_state");
335 298
336 /* Create the generic state object */ 299 /* Create the generic state object */
337 300
338 state = acpi_ut_create_generic_state (); 301 state = acpi_ut_create_generic_state();
339 if (!state) { 302 if (!state) {
340 return_PTR (NULL); 303 return_PTR(NULL);
341 } 304 }
342 305
343 /* Init fields specific to the control struct */ 306 /* Init fields specific to the control struct */
344 307
345 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; 308 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
346 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; 309 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
347 310
348 return_PTR (state); 311 return_PTR(state);
349} 312}
350 313
351
352/******************************************************************************* 314/*******************************************************************************
353 * 315 *
354 * FUNCTION: acpi_ut_delete_generic_state 316 * FUNCTION: acpi_ut_delete_generic_state
@@ -362,15 +324,10 @@ acpi_ut_create_control_state (
362 * 324 *
363 ******************************************************************************/ 325 ******************************************************************************/
364 326
365void 327void acpi_ut_delete_generic_state(union acpi_generic_state *state)
366acpi_ut_delete_generic_state (
367 union acpi_generic_state *state)
368{ 328{
369 ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); 329 ACPI_FUNCTION_TRACE("ut_delete_generic_state");
370 330
371 331 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
372 (void) acpi_os_release_object (acpi_gbl_state_cache, state);
373 return_VOID; 332 return_VOID;
374} 333}
375
376
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index 850da6817423..f06bd5e5e9d1 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -49,8 +49,7 @@
49#include <acpi/acdebug.h> 49#include <acpi/acdebug.h>
50 50
51#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utxface") 52ACPI_MODULE_NAME("utxface")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -64,60 +63,54 @@
64 * called, so any early initialization belongs here. 63 * called, so any early initialization belongs here.
65 * 64 *
66 ******************************************************************************/ 65 ******************************************************************************/
67 66acpi_status acpi_initialize_subsystem(void)
68acpi_status
69acpi_initialize_subsystem (
70 void)
71{ 67{
72 acpi_status status; 68 acpi_status status;
73
74 69
75 ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); 70 ACPI_FUNCTION_TRACE("acpi_initialize_subsystem");
76 71
77 72 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
78 ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
79 73
80 /* Initialize the OS-Dependent layer */ 74 /* Initialize the OS-Dependent layer */
81 75
82 status = acpi_os_initialize (); 76 status = acpi_os_initialize();
83 if (ACPI_FAILURE (status)) { 77 if (ACPI_FAILURE(status)) {
84 ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n", 78 ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n",
85 acpi_format_exception (status))); 79 acpi_format_exception(status)));
86 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
87 } 81 }
88 82
89 /* Initialize all globals used by the subsystem */ 83 /* Initialize all globals used by the subsystem */
90 84
91 acpi_ut_init_globals (); 85 acpi_ut_init_globals();
92 86
93 /* Create the default mutex objects */ 87 /* Create the default mutex objects */
94 88
95 status = acpi_ut_mutex_initialize (); 89 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n", 91 ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n",
98 acpi_format_exception (status))); 92 acpi_format_exception(status)));
99 return_ACPI_STATUS (status); 93 return_ACPI_STATUS(status);
100 } 94 }
101 95
102 /* 96 /*
103 * Initialize the namespace manager and 97 * Initialize the namespace manager and
104 * the root of the namespace tree 98 * the root of the namespace tree
105 */ 99 */
106 status = acpi_ns_root_initialize (); 100 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE (status)) { 101 if (ACPI_FAILURE(status)) {
108 ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", 102 ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n",
109 acpi_format_exception (status))); 103 acpi_format_exception(status)));
110 return_ACPI_STATUS (status); 104 return_ACPI_STATUS(status);
111 } 105 }
112 106
113 /* If configured, initialize the AML debugger */ 107 /* If configured, initialize the AML debugger */
114 108
115 ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); 109 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
116 110
117 return_ACPI_STATUS (status); 111 return_ACPI_STATUS(status);
118} 112}
119 113
120
121/******************************************************************************* 114/*******************************************************************************
122 * 115 *
123 * FUNCTION: acpi_enable_subsystem 116 * FUNCTION: acpi_enable_subsystem
@@ -131,41 +124,39 @@ acpi_initialize_subsystem (
131 * 124 *
132 ******************************************************************************/ 125 ******************************************************************************/
133 126
134acpi_status 127acpi_status acpi_enable_subsystem(u32 flags)
135acpi_enable_subsystem (
136 u32 flags)
137{ 128{
138 acpi_status status = AE_OK; 129 acpi_status status = AE_OK;
139
140
141 ACPI_FUNCTION_TRACE ("acpi_enable_subsystem");
142 130
131 ACPI_FUNCTION_TRACE("acpi_enable_subsystem");
143 132
144 /* 133 /*
145 * We must initialize the hardware before we can enable ACPI. 134 * We must initialize the hardware before we can enable ACPI.
146 * The values from the FADT are validated here. 135 * The values from the FADT are validated here.
147 */ 136 */
148 if (!(flags & ACPI_NO_HARDWARE_INIT)) { 137 if (!(flags & ACPI_NO_HARDWARE_INIT)) {
149 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 138 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
150 "[Init] Initializing ACPI hardware\n")); 139 "[Init] Initializing ACPI hardware\n"));
151 140
152 status = acpi_hw_initialize (); 141 status = acpi_hw_initialize();
153 if (ACPI_FAILURE (status)) { 142 if (ACPI_FAILURE(status)) {
154 return_ACPI_STATUS (status); 143 return_ACPI_STATUS(status);
155 } 144 }
156 } 145 }
157 146
158 /* Enable ACPI mode */ 147 /* Enable ACPI mode */
159 148
160 if (!(flags & ACPI_NO_ACPI_ENABLE)) { 149 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
161 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"));
162 152
163 acpi_gbl_original_mode = acpi_hw_get_mode(); 153 acpi_gbl_original_mode = acpi_hw_get_mode();
164 154
165 status = acpi_enable (); 155 status = acpi_enable();
166 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
167 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n")); 157 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
168 return_ACPI_STATUS (status); 158 "acpi_enable failed.\n"));
159 return_ACPI_STATUS(status);
169 } 160 }
170 } 161 }
171 162
@@ -175,12 +166,12 @@ acpi_enable_subsystem (
175 * install_address_space_handler interface. 166 * install_address_space_handler interface.
176 */ 167 */
177 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 168 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
178 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 169 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
179 "[Init] Installing default address space handlers\n")); 170 "[Init] Installing default address space handlers\n"));
180 171
181 status = acpi_ev_install_region_handlers (); 172 status = acpi_ev_install_region_handlers();
182 if (ACPI_FAILURE (status)) { 173 if (ACPI_FAILURE(status)) {
183 return_ACPI_STATUS (status); 174 return_ACPI_STATUS(status);
184 } 175 }
185 } 176 }
186 177
@@ -193,28 +184,28 @@ acpi_enable_subsystem (
193 * execution! 184 * execution!
194 */ 185 */
195 if (!(flags & ACPI_NO_EVENT_INIT)) { 186 if (!(flags & ACPI_NO_EVENT_INIT)) {
196 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
197 "[Init] Initializing ACPI events\n")); 188 "[Init] Initializing ACPI events\n"));
198 189
199 status = acpi_ev_initialize_events (); 190 status = acpi_ev_initialize_events();
200 if (ACPI_FAILURE (status)) { 191 if (ACPI_FAILURE(status)) {
201 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
202 } 193 }
203 } 194 }
204 195
205 /* Install the SCI handler and Global Lock handler */ 196 /* Install the SCI handler and Global Lock handler */
206 197
207 if (!(flags & ACPI_NO_HANDLER_INIT)) { 198 if (!(flags & ACPI_NO_HANDLER_INIT)) {
208 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
209 "[Init] Installing SCI/GL handlers\n")); 200 "[Init] Installing SCI/GL handlers\n"));
210 201
211 status = acpi_ev_install_xrupt_handlers (); 202 status = acpi_ev_install_xrupt_handlers();
212 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE(status)) {
213 return_ACPI_STATUS (status); 204 return_ACPI_STATUS(status);
214 } 205 }
215 } 206 }
216 207
217 return_ACPI_STATUS (status); 208 return_ACPI_STATUS(status);
218} 209}
219 210
220/******************************************************************************* 211/*******************************************************************************
@@ -230,15 +221,11 @@ acpi_enable_subsystem (
230 * 221 *
231 ******************************************************************************/ 222 ******************************************************************************/
232 223
233acpi_status 224acpi_status acpi_initialize_objects(u32 flags)
234acpi_initialize_objects (
235 u32 flags)
236{ 225{
237 acpi_status status = AE_OK; 226 acpi_status status = AE_OK;
238
239
240 ACPI_FUNCTION_TRACE ("acpi_initialize_objects");
241 227
228 ACPI_FUNCTION_TRACE("acpi_initialize_objects");
242 229
243 /* 230 /*
244 * Run all _REG methods 231 * Run all _REG methods
@@ -248,12 +235,12 @@ acpi_initialize_objects (
248 * contain executable AML (see call to acpi_ns_initialize_objects below). 235 * contain executable AML (see call to acpi_ns_initialize_objects below).
249 */ 236 */
250 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
251 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
252 "[Init] Executing _REG op_region methods\n")); 239 "[Init] Executing _REG op_region methods\n"));
253 240
254 status = acpi_ev_initialize_op_regions (); 241 status = acpi_ev_initialize_op_regions();
255 if (ACPI_FAILURE (status)) { 242 if (ACPI_FAILURE(status)) {
256 return_ACPI_STATUS (status); 243 return_ACPI_STATUS(status);
257 } 244 }
258 } 245 }
259 246
@@ -263,12 +250,12 @@ acpi_initialize_objects (
263 * objects: operation_regions, buffer_fields, Buffers, and Packages. 250 * objects: operation_regions, buffer_fields, Buffers, and Packages.
264 */ 251 */
265 if (!(flags & ACPI_NO_OBJECT_INIT)) { 252 if (!(flags & ACPI_NO_OBJECT_INIT)) {
266 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
267 "[Init] Completing Initialization of ACPI Objects\n")); 254 "[Init] Completing Initialization of ACPI Objects\n"));
268 255
269 status = acpi_ns_initialize_objects (); 256 status = acpi_ns_initialize_objects();
270 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
271 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
272 } 259 }
273 } 260 }
274 261
@@ -277,12 +264,12 @@ acpi_initialize_objects (
277 * This runs the _STA and _INI methods. 264 * This runs the _STA and _INI methods.
278 */ 265 */
279 if (!(flags & ACPI_NO_DEVICE_INIT)) { 266 if (!(flags & ACPI_NO_DEVICE_INIT)) {
280 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
281 "[Init] Initializing ACPI Devices\n")); 268 "[Init] Initializing ACPI Devices\n"));
282 269
283 status = acpi_ns_initialize_devices (); 270 status = acpi_ns_initialize_devices();
284 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
286 } 273 }
287 } 274 }
288 275
@@ -291,13 +278,12 @@ acpi_initialize_objects (
291 * 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 --
292 * thus wasting non-paged memory. 279 * thus wasting non-paged memory.
293 */ 280 */
294 status = acpi_purge_cached_objects (); 281 status = acpi_purge_cached_objects();
295 282
296 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; 283 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
297 return_ACPI_STATUS (status); 284 return_ACPI_STATUS(status);
298} 285}
299 286
300
301/******************************************************************************* 287/*******************************************************************************
302 * 288 *
303 * FUNCTION: acpi_terminate 289 * FUNCTION: acpi_terminate
@@ -310,15 +296,11 @@ acpi_initialize_objects (
310 * 296 *
311 ******************************************************************************/ 297 ******************************************************************************/
312 298
313acpi_status 299acpi_status acpi_terminate(void)
314acpi_terminate (
315 void)
316{ 300{
317 acpi_status status; 301 acpi_status status;
318
319
320 ACPI_FUNCTION_TRACE ("acpi_terminate");
321 302
303 ACPI_FUNCTION_TRACE("acpi_terminate");
322 304
323 /* Terminate the AML Debugger if present */ 305 /* Terminate the AML Debugger if present */
324 306
@@ -326,28 +308,25 @@ acpi_terminate (
326 308
327 /* Shutdown and free all resources */ 309 /* Shutdown and free all resources */
328 310
329 acpi_ut_subsystem_shutdown (); 311 acpi_ut_subsystem_shutdown();
330
331 312
332 /* Free the mutex objects */ 313 /* Free the mutex objects */
333 314
334 acpi_ut_mutex_terminate (); 315 acpi_ut_mutex_terminate();
335
336 316
337#ifdef ACPI_DEBUGGER 317#ifdef ACPI_DEBUGGER
338 318
339 /* Shut down the debugger */ 319 /* Shut down the debugger */
340 320
341 acpi_db_terminate (); 321 acpi_db_terminate();
342#endif 322#endif
343 323
344 /* Now we can shutdown the OS-dependent layer */ 324 /* Now we can shutdown the OS-dependent layer */
345 325
346 status = acpi_os_terminate (); 326 status = acpi_os_terminate();
347 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
348} 328}
349 329
350
351#ifdef ACPI_FUTURE_USAGE 330#ifdef ACPI_FUTURE_USAGE
352/******************************************************************************* 331/*******************************************************************************
353 * 332 *
@@ -363,20 +342,16 @@ acpi_terminate (
363 * 342 *
364 ******************************************************************************/ 343 ******************************************************************************/
365 344
366acpi_status 345acpi_status acpi_subsystem_status(void)
367acpi_subsystem_status (
368 void)
369{ 346{
370 347
371 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { 348 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
372 return (AE_OK); 349 return (AE_OK);
373 } 350 } else {
374 else {
375 return (AE_ERROR); 351 return (AE_ERROR);
376 } 352 }
377} 353}
378 354
379
380/******************************************************************************* 355/*******************************************************************************
381 * 356 *
382 * FUNCTION: acpi_get_system_info 357 * FUNCTION: acpi_get_system_info
@@ -395,64 +370,60 @@ acpi_subsystem_status (
395 * 370 *
396 ******************************************************************************/ 371 ******************************************************************************/
397 372
398acpi_status 373acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
399acpi_get_system_info (
400 struct acpi_buffer *out_buffer)
401{ 374{
402 struct acpi_system_info *info_ptr; 375 struct acpi_system_info *info_ptr;
403 acpi_status status; 376 acpi_status status;
404 u32 i; 377 u32 i;
405
406
407 ACPI_FUNCTION_TRACE ("acpi_get_system_info");
408 378
379 ACPI_FUNCTION_TRACE("acpi_get_system_info");
409 380
410 /* Parameter validation */ 381 /* Parameter validation */
411 382
412 status = acpi_ut_validate_buffer (out_buffer); 383 status = acpi_ut_validate_buffer(out_buffer);
413 if (ACPI_FAILURE (status)) { 384 if (ACPI_FAILURE(status)) {
414 return_ACPI_STATUS (status); 385 return_ACPI_STATUS(status);
415 } 386 }
416 387
417 /* Validate/Allocate/Clear caller buffer */ 388 /* Validate/Allocate/Clear caller buffer */
418 389
419 status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info)); 390 status =
420 if (ACPI_FAILURE (status)) { 391 acpi_ut_initialize_buffer(out_buffer,
421 return_ACPI_STATUS (status); 392 sizeof(struct acpi_system_info));
393 if (ACPI_FAILURE(status)) {
394 return_ACPI_STATUS(status);
422 } 395 }
423 396
424 /* 397 /*
425 * Populate the return buffer 398 * Populate the return buffer
426 */ 399 */
427 info_ptr = (struct acpi_system_info *) out_buffer->pointer; 400 info_ptr = (struct acpi_system_info *)out_buffer->pointer;
428 401
429 info_ptr->acpi_ca_version = ACPI_CA_VERSION; 402 info_ptr->acpi_ca_version = ACPI_CA_VERSION;
430 403
431 /* System flags (ACPI capabilities) */ 404 /* System flags (ACPI capabilities) */
432 405
433 info_ptr->flags = ACPI_SYS_MODE_ACPI; 406 info_ptr->flags = ACPI_SYS_MODE_ACPI;
434 407
435 /* Timer resolution - 24 or 32 bits */ 408 /* Timer resolution - 24 or 32 bits */
436 409
437 if (!acpi_gbl_FADT) { 410 if (!acpi_gbl_FADT) {
438 info_ptr->timer_resolution = 0; 411 info_ptr->timer_resolution = 0;
439 } 412 } else if (acpi_gbl_FADT->tmr_val_ext == 0) {
440 else if (acpi_gbl_FADT->tmr_val_ext == 0) {
441 info_ptr->timer_resolution = 24; 413 info_ptr->timer_resolution = 24;
442 } 414 } else {
443 else {
444 info_ptr->timer_resolution = 32; 415 info_ptr->timer_resolution = 32;
445 } 416 }
446 417
447 /* Clear the reserved fields */ 418 /* Clear the reserved fields */
448 419
449 info_ptr->reserved1 = 0; 420 info_ptr->reserved1 = 0;
450 info_ptr->reserved2 = 0; 421 info_ptr->reserved2 = 0;
451 422
452 /* Current debug levels */ 423 /* Current debug levels */
453 424
454 info_ptr->debug_layer = acpi_dbg_layer; 425 info_ptr->debug_layer = acpi_dbg_layer;
455 info_ptr->debug_level = acpi_dbg_level; 426 info_ptr->debug_level = acpi_dbg_level;
456 427
457 /* Current status of the ACPI tables, per table type */ 428 /* Current status of the ACPI tables, per table type */
458 429
@@ -461,10 +432,10 @@ acpi_get_system_info (
461 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;
462 } 433 }
463 434
464 return_ACPI_STATUS (AE_OK); 435 return_ACPI_STATUS(AE_OK);
465} 436}
466EXPORT_SYMBOL(acpi_get_system_info);
467 437
438EXPORT_SYMBOL(acpi_get_system_info);
468 439
469/***************************************************************************** 440/*****************************************************************************
470 * 441 *
@@ -482,9 +453,7 @@ EXPORT_SYMBOL(acpi_get_system_info);
482 ****************************************************************************/ 453 ****************************************************************************/
483 454
484acpi_status 455acpi_status
485acpi_install_initialization_handler ( 456acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
486 acpi_init_handler handler,
487 u32 function)
488{ 457{
489 458
490 if (!handler) { 459 if (!handler) {
@@ -499,7 +468,7 @@ acpi_install_initialization_handler (
499 return AE_OK; 468 return AE_OK;
500} 469}
501 470
502#endif /* ACPI_FUTURE_USAGE */ 471#endif /* ACPI_FUTURE_USAGE */
503 472
504/***************************************************************************** 473/*****************************************************************************
505 * 474 *
@@ -513,15 +482,13 @@ acpi_install_initialization_handler (
513 * 482 *
514 ****************************************************************************/ 483 ****************************************************************************/
515 484
516acpi_status 485acpi_status acpi_purge_cached_objects(void)
517acpi_purge_cached_objects (
518 void)
519{ 486{
520 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); 487 ACPI_FUNCTION_TRACE("acpi_purge_cached_objects");
521 488
522 (void) acpi_os_purge_cache (acpi_gbl_state_cache); 489 (void)acpi_os_purge_cache(acpi_gbl_state_cache);
523 (void) acpi_os_purge_cache (acpi_gbl_operand_cache); 490 (void)acpi_os_purge_cache(acpi_gbl_operand_cache);
524 (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); 491 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
525 (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); 492 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
526 return_ACPI_STATUS (AE_OK); 493 return_ACPI_STATUS(AE_OK);
527} 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 7b10a7b070c9..b9132b5ac0f0 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,13 +292,11 @@ 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 };
301 300
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); 301 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
303 302
@@ -308,14 +307,12 @@ acpi_video_device_set_state (
308} 307}
309 308
310static int 309static int
311acpi_video_device_lcd_query_levels ( 310acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
312 struct acpi_video_device *device, 311 union acpi_object **levels)
313 union acpi_object **levels)
314{ 312{
315 int status; 313 int status;
316 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 314 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
317 union acpi_object *obj; 315 union acpi_object *obj;
318
319 316
320 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels"); 317 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
321 318
@@ -324,7 +321,7 @@ acpi_video_device_lcd_query_levels (
324 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); 321 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
325 if (!ACPI_SUCCESS(status)) 322 if (!ACPI_SUCCESS(status))
326 return_VALUE(status); 323 return_VALUE(status);
327 obj = (union acpi_object *) buffer.pointer; 324 obj = (union acpi_object *)buffer.pointer;
328 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) { 325 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
329 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); 326 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
330 status = -EFAULT; 327 status = -EFAULT;
@@ -335,7 +332,7 @@ acpi_video_device_lcd_query_levels (
335 332
336 return_VALUE(0); 333 return_VALUE(0);
337 334
338err: 335 err:
339 if (buffer.pointer) 336 if (buffer.pointer)
340 kfree(buffer.pointer); 337 kfree(buffer.pointer);
341 338
@@ -343,13 +340,11 @@ err:
343} 340}
344 341
345static int 342static int
346acpi_video_device_lcd_set_level ( 343acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
347 struct acpi_video_device *device,
348 int level)
349{ 344{
350 int status; 345 int status;
351 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 346 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
352 struct acpi_object_list args = {1, &arg0}; 347 struct acpi_object_list args = { 1, &arg0 };
353 348
354 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level"); 349 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
355 350
@@ -361,11 +356,10 @@ acpi_video_device_lcd_set_level (
361} 356}
362 357
363static int 358static int
364acpi_video_device_lcd_get_level_current ( 359acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
365 struct acpi_video_device *device, 360 unsigned long *level)
366 unsigned long *level)
367{ 361{
368 int status; 362 int status;
369 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current"); 363 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
370 364
371 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); 365 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
@@ -374,16 +368,14 @@ acpi_video_device_lcd_get_level_current (
374} 368}
375 369
376static int 370static int
377acpi_video_device_EDID ( 371acpi_video_device_EDID(struct acpi_video_device *device,
378 struct acpi_video_device *device, 372 union acpi_object **edid, ssize_t length)
379 union acpi_object **edid,
380 ssize_t length)
381{ 373{
382 int status; 374 int status;
383 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 375 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
384 union acpi_object *obj; 376 union acpi_object *obj;
385 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 377 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
386 struct acpi_object_list args = {1, &arg0}; 378 struct acpi_object_list args = { 1, &arg0 };
387 379
388 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID"); 380 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
389 381
@@ -402,7 +394,7 @@ acpi_video_device_EDID (
402 if (ACPI_FAILURE(status)) 394 if (ACPI_FAILURE(status))
403 return_VALUE(-ENODEV); 395 return_VALUE(-ENODEV);
404 396
405 obj = (union acpi_object *) buffer.pointer; 397 obj = (union acpi_object *)buffer.pointer;
406 398
407 if (obj && obj->type == ACPI_TYPE_BUFFER) 399 if (obj && obj->type == ACPI_TYPE_BUFFER)
408 *edid = obj; 400 *edid = obj;
@@ -415,18 +407,15 @@ acpi_video_device_EDID (
415 return_VALUE(status); 407 return_VALUE(status);
416} 408}
417 409
418
419/* bus */ 410/* bus */
420 411
421static int 412static int
422acpi_video_bus_set_POST ( 413acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
423 struct acpi_video_bus *video,
424 unsigned long option)
425{ 414{
426 int status; 415 int status;
427 unsigned long tmp; 416 unsigned long tmp;
428 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 417 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
429 struct acpi_object_list args = {1, &arg0}; 418 struct acpi_object_list args = { 1, &arg0 };
430 419
431 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST"); 420 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
432 421
@@ -434,15 +423,13 @@ acpi_video_bus_set_POST (
434 423
435 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp); 424 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
436 if (ACPI_SUCCESS(status)) 425 if (ACPI_SUCCESS(status))
437 status = tmp ? (-EINVAL):(AE_OK); 426 status = tmp ? (-EINVAL) : (AE_OK);
438 427
439 return_VALUE(status); 428 return_VALUE(status);
440} 429}
441 430
442static int 431static int
443acpi_video_bus_get_POST ( 432acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
444 struct acpi_video_bus *video,
445 unsigned long *id)
446{ 433{
447 int status; 434 int status;
448 435
@@ -454,11 +441,10 @@ acpi_video_bus_get_POST (
454} 441}
455 442
456static int 443static int
457acpi_video_bus_POST_options ( 444acpi_video_bus_POST_options(struct acpi_video_bus *video,
458 struct acpi_video_bus *video, 445 unsigned long *options)
459 unsigned long *options)
460{ 446{
461 int status; 447 int status;
462 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options"); 448 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
463 449
464 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); 450 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
@@ -489,18 +475,15 @@ acpi_video_bus_POST_options (
489 */ 475 */
490 476
491static int 477static int
492acpi_video_bus_DOS( 478acpi_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{ 479{
497 acpi_integer status = 0; 480 acpi_integer status = 0;
498 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 481 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
499 struct acpi_object_list args = {1, &arg0}; 482 struct acpi_object_list args = { 1, &arg0 };
500 483
501 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS"); 484 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
502 485
503 if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){ 486 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
504 status = -1; 487 status = -1;
505 goto Failed; 488 goto Failed;
506 } 489 }
@@ -508,7 +491,7 @@ acpi_video_bus_DOS(
508 video->dos_setting = arg0.integer.value; 491 video->dos_setting = arg0.integer.value;
509 acpi_evaluate_object(video->handle, "_DOS", &args, NULL); 492 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
510 493
511Failed: 494 Failed:
512 return_VALUE(status); 495 return_VALUE(status);
513} 496}
514 497
@@ -523,10 +506,9 @@ Failed:
523 * device. 506 * device.
524 */ 507 */
525 508
526static void 509static void acpi_video_device_find_cap(struct acpi_video_device *device)
527acpi_video_device_find_cap (struct acpi_video_device *device)
528{ 510{
529 acpi_integer status; 511 acpi_integer status;
530 acpi_handle h_dummy1; 512 acpi_handle h_dummy1;
531 int i; 513 int i;
532 union acpi_object *obj = NULL; 514 union acpi_object *obj = NULL;
@@ -534,27 +516,27 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
534 516
535 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap"); 517 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
536 518
537 memset( &device->cap, 0, 4); 519 memset(&device->cap, 0, 4);
538 520
539 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { 521 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
540 device->cap._ADR = 1; 522 device->cap._ADR = 1;
541 } 523 }
542 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) { 524 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
543 device->cap._BCL= 1; 525 device->cap._BCL = 1;
544 } 526 }
545 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) { 527 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
546 device->cap._BCM= 1; 528 device->cap._BCM = 1;
547 } 529 }
548 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) { 530 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
549 device->cap._DDC= 1; 531 device->cap._DDC = 1;
550 } 532 }
551 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) { 533 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
552 device->cap._DCS = 1; 534 device->cap._DCS = 1;
553 } 535 }
554 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) { 536 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
555 device->cap._DGS = 1; 537 device->cap._DGS = 1;
556 } 538 }
557 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) { 539 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
558 device->cap._DSS = 1; 540 device->cap._DSS = 1;
559 } 541 }
560 542
@@ -563,34 +545,38 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
563 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) { 545 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
564 int count = 0; 546 int count = 0;
565 union acpi_object *o; 547 union acpi_object *o;
566 548
567 br = kmalloc(sizeof(*br), GFP_KERNEL); 549 br = kmalloc(sizeof(*br), GFP_KERNEL);
568 if (!br) { 550 if (!br) {
569 printk(KERN_ERR "can't allocate memory\n"); 551 printk(KERN_ERR "can't allocate memory\n");
570 } else { 552 } else {
571 memset(br, 0, sizeof(*br)); 553 memset(br, 0, sizeof(*br));
572 br->levels = kmalloc(obj->package.count * 554 br->levels = kmalloc(obj->package.count *
573 sizeof *(br->levels), GFP_KERNEL); 555 sizeof *(br->levels), GFP_KERNEL);
574 if (!br->levels) 556 if (!br->levels)
575 goto out; 557 goto out;
576 558
577 for (i = 0; i < obj->package.count; i++) { 559 for (i = 0; i < obj->package.count; i++) {
578 o = (union acpi_object *) &obj->package.elements[i]; 560 o = (union acpi_object *)&obj->package.
561 elements[i];
579 if (o->type != ACPI_TYPE_INTEGER) { 562 if (o->type != ACPI_TYPE_INTEGER) {
580 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 563 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
564 "Invalid data\n"));
581 continue; 565 continue;
582 } 566 }
583 br->levels[count] = (u32) o->integer.value; 567 br->levels[count] = (u32) o->integer.value;
584 count++; 568 count++;
585 } 569 }
586out: 570 out:
587 if (count < 2) { 571 if (count < 2) {
588 kfree(br->levels); 572 kfree(br->levels);
589 kfree(br); 573 kfree(br);
590 } else { 574 } else {
591 br->count = count; 575 br->count = count;
592 device->brightness = br; 576 device->brightness = br;
593 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count)); 577 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
578 "found %d brightness levels\n",
579 count));
594 } 580 }
595 } 581 }
596 } 582 }
@@ -610,28 +596,27 @@ out:
610 * Find out all required AML method defined under the video bus device. 596 * Find out all required AML method defined under the video bus device.
611 */ 597 */
612 598
613static void 599static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
614acpi_video_bus_find_cap (struct acpi_video_bus *video)
615{ 600{
616 acpi_handle h_dummy1; 601 acpi_handle h_dummy1;
617 602
618 memset(&video->cap ,0, 4); 603 memset(&video->cap, 0, 4);
619 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) { 604 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
620 video->cap._DOS = 1; 605 video->cap._DOS = 1;
621 } 606 }
622 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) { 607 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
623 video->cap._DOD = 1; 608 video->cap._DOD = 1;
624 } 609 }
625 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) { 610 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
626 video->cap._ROM = 1; 611 video->cap._ROM = 1;
627 } 612 }
628 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) { 613 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
629 video->cap._GPD = 1; 614 video->cap._GPD = 1;
630 } 615 }
631 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) { 616 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
632 video->cap._SPD = 1; 617 video->cap._SPD = 1;
633 } 618 }
634 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) { 619 if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
635 video->cap._VPO = 1; 620 video->cap._VPO = 1;
636 } 621 }
637} 622}
@@ -641,12 +626,9 @@ acpi_video_bus_find_cap (struct acpi_video_bus *video)
641 * support the desired features 626 * support the desired features
642 */ 627 */
643 628
644static int 629static int acpi_video_bus_check(struct acpi_video_bus *video)
645acpi_video_bus_check (
646 struct acpi_video_bus *video)
647{ 630{
648 acpi_status status = -ENOENT; 631 acpi_status status = -ENOENT;
649
650 632
651 ACPI_FUNCTION_TRACE("acpi_video_bus_check"); 633 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
652 634
@@ -658,19 +640,19 @@ acpi_video_bus_check (
658 */ 640 */
659 641
660 /* Does this device able to support video switching ? */ 642 /* Does this device able to support video switching ? */
661 if(video->cap._DOS){ 643 if (video->cap._DOS) {
662 video->flags.multihead = 1; 644 video->flags.multihead = 1;
663 status = 0; 645 status = 0;
664 } 646 }
665 647
666 /* Does this device able to retrieve a retrieve a video ROM ? */ 648 /* Does this device able to retrieve a retrieve a video ROM ? */
667 if(video->cap._ROM){ 649 if (video->cap._ROM) {
668 video->flags.rom = 1; 650 video->flags.rom = 1;
669 status = 0; 651 status = 0;
670 } 652 }
671 653
672 /* Does this device able to configure which video device to POST ? */ 654 /* Does this device able to configure which video device to POST ? */
673 if(video->cap._GPD && video->cap._SPD && video->cap._VPO){ 655 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) {
674 video->flags.post = 1; 656 video->flags.post = 1;
675 status = 0; 657 status = 0;
676 } 658 }
@@ -682,16 +664,14 @@ acpi_video_bus_check (
682 FS Interface (/proc) 664 FS Interface (/proc)
683 -------------------------------------------------------------------------- */ 665 -------------------------------------------------------------------------- */
684 666
685static struct proc_dir_entry *acpi_video_dir; 667static struct proc_dir_entry *acpi_video_dir;
686 668
687/* video devices */ 669/* video devices */
688 670
689static int 671static 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{ 672{
694 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 673 struct acpi_video_device *dev =
674 (struct acpi_video_device *)seq->private;
695 675
696 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show"); 676 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
697 677
@@ -709,30 +689,25 @@ acpi_video_device_info_seq_show (
709 else 689 else
710 seq_printf(seq, "UNKNOWN\n"); 690 seq_printf(seq, "UNKNOWN\n");
711 691
712 seq_printf(seq,"known by bios: %s\n", 692 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
713 dev->flags.bios ? "yes":"no");
714 693
715end: 694 end:
716 return_VALUE(0); 695 return_VALUE(0);
717} 696}
718 697
719static int 698static int
720acpi_video_device_info_open_fs ( 699acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
721 struct inode *inode,
722 struct file *file)
723{ 700{
724 return single_open(file, acpi_video_device_info_seq_show, 701 return single_open(file, acpi_video_device_info_seq_show,
725 PDE(inode)->data); 702 PDE(inode)->data);
726} 703}
727 704
728static int 705static 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{ 706{
733 int status; 707 int status;
734 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 708 struct acpi_video_device *dev =
735 unsigned long state; 709 (struct acpi_video_device *)seq->private;
710 unsigned long state;
736 711
737 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show"); 712 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
738 713
@@ -753,31 +728,27 @@ acpi_video_device_state_seq_show (
753 else 728 else
754 seq_printf(seq, "<not supported>\n"); 729 seq_printf(seq, "<not supported>\n");
755 730
756end: 731 end:
757 return_VALUE(0); 732 return_VALUE(0);
758} 733}
759 734
760static int 735static int
761acpi_video_device_state_open_fs ( 736acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
762 struct inode *inode,
763 struct file *file)
764{ 737{
765 return single_open(file, acpi_video_device_state_seq_show, 738 return single_open(file, acpi_video_device_state_seq_show,
766 PDE(inode)->data); 739 PDE(inode)->data);
767} 740}
768 741
769static ssize_t 742static ssize_t
770acpi_video_device_write_state ( 743acpi_video_device_write_state(struct file *file,
771 struct file *file, 744 const char __user * buffer,
772 const char __user *buffer, 745 size_t count, loff_t * data)
773 size_t count,
774 loff_t *data)
775{ 746{
776 int status; 747 int status;
777 struct seq_file *m = (struct seq_file *) file->private_data; 748 struct seq_file *m = (struct seq_file *)file->private_data;
778 struct acpi_video_device *dev = (struct acpi_video_device *) m->private; 749 struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
779 char str[12] = {0}; 750 char str[12] = { 0 };
780 u32 state = 0; 751 u32 state = 0;
781 752
782 ACPI_FUNCTION_TRACE("acpi_video_device_write_state"); 753 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
783 754
@@ -789,7 +760,7 @@ acpi_video_device_write_state (
789 760
790 str[count] = 0; 761 str[count] = 0;
791 state = simple_strtoul(str, NULL, 0); 762 state = simple_strtoul(str, NULL, 0);
792 state &= ((1ul<<31) | (1ul<<30) | (1ul<<0)); 763 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
793 764
794 status = acpi_video_device_set_state(dev, state); 765 status = acpi_video_device_set_state(dev, state);
795 766
@@ -800,12 +771,11 @@ acpi_video_device_write_state (
800} 771}
801 772
802static int 773static int
803acpi_video_device_brightness_seq_show ( 774acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
804 struct seq_file *seq,
805 void *offset)
806{ 775{
807 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 776 struct acpi_video_device *dev =
808 int i; 777 (struct acpi_video_device *)seq->private;
778 int i;
809 779
810 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show"); 780 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
811 781
@@ -823,26 +793,22 @@ acpi_video_device_brightness_seq_show (
823} 793}
824 794
825static int 795static int
826acpi_video_device_brightness_open_fs ( 796acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
827 struct inode *inode,
828 struct file *file)
829{ 797{
830 return single_open(file, acpi_video_device_brightness_seq_show, 798 return single_open(file, acpi_video_device_brightness_seq_show,
831 PDE(inode)->data); 799 PDE(inode)->data);
832} 800}
833 801
834static ssize_t 802static ssize_t
835acpi_video_device_write_brightness ( 803acpi_video_device_write_brightness(struct file *file,
836 struct file *file, 804 const char __user * buffer,
837 const char __user *buffer, 805 size_t count, loff_t * data)
838 size_t count,
839 loff_t *data)
840{ 806{
841 struct seq_file *m = (struct seq_file *) file->private_data; 807 struct seq_file *m = (struct seq_file *)file->private_data;
842 struct acpi_video_device *dev = (struct acpi_video_device *) m->private; 808 struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
843 char str[4] = {0}; 809 char str[4] = { 0 };
844 unsigned int level = 0; 810 unsigned int level = 0;
845 int i; 811 int i;
846 812
847 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
848 814
@@ -854,14 +820,15 @@ acpi_video_device_write_brightness (
854 820
855 str[count] = 0; 821 str[count] = 0;
856 level = simple_strtoul(str, NULL, 0); 822 level = simple_strtoul(str, NULL, 0);
857 823
858 if (level > 100) 824 if (level > 100)
859 return_VALUE(-EFAULT); 825 return_VALUE(-EFAULT);
860 826
861 /* validate though the list of available levels */ 827 /* validate though the list of available levels */
862 for (i = 0; i < dev->brightness->count; i++) 828 for (i = 0; i < dev->brightness->count; i++)
863 if (level == dev->brightness->levels[i]) { 829 if (level == dev->brightness->levels[i]) {
864 if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level))) 830 if (ACPI_SUCCESS
831 (acpi_video_device_lcd_set_level(dev, level)))
865 dev->brightness->curr = level; 832 dev->brightness->curr = level;
866 break; 833 break;
867 } 834 }
@@ -869,24 +836,22 @@ acpi_video_device_write_brightness (
869 return_VALUE(count); 836 return_VALUE(count);
870} 837}
871 838
872static int 839static 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{ 840{
877 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; 841 struct acpi_video_device *dev =
878 int status; 842 (struct acpi_video_device *)seq->private;
879 int i; 843 int status;
880 union acpi_object *edid = NULL; 844 int i;
845 union acpi_object *edid = NULL;
881 846
882 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show"); 847 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
883 848
884 if (!dev) 849 if (!dev)
885 goto out; 850 goto out;
886 851
887 status = acpi_video_device_EDID (dev, &edid, 128); 852 status = acpi_video_device_EDID(dev, &edid, 128);
888 if (ACPI_FAILURE(status)) { 853 if (ACPI_FAILURE(status)) {
889 status = acpi_video_device_EDID (dev, &edid, 256); 854 status = acpi_video_device_EDID(dev, &edid, 256);
890 } 855 }
891 856
892 if (ACPI_FAILURE(status)) { 857 if (ACPI_FAILURE(status)) {
@@ -898,7 +863,7 @@ acpi_video_device_EDID_seq_show (
898 seq_putc(seq, edid->buffer.pointer[i]); 863 seq_putc(seq, edid->buffer.pointer[i]);
899 } 864 }
900 865
901out: 866 out:
902 if (!edid) 867 if (!edid)
903 seq_printf(seq, "<not supported>\n"); 868 seq_printf(seq, "<not supported>\n");
904 else 869 else
@@ -908,20 +873,15 @@ out:
908} 873}
909 874
910static int 875static int
911acpi_video_device_EDID_open_fs ( 876acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
912 struct inode *inode,
913 struct file *file)
914{ 877{
915 return single_open(file, acpi_video_device_EDID_seq_show, 878 return single_open(file, acpi_video_device_EDID_seq_show,
916 PDE(inode)->data); 879 PDE(inode)->data);
917} 880}
918 881
919 882static int acpi_video_device_add_fs(struct acpi_device *device)
920static int
921acpi_video_device_add_fs (
922 struct acpi_device *device)
923{ 883{
924 struct proc_dir_entry *entry = NULL; 884 struct proc_dir_entry *entry = NULL;
925 struct acpi_video_device *vid_dev; 885 struct acpi_video_device *vid_dev;
926 886
927 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs"); 887 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
@@ -929,13 +889,13 @@ acpi_video_device_add_fs (
929 if (!device) 889 if (!device)
930 return_VALUE(-ENODEV); 890 return_VALUE(-ENODEV);
931 891
932 vid_dev = (struct acpi_video_device *) acpi_driver_data(device); 892 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
933 if (!vid_dev) 893 if (!vid_dev)
934 return_VALUE(-ENODEV); 894 return_VALUE(-ENODEV);
935 895
936 if (!acpi_device_dir(device)) { 896 if (!acpi_device_dir(device)) {
937 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 897 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
938 vid_dev->video->dir); 898 vid_dev->video->dir);
939 if (!acpi_device_dir(device)) 899 if (!acpi_device_dir(device))
940 return_VALUE(-ENODEV); 900 return_VALUE(-ENODEV);
941 acpi_device_dir(device)->owner = THIS_MODULE; 901 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -945,7 +905,7 @@ acpi_video_device_add_fs (
945 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 905 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
946 if (!entry) 906 if (!entry)
947 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 907 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
948 "Unable to create 'info' fs entry\n")); 908 "Unable to create 'info' fs entry\n"));
949 else { 909 else {
950 entry->proc_fops = &acpi_video_device_info_fops; 910 entry->proc_fops = &acpi_video_device_info_fops;
951 entry->data = acpi_driver_data(device); 911 entry->data = acpi_driver_data(device);
@@ -953,10 +913,12 @@ acpi_video_device_add_fs (
953 } 913 }
954 914
955 /* 'state' [R/W] */ 915 /* 'state' [R/W] */
956 entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 916 entry =
917 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
918 acpi_device_dir(device));
957 if (!entry) 919 if (!entry)
958 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
959 "Unable to create 'state' fs entry\n")); 921 "Unable to create 'state' fs entry\n"));
960 else { 922 else {
961 entry->proc_fops = &acpi_video_device_state_fops; 923 entry->proc_fops = &acpi_video_device_state_fops;
962 entry->proc_fops->write = acpi_video_device_write_state; 924 entry->proc_fops->write = acpi_video_device_write_state;
@@ -965,10 +927,12 @@ acpi_video_device_add_fs (
965 } 927 }
966 928
967 /* 'brightness' [R/W] */ 929 /* 'brightness' [R/W] */
968 entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 930 entry =
931 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
932 acpi_device_dir(device));
969 if (!entry) 933 if (!entry)
970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
971 "Unable to create 'brightness' fs entry\n")); 935 "Unable to create 'brightness' fs entry\n"));
972 else { 936 else {
973 entry->proc_fops = &acpi_video_device_brightness_fops; 937 entry->proc_fops = &acpi_video_device_brightness_fops;
974 entry->proc_fops->write = acpi_video_device_write_brightness; 938 entry->proc_fops->write = acpi_video_device_write_brightness;
@@ -980,7 +944,7 @@ acpi_video_device_add_fs (
980 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); 944 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
981 if (!entry) 945 if (!entry)
982 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 946 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
983 "Unable to create 'brightness' fs entry\n")); 947 "Unable to create 'brightness' fs entry\n"));
984 else { 948 else {
985 entry->proc_fops = &acpi_video_device_EDID_fops; 949 entry->proc_fops = &acpi_video_device_EDID_fops;
986 entry->data = acpi_driver_data(device); 950 entry->data = acpi_driver_data(device);
@@ -990,14 +954,12 @@ acpi_video_device_add_fs (
990 return_VALUE(0); 954 return_VALUE(0);
991} 955}
992 956
993static int 957static int acpi_video_device_remove_fs(struct acpi_device *device)
994acpi_video_device_remove_fs (
995 struct acpi_device *device)
996{ 958{
997 struct acpi_video_device *vid_dev; 959 struct acpi_video_device *vid_dev;
998 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs"); 960 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
999 961
1000 vid_dev = (struct acpi_video_device *) acpi_driver_data(device); 962 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
1001 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) 963 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1002 return_VALUE(-ENODEV); 964 return_VALUE(-ENODEV);
1003 965
@@ -1006,22 +968,17 @@ acpi_video_device_remove_fs (
1006 remove_proc_entry("state", acpi_device_dir(device)); 968 remove_proc_entry("state", acpi_device_dir(device));
1007 remove_proc_entry("brightness", acpi_device_dir(device)); 969 remove_proc_entry("brightness", acpi_device_dir(device));
1008 remove_proc_entry("EDID", acpi_device_dir(device)); 970 remove_proc_entry("EDID", acpi_device_dir(device));
1009 remove_proc_entry(acpi_device_bid(device), 971 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1010 vid_dev->video->dir);
1011 acpi_device_dir(device) = NULL; 972 acpi_device_dir(device) = NULL;
1012 } 973 }
1013 974
1014 return_VALUE(0); 975 return_VALUE(0);
1015} 976}
1016 977
1017
1018/* video bus */ 978/* video bus */
1019static int 979static 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{ 980{
1024 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 981 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1025 982
1026 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show"); 983 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
1027 984
@@ -1029,30 +986,25 @@ acpi_video_bus_info_seq_show (
1029 goto end; 986 goto end;
1030 987
1031 seq_printf(seq, "Switching heads: %s\n", 988 seq_printf(seq, "Switching heads: %s\n",
1032 video->flags.multihead ? "yes":"no"); 989 video->flags.multihead ? "yes" : "no");
1033 seq_printf(seq, "Video ROM: %s\n", 990 seq_printf(seq, "Video ROM: %s\n",
1034 video->flags.rom ? "yes":"no"); 991 video->flags.rom ? "yes" : "no");
1035 seq_printf(seq, "Device to be POSTed on boot: %s\n", 992 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1036 video->flags.post ? "yes":"no"); 993 video->flags.post ? "yes" : "no");
1037 994
1038end: 995 end:
1039 return_VALUE(0); 996 return_VALUE(0);
1040} 997}
1041 998
1042static int 999static 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{ 1000{
1047 return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data); 1001 return single_open(file, acpi_video_bus_info_seq_show,
1002 PDE(inode)->data);
1048} 1003}
1049 1004
1050static int 1005static 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{ 1006{
1055 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1007 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1056 1008
1057 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show"); 1009 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1058 1010
@@ -1062,26 +1014,20 @@ acpi_video_bus_ROM_seq_show (
1062 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__); 1014 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1063 seq_printf(seq, "<TODO>\n"); 1015 seq_printf(seq, "<TODO>\n");
1064 1016
1065end: 1017 end:
1066 return_VALUE(0); 1018 return_VALUE(0);
1067} 1019}
1068 1020
1069static int 1021static 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{ 1022{
1074 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data); 1023 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1075} 1024}
1076 1025
1077static int 1026static 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{ 1027{
1082 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1028 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1083 unsigned long options; 1029 unsigned long options;
1084 int status; 1030 int status;
1085 1031
1086 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show"); 1032 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1087 1033
@@ -1091,8 +1037,10 @@ acpi_video_bus_POST_info_seq_show (
1091 status = acpi_video_bus_POST_options(video, &options); 1037 status = acpi_video_bus_POST_options(video, &options);
1092 if (ACPI_SUCCESS(status)) { 1038 if (ACPI_SUCCESS(status)) {
1093 if (!(options & 1)) { 1039 if (!(options & 1)) {
1094 printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n"); 1040 printk(KERN_WARNING PREFIX
1095 printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n"); 1041 "The motherboard VGA device is not listed as a possible POST device.\n");
1042 printk(KERN_WARNING PREFIX
1043 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1096 } 1044 }
1097 printk("%lx\n", options); 1045 printk("%lx\n", options);
1098 seq_printf(seq, "can POST: <intgrated video>"); 1046 seq_printf(seq, "can POST: <intgrated video>");
@@ -1103,89 +1051,74 @@ acpi_video_bus_POST_info_seq_show (
1103 seq_putc(seq, '\n'); 1051 seq_putc(seq, '\n');
1104 } else 1052 } else
1105 seq_printf(seq, "<not supported>\n"); 1053 seq_printf(seq, "<not supported>\n");
1106end: 1054 end:
1107 return_VALUE(0); 1055 return_VALUE(0);
1108} 1056}
1109 1057
1110static int 1058static int
1111acpi_video_bus_POST_info_open_fs ( 1059acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1112 struct inode *inode,
1113 struct file *file)
1114{ 1060{
1115 return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data); 1061 return single_open(file, acpi_video_bus_POST_info_seq_show,
1062 PDE(inode)->data);
1116} 1063}
1117 1064
1118static int 1065static 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{ 1066{
1123 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1067 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1124 int status; 1068 int status;
1125 unsigned long id; 1069 unsigned long id;
1126 1070
1127 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show"); 1071 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1128 1072
1129 if (!video) 1073 if (!video)
1130 goto end; 1074 goto end;
1131 1075
1132 status = acpi_video_bus_get_POST (video, &id); 1076 status = acpi_video_bus_get_POST(video, &id);
1133 if (!ACPI_SUCCESS(status)) { 1077 if (!ACPI_SUCCESS(status)) {
1134 seq_printf(seq, "<not supported>\n"); 1078 seq_printf(seq, "<not supported>\n");
1135 goto end; 1079 goto end;
1136 } 1080 }
1137 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); 1081 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1138 1082
1139end: 1083 end:
1140 return_VALUE(0); 1084 return_VALUE(0);
1141} 1085}
1142 1086
1143static int 1087static 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{ 1088{
1148 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; 1089 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1149 1090
1150 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show"); 1091 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1151 1092
1152 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting ); 1093 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1153 1094
1154 return_VALUE(0); 1095 return_VALUE(0);
1155} 1096}
1156 1097
1157static int 1098static 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{ 1099{
1162 return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data); 1100 return single_open(file, acpi_video_bus_POST_seq_show,
1101 PDE(inode)->data);
1163} 1102}
1164 1103
1165static int 1104static 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{ 1105{
1170 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data); 1106 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1171} 1107}
1172 1108
1173static ssize_t 1109static ssize_t
1174acpi_video_bus_write_POST ( 1110acpi_video_bus_write_POST(struct file *file,
1175 struct file *file, 1111 const char __user * buffer,
1176 const char __user *buffer, 1112 size_t count, loff_t * data)
1177 size_t count,
1178 loff_t *data)
1179{ 1113{
1180 int status; 1114 int status;
1181 struct seq_file *m = (struct seq_file *) file->private_data; 1115 struct seq_file *m = (struct seq_file *)file->private_data;
1182 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; 1116 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
1183 char str[12] = {0}; 1117 char str[12] = { 0 };
1184 unsigned long opt, options; 1118 unsigned long opt, options;
1185 1119
1186 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST"); 1120 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1187 1121
1188
1189 if (!video || count + 1 > sizeof str) 1122 if (!video || count + 1 > sizeof str)
1190 return_VALUE(-EINVAL); 1123 return_VALUE(-EINVAL);
1191 1124
@@ -1205,32 +1138,28 @@ acpi_video_bus_write_POST (
1205 options |= 1; 1138 options |= 1;
1206 1139
1207 if (options & (1ul << opt)) { 1140 if (options & (1ul << opt)) {
1208 status = acpi_video_bus_set_POST (video, opt); 1141 status = acpi_video_bus_set_POST(video, opt);
1209 if (!ACPI_SUCCESS(status)) 1142 if (!ACPI_SUCCESS(status))
1210 return_VALUE(-EFAULT); 1143 return_VALUE(-EFAULT);
1211 1144
1212 } 1145 }
1213 1146
1214
1215 return_VALUE(count); 1147 return_VALUE(count);
1216} 1148}
1217 1149
1218static ssize_t 1150static ssize_t
1219acpi_video_bus_write_DOS ( 1151acpi_video_bus_write_DOS(struct file *file,
1220 struct file *file, 1152 const char __user * buffer,
1221 const char __user *buffer, 1153 size_t count, loff_t * data)
1222 size_t count,
1223 loff_t *data)
1224{ 1154{
1225 int status; 1155 int status;
1226 struct seq_file *m = (struct seq_file *) file->private_data; 1156 struct seq_file *m = (struct seq_file *)file->private_data;
1227 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; 1157 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
1228 char str[12] = {0}; 1158 char str[12] = { 0 };
1229 unsigned long opt; 1159 unsigned long opt;
1230 1160
1231 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS"); 1161 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1232 1162
1233
1234 if (!video || count + 1 > sizeof str) 1163 if (!video || count + 1 > sizeof str)
1235 return_VALUE(-EINVAL); 1164 return_VALUE(-EINVAL);
1236 1165
@@ -1242,7 +1171,7 @@ acpi_video_bus_write_DOS (
1242 if (opt > 7) 1171 if (opt > 7)
1243 return_VALUE(-EFAULT); 1172 return_VALUE(-EFAULT);
1244 1173
1245 status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2); 1174 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1246 1175
1247 if (!ACPI_SUCCESS(status)) 1176 if (!ACPI_SUCCESS(status))
1248 return_VALUE(-EFAULT); 1177 return_VALUE(-EFAULT);
@@ -1250,20 +1179,18 @@ acpi_video_bus_write_DOS (
1250 return_VALUE(count); 1179 return_VALUE(count);
1251} 1180}
1252 1181
1253static int 1182static int acpi_video_bus_add_fs(struct acpi_device *device)
1254acpi_video_bus_add_fs (
1255 struct acpi_device *device)
1256{ 1183{
1257 struct proc_dir_entry *entry = NULL; 1184 struct proc_dir_entry *entry = NULL;
1258 struct acpi_video_bus *video; 1185 struct acpi_video_bus *video;
1259 1186
1260 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs"); 1187 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1261 1188
1262 video = (struct acpi_video_bus *) acpi_driver_data(device); 1189 video = (struct acpi_video_bus *)acpi_driver_data(device);
1263 1190
1264 if (!acpi_device_dir(device)) { 1191 if (!acpi_device_dir(device)) {
1265 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1192 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1266 acpi_video_dir); 1193 acpi_video_dir);
1267 if (!acpi_device_dir(device)) 1194 if (!acpi_device_dir(device))
1268 return_VALUE(-ENODEV); 1195 return_VALUE(-ENODEV);
1269 video->dir = acpi_device_dir(device); 1196 video->dir = acpi_device_dir(device);
@@ -1273,7 +1200,8 @@ acpi_video_bus_add_fs (
1273 /* 'info' [R] */ 1200 /* 'info' [R] */
1274 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 1201 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1275 if (!entry) 1202 if (!entry)
1276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n")); 1203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1204 "Unable to create 'info' fs entry\n"));
1277 else { 1205 else {
1278 entry->proc_fops = &acpi_video_bus_info_fops; 1206 entry->proc_fops = &acpi_video_bus_info_fops;
1279 entry->data = acpi_driver_data(device); 1207 entry->data = acpi_driver_data(device);
@@ -1283,7 +1211,8 @@ acpi_video_bus_add_fs (
1283 /* 'ROM' [R] */ 1211 /* 'ROM' [R] */
1284 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); 1212 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1285 if (!entry) 1213 if (!entry)
1286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n")); 1214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1215 "Unable to create 'ROM' fs entry\n"));
1287 else { 1216 else {
1288 entry->proc_fops = &acpi_video_bus_ROM_fops; 1217 entry->proc_fops = &acpi_video_bus_ROM_fops;
1289 entry->data = acpi_driver_data(device); 1218 entry->data = acpi_driver_data(device);
@@ -1291,9 +1220,11 @@ acpi_video_bus_add_fs (
1291 } 1220 }
1292 1221
1293 /* 'POST_info' [R] */ 1222 /* 'POST_info' [R] */
1294 entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); 1223 entry =
1224 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1295 if (!entry) 1225 if (!entry)
1296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n")); 1226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1227 "Unable to create 'POST_info' fs entry\n"));
1297 else { 1228 else {
1298 entry->proc_fops = &acpi_video_bus_POST_info_fops; 1229 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1299 entry->data = acpi_driver_data(device); 1230 entry->data = acpi_driver_data(device);
@@ -1301,9 +1232,12 @@ acpi_video_bus_add_fs (
1301 } 1232 }
1302 1233
1303 /* 'POST' [R/W] */ 1234 /* 'POST' [R/W] */
1304 entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); 1235 entry =
1236 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1237 acpi_device_dir(device));
1305 if (!entry) 1238 if (!entry)
1306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n")); 1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1240 "Unable to create 'POST' fs entry\n"));
1307 else { 1241 else {
1308 entry->proc_fops = &acpi_video_bus_POST_fops; 1242 entry->proc_fops = &acpi_video_bus_POST_fops;
1309 entry->proc_fops->write = acpi_video_bus_write_POST; 1243 entry->proc_fops->write = acpi_video_bus_write_POST;
@@ -1312,9 +1246,12 @@ acpi_video_bus_add_fs (
1312 } 1246 }
1313 1247
1314 /* 'DOS' [R/W] */ 1248 /* 'DOS' [R/W] */
1315 entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); 1249 entry =
1250 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1251 acpi_device_dir(device));
1316 if (!entry) 1252 if (!entry)
1317 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n")); 1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1254 "Unable to create 'DOS' fs entry\n"));
1318 else { 1255 else {
1319 entry->proc_fops = &acpi_video_bus_DOS_fops; 1256 entry->proc_fops = &acpi_video_bus_DOS_fops;
1320 entry->proc_fops->write = acpi_video_bus_write_DOS; 1257 entry->proc_fops->write = acpi_video_bus_write_DOS;
@@ -1325,15 +1262,13 @@ acpi_video_bus_add_fs (
1325 return_VALUE(0); 1262 return_VALUE(0);
1326} 1263}
1327 1264
1328static int 1265static int acpi_video_bus_remove_fs(struct acpi_device *device)
1329acpi_video_bus_remove_fs (
1330 struct acpi_device *device)
1331{ 1266{
1332 struct acpi_video_bus *video; 1267 struct acpi_video_bus *video;
1333 1268
1334 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs"); 1269 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1335 1270
1336 video = (struct acpi_video_bus *) acpi_driver_data(device); 1271 video = (struct acpi_video_bus *)acpi_driver_data(device);
1337 1272
1338 if (acpi_device_dir(device)) { 1273 if (acpi_device_dir(device)) {
1339 remove_proc_entry("info", acpi_device_dir(device)); 1274 remove_proc_entry("info", acpi_device_dir(device));
@@ -1341,8 +1276,7 @@ acpi_video_bus_remove_fs (
1341 remove_proc_entry("POST_info", acpi_device_dir(device)); 1276 remove_proc_entry("POST_info", acpi_device_dir(device));
1342 remove_proc_entry("POST", acpi_device_dir(device)); 1277 remove_proc_entry("POST", acpi_device_dir(device));
1343 remove_proc_entry("DOS", acpi_device_dir(device)); 1278 remove_proc_entry("DOS", acpi_device_dir(device));
1344 remove_proc_entry(acpi_device_bid(device), 1279 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1345 acpi_video_dir);
1346 acpi_device_dir(device) = NULL; 1280 acpi_device_dir(device) = NULL;
1347 } 1281 }
1348 1282
@@ -1356,20 +1290,20 @@ acpi_video_bus_remove_fs (
1356/* device interface */ 1290/* device interface */
1357 1291
1358static int 1292static int
1359acpi_video_bus_get_one_device ( 1293acpi_video_bus_get_one_device(struct acpi_device *device,
1360 struct acpi_device *device, 1294 struct acpi_video_bus *video)
1361 struct acpi_video_bus *video)
1362{ 1295{
1363 unsigned long device_id; 1296 unsigned long device_id;
1364 int status, result; 1297 int status, result;
1365 struct acpi_video_device *data; 1298 struct acpi_video_device *data;
1366 1299
1367 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); 1300 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1368 1301
1369 if (!device || !video) 1302 if (!device || !video)
1370 return_VALUE(-EINVAL); 1303 return_VALUE(-EINVAL);
1371 1304
1372 status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); 1305 status =
1306 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1373 if (ACPI_SUCCESS(status)) { 1307 if (ACPI_SUCCESS(status)) {
1374 1308
1375 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); 1309 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
@@ -1401,15 +1335,17 @@ acpi_video_bus_get_one_device (
1401 data->flags.unknown = 1; 1335 data->flags.unknown = 1;
1402 break; 1336 break;
1403 } 1337 }
1404 1338
1405 acpi_video_device_bind(video, data); 1339 acpi_video_device_bind(video, data);
1406 acpi_video_device_find_cap(data); 1340 acpi_video_device_find_cap(data);
1407 1341
1408 status = acpi_install_notify_handler(data->handle, 1342 status = acpi_install_notify_handler(data->handle,
1409 ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data); 1343 ACPI_DEVICE_NOTIFY,
1344 acpi_video_device_notify,
1345 data);
1410 if (ACPI_FAILURE(status)) { 1346 if (ACPI_FAILURE(status)) {
1411 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1347 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1412 "Error installing notify handler\n")); 1348 "Error installing notify handler\n"));
1413 result = -ENODEV; 1349 result = -ENODEV;
1414 goto end; 1350 goto end;
1415 } 1351 }
@@ -1423,7 +1359,7 @@ acpi_video_bus_get_one_device (
1423 return_VALUE(0); 1359 return_VALUE(0);
1424 } 1360 }
1425 1361
1426end: 1362 end:
1427 return_VALUE(-ENOENT); 1363 return_VALUE(-ENOENT);
1428} 1364}
1429 1365
@@ -1437,15 +1373,15 @@ end:
1437 * Enumerate the video device list of the video bus, 1373 * Enumerate the video device list of the video bus,
1438 * bind the ids with the corresponding video devices 1374 * bind the ids with the corresponding video devices
1439 * under the video bus. 1375 * under the video bus.
1440 */ 1376 */
1441 1377
1442static void 1378static void acpi_video_device_rebind(struct acpi_video_bus *video)
1443acpi_video_device_rebind( struct acpi_video_bus *video)
1444{ 1379{
1445 struct list_head * node, * next; 1380 struct list_head *node, *next;
1446 list_for_each_safe(node, next, &video->video_device_list) { 1381 list_for_each_safe(node, next, &video->video_device_list) {
1447 struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry); 1382 struct acpi_video_device *dev =
1448 acpi_video_device_bind( video, dev); 1383 container_of(node, struct acpi_video_device, entry);
1384 acpi_video_device_bind(video, dev);
1449 } 1385 }
1450} 1386}
1451 1387
@@ -1460,21 +1396,21 @@ acpi_video_device_rebind( struct acpi_video_bus *video)
1460 * 1396 *
1461 * Bind the ids with the corresponding video devices 1397 * Bind the ids with the corresponding video devices
1462 * under the video bus. 1398 * under the video bus.
1463 */ 1399 */
1464 1400
1465static void 1401static void
1466acpi_video_device_bind( struct acpi_video_bus *video, 1402acpi_video_device_bind(struct acpi_video_bus *video,
1467 struct acpi_video_device *device) 1403 struct acpi_video_device *device)
1468{ 1404{
1469 int i; 1405 int i;
1470 ACPI_FUNCTION_TRACE("acpi_video_device_bind"); 1406 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1471 1407
1472#define IDS_VAL(i) video->attached_array[i].value.int_val 1408#define IDS_VAL(i) video->attached_array[i].value.int_val
1473#define IDS_BIND(i) video->attached_array[i].bind_info 1409#define IDS_BIND(i) video->attached_array[i].bind_info
1474 1410
1475 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && 1411 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1476 i < video->attached_count; i++) { 1412 i < video->attached_count; i++) {
1477 if (device->device_id == (IDS_VAL(i)& 0xffff)) { 1413 if (device->device_id == (IDS_VAL(i) & 0xffff)) {
1478 IDS_BIND(i) = device; 1414 IDS_BIND(i) = device;
1479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i)); 1415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1480 } 1416 }
@@ -1492,17 +1428,17 @@ acpi_video_device_bind( struct acpi_video_bus *video,
1492 * 1428 *
1493 * Call _DOD to enumerate all devices attached to display adapter 1429 * Call _DOD to enumerate all devices attached to display adapter
1494 * 1430 *
1495 */ 1431 */
1496 1432
1497static int acpi_video_device_enumerate(struct acpi_video_bus *video) 1433static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1498{ 1434{
1499 int status; 1435 int status;
1500 int count; 1436 int count;
1501 int i; 1437 int i;
1502 struct acpi_video_enumerated_device *active_device_list; 1438 struct acpi_video_enumerated_device *active_device_list;
1503 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 1439 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1504 union acpi_object *dod = NULL; 1440 union acpi_object *dod = NULL;
1505 union acpi_object *obj; 1441 union acpi_object *obj;
1506 1442
1507 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate"); 1443 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1508 1444
@@ -1512,7 +1448,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1512 return_VALUE(status); 1448 return_VALUE(status);
1513 } 1449 }
1514 1450
1515 dod = (union acpi_object *) buffer.pointer; 1451 dod = (union acpi_object *)buffer.pointer;
1516 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { 1452 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1517 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1453 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
1518 status = -EFAULT; 1454 status = -EFAULT;
@@ -1520,11 +1456,13 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1520 } 1456 }
1521 1457
1522 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n", 1458 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1523 dod->package.count)); 1459 dod->package.count));
1524 1460
1525 active_device_list= kmalloc( 1461 active_device_list = kmalloc((1 +
1526 (1+dod->package.count)*sizeof(struct acpi_video_enumerated_device), 1462 dod->package.count) *
1527 GFP_KERNEL); 1463 sizeof(struct
1464 acpi_video_enumerated_device),
1465 GFP_KERNEL);
1528 1466
1529 if (!active_device_list) { 1467 if (!active_device_list) {
1530 status = -ENOMEM; 1468 status = -ENOMEM;
@@ -1533,25 +1471,28 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1533 1471
1534 count = 0; 1472 count = 0;
1535 for (i = 0; i < dod->package.count; i++) { 1473 for (i = 0; i < dod->package.count; i++) {
1536 obj = (union acpi_object *) &dod->package.elements[i]; 1474 obj = (union acpi_object *)&dod->package.elements[i];
1537 1475
1538 if (obj->type != ACPI_TYPE_INTEGER) { 1476 if (obj->type != ACPI_TYPE_INTEGER) {
1539 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1477 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1540 active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID; 1478 "Invalid _DOD data\n"));
1479 active_device_list[i].value.int_val =
1480 ACPI_VIDEO_HEAD_INVALID;
1541 } 1481 }
1542 active_device_list[i].value.int_val = obj->integer.value; 1482 active_device_list[i].value.int_val = obj->integer.value;
1543 active_device_list[i].bind_info = NULL; 1483 active_device_list[i].bind_info = NULL;
1544 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value)); 1484 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
1485 (int)obj->integer.value));
1545 count++; 1486 count++;
1546 } 1487 }
1547 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; 1488 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1548 1489
1549 if(video->attached_array) 1490 if (video->attached_array)
1550 kfree(video->attached_array); 1491 kfree(video->attached_array);
1551 1492
1552 video->attached_array = active_device_list; 1493 video->attached_array = active_device_list;
1553 video->attached_count = count; 1494 video->attached_count = count;
1554out: 1495 out:
1555 acpi_os_free(buffer.pointer); 1496 acpi_os_free(buffer.pointer);
1556 return_VALUE(status); 1497 return_VALUE(status);
1557} 1498}
@@ -1567,17 +1508,14 @@ out:
1567 * 1. Find out the current active output device. 1508 * 1. Find out the current active output device.
1568 * 2. Identify the next output device to switch 1509 * 2. Identify the next output device to switch
1569 * 3. call _DSS to do actual switch. 1510 * 3. call _DSS to do actual switch.
1570 */ 1511 */
1571 1512
1572static int 1513static 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{ 1514{
1577 struct list_head * node, * next; 1515 struct list_head *node, *next;
1578 struct acpi_video_device *dev=NULL; 1516 struct acpi_video_device *dev = NULL;
1579 struct acpi_video_device *dev_next=NULL; 1517 struct acpi_video_device *dev_next = NULL;
1580 struct acpi_video_device *dev_prev=NULL; 1518 struct acpi_video_device *dev_prev = NULL;
1581 unsigned long state; 1519 unsigned long state;
1582 int status = 0; 1520 int status = 0;
1583 1521
@@ -1586,15 +1524,19 @@ acpi_video_switch_output(
1586 list_for_each_safe(node, next, &video->video_device_list) { 1524 list_for_each_safe(node, next, &video->video_device_list) {
1587 dev = container_of(node, struct acpi_video_device, entry); 1525 dev = container_of(node, struct acpi_video_device, entry);
1588 status = acpi_video_device_get_state(dev, &state); 1526 status = acpi_video_device_get_state(dev, &state);
1589 if (state & 0x2){ 1527 if (state & 0x2) {
1590 dev_next = container_of(node->next, struct acpi_video_device, entry); 1528 dev_next =
1591 dev_prev = container_of(node->prev, struct acpi_video_device, entry); 1529 container_of(node->next, struct acpi_video_device,
1530 entry);
1531 dev_prev =
1532 container_of(node->prev, struct acpi_video_device,
1533 entry);
1592 goto out; 1534 goto out;
1593 } 1535 }
1594 } 1536 }
1595 dev_next = container_of(node->next, struct acpi_video_device, entry); 1537 dev_next = container_of(node->next, struct acpi_video_device, entry);
1596 dev_prev = container_of(node->prev, struct acpi_video_device, entry); 1538 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1597out: 1539 out:
1598 switch (event) { 1540 switch (event) {
1599 case ACPI_VIDEO_NOTIFY_CYCLE: 1541 case ACPI_VIDEO_NOTIFY_CYCLE:
1600 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: 1542 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
@@ -1611,21 +1553,16 @@ out:
1611 return_VALUE(status); 1553 return_VALUE(status);
1612} 1554}
1613 1555
1614static int 1556static int
1615acpi_video_get_next_level( 1557acpi_video_get_next_level(struct acpi_video_device *device,
1616 struct acpi_video_device *device, 1558 u32 level_current, u32 event)
1617 u32 level_current,
1618 u32 event)
1619{ 1559{
1620 /*Fix me*/ 1560 /*Fix me */
1621 return level_current; 1561 return level_current;
1622} 1562}
1623 1563
1624
1625static void 1564static void
1626acpi_video_switch_brightness ( 1565acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1627 struct acpi_video_device *device,
1628 int event)
1629{ 1566{
1630 unsigned long level_current, level_next; 1567 unsigned long level_current, level_next;
1631 acpi_video_device_lcd_get_level_current(device, &level_current); 1568 acpi_video_device_lcd_get_level_current(device, &level_current);
@@ -1634,26 +1571,27 @@ acpi_video_switch_brightness (
1634} 1571}
1635 1572
1636static int 1573static int
1637acpi_video_bus_get_devices ( 1574acpi_video_bus_get_devices(struct acpi_video_bus *video,
1638 struct acpi_video_bus *video, 1575 struct acpi_device *device)
1639 struct acpi_device *device)
1640{ 1576{
1641 int status = 0; 1577 int status = 0;
1642 struct list_head *node, *next; 1578 struct list_head *node, *next;
1643 1579
1644 ACPI_FUNCTION_TRACE("acpi_video_get_devices"); 1580 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1645 1581
1646 acpi_video_device_enumerate(video); 1582 acpi_video_device_enumerate(video);
1647 1583
1648 list_for_each_safe(node, next, &device->children) { 1584 list_for_each_safe(node, next, &device->children) {
1649 struct acpi_device *dev = list_entry(node, struct acpi_device, node); 1585 struct acpi_device *dev =
1586 list_entry(node, struct acpi_device, node);
1650 1587
1651 if (!dev) 1588 if (!dev)
1652 continue; 1589 continue;
1653 1590
1654 status = acpi_video_bus_get_one_device(dev, video); 1591 status = acpi_video_bus_get_one_device(dev, video);
1655 if (ACPI_FAILURE(status)) { 1592 if (ACPI_FAILURE(status)) {
1656 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n")); 1593 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1594 "Cant attach device\n"));
1657 continue; 1595 continue;
1658 } 1596 }
1659 1597
@@ -1661,9 +1599,7 @@ acpi_video_bus_get_devices (
1661 return_VALUE(status); 1599 return_VALUE(status);
1662} 1600}
1663 1601
1664static int 1602static 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{ 1603{
1668 acpi_status status; 1604 acpi_status status;
1669 struct acpi_video_bus *video; 1605 struct acpi_video_bus *video;
@@ -1681,31 +1617,32 @@ acpi_video_bus_put_one_device(
1681 acpi_video_device_remove_fs(device->dev); 1617 acpi_video_device_remove_fs(device->dev);
1682 1618
1683 status = acpi_remove_notify_handler(device->handle, 1619 status = acpi_remove_notify_handler(device->handle,
1684 ACPI_DEVICE_NOTIFY, acpi_video_device_notify); 1620 ACPI_DEVICE_NOTIFY,
1621 acpi_video_device_notify);
1685 if (ACPI_FAILURE(status)) 1622 if (ACPI_FAILURE(status))
1686 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1623 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1687 "Error removing notify handler\n")); 1624 "Error removing notify handler\n"));
1688 1625
1689 return_VALUE(0); 1626 return_VALUE(0);
1690} 1627}
1691 1628
1692static int 1629static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1693acpi_video_bus_put_devices (
1694 struct acpi_video_bus *video)
1695{ 1630{
1696 int status; 1631 int status;
1697 struct list_head *node, *next; 1632 struct list_head *node, *next;
1698 1633
1699 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices"); 1634 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1700 1635
1701 list_for_each_safe(node, next, &video->video_device_list) { 1636 list_for_each_safe(node, next, &video->video_device_list) {
1702 struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry); 1637 struct acpi_video_device *data =
1638 list_entry(node, struct acpi_video_device, entry);
1703 if (!data) 1639 if (!data)
1704 continue; 1640 continue;
1705 1641
1706 status = acpi_video_bus_put_one_device(data); 1642 status = acpi_video_bus_put_one_device(data);
1707 if(ACPI_FAILURE(status)) 1643 if (ACPI_FAILURE(status))
1708 printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); 1644 printk(KERN_WARNING PREFIX
1645 "hhuuhhuu bug in acpi video driver.\n");
1709 1646
1710 if (data->brightness) 1647 if (data->brightness)
1711 kfree(data->brightness); 1648 kfree(data->brightness);
@@ -1718,28 +1655,20 @@ acpi_video_bus_put_devices (
1718 1655
1719/* acpi_video interface */ 1656/* acpi_video interface */
1720 1657
1721static int 1658static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1722acpi_video_bus_start_devices(
1723 struct acpi_video_bus *video)
1724{ 1659{
1725 return acpi_video_bus_DOS(video, 1, 0); 1660 return acpi_video_bus_DOS(video, 1, 0);
1726} 1661}
1727 1662
1728static int 1663static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1729acpi_video_bus_stop_devices(
1730 struct acpi_video_bus *video)
1731{ 1664{
1732 return acpi_video_bus_DOS(video, 0, 1); 1665 return acpi_video_bus_DOS(video, 0, 1);
1733} 1666}
1734 1667
1735static void 1668static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1736acpi_video_bus_notify (
1737 acpi_handle handle,
1738 u32 event,
1739 void *data)
1740{ 1669{
1741 struct acpi_video_bus *video = (struct acpi_video_bus *) data; 1670 struct acpi_video_bus *video = (struct acpi_video_bus *)data;
1742 struct acpi_device *device = NULL; 1671 struct acpi_device *device = NULL;
1743 1672
1744 ACPI_FUNCTION_TRACE("acpi_video_bus_notify"); 1673 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1745 printk("video bus notify\n"); 1674 printk("video bus notify\n");
@@ -1764,30 +1693,27 @@ acpi_video_bus_notify (
1764 acpi_bus_generate_event(device, event, 0); 1693 acpi_bus_generate_event(device, event, 0);
1765 break; 1694 break;
1766 1695
1767 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/ 1696 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1768 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ 1697 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1769 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ 1698 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1770 acpi_video_switch_output(video, event); 1699 acpi_video_switch_output(video, event);
1771 acpi_bus_generate_event(device, event, 0); 1700 acpi_bus_generate_event(device, event, 0);
1772 break; 1701 break;
1773 1702
1774 default: 1703 default:
1775 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1704 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1776 "Unsupported event [0x%x]\n", event)); 1705 "Unsupported event [0x%x]\n", event));
1777 break; 1706 break;
1778 } 1707 }
1779 1708
1780 return_VOID; 1709 return_VOID;
1781} 1710}
1782 1711
1783static void 1712static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1784acpi_video_device_notify (
1785 acpi_handle handle,
1786 u32 event,
1787 void *data)
1788{ 1713{
1789 struct acpi_video_device *video_device = (struct acpi_video_device *) data; 1714 struct acpi_video_device *video_device =
1790 struct acpi_device *device = NULL; 1715 (struct acpi_video_device *)data;
1716 struct acpi_device *device = NULL;
1791 1717
1792 ACPI_FUNCTION_TRACE("acpi_video_device_notify"); 1718 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1793 1719
@@ -1799,36 +1725,34 @@ acpi_video_device_notify (
1799 return_VOID; 1725 return_VOID;
1800 1726
1801 switch (event) { 1727 switch (event) {
1802 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ 1728 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1803 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */ 1729 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1804 acpi_bus_generate_event(device, event, 0); 1730 acpi_bus_generate_event(device, event, 0);
1805 break; 1731 break;
1806 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ 1732 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1807 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ 1733 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1808 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ 1734 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1809 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ 1735 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1810 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ 1736 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1811 acpi_video_switch_brightness (video_device, event); 1737 acpi_video_switch_brightness(video_device, event);
1812 acpi_bus_generate_event(device, event, 0); 1738 acpi_bus_generate_event(device, event, 0);
1813 break; 1739 break;
1814 default: 1740 default:
1815 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1741 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1816 "Unsupported event [0x%x]\n", event)); 1742 "Unsupported event [0x%x]\n", event));
1817 break; 1743 break;
1818 } 1744 }
1819 return_VOID; 1745 return_VOID;
1820} 1746}
1821 1747
1822static int 1748static int acpi_video_bus_add(struct acpi_device *device)
1823acpi_video_bus_add (
1824 struct acpi_device *device)
1825{ 1749{
1826 int result = 0; 1750 int result = 0;
1827 acpi_status status = 0; 1751 acpi_status status = 0;
1828 struct acpi_video_bus *video = NULL; 1752 struct acpi_video_bus *video = NULL;
1829 1753
1830 ACPI_FUNCTION_TRACE("acpi_video_bus_add"); 1754 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1831 1755
1832 if (!device) 1756 if (!device)
1833 return_VALUE(-EINVAL); 1757 return_VALUE(-EINVAL);
1834 1758
@@ -1858,21 +1782,22 @@ acpi_video_bus_add (
1858 acpi_video_bus_start_devices(video); 1782 acpi_video_bus_start_devices(video);
1859 1783
1860 status = acpi_install_notify_handler(video->handle, 1784 status = acpi_install_notify_handler(video->handle,
1861 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video); 1785 ACPI_DEVICE_NOTIFY,
1786 acpi_video_bus_notify, video);
1862 if (ACPI_FAILURE(status)) { 1787 if (ACPI_FAILURE(status)) {
1863 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1788 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1864 "Error installing notify handler\n")); 1789 "Error installing notify handler\n"));
1865 result = -ENODEV; 1790 result = -ENODEV;
1866 goto end; 1791 goto end;
1867 } 1792 }
1868 1793
1869 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1794 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1870 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1795 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1871 video->flags.multihead ? "yes":"no", 1796 video->flags.multihead ? "yes" : "no",
1872 video->flags.rom ? "yes":"no", 1797 video->flags.rom ? "yes" : "no",
1873 video->flags.post ? "yes":"no"); 1798 video->flags.post ? "yes" : "no");
1874 1799
1875end: 1800 end:
1876 if (result) { 1801 if (result) {
1877 acpi_video_bus_remove_fs(device); 1802 acpi_video_bus_remove_fs(device);
1878 kfree(video); 1803 kfree(video);
@@ -1881,28 +1806,26 @@ end:
1881 return_VALUE(result); 1806 return_VALUE(result);
1882} 1807}
1883 1808
1884static int 1809static int acpi_video_bus_remove(struct acpi_device *device, int type)
1885acpi_video_bus_remove (
1886 struct acpi_device *device,
1887 int type)
1888{ 1810{
1889 acpi_status status = 0; 1811 acpi_status status = 0;
1890 struct acpi_video_bus *video = NULL; 1812 struct acpi_video_bus *video = NULL;
1891 1813
1892 ACPI_FUNCTION_TRACE("acpi_video_bus_remove"); 1814 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1893 1815
1894 if (!device || !acpi_driver_data(device)) 1816 if (!device || !acpi_driver_data(device))
1895 return_VALUE(-EINVAL); 1817 return_VALUE(-EINVAL);
1896 1818
1897 video = (struct acpi_video_bus *) acpi_driver_data(device); 1819 video = (struct acpi_video_bus *)acpi_driver_data(device);
1898 1820
1899 acpi_video_bus_stop_devices(video); 1821 acpi_video_bus_stop_devices(video);
1900 1822
1901 status = acpi_remove_notify_handler(video->handle, 1823 status = acpi_remove_notify_handler(video->handle,
1902 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); 1824 ACPI_DEVICE_NOTIFY,
1825 acpi_video_bus_notify);
1903 if (ACPI_FAILURE(status)) 1826 if (ACPI_FAILURE(status))
1904 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1827 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1905 "Error removing notify handler\n")); 1828 "Error removing notify handler\n"));
1906 1829
1907 acpi_video_bus_put_devices(video); 1830 acpi_video_bus_put_devices(video);
1908 acpi_video_bus_remove_fs(device); 1831 acpi_video_bus_remove_fs(device);
@@ -1914,15 +1837,12 @@ acpi_video_bus_remove (
1914 return_VALUE(0); 1837 return_VALUE(0);
1915} 1838}
1916 1839
1917
1918static int 1840static int
1919acpi_video_bus_match ( 1841acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1920 struct acpi_device *device,
1921 struct acpi_driver *driver)
1922{ 1842{
1923 acpi_handle h_dummy1; 1843 acpi_handle h_dummy1;
1924 acpi_handle h_dummy2; 1844 acpi_handle h_dummy2;
1925 acpi_handle h_dummy3; 1845 acpi_handle h_dummy3;
1926 1846
1927 ACPI_FUNCTION_TRACE("acpi_video_bus_match"); 1847 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1928 1848
@@ -1948,22 +1868,19 @@ acpi_video_bus_match (
1948 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) 1868 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1949 return_VALUE(0); 1869 return_VALUE(0);
1950 1870
1951
1952 return_VALUE(-ENODEV); 1871 return_VALUE(-ENODEV);
1953} 1872}
1954 1873
1955 1874static int __init acpi_video_init(void)
1956static int __init
1957acpi_video_init (void)
1958{ 1875{
1959 int result = 0; 1876 int result = 0;
1960 1877
1961 ACPI_FUNCTION_TRACE("acpi_video_init"); 1878 ACPI_FUNCTION_TRACE("acpi_video_init");
1962 1879
1963 /* 1880 /*
1964 acpi_dbg_level = 0xFFFFFFFF; 1881 acpi_dbg_level = 0xFFFFFFFF;
1965 acpi_dbg_layer = 0x08000000; 1882 acpi_dbg_layer = 0x08000000;
1966 */ 1883 */
1967 1884
1968 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 1885 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1969 if (!acpi_video_dir) 1886 if (!acpi_video_dir)
@@ -1979,8 +1896,7 @@ acpi_video_init (void)
1979 return_VALUE(0); 1896 return_VALUE(0);
1980} 1897}
1981 1898
1982static void __exit 1899static void __exit acpi_video_exit(void)
1983acpi_video_exit (void)
1984{ 1900{
1985 ACPI_FUNCTION_TRACE("acpi_video_exit"); 1901 ACPI_FUNCTION_TRACE("acpi_video_exit");
1986 1902
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index d62af7293923..f3810cc5d48e 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
@@ -78,10 +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 96 /* 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 96 /* Parse tree objects */ 82#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
84#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ 83#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
85 84
86/* 85/*
87 * 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
@@ -89,7 +88,6 @@
89 */ 88 */
90#define ACPI_CHECKSUM_ABORT FALSE 89#define ACPI_CHECKSUM_ABORT FALSE
91 90
92
93/****************************************************************************** 91/******************************************************************************
94 * 92 *
95 * Subsystem Constants 93 * Subsystem Constants
@@ -103,7 +101,7 @@
103/* String size constants */ 101/* String size constants */
104 102
105#define ACPI_MAX_STRING_LENGTH 512 103#define ACPI_MAX_STRING_LENGTH 512
106#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */ 104#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */
107 105
108/* Maximum count for a semaphore object */ 106/* Maximum count for a semaphore object */
109 107
@@ -117,7 +115,6 @@
117 115
118#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 116#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
119 117
120
121/****************************************************************************** 118/******************************************************************************
122 * 119 *
123 * ACPI Specification constants (Do not change unless the specification changes) 120 * ACPI Specification constants (Do not change unless the specification changes)
@@ -155,15 +152,15 @@
155/* Names within the namespace are 4 bytes long */ 152/* Names within the namespace are 4 bytes long */
156 153
157#define ACPI_NAME_SIZE 4 154#define ACPI_NAME_SIZE 4
158#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 */
159#define ACPI_PATH_SEPARATOR '.' 156#define ACPI_PATH_SEPARATOR '.'
160 157
161/* Constants used in searching for the RSDP in low memory */ 158/* Constants used in searching for the RSDP in low memory */
162 159
163#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ 160#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
164#define ACPI_EBDA_PTR_LENGTH 2 161#define ACPI_EBDA_PTR_LENGTH 2
165#define ACPI_EBDA_WINDOW_SIZE 1024 162#define ACPI_EBDA_WINDOW_SIZE 1024
166#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ 163#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */
167#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 164#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000
168#define ACPI_RSDP_SCAN_STEP 16 165#define ACPI_RSDP_SCAN_STEP 16
169 166
@@ -198,18 +195,15 @@
198 195
199#define ACPI_NUM_OSI_STRINGS 10 196#define ACPI_NUM_OSI_STRINGS 10
200 197
201
202/****************************************************************************** 198/******************************************************************************
203 * 199 *
204 * ACPI AML Debugger 200 * ACPI AML Debugger
205 * 201 *
206 *****************************************************************************/ 202 *****************************************************************************/
207 203
208#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 */
209 205
210#define ACPI_DEBUGGER_COMMAND_PROMPT '-' 206#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
211#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' 207#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
212 208
213 209#endif /* _ACCONFIG_H */
214#endif /* _ACCONFIG_H */
215
diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h
index f8fa2227583d..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,279 +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
97void
98acpi_db_display_table_info (
99 char *table_arg);
100 81
101void 82void acpi_db_display_table_info(char *table_arg);
102acpi_db_unload_acpi_table (
103 char *table_arg,
104 char *instance_arg);
105 83
106void 84void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg);
107acpi_db_set_method_breakpoint (
108 char *location,
109 struct acpi_walk_state *walk_state,
110 union acpi_parse_object *op);
111 85
112void 86void
113acpi_db_set_method_call_breakpoint ( 87acpi_db_set_method_breakpoint(char *location,
114 union acpi_parse_object *op); 88 struct acpi_walk_state *walk_state,
89 union acpi_parse_object *op);
115 90
116void 91void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
117acpi_db_get_bus_info (
118 void);
119 92
120void 93void acpi_db_get_bus_info(void);
121acpi_db_disassemble_aml (
122 char *statements,
123 union acpi_parse_object *op);
124 94
125void 95void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
126acpi_db_dump_namespace (
127 char *start_arg,
128 char *depth_arg);
129 96
130void 97void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
131acpi_db_dump_namespace_by_owner (
132 char *owner_arg,
133 char *depth_arg);
134 98
135void 99void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
136acpi_db_send_notify (
137 char *name,
138 u32 value);
139 100
140void 101void acpi_db_send_notify(char *name, u32 value);
141acpi_db_set_method_data (
142 char *type_arg,
143 char *index_arg,
144 char *value_arg);
145 102
146acpi_status 103void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
147acpi_db_display_objects (
148 char *obj_type_arg,
149 char *display_count_arg);
150 104
151acpi_status 105acpi_status
152acpi_db_find_name_in_namespace ( 106acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
153 char *name_arg);
154 107
155void 108acpi_status acpi_db_find_name_in_namespace(char *name_arg);
156acpi_db_set_scope (
157 char *name);
158 109
159acpi_status 110void acpi_db_set_scope(char *name);
160acpi_db_sleep (
161 char *object_arg);
162 111
163void 112acpi_status acpi_db_sleep(char *object_arg);
164acpi_db_find_references (
165 char *object_arg);
166 113
167void 114void acpi_db_find_references(char *object_arg);
168acpi_db_display_locks (
169 void);
170 115
171void 116void acpi_db_display_locks(void);
172acpi_db_display_resources (
173 char *object_arg);
174 117
175void 118void acpi_db_display_resources(char *object_arg);
176acpi_db_display_gpes (
177 void);
178 119
179void 120void acpi_db_display_gpes(void);
180acpi_db_check_integrity (
181 void);
182 121
183void 122void acpi_db_check_integrity(void);
184acpi_db_generate_gpe (
185 char *gpe_arg,
186 char *block_arg);
187 123
124void acpi_db_generate_gpe(char *gpe_arg, char *block_arg);
188 125
189/* 126/*
190 * dbdisply - debug display commands 127 * dbdisply - debug display commands
191 */ 128 */
192void 129void acpi_db_display_method_info(union acpi_parse_object *op);
193acpi_db_display_method_info (
194 union acpi_parse_object *op);
195 130
196void 131void acpi_db_decode_and_display_object(char *target, char *output_type);
197acpi_db_decode_and_display_object (
198 char *target,
199 char *output_type);
200 132
201void 133void
202acpi_db_display_result_object ( 134acpi_db_display_result_object(union acpi_operand_object *obj_desc,
203 union acpi_operand_object *obj_desc, 135 struct acpi_walk_state *walk_state);
204 struct acpi_walk_state *walk_state);
205 136
206acpi_status 137acpi_status acpi_db_display_all_methods(char *display_count_arg);
207acpi_db_display_all_methods (
208 char *display_count_arg);
209 138
210void 139void acpi_db_display_arguments(void);
211acpi_db_display_arguments (
212 void);
213 140
214void 141void acpi_db_display_locals(void);
215acpi_db_display_locals (
216 void);
217 142
218void 143void acpi_db_display_results(void);
219acpi_db_display_results (
220 void);
221 144
222void 145void acpi_db_display_calling_tree(void);
223acpi_db_display_calling_tree (
224 void);
225 146
226void 147void acpi_db_display_object_type(char *object_arg);
227acpi_db_display_object_type (
228 char *object_arg);
229 148
230void 149void
231acpi_db_display_argument_object ( 150acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
232 union acpi_operand_object *obj_desc, 151 struct acpi_walk_state *walk_state);
233 struct acpi_walk_state *walk_state);
234
235 152
236/* 153/*
237 * dbexec - debugger control method execution 154 * dbexec - debugger control method execution
238 */ 155 */
239void 156void acpi_db_execute(char *name, char **args, u32 flags);
240acpi_db_execute (
241 char *name,
242 char **args,
243 u32 flags);
244 157
245void 158void
246acpi_db_create_execution_threads ( 159acpi_db_create_execution_threads(char *num_threads_arg,
247 char *num_threads_arg, 160 char *num_loops_arg, char *method_name_arg);
248 char *num_loops_arg,
249 char *method_name_arg);
250
251 161
252/* 162/*
253 * dbfileio - Debugger file I/O commands 163 * dbfileio - Debugger file I/O commands
254 */ 164 */
255acpi_object_type 165acpi_object_type
256acpi_db_match_argument ( 166acpi_db_match_argument(char *user_argument, struct argument_info *arguments);
257 char *user_argument,
258 struct argument_info *arguments);
259 167
260void 168void acpi_db_close_debug_file(void);
261acpi_db_close_debug_file (
262 void);
263 169
264void 170void acpi_db_open_debug_file(char *name);
265acpi_db_open_debug_file (
266 char *name);
267 171
268acpi_status 172acpi_status acpi_db_load_acpi_table(char *filename);
269acpi_db_load_acpi_table (
270 char *filename);
271 173
272acpi_status 174acpi_status
273acpi_db_get_table_from_file ( 175acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
274 char *filename,
275 struct acpi_table_header **table);
276 176
277acpi_status 177acpi_status
278acpi_db_read_table_from_file ( 178acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
279 char *filename,
280 struct acpi_table_header **table);
281
282 179
283/* 180/*
284 * dbhistry - debugger HISTORY command 181 * dbhistry - debugger HISTORY command
285 */ 182 */
286void 183void acpi_db_add_to_history(char *command_line);
287acpi_db_add_to_history (
288 char *command_line);
289 184
290void 185void acpi_db_display_history(void);
291acpi_db_display_history (
292 void);
293
294char *
295acpi_db_get_from_history (
296 char *command_num_arg);
297 186
187char *acpi_db_get_from_history(char *command_num_arg);
298 188
299/* 189/*
300 * dbinput - user front-end to the AML debugger 190 * dbinput - user front-end to the AML debugger
301 */ 191 */
302acpi_status 192acpi_status
303acpi_db_command_dispatch ( 193acpi_db_command_dispatch(char *input_buffer,
304 char *input_buffer, 194 struct acpi_walk_state *walk_state,
305 struct acpi_walk_state *walk_state, 195 union acpi_parse_object *op);
306 union acpi_parse_object *op);
307
308void ACPI_SYSTEM_XFACE
309acpi_db_execute_thread (
310 void *context);
311 196
197void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
312 198
313/* 199/*
314 * dbstats - Generation and display of ACPI table statistics 200 * dbstats - Generation and display of ACPI table statistics
315 */ 201 */
316void 202void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method);
317acpi_db_generate_statistics (
318 union acpi_parse_object *root,
319 u8 is_method);
320
321acpi_status
322acpi_db_display_statistics (
323 char *type_arg);
324 203
204acpi_status acpi_db_display_statistics(char *type_arg);
325 205
326/* 206/*
327 * dbutils - AML debugger utilities 207 * dbutils - AML debugger utilities
328 */ 208 */
329void 209void acpi_db_set_output_destination(u32 where);
330acpi_db_set_output_destination (
331 u32 where);
332 210
333void 211void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level);
334acpi_db_dump_external_object (
335 union acpi_object *obj_desc,
336 u32 level);
337 212
338void 213void acpi_db_prep_namestring(char *name);
339acpi_db_prep_namestring (
340 char *name);
341 214
342struct acpi_namespace_node * 215struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name);
343acpi_db_local_ns_lookup (
344 char *name);
345 216
346#endif /* __ACDEBUG_H__ */ 217#endif /* __ACDEBUG_H__ */
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
index 26325430db80..3d96dcb1bb4b 100644
--- a/include/acpi/acdisasm.h
+++ b/include/acpi/acdisasm.h
@@ -46,328 +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 struct acpi_walk_state *walk_state;
94}; 89};
95 90
96typedef 91typedef
97acpi_status (*asl_walk_callback) ( 92acpi_status(*asl_walk_callback) (union acpi_parse_object * op,
98 union acpi_parse_object *op, 93 u32 level, void *context);
99 u32 level,
100 void *context);
101
102 94
103/* 95/*
104 * dmwalk 96 * dmwalk
105 */ 97 */
106void 98void
107acpi_dm_disassemble ( 99acpi_dm_disassemble(struct acpi_walk_state *walk_state,
108 struct acpi_walk_state *walk_state, 100 union acpi_parse_object *origin, u32 num_opcodes);
109 union acpi_parse_object *origin,
110 u32 num_opcodes);
111
112 101
113/* 102/*
114 * dmopcode 103 * dmopcode
115 */ 104 */
116void 105void
117acpi_dm_disassemble_one_op ( 106acpi_dm_disassemble_one_op(struct acpi_walk_state *walk_state,
118 struct acpi_walk_state *walk_state, 107 struct acpi_op_walk_info *info,
119 struct acpi_op_walk_info *info, 108 union acpi_parse_object *op);
120 union acpi_parse_object *op);
121 109
122void 110void acpi_dm_decode_internal_object(union acpi_operand_object *obj_desc);
123acpi_dm_decode_internal_object (
124 union acpi_operand_object *obj_desc);
125 111
126u32 112u32 acpi_dm_list_type(union acpi_parse_object *op);
127acpi_dm_list_type (
128 union acpi_parse_object *op);
129 113
130void 114void acpi_dm_method_flags(union acpi_parse_object *op);
131acpi_dm_method_flags (
132 union acpi_parse_object *op);
133
134void
135acpi_dm_field_flags (
136 union acpi_parse_object *op);
137 115
138void 116void acpi_dm_field_flags(union acpi_parse_object *op);
139acpi_dm_address_space (
140 u8 space_id);
141 117
142void 118void acpi_dm_address_space(u8 space_id);
143acpi_dm_region_flags (
144 union acpi_parse_object *op);
145 119
146void 120void acpi_dm_region_flags(union acpi_parse_object *op);
147acpi_dm_match_op (
148 union acpi_parse_object *op);
149 121
150u8 122void acpi_dm_match_op(union acpi_parse_object *op);
151acpi_dm_comma_if_list_member (
152 union acpi_parse_object *op);
153 123
154void 124u8 acpi_dm_comma_if_list_member(union acpi_parse_object *op);
155acpi_dm_comma_if_field_member (
156 union acpi_parse_object *op);
157 125
126void acpi_dm_comma_if_field_member(union acpi_parse_object *op);
158 127
159/* 128/*
160 * dmnames 129 * dmnames
161 */ 130 */
162u32 131u32 acpi_dm_dump_name(char *name);
163acpi_dm_dump_name (
164 char *name);
165 132
166acpi_status 133acpi_status
167acpi_ps_display_object_pathname ( 134acpi_ps_display_object_pathname(struct acpi_walk_state *walk_state,
168 struct acpi_walk_state *walk_state, 135 union acpi_parse_object *op);
169 union acpi_parse_object *op);
170
171void
172acpi_dm_namestring (
173 char *name);
174 136
137void acpi_dm_namestring(char *name);
175 138
176/* 139/*
177 * dmobject 140 * dmobject
178 */ 141 */
179void 142void
180acpi_dm_display_internal_object ( 143acpi_dm_display_internal_object(union acpi_operand_object *obj_desc,
181 union acpi_operand_object *obj_desc, 144 struct acpi_walk_state *walk_state);
182 struct acpi_walk_state *walk_state);
183 145
184void 146void acpi_dm_display_arguments(struct acpi_walk_state *walk_state);
185acpi_dm_display_arguments (
186 struct acpi_walk_state *walk_state);
187 147
188void 148void acpi_dm_display_locals(struct acpi_walk_state *walk_state);
189acpi_dm_display_locals (
190 struct acpi_walk_state *walk_state);
191 149
192void 150void
193acpi_dm_dump_method_info ( 151acpi_dm_dump_method_info(acpi_status status,
194 acpi_status status, 152 struct acpi_walk_state *walk_state,
195 struct acpi_walk_state *walk_state, 153 union acpi_parse_object *op);
196 union acpi_parse_object *op);
197
198 154
199/* 155/*
200 * dmbuffer 156 * dmbuffer
201 */ 157 */
202void 158void acpi_dm_disasm_byte_list(u32 level, u8 * byte_data, u32 byte_count);
203acpi_dm_disasm_byte_list (
204 u32 level,
205 u8 *byte_data,
206 u32 byte_count);
207 159
208void 160void
209acpi_dm_byte_list ( 161acpi_dm_byte_list(struct acpi_op_walk_info *info, union acpi_parse_object *op);
210 struct acpi_op_walk_info *info,
211 union acpi_parse_object *op);
212 162
213void 163void acpi_dm_is_eisa_id(union acpi_parse_object *op);
214acpi_dm_is_eisa_id (
215 union acpi_parse_object *op);
216 164
217void 165void acpi_dm_eisa_id(u32 encoded_id);
218acpi_dm_eisa_id (
219 u32 encoded_id);
220
221u8
222acpi_dm_is_unicode_buffer (
223 union acpi_parse_object *op);
224 166
225u8 167u8 acpi_dm_is_unicode_buffer(union acpi_parse_object *op);
226acpi_dm_is_string_buffer (
227 union acpi_parse_object *op);
228 168
169u8 acpi_dm_is_string_buffer(union acpi_parse_object *op);
229 170
230/* 171/*
231 * dmresrc 172 * dmresrc
232 */ 173 */
233void 174void
234acpi_dm_resource_descriptor ( 175acpi_dm_resource_descriptor(struct acpi_op_walk_info *info,
235 struct acpi_op_walk_info *info, 176 u8 * byte_data, u32 byte_count);
236 u8 *byte_data,
237 u32 byte_count);
238 177
239u8 178u8 acpi_dm_is_resource_descriptor(union acpi_parse_object *op);
240acpi_dm_is_resource_descriptor (
241 union acpi_parse_object *op);
242 179
243void 180void acpi_dm_indent(u32 level);
244acpi_dm_indent (
245 u32 level);
246 181
247void 182void acpi_dm_bit_list(u16 mask);
248acpi_dm_bit_list (
249 u16 mask);
250
251void
252acpi_dm_decode_attribute (
253 u8 attribute);
254 183
184void acpi_dm_decode_attribute(u8 attribute);
255 185
256/* 186/*
257 * dmresrcl 187 * dmresrcl
258 */ 188 */
259void 189void
260acpi_dm_word_descriptor ( 190acpi_dm_word_descriptor(struct asl_word_address_desc *resource,
261 struct asl_word_address_desc *resource, 191 u32 length, u32 level);
262 u32 length,
263 u32 level);
264 192
265void 193void
266acpi_dm_dword_descriptor ( 194acpi_dm_dword_descriptor(struct asl_dword_address_desc *resource,
267 struct asl_dword_address_desc *resource, 195 u32 length, u32 level);
268 u32 length,
269 u32 level);
270 196
271void 197void
272acpi_dm_extended_descriptor ( 198acpi_dm_extended_descriptor(struct asl_extended_address_desc *resource,
273 struct asl_extended_address_desc *resource, 199 u32 length, u32 level);
274 u32 length,
275 u32 level);
276 200
277void 201void
278acpi_dm_qword_descriptor ( 202acpi_dm_qword_descriptor(struct asl_qword_address_desc *resource,
279 struct asl_qword_address_desc *resource, 203 u32 length, u32 level);
280 u32 length,
281 u32 level);
282 204
283void 205void
284acpi_dm_memory24_descriptor ( 206acpi_dm_memory24_descriptor(struct asl_memory_24_desc *resource,
285 struct asl_memory_24_desc *resource, 207 u32 length, u32 level);
286 u32 length,
287 u32 level);
288 208
289void 209void
290acpi_dm_memory32_descriptor ( 210acpi_dm_memory32_descriptor(struct asl_memory_32_desc *resource,
291 struct asl_memory_32_desc *resource, 211 u32 length, u32 level);
292 u32 length,
293 u32 level);
294 212
295void 213void
296acpi_dm_fixed_mem32_descriptor ( 214acpi_dm_fixed_mem32_descriptor(struct asl_fixed_memory_32_desc *resource,
297 struct asl_fixed_memory_32_desc *resource, 215 u32 length, u32 level);
298 u32 length,
299 u32 level);
300 216
301void 217void
302acpi_dm_generic_register_descriptor ( 218acpi_dm_generic_register_descriptor(struct asl_general_register_desc *resource,
303 struct asl_general_register_desc *resource, 219 u32 length, u32 level);
304 u32 length,
305 u32 level);
306 220
307void 221void
308acpi_dm_interrupt_descriptor ( 222acpi_dm_interrupt_descriptor(struct asl_extended_xrupt_desc *resource,
309 struct asl_extended_xrupt_desc *resource, 223 u32 length, u32 level);
310 u32 length,
311 u32 level);
312 224
313void 225void
314acpi_dm_vendor_large_descriptor ( 226acpi_dm_vendor_large_descriptor(struct asl_large_vendor_desc *resource,
315 struct asl_large_vendor_desc *resource, 227 u32 length, u32 level);
316 u32 length,
317 u32 level);
318
319 228
320/* 229/*
321 * dmresrcs 230 * dmresrcs
322 */ 231 */
323void 232void
324acpi_dm_irq_descriptor ( 233acpi_dm_irq_descriptor(struct asl_irq_format_desc *resource,
325 struct asl_irq_format_desc *resource, 234 u32 length, u32 level);
326 u32 length,
327 u32 level);
328 235
329void 236void
330acpi_dm_dma_descriptor ( 237acpi_dm_dma_descriptor(struct asl_dma_format_desc *resource,
331 struct asl_dma_format_desc *resource, 238 u32 length, u32 level);
332 u32 length,
333 u32 level);
334 239
335void 240void
336acpi_dm_io_descriptor ( 241acpi_dm_io_descriptor(struct asl_io_port_desc *resource, u32 length, u32 level);
337 struct asl_io_port_desc *resource,
338 u32 length,
339 u32 level);
340 242
341void 243void
342acpi_dm_fixed_io_descriptor ( 244acpi_dm_fixed_io_descriptor(struct asl_fixed_io_port_desc *resource,
343 struct asl_fixed_io_port_desc *resource, 245 u32 length, u32 level);
344 u32 length,
345 u32 level);
346 246
347void 247void
348acpi_dm_start_dependent_descriptor ( 248acpi_dm_start_dependent_descriptor(struct asl_start_dependent_desc *resource,
349 struct asl_start_dependent_desc *resource, 249 u32 length, u32 level);
350 u32 length,
351 u32 level);
352 250
353void 251void
354acpi_dm_end_dependent_descriptor ( 252acpi_dm_end_dependent_descriptor(struct asl_start_dependent_desc *resource,
355 struct asl_start_dependent_desc *resource, 253 u32 length, u32 level);
356 u32 length,
357 u32 level);
358 254
359void 255void
360acpi_dm_vendor_small_descriptor ( 256acpi_dm_vendor_small_descriptor(struct asl_small_vendor_desc *resource,
361 struct asl_small_vendor_desc *resource, 257 u32 length, u32 level);
362 u32 length,
363 u32 level);
364
365 258
366/* 259/*
367 * dmutils 260 * dmutils
368 */ 261 */
369void 262void acpi_dm_add_to_external_list(char *path);
370acpi_dm_add_to_external_list (
371 char *path);
372 263
373#endif /* __ACDISASM_H__ */ 264#endif /* __ACDISASM_H__ */
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 90b7d30bd255..59306186f5e2 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -41,413 +41,305 @@
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 55
60acpi_status 56acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc);
61acpi_ds_get_region_arguments (
62 union acpi_operand_object *rgn_desc);
63 57
64acpi_status 58acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
65acpi_ds_get_buffer_arguments (
66 union acpi_operand_object *obj_desc);
67 59
68acpi_status 60acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
69acpi_ds_get_package_arguments (
70 union acpi_operand_object *obj_desc);
71
72acpi_status
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 94
115acpi_status 95acpi_status
116acpi_ds_exec_begin_op ( 96acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
117 struct acpi_walk_state *walk_state, 97 union acpi_parse_object **out_op);
118 union acpi_parse_object **out_op);
119
120acpi_status
121acpi_ds_exec_end_op (
122 struct acpi_walk_state *state);
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 struct acpi_namespace_node *node);
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 197acpi_status
253acpi_ds_terminate_control_method ( 198acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state);
254 struct acpi_walk_state *walk_state);
255 199
256acpi_status 200acpi_status
257acpi_ds_begin_method_execution ( 201acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
258 struct acpi_namespace_node *method_node, 202 union acpi_operand_object *obj_desc,
259 union acpi_operand_object *obj_desc, 203 struct acpi_namespace_node *calling_method_node);
260 struct acpi_namespace_node *calling_method_node);
261
262 204
263/* 205/*
264 * dsinit 206 * dsinit
265 */ 207 */
266acpi_status 208acpi_status
267acpi_ds_initialize_objects ( 209acpi_ds_initialize_objects(struct acpi_table_desc *table_desc,
268 struct acpi_table_desc *table_desc, 210 struct acpi_namespace_node *start_node);
269 struct acpi_namespace_node *start_node);
270
271 211
272/* 212/*
273 * dsobject - Parser/Interpreter interface - object initialization and conversion 213 * dsobject - Parser/Interpreter interface - object initialization and conversion
274 */ 214 */
275acpi_status 215acpi_status
276acpi_ds_build_internal_buffer_obj ( 216acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
277 struct acpi_walk_state *walk_state, 217 union acpi_parse_object *op,
278 union acpi_parse_object *op, 218 u32 buffer_length,
279 u32 buffer_length, 219 union acpi_operand_object **obj_desc_ptr);
280 union acpi_operand_object **obj_desc_ptr);
281 220
282acpi_status 221acpi_status
283acpi_ds_build_internal_package_obj ( 222acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
284 struct acpi_walk_state *walk_state, 223 union acpi_parse_object *op,
285 union acpi_parse_object *op, 224 u32 package_length,
286 u32 package_length, 225 union acpi_operand_object **obj_desc);
287 union acpi_operand_object **obj_desc);
288 226
289acpi_status 227acpi_status
290acpi_ds_init_object_from_op ( 228acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
291 struct acpi_walk_state *walk_state, 229 union acpi_parse_object *op,
292 union acpi_parse_object *op, 230 u16 opcode, union acpi_operand_object **obj_desc);
293 u16 opcode,
294 union acpi_operand_object **obj_desc);
295 231
296acpi_status 232acpi_status
297acpi_ds_create_node ( 233acpi_ds_create_node(struct acpi_walk_state *walk_state,
298 struct acpi_walk_state *walk_state, 234 struct acpi_namespace_node *node,
299 struct acpi_namespace_node *node, 235 union acpi_parse_object *op);
300 union acpi_parse_object *op);
301
302 236
303/* 237/*
304 * dsutils - Parser/Interpreter interface utility routines 238 * dsutils - Parser/Interpreter interface utility routines
305 */ 239 */
306void 240void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state);
307acpi_ds_clear_implicit_return (
308 struct acpi_walk_state *walk_state);
309 241
310u8 242u8
311acpi_ds_do_implicit_return ( 243acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
312 union acpi_operand_object *return_desc, 244 struct acpi_walk_state *walk_state,
313 struct acpi_walk_state *walk_state, 245 u8 add_reference);
314 u8 add_reference);
315 246
316u8 247u8
317acpi_ds_is_result_used ( 248acpi_ds_is_result_used(union acpi_parse_object *op,
318 union acpi_parse_object *op, 249 struct acpi_walk_state *walk_state);
319 struct acpi_walk_state *walk_state);
320 250
321void 251void
322acpi_ds_delete_result_if_not_used ( 252acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
323 union acpi_parse_object *op, 253 union acpi_operand_object *result_obj,
324 union acpi_operand_object *result_obj, 254 struct acpi_walk_state *walk_state);
325 struct acpi_walk_state *walk_state);
326
327acpi_status
328acpi_ds_create_operand (
329 struct acpi_walk_state *walk_state,
330 union acpi_parse_object *arg,
331 u32 args_remaining);
332 255
333acpi_status 256acpi_status
334acpi_ds_create_operands ( 257acpi_ds_create_operand(struct acpi_walk_state *walk_state,
335 struct acpi_walk_state *walk_state, 258 union acpi_parse_object *arg, u32 args_remaining);
336 union acpi_parse_object *first_arg);
337 259
338acpi_status 260acpi_status
339acpi_ds_resolve_operands ( 261acpi_ds_create_operands(struct acpi_walk_state *walk_state,
340 struct acpi_walk_state *walk_state); 262 union acpi_parse_object *first_arg);
341 263
342void 264acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state);
343acpi_ds_clear_operands (
344 struct acpi_walk_state *walk_state);
345 265
266void acpi_ds_clear_operands(struct acpi_walk_state *walk_state);
346 267
347/* 268/*
348 * dswscope - Scope Stack manipulation 269 * dswscope - Scope Stack manipulation
349 */ 270 */
350acpi_status 271acpi_status
351acpi_ds_scope_stack_push ( 272acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
352 struct acpi_namespace_node *node, 273 acpi_object_type type,
353 acpi_object_type type, 274 struct acpi_walk_state *walk_state);
354 struct acpi_walk_state *walk_state);
355 275
276acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state);
356 277
357acpi_status 278void 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 279
366/* 280/*
367 * dswstate - parser WALK_STATE management routines 281 * dswstate - parser WALK_STATE management routines
368 */ 282 */
369acpi_status 283acpi_status
370acpi_ds_obj_stack_push ( 284acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state);
371 void *object,
372 struct acpi_walk_state *walk_state);
373 285
374acpi_status 286acpi_status
375acpi_ds_obj_stack_pop ( 287acpi_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 288
379struct acpi_walk_state * 289struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
380acpi_ds_create_walk_state ( 290 union acpi_parse_object
381 acpi_owner_id owner_id, 291 *origin,
382 union acpi_parse_object *origin, 292 union acpi_operand_object
383 union acpi_operand_object *mth_desc, 293 *mth_desc,
384 struct acpi_thread_state *thread); 294 struct acpi_thread_state
295 *thread);
385 296
386acpi_status 297acpi_status
387acpi_ds_init_aml_walk ( 298acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
388 struct acpi_walk_state *walk_state, 299 union acpi_parse_object *op,
389 union acpi_parse_object *op, 300 struct acpi_namespace_node *method_node,
390 struct acpi_namespace_node *method_node, 301 u8 * aml_start,
391 u8 *aml_start, 302 u32 aml_length,
392 u32 aml_length, 303 struct acpi_parameter_info *info, u8 pass_number);
393 struct acpi_parameter_info *info,
394 u8 pass_number);
395 304
396acpi_status 305acpi_status
397acpi_ds_obj_stack_pop_and_delete ( 306acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
398 u32 pop_count, 307 struct acpi_walk_state *walk_state);
399 struct acpi_walk_state *walk_state);
400 308
401void 309void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state);
402acpi_ds_delete_walk_state (
403 struct acpi_walk_state *walk_state);
404 310
405struct acpi_walk_state * 311struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state
406acpi_ds_pop_walk_state ( 312 *thread);
407 struct acpi_thread_state *thread);
408 313
409void 314void
410acpi_ds_push_walk_state ( 315acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
411 struct acpi_walk_state *walk_state, 316 struct acpi_thread_state *thread);
412 struct acpi_thread_state *thread);
413 317
414acpi_status 318acpi_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 319
418acpi_status 320acpi_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 321
422acpi_status 322acpi_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 323
426struct acpi_walk_state * 324struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
427acpi_ds_get_current_walk_state ( 325 *thread);
428 struct acpi_thread_state *thread);
429 326
430#ifdef ACPI_FUTURE_USAGE 327#ifdef ACPI_FUTURE_USAGE
431acpi_status 328acpi_status
432acpi_ds_result_remove ( 329acpi_ds_result_remove(union acpi_operand_object **object,
433 union acpi_operand_object **object, 330 u32 index, struct acpi_walk_state *walk_state);
434 u32 index,
435 struct acpi_walk_state *walk_state);
436#endif 331#endif
437 332
438acpi_status 333acpi_status
439acpi_ds_result_pop ( 334acpi_ds_result_pop(union acpi_operand_object **object,
440 union acpi_operand_object **object, 335 struct acpi_walk_state *walk_state);
441 struct acpi_walk_state *walk_state);
442 336
443acpi_status 337acpi_status
444acpi_ds_result_push ( 338acpi_ds_result_push(union acpi_operand_object *object,
445 union acpi_operand_object *object, 339 struct acpi_walk_state *walk_state);
446 struct acpi_walk_state *walk_state);
447 340
448acpi_status 341acpi_status
449acpi_ds_result_pop_from_bottom ( 342acpi_ds_result_pop_from_bottom(union acpi_operand_object **object,
450 union acpi_operand_object **object, 343 struct acpi_walk_state *walk_state);
451 struct acpi_walk_state *walk_state);
452 344
453#endif /* _ACDISPAT_H_ */ 345#endif /* _ACDISPAT_H_ */
diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h
index 33ae2ca997b7..bfa54600ecd9 100644
--- a/include/acpi/acevents.h
+++ b/include/acpi/acevents.h
@@ -44,249 +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 93
127acpi_status 94acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback);
128acpi_ev_delete_gpe_handlers (
129 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
130 struct acpi_gpe_block_info *gpe_block);
131 95
132acpi_status 96acpi_status
133acpi_ev_create_gpe_block ( 97acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
134 struct acpi_namespace_node *gpe_device, 98 struct acpi_gpe_block_info *gpe_block);
135 struct acpi_generic_address *gpe_block_address,
136 u32 register_count,
137 u8 gpe_block_base_number,
138 u32 interrupt_number,
139 struct acpi_gpe_block_info **return_gpe_block);
140 99
141acpi_status 100acpi_status
142acpi_ev_delete_gpe_block ( 101acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
143 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);
144 107
145u32 108acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
146acpi_ev_gpe_dispatch (
147 struct acpi_gpe_event_info *gpe_event_info,
148 u32 gpe_number);
149 109
150u32 110u32
151acpi_ev_gpe_detect ( 111acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info,
152 struct acpi_gpe_xrupt_info *gpe_xrupt_list); 112 u32 gpe_number);
153 113
154acpi_status 114u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
155acpi_ev_set_gpe_type (
156 struct acpi_gpe_event_info *gpe_event_info,
157 u8 type);
158 115
159acpi_status 116acpi_status
160acpi_ev_check_for_wake_only_gpe ( 117acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type);
161 struct acpi_gpe_event_info *gpe_event_info);
162 118
163acpi_status 119acpi_status
164acpi_ev_gpe_initialize ( 120acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info);
165 void);
166 121
122acpi_status acpi_ev_gpe_initialize(void);
167 123
168/* 124/*
169 * evregion - Address Space handling 125 * evregion - Address Space handling
170 */ 126 */
171acpi_status 127acpi_status acpi_ev_install_region_handlers(void);
172acpi_ev_install_region_handlers (
173 void);
174 128
175acpi_status 129acpi_status acpi_ev_initialize_op_regions(void);
176acpi_ev_initialize_op_regions (
177 void);
178 130
179acpi_status 131acpi_status
180acpi_ev_address_space_dispatch ( 132acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
181 union acpi_operand_object *region_obj, 133 u32 function,
182 u32 function, 134 acpi_physical_address address,
183 acpi_physical_address address, 135 u32 bit_width, void *value);
184 u32 bit_width,
185 void *value);
186 136
187acpi_status 137acpi_status
188acpi_ev_attach_region ( 138acpi_ev_attach_region(union acpi_operand_object *handler_obj,
189 union acpi_operand_object *handler_obj, 139 union acpi_operand_object *region_obj,
190 union acpi_operand_object *region_obj, 140 u8 acpi_ns_is_locked);
191 u8 acpi_ns_is_locked);
192 141
193void 142void
194acpi_ev_detach_region ( 143acpi_ev_detach_region(union acpi_operand_object *region_obj,
195 union acpi_operand_object *region_obj, 144 u8 acpi_ns_is_locked);
196 u8 acpi_ns_is_locked);
197 145
198acpi_status 146acpi_status
199acpi_ev_install_space_handler ( 147acpi_ev_install_space_handler(struct acpi_namespace_node *node,
200 struct acpi_namespace_node *node, 148 acpi_adr_space_type space_id,
201 acpi_adr_space_type space_id, 149 acpi_adr_space_handler handler,
202 acpi_adr_space_handler handler, 150 acpi_adr_space_setup setup, void *context);
203 acpi_adr_space_setup setup,
204 void *context);
205 151
206acpi_status 152acpi_status
207acpi_ev_execute_reg_methods ( 153acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
208 struct acpi_namespace_node *node, 154 acpi_adr_space_type space_id);
209 acpi_adr_space_type space_id);
210 155
211acpi_status 156acpi_status
212acpi_ev_execute_reg_method ( 157acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function);
213 union acpi_operand_object *region_obj,
214 u32 function);
215
216 158
217/* 159/*
218 * evregini - Region initialization and setup 160 * evregini - Region initialization and setup
219 */ 161 */
220acpi_status 162acpi_status
221acpi_ev_system_memory_region_setup ( 163acpi_ev_system_memory_region_setup(acpi_handle handle,
222 acpi_handle handle, 164 u32 function,
223 u32 function, 165 void *handler_context,
224 void *handler_context, 166 void **region_context);
225 void **region_context);
226 167
227acpi_status 168acpi_status
228acpi_ev_io_space_region_setup ( 169acpi_ev_io_space_region_setup(acpi_handle handle,
229 acpi_handle handle, 170 u32 function,
230 u32 function, 171 void *handler_context, void **region_context);
231 void *handler_context,
232 void **region_context);
233 172
234acpi_status 173acpi_status
235acpi_ev_pci_config_region_setup ( 174acpi_ev_pci_config_region_setup(acpi_handle handle,
236 acpi_handle handle, 175 u32 function,
237 u32 function, 176 void *handler_context, void **region_context);
238 void *handler_context,
239 void **region_context);
240 177
241acpi_status 178acpi_status
242acpi_ev_cmos_region_setup ( 179acpi_ev_cmos_region_setup(acpi_handle handle,
243 acpi_handle handle, 180 u32 function,
244 u32 function, 181 void *handler_context, void **region_context);
245 void *handler_context,
246 void **region_context);
247 182
248acpi_status 183acpi_status
249acpi_ev_pci_bar_region_setup ( 184acpi_ev_pci_bar_region_setup(acpi_handle handle,
250 acpi_handle handle, 185 u32 function,
251 u32 function, 186 void *handler_context, void **region_context);
252 void *handler_context,
253 void **region_context);
254 187
255acpi_status 188acpi_status
256acpi_ev_default_region_setup ( 189acpi_ev_default_region_setup(acpi_handle handle,
257 acpi_handle handle, 190 u32 function,
258 u32 function, 191 void *handler_context, void **region_context);
259 void *handler_context,
260 void **region_context);
261 192
262acpi_status 193acpi_status
263acpi_ev_initialize_region ( 194acpi_ev_initialize_region(union acpi_operand_object *region_obj,
264 union acpi_operand_object *region_obj, 195 u8 acpi_ns_locked);
265 u8 acpi_ns_locked);
266
267 196
268/* 197/*
269 * evsci - SCI (System Control Interrupt) handling/dispatch 198 * evsci - SCI (System Control Interrupt) handling/dispatch
270 */ 199 */
271u32 ACPI_SYSTEM_XFACE 200u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context);
272acpi_ev_gpe_xrupt_handler (
273 void *context);
274
275u32
276acpi_ev_install_sci_handler (
277 void);
278 201
279acpi_status 202u32 acpi_ev_install_sci_handler(void);
280acpi_ev_remove_sci_handler (
281 void);
282 203
283u32 204acpi_status acpi_ev_remove_sci_handler(void);
284acpi_ev_initialize_sCI (
285 u32 program_sCI);
286 205
287void 206u32 acpi_ev_initialize_sCI(u32 program_sCI);
288acpi_ev_terminate (
289 void);
290 207
208void acpi_ev_terminate(void);
291 209
292#endif /* __ACEVENTS_H__ */ 210#endif /* __ACEVENTS_H__ */
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 0a6f492f3c8e..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/*
@@ -99,7 +96,6 @@
99 96
100#define AE_CODE_ENV_MAX 0x001F 97#define AE_CODE_ENV_MAX 0x001F
101 98
102
103/* 99/*
104 * Programmer exceptions 100 * Programmer exceptions
105 */ 101 */
@@ -115,7 +111,6 @@
115 111
116#define AE_CODE_PGM_MAX 0x0009 112#define AE_CODE_PGM_MAX 0x0009
117 113
118
119/* 114/*
120 * Acpi table exceptions 115 * Acpi table exceptions
121 */ 116 */
@@ -128,7 +123,6 @@
128 123
129#define AE_CODE_TBL_MAX 0x0006 124#define AE_CODE_TBL_MAX 0x0006
130 125
131
132/* 126/*
133 * AML exceptions. These are caused by problems with 127 * AML exceptions. These are caused by problems with
134 * the actual AML byte stream 128 * the actual AML byte stream
@@ -169,7 +163,6 @@
169 163
170#define AE_CODE_AML_MAX 0x0021 164#define AE_CODE_AML_MAX 0x0021
171 165
172
173/* 166/*
174 * Internal exceptions used for control 167 * Internal exceptions used for control
175 */ 168 */
@@ -187,16 +180,13 @@
187 180
188#define AE_CODE_CTRL_MAX 0x000B 181#define AE_CODE_CTRL_MAX 0x000B
189 182
190
191#ifdef DEFINE_ACPI_GLOBALS 183#ifdef DEFINE_ACPI_GLOBALS
192 184
193
194/* 185/*
195 * String versions of the exception codes above 186 * String versions of the exception codes above
196 * These strings must match the corresponding defines exactly 187 * These strings must match the corresponding defines exactly
197 */ 188 */
198char const *acpi_gbl_exception_names_env[] = 189char const *acpi_gbl_exception_names_env[] = {
199{
200 "AE_OK", 190 "AE_OK",
201 "AE_ERROR", 191 "AE_ERROR",
202 "AE_NO_ACPI_TABLES", 192 "AE_NO_ACPI_TABLES",
@@ -231,8 +221,7 @@ char const *acpi_gbl_exception_names_env[] =
231 "AE_OWNER_ID_LIMIT" 221 "AE_OWNER_ID_LIMIT"
232}; 222};
233 223
234char const *acpi_gbl_exception_names_pgm[] = 224char const *acpi_gbl_exception_names_pgm[] = {
235{
236 "AE_BAD_PARAMETER", 225 "AE_BAD_PARAMETER",
237 "AE_BAD_CHARACTER", 226 "AE_BAD_CHARACTER",
238 "AE_BAD_PATHNAME", 227 "AE_BAD_PATHNAME",
@@ -244,8 +233,7 @@ char const *acpi_gbl_exception_names_pgm[] =
244 "AE_BAD_DECIMAL_CONSTANT" 233 "AE_BAD_DECIMAL_CONSTANT"
245}; 234};
246 235
247char const *acpi_gbl_exception_names_tbl[] = 236char const *acpi_gbl_exception_names_tbl[] = {
248{
249 "AE_BAD_SIGNATURE", 237 "AE_BAD_SIGNATURE",
250 "AE_BAD_HEADER", 238 "AE_BAD_HEADER",
251 "AE_BAD_CHECKSUM", 239 "AE_BAD_CHECKSUM",
@@ -254,8 +242,7 @@ char const *acpi_gbl_exception_names_tbl[] =
254 "AE_INVALID_TABLE_LENGTH" 242 "AE_INVALID_TABLE_LENGTH"
255}; 243};
256 244
257char const *acpi_gbl_exception_names_aml[] = 245char const *acpi_gbl_exception_names_aml[] = {
258{
259 "AE_AML_ERROR", 246 "AE_AML_ERROR",
260 "AE_AML_PARSE", 247 "AE_AML_PARSE",
261 "AE_AML_BAD_OPCODE", 248 "AE_AML_BAD_OPCODE",
@@ -291,8 +278,7 @@ char const *acpi_gbl_exception_names_aml[] =
291 "AE_AML_BAD_RESOURCE_LENGTH" 278 "AE_AML_BAD_RESOURCE_LENGTH"
292}; 279};
293 280
294char const *acpi_gbl_exception_names_ctrl[] = 281char const *acpi_gbl_exception_names_ctrl[] = {
295{
296 "AE_CTRL_RETURN_VALUE", 282 "AE_CTRL_RETURN_VALUE",
297 "AE_CTRL_PENDING", 283 "AE_CTRL_PENDING",
298 "AE_CTRL_TERMINATE", 284 "AE_CTRL_TERMINATE",
@@ -306,6 +292,6 @@ char const *acpi_gbl_exception_names_ctrl[] =
306 "AE_CTRL_SKIP" 292 "AE_CTRL_SKIP"
307}; 293};
308 294
309#endif /* ACPI GLOBALS */ 295#endif /* ACPI GLOBALS */
310 296
311#endif /* __ACEXCEP_H__ */ 297#endif /* __ACEXCEP_H__ */
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index e3cf16eadbed..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,49 +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
153
154/* The root table can be either an RSDT or an XSDT */ 149/* The root table can be either an RSDT or an XSDT */
155 150
156ACPI_EXTERN u8 acpi_gbl_root_table_type; 151ACPI_EXTERN u8 acpi_gbl_root_table_type;
157#define ACPI_TABLE_TYPE_RSDT 'R' 152#define ACPI_TABLE_TYPE_RSDT 'R'
158#define ACPI_TABLE_TYPE_XSDT 'X' 153#define ACPI_TABLE_TYPE_XSDT 'X'
159 154
160
161/* 155/*
162 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: 156 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths:
163 * 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,
164 * 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.
165 */ 159 */
166ACPI_EXTERN u8 acpi_gbl_integer_bit_width; 160ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
167ACPI_EXTERN u8 acpi_gbl_integer_byte_width; 161ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
168ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; 162ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
169 163
170/* 164/*
171 * ACPI Table info arrays 165 * ACPI Table info arrays
172 */ 166 */
173extern 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];
174extern 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];
175 169
176/* 170/*
177 * Predefined mutex objects. This array contains the 171 * Predefined mutex objects. This array contains the
178 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. 172 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
179 * (The table maps local handles to the real OS handles) 173 * (The table maps local handles to the real OS handles)
180 */ 174 */
181ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; 175ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX];
182
183 176
184/***************************************************************************** 177/*****************************************************************************
185 * 178 *
@@ -191,53 +184,52 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX];
191 184
192/* Lists for tracking memory allocations */ 185/* Lists for tracking memory allocations */
193 186
194ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; 187ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
195ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; 188ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
196#endif 189#endif
197 190
198/* Object caches */ 191/* Object caches */
199 192
200ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache; 193ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache;
201ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache; 194ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache;
202ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache; 195ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache;
203ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; 196ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
204 197
205/* Global handlers */ 198/* Global handlers */
206 199
207ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify; 200ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
208ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; 201ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
209ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 202ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
210ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 203ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
211ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; 204ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
212ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore; 205ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;
213 206
214/* Misc */ 207/* Misc */
215 208
216ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; 209ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count;
217ACPI_EXTERN u32 acpi_gbl_original_mode; 210ACPI_EXTERN u32 acpi_gbl_original_mode;
218ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; 211ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
219ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; 212ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
220ACPI_EXTERN u32 acpi_gbl_ps_find_count; 213ACPI_EXTERN u32 acpi_gbl_ps_find_count;
221ACPI_EXTERN u32 acpi_gbl_owner_id_mask; 214ACPI_EXTERN u32 acpi_gbl_owner_id_mask;
222ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; 215ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
223ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 216ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
224ACPI_EXTERN u8 acpi_gbl_debugger_configuration; 217ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
225ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 218ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
226ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 219ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
227ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; 220ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
228ACPI_EXTERN u8 acpi_gbl_global_lock_present; 221ACPI_EXTERN u8 acpi_gbl_global_lock_present;
229ACPI_EXTERN u8 acpi_gbl_events_initialized; 222ACPI_EXTERN u8 acpi_gbl_events_initialized;
230ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; 223ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
231 224
232extern u8 acpi_gbl_shutdown; 225extern u8 acpi_gbl_shutdown;
233extern u32 acpi_gbl_startup_flags; 226extern u32 acpi_gbl_startup_flags;
234extern const u8 acpi_gbl_decode_to8bit[8]; 227extern const u8 acpi_gbl_decode_to8bit[8];
235extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; 228extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
236extern const char *acpi_gbl_highest_dstate_names[4]; 229extern const char *acpi_gbl_highest_dstate_names[4];
237extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; 230extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
238extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; 231extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
239extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS]; 232extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS];
240
241 233
242/***************************************************************************** 234/*****************************************************************************
243 * 235 *
@@ -253,36 +245,34 @@ extern const char *acpi_gbl_valid_osi_strings[ACPI_
253#define NUM_PREDEFINED_NAMES 9 245#define NUM_PREDEFINED_NAMES 9
254#endif 246#endif
255 247
256ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; 248ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
257ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; 249ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
258ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; 250ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
259 251
260extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; 252extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES];
261extern 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];
262 255
263#ifdef ACPI_DEBUG_OUTPUT 256#ifdef ACPI_DEBUG_OUTPUT
264ACPI_EXTERN u32 acpi_gbl_current_node_count; 257ACPI_EXTERN u32 acpi_gbl_current_node_count;
265ACPI_EXTERN u32 acpi_gbl_current_node_size; 258ACPI_EXTERN u32 acpi_gbl_current_node_size;
266ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; 259ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
267ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer; 260ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer;
268ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer; 261ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer;
269ACPI_EXTERN u32 acpi_gbl_deepest_nesting; 262ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
270#endif 263#endif
271 264
272
273/***************************************************************************** 265/*****************************************************************************
274 * 266 *
275 * Interpreter globals 267 * Interpreter globals
276 * 268 *
277 ****************************************************************************/ 269 ****************************************************************************/
278 270
279 271ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
280ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
281 272
282/* Control method single step flag */ 273/* Control method single step flag */
283 274
284ACPI_EXTERN u8 acpi_gbl_cm_single_step; 275ACPI_EXTERN u8 acpi_gbl_cm_single_step;
285
286 276
287/***************************************************************************** 277/*****************************************************************************
288 * 278 *
@@ -290,8 +280,7 @@ ACPI_EXTERN u8 acpi_gbl_cm_single_step;
290 * 280 *
291 ****************************************************************************/ 281 ****************************************************************************/
292 282
293ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root; 283ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root;
294
295 284
296/***************************************************************************** 285/*****************************************************************************
297 * 286 *
@@ -299,10 +288,10 @@ ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root;
299 * 288 *
300 ****************************************************************************/ 289 ****************************************************************************/
301 290
302extern struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG]; 291extern struct acpi_bit_register_info
303ACPI_EXTERN u8 acpi_gbl_sleep_type_a; 292 acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
304ACPI_EXTERN u8 acpi_gbl_sleep_type_b; 293ACPI_EXTERN u8 acpi_gbl_sleep_type_a;
305 294ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
306 295
307/***************************************************************************** 296/*****************************************************************************
308 * 297 *
@@ -310,12 +299,14 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
310 * 299 *
311 ****************************************************************************/ 300 ****************************************************************************/
312 301
313extern struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS]; 302extern struct acpi_fixed_event_info
314ACPI_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];
315ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 304ACPI_EXTERN struct acpi_fixed_event_handler
316ACPI_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];
317ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; 306ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
318 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;
319 310
320/***************************************************************************** 311/*****************************************************************************
321 * 312 *
@@ -323,58 +314,55 @@ ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
323 * 314 *
324 ****************************************************************************/ 315 ****************************************************************************/
325 316
326ACPI_EXTERN u8 acpi_gbl_db_output_flags; 317ACPI_EXTERN u8 acpi_gbl_db_output_flags;
327 318
328#ifdef ACPI_DISASSEMBLER 319#ifdef ACPI_DISASSEMBLER
329 320
330ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; 321ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
331ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; 322ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
332#endif 323#endif
333 324
334
335#ifdef ACPI_DEBUGGER 325#ifdef ACPI_DEBUGGER
336 326
337extern u8 acpi_gbl_method_executing; 327extern u8 acpi_gbl_method_executing;
338extern u8 acpi_gbl_abort_method; 328extern u8 acpi_gbl_abort_method;
339extern u8 acpi_gbl_db_terminate_threads; 329extern u8 acpi_gbl_db_terminate_threads;
340 330
341ACPI_EXTERN int optind; 331ACPI_EXTERN int optind;
342ACPI_EXTERN char *optarg; 332ACPI_EXTERN char *optarg;
343 333
344ACPI_EXTERN u8 acpi_gbl_db_opt_tables; 334ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
345ACPI_EXTERN u8 acpi_gbl_db_opt_stats; 335ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
346ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; 336ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
347 337
348 338ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
349ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; 339ACPI_EXTERN char acpi_gbl_db_line_buf[80];
350ACPI_EXTERN char acpi_gbl_db_line_buf[80]; 340ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
351ACPI_EXTERN char acpi_gbl_db_parsed_buf[80]; 341ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
352ACPI_EXTERN char acpi_gbl_db_scope_buf[40]; 342ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
353ACPI_EXTERN char acpi_gbl_db_debug_filename[40]; 343ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
354ACPI_EXTERN u8 acpi_gbl_db_output_to_file; 344ACPI_EXTERN char *acpi_gbl_db_buffer;
355ACPI_EXTERN char *acpi_gbl_db_buffer; 345ACPI_EXTERN char *acpi_gbl_db_filename;
356ACPI_EXTERN char *acpi_gbl_db_filename; 346ACPI_EXTERN u32 acpi_gbl_db_debug_level;
357ACPI_EXTERN u32 acpi_gbl_db_debug_level; 347ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
358ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; 348ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr;
359ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr; 349ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
360ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
361 350
362/* 351/*
363 * Statistic globals 352 * Statistic globals
364 */ 353 */
365ACPI_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];
366ACPI_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];
367ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc; 356ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc;
368ACPI_EXTERN u16 acpi_gbl_node_type_count_misc; 357ACPI_EXTERN u16 acpi_gbl_node_type_count_misc;
369ACPI_EXTERN u32 acpi_gbl_num_nodes; 358ACPI_EXTERN u32 acpi_gbl_num_nodes;
370ACPI_EXTERN u32 acpi_gbl_num_objects; 359ACPI_EXTERN u32 acpi_gbl_num_objects;
371
372 360
373ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree; 361ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree;
374ACPI_EXTERN u32 acpi_gbl_size_of_method_trees; 362ACPI_EXTERN u32 acpi_gbl_size_of_method_trees;
375ACPI_EXTERN u32 acpi_gbl_size_of_node_entries; 363ACPI_EXTERN u32 acpi_gbl_size_of_node_entries;
376ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; 364ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
377 365
378#endif /* ACPI_DEBUGGER */ 366#endif /* ACPI_DEBUGGER */
379 367
380#endif /* __ACGLOBAL_H__ */ 368#endif /* __ACGLOBAL_H__ */
diff --git a/include/acpi/achware.h b/include/acpi/achware.h
index cf5de4625a71..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 void);
147 112
148acpi_status 113acpi_status acpi_hw_enable_all_runtime_gpes(void);
149acpi_hw_enable_all_runtime_gpes (
150 void);
151 114
152acpi_status 115acpi_status acpi_hw_enable_all_wakeup_gpes(void);
153acpi_hw_enable_all_wakeup_gpes (
154 void);
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 4d2635698e10..9fba0fddda90 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -44,24 +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
58
59/* Forward declarations */ 56/* Forward declarations */
60 57
61struct acpi_walk_state ; 58struct acpi_walk_state;
62struct acpi_obj_mutex; 59struct acpi_obj_mutex;
63union acpi_parse_object ; 60union acpi_parse_object;
64
65 61
66/***************************************************************************** 62/*****************************************************************************
67 * 63 *
@@ -69,7 +65,6 @@ union acpi_parse_object ;
69 * 65 *
70 ****************************************************************************/ 66 ****************************************************************************/
71 67
72
73/* 68/*
74 * Predefined handles for the mutex objects used within the subsystem 69 * Predefined handles for the mutex objects used within the subsystem
75 * All mutex objects are automatically created by acpi_ut_mutex_initialize. 70 * All mutex objects are automatically created by acpi_ut_mutex_initialize.
@@ -96,14 +91,12 @@ union acpi_parse_object ;
96#define MAX_MUTEX 12 91#define MAX_MUTEX 12
97#define NUM_MUTEX MAX_MUTEX+1 92#define NUM_MUTEX MAX_MUTEX+1
98 93
99
100#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 94#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
101#ifdef DEFINE_ACPI_GLOBALS 95#ifdef DEFINE_ACPI_GLOBALS
102 96
103/* Names for the mutexes used in the subsystem */ 97/* Names for the mutexes used in the subsystem */
104 98
105static char *acpi_gbl_mutex_names[] = 99static char *acpi_gbl_mutex_names[] = {
106{
107 "ACPI_MTX_Execute", 100 "ACPI_MTX_Execute",
108 "ACPI_MTX_Interpreter", 101 "ACPI_MTX_Interpreter",
109 "ACPI_MTX_Parser", 102 "ACPI_MTX_Parser",
@@ -122,10 +115,9 @@ static char *acpi_gbl_mutex_names[] =
122#endif 115#endif
123#endif 116#endif
124 117
125
126/* Owner IDs are used to track namespace nodes for selective deletion */ 118/* Owner IDs are used to track namespace nodes for selective deletion */
127 119
128typedef u8 acpi_owner_id; 120typedef u8 acpi_owner_id;
129#define ACPI_OWNER_ID_MAX 0xFF 121#define ACPI_OWNER_ID_MAX 0xFF
130 122
131/* This Thread ID means that the mutex is not in use (unlocked) */ 123/* This Thread ID means that the mutex is not in use (unlocked) */
@@ -134,20 +126,17 @@ typedef u8 acpi_owner_id;
134 126
135/* Table for the global mutexes */ 127/* Table for the global mutexes */
136 128
137struct acpi_mutex_info 129struct acpi_mutex_info {
138{ 130 acpi_mutex mutex;
139 acpi_mutex mutex; 131 u32 use_count;
140 u32 use_count; 132 u32 thread_id;
141 u32 thread_id;
142}; 133};
143 134
144
145/* Lock flag parameter for various interfaces */ 135/* Lock flag parameter for various interfaces */
146 136
147#define ACPI_MTX_DO_NOT_LOCK 0 137#define ACPI_MTX_DO_NOT_LOCK 0
148#define ACPI_MTX_LOCK 1 138#define ACPI_MTX_LOCK 1
149 139
150
151/* Field access granularities */ 140/* Field access granularities */
152 141
153#define ACPI_FIELD_BYTE_GRANULARITY 1 142#define ACPI_FIELD_BYTE_GRANULARITY 1
@@ -155,7 +144,6 @@ struct acpi_mutex_info
155#define ACPI_FIELD_DWORD_GRANULARITY 4 144#define ACPI_FIELD_DWORD_GRANULARITY 4
156#define ACPI_FIELD_QWORD_GRANULARITY 8 145#define ACPI_FIELD_QWORD_GRANULARITY 8
157 146
158
159/***************************************************************************** 147/*****************************************************************************
160 * 148 *
161 * Namespace typedefs and structs 149 * Namespace typedefs and structs
@@ -164,15 +152,12 @@ struct acpi_mutex_info
164 152
165/* Operational modes of the AML interpreter/scanner */ 153/* Operational modes of the AML interpreter/scanner */
166 154
167typedef enum 155typedef enum {
168{ 156 ACPI_IMODE_LOAD_PASS1 = 0x01,
169 ACPI_IMODE_LOAD_PASS1 = 0x01, 157 ACPI_IMODE_LOAD_PASS2 = 0x02,
170 ACPI_IMODE_LOAD_PASS2 = 0x02, 158 ACPI_IMODE_EXECUTE = 0x0E
171 ACPI_IMODE_EXECUTE = 0x0E
172
173} acpi_interpreter_mode; 159} acpi_interpreter_mode;
174 160
175
176/* 161/*
177 * The Node describes a named object that appears in the AML 162 * The Node describes a named object that appears in the AML
178 * An acpi_node is used to store Nodes. 163 * An acpi_node is used to store Nodes.
@@ -180,41 +165,37 @@ typedef enum
180 * data_type is used to differentiate between internal descriptors, and MUST 165 * data_type is used to differentiate between internal descriptors, and MUST
181 * be the first byte in this structure. 166 * be the first byte in this structure.
182 */ 167 */
183union acpi_name_union 168union acpi_name_union {
184{ 169 u32 integer;
185 u32 integer; 170 char ascii[4];
186 char ascii[4]; 171};
187}; 172
188 173struct acpi_namespace_node {
189struct acpi_namespace_node 174 u8 descriptor; /* Used to differentiate object descriptor types */
190{ 175 u8 type; /* Type associated with this name */
191 u8 descriptor; /* Used to differentiate object descriptor types */ 176 u16 reference_count; /* Current count of references and children */
192 u8 type; /* Type associated with this name */ 177 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
193 u16 reference_count; /* Current count of references and children */ 178 union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */
194 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ 179 struct acpi_namespace_node *child; /* First child */
195 union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */ 180 struct acpi_namespace_node *peer; /* Next peer */
196 struct acpi_namespace_node *child; /* First child */ 181 u8 owner_id; /* Who created this node */
197 struct acpi_namespace_node *peer; /* Next peer*/ 182 u8 flags;
198 u8 owner_id; /* Who created this node */
199 u8 flags;
200 183
201 /* Fields used by the ASL compiler only */ 184 /* Fields used by the ASL compiler only */
202 185
203#ifdef ACPI_ASL_COMPILER 186#ifdef ACPI_ASL_COMPILER
204 u32 value; 187 u32 value;
205 union acpi_parse_object *op; 188 union acpi_parse_object *op;
206#endif 189#endif
207}; 190};
208 191
209
210#define ACPI_ENTRY_NOT_FOUND NULL 192#define ACPI_ENTRY_NOT_FOUND NULL
211 193
212
213/* Node flags */ 194/* Node flags */
214 195
215#define ANOBJ_RESERVED 0x01 196#define ANOBJ_RESERVED 0x01
216#define ANOBJ_END_OF_PEER_LIST 0x02 197#define ANOBJ_END_OF_PEER_LIST 0x02
217#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ 198#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */
218#define ANOBJ_METHOD_ARG 0x08 199#define ANOBJ_METHOD_ARG 0x08
219#define ANOBJ_METHOD_LOCAL 0x10 200#define ANOBJ_METHOD_LOCAL 0x10
220#define ANOBJ_METHOD_NO_RETVAL 0x20 201#define ANOBJ_METHOD_NO_RETVAL 0x20
@@ -224,91 +205,77 @@ struct acpi_namespace_node
224/* 205/*
225 * ACPI Table Descriptor. One per ACPI table 206 * ACPI Table Descriptor. One per ACPI table
226 */ 207 */
227struct acpi_table_desc 208struct acpi_table_desc {
228{ 209 struct acpi_table_desc *prev;
229 struct acpi_table_desc *prev; 210 struct acpi_table_desc *next;
230 struct acpi_table_desc *next; 211 struct acpi_table_desc *installed_desc;
231 struct acpi_table_desc *installed_desc; 212 struct acpi_table_header *pointer;
232 struct acpi_table_header *pointer; 213 u8 *aml_start;
233 u8 *aml_start; 214 u64 physical_address;
234 u64 physical_address; 215 u32 aml_length;
235 u32 aml_length; 216 acpi_size length;
236 acpi_size length; 217 acpi_owner_id owner_id;
237 acpi_owner_id owner_id; 218 u8 type;
238 u8 type; 219 u8 allocation;
239 u8 allocation; 220 u8 loaded_into_namespace;
240 u8 loaded_into_namespace;
241}; 221};
242 222
243struct acpi_table_list 223struct acpi_table_list {
244{ 224 struct acpi_table_desc *next;
245 struct acpi_table_desc *next; 225 u32 count;
246 u32 count;
247}; 226};
248 227
249 228struct acpi_find_context {
250struct acpi_find_context 229 char *search_for;
251{ 230 acpi_handle *list;
252 char *search_for; 231 u32 *count;
253 acpi_handle *list;
254 u32 *count;
255}; 232};
256 233
257 234struct acpi_ns_search_data {
258struct acpi_ns_search_data 235 struct acpi_namespace_node *node;
259{
260 struct acpi_namespace_node *node;
261}; 236};
262 237
263
264/* 238/*
265 * Predefined Namespace items 239 * Predefined Namespace items
266 */ 240 */
267struct acpi_predefined_names 241struct acpi_predefined_names {
268{ 242 char *name;
269 char *name; 243 u8 type;
270 u8 type; 244 char *val;
271 char *val;
272}; 245};
273 246
274
275/* Object types used during package copies */ 247/* Object types used during package copies */
276 248
277
278#define ACPI_COPY_TYPE_SIMPLE 0 249#define ACPI_COPY_TYPE_SIMPLE 0
279#define ACPI_COPY_TYPE_PACKAGE 1 250#define ACPI_COPY_TYPE_PACKAGE 1
280 251
281/* Info structure used to convert external<->internal namestrings */ 252/* Info structure used to convert external<->internal namestrings */
282 253
283struct acpi_namestring_info 254struct acpi_namestring_info {
284{ 255 char *external_name;
285 char *external_name; 256 char *next_external_char;
286 char *next_external_char; 257 char *internal_name;
287 char *internal_name; 258 u32 length;
288 u32 length; 259 u32 num_segments;
289 u32 num_segments; 260 u32 num_carats;
290 u32 num_carats; 261 u8 fully_qualified;
291 u8 fully_qualified;
292}; 262};
293 263
294
295/* Field creation info */ 264/* Field creation info */
296 265
297struct acpi_create_field_info 266struct acpi_create_field_info {
298{ 267 struct acpi_namespace_node *region_node;
299 struct acpi_namespace_node *region_node; 268 struct acpi_namespace_node *field_node;
300 struct acpi_namespace_node *field_node; 269 struct acpi_namespace_node *register_node;
301 struct acpi_namespace_node *register_node; 270 struct acpi_namespace_node *data_register_node;
302 struct acpi_namespace_node *data_register_node; 271 u32 bank_value;
303 u32 bank_value; 272 u32 field_bit_position;
304 u32 field_bit_position; 273 u32 field_bit_length;
305 u32 field_bit_length; 274 u8 field_flags;
306 u8 field_flags; 275 u8 attribute;
307 u8 attribute; 276 u8 field_type;
308 u8 field_type;
309}; 277};
310 278
311
312/***************************************************************************** 279/*****************************************************************************
313 * 280 *
314 * Event typedefs and structs 281 * Event typedefs and structs
@@ -317,108 +284,95 @@ struct acpi_create_field_info
317 284
318/* 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 */
319 286
320struct acpi_handler_info 287struct acpi_handler_info {
321{ 288 acpi_event_handler address; /* Address of handler, if any */
322 acpi_event_handler address; /* Address of handler, if any */ 289 void *context; /* Context to be passed to handler */
323 void *context; /* Context to be passed to handler */ 290 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
324 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
325}; 291};
326 292
327union acpi_gpe_dispatch_info 293union acpi_gpe_dispatch_info {
328{ 294 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
329 struct acpi_namespace_node *method_node; /* Method node for this GPE level */ 295 struct acpi_handler_info *handler;
330 struct acpi_handler_info *handler;
331}; 296};
332 297
333/* 298/*
334 * Information about a GPE, one per each GPE in an array. 299 * Information about a GPE, one per each GPE in an array.
335 * NOTE: Important to keep this struct as small as possible. 300 * NOTE: Important to keep this struct as small as possible.
336 */ 301 */
337struct acpi_gpe_event_info 302struct acpi_gpe_event_info {
338{ 303 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
339 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ 304 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
340 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ 305 u8 flags; /* Misc info about this GPE */
341 u8 flags; /* Misc info about this GPE */ 306 u8 register_bit; /* This GPE bit within the register */
342 u8 register_bit; /* This GPE bit within the register */
343}; 307};
344 308
345/* 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 */
346 310
347struct acpi_gpe_register_info 311struct acpi_gpe_register_info {
348{ 312 struct acpi_generic_address status_address; /* Address of status reg */
349 struct acpi_generic_address status_address; /* Address of status reg */ 313 struct acpi_generic_address enable_address; /* Address of enable reg */
350 struct acpi_generic_address enable_address; /* Address of enable reg */ 314 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
351 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ 315 u8 enable_for_run; /* GPEs to keep enabled when running */
352 u8 enable_for_run; /* GPEs to keep enabled when running */ 316 u8 base_gpe_number; /* Base GPE number for this register */
353 u8 base_gpe_number; /* Base GPE number for this register */
354}; 317};
355 318
356/* 319/*
357 * Information about a GPE register block, one per each installed block -- 320 * Information about a GPE register block, one per each installed block --
358 * GPE0, GPE1, and one per each installed GPE Block Device. 321 * GPE0, GPE1, and one per each installed GPE Block Device.
359 */ 322 */
360struct acpi_gpe_block_info 323struct acpi_gpe_block_info {
361{ 324 struct acpi_namespace_node *node;
362 struct acpi_namespace_node *node; 325 struct acpi_gpe_block_info *previous;
363 struct acpi_gpe_block_info *previous; 326 struct acpi_gpe_block_info *next;
364 struct acpi_gpe_block_info *next; 327 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
365 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ 328 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
366 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ 329 struct acpi_gpe_event_info *event_info; /* One for each GPE */
367 struct acpi_gpe_event_info *event_info; /* One for each GPE */ 330 struct acpi_generic_address block_address; /* Base address of the block */
368 struct acpi_generic_address block_address; /* Base address of the block */ 331 u32 register_count; /* Number of register pairs in block */
369 u32 register_count; /* Number of register pairs in block */ 332 u8 block_base_number; /* Base GPE number for this block */
370 u8 block_base_number;/* Base GPE number for this block */
371}; 333};
372 334
373/* 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 */
374 336
375struct acpi_gpe_xrupt_info 337struct acpi_gpe_xrupt_info {
376{ 338 struct acpi_gpe_xrupt_info *previous;
377 struct acpi_gpe_xrupt_info *previous; 339 struct acpi_gpe_xrupt_info *next;
378 struct acpi_gpe_xrupt_info *next; 340 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
379 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ 341 u32 interrupt_number; /* System interrupt number */
380 u32 interrupt_number; /* System interrupt number */
381}; 342};
382 343
383 344struct acpi_gpe_walk_info {
384struct acpi_gpe_walk_info 345 struct acpi_namespace_node *gpe_device;
385{ 346 struct acpi_gpe_block_info *gpe_block;
386 struct acpi_namespace_node *gpe_device;
387 struct acpi_gpe_block_info *gpe_block;
388}; 347};
389 348
390 349typedef acpi_status(*ACPI_GPE_CALLBACK) (struct acpi_gpe_xrupt_info *
391typedef acpi_status (*ACPI_GPE_CALLBACK) ( 350 gpe_xrupt_info,
392 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 351 struct acpi_gpe_block_info *
393 struct acpi_gpe_block_info *gpe_block); 352 gpe_block);
394
395 353
396/* Information about each particular fixed event */ 354/* Information about each particular fixed event */
397 355
398struct acpi_fixed_event_handler 356struct acpi_fixed_event_handler {
399{ 357 acpi_event_handler handler; /* Address of handler. */
400 acpi_event_handler handler; /* Address of handler. */ 358 void *context; /* Context to be passed to handler */
401 void *context; /* Context to be passed to handler */
402}; 359};
403 360
404struct acpi_fixed_event_info 361struct acpi_fixed_event_info {
405{ 362 u8 status_register_id;
406 u8 status_register_id; 363 u8 enable_register_id;
407 u8 enable_register_id; 364 u16 status_bit_mask;
408 u16 status_bit_mask; 365 u16 enable_bit_mask;
409 u16 enable_bit_mask;
410}; 366};
411 367
412/* Information used during field processing */ 368/* Information used during field processing */
413 369
414struct acpi_field_info 370struct acpi_field_info {
415{ 371 u8 skip_field;
416 u8 skip_field; 372 u8 field_flag;
417 u8 field_flag; 373 u32 pkg_length;
418 u32 pkg_length;
419}; 374};
420 375
421
422/***************************************************************************** 376/*****************************************************************************
423 * 377 *
424 * Generic "state" object for stacks 378 * Generic "state" object for stacks
@@ -431,7 +385,6 @@ struct acpi_field_info
431#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 385#define ACPI_CONTROL_PREDICATE_FALSE 0xC3
432#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 386#define ACPI_CONTROL_PREDICATE_TRUE 0xC4
433 387
434
435#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ 388#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\
436 u8 data_type; /* To differentiate various internal objs */\ 389 u8 data_type; /* To differentiate various internal objs */\
437 u8 flags; \ 390 u8 flags; \
@@ -440,147 +393,112 @@ struct acpi_field_info
440 u16 reserved; \ 393 u16 reserved; \
441 void *next; \ 394 void *next; \
442 395
443struct acpi_common_state 396struct acpi_common_state {
444{ 397ACPI_STATE_COMMON};
445 ACPI_STATE_COMMON
446};
447
448 398
449/* 399/*
450 * Update state - used to traverse complex objects such as packages 400 * Update state - used to traverse complex objects such as packages
451 */ 401 */
452struct acpi_update_state 402struct acpi_update_state {
453{ 403 ACPI_STATE_COMMON union acpi_operand_object *object;
454 ACPI_STATE_COMMON
455 union acpi_operand_object *object;
456}; 404};
457 405
458
459/* 406/*
460 * Pkg state - used to traverse nested package structures 407 * Pkg state - used to traverse nested package structures
461 */ 408 */
462struct acpi_pkg_state 409struct acpi_pkg_state {
463{ 410 ACPI_STATE_COMMON union acpi_operand_object *source_object;
464 ACPI_STATE_COMMON 411 union acpi_operand_object *dest_object;
465 union acpi_operand_object *source_object; 412 struct acpi_walk_state *walk_state;
466 union acpi_operand_object *dest_object; 413 void *this_target_obj;
467 struct acpi_walk_state *walk_state; 414 u32 num_packages;
468 void *this_target_obj; 415 u16 index;
469 u32 num_packages;
470 u16 index;
471}; 416};
472 417
473
474/* 418/*
475 * Control state - one per if/else and while constructs. 419 * Control state - one per if/else and while constructs.
476 * Allows nesting of these constructs 420 * Allows nesting of these constructs
477 */ 421 */
478struct acpi_control_state 422struct acpi_control_state {
479{ 423 ACPI_STATE_COMMON union acpi_parse_object *predicate_op;
480 ACPI_STATE_COMMON 424 u8 *aml_predicate_start; /* Start of if/while predicate */
481 union acpi_parse_object *predicate_op; 425 u8 *package_end; /* End of if/while block */
482 u8 *aml_predicate_start; /* Start of if/while predicate */ 426 u16 opcode;
483 u8 *package_end; /* End of if/while block */
484 u16 opcode;
485}; 427};
486 428
487
488/* 429/*
489 * Scope state - current scope during namespace lookups 430 * Scope state - current scope during namespace lookups
490 */ 431 */
491struct acpi_scope_state 432struct acpi_scope_state {
492{ 433 ACPI_STATE_COMMON struct acpi_namespace_node *node;
493 ACPI_STATE_COMMON
494 struct acpi_namespace_node *node;
495}; 434};
496 435
497 436struct acpi_pscope_state {
498struct acpi_pscope_state 437 ACPI_STATE_COMMON union acpi_parse_object *op; /* Current op being parsed */
499{ 438 u8 *arg_end; /* Current argument end */
500 ACPI_STATE_COMMON 439 u8 *pkg_end; /* Current package end */
501 union acpi_parse_object *op; /* Current op being parsed */ 440 u32 arg_list; /* Next argument to parse */
502 u8 *arg_end; /* Current argument end */ 441 u32 arg_count; /* Number of fixed arguments */
503 u8 *pkg_end; /* Current package end */
504 u32 arg_list; /* Next argument to parse */
505 u32 arg_count; /* Number of fixed arguments */
506}; 442};
507 443
508
509/* 444/*
510 * Thread state - one per thread across multiple walk states. Multiple walk 445 * Thread state - one per thread across multiple walk states. Multiple walk
511 * states are created when there are nested control methods executing. 446 * states are created when there are nested control methods executing.
512 */ 447 */
513struct acpi_thread_state 448struct acpi_thread_state {
514{ 449 ACPI_STATE_COMMON struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
515 ACPI_STATE_COMMON 450 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
516 struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ 451 u32 thread_id; /* Running thread ID */
517 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ 452 u8 current_sync_level; /* Mutex Sync (nested acquire) level */
518 u32 thread_id; /* Running thread ID */
519 u8 current_sync_level; /* Mutex Sync (nested acquire) level */
520}; 453};
521 454
522
523/* 455/*
524 * Result values - used to accumulate the results of nested 456 * Result values - used to accumulate the results of nested
525 * AML arguments 457 * AML arguments
526 */ 458 */
527struct acpi_result_values 459struct acpi_result_values {
528{
529 ACPI_STATE_COMMON 460 ACPI_STATE_COMMON
530 union acpi_operand_object *obj_desc [ACPI_OBJ_NUM_OPERANDS]; 461 union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS];
531 u8 num_results; 462 u8 num_results;
532 u8 last_insert; 463 u8 last_insert;
533}; 464};
534 465
535
536typedef 466typedef
537acpi_status (*acpi_parse_downwards) ( 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 union acpi_parse_object **out_op);
540
541typedef
542acpi_status (*acpi_parse_upwards) (
543 struct acpi_walk_state *walk_state);
544 469
470typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
545 471
546/* 472/*
547 * Notify info - used to pass info to the deferred notify 473 * Notify info - used to pass info to the deferred notify
548 * handler/dispatcher. 474 * handler/dispatcher.
549 */ 475 */
550struct acpi_notify_info 476struct acpi_notify_info {
551{ 477 ACPI_STATE_COMMON struct acpi_namespace_node *node;
552 ACPI_STATE_COMMON 478 union acpi_operand_object *handler_obj;
553 struct acpi_namespace_node *node;
554 union acpi_operand_object *handler_obj;
555}; 479};
556 480
557
558/* Generic state is union of structs above */ 481/* Generic state is union of structs above */
559 482
560union acpi_generic_state 483union acpi_generic_state {
561{ 484 struct acpi_common_state common;
562 struct acpi_common_state common; 485 struct acpi_control_state control;
563 struct acpi_control_state control; 486 struct acpi_update_state update;
564 struct acpi_update_state update; 487 struct acpi_scope_state scope;
565 struct acpi_scope_state scope; 488 struct acpi_pscope_state parse_scope;
566 struct acpi_pscope_state parse_scope; 489 struct acpi_pkg_state pkg;
567 struct acpi_pkg_state pkg; 490 struct acpi_thread_state thread;
568 struct acpi_thread_state thread; 491 struct acpi_result_values results;
569 struct acpi_result_values results; 492 struct acpi_notify_info notify;
570 struct acpi_notify_info notify;
571}; 493};
572 494
573
574/***************************************************************************** 495/*****************************************************************************
575 * 496 *
576 * Interpreter typedefs and structs 497 * Interpreter typedefs and structs
577 * 498 *
578 ****************************************************************************/ 499 ****************************************************************************/
579 500
580typedef 501typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
581acpi_status (*ACPI_EXECUTE_OP) (
582 struct acpi_walk_state *walk_state);
583
584 502
585/***************************************************************************** 503/*****************************************************************************
586 * 504 *
@@ -591,28 +509,26 @@ acpi_status (*ACPI_EXECUTE_OP) (
591/* 509/*
592 * AML opcode, name, and argument layout 510 * AML opcode, name, and argument layout
593 */ 511 */
594struct acpi_opcode_info 512struct acpi_opcode_info {
595{
596#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) 513#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
597 char *name; /* Opcode name (disassembler/debug only) */ 514 char *name; /* Opcode name (disassembler/debug only) */
598#endif 515#endif
599 u32 parse_args; /* Grammar/Parse time arguments */ 516 u32 parse_args; /* Grammar/Parse time arguments */
600 u32 runtime_args; /* Interpret time arguments */ 517 u32 runtime_args; /* Interpret time arguments */
601 u32 flags; /* Misc flags */ 518 u32 flags; /* Misc flags */
602 u8 object_type; /* Corresponding internal object type */ 519 u8 object_type; /* Corresponding internal object type */
603 u8 class; /* Opcode class */ 520 u8 class; /* Opcode class */
604 u8 type; /* Opcode type */ 521 u8 type; /* Opcode type */
605}; 522};
606 523
607union acpi_parse_value 524union acpi_parse_value {
608{ 525 acpi_integer integer; /* Integer constant (Up to 64 bits) */
609 acpi_integer integer; /* Integer constant (Up to 64 bits) */ 526 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
610 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ 527 u32 size; /* bytelist or field size */
611 u32 size; /* bytelist or field size */ 528 char *string; /* NULL terminated string */
612 char *string; /* NULL terminated string */ 529 u8 *buffer; /* buffer or string */
613 u8 *buffer; /* buffer or string */ 530 char *name; /* NULL terminated string */
614 char *name; /* NULL terminated string */ 531 union acpi_parse_object *arg; /* arguments and contained ops */
615 union acpi_parse_object *arg; /* arguments and contained ops */
616}; 532};
617 533
618#define ACPI_PARSE_COMMON \ 534#define ACPI_PARSE_COMMON \
@@ -641,84 +557,72 @@ union acpi_parse_value
641/* 557/*
642 * generic operation (for example: If, While, Store) 558 * generic operation (for example: If, While, Store)
643 */ 559 */
644struct acpi_parse_obj_common 560struct acpi_parse_obj_common {
645{ 561ACPI_PARSE_COMMON};
646 ACPI_PARSE_COMMON
647};
648
649 562
650/* 563/*
651 * 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),
652 * and bytelists. 565 * and bytelists.
653 */ 566 */
654struct acpi_parse_obj_named 567struct acpi_parse_obj_named {
655{ 568 ACPI_PARSE_COMMON u8 * path;
656 ACPI_PARSE_COMMON 569 u8 *data; /* AML body or bytelist data */
657 u8 *path; 570 u32 length; /* AML length */
658 u8 *data; /* AML body or bytelist data */ 571 u32 name; /* 4-byte name or zero if no name */
659 u32 length; /* AML length */
660 u32 name; /* 4-byte name or zero if no name */
661}; 572};
662 573
663
664/* The parse node is the fundamental element of the parse tree */ 574/* The parse node is the fundamental element of the parse tree */
665 575
666struct acpi_parse_obj_asl 576struct acpi_parse_obj_asl {
667{ 577 ACPI_PARSE_COMMON union acpi_parse_object *child;
668 ACPI_PARSE_COMMON 578 union acpi_parse_object *parent_method;
669 union acpi_parse_object *child; 579 char *filename;
670 union acpi_parse_object *parent_method; 580 char *external_name;
671 char *filename; 581 char *namepath;
672 char *external_name; 582 char name_seg[4];
673 char *namepath; 583 u32 extra_value;
674 char name_seg[4]; 584 u32 column;
675 u32 extra_value; 585 u32 line_number;
676 u32 column; 586 u32 logical_line_number;
677 u32 line_number; 587 u32 logical_byte_offset;
678 u32 logical_line_number; 588 u32 end_line;
679 u32 logical_byte_offset; 589 u32 end_logical_line;
680 u32 end_line; 590 u32 acpi_btype;
681 u32 end_logical_line; 591 u32 aml_length;
682 u32 acpi_btype; 592 u32 aml_subtree_length;
683 u32 aml_length; 593 u32 final_aml_length;
684 u32 aml_subtree_length; 594 u32 final_aml_offset;
685 u32 final_aml_length; 595 u32 compile_flags;
686 u32 final_aml_offset; 596 u16 parse_opcode;
687 u32 compile_flags; 597 u8 aml_opcode_length;
688 u16 parse_opcode; 598 u8 aml_pkg_len_bytes;
689 u8 aml_opcode_length; 599 u8 extra;
690 u8 aml_pkg_len_bytes; 600 char parse_op_name[12];
691 u8 extra; 601};
692 char parse_op_name[12]; 602
693}; 603union acpi_parse_object {
694 604 struct acpi_parse_obj_common common;
695union acpi_parse_object 605 struct acpi_parse_obj_named named;
696{ 606 struct acpi_parse_obj_asl asl;
697 struct acpi_parse_obj_common common;
698 struct acpi_parse_obj_named named;
699 struct acpi_parse_obj_asl asl;
700}; 607};
701 608
702
703/* 609/*
704 * Parse state - one state per parser invocation and each control 610 * Parse state - one state per parser invocation and each control
705 * method. 611 * method.
706 */ 612 */
707struct acpi_parse_state 613struct acpi_parse_state {
708{ 614 u32 aml_size;
709 u32 aml_size; 615 u8 *aml_start; /* First AML byte */
710 u8 *aml_start; /* First AML byte */ 616 u8 *aml; /* Next AML byte */
711 u8 *aml; /* Next AML byte */ 617 u8 *aml_end; /* (last + 1) AML byte */
712 u8 *aml_end; /* (last + 1) AML byte */ 618 u8 *pkg_start; /* Current package begin */
713 u8 *pkg_start; /* Current package begin */ 619 u8 *pkg_end; /* Current package end */
714 u8 *pkg_end; /* Current package end */ 620 union acpi_parse_object *start_op; /* Root of parse tree */
715 union acpi_parse_object *start_op; /* Root of parse tree */ 621 struct acpi_namespace_node *start_node;
716 struct acpi_namespace_node *start_node; 622 union acpi_generic_state *scope; /* Current scope */
717 union acpi_generic_state *scope; /* Current scope */ 623 union acpi_parse_object *start_scope;
718 union acpi_parse_object *start_scope;
719}; 624};
720 625
721
722/* Parse object flags */ 626/* Parse object flags */
723 627
724#define ACPI_PARSEOP_GENERIC 0x01 628#define ACPI_PARSEOP_GENERIC 0x01
@@ -734,7 +638,6 @@ struct acpi_parse_state
734#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 638#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
735#define ACPI_PARSEOP_SPECIAL 0x10 639#define ACPI_PARSEOP_SPECIAL 0x10
736 640
737
738/***************************************************************************** 641/*****************************************************************************
739 * 642 *
740 * Hardware (ACPI registers) and PNP 643 * Hardware (ACPI registers) and PNP
@@ -744,14 +647,12 @@ struct acpi_parse_state
744#define PCI_ROOT_HID_STRING "PNP0A03" 647#define PCI_ROOT_HID_STRING "PNP0A03"
745#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" 648#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
746 649
747struct acpi_bit_register_info 650struct acpi_bit_register_info {
748{ 651 u8 parent_register;
749 u8 parent_register; 652 u8 bit_position;
750 u8 bit_position; 653 u16 access_bit_mask;
751 u16 access_bit_mask;
752}; 654};
753 655
754
755/* 656/*
756 * Register IDs 657 * Register IDs
757 * These are the full ACPI registers 658 * These are the full ACPI registers
@@ -766,7 +667,6 @@ struct acpi_bit_register_info
766#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 667#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
767#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 668#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
768 669
769
770/* Masks used to access the bit_registers */ 670/* Masks used to access the bit_registers */
771 671
772#define ACPI_BITMASK_TIMER_STATUS 0x0001 672#define ACPI_BITMASK_TIMER_STATUS 0x0001
@@ -775,7 +675,7 @@ struct acpi_bit_register_info
775#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 675#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
776#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 676#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
777#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 677#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
778#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ 678#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
779#define ACPI_BITMASK_WAKE_STATUS 0x8000 679#define ACPI_BITMASK_WAKE_STATUS 0x8000
780 680
781#define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ 681#define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \
@@ -791,7 +691,7 @@ struct acpi_bit_register_info
791#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 691#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
792#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 692#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
793#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 693#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
794#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ 694#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
795 695
796#define ACPI_BITMASK_SCI_ENABLE 0x0001 696#define ACPI_BITMASK_SCI_ENABLE 0x0001
797#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 697#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
@@ -801,7 +701,6 @@ struct acpi_bit_register_info
801 701
802#define ACPI_BITMASK_ARB_DISABLE 0x0001 702#define ACPI_BITMASK_ARB_DISABLE 0x0001
803 703
804
805/* Raw bit position of each bit_register */ 704/* Raw bit position of each bit_register */
806 705
807#define ACPI_BITPOSITION_TIMER_STATUS 0x00 706#define ACPI_BITPOSITION_TIMER_STATUS 0x00
@@ -810,7 +709,7 @@ struct acpi_bit_register_info
810#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 709#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
811#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 710#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
812#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A 711#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
813#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ 712#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
814#define ACPI_BITPOSITION_WAKE_STATUS 0x0F 713#define ACPI_BITPOSITION_WAKE_STATUS 0x0F
815 714
816#define ACPI_BITPOSITION_TIMER_ENABLE 0x00 715#define ACPI_BITPOSITION_TIMER_ENABLE 0x00
@@ -818,7 +717,7 @@ struct acpi_bit_register_info
818#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 717#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
819#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 718#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
820#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A 719#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
821#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ 720#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
822 721
823#define ACPI_BITPOSITION_SCI_ENABLE 0x00 722#define ACPI_BITPOSITION_SCI_ENABLE 0x00
824#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 723#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
@@ -828,7 +727,6 @@ struct acpi_bit_register_info
828 727
829#define ACPI_BITPOSITION_ARB_DISABLE 0x00 728#define ACPI_BITPOSITION_ARB_DISABLE 0x00
830 729
831
832/***************************************************************************** 730/*****************************************************************************
833 * 731 *
834 * Resource descriptors 732 * Resource descriptors
@@ -847,8 +745,7 @@ struct acpi_bit_register_info
847#define ACPI_RDESC_TYPE_SMALL 0x00 745#define ACPI_RDESC_TYPE_SMALL 0x00
848 746
849#define ACPI_RDESC_TYPE_MASK 0x80 747#define ACPI_RDESC_TYPE_MASK 0x80
850#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 */
851
852 749
853/* 750/*
854 * Small resource descriptor types 751 * Small resource descriptor types
@@ -877,7 +774,6 @@ struct acpi_bit_register_info
877#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A 774#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A
878#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B 775#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B
879 776
880
881/***************************************************************************** 777/*****************************************************************************
882 * 778 *
883 * Miscellaneous 779 * Miscellaneous
@@ -886,35 +782,30 @@ struct acpi_bit_register_info
886 782
887#define ACPI_ASCII_ZERO 0x30 783#define ACPI_ASCII_ZERO 0x30
888 784
889
890/***************************************************************************** 785/*****************************************************************************
891 * 786 *
892 * Debugger 787 * Debugger
893 * 788 *
894 ****************************************************************************/ 789 ****************************************************************************/
895 790
896struct acpi_db_method_info 791struct acpi_db_method_info {
897{ 792 acpi_handle thread_gate;
898 acpi_handle thread_gate; 793 char *name;
899 char *name; 794 char **args;
900 char **args; 795 u32 flags;
901 u32 flags; 796 u32 num_loops;
902 u32 num_loops; 797 char pathname[128];
903 char pathname[128];
904}; 798};
905 799
906struct acpi_integrity_info 800struct acpi_integrity_info {
907{ 801 u32 nodes;
908 u32 nodes; 802 u32 objects;
909 u32 objects;
910}; 803};
911 804
912
913#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 805#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
914#define ACPI_DB_CONSOLE_OUTPUT 0x02 806#define ACPI_DB_CONSOLE_OUTPUT 0x02
915#define ACPI_DB_DUPLICATE_OUTPUT 0x03 807#define ACPI_DB_DUPLICATE_OUTPUT 0x03
916 808
917
918/***************************************************************************** 809/*****************************************************************************
919 * 810 *
920 * Debug 811 * Debug
@@ -936,43 +827,36 @@ struct acpi_integrity_info
936 char module[ACPI_MAX_MODULE_NAME]; \ 827 char module[ACPI_MAX_MODULE_NAME]; \
937 u8 alloc_type; 828 u8 alloc_type;
938 829
939struct acpi_debug_mem_header 830struct acpi_debug_mem_header {
940{ 831ACPI_COMMON_DEBUG_MEM_HEADER};
941 ACPI_COMMON_DEBUG_MEM_HEADER
942};
943 832
944struct acpi_debug_mem_block 833struct acpi_debug_mem_block {
945{ 834 ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
946 ACPI_COMMON_DEBUG_MEM_HEADER
947 u64 user_space;
948}; 835};
949 836
950
951#define ACPI_MEM_LIST_GLOBAL 0 837#define ACPI_MEM_LIST_GLOBAL 0
952#define ACPI_MEM_LIST_NSNODE 1 838#define ACPI_MEM_LIST_NSNODE 1
953#define ACPI_MEM_LIST_MAX 1 839#define ACPI_MEM_LIST_MAX 1
954#define ACPI_NUM_MEM_LISTS 2 840#define ACPI_NUM_MEM_LISTS 2
955 841
956 842struct acpi_memory_list {
957struct acpi_memory_list 843 char *list_name;
958{ 844 void *list_head;
959 char *list_name; 845 u16 object_size;
960 void *list_head; 846 u16 max_depth;
961 u16 object_size; 847 u16 current_depth;
962 u16 max_depth; 848 u16 link_offset;
963 u16 current_depth;
964 u16 link_offset;
965 849
966#ifdef ACPI_DBG_TRACK_ALLOCATIONS 850#ifdef ACPI_DBG_TRACK_ALLOCATIONS
967 851
968 /* Statistics for debug memory tracking only */ 852 /* Statistics for debug memory tracking only */
969 853
970 u32 total_allocated; 854 u32 total_allocated;
971 u32 total_freed; 855 u32 total_freed;
972 u32 current_total_size; 856 u32 current_total_size;
973 u32 requests; 857 u32 requests;
974 u32 hits; 858 u32 hits;
975#endif 859#endif
976}; 860};
977 861
978#endif /* __ACLOCAL_H__ */ 862#endif /* __ACLOCAL_H__ */
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index fcdef0a4b01b..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,7 +423,6 @@
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 */
@@ -554,20 +546,17 @@
554#define ACPI_DEBUG_ONLY_MEMBERS(a) a; 546#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
555#define _VERBOSE_STRUCTURES 547#define _VERBOSE_STRUCTURES
556 548
557
558/* Stack and buffer dumping */ 549/* Stack and buffer dumping */
559 550
560#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)
561#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__) 552#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__)
562 553
563
564#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)
565#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)
566#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) 556#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
567#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)
568#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))
569 559
570
571/* 560/*
572 * Generate INT3 on ACPI_ERROR (Debug only!) 561 * Generate INT3 on ACPI_ERROR (Debug only!)
573 */ 562 */
@@ -588,7 +577,6 @@
588#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)
589#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)
590 579
591
592#else 580#else
593/* 581/*
594 * This is the non-debug case -- make everything go away, 582 * This is the non-debug case -- make everything go away,
@@ -639,7 +627,6 @@
639#define ACPI_DEBUGGER_EXEC(a) 627#define ACPI_DEBUGGER_EXEC(a)
640#endif 628#endif
641 629
642
643/* 630/*
644 * 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
645 * we are using ACPI_DEBUG_OUTPUT to get the debug output 632 * we are using ACPI_DEBUG_OUTPUT to get the debug output
@@ -650,7 +637,6 @@
650#define ACPI_DEBUG_ONLY_MEMBERS(a) 637#define ACPI_DEBUG_ONLY_MEMBERS(a)
651#endif 638#endif
652 639
653
654#ifdef ACPI_DEBUG_OUTPUT 640#ifdef ACPI_DEBUG_OUTPUT
655/* 641/*
656 * 1) Set name to blanks 642 * 1) Set name to blanks
@@ -663,7 +649,6 @@
663#define ACPI_ADD_OBJECT_NAME(a,b) 649#define ACPI_ADD_OBJECT_NAME(a,b)
664#endif 650#endif
665 651
666
667/* 652/*
668 * Memory allocation tracking (DEBUG ONLY) 653 * Memory allocation tracking (DEBUG ONLY)
669 */ 654 */
@@ -685,6 +670,6 @@
685#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) 670#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__)
686#define ACPI_MEM_TRACKING(a) a 671#define ACPI_MEM_TRACKING(a) a
687 672
688#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 673#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
689 674
690#endif /* ACMACROS_H */ 675#endif /* ACMACROS_H */
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 280e9ed76674..79152fbc8f8c 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -71,9 +71,9 @@
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#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */
77 77
78#define ACPI_NS_ROOT_PATH "\\" 78#define ACPI_NS_ROOT_PATH "\\"
79#define ACPI_NS_SYSTEM_BUS "_SB_" 79#define ACPI_NS_SYSTEM_BUS "_SB_"
@@ -83,7 +83,4 @@
83#define ACPI_FUNCTION_PREFIX2 'ipca' 83#define ACPI_FUNCTION_PREFIX2 'ipca'
84/*! [End] no source code translation !*/ 84/*! [End] no source code translation !*/
85 85
86 86#endif /* __ACNAMES_H__ */
87#endif /* __ACNAMES_H__ */
88
89
diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
index 0c9ba707925b..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 u8 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 acpi_owner_id owner_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 acpi_owner_id owner_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 34f9d1f1f79b..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 owner_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 093f697e8c54..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
@@ -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 d7e828cb84b3..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,7 +130,6 @@
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 */
@@ -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 f692ad56cd82..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
@@ -65,266 +62,171 @@
65#define ACPI_PARSE_DEFERRED_OP 0x0100 62#define ACPI_PARSE_DEFERRED_OP 0x0100
66#define ACPI_PARSE_DISASSEMBLE 0x0200 63#define ACPI_PARSE_DISASSEMBLE 0x0200
67 64
68
69/****************************************************************************** 65/******************************************************************************
70 * 66 *
71 * Parser interfaces 67 * Parser interfaces
72 * 68 *
73 *****************************************************************************/ 69 *****************************************************************************/
74 70
75
76/* 71/*
77 * psxface - Parser external interfaces 72 * psxface - Parser external interfaces
78 */ 73 */
79acpi_status 74acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info);
80acpi_ps_execute_method (
81 struct acpi_parameter_info *info);
82
83 75
84/* 76/*
85 * psargs - Parse AML opcode arguments 77 * psargs - Parse AML opcode arguments
86 */ 78 */
87u8 * 79u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
88acpi_ps_get_next_package_end (
89 struct acpi_parse_state *parser_state);
90 80
91char * 81char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
92acpi_ps_get_next_namestring (
93 struct acpi_parse_state *parser_state);
94 82
95void 83void
96acpi_ps_get_next_simple_arg ( 84acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
97 struct acpi_parse_state *parser_state, 85 u32 arg_type, union acpi_parse_object *arg);
98 u32 arg_type,
99 union acpi_parse_object *arg);
100 86
101acpi_status 87acpi_status
102acpi_ps_get_next_namepath ( 88acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
103 struct acpi_walk_state *walk_state, 89 struct acpi_parse_state *parser_state,
104 struct acpi_parse_state *parser_state, 90 union acpi_parse_object *arg, u8 method_call);
105 union acpi_parse_object *arg,
106 u8 method_call);
107 91
108acpi_status 92acpi_status
109acpi_ps_get_next_arg ( 93acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
110 struct acpi_walk_state *walk_state, 94 struct acpi_parse_state *parser_state,
111 struct acpi_parse_state *parser_state, 95 u32 arg_type, union acpi_parse_object **return_arg);
112 u32 arg_type,
113 union acpi_parse_object **return_arg);
114
115 96
116/* 97/*
117 * psfind 98 * psfind
118 */ 99 */
119union acpi_parse_object * 100union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
120acpi_ps_find_name ( 101 u32 name, u32 opcode);
121 union acpi_parse_object *scope,
122 u32 name,
123 u32 opcode);
124
125union acpi_parse_object*
126acpi_ps_get_parent (
127 union acpi_parse_object *op);
128 102
103union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
129 104
130/* 105/*
131 * psopcode - AML Opcode information 106 * psopcode - AML Opcode information
132 */ 107 */
133const struct acpi_opcode_info * 108const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
134acpi_ps_get_opcode_info (
135 u16 opcode);
136
137char *
138acpi_ps_get_opcode_name (
139 u16 opcode);
140 109
110char *acpi_ps_get_opcode_name(u16 opcode);
141 111
142/* 112/*
143 * psparse - top level parsing routines 113 * psparse - top level parsing routines
144 */ 114 */
145acpi_status 115acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
146acpi_ps_parse_aml (
147 struct acpi_walk_state *walk_state);
148 116
149u32 117u32 acpi_ps_get_opcode_size(u32 opcode);
150acpi_ps_get_opcode_size (
151 u32 opcode);
152 118
153u16 119u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
154acpi_ps_peek_opcode (
155 struct acpi_parse_state *state);
156 120
157acpi_status 121acpi_status
158acpi_ps_complete_this_op ( 122acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
159 struct acpi_walk_state *walk_state, 123 union acpi_parse_object *op);
160 union acpi_parse_object *op);
161 124
162acpi_status 125acpi_status
163acpi_ps_next_parse_state ( 126acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
164 struct acpi_walk_state *walk_state, 127 union acpi_parse_object *op,
165 union acpi_parse_object *op, 128 acpi_status callback_status);
166 acpi_status callback_status);
167
168 129
169/* 130/*
170 * psloop - main parse loop 131 * psloop - main parse loop
171 */ 132 */
172acpi_status 133acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
173acpi_ps_parse_loop (
174 struct acpi_walk_state *walk_state);
175
176 134
177/* 135/*
178 * psscope - Scope stack management routines 136 * psscope - Scope stack management routines
179 */ 137 */
180acpi_status 138acpi_status
181acpi_ps_init_scope ( 139acpi_ps_init_scope(struct acpi_parse_state *parser_state,
182 struct acpi_parse_state *parser_state, 140 union acpi_parse_object *root);
183 union acpi_parse_object *root);
184 141
185union acpi_parse_object * 142union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
186acpi_ps_get_parent_scope ( 143 *state);
187 struct acpi_parse_state *state);
188 144
189u8 145u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
190acpi_ps_has_completed_scope (
191 struct acpi_parse_state *parser_state);
192 146
193void 147void
194acpi_ps_pop_scope ( 148acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
195 struct acpi_parse_state *parser_state, 149 union acpi_parse_object **op,
196 union acpi_parse_object **op, 150 u32 * arg_list, u32 * arg_count);
197 u32 *arg_list,
198 u32 *arg_count);
199 151
200acpi_status 152acpi_status
201acpi_ps_push_scope ( 153acpi_ps_push_scope(struct acpi_parse_state *parser_state,
202 struct acpi_parse_state *parser_state, 154 union acpi_parse_object *op,
203 union acpi_parse_object *op, 155 u32 remaining_args, u32 arg_count);
204 u32 remaining_args,
205 u32 arg_count);
206
207void
208acpi_ps_cleanup_scope (
209 struct acpi_parse_state *state);
210 156
157void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
211 158
212/* 159/*
213 * pstree - parse tree manipulation routines 160 * pstree - parse tree manipulation routines
214 */ 161 */
215void 162void
216acpi_ps_append_arg( 163acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
217 union acpi_parse_object *op,
218 union acpi_parse_object *arg);
219
220union acpi_parse_object*
221acpi_ps_find (
222 union acpi_parse_object *scope,
223 char *path,
224 u16 opcode,
225 u32 create);
226
227union acpi_parse_object *
228acpi_ps_get_arg(
229 union acpi_parse_object *op,
230 u32 argn);
231 164
232#ifdef ACPI_FUTURE_USAGE 165union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
233union acpi_parse_object * 166 char *path, u16 opcode, u32 create);
234acpi_ps_get_depth_next ( 167
235 union acpi_parse_object *origin, 168union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
236 union acpi_parse_object *op);
237#endif /* ACPI_FUTURE_USAGE */
238 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 */
239 174
240/* 175/*
241 * pswalk - parse tree walk routines 176 * pswalk - parse tree walk routines
242 */ 177 */
243acpi_status 178acpi_status
244acpi_ps_walk_parsed_aml ( 179acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
245 union acpi_parse_object *start_op, 180 union acpi_parse_object *end_op,
246 union acpi_parse_object *end_op, 181 union acpi_operand_object *mth_desc,
247 union acpi_operand_object *mth_desc, 182 struct acpi_namespace_node *start_node,
248 struct acpi_namespace_node *start_node, 183 union acpi_operand_object **params,
249 union acpi_operand_object **params, 184 union acpi_operand_object **caller_return_desc,
250 union acpi_operand_object **caller_return_desc, 185 acpi_owner_id owner_id,
251 acpi_owner_id owner_id, 186 acpi_parse_downwards descending_callback,
252 acpi_parse_downwards descending_callback, 187 acpi_parse_upwards ascending_callback);
253 acpi_parse_upwards ascending_callback);
254
255acpi_status
256acpi_ps_get_next_walk_op (
257 struct acpi_walk_state *walk_state,
258 union acpi_parse_object *op,
259 acpi_parse_upwards ascending_callback);
260 188
261acpi_status 189acpi_status
262acpi_ps_delete_completed_op ( 190acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
263 struct acpi_walk_state *walk_state); 191 union acpi_parse_object *op,
192 acpi_parse_upwards ascending_callback);
264 193
265void 194acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
266acpi_ps_delete_parse_tree (
267 union acpi_parse_object *root);
268 195
196void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
269 197
270/* 198/*
271 * psutils - parser utilities 199 * psutils - parser utilities
272 */ 200 */
273union acpi_parse_object * 201union acpi_parse_object *acpi_ps_create_scope_op(void);
274acpi_ps_create_scope_op (
275 void);
276 202
277void 203void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
278acpi_ps_init_op (
279 union acpi_parse_object *op,
280 u16 opcode);
281 204
282union acpi_parse_object * 205union acpi_parse_object *acpi_ps_alloc_op(u16 opcode);
283acpi_ps_alloc_op (
284 u16 opcode);
285 206
286void 207void acpi_ps_free_op(union acpi_parse_object *op);
287acpi_ps_free_op (
288 union acpi_parse_object *op);
289 208
290u8 209u8 acpi_ps_is_leading_char(u32 c);
291acpi_ps_is_leading_char (
292 u32 c);
293 210
294u8 211u8 acpi_ps_is_prefix_char(u32 c);
295acpi_ps_is_prefix_char (
296 u32 c);
297 212
298#ifdef ACPI_FUTURE_USAGE 213#ifdef ACPI_FUTURE_USAGE
299u32 214u32 acpi_ps_get_name(union acpi_parse_object *op);
300acpi_ps_get_name( 215#endif /* ACPI_FUTURE_USAGE */
301 union acpi_parse_object *op);
302#endif /* ACPI_FUTURE_USAGE */
303
304void
305acpi_ps_set_name(
306 union acpi_parse_object *op,
307 u32 name);
308 216
217void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
309 218
310/* 219/*
311 * psdump - display parser tree 220 * psdump - display parser tree
312 */ 221 */
313u32 222u32
314acpi_ps_sprint_path ( 223acpi_ps_sprint_path(char *buffer_start,
315 char *buffer_start, 224 u32 buffer_size, union acpi_parse_object *op);
316 u32 buffer_size,
317 union acpi_parse_object *op);
318 225
319u32 226u32
320acpi_ps_sprint_op ( 227acpi_ps_sprint_op(char *buffer_start,
321 char *buffer_start, 228 u32 buffer_size, union acpi_parse_object *op);
322 u32 buffer_size,
323 union acpi_parse_object *op);
324
325void
326acpi_ps_show (
327 union acpi_parse_object *op);
328 229
230void acpi_ps_show(union acpi_parse_object *op);
329 231
330#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..4f4b2baa7176 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_BUS
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_BUS */
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..e976cb109b13 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,7 +43,6 @@
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 -------------------------------------------------------------------------- */
@@ -55,49 +53,49 @@
55 53
56/* ACPI PCI Interrupt Link (pci_link.c) */ 54/* ACPI PCI Interrupt Link (pci_link.c) */
57 55
58int acpi_irq_penalty_init (void); 56int acpi_irq_penalty_init(void);
59int acpi_pci_link_allocate_irq (acpi_handle handle, int index, int *edge_level, 57int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level,
60 int *active_high_low, char **name); 58 int *active_high_low, char **name);
61int acpi_pci_link_free_irq(acpi_handle handle); 59int acpi_pci_link_free_irq(acpi_handle handle);
62 60
63/* ACPI PCI Interrupt Routing (pci_irq.c) */ 61/* ACPI PCI Interrupt Routing (pci_irq.c) */
64 62
65int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus); 63int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus);
66void acpi_pci_irq_del_prt (int segment, int bus); 64void acpi_pci_irq_del_prt(int segment, int bus);
67 65
68/* ACPI PCI Device Binding (pci_bind.c) */ 66/* ACPI PCI Device Binding (pci_bind.c) */
69 67
70struct pci_bus; 68struct pci_bus;
71 69
72acpi_status acpi_get_pci_id (acpi_handle handle, struct acpi_pci_id *id); 70acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id);
73int acpi_pci_bind (struct acpi_device *device); 71int acpi_pci_bind(struct acpi_device *device);
74int acpi_pci_unbind (struct acpi_device *device); 72int 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); 73int acpi_pci_bind_root(struct acpi_device *device, struct acpi_pci_id *id,
74 struct pci_bus *bus);
76 75
77/* Arch-defined function to add a bus to the system */ 76/* Arch-defined function to add a bus to the system */
78 77
79struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, int bus); 78struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain,
80 79 int bus);
81#endif /*CONFIG_ACPI_PCI*/
82 80
81#endif /*CONFIG_ACPI_PCI */
83 82
84/* -------------------------------------------------------------------------- 83/* --------------------------------------------------------------------------
85 Power Resource 84 Power Resource
86 -------------------------------------------------------------------------- */ 85 -------------------------------------------------------------------------- */
87 86
88#ifdef CONFIG_ACPI_POWER 87#ifdef CONFIG_ACPI_POWER
89int acpi_enable_wakeup_device_power (struct acpi_device *dev); 88int acpi_enable_wakeup_device_power(struct acpi_device *dev);
90int acpi_disable_wakeup_device_power (struct acpi_device *dev); 89int acpi_disable_wakeup_device_power(struct acpi_device *dev);
91int acpi_power_get_inferred_state (struct acpi_device *device); 90int acpi_power_get_inferred_state(struct acpi_device *device);
92int acpi_power_transition (struct acpi_device *device, int state); 91int acpi_power_transition(struct acpi_device *device, int state);
93#endif 92#endif
94 93
95
96/* -------------------------------------------------------------------------- 94/* --------------------------------------------------------------------------
97 Embedded Controller 95 Embedded Controller
98 -------------------------------------------------------------------------- */ 96 -------------------------------------------------------------------------- */
99#ifdef CONFIG_ACPI_EC 97#ifdef CONFIG_ACPI_EC
100int acpi_ec_ecdt_probe (void); 98int acpi_ec_ecdt_probe(void);
101#endif 99#endif
102 100
103/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 819a53f83cfa..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,227 +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
142unsigned long 109void acpi_os_delete_lock(acpi_handle handle);
143acpi_os_acquire_lock (
144 acpi_handle handle);
145 110
146void 111unsigned long acpi_os_acquire_lock(acpi_handle handle);
147acpi_os_release_lock (
148 acpi_handle handle,
149 unsigned long flags);
150 112
113void acpi_os_release_lock(acpi_handle handle, unsigned long flags);
151 114
152/* 115/*
153 * Memory allocation and mapping 116 * Memory allocation and mapping
154 */ 117 */
155void * 118void *acpi_os_allocate(acpi_size size);
156acpi_os_allocate (
157 acpi_size size);
158 119
159void 120void acpi_os_free(void *memory);
160acpi_os_free (
161 void * memory);
162 121
163acpi_status 122acpi_status
164acpi_os_map_memory ( 123acpi_os_map_memory(acpi_physical_address physical_address,
165 acpi_physical_address physical_address, 124 acpi_size size, void __iomem ** logical_address);
166 acpi_size size,
167 void __iomem **logical_address);
168 125
169void 126void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
170acpi_os_unmap_memory (
171 void __iomem *logical_address,
172 acpi_size size);
173 127
174#ifdef ACPI_FUTURE_USAGE 128#ifdef ACPI_FUTURE_USAGE
175acpi_status 129acpi_status
176acpi_os_get_physical_address ( 130acpi_os_get_physical_address(void *logical_address,
177 void *logical_address, 131 acpi_physical_address * physical_address);
178 acpi_physical_address *physical_address);
179#endif 132#endif
180 133
181
182
183/* 134/*
184 * Memory/Object Cache 135 * Memory/Object Cache
185 */ 136 */
186acpi_status 137acpi_status
187acpi_os_create_cache ( 138acpi_os_create_cache(char *cache_name,
188 char *cache_name, 139 u16 object_size,
189 u16 object_size, 140 u16 max_depth, acpi_cache_t ** return_cache);
190 u16 max_depth,
191 acpi_cache_t **return_cache);
192 141
193acpi_status 142acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
194acpi_os_delete_cache (
195 acpi_cache_t *cache);
196 143
197acpi_status 144acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
198acpi_os_purge_cache (
199 acpi_cache_t *cache);
200 145
201void * 146void *acpi_os_acquire_object(acpi_cache_t * cache);
202acpi_os_acquire_object (
203 acpi_cache_t *cache);
204 147
205acpi_status 148acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
206acpi_os_release_object (
207 acpi_cache_t *cache,
208 void *object);
209 149
210/* 150/*
211 * Interrupt handlers 151 * Interrupt handlers
212 */ 152 */
213acpi_status 153acpi_status
214acpi_os_install_interrupt_handler ( 154acpi_os_install_interrupt_handler(u32 gsi,
215 u32 gsi, 155 acpi_osd_handler service_routine,
216 acpi_osd_handler service_routine, 156 void *context);
217 void *context);
218 157
219acpi_status 158acpi_status
220acpi_os_remove_interrupt_handler ( 159acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine);
221 u32 gsi,
222 acpi_osd_handler service_routine);
223
224 160
225/* 161/*
226 * Threads and Scheduling 162 * Threads and Scheduling
227 */ 163 */
228u32 164u32 acpi_os_get_thread_id(void);
229acpi_os_get_thread_id (
230 void);
231 165
232acpi_status 166acpi_status
233acpi_os_queue_for_execution ( 167acpi_os_queue_for_execution(u32 priority,
234 u32 priority, 168 acpi_osd_exec_callback function, void *context);
235 acpi_osd_exec_callback function,
236 void *context);
237
238void
239acpi_os_wait_events_complete(
240 void * context);
241 169
242void 170void acpi_os_wait_events_complete(void *context);
243acpi_os_wait_events_complete (
244 void *context);
245 171
246void 172void acpi_os_wait_events_complete(void *context);
247acpi_os_sleep (
248 acpi_integer milliseconds);
249 173
250void 174void acpi_os_sleep(acpi_integer milliseconds);
251acpi_os_stall (
252 u32 microseconds);
253 175
176void acpi_os_stall(u32 microseconds);
254 177
255/* 178/*
256 * Platform and hardware-independent I/O interfaces 179 * Platform and hardware-independent I/O interfaces
257 */ 180 */
258acpi_status 181acpi_status acpi_os_read_port(acpi_io_address address, u32 * value, u32 width);
259acpi_os_read_port (
260 acpi_io_address address,
261 u32 *value,
262 u32 width);
263
264acpi_status
265acpi_os_write_port (
266 acpi_io_address address,
267 u32 value,
268 u32 width);
269 182
183acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
270 184
271/* 185/*
272 * Platform and hardware-independent physical memory interfaces 186 * Platform and hardware-independent physical memory interfaces
273 */ 187 */
274acpi_status 188acpi_status
275acpi_os_read_memory ( 189acpi_os_read_memory(acpi_physical_address address, u32 * value, u32 width);
276 acpi_physical_address address,
277 u32 *value,
278 u32 width);
279 190
280acpi_status 191acpi_status
281acpi_os_write_memory ( 192acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width);
282 acpi_physical_address address,
283 u32 value,
284 u32 width);
285
286 193
287/* 194/*
288 * Platform and hardware-independent PCI configuration space access 195 * Platform and hardware-independent PCI configuration space access
@@ -290,111 +197,69 @@ acpi_os_write_memory (
290 * certain compilers complain. 197 * certain compilers complain.
291 */ 198 */
292acpi_status 199acpi_status
293acpi_os_read_pci_configuration ( 200acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
294 struct acpi_pci_id *pci_id, 201 u32 reg, void *value, u32 width);
295 u32 reg,
296 void *value,
297 u32 width);
298 202
299acpi_status 203acpi_status
300acpi_os_write_pci_configuration ( 204acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
301 struct acpi_pci_id *pci_id, 205 u32 reg, acpi_integer value, u32 width);
302 u32 reg,
303 acpi_integer value,
304 u32 width);
305 206
306/* 207/*
307 * Interim function needed for PCI IRQ routing 208 * Interim function needed for PCI IRQ routing
308 */ 209 */
309void 210void
310acpi_os_derive_pci_id( 211acpi_os_derive_pci_id(acpi_handle rhandle,
311 acpi_handle rhandle, 212 acpi_handle chandle, struct acpi_pci_id **pci_id);
312 acpi_handle chandle,
313 struct acpi_pci_id **pci_id);
314 213
315/* 214/*
316 * Miscellaneous 215 * Miscellaneous
317 */ 216 */
318u8 217u8 acpi_os_readable(void *pointer, acpi_size length);
319acpi_os_readable (
320 void *pointer,
321 acpi_size length);
322 218
323#ifdef ACPI_FUTURE_USAGE 219#ifdef ACPI_FUTURE_USAGE
324u8 220u8 acpi_os_writable(void *pointer, acpi_size length);
325acpi_os_writable (
326 void *pointer,
327 acpi_size length);
328#endif 221#endif
329 222
330u64 223u64 acpi_os_get_timer(void);
331acpi_os_get_timer (
332 void);
333 224
334acpi_status 225acpi_status acpi_os_signal(u32 function, void *info);
335acpi_os_signal (
336 u32 function,
337 void *info);
338 226
339/* 227/*
340 * Debug print routines 228 * Debug print routines
341 */ 229 */
342void ACPI_INTERNAL_VAR_XFACE 230void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
343acpi_os_printf (
344 const char *format,
345 ...);
346
347void
348acpi_os_vprintf (
349 const char *format,
350 va_list args);
351 231
352void 232void acpi_os_vprintf(const char *format, va_list args);
353acpi_os_redirect_output (
354 void *destination);
355 233
234void acpi_os_redirect_output(void *destination);
356 235
357#ifdef ACPI_FUTURE_USAGE 236#ifdef ACPI_FUTURE_USAGE
358/* 237/*
359 * Debug input 238 * Debug input
360 */ 239 */
361u32 240u32 acpi_os_get_line(char *buffer);
362acpi_os_get_line (
363 char *buffer);
364#endif 241#endif
365 242
366
367/* 243/*
368 * Directory manipulation 244 * Directory manipulation
369 */ 245 */
370void * 246void *acpi_os_open_directory(char *pathname,
371acpi_os_open_directory ( 247 char *wildcard_spec, char requested_file_type);
372 char *pathname,
373 char *wildcard_spec,
374 char requested_file_type);
375 248
376/* requeste_file_type values */ 249/* requeste_file_type values */
377 250
378#define REQUEST_FILE_ONLY 0 251#define REQUEST_FILE_ONLY 0
379#define REQUEST_DIR_ONLY 1 252#define REQUEST_DIR_ONLY 1
380 253
254char *acpi_os_get_next_filename(void *dir_handle);
381 255
382char * 256void acpi_os_close_directory(void *dir_handle);
383acpi_os_get_next_filename (
384 void *dir_handle);
385
386void
387acpi_os_close_directory (
388 void *dir_handle);
389 257
390/* 258/*
391 * Debug 259 * Debug
392 */ 260 */
393void 261void
394acpi_os_dbg_assert( 262acpi_os_dbg_assert(void *failed_assertion,
395 void *failed_assertion, 263 void *file_name, u32 line_number, char *message);
396 void *file_name,
397 u32 line_number,
398 char *message);
399 264
400#endif /* __ACPIOSXF_H__ */ 265#endif /* __ACPIOSXF_H__ */
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 9ca212d73fb5..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_number);
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 27b22bb3d229..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,97 +63,90 @@
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 current_result; /* */ 72 u8 next_op_info; /* Info about next_op */
75 u8 next_op_info; /* Info about next_op */ 73 u8 num_operands; /* Stack pointer for Operands[] array */
76 u8 num_operands; /* Stack pointer for Operands[] array */ 74 u8 return_used;
77 u8 return_used; 75 u16 opcode; /* Current AML opcode */
78 u16 opcode; /* Current AML opcode */ 76 u8 scope_depth;
79 u8 scope_depth; 77 u8 pass_number; /* Parse pass during table load */
80 u8 pass_number; /* Parse pass during table load */ 78 u32 arg_count; /* push for fixed or var args */
81 u32 arg_count; /* push for fixed or var args */ 79 u32 aml_offset;
82 u32 aml_offset; 80 u32 arg_types;
83 u32 arg_types; 81 u32 method_breakpoint; /* For single stepping */
84 u32 method_breakpoint; /* For single stepping */ 82 u32 user_breakpoint; /* User AML breakpoint */
85 u32 user_breakpoint; /* User AML breakpoint */ 83 u32 parse_flags;
86 u32 parse_flags; 84 u32 prev_arg_types;
87 u32 prev_arg_types; 85
88 86 u8 *aml_last_while;
89 u8 *aml_last_while; 87 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
90 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ 88 union acpi_operand_object **caller_return_desc;
91 union acpi_operand_object **caller_return_desc; 89 union acpi_generic_state *control_state; /* List of control states (nested IFs) */
92 union acpi_generic_state *control_state; /* List of control states (nested IFs) */ 90 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */
93 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */ 91 struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */
94 struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */ 92 union acpi_operand_object *implicit_return_obj;
95 union acpi_operand_object *implicit_return_obj; 93 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
96 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ 94 struct acpi_namespace_node *method_call_node; /* Called method Node */
97 struct acpi_namespace_node *method_call_node; /* Called method Node*/ 95 union acpi_parse_object *method_call_op; /* method_call Op if running a method */
98 union acpi_parse_object *method_call_op; /* method_call Op if running a method */ 96 union acpi_operand_object *method_desc; /* Method descriptor if running a method */
99 union acpi_operand_object *method_desc; /* Method descriptor if running a method */ 97 struct acpi_namespace_node *method_node; /* Method node if running a method. */
100 struct acpi_namespace_node *method_node; /* Method node if running a method. */ 98 union acpi_parse_object *op; /* Current parser op */
101 union acpi_parse_object *op; /* Current parser op */ 99 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
102 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ 100 const struct acpi_opcode_info *op_info; /* Info on current opcode */
103 const struct acpi_opcode_info *op_info; /* Info on current opcode */ 101 union acpi_parse_object *origin; /* Start of walk [Obsolete] */
104 union acpi_parse_object *origin; /* Start of walk [Obsolete] */ 102 union acpi_operand_object **params;
105 union acpi_operand_object **params; 103 struct acpi_parse_state parser_state; /* Current state of parser */
106 struct acpi_parse_state parser_state; /* Current state of parser */ 104 union acpi_operand_object *result_obj;
107 union acpi_operand_object *result_obj; 105 union acpi_generic_state *results; /* Stack of accumulated results */
108 union acpi_generic_state *results; /* Stack of accumulated results */ 106 union acpi_operand_object *return_desc; /* Return object, if any */
109 union acpi_operand_object *return_desc; /* Return object, if any */ 107 union acpi_generic_state *scope_info; /* Stack of nested scopes */
110 union acpi_generic_state *scope_info; /* Stack of nested scopes */ 108
111 109 union acpi_parse_object *prev_op; /* Last op that was processed */
112 union acpi_parse_object *prev_op; /* Last op that was processed */ 110 union acpi_parse_object *next_op; /* next op to be processed */
113 union acpi_parse_object *next_op; /* next op to be processed */ 111 acpi_parse_downwards descending_callback;
114 acpi_parse_downwards descending_callback; 112 acpi_parse_upwards ascending_callback;
115 acpi_parse_upwards ascending_callback; 113 struct acpi_thread_state *thread;
116 struct acpi_thread_state *thread; 114 struct acpi_walk_state *next; /* Next walk_state in list */
117 struct acpi_walk_state *next; /* Next walk_state in list */
118}; 115};
119 116
120
121/* Info used by acpi_ps_init_objects */ 117/* Info used by acpi_ps_init_objects */
122 118
123struct acpi_init_walk_info 119struct acpi_init_walk_info {
124{ 120 u16 method_count;
125 u16 method_count; 121 u16 device_count;
126 u16 device_count; 122 u16 op_region_count;
127 u16 op_region_count; 123 u16 field_count;
128 u16 field_count; 124 u16 buffer_count;
129 u16 buffer_count; 125 u16 package_count;
130 u16 package_count; 126 u16 op_region_init;
131 u16 op_region_init; 127 u16 field_init;
132 u16 field_init; 128 u16 buffer_init;
133 u16 buffer_init; 129 u16 package_init;
134 u16 package_init; 130 u16 object_count;
135 u16 object_count; 131 struct acpi_table_desc *table_desc;
136 struct acpi_table_desc *table_desc;
137}; 132};
138 133
139
140/* Info used by acpi_ns_initialize_devices */ 134/* Info used by acpi_ns_initialize_devices */
141 135
142struct acpi_device_walk_info 136struct acpi_device_walk_info {
143{ 137 u16 device_count;
144 u16 device_count; 138 u16 num_STA;
145 u16 num_STA; 139 u16 num_INI;
146 u16 num_INI; 140 struct acpi_table_desc *table_desc;
147 struct acpi_table_desc *table_desc;
148}; 141};
149 142
150
151/* TBD: [Restructure] Merge with struct above */ 143/* TBD: [Restructure] Merge with struct above */
152 144
153struct acpi_walk_info 145struct acpi_walk_info {
154{ 146 u32 debug_level;
155 u32 debug_level; 147 u32 count;
156 u32 count; 148 acpi_owner_id owner_id;
157 acpi_owner_id owner_id; 149 u8 display_type;
158 u8 display_type;
159}; 150};
160 151
161/* Display Types */ 152/* Display Types */
@@ -166,56 +157,48 @@ struct acpi_walk_info
166 157
167#define ACPI_DISPLAY_SHORT (u8) 2 158#define ACPI_DISPLAY_SHORT (u8) 2
168 159
169struct acpi_get_devices_info 160struct acpi_get_devices_info {
170{ 161 acpi_walk_callback user_function;
171 acpi_walk_callback user_function; 162 void *context;
172 void *context; 163 char *hid;
173 char *hid;
174}; 164};
175 165
166union acpi_aml_operands {
167 union acpi_operand_object *operands[7];
176 168
177union acpi_aml_operands 169 struct {
178{ 170 struct acpi_object_integer *type;
179 union acpi_operand_object *operands[7]; 171 struct acpi_object_integer *code;
180 172 struct acpi_object_integer *argument;
181 struct
182 {
183 struct acpi_object_integer *type;
184 struct acpi_object_integer *code;
185 struct acpi_object_integer *argument;
186 173
187 } fatal; 174 } fatal;
188 175
189 struct 176 struct {
190 { 177 union acpi_operand_object *source;
191 union acpi_operand_object *source; 178 struct acpi_object_integer *index;
192 struct acpi_object_integer *index; 179 union acpi_operand_object *target;
193 union acpi_operand_object *target;
194 180
195 } index; 181 } index;
196 182
197 struct 183 struct {
198 { 184 union acpi_operand_object *source;
199 union acpi_operand_object *source; 185 struct acpi_object_integer *index;
200 struct acpi_object_integer *index; 186 struct acpi_object_integer *length;
201 struct acpi_object_integer *length; 187 union acpi_operand_object *target;
202 union acpi_operand_object *target;
203 188
204 } mid; 189 } mid;
205}; 190};
206 191
207
208/* Internal method parameter list */ 192/* Internal method parameter list */
209 193
210struct acpi_parameter_info 194struct acpi_parameter_info {
211{ 195 struct acpi_namespace_node *node;
212 struct acpi_namespace_node *node; 196 union acpi_operand_object *obj_desc;
213 union acpi_operand_object *obj_desc; 197 union acpi_operand_object **parameters;
214 union acpi_operand_object **parameters; 198 union acpi_operand_object *return_object;
215 union acpi_operand_object *return_object; 199 u8 pass_number;
216 u8 pass_number; 200 u8 parameter_type;
217 u8 parameter_type; 201 u8 return_object_type;
218 u8 return_object_type;
219}; 202};
220 203
221/* Types for parameter_type above */ 204/* Types for parameter_type above */
@@ -223,5 +206,4 @@ struct acpi_parameter_info
223#define ACPI_PARAM_ARGS 0 206#define ACPI_PARAM_ARGS 0
224#define ACPI_PARAM_GPE 1 207#define ACPI_PARAM_GPE 1
225 208
226
227#endif 209#endif
diff --git a/include/acpi/actables.h b/include/acpi/actables.h
index e6ceb1819643..f92c1858b808 100644
--- a/include/acpi/actables.h
+++ b/include/acpi/actables.h
@@ -44,154 +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
172acpi_status
173acpi_tb_validate_rsdp (
174 struct rsdp_descriptor *rsdp);
175 128
129acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp);
176 130
177/* 131/*
178 * tbutils - common table utilities 132 * tbutils - common table utilities
179 */ 133 */
180acpi_status 134acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc);
181acpi_tb_is_table_installed (
182 struct acpi_table_desc *new_table_desc);
183 135
184acpi_status 136acpi_status
185acpi_tb_verify_table_checksum ( 137acpi_tb_verify_table_checksum(struct acpi_table_header *table_header);
186 struct acpi_table_header *table_header);
187 138
188u8 139u8 acpi_tb_generate_checksum(void *buffer, u32 length);
189acpi_tb_generate_checksum (
190 void *buffer,
191 u32 length);
192 140
193acpi_status 141acpi_status
194acpi_tb_validate_table_header ( 142acpi_tb_validate_table_header(struct acpi_table_header *table_header);
195 struct acpi_table_header *table_header);
196 143
197#endif /* __ACTABLES_H__ */ 144#endif /* __ACTABLES_H__ */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index c1e9110c3661..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,28 +80,24 @@
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; /* ACPI 1.0 checksum */ 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 ACPI 1.0 or (2) for ACPI 2.0+ */ 88 u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */
93 u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */ 89 u32 length; /* XSDT Length in bytes, including header */
94 u32 length; /* XSDT Length in bytes, including header */ 90 u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */
95 u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */ 91 u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */
96 u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */ 92 char reserved[3]; /* Reserved, must be zero */
97 char reserved[3]; /* Reserved, must be zero */
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]; /* ASCII table signature */\ 102 char signature[4]; /* ASCII table signature */\
111 u32 length; /* Length of table in bytes, including this header */\ 103 u32 length; /* Length of table in bytes, including this header */\
@@ -115,14 +107,10 @@ struct acpi_common_facs /* Common FACS for internal use */
115 char oem_table_id[8]; /* ASCII 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]; /* ASCII ASL compiler vendor ID */\ 109 char asl_compiler_id [4]; /* ASCII ASL compiler vendor ID */\
118 u32 asl_compiler_revision; /* ASL compiler version */ 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,16 +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 */
142 129
143 /* Flags (32 bits) */ 130 /* Flags (32 bits) */
144 131
145 u8 PCATcompat : 1; /* 00: System also has dual 8259s */ 132 u8 PCATcompat:1; /* 00: System also has dual 8259s */
146 u8 : 7; /* 01-07: Reserved, must be zero */ 133 u8:7; /* 01-07: Reserved, must be zero */
147 u8 reserved1[3]; /* 08-31: Reserved, must be zero */ 134 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
148}; 135};
149 136
150/* Values for Type in APIC_HEADER_DEF */ 137/* Values for Type in APIC_HEADER_DEF */
@@ -158,7 +145,7 @@ struct multiple_apic_table
158#define APIC_IO_SAPIC 6 145#define APIC_IO_SAPIC 6
159#define APIC_LOCAL_SAPIC 7 146#define APIC_LOCAL_SAPIC 7
160#define APIC_XRUPT_SOURCE 8 147#define APIC_XRUPT_SOURCE 8
161#define APIC_RESERVED 9 /* 9 and greater are reserved */ 148#define APIC_RESERVED 9 /* 9 and greater are reserved */
162 149
163/* 150/*
164 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) 151 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
@@ -167,10 +154,8 @@ struct multiple_apic_table
167 u8 type; \ 154 u8 type; \
168 u8 length; 155 u8 length;
169 156
170struct apic_header 157struct apic_header {
171{ 158APIC_HEADER_DEF};
172 APIC_HEADER_DEF
173};
174 159
175/* Values for MPS INTI flags */ 160/* Values for MPS INTI flags */
176 161
@@ -190,113 +175,84 @@ struct apic_header
190 u8 polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\ 175 u8 polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\
191 u8 trigger_mode : 2; /* 02-03: Trigger mode of APIC input signals */\ 176 u8 trigger_mode : 2; /* 02-03: Trigger mode of APIC input signals */\
192 u8 : 4; /* 04-07: Reserved, must be zero */\ 177 u8 : 4; /* 04-07: Reserved, must be zero */\
193 u8 reserved1; /* 08-15: Reserved, must be zero */ 178 u8 reserved1; /* 08-15: Reserved, must be zero */
194 179
195#define LOCAL_APIC_FLAGS \ 180#define LOCAL_APIC_FLAGS \
196 u8 processor_enabled: 1; /* 00: Processor is usable if set */\ 181 u8 processor_enabled: 1; /* 00: Processor is usable if set */\
197 u8 : 7; /* 01-07: Reserved, must be zero */\ 182 u8 : 7; /* 01-07: Reserved, must be zero */\
198 u8 reserved2; /* 08-15: Reserved, must be zero */ 183 u8 reserved2; /* 08-15: Reserved, must be zero */
199 184
200/* Sub-structures for MADT */ 185/* Sub-structures for MADT */
201 186
202struct madt_processor_apic 187struct madt_processor_apic {
203{ 188 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
204 APIC_HEADER_DEF 189 u8 local_apic_id; /* Processor's local APIC id */
205 u8 processor_id; /* ACPI processor id */ 190 LOCAL_APIC_FLAGS};
206 u8 local_apic_id; /* Processor's local APIC id */ 191
207 LOCAL_APIC_FLAGS 192struct madt_io_apic {
193 APIC_HEADER_DEF u8 io_apic_id; /* I/O APIC ID */
194 u8 reserved; /* Reserved - must be zero */
195 u32 address; /* APIC physical address */
196 u32 interrupt; /* Global system interrupt where INTI
197 * lines start */
208}; 198};
209 199
210struct madt_io_apic 200struct madt_interrupt_override {
211{ 201 APIC_HEADER_DEF u8 bus; /* 0 - ISA */
212 APIC_HEADER_DEF 202 u8 source; /* Interrupt source (IRQ) */
213 u8 io_apic_id; /* I/O APIC ID */ 203 u32 interrupt; /* Global system interrupt */
214 u8 reserved; /* Reserved - must be zero */ 204 MPS_INTI_FLAGS};
215 u32 address; /* APIC physical address */
216 u32 interrupt; /* Global system interrupt where INTI
217 * lines start */
218};
219
220struct madt_interrupt_override
221{
222 APIC_HEADER_DEF
223 u8 bus; /* 0 - ISA */
224 u8 source; /* Interrupt source (IRQ) */
225 u32 interrupt; /* Global system interrupt */
226 MPS_INTI_FLAGS
227};
228 205
229struct madt_nmi_source 206struct madt_nmi_source {
230{ 207 APIC_HEADER_DEF MPS_INTI_FLAGS u32 interrupt; /* Global system interrupt */
231 APIC_HEADER_DEF
232 MPS_INTI_FLAGS
233 u32 interrupt; /* Global system interrupt */
234}; 208};
235 209
236struct madt_local_apic_nmi 210struct madt_local_apic_nmi {
237{ 211 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
238 APIC_HEADER_DEF 212 MPS_INTI_FLAGS u8 lint; /* LINTn to which NMI is connected */
239 u8 processor_id; /* ACPI processor id */
240 MPS_INTI_FLAGS
241 u8 lint; /* LINTn to which NMI is connected */
242}; 213};
243 214
244struct madt_address_override 215struct madt_address_override {
245{ 216 APIC_HEADER_DEF u16 reserved; /* Reserved, must be zero */
246 APIC_HEADER_DEF 217 u64 address; /* APIC physical address */
247 u16 reserved; /* Reserved, must be zero */
248 u64 address; /* APIC physical address */
249}; 218};
250 219
251struct madt_io_sapic 220struct madt_io_sapic {
252{ 221 APIC_HEADER_DEF u8 io_sapic_id; /* I/O SAPIC ID */
253 APIC_HEADER_DEF 222 u8 reserved; /* Reserved, must be zero */
254 u8 io_sapic_id; /* I/O SAPIC ID */ 223 u32 interrupt_base; /* Glocal interrupt for SAPIC start */
255 u8 reserved; /* Reserved, must be zero */ 224 u64 address; /* SAPIC physical address */
256 u32 interrupt_base; /* Glocal interrupt for SAPIC start */
257 u64 address; /* SAPIC physical address */
258}; 225};
259 226
260struct madt_local_sapic 227struct madt_local_sapic {
261{ 228 APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */
262 APIC_HEADER_DEF 229 u8 local_sapic_id; /* SAPIC ID */
263 u8 processor_id; /* ACPI processor id */ 230 u8 local_sapic_eid; /* SAPIC EID */
264 u8 local_sapic_id; /* SAPIC ID */ 231 u8 reserved[3]; /* Reserved, must be zero */
265 u8 local_sapic_eid; /* SAPIC EID */ 232 LOCAL_APIC_FLAGS u32 processor_uID; /* Numeric UID - ACPI 3.0 */
266 u8 reserved[3]; /* Reserved, must be zero */ 233 char processor_uIDstring[1]; /* String UID - ACPI 3.0 */
267 LOCAL_APIC_FLAGS
268 u32 processor_uID; /* Numeric UID - ACPI 3.0 */
269 char processor_uIDstring[1]; /* String UID - ACPI 3.0 */
270}; 234};
271 235
272struct madt_interrupt_source 236struct madt_interrupt_source {
273{ 237 APIC_HEADER_DEF MPS_INTI_FLAGS u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */
274 APIC_HEADER_DEF 238 u8 processor_id; /* Processor ID */
275 MPS_INTI_FLAGS 239 u8 processor_eid; /* Processor EID */
276 u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */ 240 u8 io_sapic_vector; /* Vector value for PMI interrupts */
277 u8 processor_id; /* Processor ID */ 241 u32 interrupt; /* Global system interrupt */
278 u8 processor_eid; /* Processor EID */ 242 u32 flags; /* Interrupt Source Flags */
279 u8 io_sapic_vector; /* Vector value for PMI interrupts */
280 u32 interrupt; /* Global system interrupt */
281 u32 flags; /* Interrupt Source Flags */
282}; 243};
283 244
284
285/* 245/*
286 * Smart Battery 246 * Smart Battery
287 */ 247 */
288struct smart_battery_table 248struct smart_battery_table {
289{ 249 ACPI_TABLE_HEADER_DEF u32 warning_level;
290 ACPI_TABLE_HEADER_DEF 250 u32 low_level;
291 u32 warning_level; 251 u32 critical_level;
292 u32 low_level;
293 u32 critical_level;
294}; 252};
295 253
296
297#pragma pack() 254#pragma pack()
298 255
299
300/* 256/*
301 * ACPI Table information. We save the table address, length, 257 * ACPI Table information. We save the table address, length,
302 * and type of memory allocation (mapped or allocated) for each 258 * and type of memory allocation (mapped or allocated) for each
@@ -320,39 +276,35 @@ struct smart_battery_table
320 276
321/* Data about each known table type */ 277/* Data about each known table type */
322 278
323struct acpi_table_support 279struct acpi_table_support {
324{ 280 char *name;
325 char *name; 281 char *signature;
326 char *signature; 282 void **global_ptr;
327 void **global_ptr; 283 u8 sig_length;
328 u8 sig_length; 284 u8 flags;
329 u8 flags;
330}; 285};
331 286
332
333/* 287/*
334 * Get the ACPI version-specific tables 288 * Get the ACPI version-specific tables
335 */ 289 */
336#include "actbl1.h" /* Acpi 1.0 table definitions */ 290#include "actbl1.h" /* Acpi 1.0 table definitions */
337#include "actbl2.h" /* Acpi 2.0 table definitions */ 291#include "actbl2.h" /* Acpi 2.0 table definitions */
338 292
339extern 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,
340 * needed for certain workarounds */ 294 * needed for certain workarounds */
341 295
342#pragma pack(1) 296#pragma pack(1)
343/* 297/*
344 * High performance timer 298 * High performance timer
345 */ 299 */
346struct hpet_table 300struct hpet_table {
347{ 301 ACPI_TABLE_HEADER_DEF u32 hardware_id;
348 ACPI_TABLE_HEADER_DEF 302 struct acpi_generic_address base_address;
349 u32 hardware_id; 303 u8 hpet_number;
350 struct acpi_generic_address base_address; 304 u16 clock_tick;
351 u8 hpet_number; 305 u8 attributes;
352 u16 clock_tick;
353 u8 attributes;
354}; 306};
355 307
356#pragma pack() 308#pragma pack()
357 309
358#endif /* __ACTBL_H__ */ 310#endif /* __ACTBL_H__ */
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 93c175a4f446..67312c3a915a 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -49,94 +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 ACPI tables */
56}; 55};
57 56
58
59/* 57/*
60 * ACPI 1.0 Firmware ACPI Control Structure (FACS) 58 * ACPI 1.0 Firmware ACPI Control Structure (FACS)
61 */ 59 */
62struct facs_descriptor_rev1 60struct facs_descriptor_rev1 {
63{ 61 char signature[4]; /* ASCII table signature */
64 char signature[4]; /* ASCII table signature */ 62 u32 length; /* Length of structure in bytes */
65 u32 length; /* Length of structure in bytes */ 63 u32 hardware_signature; /* Hardware configuration signature */
66 u32 hardware_signature; /* Hardware configuration signature */ 64 u32 firmware_waking_vector; /* ACPI OS waking vector */
67 u32 firmware_waking_vector; /* ACPI OS waking vector */ 65 u32 global_lock; /* Global Lock */
68 u32 global_lock; /* Global Lock */
69 66
70 /* Flags (32 bits) */ 67 /* Flags (32 bits) */
71 68
72 u8 S4bios_f : 1; /* 00: S4BIOS support is present */ 69 u8 S4bios_f:1; /* 00: S4BIOS support is present */
73 u8 : 7; /* 01-07: Reserved, must be zero */ 70 u8:7; /* 01-07: Reserved, must be zero */
74 u8 reserved1[3]; /* 08-31: Reserved, must be zero */ 71 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
75 72
76 u8 reserved2[40]; /* Reserved, must be zero */ 73 u8 reserved2[40]; /* Reserved, must be zero */
77}; 74};
78 75
79
80/* 76/*
81 * ACPI 1.0 Fixed ACPI Description Table (FADT) 77 * ACPI 1.0 Fixed ACPI Description Table (FADT)
82 */ 78 */
83struct fadt_descriptor_rev1 79struct fadt_descriptor_rev1 {
84{ 80 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
85 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 81 u32 firmware_ctrl; /* Physical address of FACS */
86 u32 firmware_ctrl; /* Physical address of FACS */ 82 u32 dsdt; /* Physical address of DSDT */
87 u32 dsdt; /* Physical address of DSDT */ 83 u8 model; /* System Interrupt Model */
88 u8 model; /* System Interrupt Model */ 84 u8 reserved1; /* Reserved, must be zero */
89 u8 reserved1; /* Reserved, must be zero */ 85 u16 sci_int; /* System vector of SCI interrupt */
90 u16 sci_int; /* System vector of SCI interrupt */ 86 u32 smi_cmd; /* Port address of SMI command port */
91 u32 smi_cmd; /* Port address of SMI command port */ 87 u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */
92 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 */
93 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 */
94 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ 90 u8 reserved2; /* Reserved, must be zero */
95 u8 reserved2; /* Reserved, must be zero */ 91 u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */
96 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 */
97 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 */
98 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 */
99 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 */
100 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 */
101 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 */
102 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 */
103 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 */
104 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 */
105 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 */
106 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 */
107 u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ 103 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */
108 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ 104 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */
109 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ 105 u8 gpe1_base; /* Offset in gpe model where gpe1 events start */
110 u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ 106 u8 reserved3; /* Reserved, must be zero */
111 u8 reserved3; /* Reserved, must be zero */ 107 u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */
112 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 */
113 u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ 109 u16 flush_size; /* Size of area read to flush caches */
114 u16 flush_size; /* Size of area read to flush caches */ 110 u16 flush_stride; /* Stride used in flushing caches */
115 u16 flush_stride; /* Stride used in flushing caches */ 111 u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */
116 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 */
117 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 */
118 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 */
119 u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ 115 u8 century; /* Index to century in RTC CMOS RAM */
120 u8 century; /* Index to century in RTC CMOS RAM */ 116 u8 reserved4[3]; /* Reserved, must be zero */
121 u8 reserved4[3]; /* Reserved, must be zero */
122 117
123 /* Flags (32 bits) */ 118 /* Flags (32 bits) */
124 119
125 u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ 120 u8 wb_invd:1; /* 00: The wbinvd instruction works properly */
126 u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ 121 u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */
127 u8 proc_c1 : 1; /* 02: All processors support C1 state */ 122 u8 proc_c1:1; /* 02: All processors support C1 state */
128 u8 plvl2_up : 1; /* 03: C2 state works on MP system */ 123 u8 plvl2_up:1; /* 03: C2 state works on MP system */
129 u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ 124 u8 pwr_button:1; /* 04: Power button is handled as a generic feature */
130 u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ 125 u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */
131 u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ 126 u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */
132 u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ 127 u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */
133 u8 tmr_val_ext : 1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ 128 u8 tmr_val_ext:1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */
134 u8 : 7; /* 09-15: Reserved, must be zero */ 129 u8:7; /* 09-15: Reserved, must be zero */
135 u8 reserved5[2]; /* 16-31: Reserved, must be zero */ 130 u8 reserved5[2]; /* 16-31: Reserved, must be zero */
136}; 131};
137 132
138#pragma pack() 133#pragma pack()
139 134
140#endif /* __ACTBL1_H__ */ 135#endif /* __ACTBL1_H__ */
141
142
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 84ce5abbd6f6..50305ce2681a 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -64,65 +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 ACPI tables */
77}; 75};
78 76
79
80/* 77/*
81 * ACPI 2.0 Extended System Description Table (XSDT) 78 * ACPI 2.0 Extended System Description Table (XSDT)
82 */ 79 */
83struct xsdt_descriptor_rev2 80struct xsdt_descriptor_rev2 {
84{ 81 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
85 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 82 u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */
86 u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */
87}; 83};
88 84
89
90/* 85/*
91 * ACPI 2.0 Firmware ACPI Control Structure (FACS) 86 * ACPI 2.0 Firmware ACPI Control Structure (FACS)
92 */ 87 */
93struct facs_descriptor_rev2 88struct facs_descriptor_rev2 {
94{ 89 char signature[4]; /* ASCII table signature */
95 char signature[4]; /* ASCII table signature */ 90 u32 length; /* Length of structure, in bytes */
96 u32 length; /* Length of structure, in bytes */ 91 u32 hardware_signature; /* Hardware configuration signature */
97 u32 hardware_signature; /* Hardware configuration signature */ 92 u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */
98 u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */ 93 u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */
99 u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */
100 94
101 /* Flags (32 bits) */ 95 /* Flags (32 bits) */
102 96
103 u8 S4bios_f : 1; /* 00: S4BIOS support is present */ 97 u8 S4bios_f:1; /* 00: S4BIOS support is present */
104 u8 : 7; /* 01-07: Reserved, must be zero */ 98 u8:7; /* 01-07: Reserved, must be zero */
105 u8 reserved1[3]; /* 08-31: Reserved, must be zero */ 99 u8 reserved1[3]; /* 08-31: Reserved, must be zero */
106 100
107 u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */ 101 u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */
108 u8 version; /* Version of this table */ 102 u8 version; /* Version of this table */
109 u8 reserved3[31]; /* Reserved, must be zero */ 103 u8 reserved3[31]; /* Reserved, must be zero */
110}; 104};
111 105
112
113/* 106/*
114 * ACPI 2.0+ Generic Address Structure (GAS) 107 * ACPI 2.0+ Generic Address Structure (GAS)
115 */ 108 */
116struct acpi_generic_address 109struct acpi_generic_address {
117{ 110 u8 address_space_id; /* Address space where struct or register exists. */
118 u8 address_space_id; /* Address space where struct or register exists. */ 111 u8 register_bit_width; /* Size in bits of given register */
119 u8 register_bit_width; /* Size in bits of given register */ 112 u8 register_bit_offset; /* Bit offset within the register */
120 u8 register_bit_offset; /* Bit offset within the register */ 113 u8 access_width; /* Minimum Access size (ACPI 3.0) */
121 u8 access_width; /* Minimum Access size (ACPI 3.0) */ 114 u64 address; /* 64-bit address of struct or register */
122 u64 address; /* 64-bit address of struct or register */
123}; 115};
124 116
125
126#define FADT_REV2_COMMON \ 117#define FADT_REV2_COMMON \
127 u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ \ 118 u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ \
128 u32 V1_dsdt; /* 32-bit physical address of DSDT */ \ 119 u32 V1_dsdt; /* 32-bit physical address of DSDT */ \
@@ -164,141 +155,123 @@ struct acpi_generic_address
164/* 155/*
165 * ACPI 2.0+ Fixed ACPI Description Table (FADT) 156 * ACPI 2.0+ Fixed ACPI Description Table (FADT)
166 */ 157 */
167struct fadt_descriptor_rev2 158struct fadt_descriptor_rev2 {
168{ 159 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
169 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 160 FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */
170 FADT_REV2_COMMON
171 u8 reserved2; /* Reserved, must be zero */
172 161
173 /* Flags (32 bits) */ 162 /* Flags (32 bits) */
174 163
175 u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ 164 u8 wb_invd:1; /* 00: The wbinvd instruction works properly */
176 u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ 165 u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */
177 u8 proc_c1 : 1; /* 02: All processors support C1 state */ 166 u8 proc_c1:1; /* 02: All processors support C1 state */
178 u8 plvl2_up : 1; /* 03: C2 state works on MP system */ 167 u8 plvl2_up:1; /* 03: C2 state works on MP system */
179 u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ 168 u8 pwr_button:1; /* 04: Power button is handled as a generic feature */
180 u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ 169 u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */
181 u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ 170 u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */
182 u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ 171 u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */
183 u8 tmr_val_ext : 1; /* 08: tmr_val is 32 bits 0=24-bits */ 172 u8 tmr_val_ext:1; /* 08: tmr_val is 32 bits 0=24-bits */
184 u8 dock_cap : 1; /* 09: Docking supported */ 173 u8 dock_cap:1; /* 09: Docking supported */
185 u8 reset_reg_sup : 1; /* 10: System reset via the FADT RESET_REG supported */ 174 u8 reset_reg_sup:1; /* 10: System reset via the FADT RESET_REG supported */
186 u8 sealed_case : 1; /* 11: No internal expansion capabilities and case is sealed */ 175 u8 sealed_case:1; /* 11: No internal expansion capabilities and case is sealed */
187 u8 headless : 1; /* 12: No local video capabilities or local input devices */ 176 u8 headless:1; /* 12: No local video capabilities or local input devices */
188 u8 cpu_sw_sleep : 1; /* 13: Must execute native instruction after writing SLP_TYPx register */ 177 u8 cpu_sw_sleep:1; /* 13: Must execute native instruction after writing SLP_TYPx register */
189 178
190 u8 pci_exp_wak : 1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ 179 u8 pci_exp_wak:1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */
191 u8 use_platform_clock : 1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ 180 u8 use_platform_clock:1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */
192 u8 S4rtc_sts_valid : 1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ 181 u8 S4rtc_sts_valid:1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */
193 u8 remote_power_on_capable : 1; /* 17: System is compatible with remote power on (ACPI 3.0) */ 182 u8 remote_power_on_capable:1; /* 17: System is compatible with remote power on (ACPI 3.0) */
194 u8 force_apic_cluster_model : 1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ 183 u8 force_apic_cluster_model:1; /* 18: All local APICs must use cluster model (ACPI 3.0) */
195 u8 force_apic_physical_destination_mode : 1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */ 184 u8 force_apic_physical_destination_mode:1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */
196 u8 : 4; /* 20-23: Reserved, must be zero */ 185 u8:4; /* 20-23: Reserved, must be zero */
197 u8 reserved3; /* 24-31: Reserved, must be zero */ 186 u8 reserved3; /* 24-31: Reserved, must be zero */
198 187
199 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 */
200 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 */
201 u8 reserved4[3]; /* These three bytes must be zero */ 190 u8 reserved4[3]; /* These three bytes must be zero */
202 u64 xfirmware_ctrl; /* 64-bit physical address of FACS */ 191 u64 xfirmware_ctrl; /* 64-bit physical address of FACS */
203 u64 Xdsdt; /* 64-bit physical address of DSDT */ 192 u64 Xdsdt; /* 64-bit physical address of DSDT */
204 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 */
205 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 */
206 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 */
207 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 */
208 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 */
209 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 */
210 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 */
211 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 */
212}; 201};
213 202
214
215/* "Down-revved" ACPI 2.0 FADT descriptor */ 203/* "Down-revved" ACPI 2.0 FADT descriptor */
216 204
217struct fadt_descriptor_rev2_minus 205struct fadt_descriptor_rev2_minus {
218{ 206 ACPI_TABLE_HEADER_DEF /* ACPI common table header */
219 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 207 FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */
220 FADT_REV2_COMMON 208 u32 flags;
221 u8 reserved2; /* Reserved, must be zero */ 209 struct acpi_generic_address reset_register; /* Reset register address in GAS format */
222 u32 flags; 210 u8 reset_value; /* Value to write to the reset_register port to reset the system. */
223 struct acpi_generic_address reset_register; /* Reset register address in GAS format */ 211 u8 reserved7[3]; /* Reserved, must be zero */
224 u8 reset_value; /* Value to write to the reset_register port to reset the system. */
225 u8 reserved7[3]; /* Reserved, must be zero */
226}; 212};
227 213
228
229/* ECDT - Embedded Controller Boot Resources Table */ 214/* ECDT - Embedded Controller Boot Resources Table */
230 215
231struct ec_boot_resources 216struct ec_boot_resources {
232{ 217 ACPI_TABLE_HEADER_DEF struct acpi_generic_address ec_control; /* Address of EC command/status register */
233 ACPI_TABLE_HEADER_DEF 218 struct acpi_generic_address ec_data; /* Address of EC data register */
234 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 */
235 struct acpi_generic_address ec_data; /* Address of EC data register */ 220 u8 gpe_bit; /* The GPE for the EC */
236 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 */
237 u8 gpe_bit; /* The GPE for the EC */
238 u8 ec_id[1]; /* Full namepath of the EC in the ACPI namespace */
239}; 222};
240 223
241
242/* SRAT - System Resource Affinity Table */ 224/* SRAT - System Resource Affinity Table */
243 225
244struct static_resource_alloc 226struct static_resource_alloc {
245{ 227 u8 type;
246 u8 type; 228 u8 length;
247 u8 length; 229 u8 proximity_domain_lo;
248 u8 proximity_domain_lo; 230 u8 apic_id;
249 u8 apic_id;
250 231
251 /* Flags (32 bits) */ 232 /* Flags (32 bits) */
252 233
253 u8 enabled :1; /* 00: Use affinity structure */ 234 u8 enabled:1; /* 00: Use affinity structure */
254 u8 :7; /* 01-07: Reserved, must be zero */ 235 u8:7; /* 01-07: Reserved, must be zero */
255 u8 reserved3[3]; /* 08-31: Reserved, must be zero */ 236 u8 reserved3[3]; /* 08-31: Reserved, must be zero */
256 237
257 u8 local_sapic_eid; 238 u8 local_sapic_eid;
258 u8 proximity_domain_hi[3]; 239 u8 proximity_domain_hi[3];
259 u32 reserved4; /* Reserved, must be zero */ 240 u32 reserved4; /* Reserved, must be zero */
260}; 241};
261 242
262struct memory_affinity 243struct memory_affinity {
263{ 244 u8 type;
264 u8 type; 245 u8 length;
265 u8 length; 246 u32 proximity_domain;
266 u32 proximity_domain; 247 u16 reserved3;
267 u16 reserved3; 248 u64 base_address;
268 u64 base_address; 249 u64 address_length;
269 u64 address_length; 250 u32 reserved4;
270 u32 reserved4;
271 251
272 /* Flags (32 bits) */ 252 /* Flags (32 bits) */
273 253
274 u8 enabled :1; /* 00: Use affinity structure */ 254 u8 enabled:1; /* 00: Use affinity structure */
275 u8 hot_pluggable :1; /* 01: Memory region is hot pluggable */ 255 u8 hot_pluggable:1; /* 01: Memory region is hot pluggable */
276 u8 non_volatile :1; /* 02: Memory is non-volatile */ 256 u8 non_volatile:1; /* 02: Memory is non-volatile */
277 u8 :5; /* 03-07: Reserved, must be zero */ 257 u8:5; /* 03-07: Reserved, must be zero */
278 u8 reserved5[3]; /* 08-31: Reserved, must be zero */ 258 u8 reserved5[3]; /* 08-31: Reserved, must be zero */
279 259
280 u64 reserved6; /* Reserved, must be zero */ 260 u64 reserved6; /* Reserved, must be zero */
281}; 261};
282 262
283struct system_resource_affinity 263struct system_resource_affinity {
284{ 264 ACPI_TABLE_HEADER_DEF u32 reserved1; /* Must be value '1' */
285 ACPI_TABLE_HEADER_DEF 265 u64 reserved2; /* Reserved, must be zero */
286 u32 reserved1; /* Must be value '1' */
287 u64 reserved2; /* Reserved, must be zero */
288}; 266};
289 267
290
291/* SLIT - System Locality Distance Information Table */ 268/* SLIT - System Locality Distance Information Table */
292 269
293struct system_locality_info 270struct system_locality_info {
294{ 271 ACPI_TABLE_HEADER_DEF u64 locality_count;
295 ACPI_TABLE_HEADER_DEF 272 u8 entry[1][1];
296 u64 locality_count;
297 u8 entry[1][1];
298}; 273};
299 274
300
301#pragma pack() 275#pragma pack()
302 276
303#endif /* __ACTBL2_H__ */ 277#endif /* __ACTBL2_H__ */
304
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 1895b862ce0d..254f4b06e7ef 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,30 +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 * This type is used for bitfields in ACPI tables. The only type that is 200 * This type is used for bitfields in ACPI tables. The only type that is
209 * even remotely portable is u8. Anything else is not portable, so 201 * even remotely portable is u8. Anything else is not portable, so
210 * do not add any more bitfield types. 202 * do not add any more bitfield types.
211 */ 203 */
212typedef u8 UINT8_BIT; 204typedef u8 UINT8_BIT;
213typedef acpi_native_uint ACPI_PTRDIFF; 205typedef acpi_native_uint ACPI_PTRDIFF;
214 206
215/* 207/*
216 * Pointer overlays to avoid lots of typecasting for 208 * Pointer overlays to avoid lots of typecasting for
217 * code that accepts both physical and logical pointers. 209 * code that accepts both physical and logical pointers.
218 */ 210 */
219union acpi_pointers 211union acpi_pointers {
220{ 212 acpi_physical_address physical;
221 acpi_physical_address physical; 213 void *logical;
222 void *logical; 214 acpi_table_ptr value;
223 acpi_table_ptr value;
224}; 215};
225 216
226struct acpi_pointer 217struct acpi_pointer {
227{ 218 u32 pointer_type;
228 u32 pointer_type; 219 union acpi_pointers pointer;
229 union acpi_pointers pointer;
230}; 220};
231 221
232/* pointer_types for above */ 222/* pointer_types for above */
@@ -270,34 +260,29 @@ struct acpi_pointer
270#define NULL (void *) 0 260#define NULL (void *) 0
271#endif 261#endif
272 262
273
274/* 263/*
275 * Local datatypes 264 * Local datatypes
276 */ 265 */
277typedef u32 acpi_status; /* All ACPI Exceptions */ 266typedef u32 acpi_status; /* All ACPI Exceptions */
278typedef u32 acpi_name; /* 4-byte ACPI name */ 267typedef u32 acpi_name; /* 4-byte ACPI name */
279typedef char * acpi_string; /* Null terminated ASCII string */ 268typedef char *acpi_string; /* Null terminated ASCII string */
280typedef void * acpi_handle; /* Actually a ptr to an Node */ 269typedef void *acpi_handle; /* Actually a ptr to an Node */
281 270
282struct uint64_struct 271struct uint64_struct {
283{ 272 u32 lo;
284 u32 lo; 273 u32 hi;
285 u32 hi;
286}; 274};
287 275
288union uint64_overlay 276union uint64_overlay {
289{ 277 u64 full;
290 u64 full; 278 struct uint64_struct part;
291 struct uint64_struct part;
292}; 279};
293 280
294struct uint32_struct 281struct uint32_struct {
295{ 282 u32 lo;
296 u32 lo; 283 u32 hi;
297 u32 hi;
298}; 284};
299 285
300
301/* 286/*
302 * Acpi integer width. In ACPI version 1, integers are 287 * Acpi integer width. In ACPI version 1, integers are
303 * 32 bits. In ACPI version 2, integers are 64 bits. 288 * 32 bits. In ACPI version 2, integers are 64 bits.
@@ -309,26 +294,24 @@ struct uint32_struct
309 294
310/* 32-bit integers only, no 64-bit support */ 295/* 32-bit integers only, no 64-bit support */
311 296
312typedef u32 acpi_integer; 297typedef u32 acpi_integer;
313#define ACPI_INTEGER_MAX ACPI_UINT32_MAX 298#define ACPI_INTEGER_MAX ACPI_UINT32_MAX
314#define ACPI_INTEGER_BIT_SIZE 32 299#define ACPI_INTEGER_BIT_SIZE 32
315#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 */
316
317#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */
318 301
302#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */
319 303
320#else 304#else
321 305
322/* 64-bit integers */ 306/* 64-bit integers */
323 307
324typedef u64 acpi_integer; 308typedef u64 acpi_integer;
325#define ACPI_INTEGER_MAX ACPI_UINT64_MAX 309#define ACPI_INTEGER_MAX ACPI_UINT64_MAX
326#define ACPI_INTEGER_BIT_SIZE 64 310#define ACPI_INTEGER_BIT_SIZE 64
327#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 */
328
329 312
330#if ACPI_MACHINE_WIDTH == 64 313#if ACPI_MACHINE_WIDTH == 64
331#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ 314#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */
332#endif 315#endif
333#endif 316#endif
334 317
@@ -342,7 +325,6 @@ typedef u64 acpi_integer;
342 */ 325 */
343#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)
344 327
345
346/* 328/*
347 * Initialization sequence 329 * Initialization sequence
348 */ 330 */
@@ -409,7 +391,7 @@ typedef u64 acpi_integer;
409/* 391/*
410 * Table types. These values are passed to the table related APIs 392 * Table types. These values are passed to the table related APIs
411 */ 393 */
412typedef u32 acpi_table_type; 394typedef u32 acpi_table_type;
413 395
414#define ACPI_TABLE_RSDP (acpi_table_type) 0 396#define ACPI_TABLE_RSDP (acpi_table_type) 0
415#define ACPI_TABLE_DSDT (acpi_table_type) 1 397#define ACPI_TABLE_DSDT (acpi_table_type) 1
@@ -430,22 +412,22 @@ typedef u32 acpi_table_type;
430 * 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
431 * and acpi_ns_type_names arrays. 413 * and acpi_ns_type_names arrays.
432 */ 414 */
433typedef u32 acpi_object_type; 415typedef u32 acpi_object_type;
434 416
435#define ACPI_TYPE_ANY 0x00 417#define ACPI_TYPE_ANY 0x00
436#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ 418#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */
437#define ACPI_TYPE_STRING 0x02 419#define ACPI_TYPE_STRING 0x02
438#define ACPI_TYPE_BUFFER 0x03 420#define ACPI_TYPE_BUFFER 0x03
439#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 */
440#define ACPI_TYPE_FIELD_UNIT 0x05 422#define ACPI_TYPE_FIELD_UNIT 0x05
441#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ 423#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */
442#define ACPI_TYPE_EVENT 0x07 424#define ACPI_TYPE_EVENT 0x07
443#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */ 425#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */
444#define ACPI_TYPE_MUTEX 0x09 426#define ACPI_TYPE_MUTEX 0x09
445#define ACPI_TYPE_REGION 0x0A 427#define ACPI_TYPE_REGION 0x0A
446#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 */
447#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 */
448#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ 430#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */
449#define ACPI_TYPE_BUFFER_FIELD 0x0E 431#define ACPI_TYPE_BUFFER_FIELD 0x0E
450#define ACPI_TYPE_DDB_HANDLE 0x0F 432#define ACPI_TYPE_DDB_HANDLE 0x0F
451#define ACPI_TYPE_DEBUG_OBJECT 0x10 433#define ACPI_TYPE_DEBUG_OBJECT 0x10
@@ -462,16 +444,16 @@ typedef u32 acpi_object_type;
462#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 444#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11
463#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 445#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12
464#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 446#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13
465#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 */
466#define ACPI_TYPE_LOCAL_ALIAS 0x15 448#define ACPI_TYPE_LOCAL_ALIAS 0x15
467#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 449#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16
468#define ACPI_TYPE_LOCAL_NOTIFY 0x17 450#define ACPI_TYPE_LOCAL_NOTIFY 0x17
469#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 451#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
470#define ACPI_TYPE_LOCAL_RESOURCE 0x19 452#define ACPI_TYPE_LOCAL_RESOURCE 0x19
471#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A 453#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A
472#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 */
473 455
474#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 */
475 457
476/* 458/*
477 * These are special object types that never appear in 459 * These are special object types that never appear in
@@ -515,7 +497,7 @@ typedef u32 acpi_object_type;
515#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) 497#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
516#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)
517#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)
518#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ 500#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
519#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF 501#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
520 502
521/* 503/*
@@ -528,7 +510,7 @@ typedef u32 acpi_object_type;
528/* 510/*
529 * Event Types: Fixed & General Purpose 511 * Event Types: Fixed & General Purpose
530 */ 512 */
531typedef u32 acpi_event_type; 513typedef u32 acpi_event_type;
532 514
533/* 515/*
534 * Fixed events 516 * Fixed events
@@ -556,7 +538,7 @@ typedef u32 acpi_event_type;
556 * | +----- Set? 538 * | +----- Set?
557 * +----------- <Reserved> 539 * +----------- <Reserved>
558 */ 540 */
559typedef u32 acpi_event_status; 541typedef u32 acpi_event_status;
560 542
561#define ACPI_EVENT_FLAG_DISABLED (acpi_event_status) 0x00 543#define ACPI_EVENT_FLAG_DISABLED (acpi_event_status) 0x00
562#define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 544#define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01
@@ -573,7 +555,6 @@ typedef u32 acpi_event_status;
573#define ACPI_GPE_ENABLE 0 555#define ACPI_GPE_ENABLE 0
574#define ACPI_GPE_DISABLE 1 556#define ACPI_GPE_DISABLE 1
575 557
576
577/* 558/*
578 * GPE info flags - Per GPE 559 * GPE info flags - Per GPE
579 * +-+-+-+---+---+-+ 560 * +-+-+-+---+---+-+
@@ -594,22 +575,22 @@ typedef u32 acpi_event_status;
594#define ACPI_GPE_TYPE_MASK (u8) 0x06 575#define ACPI_GPE_TYPE_MASK (u8) 0x06
595#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 576#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06
596#define ACPI_GPE_TYPE_WAKE (u8) 0x02 577#define ACPI_GPE_TYPE_WAKE (u8) 0x02
597#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */ 578#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */
598 579
599#define ACPI_GPE_DISPATCH_MASK (u8) 0x18 580#define ACPI_GPE_DISPATCH_MASK (u8) 0x18
600#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08 581#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08
601#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10 582#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10
602#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */ 583#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */
603 584
604#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 585#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20
605#define ACPI_GPE_RUN_ENABLED (u8) 0x20 586#define ACPI_GPE_RUN_ENABLED (u8) 0x20
606#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */ 587#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */
607 588
608#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 589#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40
609#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 590#define ACPI_GPE_WAKE_ENABLED (u8) 0x40
610#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */ 591#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */
611 592
612#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */ 593#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */
613 594
614#define ACPI_GPE_SYSTEM_MASK (u8) 0x80 595#define ACPI_GPE_SYSTEM_MASK (u8) 0x80
615#define ACPI_GPE_SYSTEM_RUNNING (u8) 0x80 596#define ACPI_GPE_SYSTEM_RUNNING (u8) 0x80
@@ -618,13 +599,12 @@ typedef u32 acpi_event_status;
618/* 599/*
619 * Flags for GPE and Lock interfaces 600 * Flags for GPE and Lock interfaces
620 */ 601 */
621#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */ 602#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */
622#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */ 603#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */
623 604
624#define ACPI_NOT_ISR 0x1 605#define ACPI_NOT_ISR 0x1
625#define ACPI_ISR 0x0 606#define ACPI_ISR 0x0
626 607
627
628/* Notify types */ 608/* Notify types */
629 609
630#define ACPI_SYSTEM_NOTIFY 0x1 610#define ACPI_SYSTEM_NOTIFY 0x1
@@ -634,10 +614,9 @@ typedef u32 acpi_event_status;
634 614
635#define ACPI_MAX_SYS_NOTIFY 0x7f 615#define ACPI_MAX_SYS_NOTIFY 0x7f
636 616
637
638/* Address Space (Operation Region) Types */ 617/* Address Space (Operation Region) Types */
639 618
640typedef u8 acpi_adr_space_type; 619typedef u8 acpi_adr_space_type;
641 620
642#define ACPI_ADR_SPACE_SYSTEM_MEMORY (acpi_adr_space_type) 0 621#define ACPI_ADR_SPACE_SYSTEM_MEMORY (acpi_adr_space_type) 0
643#define ACPI_ADR_SPACE_SYSTEM_IO (acpi_adr_space_type) 1 622#define ACPI_ADR_SPACE_SYSTEM_IO (acpi_adr_space_type) 1
@@ -649,7 +628,6 @@ typedef u8 acpi_adr_space_type;
649#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7 628#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7
650#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 629#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127
651 630
652
653/* 631/*
654 * bit_register IDs 632 * bit_register IDs
655 * These are bitfields defined within the full ACPI registers 633 * These are bitfields defined within the full ACPI registers
@@ -683,74 +661,62 @@ typedef u8 acpi_adr_space_type;
683#define ACPI_BITREG_MAX 0x15 661#define ACPI_BITREG_MAX 0x15
684#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 662#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1
685 663
686
687/* 664/*
688 * External ACPI object definition 665 * External ACPI object definition
689 */ 666 */
690union acpi_object 667union acpi_object {
691{ 668 acpi_object_type type; /* See definition of acpi_ns_type for values */
692 acpi_object_type type; /* See definition of acpi_ns_type for values */ 669 struct {
693 struct 670 acpi_object_type type;
694 { 671 acpi_integer value; /* The actual number */
695 acpi_object_type type;
696 acpi_integer value; /* The actual number */
697 } integer; 672 } integer;
698 673
699 struct 674 struct {
700 { 675 acpi_object_type type;
701 acpi_object_type type; 676 u32 length; /* # of bytes in string, excluding trailing null */
702 u32 length; /* # of bytes in string, excluding trailing null */ 677 char *pointer; /* points to the string value */
703 char *pointer; /* points to the string value */
704 } string; 678 } string;
705 679
706 struct 680 struct {
707 { 681 acpi_object_type type;
708 acpi_object_type type; 682 u32 length; /* # of bytes in buffer */
709 u32 length; /* # of bytes in buffer */ 683 u8 *pointer; /* points to the buffer */
710 u8 *pointer; /* points to the buffer */
711 } buffer; 684 } buffer;
712 685
713 struct 686 struct {
714 { 687 acpi_object_type type;
715 acpi_object_type type; 688 u32 fill1;
716 u32 fill1; 689 acpi_handle handle; /* object reference */
717 acpi_handle handle; /* object reference */
718 } reference; 690 } reference;
719 691
720 struct 692 struct {
721 { 693 acpi_object_type type;
722 acpi_object_type type; 694 u32 count; /* # of elements in package */
723 u32 count; /* # of elements in package */ 695 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */
724 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */
725 } package; 696 } package;
726 697
727 struct 698 struct {
728 { 699 acpi_object_type type;
729 acpi_object_type type; 700 u32 proc_id;
730 u32 proc_id; 701 acpi_io_address pblk_address;
731 acpi_io_address pblk_address; 702 u32 pblk_length;
732 u32 pblk_length;
733 } processor; 703 } processor;
734 704
735 struct 705 struct {
736 { 706 acpi_object_type type;
737 acpi_object_type type; 707 u32 system_level;
738 u32 system_level; 708 u32 resource_order;
739 u32 resource_order;
740 } power_resource; 709 } power_resource;
741}; 710};
742 711
743
744/* 712/*
745 * 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
746 */ 714 */
747struct acpi_object_list 715struct acpi_object_list {
748{ 716 u32 count;
749 u32 count; 717 union acpi_object *pointer;
750 union acpi_object *pointer;
751}; 718};
752 719
753
754/* 720/*
755 * Miscellaneous common Data Structures used by the interfaces 721 * Miscellaneous common Data Structures used by the interfaces
756 */ 722 */
@@ -758,13 +724,11 @@ struct acpi_object_list
758#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) 724#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1)
759#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) 725#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2)
760 726
761struct acpi_buffer 727struct acpi_buffer {
762{ 728 acpi_size length; /* Length in bytes of the buffer */
763 acpi_size length; /* Length in bytes of the buffer */ 729 void *pointer; /* pointer to buffer */
764 void *pointer; /* pointer to buffer */
765}; 730};
766 731
767
768/* 732/*
769 * name_type for acpi_get_name 733 * name_type for acpi_get_name
770 */ 734 */
@@ -772,7 +736,6 @@ struct acpi_buffer
772#define ACPI_SINGLE_NAME 1 736#define ACPI_SINGLE_NAME 1
773#define ACPI_NAME_TYPE_MAX 1 737#define ACPI_NAME_TYPE_MAX 1
774 738
775
776/* 739/*
777 * Structure and flags for acpi_get_system_info 740 * Structure and flags for acpi_get_system_info
778 */ 741 */
@@ -781,139 +744,106 @@ struct acpi_buffer
781#define ACPI_SYS_MODE_LEGACY 0x0002 744#define ACPI_SYS_MODE_LEGACY 0x0002
782#define ACPI_SYS_MODES_MASK 0x0003 745#define ACPI_SYS_MODES_MASK 0x0003
783 746
784
785/* 747/*
786 * ACPI Table Info. One per ACPI table _type_ 748 * ACPI Table Info. One per ACPI table _type_
787 */ 749 */
788struct acpi_table_info 750struct acpi_table_info {
789{ 751 u32 count;
790 u32 count;
791}; 752};
792 753
793
794/* 754/*
795 * System info returned by acpi_get_system_info() 755 * System info returned by acpi_get_system_info()
796 */ 756 */
797struct acpi_system_info 757struct acpi_system_info {
798{ 758 u32 acpi_ca_version;
799 u32 acpi_ca_version; 759 u32 flags;
800 u32 flags; 760 u32 timer_resolution;
801 u32 timer_resolution; 761 u32 reserved1;
802 u32 reserved1; 762 u32 reserved2;
803 u32 reserved2; 763 u32 debug_level;
804 u32 debug_level; 764 u32 debug_layer;
805 u32 debug_layer; 765 u32 num_table_types;
806 u32 num_table_types; 766 struct acpi_table_info table_info[NUM_ACPI_TABLE_TYPES];
807 struct acpi_table_info table_info [NUM_ACPI_TABLE_TYPES];
808}; 767};
809 768
810
811/* 769/*
812 * Types specific to the OS service interfaces 770 * Types specific to the OS service interfaces
813 */ 771 */
814typedef u32 772typedef u32(ACPI_SYSTEM_XFACE * acpi_osd_handler) (void *context);
815(ACPI_SYSTEM_XFACE *acpi_osd_handler) (
816 void *context);
817 773
818typedef void 774typedef void
819(ACPI_SYSTEM_XFACE *acpi_osd_exec_callback) ( 775 (ACPI_SYSTEM_XFACE * acpi_osd_exec_callback) (void *context);
820 void *context);
821 776
822/* 777/*
823 * Various handlers and callback procedures 778 * Various handlers and callback procedures
824 */ 779 */
825typedef 780typedef u32(*acpi_event_handler) (void *context);
826u32 (*acpi_event_handler) (
827 void *context);
828 781
829typedef 782typedef
830void (*acpi_notify_handler) ( 783void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
831 acpi_handle device,
832 u32 value,
833 void *context);
834 784
835typedef 785typedef
836void (*acpi_object_handler) ( 786void (*acpi_object_handler) (acpi_handle object, u32 function, void *data);
837 acpi_handle object,
838 u32 function,
839 void *data);
840 787
841typedef 788typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function);
842acpi_status (*acpi_init_handler) (
843 acpi_handle object,
844 u32 function);
845 789
846#define ACPI_INIT_DEVICE_INI 1 790#define ACPI_INIT_DEVICE_INI 1
847 791
848typedef 792typedef
849acpi_status (*acpi_exception_handler) ( 793acpi_status(*acpi_exception_handler) (acpi_status aml_status,
850 acpi_status aml_status, 794 acpi_name name,
851 acpi_name name, 795 u16 opcode,
852 u16 opcode, 796 u32 aml_offset, void *context);
853 u32 aml_offset,
854 void *context);
855
856 797
857/* Address Spaces (For Operation Regions) */ 798/* Address Spaces (For Operation Regions) */
858 799
859typedef 800typedef
860acpi_status (*acpi_adr_space_handler) ( 801acpi_status(*acpi_adr_space_handler) (u32 function,
861 u32 function, 802 acpi_physical_address address,
862 acpi_physical_address address, 803 u32 bit_width,
863 u32 bit_width, 804 acpi_integer * value,
864 acpi_integer *value, 805 void *handler_context,
865 void *handler_context, 806 void *region_context);
866 void *region_context);
867 807
868#define ACPI_DEFAULT_HANDLER NULL 808#define ACPI_DEFAULT_HANDLER NULL
869 809
870
871typedef 810typedef
872acpi_status (*acpi_adr_space_setup) ( 811acpi_status(*acpi_adr_space_setup) (acpi_handle region_handle,
873 acpi_handle region_handle, 812 u32 function,
874 u32 function, 813 void *handler_context,
875 void *handler_context, 814 void **region_context);
876 void **region_context);
877 815
878#define ACPI_REGION_ACTIVATE 0 816#define ACPI_REGION_ACTIVATE 0
879#define ACPI_REGION_DEACTIVATE 1 817#define ACPI_REGION_DEACTIVATE 1
880 818
881typedef 819typedef
882acpi_status (*acpi_walk_callback) ( 820acpi_status(*acpi_walk_callback) (acpi_handle obj_handle,
883 acpi_handle obj_handle, 821 u32 nesting_level,
884 u32 nesting_level, 822 void *context, void **return_value);
885 void *context,
886 void **return_value);
887
888 823
889/* Interrupt handler return values */ 824/* Interrupt handler return values */
890 825
891#define ACPI_INTERRUPT_NOT_HANDLED 0x00 826#define ACPI_INTERRUPT_NOT_HANDLED 0x00
892#define ACPI_INTERRUPT_HANDLED 0x01 827#define ACPI_INTERRUPT_HANDLED 0x01
893 828
894
895/* Common string version of device HIDs and UIDs */ 829/* Common string version of device HIDs and UIDs */
896 830
897struct acpi_device_id 831struct acpi_device_id {
898{ 832 char value[ACPI_DEVICE_ID_LENGTH];
899 char value[ACPI_DEVICE_ID_LENGTH];
900}; 833};
901 834
902/* Common string version of device CIDs */ 835/* Common string version of device CIDs */
903 836
904struct acpi_compatible_id 837struct acpi_compatible_id {
905{ 838 char value[ACPI_MAX_CID_LENGTH];
906 char value[ACPI_MAX_CID_LENGTH];
907}; 839};
908 840
909struct acpi_compatible_id_list 841struct acpi_compatible_id_list {
910{ 842 u32 count;
911 u32 count; 843 u32 size;
912 u32 size; 844 struct acpi_compatible_id id[1];
913 struct acpi_compatible_id id[1];
914}; 845};
915 846
916
917/* Structure and flags for acpi_get_object_info */ 847/* Structure and flags for acpi_get_object_info */
918 848
919#define ACPI_VALID_STA 0x0001 849#define ACPI_VALID_STA 0x0001
@@ -923,55 +853,45 @@ struct acpi_compatible_id_list
923#define ACPI_VALID_CID 0x0010 853#define ACPI_VALID_CID 0x0010
924#define ACPI_VALID_SXDS 0x0020 854#define ACPI_VALID_SXDS 0x0020
925 855
926
927#define ACPI_COMMON_OBJ_INFO \ 856#define ACPI_COMMON_OBJ_INFO \
928 acpi_object_type type; /* ACPI object type */ \ 857 acpi_object_type type; /* ACPI object type */ \
929 acpi_name name /* ACPI object Name */ 858 acpi_name name /* ACPI object Name */
930
931 859
932struct acpi_obj_info_header 860struct acpi_obj_info_header {
933{
934 ACPI_COMMON_OBJ_INFO; 861 ACPI_COMMON_OBJ_INFO;
935}; 862};
936 863
937
938/* Structure returned from Get Object Info */ 864/* Structure returned from Get Object Info */
939 865
940struct acpi_device_info 866struct acpi_device_info {
941{
942 ACPI_COMMON_OBJ_INFO; 867 ACPI_COMMON_OBJ_INFO;
943 868
944 u32 valid; /* Indicates which fields below are valid */ 869 u32 valid; /* Indicates which fields below are valid */
945 u32 current_status; /* _STA value */ 870 u32 current_status; /* _STA value */
946 acpi_integer address; /* _ADR value if any */ 871 acpi_integer address; /* _ADR value if any */
947 struct acpi_device_id hardware_id; /* _HID value if any */ 872 struct acpi_device_id hardware_id; /* _HID value if any */
948 struct acpi_device_id unique_id; /* _UID value if any */ 873 struct acpi_device_id unique_id; /* _UID value if any */
949 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 874 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */
950 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 */
951}; 876};
952 877
953
954/* Context structs for address space handlers */ 878/* Context structs for address space handlers */
955 879
956struct acpi_pci_id 880struct acpi_pci_id {
957{ 881 u16 segment;
958 u16 segment; 882 u16 bus;
959 u16 bus; 883 u16 device;
960 u16 device; 884 u16 function;
961 u16 function;
962}; 885};
963 886
964 887struct acpi_mem_space_context {
965struct acpi_mem_space_context 888 u32 length;
966{ 889 acpi_physical_address address;
967 u32 length; 890 acpi_physical_address mapped_physical_address;
968 acpi_physical_address address; 891 u8 *mapped_logical_address;
969 acpi_physical_address mapped_physical_address; 892 acpi_size mapped_length;
970 u8 *mapped_logical_address;
971 acpi_size mapped_length;
972}; 893};
973 894
974
975/* 895/*
976 * Definitions for Resource Attributes 896 * Definitions for Resource Attributes
977 */ 897 */
@@ -1001,8 +921,8 @@ struct acpi_mem_space_context
1001/* 921/*
1002 * IO Port Descriptor Decode 922 * IO Port Descriptor Decode
1003 */ 923 */
1004#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ 924#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */
1005#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ 925#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */
1006 926
1007/* 927/*
1008 * IRQ Attributes 928 * IRQ Attributes
@@ -1054,32 +974,28 @@ struct acpi_mem_space_context
1054#define ACPI_PRODUCER (u8) 0x00 974#define ACPI_PRODUCER (u8) 0x00
1055#define ACPI_CONSUMER (u8) 0x01 975#define ACPI_CONSUMER (u8) 0x01
1056 976
1057
1058/* 977/*
1059 * Structures used to describe device resources 978 * Structures used to describe device resources
1060 */ 979 */
1061struct acpi_resource_irq 980struct acpi_resource_irq {
1062{ 981 u32 edge_level;
1063 u32 edge_level; 982 u32 active_high_low;
1064 u32 active_high_low; 983 u32 shared_exclusive;
1065 u32 shared_exclusive; 984 u32 number_of_interrupts;
1066 u32 number_of_interrupts; 985 u32 interrupts[1];
1067 u32 interrupts[1];
1068}; 986};
1069 987
1070struct acpi_resource_dma 988struct acpi_resource_dma {
1071{ 989 u32 type;
1072 u32 type; 990 u32 bus_master;
1073 u32 bus_master; 991 u32 transfer;
1074 u32 transfer; 992 u32 number_of_channels;
1075 u32 number_of_channels; 993 u32 channels[1];
1076 u32 channels[1];
1077}; 994};
1078 995
1079struct acpi_resource_start_dpf 996struct acpi_resource_start_dpf {
1080{ 997 u32 compatibility_priority;
1081 u32 compatibility_priority; 998 u32 performance_robustness;
1082 u32 performance_robustness;
1083}; 999};
1084 1000
1085/* 1001/*
@@ -1087,150 +1003,133 @@ struct acpi_resource_start_dpf
1087 * needed because it has no fields 1003 * needed because it has no fields
1088 */ 1004 */
1089 1005
1090struct acpi_resource_io 1006struct acpi_resource_io {
1091{ 1007 u32 io_decode;
1092 u32 io_decode; 1008 u32 min_base_address;
1093 u32 min_base_address; 1009 u32 max_base_address;
1094 u32 max_base_address; 1010 u32 alignment;
1095 u32 alignment; 1011 u32 range_length;
1096 u32 range_length;
1097}; 1012};
1098 1013
1099struct acpi_resource_fixed_io 1014struct acpi_resource_fixed_io {
1100{ 1015 u32 base_address;
1101 u32 base_address; 1016 u32 range_length;
1102 u32 range_length;
1103}; 1017};
1104 1018
1105struct acpi_resource_vendor 1019struct acpi_resource_vendor {
1106{ 1020 u32 length;
1107 u32 length; 1021 u8 reserved[1];
1108 u8 reserved[1];
1109}; 1022};
1110 1023
1111struct acpi_resource_end_tag 1024struct acpi_resource_end_tag {
1112{ 1025 u8 checksum;
1113 u8 checksum;
1114}; 1026};
1115 1027
1116struct acpi_resource_mem24 1028struct acpi_resource_mem24 {
1117{ 1029 u32 read_write_attribute;
1118 u32 read_write_attribute; 1030 u32 min_base_address;
1119 u32 min_base_address; 1031 u32 max_base_address;
1120 u32 max_base_address; 1032 u32 alignment;
1121 u32 alignment; 1033 u32 range_length;
1122 u32 range_length;
1123}; 1034};
1124 1035
1125struct acpi_resource_mem32 1036struct acpi_resource_mem32 {
1126{ 1037 u32 read_write_attribute;
1127 u32 read_write_attribute; 1038 u32 min_base_address;
1128 u32 min_base_address; 1039 u32 max_base_address;
1129 u32 max_base_address; 1040 u32 alignment;
1130 u32 alignment; 1041 u32 range_length;
1131 u32 range_length;
1132}; 1042};
1133 1043
1134struct acpi_resource_fixed_mem32 1044struct acpi_resource_fixed_mem32 {
1135{ 1045 u32 read_write_attribute;
1136 u32 read_write_attribute; 1046 u32 range_base_address;
1137 u32 range_base_address; 1047 u32 range_length;
1138 u32 range_length;
1139}; 1048};
1140 1049
1141struct acpi_memory_attribute 1050struct acpi_memory_attribute {
1142{ 1051 u16 cache_attribute;
1143 u16 cache_attribute; 1052 u16 read_write_attribute;
1144 u16 read_write_attribute;
1145}; 1053};
1146 1054
1147struct acpi_io_attribute 1055struct acpi_io_attribute {
1148{ 1056 u16 range_attribute;
1149 u16 range_attribute; 1057 u16 translation_attribute;
1150 u16 translation_attribute;
1151}; 1058};
1152 1059
1153struct acpi_bus_attribute 1060struct acpi_bus_attribute {
1154{ 1061 u16 reserved1;
1155 u16 reserved1; 1062 u16 reserved2;
1156 u16 reserved2;
1157}; 1063};
1158 1064
1159union acpi_resource_attribute 1065union acpi_resource_attribute {
1160{ 1066 struct acpi_memory_attribute memory;
1161 struct acpi_memory_attribute memory; 1067 struct acpi_io_attribute io;
1162 struct acpi_io_attribute io; 1068 struct acpi_bus_attribute bus;
1163 struct acpi_bus_attribute bus;
1164}; 1069};
1165 1070
1166struct acpi_resource_source 1071struct acpi_resource_source {
1167{ 1072 u32 index;
1168 u32 index; 1073 u32 string_length;
1169 u32 string_length; 1074 char *string_ptr;
1170 char *string_ptr;
1171}; 1075};
1172 1076
1173struct acpi_resource_address16 1077struct acpi_resource_address16 {
1174{ 1078 u32 resource_type;
1175 u32 resource_type; 1079 u32 producer_consumer;
1176 u32 producer_consumer; 1080 u32 decode;
1177 u32 decode; 1081 u32 min_address_fixed;
1178 u32 min_address_fixed; 1082 u32 max_address_fixed;
1179 u32 max_address_fixed; 1083 union acpi_resource_attribute attribute;
1180 union acpi_resource_attribute attribute; 1084 u32 granularity;
1181 u32 granularity; 1085 u32 min_address_range;
1182 u32 min_address_range; 1086 u32 max_address_range;
1183 u32 max_address_range; 1087 u32 address_translation_offset;
1184 u32 address_translation_offset; 1088 u32 address_length;
1185 u32 address_length; 1089 struct acpi_resource_source resource_source;
1186 struct acpi_resource_source resource_source;
1187}; 1090};
1188 1091
1189struct acpi_resource_address32 1092struct acpi_resource_address32 {
1190{ 1093 u32 resource_type;
1191 u32 resource_type; 1094 u32 producer_consumer;
1192 u32 producer_consumer; 1095 u32 decode;
1193 u32 decode; 1096 u32 min_address_fixed;
1194 u32 min_address_fixed; 1097 u32 max_address_fixed;
1195 u32 max_address_fixed; 1098 union acpi_resource_attribute attribute;
1196 union acpi_resource_attribute attribute; 1099 u32 granularity;
1197 u32 granularity; 1100 u32 min_address_range;
1198 u32 min_address_range; 1101 u32 max_address_range;
1199 u32 max_address_range; 1102 u32 address_translation_offset;
1200 u32 address_translation_offset; 1103 u32 address_length;
1201 u32 address_length; 1104 struct acpi_resource_source resource_source;
1202 struct acpi_resource_source resource_source;
1203}; 1105};
1204 1106
1205struct acpi_resource_address64 1107struct acpi_resource_address64 {
1206{ 1108 u32 resource_type;
1207 u32 resource_type; 1109 u32 producer_consumer;
1208 u32 producer_consumer; 1110 u32 decode;
1209 u32 decode; 1111 u32 min_address_fixed;
1210 u32 min_address_fixed; 1112 u32 max_address_fixed;
1211 u32 max_address_fixed; 1113 union acpi_resource_attribute attribute;
1212 union acpi_resource_attribute attribute; 1114 u64 granularity;
1213 u64 granularity; 1115 u64 min_address_range;
1214 u64 min_address_range; 1116 u64 max_address_range;
1215 u64 max_address_range; 1117 u64 address_translation_offset;
1216 u64 address_translation_offset; 1118 u64 address_length;
1217 u64 address_length; 1119 u64 type_specific_attributes;
1218 u64 type_specific_attributes; 1120 struct acpi_resource_source resource_source;
1219 struct acpi_resource_source resource_source;
1220}; 1121};
1221 1122
1222struct acpi_resource_ext_irq 1123struct acpi_resource_ext_irq {
1223{ 1124 u32 producer_consumer;
1224 u32 producer_consumer; 1125 u32 edge_level;
1225 u32 edge_level; 1126 u32 active_high_low;
1226 u32 active_high_low; 1127 u32 shared_exclusive;
1227 u32 shared_exclusive; 1128 u32 number_of_interrupts;
1228 u32 number_of_interrupts; 1129 struct acpi_resource_source resource_source;
1229 struct acpi_resource_source resource_source; 1130 u32 interrupts[1];
1230 u32 interrupts[1];
1231}; 1131};
1232 1132
1233
1234/* ACPI_RESOURCE_TYPEs */ 1133/* ACPI_RESOURCE_TYPEs */
1235 1134
1236#define ACPI_RSTYPE_IRQ 0 1135#define ACPI_RSTYPE_IRQ 0
@@ -1249,35 +1148,33 @@ struct acpi_resource_ext_irq
1249#define ACPI_RSTYPE_ADDRESS64 13 1148#define ACPI_RSTYPE_ADDRESS64 13
1250#define ACPI_RSTYPE_EXT_IRQ 14 1149#define ACPI_RSTYPE_EXT_IRQ 14
1251 1150
1252typedef u32 acpi_resource_type; 1151typedef u32 acpi_resource_type;
1253 1152
1254union acpi_resource_data 1153union acpi_resource_data {
1255{ 1154 struct acpi_resource_irq irq;
1256 struct acpi_resource_irq irq; 1155 struct acpi_resource_dma dma;
1257 struct acpi_resource_dma dma; 1156 struct acpi_resource_start_dpf start_dpf;
1258 struct acpi_resource_start_dpf start_dpf; 1157 struct acpi_resource_io io;
1259 struct acpi_resource_io io; 1158 struct acpi_resource_fixed_io fixed_io;
1260 struct acpi_resource_fixed_io fixed_io; 1159 struct acpi_resource_vendor vendor_specific;
1261 struct acpi_resource_vendor vendor_specific; 1160 struct acpi_resource_end_tag end_tag;
1262 struct acpi_resource_end_tag end_tag; 1161 struct acpi_resource_mem24 memory24;
1263 struct acpi_resource_mem24 memory24; 1162 struct acpi_resource_mem32 memory32;
1264 struct acpi_resource_mem32 memory32; 1163 struct acpi_resource_fixed_mem32 fixed_memory32;
1265 struct acpi_resource_fixed_mem32 fixed_memory32; 1164 struct acpi_resource_address16 address16;
1266 struct acpi_resource_address16 address16; 1165 struct acpi_resource_address32 address32;
1267 struct acpi_resource_address32 address32; 1166 struct acpi_resource_address64 address64;
1268 struct acpi_resource_address64 address64; 1167 struct acpi_resource_ext_irq extended_irq;
1269 struct acpi_resource_ext_irq extended_irq;
1270}; 1168};
1271 1169
1272struct acpi_resource 1170struct acpi_resource {
1273{ 1171 acpi_resource_type id;
1274 acpi_resource_type id; 1172 u32 length;
1275 u32 length; 1173 union acpi_resource_data data;
1276 union acpi_resource_data data;
1277}; 1174};
1278 1175
1279#define ACPI_RESOURCE_LENGTH 12 1176#define ACPI_RESOURCE_LENGTH 12
1280#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ 1177#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */
1281 1178
1282#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) 1179#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
1283 1180
@@ -1293,19 +1190,16 @@ struct acpi_resource
1293 * END: of definitions for Resource Attributes 1190 * END: of definitions for Resource Attributes
1294 */ 1191 */
1295 1192
1296 1193struct acpi_pci_routing_table {
1297struct acpi_pci_routing_table 1194 u32 length;
1298{ 1195 u32 pin;
1299 u32 length; 1196 acpi_integer address; /* here for 64-bit alignment */
1300 u32 pin; 1197 u32 source_index;
1301 acpi_integer address; /* here for 64-bit alignment */ 1198 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
1302 u32 source_index;
1303 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
1304}; 1199};
1305 1200
1306/* 1201/*
1307 * END: of definitions for PCI Routing tables 1202 * END: of definitions for PCI Routing tables
1308 */ 1203 */
1309 1204
1310 1205#endif /* __ACTYPES_H__ */
1311#endif /* __ACTYPES_H__ */
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index 0e7b0a3e3b5e..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,163 +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 83
98char * 84char *acpi_ut_get_node_name(void *object);
99acpi_ut_get_descriptor_name (
100 void *object);
101 85
102char * 86char *acpi_ut_get_descriptor_name(void *object);
103acpi_ut_get_object_type_name (
104 union acpi_operand_object *obj_desc);
105 87
106char * 88char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
107acpi_ut_get_region_name (
108 u8 space_id);
109 89
110char * 90char *acpi_ut_get_region_name(u8 space_id);
111acpi_ut_get_event_name (
112 u32 event_id);
113 91
114char 92char *acpi_ut_get_event_name(u32 event_id);
115acpi_ut_hex_to_ascii_char (
116 acpi_integer integer,
117 u32 position);
118 93
119u8 94char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position);
120acpi_ut_valid_object_type (
121 acpi_object_type type);
122 95
96u8 acpi_ut_valid_object_type(acpi_object_type type);
123 97
124/* 98/*
125 * utinit - miscellaneous initialization and shutdown 99 * utinit - miscellaneous initialization and shutdown
126 */ 100 */
127acpi_status 101acpi_status acpi_ut_hardware_initialize(void);
128acpi_ut_hardware_initialize (
129 void);
130
131void
132acpi_ut_subsystem_shutdown (
133 void);
134 102
135acpi_status 103void acpi_ut_subsystem_shutdown(void);
136acpi_ut_validate_fadt (
137 void);
138 104
105acpi_status acpi_ut_validate_fadt(void);
139 106
140/* 107/*
141 * utclib - Local implementations of C library functions 108 * utclib - Local implementations of C library functions
142 */ 109 */
143#ifndef ACPI_USE_SYSTEM_CLIBRARY 110#ifndef ACPI_USE_SYSTEM_CLIBRARY
144 111
145acpi_size 112acpi_size acpi_ut_strlen(const char *string);
146acpi_ut_strlen ( 113
147 const char *string); 114char *acpi_ut_strcpy(char *dst_string, const char *src_string);
148 115
149char * 116char *acpi_ut_strncpy(char *dst_string,
150acpi_ut_strcpy ( 117 const char *src_string, acpi_size count);
151 char *dst_string, 118
152 const char *src_string); 119int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count);
153 120
154char * 121int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count);
155acpi_ut_strncpy ( 122
156 char *dst_string, 123int acpi_ut_strcmp(const char *string1, const char *string2);
157 const char *src_string, 124
158 acpi_size count); 125char *acpi_ut_strcat(char *dst_string, const char *src_string);
159 126
160int 127char *acpi_ut_strncat(char *dst_string,
161acpi_ut_memcmp ( 128 const char *src_string, acpi_size count);
162 const char *buffer1, 129
163 const char *buffer2, 130u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base);
164 acpi_size count); 131
165 132char *acpi_ut_strstr(char *string1, char *string2);
166int 133
167acpi_ut_strncmp ( 134void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count);
168 const char *string1, 135
169 const char *string2, 136void *acpi_ut_memset(void *dest, acpi_native_uint value, acpi_size count);
170 acpi_size count); 137
171 138int acpi_ut_to_upper(int c);
172int 139
173acpi_ut_strcmp ( 140int acpi_ut_to_lower(int c);
174 const char *string1,
175 const char *string2);
176
177char *
178acpi_ut_strcat (
179 char *dst_string,
180 const char *src_string);
181
182char *
183acpi_ut_strncat (
184 char *dst_string,
185 const char *src_string,
186 acpi_size count);
187
188u32
189acpi_ut_strtoul (
190 const char *string,
191 char **terminator,
192 u32 base);
193
194char *
195acpi_ut_strstr (
196 char *string1,
197 char *string2);
198
199void *
200acpi_ut_memcpy (
201 void *dest,
202 const void *src,
203 acpi_size count);
204
205void *
206acpi_ut_memset (
207 void *dest,
208 acpi_native_uint value,
209 acpi_size count);
210
211int
212acpi_ut_to_upper (
213 int c);
214
215int
216acpi_ut_to_lower (
217 int c);
218 141
219extern const u8 _acpi_ctype[]; 142extern const u8 _acpi_ctype[];
220 143
221#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ 144#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
222#define _ACPI_XS 0x40 /* extra space */ 145#define _ACPI_XS 0x40 /* extra space */
223#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ 146#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
224#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ 147#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
225#define _ACPI_DI 0x04 /* '0'-'9' */ 148#define _ACPI_DI 0x04 /* '0'-'9' */
226#define _ACPI_LO 0x02 /* 'a'-'z' */ 149#define _ACPI_LO 0x02 /* 'a'-'z' */
227#define _ACPI_PU 0x10 /* punctuation */ 150#define _ACPI_PU 0x10 /* punctuation */
228#define _ACPI_SP 0x08 /* space */ 151#define _ACPI_SP 0x08 /* space */
229#define _ACPI_UP 0x01 /* 'A'-'Z' */ 152#define _ACPI_UP 0x01 /* 'A'-'Z' */
230#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ 153#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
231 154
232#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))
233#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))
@@ -238,517 +161,323 @@ extern const u8 _acpi_ctype[];
238#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))
239#define ACPI_IS_ASCII(c) ((c) < 0x80) 162#define ACPI_IS_ASCII(c) ((c) < 0x80)
240 163
241#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 164#endif /* ACPI_USE_SYSTEM_CLIBRARY */
242
243 165
244/* 166/*
245 * utcopy - Object construction and conversion interfaces 167 * utcopy - Object construction and conversion interfaces
246 */ 168 */
247acpi_status 169acpi_status
248acpi_ut_build_simple_object( 170acpi_ut_build_simple_object(union acpi_operand_object *obj,
249 union acpi_operand_object *obj, 171 union acpi_object *user_obj,
250 union acpi_object *user_obj, 172 u8 * data_space, u32 * buffer_space_used);
251 u8 *data_space,
252 u32 *buffer_space_used);
253 173
254acpi_status 174acpi_status
255acpi_ut_build_package_object ( 175acpi_ut_build_package_object(union acpi_operand_object *obj,
256 union acpi_operand_object *obj, 176 u8 * buffer, u32 * space_used);
257 u8 *buffer,
258 u32 *space_used);
259 177
260acpi_status 178acpi_status
261acpi_ut_copy_iobject_to_eobject ( 179acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj,
262 union acpi_operand_object *obj, 180 struct acpi_buffer *ret_buffer);
263 struct acpi_buffer *ret_buffer);
264 181
265acpi_status 182acpi_status
266acpi_ut_copy_eobject_to_iobject ( 183acpi_ut_copy_eobject_to_iobject(union acpi_object *obj,
267 union acpi_object *obj, 184 union acpi_operand_object **internal_obj);
268 union acpi_operand_object **internal_obj);
269 185
270acpi_status 186acpi_status
271acpi_ut_copy_isimple_to_isimple ( 187acpi_ut_copy_isimple_to_isimple(union acpi_operand_object *source_obj,
272 union acpi_operand_object *source_obj, 188 union acpi_operand_object *dest_obj);
273 union acpi_operand_object *dest_obj);
274 189
275acpi_status 190acpi_status
276acpi_ut_copy_iobject_to_iobject ( 191acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
277 union acpi_operand_object *source_desc, 192 union acpi_operand_object **dest_desc,
278 union acpi_operand_object **dest_desc, 193 struct acpi_walk_state *walk_state);
279 struct acpi_walk_state *walk_state);
280
281 194
282/* 195/*
283 * utcreate - Object creation 196 * utcreate - Object creation
284 */ 197 */
285acpi_status 198acpi_status
286acpi_ut_update_object_reference ( 199acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action);
287 union acpi_operand_object *object,
288 u16 action);
289
290 200
291/* 201/*
292 * utdebug - Debug interfaces 202 * utdebug - Debug interfaces
293 */ 203 */
294void 204void acpi_ut_init_stack_ptr_trace(void);
295acpi_ut_init_stack_ptr_trace (
296 void);
297 205
298void 206void acpi_ut_track_stack_ptr(void);
299acpi_ut_track_stack_ptr (
300 void);
301 207
302void 208void
303acpi_ut_trace ( 209acpi_ut_trace(u32 line_number,
304 u32 line_number, 210 const char *function_name, char *module_name, u32 component_id);
305 const char *function_name,
306 char *module_name,
307 u32 component_id);
308 211
309void 212void
310acpi_ut_trace_ptr ( 213acpi_ut_trace_ptr(u32 line_number,
311 u32 line_number, 214 const char *function_name,
312 const char *function_name, 215 char *module_name, u32 component_id, void *pointer);
313 char *module_name,
314 u32 component_id,
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 const char *function_name, 220 char *module_name, u32 component_id, u32 integer);
321 char *module_name,
322 u32 component_id,
323 u32 integer);
324 221
325void 222void
326acpi_ut_trace_str ( 223acpi_ut_trace_str(u32 line_number,
327 u32 line_number, 224 const char *function_name,
328 const char *function_name, 225 char *module_name, u32 component_id, char *string);
329 char *module_name,
330 u32 component_id,
331 char *string);
332 226
333void 227void
334acpi_ut_exit ( 228acpi_ut_exit(u32 line_number,
335 u32 line_number, 229 const char *function_name, char *module_name, u32 component_id);
336 const char *function_name,
337 char *module_name,
338 u32 component_id);
339 230
340void 231void
341acpi_ut_status_exit ( 232acpi_ut_status_exit(u32 line_number,
342 u32 line_number, 233 const char *function_name,
343 const char *function_name, 234 char *module_name, u32 component_id, acpi_status status);
344 char *module_name,
345 u32 component_id,
346 acpi_status status);
347 235
348void 236void
349acpi_ut_value_exit ( 237acpi_ut_value_exit(u32 line_number,
350 u32 line_number, 238 const char *function_name,
351 const char *function_name, 239 char *module_name, u32 component_id, acpi_integer value);
352 char *module_name,
353 u32 component_id,
354 acpi_integer value);
355 240
356void 241void
357acpi_ut_ptr_exit ( 242acpi_ut_ptr_exit(u32 line_number,
358 u32 line_number, 243 const char *function_name,
359 const char *function_name, 244 char *module_name, u32 component_id, u8 * ptr);
360 char *module_name,
361 u32 component_id,
362 u8 *ptr);
363 245
364void 246void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id);
365acpi_ut_report_info (
366 char *module_name,
367 u32 line_number,
368 u32 component_id);
369 247
370void 248void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id);
371acpi_ut_report_error (
372 char *module_name,
373 u32 line_number,
374 u32 component_id);
375 249
376void 250void
377acpi_ut_report_warning ( 251acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id);
378 char *module_name,
379 u32 line_number,
380 u32 component_id);
381 252
382void 253void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
383acpi_ut_dump_buffer (
384 u8 *buffer,
385 u32 count,
386 u32 display,
387 u32 component_id);
388 254
389void ACPI_INTERNAL_VAR_XFACE 255void ACPI_INTERNAL_VAR_XFACE
390acpi_ut_debug_print ( 256acpi_ut_debug_print(u32 requested_debug_level,
391 u32 requested_debug_level, 257 u32 line_number,
392 u32 line_number, 258 const char *function_name,
393 const char *function_name, 259 char *module_name,
394 char *module_name, 260 u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC;
395 u32 component_id,
396 char *format,
397 ...) ACPI_PRINTF_LIKE_FUNC;
398 261
399void ACPI_INTERNAL_VAR_XFACE 262void ACPI_INTERNAL_VAR_XFACE
400acpi_ut_debug_print_raw ( 263acpi_ut_debug_print_raw(u32 requested_debug_level,
401 u32 requested_debug_level, 264 u32 line_number,
402 u32 line_number, 265 const char *function_name,
403 const char *function_name, 266 char *module_name,
404 char *module_name, 267 u32 component_id,
405 u32 component_id, 268 char *format, ...) ACPI_PRINTF_LIKE_FUNC;
406 char *format,
407 ...) ACPI_PRINTF_LIKE_FUNC;
408
409 269
410/* 270/*
411 * utdelete - Object deletion and reference counts 271 * utdelete - Object deletion and reference counts
412 */ 272 */
413void 273void acpi_ut_add_reference(union acpi_operand_object *object);
414acpi_ut_add_reference (
415 union acpi_operand_object *object);
416 274
417void 275void acpi_ut_remove_reference(union acpi_operand_object *object);
418acpi_ut_remove_reference (
419 union acpi_operand_object *object);
420 276
421void 277void acpi_ut_delete_internal_package_object(union acpi_operand_object *object);
422acpi_ut_delete_internal_package_object (
423 union acpi_operand_object *object);
424
425void
426acpi_ut_delete_internal_simple_object (
427 union acpi_operand_object *object);
428 278
429void 279void acpi_ut_delete_internal_simple_object(union acpi_operand_object *object);
430acpi_ut_delete_internal_object_list (
431 union acpi_operand_object **obj_list);
432 280
281void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list);
433 282
434/* 283/*
435 * uteval - object evaluation 284 * uteval - object evaluation
436 */ 285 */
437acpi_status 286acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
438acpi_ut_osi_implementation (
439 struct acpi_walk_state *walk_state);
440 287
441acpi_status 288acpi_status
442acpi_ut_evaluate_object ( 289acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
443 struct acpi_namespace_node *prefix_node, 290 char *path,
444 char *path, 291 u32 expected_return_btypes,
445 u32 expected_return_btypes, 292 union acpi_operand_object **return_desc);
446 union acpi_operand_object **return_desc);
447 293
448acpi_status 294acpi_status
449acpi_ut_evaluate_numeric_object ( 295acpi_ut_evaluate_numeric_object(char *object_name,
450 char *object_name, 296 struct acpi_namespace_node *device_node,
451 struct acpi_namespace_node *device_node, 297 acpi_integer * address);
452 acpi_integer *address);
453 298
454acpi_status 299acpi_status
455acpi_ut_execute_HID ( 300acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
456 struct acpi_namespace_node *device_node, 301 struct acpi_device_id *hid);
457 struct acpi_device_id *hid);
458 302
459acpi_status 303acpi_status
460acpi_ut_execute_CID ( 304acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
461 struct acpi_namespace_node *device_node, 305 struct acpi_compatible_id_list **return_cid_list);
462 struct acpi_compatible_id_list **return_cid_list);
463 306
464acpi_status 307acpi_status
465acpi_ut_execute_STA ( 308acpi_ut_execute_STA(struct acpi_namespace_node *device_node,
466 struct acpi_namespace_node *device_node, 309 u32 * status_flags);
467 u32 *status_flags);
468 310
469acpi_status 311acpi_status
470acpi_ut_execute_UID ( 312acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
471 struct acpi_namespace_node *device_node, 313 struct acpi_device_id *uid);
472 struct acpi_device_id *uid);
473 314
474acpi_status 315acpi_status
475acpi_ut_execute_sxds ( 316acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
476 struct acpi_namespace_node *device_node,
477 u8 *highest);
478
479 317
480/* 318/*
481 * utobject - internal object create/delete/cache routines 319 * utobject - internal object create/delete/cache routines
482 */ 320 */
483union acpi_operand_object * 321union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name,
484acpi_ut_create_internal_object_dbg ( 322 u32 line_number,
485 char *module_name, 323 u32 component_id,
486 u32 line_number, 324 acpi_object_type
487 u32 component_id, 325 type);
488 acpi_object_type type); 326
489 327void *acpi_ut_allocate_object_desc_dbg(char *module_name,
490void * 328 u32 line_number, u32 component_id);
491acpi_ut_allocate_object_desc_dbg (
492 char *module_name,
493 u32 line_number,
494 u32 component_id);
495 329
496#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t) 330#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t)
497#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT) 331#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT)
498 332
499void 333void acpi_ut_delete_object_desc(union acpi_operand_object *object);
500acpi_ut_delete_object_desc (
501 union acpi_operand_object *object);
502 334
503u8 335u8 acpi_ut_valid_internal_object(void *object);
504acpi_ut_valid_internal_object (
505 void *object);
506 336
507union acpi_operand_object * 337union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
508acpi_ut_create_buffer_object (
509 acpi_size buffer_size);
510 338
511union acpi_operand_object * 339union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
512acpi_ut_create_string_object (
513 acpi_size string_size);
514 340
515acpi_status 341acpi_status
516acpi_ut_get_object_size( 342acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length);
517 union acpi_operand_object *obj,
518 acpi_size *obj_length);
519
520 343
521/* 344/*
522 * utstate - Generic state creation/cache routines 345 * utstate - Generic state creation/cache routines
523 */ 346 */
524void 347void
525acpi_ut_push_generic_state ( 348acpi_ut_push_generic_state(union acpi_generic_state **list_head,
526 union acpi_generic_state **list_head, 349 union acpi_generic_state *state);
527 union acpi_generic_state *state);
528
529union acpi_generic_state *
530acpi_ut_pop_generic_state (
531 union acpi_generic_state **list_head);
532 350
351union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
352 **list_head);
533 353
534union acpi_generic_state * 354union acpi_generic_state *acpi_ut_create_generic_state(void);
535acpi_ut_create_generic_state (
536 void);
537 355
538struct acpi_thread_state * 356struct acpi_thread_state *acpi_ut_create_thread_state(void);
539acpi_ut_create_thread_state (
540 void);
541 357
542union acpi_generic_state * 358union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
543acpi_ut_create_update_state ( 359 *object, u16 action);
544 union acpi_operand_object *object,
545 u16 action);
546 360
547union acpi_generic_state * 361union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
548acpi_ut_create_pkg_state ( 362 void *external_object,
549 void *internal_object, 363 u16 index);
550 void *external_object,
551 u16 index);
552 364
553acpi_status 365acpi_status
554acpi_ut_create_update_state_and_push ( 366acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
555 union acpi_operand_object *object, 367 u16 action,
556 u16 action, 368 union acpi_generic_state **state_list);
557 union acpi_generic_state **state_list);
558 369
559#ifdef ACPI_FUTURE_USAGE 370#ifdef ACPI_FUTURE_USAGE
560acpi_status 371acpi_status
561acpi_ut_create_pkg_state_and_push ( 372acpi_ut_create_pkg_state_and_push(void *internal_object,
562 void *internal_object, 373 void *external_object,
563 void *external_object, 374 u16 index,
564 u16 index, 375 union acpi_generic_state **state_list);
565 union acpi_generic_state **state_list); 376#endif /* ACPI_FUTURE_USAGE */
566#endif /* ACPI_FUTURE_USAGE */
567 377
568union acpi_generic_state * 378union acpi_generic_state *acpi_ut_create_control_state(void);
569acpi_ut_create_control_state (
570 void);
571
572void
573acpi_ut_delete_generic_state (
574 union acpi_generic_state *state);
575 379
380void acpi_ut_delete_generic_state(union acpi_generic_state *state);
576 381
577/* 382/*
578 * utmath 383 * utmath
579 */ 384 */
580acpi_status 385acpi_status
581acpi_ut_divide ( 386acpi_ut_divide(acpi_integer in_dividend,
582 acpi_integer in_dividend, 387 acpi_integer in_divisor,
583 acpi_integer in_divisor, 388 acpi_integer * out_quotient, acpi_integer * out_remainder);
584 acpi_integer *out_quotient,
585 acpi_integer *out_remainder);
586 389
587acpi_status 390acpi_status
588acpi_ut_short_divide ( 391acpi_ut_short_divide(acpi_integer in_dividend,
589 acpi_integer in_dividend, 392 u32 divisor,
590 u32 divisor, 393 acpi_integer * out_quotient, u32 * out_remainder);
591 acpi_integer *out_quotient,
592 u32 *out_remainder);
593 394
594/* 395/*
595 * utmisc 396 * utmisc
596 */ 397 */
597acpi_status 398acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
598acpi_ut_allocate_owner_id (
599 acpi_owner_id *owner_id);
600 399
601void 400void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
602acpi_ut_release_owner_id (
603 acpi_owner_id *owner_id);
604 401
605acpi_status 402acpi_status
606acpi_ut_walk_package_tree ( 403acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
607 union acpi_operand_object *source_object, 404 void *target_object,
608 void *target_object, 405 acpi_pkg_callback walk_callback, void *context);
609 acpi_pkg_callback walk_callback,
610 void *context);
611 406
612void 407void acpi_ut_strupr(char *src_string);
613acpi_ut_strupr (
614 char *src_string);
615 408
616void 409void acpi_ut_print_string(char *string, u8 max_length);
617acpi_ut_print_string (
618 char *string,
619 u8 max_length);
620 410
621u8 411u8 acpi_ut_valid_acpi_name(u32 name);
622acpi_ut_valid_acpi_name (
623 u32 name);
624 412
625u8 413u8 acpi_ut_valid_acpi_character(char character);
626acpi_ut_valid_acpi_character (
627 char character);
628 414
629acpi_status 415acpi_status
630acpi_ut_strtoul64 ( 416acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
631 char *string,
632 u32 base,
633 acpi_integer *ret_integer);
634 417
635/* Values for Base above (16=Hex, 10=Decimal) */ 418/* Values for Base above (16=Hex, 10=Decimal) */
636 419
637#define ACPI_ANY_BASE 0 420#define ACPI_ANY_BASE 0
638 421
639u8 * 422u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc);
640acpi_ut_get_resource_end_tag (
641 union acpi_operand_object *obj_desc);
642 423
643u8 424u8 acpi_ut_generate_checksum(u8 * buffer, u32 length);
644acpi_ut_generate_checksum (
645 u8 *buffer,
646 u32 length);
647 425
648u32 426u32 acpi_ut_dword_byte_swap(u32 value);
649acpi_ut_dword_byte_swap (
650 u32 value);
651 427
652void 428void acpi_ut_set_integer_width(u8 revision);
653acpi_ut_set_integer_width (
654 u8 revision);
655 429
656#ifdef ACPI_DEBUG_OUTPUT 430#ifdef ACPI_DEBUG_OUTPUT
657void 431void
658acpi_ut_display_init_pathname ( 432acpi_ut_display_init_pathname(u8 type,
659 u8 type, 433 struct acpi_namespace_node *obj_handle,
660 struct acpi_namespace_node *obj_handle, 434 char *path);
661 char *path);
662 435
663#endif 436#endif
664 437
665
666/* 438/*
667 * utmutex - mutex support 439 * utmutex - mutex support
668 */ 440 */
669acpi_status 441acpi_status acpi_ut_mutex_initialize(void);
670acpi_ut_mutex_initialize (
671 void);
672
673void
674acpi_ut_mutex_terminate (
675 void);
676 442
677acpi_status 443void acpi_ut_mutex_terminate(void);
678acpi_ut_acquire_mutex (
679 acpi_mutex_handle mutex_id);
680 444
681acpi_status 445acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id);
682acpi_ut_release_mutex (
683 acpi_mutex_handle mutex_id);
684 446
447acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id);
685 448
686/* 449/*
687 * utalloc - memory allocation and object caching 450 * utalloc - memory allocation and object caching
688 */ 451 */
689acpi_status 452acpi_status acpi_ut_create_caches(void);
690acpi_ut_create_caches (
691 void);
692 453
693acpi_status 454acpi_status acpi_ut_delete_caches(void);
694acpi_ut_delete_caches (
695 void);
696 455
697acpi_status 456acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer);
698acpi_ut_validate_buffer (
699 struct acpi_buffer *buffer);
700 457
701acpi_status 458acpi_status
702acpi_ut_initialize_buffer ( 459acpi_ut_initialize_buffer(struct acpi_buffer *buffer,
703 struct acpi_buffer *buffer, 460 acpi_size required_length);
704 acpi_size required_length); 461
705 462void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line);
706void * 463
707acpi_ut_allocate ( 464void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line);
708 acpi_size size,
709 u32 component,
710 char *module,
711 u32 line);
712
713void *
714acpi_ut_callocate (
715 acpi_size size,
716 u32 component,
717 char *module,
718 u32 line);
719 465
720#ifdef ACPI_DBG_TRACK_ALLOCATIONS 466#ifdef ACPI_DBG_TRACK_ALLOCATIONS
721void * 467void *acpi_ut_allocate_and_track(acpi_size size,
722acpi_ut_allocate_and_track ( 468 u32 component, char *module, u32 line);
723 acpi_size size, 469
724 u32 component, 470void *acpi_ut_callocate_and_track(acpi_size size,
725 char *module, 471 u32 component, char *module, u32 line);
726 u32 line);
727
728void *
729acpi_ut_callocate_and_track (
730 acpi_size size,
731 u32 component,
732 char *module,
733 u32 line);
734 472
735void 473void
736acpi_ut_free_and_track ( 474acpi_ut_free_and_track(void *address, u32 component, char *module, u32 line);
737 void *address,
738 u32 component,
739 char *module,
740 u32 line);
741 475
742#ifdef ACPI_FUTURE_USAGE 476#ifdef ACPI_FUTURE_USAGE
743void 477void acpi_ut_dump_allocation_info(void);
744acpi_ut_dump_allocation_info ( 478#endif /* ACPI_FUTURE_USAGE */
745 void);
746#endif /* ACPI_FUTURE_USAGE */
747 479
748void 480void acpi_ut_dump_allocations(u32 component, char *module);
749acpi_ut_dump_allocations (
750 u32 component,
751 char *module);
752#endif 481#endif
753 482
754#endif /* _ACUTILS_H */ 483#endif /* _ACUTILS_H */
diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h
index 50a088901196..7fdf5299f501 100644
--- a/include/acpi/amlcode.h
+++ b/include/acpi/amlcode.h
@@ -59,11 +59,11 @@
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
@@ -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_EXTENDED_OPCODE (u16) 0x5b00 /* 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 bae1fbed097a..16609c1ab2eb 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -44,7 +44,6 @@
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 */
@@ -134,7 +133,7 @@
134#elif defined(WIN64) 133#elif defined(WIN64)
135#include "acwin64.h" 134#include "acwin64.h"
136 135
137#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ 136#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */
138#include "acdos16.h" 137#include "acdos16.h"
139 138
140#elif defined(__FreeBSD__) 139#elif defined(__FreeBSD__)
@@ -180,7 +179,6 @@
180 179
181/*! [End] no source code translation !*/ 180/*! [End] no source code translation !*/
182 181
183
184/* 182/*
185 * Debugger threading model 183 * Debugger threading model
186 * 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
@@ -199,8 +197,7 @@
199#else 197#else
200#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED 198#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED
201#endif 199#endif
202#endif /* !DEBUGGER_THREADING */ 200#endif /* !DEBUGGER_THREADING */
203
204 201
205/****************************************************************************** 202/******************************************************************************
206 * 203 *
@@ -222,7 +219,7 @@
222#include <string.h> 219#include <string.h>
223#include <ctype.h> 220#include <ctype.h>
224 221
225#endif /* ACPI_USE_STANDARD_HEADERS */ 222#endif /* ACPI_USE_STANDARD_HEADERS */
226 223
227/* 224/*
228 * We will be linking to the standard Clib functions 225 * We will be linking to the standard Clib functions
@@ -260,18 +257,18 @@
260 *****************************************************************************/ 257 *****************************************************************************/
261 258
262 /* 259 /*
263 * Use local definitions of C library macros and functions 260 * Use local definitions of C library macros and functions
264 * NOTE: The function implementations may not be as efficient 261 * NOTE: The function implementations may not be as efficient
265 * as an inline or assembly code implementation provided by a 262 * as an inline or assembly code implementation provided by a
266 * native C library. 263 * native C library.
267 */ 264 */
268 265
269#ifndef va_arg 266#ifndef va_arg
270 267
271#ifndef _VALIST 268#ifndef _VALIST
272#define _VALIST 269#define _VALIST
273typedef char *va_list; 270typedef char *va_list;
274#endif /* _VALIST */ 271#endif /* _VALIST */
275 272
276/* 273/*
277 * Storage alignment properties 274 * Storage alignment properties
@@ -287,8 +284,7 @@ typedef char *va_list;
287#define va_end(ap) (void) 0 284#define va_end(ap) (void) 0
288#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))))
289 286
290#endif /* va_arg */ 287#endif /* va_arg */
291
292 288
293#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2)) 289#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))
294#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c)) 290#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))
@@ -306,8 +302,7 @@ typedef char *va_list;
306#define ACPI_TOUPPER acpi_ut_to_upper 302#define ACPI_TOUPPER acpi_ut_to_upper
307#define ACPI_TOLOWER acpi_ut_to_lower 303#define ACPI_TOLOWER acpi_ut_to_lower
308 304
309#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 305#endif /* ACPI_USE_SYSTEM_CLIBRARY */
310
311 306
312/****************************************************************************** 307/******************************************************************************
313 * 308 *
@@ -348,8 +343,7 @@ typedef char *va_list;
348#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) 343#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
349#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) 344#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
350 345
351#endif /* ACPI_ASM_MACROS */ 346#endif /* ACPI_ASM_MACROS */
352
353 347
354#ifdef ACPI_APPLICATION 348#ifdef ACPI_APPLICATION
355 349
@@ -359,11 +353,10 @@ typedef char *va_list;
359#define BREAKPOINT3 353#define BREAKPOINT3
360#endif 354#endif
361 355
362
363/****************************************************************************** 356/******************************************************************************
364 * 357 *
365 * Compiler-specific information is contained in the compiler-specific 358 * Compiler-specific information is contained in the compiler-specific
366 * headers. 359 * headers.
367 * 360 *
368 *****************************************************************************/ 361 *****************************************************************************/
369#endif /* __ACENV_H__ */ 362#endif /* __ACENV_H__ */
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 39264127574c..4c0e0ba09ba0 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -60,4 +60,4 @@
60 */ 60 */
61#define ACPI_UNUSED_VAR __attribute__ ((unused)) 61#define ACPI_UNUSED_VAR __attribute__ ((unused))
62 62
63#endif /* __ACGCC_H__ */ 63#endif /* __ACGCC_H__ */
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 4fbc0fd52a27..c93e6562f0e1 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -71,9 +71,7 @@
71#define acpi_cache_t kmem_cache_t 71#define acpi_cache_t kmem_cache_t
72#endif 72#endif
73 73
74 74#else /* !__KERNEL__ */
75
76#else /* !__KERNEL__ */
77 75
78#include <stdarg.h> 76#include <stdarg.h>
79#include <string.h> 77#include <string.h>
@@ -94,10 +92,10 @@
94 92
95#define __cdecl 93#define __cdecl
96#define ACPI_FLUSH_CPU_CACHE() 94#define ACPI_FLUSH_CPU_CACHE()
97#endif /* __KERNEL__ */ 95#endif /* __KERNEL__ */
98 96
99/* Linux uses GCC */ 97/* Linux uses GCC */
100 98
101#include "acgcc.h" 99#include "acgcc.h"
102 100
103#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