aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-07 20:08:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-07 20:08:30 -0400
commit9e50ab91d025afc17ca14a1764be2e1d0c24245d (patch)
tree2647ef3fed12810ef88eb77e05bb7c3b2ea49d56 /drivers/acpi
parent3cc08fc35db75b059118626c30b60b0f56583802 (diff)
parenta0d468718b9049f7396d101075a129a2d683ad66 (diff)
Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (27 commits) ACPI / ACPICA: Simplify acpi_ev_initialize_gpe_block() ACPI / ACPICA: Fail acpi_gpe_wakeup() if ACPI_GPE_CAN_WAKE is unset ACPI / ACPICA: Do not execute _PRW methods during initialization ACPI: Fix bogus GPE test in acpi_bus_set_run_wake_flags() ACPICA: Update version to 20100702 ACPICA: Fix for Alias references within Package objects ACPICA: Fix lint warning for 64-bit constant ACPICA: Remove obsolete GPE function ACPICA: Update debug output components ACPICA: Add support for WDDT - Watchdog Descriptor Table ACPICA: Drop acpi_set_gpe ACPICA: Use low-level GPE enable during GPE block initialization ACPI / EC: Do not use acpi_set_gpe ACPI / EC: Drop suspend and resume routines ACPICA: Remove wakeup GPE reference counting which is not used ACPICA: Introduce acpi_gpe_wakeup() ACPICA: Rename acpi_hw_gpe_register_bit ACPICA: Update version to 20100528 ACPICA: Add signatures for undefined tables: ATKG, GSCI, IEIT ACPICA: Optimization: Reduce the number of namespace walks ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/acevents.h4
-rw-r--r--drivers/acpi/acpica/acglobal.h7
-rw-r--r--drivers/acpi/acpica/achware.h5
-rw-r--r--drivers/acpi/acpica/aclocal.h6
-rw-r--r--drivers/acpi/acpica/acnamesp.h7
-rw-r--r--drivers/acpi/acpica/acobject.h16
-rw-r--r--drivers/acpi/acpica/acpredef.h13
-rw-r--r--drivers/acpi/acpica/acstruct.h32
-rw-r--r--drivers/acpi/acpica/dsinit.c14
-rw-r--r--drivers/acpi/acpica/dsmethod.c20
-rw-r--r--drivers/acpi/acpica/dsmthdat.c16
-rw-r--r--drivers/acpi/acpica/dsobject.c16
-rw-r--r--drivers/acpi/acpica/dsopcode.c6
-rw-r--r--drivers/acpi/acpica/dsutils.c4
-rw-r--r--drivers/acpi/acpica/evevent.c5
-rw-r--r--drivers/acpi/acpica/evgpe.c69
-rw-r--r--drivers/acpi/acpica/evgpeblk.c70
-rw-r--r--drivers/acpi/acpica/evgpeinit.c236
-rw-r--r--drivers/acpi/acpica/evrgnini.c10
-rw-r--r--drivers/acpi/acpica/evxfevnt.c249
-rw-r--r--drivers/acpi/acpica/exconfig.c2
-rw-r--r--drivers/acpi/acpica/exdump.c6
-rw-r--r--drivers/acpi/acpica/exfldio.c4
-rw-r--r--drivers/acpi/acpica/exprep.c23
-rw-r--r--drivers/acpi/acpica/exregion.c6
-rw-r--r--drivers/acpi/acpica/hwgpe.c35
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c9
-rw-r--r--drivers/acpi/acpica/nsalloc.c94
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c16
-rw-r--r--drivers/acpi/acpica/nsnames.c4
-rw-r--r--drivers/acpi/acpica/nsparse.c4
-rw-r--r--drivers/acpi/acpica/nsrepair.c2
-rw-r--r--drivers/acpi/acpica/nsrepair2.c7
-rw-r--r--drivers/acpi/acpica/nssearch.c15
-rw-r--r--drivers/acpi/acpica/nsutils.c113
-rw-r--r--drivers/acpi/acpica/nswalk.c15
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/utglobal.c2
-rw-r--r--drivers/acpi/acpica/utxface.c8
-rw-r--r--drivers/acpi/button.c6
-rw-r--r--drivers/acpi/ec.c39
-rw-r--r--drivers/acpi/osl.c20
-rw-r--r--drivers/acpi/scan.c7
-rw-r--r--drivers/acpi/sleep.c15
-rw-r--r--drivers/acpi/system.c6
-rw-r--r--drivers/acpi/wakeup.c18
48 files changed, 411 insertions, 876 deletions
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index c3f43daa8be3..e0e6affb0d80 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -78,7 +78,9 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
78u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); 78u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
79 79
80acpi_status 80acpi_status
81acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info); 81acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info);
82
83acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info);
82 84
83struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, 85struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
84 u32 gpe_number); 86 u32 gpe_number);
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 899d68afc3c5..18e796fe4295 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -100,13 +100,6 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
100u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE); 100u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
101 101
102/* 102/*
103 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
104 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
105 * be enabled just before going to sleep.
106 */
107u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
108
109/*
110 * Optionally use default values for the ACPI register widths. Set this to 103 * Optionally use default values for the ACPI register widths. Set this to
111 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. 104 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
112 */ 105 */
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 32391588e163..120b3af56596 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -90,16 +90,13 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
90/* 90/*
91 * hwgpe - GPE support 91 * hwgpe - GPE support
92 */ 92 */
93u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, 93u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
94 struct acpi_gpe_register_info *gpe_register_info); 94 struct acpi_gpe_register_info *gpe_register_info);
95 95
96acpi_status 96acpi_status
97acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action); 97acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action);
98 98
99acpi_status 99acpi_status
100acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
101
102acpi_status
103acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 100acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
104 struct acpi_gpe_block_info *gpe_block, void *context); 101 struct acpi_gpe_block_info *gpe_block, void *context);
105 102
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 147a7e6bd38f..1ee0bcf399aa 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -184,8 +184,9 @@ struct acpi_namespace_node {
184 u8 flags; /* Miscellaneous flags */ 184 u8 flags; /* Miscellaneous flags */
185 acpi_owner_id owner_id; /* Node creator */ 185 acpi_owner_id owner_id; /* Node creator */
186 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ 186 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
187 struct acpi_namespace_node *parent; /* Parent node */
187 struct acpi_namespace_node *child; /* First child */ 188 struct acpi_namespace_node *child; /* First child */
188 struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ 189 struct acpi_namespace_node *peer; /* First peer */
189 190
190 /* 191 /*
191 * The following fields are used by the ASL compiler and disassembler only 192 * The following fields are used by the ASL compiler and disassembler only
@@ -199,7 +200,7 @@ struct acpi_namespace_node {
199 200
200/* Namespace Node flags */ 201/* Namespace Node flags */
201 202
202#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ 203#define ANOBJ_RESERVED 0x01 /* Available for use */
203#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ 204#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */
204#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ 205#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
205#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ 206#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
@@ -428,7 +429,6 @@ struct acpi_gpe_event_info {
428 u8 flags; /* Misc info about this GPE */ 429 u8 flags; /* Misc info about this GPE */
429 u8 gpe_number; /* This GPE */ 430 u8 gpe_number; /* This GPE */
430 u8 runtime_count; /* References to a run GPE */ 431 u8 runtime_count; /* References to a run GPE */
431 u8 wakeup_count; /* References to a wake GPE */
432}; 432};
433 433
434/* Information about a GPE register pair, one per each status/enable pair in an array */ 434/* Information about a GPE register pair, one per each status/enable pair in an array */
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 258159cfcdfa..9f60ff002203 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -369,11 +369,4 @@ struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle);
369 369
370void acpi_ns_terminate(void); 370void acpi_ns_terminate(void);
371 371
372struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
373 *node);
374
375struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
376 acpi_namespace_node
377 *node);
378
379#endif /* __ACNAMESP_H__ */ 372#endif /* __ACNAMESP_H__ */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index cde18ea82656..54857fa87aaf 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -91,14 +91,14 @@
91 91
92/* Values for Flag byte above */ 92/* Values for Flag byte above */
93 93
94#define AOPOBJ_AML_CONSTANT 0x01 94#define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */
95#define AOPOBJ_STATIC_POINTER 0x02 95#define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */
96#define AOPOBJ_DATA_VALID 0x04 96#define AOPOBJ_DATA_VALID 0x04 /* Object is intialized and data is valid */
97#define AOPOBJ_OBJECT_INITIALIZED 0x08 97#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */
98#define AOPOBJ_SETUP_COMPLETE 0x10 98#define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */
99#define AOPOBJ_SINGLE_DATUM 0x20 99#define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */ 100#define AOPOBJ_MODULE_LEVEL 0x40 /* Method is actually module-level code */
101#define AOPOBJ_MODULE_LEVEL 0x80 101#define AOPOBJ_MODIFIED_NAMESPACE 0x80 /* Method modified the namespace */
102 102
103/****************************************************************************** 103/******************************************************************************
104 * 104 *
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 97116082cb6c..10998d369ad0 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -503,15 +503,16 @@ static const union acpi_predefined_info predefined_names[] =
503 {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, 503 {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
504 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ 504 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */
505 505
506 {{{0,0,0,0}, 0,0}} /* Table terminator */ 506 /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */
507};
508 507
509#if 0 508 {{"_WDG", 0, ACPI_RTYPE_BUFFER}},
510 /* Not implemented */ 509 {{"_WED", 1,
510 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER}},
511 511
512 {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */ 512 {{{0, 0, 0, 0}, 0, 0}} /* Table terminator */
513 {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */ 513};
514 514
515#if 0
515 /* This is an internally implemented control method, no need to check */ 516 /* This is an internally implemented control method, no need to check */
516 {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, 517 {{"_OSI", 1, ACPI_RTYPE_INTEGER}},
517 518
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 161bc0e3d70a..6e5dd97949fe 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -127,22 +127,22 @@ struct acpi_walk_state {
127 acpi_parse_upwards ascending_callback; 127 acpi_parse_upwards ascending_callback;
128}; 128};
129 129
130/* Info used by acpi_ps_init_objects */ 130/* Info used by acpi_ns_initialize_objects and acpi_ds_initialize_objects */
131 131
132struct acpi_init_walk_info { 132struct acpi_init_walk_info {
133 u16 method_count;
134 u16 device_count;
135 u16 op_region_count;
136 u16 field_count;
137 u16 buffer_count;
138 u16 package_count;
139 u16 op_region_init;
140 u16 field_init;
141 u16 buffer_init;
142 u16 package_init;
143 u16 object_count;
144 acpi_owner_id owner_id;
145 u32 table_index; 133 u32 table_index;
134 u32 object_count;
135 u32 method_count;
136 u32 device_count;
137 u32 op_region_count;
138 u32 field_count;
139 u32 buffer_count;
140 u32 package_count;
141 u32 op_region_init;
142 u32 field_init;
143 u32 buffer_init;
144 u32 package_init;
145 acpi_owner_id owner_id;
146}; 146};
147 147
148struct acpi_get_devices_info { 148struct acpi_get_devices_info {
@@ -201,11 +201,11 @@ struct acpi_evaluate_info {
201/* Info used by acpi_ns_initialize_devices */ 201/* Info used by acpi_ns_initialize_devices */
202 202
203struct acpi_device_walk_info { 203struct acpi_device_walk_info {
204 u16 device_count;
205 u16 num_STA;
206 u16 num_INI;
207 struct acpi_table_desc *table_desc; 204 struct acpi_table_desc *table_desc;
208 struct acpi_evaluate_info *evaluate_info; 205 struct acpi_evaluate_info *evaluate_info;
206 u32 device_count;
207 u32 num_STA;
208 u32 num_INI;
209}; 209};
210 210
211/* TBD: [Restructure] Merge with struct above */ 211/* TBD: [Restructure] Merge with struct above */
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index abe140318a74..cc4a38c57558 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -171,12 +171,12 @@ acpi_ds_initialize_objects(u32 table_index,
171 "**** Starting initialization of namespace objects ****\n")); 171 "**** Starting initialization of namespace objects ****\n"));
172 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:")); 172 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
173 173
174 info.method_count = 0; 174 /* Set all init info to zero */
175 info.op_region_count = 0; 175
176 info.object_count = 0; 176 ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
177 info.device_count = 0; 177
178 info.table_index = table_index;
179 info.owner_id = owner_id; 178 info.owner_id = owner_id;
179 info.table_index = table_index;
180 180
181 /* Walk entire namespace from the supplied root */ 181 /* Walk entire namespace from the supplied root */
182 182
@@ -204,13 +204,13 @@ acpi_ds_initialize_objects(u32 table_index,
204 } 204 }
205 205
206 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 206 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
207 "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", 207 "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n",
208 table->signature, owner_id, info.object_count, 208 table->signature, owner_id, info.object_count,
209 info.device_count, info.method_count, 209 info.device_count, info.method_count,
210 info.op_region_count)); 210 info.op_region_count));
211 211
212 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 212 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
213 "%hd Methods, %hd Regions\n", info.method_count, 213 "%u Methods, %u Regions\n", info.method_count,
214 info.op_region_count)); 214 info.op_region_count));
215 215
216 return_ACPI_STATUS(AE_OK); 216 return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 2a9a561c2f01..64750ee96e20 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -584,8 +584,22 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
584 * want make the objects permanent. 584 * want make the objects permanent.
585 */ 585 */
586 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) { 586 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) {
587 acpi_ns_delete_namespace_by_owner(method_desc->method. 587
588 owner_id); 588 /* Delete any direct children of (created by) this method */
589
590 acpi_ns_delete_namespace_subtree(walk_state->
591 method_node);
592
593 /*
594 * Delete any objects that were created by this method
595 * elsewhere in the namespace (if any were created).
596 */
597 if (method_desc->method.
598 flags & AOPOBJ_MODIFIED_NAMESPACE) {
599 acpi_ns_delete_namespace_by_owner(method_desc->
600 method.
601 owner_id);
602 }
589 } 603 }
590 } 604 }
591 605
@@ -605,7 +619,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
605 * we immediately reuse it for the next thread executing this method 619 * we immediately reuse it for the next thread executing this method
606 */ 620 */
607 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 621 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
608 "*** Completed execution of one thread, %d threads remaining\n", 622 "*** Completed execution of one thread, %u threads remaining\n",
609 method_desc->method.thread_count)); 623 method_desc->method.thread_count));
610 } else { 624 } else {
611 /* This is the only executing thread for this method */ 625 /* This is the only executing thread for this method */
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index f3d52f59250b..8095306fcd8c 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -102,8 +102,7 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
102 walk_state->arguments[i].name.integer |= (i << 24); 102 walk_state->arguments[i].name.integer |= (i << 24);
103 walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED; 103 walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED;
104 walk_state->arguments[i].type = ACPI_TYPE_ANY; 104 walk_state->arguments[i].type = ACPI_TYPE_ANY;
105 walk_state->arguments[i].flags = 105 walk_state->arguments[i].flags = ANOBJ_METHOD_ARG;
106 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
107 } 106 }
108 107
109 /* Init the method locals */ 108 /* Init the method locals */
@@ -116,8 +115,7 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
116 walk_state->local_variables[i].descriptor_type = 115 walk_state->local_variables[i].descriptor_type =
117 ACPI_DESC_TYPE_NAMED; 116 ACPI_DESC_TYPE_NAMED;
118 walk_state->local_variables[i].type = ACPI_TYPE_ANY; 117 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
119 walk_state->local_variables[i].flags = 118 walk_state->local_variables[i].flags = ANOBJ_METHOD_LOCAL;
120 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
121 } 119 }
122 120
123 return_VOID; 121 return_VOID;
@@ -146,7 +144,7 @@ void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
146 144
147 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) { 145 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
148 if (walk_state->local_variables[index].object) { 146 if (walk_state->local_variables[index].object) {
149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
150 index, 148 index,
151 walk_state->local_variables[index]. 149 walk_state->local_variables[index].
152 object)); 150 object));
@@ -162,7 +160,7 @@ void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
162 160
163 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) { 161 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
164 if (walk_state->arguments[index].object) { 162 if (walk_state->arguments[index].object) {
165 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", 163 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
166 index, 164 index,
167 walk_state->arguments[index].object)); 165 walk_state->arguments[index].object));
168 166
@@ -226,7 +224,7 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params,
226 index++; 224 index++;
227 } 225 }
228 226
229 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index)); 227 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%u args passed to method\n", index));
230 return_ACPI_STATUS(AE_OK); 228 return_ACPI_STATUS(AE_OK);
231} 229}
232 230
@@ -323,7 +321,7 @@ acpi_ds_method_data_set_value(u8 type,
323 ACPI_FUNCTION_TRACE(ds_method_data_set_value); 321 ACPI_FUNCTION_TRACE(ds_method_data_set_value);
324 322
325 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 323 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
326 "NewObj %p Type %2.2X, Refs=%d [%s]\n", object, 324 "NewObj %p Type %2.2X, Refs=%u [%s]\n", object,
327 type, object->common.reference_count, 325 type, object->common.reference_count,
328 acpi_ut_get_type_name(object->common.type))); 326 acpi_ut_get_type_name(object->common.type)));
329 327
@@ -543,7 +541,7 @@ acpi_ds_store_object_to_local(u8 type,
543 union acpi_operand_object *new_obj_desc; 541 union acpi_operand_object *new_obj_desc;
544 542
545 ACPI_FUNCTION_TRACE(ds_store_object_to_local); 543 ACPI_FUNCTION_TRACE(ds_store_object_to_local);
546 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", 544 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
547 type, index, obj_desc)); 545 type, index, obj_desc));
548 546
549 /* Parameter validation */ 547 /* Parameter validation */
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 3607adcaf085..8e85f54a8e0e 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -81,6 +81,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
81{ 81{
82 union acpi_operand_object *obj_desc; 82 union acpi_operand_object *obj_desc;
83 acpi_status status; 83 acpi_status status;
84 acpi_object_type type;
84 85
85 ACPI_FUNCTION_TRACE(ds_build_internal_object); 86 ACPI_FUNCTION_TRACE(ds_build_internal_object);
86 87
@@ -172,7 +173,20 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
172 return_ACPI_STATUS(status); 173 return_ACPI_STATUS(status);
173 } 174 }
174 175
175 switch (op->common.node->type) { 176 /*
177 * Special handling for Alias objects. We need to setup the type
178 * and the Op->Common.Node to point to the Alias target. Note,
179 * Alias has at most one level of indirection internally.
180 */
181 type = op->common.node->type;
182 if (type == ACPI_TYPE_LOCAL_ALIAS) {
183 type = obj_desc->common.type;
184 op->common.node =
185 ACPI_CAST_PTR(struct acpi_namespace_node,
186 op->common.node->object);
187 }
188
189 switch (type) {
176 /* 190 /*
177 * For these types, we need the actual node, not the subobject. 191 * For these types, we need the actual node, not the subobject.
178 * However, the subobject did not get an extra reference count above. 192 * However, the subobject did not get an extra reference count above.
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 53a7e416f33e..7c0e74227171 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -213,7 +213,7 @@ acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
213 213
214 /* Execute the AML code for the term_arg arguments */ 214 /* Execute the AML code for the term_arg arguments */
215 215
216 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), 216 status = acpi_ds_execute_arguments(node, node->parent,
217 extra_desc->extra.aml_length, 217 extra_desc->extra.aml_length,
218 extra_desc->extra.aml_start); 218 extra_desc->extra.aml_start);
219 return_ACPI_STATUS(status); 219 return_ACPI_STATUS(status);
@@ -257,7 +257,7 @@ acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
257 257
258 /* Execute the AML code for the term_arg arguments */ 258 /* Execute the AML code for the term_arg arguments */
259 259
260 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), 260 status = acpi_ds_execute_arguments(node, node->parent,
261 extra_desc->extra.aml_length, 261 extra_desc->extra.aml_length,
262 extra_desc->extra.aml_start); 262 extra_desc->extra.aml_start);
263 return_ACPI_STATUS(status); 263 return_ACPI_STATUS(status);
@@ -394,7 +394,7 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
394 394
395 /* Execute the argument AML */ 395 /* Execute the argument AML */
396 396
397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), 397 status = acpi_ds_execute_arguments(node, node->parent,
398 extra_desc->extra.aml_length, 398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start); 399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) { 400 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index 306c62ab2e88..15135c25aa9b 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -746,7 +746,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
746 index--; 746 index--;
747 747
748 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 748 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
749 "Arg #%d (%p) done, Arg1=%p\n", index, arg, 749 "Arg #%u (%p) done, Arg1=%p\n", index, arg,
750 first_arg)); 750 first_arg));
751 } 751 }
752 752
@@ -760,7 +760,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
760 */ 760 */
761 acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); 761 acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
762 762
763 ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %d", index)); 763 ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %u", index));
764 return_ACPI_STATUS(status); 764 return_ACPI_STATUS(status);
765} 765}
766 766
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index f5795915a2e9..303618889da0 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -102,9 +102,8 @@ acpi_status acpi_ev_initialize_events(void)
102 * RETURN: Status 102 * RETURN: Status
103 * 103 *
104 * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks 104 * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks
105 * (0 and 1). This causes the _PRW methods to be run, so the HW 105 * (0 and 1). The HW must be fully initialized at this point,
106 * must be fully initialized at this point, including global lock 106 * including global lock support.
107 * support.
108 * 107 *
109 ******************************************************************************/ 108 ******************************************************************************/
110 109
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 7c2c336006a1..7a6a3e6f4be0 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -54,49 +54,84 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
54 54
55/******************************************************************************* 55/*******************************************************************************
56 * 56 *
57 * FUNCTION: acpi_ev_update_gpe_enable_masks 57 * FUNCTION: acpi_ev_update_gpe_enable_mask
58 * 58 *
59 * PARAMETERS: gpe_event_info - GPE to update 59 * PARAMETERS: gpe_event_info - GPE to update
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
63 * DESCRIPTION: Updates GPE register enable masks based upon whether there are 63 * DESCRIPTION: Updates GPE register enable mask based upon whether there are
64 * references (either wake or run) to this GPE 64 * runtime references to this GPE
65 * 65 *
66 ******************************************************************************/ 66 ******************************************************************************/
67 67
68acpi_status 68acpi_status
69acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) 69acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
70{ 70{
71 struct acpi_gpe_register_info *gpe_register_info; 71 struct acpi_gpe_register_info *gpe_register_info;
72 u32 register_bit; 72 u32 register_bit;
73 73
74 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks); 74 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_mask);
75 75
76 gpe_register_info = gpe_event_info->register_info; 76 gpe_register_info = gpe_event_info->register_info;
77 if (!gpe_register_info) { 77 if (!gpe_register_info) {
78 return_ACPI_STATUS(AE_NOT_EXIST); 78 return_ACPI_STATUS(AE_NOT_EXIST);
79 } 79 }
80 80
81 register_bit = acpi_hw_gpe_register_bit(gpe_event_info, 81 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
82 gpe_register_info); 82 gpe_register_info);
83 83
84 /* Clear the wake/run bits up front */ 84 /* Clear the run bit up front */
85 85
86 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, register_bit);
87 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit); 86 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
88 87
89 /* Set the mask bits only if there are references to this GPE */ 88 /* Set the mask bit only if there are references to this GPE */
90 89
91 if (gpe_event_info->runtime_count) { 90 if (gpe_event_info->runtime_count) {
92 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit); 91 ACPI_SET_BIT(gpe_register_info->enable_for_run, (u8)register_bit);
93 } 92 }
94 93
95 if (gpe_event_info->wakeup_count) { 94 return_ACPI_STATUS(AE_OK);
96 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit); 95}
96
97/*******************************************************************************
98 *
99 * FUNCTION: acpi_ev_enable_gpe
100 *
101 * PARAMETERS: gpe_event_info - GPE to enable
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Clear the given GPE from stale events and enable it.
106 *
107 ******************************************************************************/
108acpi_status
109acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
110{
111 acpi_status status;
112
113 ACPI_FUNCTION_TRACE(ev_enable_gpe);
114
115 /*
116 * We will only allow a GPE to be enabled if it has either an
117 * associated method (_Lxx/_Exx) or a handler. Otherwise, the
118 * GPE will be immediately disabled by acpi_ev_gpe_dispatch the
119 * first time it fires.
120 */
121 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) {
122 return_ACPI_STATUS(AE_NO_HANDLER);
97 } 123 }
98 124
99 return_ACPI_STATUS(AE_OK); 125 /* Clear the GPE (of stale events) */
126 status = acpi_hw_clear_gpe(gpe_event_info);
127 if (ACPI_FAILURE(status)) {
128 return_ACPI_STATUS(status);
129 }
130
131 /* Enable the requested GPE */
132 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
133
134 return_ACPI_STATUS(status);
100} 135}
101 136
102 137
@@ -417,8 +452,12 @@ static void acpi_ev_asynch_enable_gpe(void *context)
417 } 452 }
418 } 453 }
419 454
420 /* Enable this GPE */ 455 /*
421 (void)acpi_hw_write_gpe_enable_reg(gpe_event_info); 456 * Enable this GPE, conditionally. This means that the GPE will only be
457 * physically enabled if the enable_for_run bit is set in the event_info
458 */
459 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_COND_ENABLE);
460
422 return_VOID; 461 return_VOID;
423} 462}
424 463
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 341a38ce8aa6..85445fb5844e 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -439,8 +439,6 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
439{ 439{
440 acpi_status status; 440 acpi_status status;
441 struct acpi_gpe_event_info *gpe_event_info; 441 struct acpi_gpe_event_info *gpe_event_info;
442 struct acpi_gpe_walk_info walk_info;
443 u32 wake_gpe_count;
444 u32 gpe_enabled_count; 442 u32 gpe_enabled_count;
445 u32 gpe_index; 443 u32 gpe_index;
446 u32 gpe_number; 444 u32 gpe_number;
@@ -456,37 +454,9 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
456 } 454 }
457 455
458 /* 456 /*
459 * Runtime option: Should wake GPEs be enabled at runtime? The default 457 * Enable all GPEs that have a corresponding method. Any other GPEs
460 * is no, they should only be enabled just as the machine goes to sleep. 458 * within this block must be enabled via the acpi_enable_gpe interface.
461 */ 459 */
462 if (acpi_gbl_leave_wake_gpes_disabled) {
463 /*
464 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
465 * Each GPE that has one or more _PRWs that reference it is by
466 * definition a wake GPE and will not be enabled while the machine
467 * is running.
468 */
469 walk_info.gpe_block = gpe_block;
470 walk_info.gpe_device = gpe_device;
471 walk_info.execute_by_owner_id = FALSE;
472
473 status =
474 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
475 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
476 acpi_ev_match_prw_and_gpe, NULL,
477 &walk_info, NULL);
478 if (ACPI_FAILURE(status)) {
479 ACPI_EXCEPTION((AE_INFO, status,
480 "While executing _PRW methods"));
481 }
482 }
483
484 /*
485 * Enable all GPEs that have a corresponding method and are not
486 * capable of generating wakeups. Any other GPEs within this block
487 * must be enabled via the acpi_enable_gpe interface.
488 */
489 wake_gpe_count = 0;
490 gpe_enabled_count = 0; 460 gpe_enabled_count = 0;
491 461
492 if (gpe_device == acpi_gbl_fadt_gpe_device) { 462 if (gpe_device == acpi_gbl_fadt_gpe_device) {
@@ -502,35 +472,21 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
502 gpe_event_info = &gpe_block->event_info[gpe_index]; 472 gpe_event_info = &gpe_block->event_info[gpe_index];
503 gpe_number = gpe_index + gpe_block->block_base_number; 473 gpe_number = gpe_index + gpe_block->block_base_number;
504 474
505 /*
506 * If the GPE has already been enabled for runtime
507 * signaling, make sure it remains enabled, but do not
508 * increment its reference counter.
509 */
510 if (gpe_event_info->runtime_count) {
511 acpi_set_gpe(gpe_device, gpe_number,
512 ACPI_GPE_ENABLE);
513 gpe_enabled_count++;
514 continue;
515 }
516
517 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
518 wake_gpe_count++;
519 if (acpi_gbl_leave_wake_gpes_disabled) {
520 continue;
521 }
522 }
523
524 /* Ignore GPEs that have no corresponding _Lxx/_Exx method */ 475 /* Ignore GPEs that have no corresponding _Lxx/_Exx method */
525 476
526 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)) { 477 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)) {
527 continue; 478 continue;
528 } 479 }
529 480
530 /* Enable this GPE */ 481 /*
482 * If the GPE has already been enabled for runtime
483 * signaling, make sure it remains enabled, but do not
484 * increment its reference counter.
485 */
486 status = gpe_event_info->runtime_count ?
487 acpi_ev_enable_gpe(gpe_event_info) :
488 acpi_enable_gpe(gpe_device, gpe_number);
531 489
532 status = acpi_enable_gpe(gpe_device, gpe_number,
533 ACPI_GPE_TYPE_RUNTIME);
534 if (ACPI_FAILURE(status)) { 490 if (ACPI_FAILURE(status)) {
535 ACPI_EXCEPTION((AE_INFO, status, 491 ACPI_EXCEPTION((AE_INFO, status,
536 "Could not enable GPE 0x%02X", 492 "Could not enable GPE 0x%02X",
@@ -542,10 +498,10 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
542 } 498 }
543 } 499 }
544 500
545 if (gpe_enabled_count || wake_gpe_count) { 501 if (gpe_enabled_count) {
546 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 502 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
547 "Enabled %u Runtime GPEs, added %u Wake GPEs in this block\n", 503 "Enabled %u GPEs in this block\n",
548 gpe_enabled_count, wake_gpe_count)); 504 gpe_enabled_count));
549 } 505 }
550 506
551 return_ACPI_STATUS(AE_OK); 507 return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index 3f6c2d26410d..3084c5de1bba 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -211,9 +211,7 @@ acpi_status acpi_ev_gpe_initialize(void)
211 * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a 211 * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
212 * result of a Load() or load_table() operation. If new GPE 212 * result of a Load() or load_table() operation. If new GPE
213 * methods have been installed, register the new methods and 213 * methods have been installed, register the new methods and
214 * enable and runtime GPEs that are associated with them. Also, 214 * enable and runtime GPEs that are associated with them.
215 * run any newly loaded _PRW methods in order to discover any
216 * new CAN_WAKE GPEs.
217 * 215 *
218 ******************************************************************************/ 216 ******************************************************************************/
219 217
@@ -223,49 +221,12 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id)
223 struct acpi_gpe_block_info *gpe_block; 221 struct acpi_gpe_block_info *gpe_block;
224 struct acpi_gpe_walk_info walk_info; 222 struct acpi_gpe_walk_info walk_info;
225 acpi_status status = AE_OK; 223 acpi_status status = AE_OK;
226 u32 new_wake_gpe_count = 0;
227
228 /* We will examine only _PRW/_Lxx/_Exx methods owned by this table */
229
230 walk_info.owner_id = table_owner_id;
231 walk_info.execute_by_owner_id = TRUE;
232 walk_info.count = 0;
233
234 if (acpi_gbl_leave_wake_gpes_disabled) {
235 /*
236 * 1) Run any newly-loaded _PRW methods to find any GPEs that
237 * can now be marked as CAN_WAKE GPEs. Note: We must run the
238 * _PRW methods before we process the _Lxx/_Exx methods because
239 * we will enable all runtime GPEs associated with the new
240 * _Lxx/_Exx methods at the time we process those methods.
241 *
242 * Unlock interpreter so that we can run the _PRW methods.
243 */
244 walk_info.gpe_block = NULL;
245 walk_info.gpe_device = NULL;
246
247 acpi_ex_exit_interpreter();
248
249 status =
250 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
251 ACPI_UINT32_MAX,
252 ACPI_NS_WALK_NO_UNLOCK,
253 acpi_ev_match_prw_and_gpe, NULL,
254 &walk_info, NULL);
255 if (ACPI_FAILURE(status)) {
256 ACPI_EXCEPTION((AE_INFO, status,
257 "While executing _PRW methods"));
258 }
259
260 acpi_ex_enter_interpreter();
261 new_wake_gpe_count = walk_info.count;
262 }
263 224
264 /* 225 /*
265 * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. 226 * 2) Find any _Lxx/_Exx GPE methods that have just been loaded.
266 * 227 *
267 * Any GPEs that correspond to new _Lxx/_Exx methods and are not 228 * Any GPEs that correspond to new _Lxx/_Exx methods are immediately
268 * marked as CAN_WAKE are immediately enabled. 229 * enabled.
269 * 230 *
270 * Examine the namespace underneath each gpe_device within the 231 * Examine the namespace underneath each gpe_device within the
271 * gpe_block lists. 232 * gpe_block lists.
@@ -275,6 +236,8 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id)
275 return; 236 return;
276 } 237 }
277 238
239 walk_info.owner_id = table_owner_id;
240 walk_info.execute_by_owner_id = TRUE;
278 walk_info.count = 0; 241 walk_info.count = 0;
279 walk_info.enable_this_gpe = TRUE; 242 walk_info.enable_this_gpe = TRUE;
280 243
@@ -307,10 +270,8 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id)
307 gpe_xrupt_info = gpe_xrupt_info->next; 270 gpe_xrupt_info = gpe_xrupt_info->next;
308 } 271 }
309 272
310 if (walk_info.count || new_wake_gpe_count) { 273 if (walk_info.count) {
311 ACPI_INFO((AE_INFO, 274 ACPI_INFO((AE_INFO, "Enabled %u new GPEs", walk_info.count));
312 "Enabled %u new runtime GPEs, added %u new wakeup GPEs",
313 walk_info.count, new_wake_gpe_count));
314 } 275 }
315 276
316 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 277 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
@@ -386,9 +347,6 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
386 /* 347 /*
387 * 3) Edge/Level determination is based on the 2nd character 348 * 3) Edge/Level determination is based on the 2nd character
388 * of the method name 349 * of the method name
389 *
390 * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is
391 * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set.
392 */ 350 */
393 switch (name[1]) { 351 switch (name[1]) {
394 case 'L': 352 case 'L':
@@ -471,24 +429,18 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
471 */ 429 */
472 if (walk_info->enable_this_gpe) { 430 if (walk_info->enable_this_gpe) {
473 431
474 /* Ignore GPEs that can wake the system */ 432 walk_info->count++;
433 gpe_device = walk_info->gpe_device;
475 434
476 if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE) || 435 if (gpe_device == acpi_gbl_fadt_gpe_device) {
477 !acpi_gbl_leave_wake_gpes_disabled) { 436 gpe_device = NULL;
478 walk_info->count++; 437 }
479 gpe_device = walk_info->gpe_device;
480
481 if (gpe_device == acpi_gbl_fadt_gpe_device) {
482 gpe_device = NULL;
483 }
484 438
485 status = acpi_enable_gpe(gpe_device, gpe_number, 439 status = acpi_enable_gpe(gpe_device, gpe_number);
486 ACPI_GPE_TYPE_RUNTIME); 440 if (ACPI_FAILURE(status)) {
487 if (ACPI_FAILURE(status)) { 441 ACPI_EXCEPTION((AE_INFO, status,
488 ACPI_EXCEPTION((AE_INFO, status, 442 "Could not enable GPE 0x%02X",
489 "Could not enable GPE 0x%02X", 443 gpe_number));
490 gpe_number));
491 }
492 } 444 }
493 } 445 }
494 446
@@ -497,157 +449,3 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
497 name, gpe_number)); 449 name, gpe_number));
498 return_ACPI_STATUS(AE_OK); 450 return_ACPI_STATUS(AE_OK);
499} 451}
500
501/*******************************************************************************
502 *
503 * FUNCTION: acpi_ev_match_prw_and_gpe
504 *
505 * PARAMETERS: Callback from walk_namespace
506 *
507 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is
508 * not aborted on a single _PRW failure.
509 *
510 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
511 * Device. Run the _PRW method. If present, extract the GPE
512 * number and mark the GPE as a CAN_WAKE GPE. Allows a
513 * per-owner_id execution if execute_by_owner_id is TRUE in the
514 * walk_info parameter block.
515 *
516 * If walk_info->execute_by_owner_id is TRUE, we only execute _PRWs with that
517 * owner.
518 * If walk_info->gpe_device is NULL, we execute every _PRW found. Otherwise,
519 * we only execute _PRWs that refer to the input gpe_device.
520 *
521 ******************************************************************************/
522
523acpi_status
524acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
525 u32 level, void *context, void **return_value)
526{
527 struct acpi_gpe_walk_info *walk_info =
528 ACPI_CAST_PTR(struct acpi_gpe_walk_info, context);
529 struct acpi_namespace_node *gpe_device;
530 struct acpi_gpe_block_info *gpe_block;
531 struct acpi_namespace_node *target_gpe_device;
532 struct acpi_namespace_node *prw_node;
533 struct acpi_gpe_event_info *gpe_event_info;
534 union acpi_operand_object *pkg_desc;
535 union acpi_operand_object *obj_desc;
536 u32 gpe_number;
537 acpi_status status;
538
539 ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe);
540
541 /* Check for a _PRW method under this device */
542
543 status = acpi_ns_get_node(obj_handle, METHOD_NAME__PRW,
544 ACPI_NS_NO_UPSEARCH, &prw_node);
545 if (ACPI_FAILURE(status)) {
546 return_ACPI_STATUS(AE_OK);
547 }
548
549 /* Check if requested owner_id matches this owner_id */
550
551 if ((walk_info->execute_by_owner_id) &&
552 (prw_node->owner_id != walk_info->owner_id)) {
553 return_ACPI_STATUS(AE_OK);
554 }
555
556 /* Execute the _PRW */
557
558 status = acpi_ut_evaluate_object(prw_node, NULL,
559 ACPI_BTYPE_PACKAGE, &pkg_desc);
560 if (ACPI_FAILURE(status)) {
561 return_ACPI_STATUS(AE_OK);
562 }
563
564 /* The returned _PRW package must have at least two elements */
565
566 if (pkg_desc->package.count < 2) {
567 goto cleanup;
568 }
569
570 /* Extract pointers from the input context */
571
572 gpe_device = walk_info->gpe_device;
573 gpe_block = walk_info->gpe_block;
574
575 /*
576 * The _PRW object must return a package, we are only interested
577 * in the first element
578 */
579 obj_desc = pkg_desc->package.elements[0];
580
581 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
582
583 /* Use FADT-defined GPE device (from definition of _PRW) */
584
585 target_gpe_device = NULL;
586 if (gpe_device) {
587 target_gpe_device = acpi_gbl_fadt_gpe_device;
588 }
589
590 /* Integer is the GPE number in the FADT described GPE blocks */
591
592 gpe_number = (u32)obj_desc->integer.value;
593 } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
594
595 /* Package contains a GPE reference and GPE number within a GPE block */
596
597 if ((obj_desc->package.count < 2) ||
598 ((obj_desc->package.elements[0])->common.type !=
599 ACPI_TYPE_LOCAL_REFERENCE) ||
600 ((obj_desc->package.elements[1])->common.type !=
601 ACPI_TYPE_INTEGER)) {
602 goto cleanup;
603 }
604
605 /* Get GPE block reference and decode */
606
607 target_gpe_device =
608 obj_desc->package.elements[0]->reference.node;
609 gpe_number = (u32)obj_desc->package.elements[1]->integer.value;
610 } else {
611 /* Unknown type, just ignore it */
612
613 goto cleanup;
614 }
615
616 /* Get the gpe_event_info for this GPE */
617
618 if (gpe_device) {
619 /*
620 * Is this GPE within this block?
621 *
622 * TRUE if and only if these conditions are true:
623 * 1) The GPE devices match.
624 * 2) The GPE index(number) is within the range of the Gpe Block
625 * associated with the GPE device.
626 */
627 if (gpe_device != target_gpe_device) {
628 goto cleanup;
629 }
630
631 gpe_event_info =
632 acpi_ev_low_get_gpe_info(gpe_number, gpe_block);
633 } else {
634 /* gpe_device is NULL, just match the target_device and gpe_number */
635
636 gpe_event_info =
637 acpi_ev_get_gpe_event_info(target_gpe_device, gpe_number);
638 }
639
640 if (gpe_event_info) {
641 if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
642
643 /* This GPE can wake the system */
644
645 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
646 walk_info->count++;
647 }
648 }
649
650 cleanup:
651 acpi_ut_remove_reference(pkg_desc);
652 return_ACPI_STATUS(AE_OK);
653}
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 2e3b0334072f..f40d271bf568 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -199,7 +199,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
199 return_ACPI_STATUS(status); 199 return_ACPI_STATUS(status);
200 } 200 }
201 201
202 parent_node = acpi_ns_get_parent_node(region_obj->region.node); 202 parent_node = region_obj->region.node->parent;
203 203
204 /* 204 /*
205 * Get the _SEG and _BBN values from the device upon which the handler 205 * Get the _SEG and _BBN values from the device upon which the handler
@@ -248,7 +248,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
248 break; 248 break;
249 } 249 }
250 250
251 pci_root_node = acpi_ns_get_parent_node(pci_root_node); 251 pci_root_node = pci_root_node->parent;
252 } 252 }
253 253
254 /* PCI root bridge not found, use namespace root node */ 254 /* PCI root bridge not found, use namespace root node */
@@ -280,7 +280,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
280 */ 280 */
281 pci_device_node = region_obj->region.node; 281 pci_device_node = region_obj->region.node;
282 while (pci_device_node && (pci_device_node->type != ACPI_TYPE_DEVICE)) { 282 while (pci_device_node && (pci_device_node->type != ACPI_TYPE_DEVICE)) {
283 pci_device_node = acpi_ns_get_parent_node(pci_device_node); 283 pci_device_node = pci_device_node->parent;
284 } 284 }
285 285
286 if (!pci_device_node) { 286 if (!pci_device_node) {
@@ -521,7 +521,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
521 return_ACPI_STATUS(AE_NOT_EXIST); 521 return_ACPI_STATUS(AE_NOT_EXIST);
522 } 522 }
523 523
524 node = acpi_ns_get_parent_node(region_obj->region.node); 524 node = region_obj->region.node->parent;
525 space_id = region_obj->region.space_id; 525 space_id = region_obj->region.space_id;
526 526
527 /* Setup defaults */ 527 /* Setup defaults */
@@ -654,7 +654,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
654 654
655 /* This node does not have the handler we need; Pop up one level */ 655 /* This node does not have the handler we need; Pop up one level */
656 656
657 node = acpi_ns_get_parent_node(node); 657 node = node->parent;
658 } 658 }
659 659
660 /* If we get here, there is no handler for this region */ 660 /* If we get here, there is no handler for this region */
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 18b3f1468b7d..0ec900da5794 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -213,101 +213,71 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
213 213
214/******************************************************************************* 214/*******************************************************************************
215 * 215 *
216 * FUNCTION: acpi_clear_and_enable_gpe 216 * FUNCTION: acpi_gpe_wakeup
217 *
218 * PARAMETERS: gpe_event_info - GPE to enable
219 *
220 * RETURN: Status
221 *
222 * DESCRIPTION: Clear the given GPE from stale events and enable it.
223 *
224 ******************************************************************************/
225static acpi_status
226acpi_clear_and_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
227{
228 acpi_status status;
229
230 /*
231 * We will only allow a GPE to be enabled if it has either an
232 * associated method (_Lxx/_Exx) or a handler. Otherwise, the
233 * GPE will be immediately disabled by acpi_ev_gpe_dispatch the
234 * first time it fires.
235 */
236 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) {
237 return_ACPI_STATUS(AE_NO_HANDLER);
238 }
239
240 /* Clear the GPE (of stale events) */
241 status = acpi_hw_clear_gpe(gpe_event_info);
242 if (ACPI_FAILURE(status)) {
243 return_ACPI_STATUS(status);
244 }
245
246 /* Enable the requested GPE */
247 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
248
249 return_ACPI_STATUS(status);
250}
251
252/*******************************************************************************
253 *
254 * FUNCTION: acpi_set_gpe
255 * 217 *
256 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 218 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
257 * gpe_number - GPE level within the GPE block 219 * gpe_number - GPE level within the GPE block
258 * action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE 220 * Action - Enable or Disable
259 * 221 *
260 * RETURN: Status 222 * RETURN: Status
261 * 223 *
262 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses 224 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
263 * the reference count mechanism used in the acpi_enable_gpe and
264 * acpi_disable_gpe interfaces -- and should be used with care.
265 *
266 * Note: Typically used to disable a runtime GPE for short period of time,
267 * then re-enable it, without disturbing the existing reference counts. This
268 * is useful, for example, in the Embedded Controller (EC) driver.
269 * 225 *
270 ******************************************************************************/ 226 ******************************************************************************/
271acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action) 227acpi_status acpi_gpe_wakeup(acpi_handle gpe_device, u32 gpe_number, u8 action)
272{ 228{
229 acpi_status status = AE_OK;
273 struct acpi_gpe_event_info *gpe_event_info; 230 struct acpi_gpe_event_info *gpe_event_info;
274 acpi_status status; 231 struct acpi_gpe_register_info *gpe_register_info;
275 acpi_cpu_flags flags; 232 acpi_cpu_flags flags;
233 u32 register_bit;
276 234
277 ACPI_FUNCTION_TRACE(acpi_set_gpe); 235 ACPI_FUNCTION_TRACE(acpi_gpe_wakeup);
278 236
279 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 237 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
280 238
281 /* Ensure that we have a valid GPE number */ 239 /* Ensure that we have a valid GPE number */
282 240
283 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 241 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
284 if (!gpe_event_info) { 242 if (!gpe_event_info || !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
285 status = AE_BAD_PARAMETER; 243 status = AE_BAD_PARAMETER;
286 goto unlock_and_exit; 244 goto unlock_and_exit;
287 } 245 }
288 246
247 gpe_register_info = gpe_event_info->register_info;
248 if (!gpe_register_info) {
249 status = AE_NOT_EXIST;
250 goto unlock_and_exit;
251 }
252
253 register_bit =
254 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
255
289 /* Perform the action */ 256 /* Perform the action */
290 257
291 switch (action) { 258 switch (action) {
292 case ACPI_GPE_ENABLE: 259 case ACPI_GPE_ENABLE:
293 status = acpi_clear_and_enable_gpe(gpe_event_info); 260 ACPI_SET_BIT(gpe_register_info->enable_for_wake,
261 (u8)register_bit);
294 break; 262 break;
295 263
296 case ACPI_GPE_DISABLE: 264 case ACPI_GPE_DISABLE:
297 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); 265 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
266 (u8)register_bit);
298 break; 267 break;
299 268
300 default: 269 default:
270 ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
301 status = AE_BAD_PARAMETER; 271 status = AE_BAD_PARAMETER;
302 break; 272 break;
303 } 273 }
304 274
305 unlock_and_exit: 275unlock_and_exit:
306 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 276 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
307 return_ACPI_STATUS(status); 277 return_ACPI_STATUS(status);
308} 278}
309 279
310ACPI_EXPORT_SYMBOL(acpi_set_gpe) 280ACPI_EXPORT_SYMBOL(acpi_gpe_wakeup)
311 281
312/******************************************************************************* 282/*******************************************************************************
313 * 283 *
@@ -315,17 +285,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_gpe)
315 * 285 *
316 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 286 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
317 * gpe_number - GPE level within the GPE block 287 * gpe_number - GPE level within the GPE block
318 * gpe_type - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
319 * or both
320 * 288 *
321 * RETURN: Status 289 * RETURN: Status
322 * 290 *
323 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is 291 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
324 * hardware-enabled (for runtime GPEs), or the GPE register mask 292 * hardware-enabled.
325 * is updated (for wake GPEs).
326 * 293 *
327 ******************************************************************************/ 294 ******************************************************************************/
328acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type) 295acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
329{ 296{
330 acpi_status status = AE_OK; 297 acpi_status status = AE_OK;
331 struct acpi_gpe_event_info *gpe_event_info; 298 struct acpi_gpe_event_info *gpe_event_info;
@@ -333,12 +300,6 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
333 300
334 ACPI_FUNCTION_TRACE(acpi_enable_gpe); 301 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
335 302
336 /* Parameter validation */
337
338 if (!gpe_type || (gpe_type & ~ACPI_GPE_TYPE_WAKE_RUN)) {
339 return_ACPI_STATUS(AE_BAD_PARAMETER);
340 }
341
342 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 303 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
343 304
344 /* Ensure that we have a valid GPE number */ 305 /* Ensure that we have a valid GPE number */
@@ -349,46 +310,19 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
349 goto unlock_and_exit; 310 goto unlock_and_exit;
350 } 311 }
351 312
352 if (gpe_type & ACPI_GPE_TYPE_RUNTIME) { 313 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) {
353 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) { 314 status = AE_LIMIT; /* Too many references */
354 status = AE_LIMIT; /* Too many references */ 315 goto unlock_and_exit;
355 goto unlock_and_exit;
356 }
357
358 gpe_event_info->runtime_count++;
359 if (gpe_event_info->runtime_count == 1) {
360 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
361 if (ACPI_SUCCESS(status)) {
362 status = acpi_clear_and_enable_gpe(gpe_event_info);
363 }
364
365 if (ACPI_FAILURE(status)) {
366 gpe_event_info->runtime_count--;
367 goto unlock_and_exit;
368 }
369 }
370 } 316 }
371 317
372 if (gpe_type & ACPI_GPE_TYPE_WAKE) { 318 gpe_event_info->runtime_count++;
373 /* The GPE must have the ability to wake the system */ 319 if (gpe_event_info->runtime_count == 1) {
374 320 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
375 if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { 321 if (ACPI_SUCCESS(status)) {
376 status = AE_TYPE; 322 status = acpi_ev_enable_gpe(gpe_event_info);
377 goto unlock_and_exit;
378 } 323 }
379 324 if (ACPI_FAILURE(status)) {
380 if (gpe_event_info->wakeup_count == ACPI_UINT8_MAX) { 325 gpe_event_info->runtime_count--;
381 status = AE_LIMIT; /* Too many references */
382 goto unlock_and_exit;
383 }
384
385 /*
386 * Update the enable mask on the first wakeup reference. Wake GPEs
387 * are only hardware-enabled just before sleeping.
388 */
389 gpe_event_info->wakeup_count++;
390 if (gpe_event_info->wakeup_count == 1) {
391 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
392 } 326 }
393 } 327 }
394 328
@@ -404,8 +338,6 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
404 * 338 *
405 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 339 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
406 * gpe_number - GPE level within the GPE block 340 * gpe_number - GPE level within the GPE block
407 * gpe_type - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
408 * or both
409 * 341 *
410 * RETURN: Status 342 * RETURN: Status
411 * 343 *
@@ -414,7 +346,7 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
414 * the GPE mask bit disabled (for wake GPEs) 346 * the GPE mask bit disabled (for wake GPEs)
415 * 347 *
416 ******************************************************************************/ 348 ******************************************************************************/
417acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type) 349acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
418{ 350{
419 acpi_status status = AE_OK; 351 acpi_status status = AE_OK;
420 struct acpi_gpe_event_info *gpe_event_info; 352 struct acpi_gpe_event_info *gpe_event_info;
@@ -422,12 +354,6 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
422 354
423 ACPI_FUNCTION_TRACE(acpi_disable_gpe); 355 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
424 356
425 /* Parameter validation */
426
427 if (!gpe_type || (gpe_type & ~ACPI_GPE_TYPE_WAKE_RUN)) {
428 return_ACPI_STATUS(AE_BAD_PARAMETER);
429 }
430
431 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 357 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
432 358
433 /* Ensure that we have a valid GPE number */ 359 /* Ensure that we have a valid GPE number */
@@ -440,41 +366,21 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
440 366
441 /* Hardware-disable a runtime GPE on removal of the last reference */ 367 /* Hardware-disable a runtime GPE on removal of the last reference */
442 368
443 if (gpe_type & ACPI_GPE_TYPE_RUNTIME) { 369 if (!gpe_event_info->runtime_count) {
444 if (!gpe_event_info->runtime_count) { 370 status = AE_LIMIT; /* There are no references to remove */
445 status = AE_LIMIT; /* There are no references to remove */ 371 goto unlock_and_exit;
446 goto unlock_and_exit;
447 }
448
449 gpe_event_info->runtime_count--;
450 if (!gpe_event_info->runtime_count) {
451 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
452 if (ACPI_SUCCESS(status)) {
453 status = acpi_hw_low_set_gpe(gpe_event_info,
454 ACPI_GPE_DISABLE);
455 }
456
457 if (ACPI_FAILURE(status)) {
458 gpe_event_info->runtime_count++;
459 goto unlock_and_exit;
460 }
461 }
462 } 372 }
463 373
464 /* 374 gpe_event_info->runtime_count--;
465 * Update masks for wake GPE on removal of the last reference. 375 if (!gpe_event_info->runtime_count) {
466 * No need to hardware-disable wake GPEs here, they are not currently 376 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
467 * enabled. 377 if (ACPI_SUCCESS(status)) {
468 */ 378 status =
469 if (gpe_type & ACPI_GPE_TYPE_WAKE) { 379 acpi_hw_low_set_gpe(gpe_event_info,
470 if (!gpe_event_info->wakeup_count) { 380 ACPI_GPE_DISABLE);
471 status = AE_LIMIT; /* There are no references to remove */
472 goto unlock_and_exit;
473 } 381 }
474 382 if (ACPI_FAILURE(status)) {
475 gpe_event_info->wakeup_count--; 383 gpe_event_info->runtime_count++;
476 if (!gpe_event_info->wakeup_count) {
477 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
478 } 384 }
479 } 385 }
480 386
@@ -486,6 +392,59 @@ ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
486 392
487/******************************************************************************* 393/*******************************************************************************
488 * 394 *
395 * FUNCTION: acpi_gpe_can_wake
396 *
397 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
398 * gpe_number - GPE level within the GPE block
399 *
400 * RETURN: Status
401 *
402 * DESCRIPTION: Set the ACPI_GPE_CAN_WAKE flag for the given GPE. If the GPE
403 * has a corresponding method and is currently enabled, disable it
404 * (GPEs with corresponding methods are enabled unconditionally
405 * during initialization, but GPEs that can wake up are expected
406 * to be initially disabled).
407 *
408 ******************************************************************************/
409acpi_status acpi_gpe_can_wake(acpi_handle gpe_device, u32 gpe_number)
410{
411 acpi_status status = AE_OK;
412 struct acpi_gpe_event_info *gpe_event_info;
413 acpi_cpu_flags flags;
414 u8 disable = 0;
415
416 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake);
417
418 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
419
420 /* Ensure that we have a valid GPE number */
421
422 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
423 if (!gpe_event_info) {
424 status = AE_BAD_PARAMETER;
425 goto unlock_and_exit;
426 }
427
428 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
429 goto unlock_and_exit;
430 }
431
432 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
433 disable = (gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)
434 && gpe_event_info->runtime_count;
435
436unlock_and_exit:
437 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
438
439 if (disable)
440 status = acpi_disable_gpe(gpe_device, gpe_number);
441
442 return_ACPI_STATUS(status);
443}
444ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake)
445
446/*******************************************************************************
447 *
489 * FUNCTION: acpi_disable_event 448 * FUNCTION: acpi_disable_event
490 * 449 *
491 * PARAMETERS: Event - The fixed eventto be enabled 450 * PARAMETERS: Event - The fixed eventto be enabled
@@ -800,7 +759,7 @@ acpi_install_gpe_block(acpi_handle gpe_device,
800 759
801 obj_desc->device.gpe_block = gpe_block; 760 obj_desc->device.gpe_block = gpe_block;
802 761
803 /* Run the _PRW methods and enable the runtime GPEs in the new block */ 762 /* Enable the runtime GPEs in the new block */
804 763
805 status = acpi_ev_initialize_gpe_block(node, gpe_block); 764 status = acpi_ev_initialize_gpe_block(node, gpe_block);
806 765
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 008621c5ad85..18832205b631 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -120,7 +120,7 @@ acpi_ex_add_table(u32 table_index,
120 acpi_ns_exec_module_code_list(); 120 acpi_ns_exec_module_code_list();
121 acpi_ex_enter_interpreter(); 121 acpi_ex_enter_interpreter();
122 122
123 /* Update GPEs for any new _PRW or _Lxx/_Exx methods. Ignore errors */ 123 /* Update GPEs for any new _Lxx/_Exx methods. Ignore errors */
124 124
125 status = acpi_tb_get_owner_id(table_index, &owner_id); 125 status = acpi_tb_get_owner_id(table_index, &owner_id);
126 if (ACPI_SUCCESS(status)) { 126 if (ACPI_SUCCESS(status)) {
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index d39d438ba1e3..f067bbb0d961 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -742,7 +742,7 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
742 } 742 }
743 743
744 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 744 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
745 "**** Start operand dump for opcode [%s], %d operands\n", 745 "**** Start operand dump for opcode [%s], %u operands\n",
746 opcode_name, num_operands)); 746 opcode_name, num_operands));
747 747
748 if (num_operands == 0) { 748 if (num_operands == 0) {
@@ -812,7 +812,7 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
812 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 812 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
813 acpi_ex_out_pointer("Attached Object", 813 acpi_ex_out_pointer("Attached Object",
814 acpi_ns_get_attached_object(node)); 814 acpi_ns_get_attached_object(node));
815 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); 815 acpi_ex_out_pointer("Parent", node->parent);
816 816
817 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node), 817 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
818 acpi_ex_dump_node); 818 acpi_ex_dump_node);
@@ -945,7 +945,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
945 945
946 case ACPI_TYPE_PACKAGE: 946 case ACPI_TYPE_PACKAGE:
947 947
948 acpi_os_printf("[Package] Contains %d Elements:\n", 948 acpi_os_printf("[Package] Contains %u Elements:\n",
949 obj_desc->package.count); 949 obj_desc->package.count);
950 950
951 for (i = 0; i < obj_desc->package.count; i++) { 951 for (i = 0; i < obj_desc->package.count; i++) {
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index a6dc26f0b3be..047217303a4b 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -534,13 +534,13 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
534 if (ACPI_SUCCESS(status)) { 534 if (ACPI_SUCCESS(status)) {
535 if (read_write == ACPI_READ) { 535 if (read_write == ACPI_READ) {
536 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 536 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
537 "Value Read %8.8X%8.8X, Width %d\n", 537 "Value Read %8.8X%8.8X, Width %u\n",
538 ACPI_FORMAT_UINT64(*value), 538 ACPI_FORMAT_UINT64(*value),
539 obj_desc->common_field. 539 obj_desc->common_field.
540 access_byte_width)); 540 access_byte_width));
541 } else { 541 } else {
542 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 542 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
543 "Value Written %8.8X%8.8X, Width %d\n", 543 "Value Written %8.8X%8.8X, Width %u\n",
544 ACPI_FORMAT_UINT64(*value), 544 ACPI_FORMAT_UINT64(*value),
545 obj_desc->common_field. 545 obj_desc->common_field.
546 access_byte_width)); 546 access_byte_width));
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 25059dace0ad..98a331d2249b 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -108,11 +108,11 @@ acpi_ex_generate_access(u32 field_bit_offset,
108 field_byte_length = field_byte_end_offset - field_byte_offset; 108 field_byte_length = field_byte_end_offset - field_byte_offset;
109 109
110 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 110 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
111 "Bit length %d, Bit offset %d\n", 111 "Bit length %u, Bit offset %u\n",
112 field_bit_length, field_bit_offset)); 112 field_bit_length, field_bit_offset));
113 113
114 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 114 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
115 "Byte Length %d, Byte Offset %d, End Offset %d\n", 115 "Byte Length %u, Byte Offset %u, End Offset %u\n",
116 field_byte_length, field_byte_offset, 116 field_byte_length, field_byte_offset,
117 field_byte_end_offset)); 117 field_byte_end_offset));
118 118
@@ -147,11 +147,11 @@ acpi_ex_generate_access(u32 field_bit_offset,
147 accesses = field_end_offset - field_start_offset; 147 accesses = field_end_offset - field_start_offset;
148 148
149 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 149 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
150 "AccessWidth %d end is within region\n", 150 "AccessWidth %u end is within region\n",
151 access_byte_width)); 151 access_byte_width));
152 152
153 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 153 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
154 "Field Start %d, Field End %d -- requires %d accesses\n", 154 "Field Start %u, Field End %u -- requires %u accesses\n",
155 field_start_offset, field_end_offset, 155 field_start_offset, field_end_offset,
156 accesses)); 156 accesses));
157 157
@@ -159,7 +159,7 @@ acpi_ex_generate_access(u32 field_bit_offset,
159 159
160 if (accesses <= 1) { 160 if (accesses <= 1) {
161 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 161 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
162 "Entire field can be accessed with one operation of size %d\n", 162 "Entire field can be accessed with one operation of size %u\n",
163 access_byte_width)); 163 access_byte_width));
164 return_VALUE(access_byte_width); 164 return_VALUE(access_byte_width);
165 } 165 }
@@ -174,7 +174,7 @@ acpi_ex_generate_access(u32 field_bit_offset,
174 } 174 }
175 } else { 175 } else {
176 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 176 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
177 "AccessWidth %d end is NOT within region\n", 177 "AccessWidth %u end is NOT within region\n",
178 access_byte_width)); 178 access_byte_width));
179 if (access_byte_width == 1) { 179 if (access_byte_width == 1) {
180 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 180 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
@@ -190,7 +190,7 @@ acpi_ex_generate_access(u32 field_bit_offset,
190 * previous access 190 * previous access
191 */ 191 */
192 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 192 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
193 "Backing off to previous optimal access width of %d\n", 193 "Backing off to previous optimal access width of %u\n",
194 minimum_access_width)); 194 minimum_access_width));
195 return_VALUE(minimum_access_width); 195 return_VALUE(minimum_access_width);
196 } 196 }
@@ -385,15 +385,6 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
385 (field_bit_position - 385 (field_bit_position -
386 ACPI_MUL_8(obj_desc->common_field.base_byte_offset)); 386 ACPI_MUL_8(obj_desc->common_field.base_byte_offset));
387 387
388 /*
389 * Does the entire field fit within a single field access element? (datum)
390 * (i.e., without crossing a datum boundary)
391 */
392 if ((obj_desc->common_field.start_field_bit_offset +
393 field_bit_length) <= (u16) access_bit_width) {
394 obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM;
395 }
396
397 return_ACPI_STATUS(AE_OK); 388 return_ACPI_STATUS(AE_OK);
398} 389}
399 390
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 531000fc77d2..8819d2ac5aee 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -194,7 +194,7 @@ acpi_ex_system_memory_space_handler(u32 function,
194 ((u64) address - (u64) mem_info->mapped_physical_address); 194 ((u64) address - (u64) mem_info->mapped_physical_address);
195 195
196 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
197 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", 197 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
198 bit_width, function, 198 bit_width, function,
199 ACPI_FORMAT_NATIVE_UINT(address))); 199 ACPI_FORMAT_NATIVE_UINT(address)));
200 200
@@ -297,7 +297,7 @@ acpi_ex_system_io_space_handler(u32 function,
297 ACPI_FUNCTION_TRACE(ex_system_io_space_handler); 297 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
298 298
299 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 299 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
300 "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", 300 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
301 bit_width, function, 301 bit_width, function,
302 ACPI_FORMAT_NATIVE_UINT(address))); 302 ACPI_FORMAT_NATIVE_UINT(address)));
303 303
@@ -373,7 +373,7 @@ acpi_ex_pci_config_space_handler(u32 function,
373 pci_register = (u16) (u32) address; 373 pci_register = (u16) (u32) address;
374 374
375 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 375 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
376 "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", 376 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
377 function, bit_width, pci_id->segment, pci_id->bus, 377 function, bit_width, pci_id->segment, pci_id->bus,
378 pci_id->device, pci_id->function, pci_register)); 378 pci_id->device, pci_id->function, pci_register));
379 379
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 3450309c2786..14750db2a1b8 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -57,7 +57,7 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
57 57
58/****************************************************************************** 58/******************************************************************************
59 * 59 *
60 * FUNCTION: acpi_hw_gpe_register_bit 60 * FUNCTION: acpi_hw_get_gpe_register_bit
61 * 61 *
62 * PARAMETERS: gpe_event_info - Info block for the GPE 62 * PARAMETERS: gpe_event_info - Info block for the GPE
63 * gpe_register_info - Info block for the GPE register 63 * gpe_register_info - Info block for the GPE register
@@ -69,7 +69,7 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
69 * 69 *
70 ******************************************************************************/ 70 ******************************************************************************/
71 71
72u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, 72u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
73 struct acpi_gpe_register_info *gpe_register_info) 73 struct acpi_gpe_register_info *gpe_register_info)
74{ 74{
75 return (u32)1 << (gpe_event_info->gpe_number - 75 return (u32)1 << (gpe_event_info->gpe_number -
@@ -115,7 +115,7 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action)
115 115
116 /* Set ot clear just the bit that corresponds to this GPE */ 116 /* Set ot clear just the bit that corresponds to this GPE */
117 117
118 register_bit = acpi_hw_gpe_register_bit(gpe_event_info, 118 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
119 gpe_register_info); 119 gpe_register_info);
120 switch (action) { 120 switch (action) {
121 case ACPI_GPE_COND_ENABLE: 121 case ACPI_GPE_COND_ENABLE:
@@ -143,31 +143,6 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action)
143 143
144/****************************************************************************** 144/******************************************************************************
145 * 145 *
146 * FUNCTION: acpi_hw_write_gpe_enable_reg
147 *
148 * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled
149 *
150 * RETURN: Status
151 *
152 * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must
153 * already be cleared or set in the parent register
154 * enable_for_run mask.
155 *
156 ******************************************************************************/
157
158acpi_status
159acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
160{
161 acpi_status status;
162
163 ACPI_FUNCTION_ENTRY();
164
165 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_COND_ENABLE);
166 return (status);
167}
168
169/******************************************************************************
170 *
171 * FUNCTION: acpi_hw_clear_gpe 146 * FUNCTION: acpi_hw_clear_gpe
172 * 147 *
173 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared 148 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
@@ -193,7 +168,7 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
193 return (AE_NOT_EXIST); 168 return (AE_NOT_EXIST);
194 } 169 }
195 170
196 register_bit = acpi_hw_gpe_register_bit(gpe_event_info, 171 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
197 gpe_register_info); 172 gpe_register_info);
198 173
199 /* 174 /*
@@ -241,7 +216,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
241 216
242 /* Get the register bitmask for this GPE */ 217 /* Get the register bitmask for this GPE */
243 218
244 register_bit = acpi_hw_gpe_register_bit(gpe_event_info, 219 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
245 gpe_register_info); 220 gpe_register_info);
246 221
247 /* GPE currently enabled? (enabled for runtime?) */ 222 /* GPE currently enabled? (enabled for runtime?) */
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 36eb803dd9d0..3796811276ac 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -307,7 +307,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
307 return_ACPI_STATUS(status); 307 return_ACPI_STATUS(status);
308 } 308 }
309 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 309 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
310 "Entering sleep state [S%d]\n", sleep_state)); 310 "Entering sleep state [S%u]\n", sleep_state));
311 311
312 /* Clear the SLP_EN and SLP_TYP fields */ 312 /* Clear the SLP_EN and SLP_TYP fields */
313 313
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 3a2814676ac3..0cd925be5fc1 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -338,8 +338,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
338 */ 338 */
339 while (!acpi_ns_opens_scope(prefix_node->type) && 339 while (!acpi_ns_opens_scope(prefix_node->type) &&
340 prefix_node->type != ACPI_TYPE_ANY) { 340 prefix_node->type != ACPI_TYPE_ANY) {
341 prefix_node = 341 prefix_node = prefix_node->parent;
342 acpi_ns_get_parent_node(prefix_node);
343 } 342 }
344 } 343 }
345 } 344 }
@@ -419,7 +418,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
419 /* Backup to the parent node */ 418 /* Backup to the parent node */
420 419
421 num_carats++; 420 num_carats++;
422 this_node = acpi_ns_get_parent_node(this_node); 421 this_node = this_node->parent;
423 if (!this_node) { 422 if (!this_node) {
424 423
425 /* Current scope has no parent scope */ 424 /* Current scope has no parent scope */
@@ -433,7 +432,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
433 432
434 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) { 433 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
435 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 434 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
436 "Search scope is [%4.4s], path has %d carat(s)\n", 435 "Search scope is [%4.4s], path has %u carat(s)\n",
437 acpi_ut_get_node_name 436 acpi_ut_get_node_name
438 (this_node), num_carats)); 437 (this_node), num_carats));
439 } 438 }
@@ -495,7 +494,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
495 path++; 494 path++;
496 495
497 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 496 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
498 "Multi Pathname (%d Segments, Flags=%X)\n", 497 "Multi Pathname (%u Segments, Flags=%X)\n",
499 num_segments, flags)); 498 num_segments, flags));
500 break; 499 break;
501 500
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 982269c1fa48..1e5ff803d9ad 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -159,7 +159,7 @@ void acpi_ns_remove_node(struct acpi_namespace_node *node)
159 159
160 ACPI_FUNCTION_TRACE_PTR(ns_remove_node, node); 160 ACPI_FUNCTION_TRACE_PTR(ns_remove_node, node);
161 161
162 parent_node = acpi_ns_get_parent_node(node); 162 parent_node = node->parent;
163 163
164 prev_node = NULL; 164 prev_node = NULL;
165 next_node = parent_node->child; 165 next_node = parent_node->child;
@@ -168,29 +168,20 @@ void acpi_ns_remove_node(struct acpi_namespace_node *node)
168 168
169 while (next_node != node) { 169 while (next_node != node) {
170 prev_node = next_node; 170 prev_node = next_node;
171 next_node = prev_node->peer; 171 next_node = next_node->peer;
172 } 172 }
173 173
174 if (prev_node) { 174 if (prev_node) {
175 175
176 /* Node is not first child, unlink it */ 176 /* Node is not first child, unlink it */
177 177
178 prev_node->peer = next_node->peer; 178 prev_node->peer = node->peer;
179 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
180 prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
181 }
182 } else { 179 } else {
183 /* Node is first child (has no previous peer) */ 180 /*
184 181 * Node is first child (has no previous peer).
185 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { 182 * Link peer list to parent
186 183 */
187 /* No peers at all */ 184 parent_node->child = node->peer;
188
189 parent_node->child = NULL;
190 } else { /* Link peer list to parent */
191
192 parent_node->child = next_node->peer;
193 }
194 } 185 }
195 186
196 /* Delete the node and any attached objects */ 187 /* Delete the node and any attached objects */
@@ -228,33 +219,42 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
228 219
229 ACPI_FUNCTION_TRACE(ns_install_node); 220 ACPI_FUNCTION_TRACE(ns_install_node);
230 221
231 /*
232 * Get the owner ID from the Walk state. The owner ID is used to track
233 * table deletion and deletion of objects created by methods.
234 */
235 if (walk_state) { 222 if (walk_state) {
223 /*
224 * Get the owner ID from the Walk state. The owner ID is used to
225 * track table deletion and deletion of objects created by methods.
226 */
236 owner_id = walk_state->owner_id; 227 owner_id = walk_state->owner_id;
228
229 if ((walk_state->method_desc) &&
230 (parent_node != walk_state->method_node)) {
231 /*
232 * A method is creating a new node that is not a child of the
233 * method (it is non-local). Mark the executing method as having
234 * modified the namespace. This is used for cleanup when the
235 * method exits.
236 */
237 walk_state->method_desc->method.flags |=
238 AOPOBJ_MODIFIED_NAMESPACE;
239 }
237 } 240 }
238 241
239 /* Link the new entry into the parent and existing children */ 242 /* Link the new entry into the parent and existing children */
240 243
244 node->peer = NULL;
245 node->parent = parent_node;
241 child_node = parent_node->child; 246 child_node = parent_node->child;
247
242 if (!child_node) { 248 if (!child_node) {
243 parent_node->child = node; 249 parent_node->child = node;
244 node->flags |= ANOBJ_END_OF_PEER_LIST;
245 node->peer = parent_node;
246 } else { 250 } else {
247 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { 251 /* Add node to the end of the peer list */
252
253 while (child_node->peer) {
248 child_node = child_node->peer; 254 child_node = child_node->peer;
249 } 255 }
250 256
251 child_node->peer = node; 257 child_node->peer = node;
252
253 /* Clear end-of-list flag */
254
255 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
256 node->flags |= ANOBJ_END_OF_PEER_LIST;
257 node->peer = parent_node;
258 } 258 }
259 259
260 /* Init the new entry */ 260 /* Init the new entry */
@@ -288,9 +288,8 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
288 288
289void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) 289void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
290{ 290{
291 struct acpi_namespace_node *child_node;
292 struct acpi_namespace_node *next_node; 291 struct acpi_namespace_node *next_node;
293 u8 flags; 292 struct acpi_namespace_node *node_to_delete;
294 293
295 ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node); 294 ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node);
296 295
@@ -298,37 +297,26 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
298 return_VOID; 297 return_VOID;
299 } 298 }
300 299
301 /* If no children, all done! */
302
303 child_node = parent_node->child;
304 if (!child_node) {
305 return_VOID;
306 }
307
308 /* Deallocate all children at this level */ 300 /* Deallocate all children at this level */
309 301
310 do { 302 next_node = parent_node->child;
311 303 while (next_node) {
312 /* Get the things we need */
313
314 next_node = child_node->peer;
315 flags = child_node->flags;
316 304
317 /* Grandchildren should have all been deleted already */ 305 /* Grandchildren should have all been deleted already */
318 306
319 if (child_node->child) { 307 if (next_node->child) {
320 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p", 308 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
321 parent_node, child_node)); 309 parent_node, next_node));
322 } 310 }
323 311
324 /* 312 /*
325 * Delete this child node and move on to the next child in the list. 313 * Delete this child node and move on to the next child in the list.
326 * No need to unlink the node since we are deleting the entire branch. 314 * No need to unlink the node since we are deleting the entire branch.
327 */ 315 */
328 acpi_ns_delete_node(child_node); 316 node_to_delete = next_node;
329 child_node = next_node; 317 next_node = next_node->peer;
330 318 acpi_ns_delete_node(node_to_delete);
331 } while (!(flags & ANOBJ_END_OF_PEER_LIST)); 319 };
332 320
333 /* Clear the parent's child pointer */ 321 /* Clear the parent's child pointer */
334 322
@@ -405,7 +393,7 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
405 393
406 /* Move up the tree to the grandparent */ 394 /* Move up the tree to the grandparent */
407 395
408 parent_node = acpi_ns_get_parent_node(parent_node); 396 parent_node = parent_node->parent;
409 } 397 }
410 } 398 }
411 399
@@ -510,7 +498,7 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
510 498
511 /* Move up the tree to the grandparent */ 499 /* Move up the tree to the grandparent */
512 500
513 parent_node = acpi_ns_get_parent_node(parent_node); 501 parent_node = parent_node->parent;
514 } 502 }
515 } 503 }
516 504
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 2110cc2360f0..a54dc39e304b 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -441,7 +441,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
441 return (AE_OK); 441 return (AE_OK);
442 } 442 }
443 443
444 acpi_os_printf("(R%d)", obj_desc->common.reference_count); 444 acpi_os_printf("(R%u)", obj_desc->common.reference_count);
445 445
446 switch (type) { 446 switch (type) {
447 case ACPI_TYPE_METHOD: 447 case ACPI_TYPE_METHOD:
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 4e5272c313e0..660a2728908d 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -103,8 +103,8 @@ acpi_status acpi_ns_initialize_objects(void)
103 } 103 }
104 104
105 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 105 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
106 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " 106 "\nInitialized %u/%u Regions %u/%u Fields %u/%u "
107 "Buffers %hd/%hd Packages (%hd nodes)\n", 107 "Buffers %u/%u Packages (%u nodes)\n",
108 info.op_region_init, info.op_region_count, 108 info.op_region_init, info.op_region_count,
109 info.field_init, info.field_count, 109 info.field_init, info.field_count,
110 info.buffer_init, info.buffer_count, 110 info.buffer_init, info.buffer_count,
@@ -112,9 +112,9 @@ acpi_status acpi_ns_initialize_objects(void)
112 info.object_count)); 112 info.object_count));
113 113
114 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 114 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
115 "%hd Control Methods found\n", info.method_count)); 115 "%u Control Methods found\n", info.method_count));
116 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 116 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
117 "%hd Op Regions found\n", info.op_region_count)); 117 "%u Op Regions found\n", info.op_region_count));
118 118
119 return_ACPI_STATUS(AE_OK); 119 return_ACPI_STATUS(AE_OK);
120} 120}
@@ -208,8 +208,8 @@ acpi_status acpi_ns_initialize_devices(void)
208 } 208 }
209 209
210 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 210 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
211 "\nExecuted %hd _INI methods requiring %hd _STA executions " 211 "\nExecuted %u _INI methods requiring %u _STA executions "
212 "(examined %hd objects)\n", 212 "(examined %u objects)\n",
213 info.num_INI, info.num_STA, info.device_count)); 213 info.num_INI, info.num_STA, info.device_count));
214 214
215 return_ACPI_STATUS(status); 215 return_ACPI_STATUS(status);
@@ -410,7 +410,7 @@ acpi_ns_find_ini_methods(acpi_handle obj_handle,
410 * The only _INI methods that we care about are those that are 410 * The only _INI methods that we care about are those that are
411 * present under Device, Processor, and Thermal objects. 411 * present under Device, Processor, and Thermal objects.
412 */ 412 */
413 parent_node = acpi_ns_get_parent_node(node); 413 parent_node = node->parent;
414 switch (parent_node->type) { 414 switch (parent_node->type) {
415 case ACPI_TYPE_DEVICE: 415 case ACPI_TYPE_DEVICE:
416 case ACPI_TYPE_PROCESSOR: 416 case ACPI_TYPE_PROCESSOR:
@@ -420,7 +420,7 @@ acpi_ns_find_ini_methods(acpi_handle obj_handle,
420 420
421 while (parent_node) { 421 while (parent_node) {
422 parent_node->flags |= ANOBJ_SUBTREE_HAS_INI; 422 parent_node->flags |= ANOBJ_SUBTREE_HAS_INI;
423 parent_node = acpi_ns_get_parent_node(parent_node); 423 parent_node = parent_node->parent;
424 } 424 }
425 break; 425 break;
426 426
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 7dea0031605c..d3104af57e13 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -93,7 +93,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
93 /* Put the name into the buffer */ 93 /* Put the name into the buffer */
94 94
95 ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name); 95 ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name);
96 parent_node = acpi_ns_get_parent_node(parent_node); 96 parent_node = parent_node->parent;
97 97
98 /* Prefix name with the path separator */ 98 /* Prefix name with the path separator */
99 99
@@ -198,7 +198,7 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
198 return 0; 198 return 0;
199 } 199 }
200 size += ACPI_PATH_SEGMENT_LENGTH; 200 size += ACPI_PATH_SEGMENT_LENGTH;
201 next_node = acpi_ns_get_parent_node(next_node); 201 next_node = next_node->parent;
202 } 202 }
203 203
204 if (!size) { 204 if (!size) {
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 27cda52c76bc..5808c89e9fac 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -136,8 +136,8 @@ acpi_ns_one_complete_parse(u32 pass_number,
136 136
137 /* Parse the AML */ 137 /* Parse the AML */
138 138
139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", 139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %u parse\n",
140 (unsigned)pass_number)); 140 pass_number));
141 status = acpi_ps_parse_aml(walk_state); 141 status = acpi_ps_parse_aml(walk_state);
142 142
143 cleanup: 143 cleanup:
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index d4be37751be4..d1c136692667 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -556,7 +556,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
556 556
557 /* Need an Integer - create a zero-value integer */ 557 /* Need an Integer - create a zero-value integer */
558 558
559 new_object = acpi_ut_create_integer_object(0); 559 new_object = acpi_ut_create_integer_object((u64)0);
560 } else if (expected_btypes & ACPI_RTYPE_STRING) { 560 } else if (expected_btypes & ACPI_RTYPE_STRING) {
561 561
562 /* Need a String - create a NULL string */ 562 /* Need a String - create a NULL string */
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 61bd0f6755d2..4009498fbabd 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -112,6 +112,13 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
112 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs 112 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
113 * _PSS: Sort the list descending by Power 113 * _PSS: Sort the list descending by Power
114 * _TSS: Sort the list descending by Power 114 * _TSS: Sort the list descending by Power
115 *
116 * Names that must be packages, but cannot be sorted:
117 *
118 * _BCL: Values are tied to the Package index where they appear, and cannot
119 * be moved or sorted. These index values are used for _BQC and _BCM.
120 * However, we can fix the case where a buffer is returned, by converting
121 * it to a Package of integers.
115 */ 122 */
116static const struct acpi_repair_info acpi_ns_repairable_names[] = { 123static const struct acpi_repair_info acpi_ns_repairable_names[] = {
117 {"_ALR", acpi_ns_repair_ALR}, 124 {"_ALR", acpi_ns_repair_ALR},
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index a8e42b5e9463..41102a84272f 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -152,17 +152,6 @@ acpi_ns_search_one_scope(u32 target_name,
152 return_ACPI_STATUS(AE_OK); 152 return_ACPI_STATUS(AE_OK);
153 } 153 }
154 154
155 /*
156 * The last entry in the list points back to the parent,
157 * so a flag is used to indicate the end-of-list
158 */
159 if (node->flags & ANOBJ_END_OF_PEER_LIST) {
160
161 /* Searched entire list, we are done */
162
163 break;
164 }
165
166 /* Didn't match name, move on to the next peer object */ 155 /* Didn't match name, move on to the next peer object */
167 156
168 node = node->peer; 157 node = node->peer;
@@ -217,7 +206,7 @@ acpi_ns_search_parent_tree(u32 target_name,
217 206
218 ACPI_FUNCTION_TRACE(ns_search_parent_tree); 207 ACPI_FUNCTION_TRACE(ns_search_parent_tree);
219 208
220 parent_node = acpi_ns_get_parent_node(node); 209 parent_node = node->parent;
221 210
222 /* 211 /*
223 * If there is no parent (i.e., we are at the root) or type is "local", 212 * If there is no parent (i.e., we are at the root) or type is "local",
@@ -261,7 +250,7 @@ acpi_ns_search_parent_tree(u32 target_name,
261 250
262 /* Not found here, go up another level (until we reach the root) */ 251 /* Not found here, go up another level (until we reach the root) */
263 252
264 parent_node = acpi_ns_get_parent_node(parent_node); 253 parent_node = parent_node->parent;
265 } 254 }
266 255
267 /* Not found in parent tree */ 256 /* Not found in parent tree */
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index bab559712da1..e1add3491b04 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -847,116 +847,3 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
847 ACPI_FREE(internal_path); 847 ACPI_FREE(internal_path);
848 return_ACPI_STATUS(status); 848 return_ACPI_STATUS(status);
849} 849}
850
851/*******************************************************************************
852 *
853 * FUNCTION: acpi_ns_get_parent_node
854 *
855 * PARAMETERS: Node - Current table entry
856 *
857 * RETURN: Parent entry of the given entry
858 *
859 * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
860 *
861 ******************************************************************************/
862
863struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
864 *node)
865{
866 ACPI_FUNCTION_ENTRY();
867
868 if (!node) {
869 return (NULL);
870 }
871
872 /*
873 * Walk to the end of this peer list. The last entry is marked with a flag
874 * and the peer pointer is really a pointer back to the parent. This saves
875 * putting a parent back pointer in each and every named object!
876 */
877 while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
878 node = node->peer;
879 }
880
881 return (node->peer);
882}
883
884/*******************************************************************************
885 *
886 * FUNCTION: acpi_ns_get_next_valid_node
887 *
888 * PARAMETERS: Node - Current table entry
889 *
890 * RETURN: Next valid Node in the linked node list. NULL if no more valid
891 * nodes.
892 *
893 * DESCRIPTION: Find the next valid node within a name table.
894 * Useful for implementing NULL-end-of-list loops.
895 *
896 ******************************************************************************/
897
898struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
899 acpi_namespace_node
900 *node)
901{
902
903 /* If we are at the end of this peer list, return NULL */
904
905 if (node->flags & ANOBJ_END_OF_PEER_LIST) {
906 return NULL;
907 }
908
909 /* Otherwise just return the next peer */
910
911 return (node->peer);
912}
913
914#ifdef ACPI_OBSOLETE_FUNCTIONS
915/*******************************************************************************
916 *
917 * FUNCTION: acpi_ns_find_parent_name
918 *
919 * PARAMETERS: *child_node - Named Obj whose name is to be found
920 *
921 * RETURN: The ACPI name
922 *
923 * DESCRIPTION: Search for the given obj in its parent scope and return the
924 * name segment, or "????" if the parent name can't be found
925 * (which "should not happen").
926 *
927 ******************************************************************************/
928
929acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node)
930{
931 struct acpi_namespace_node *parent_node;
932
933 ACPI_FUNCTION_TRACE(ns_find_parent_name);
934
935 if (child_node) {
936
937 /* Valid entry. Get the parent Node */
938
939 parent_node = acpi_ns_get_parent_node(child_node);
940 if (parent_node) {
941 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
942 "Parent of %p [%4.4s] is %p [%4.4s]\n",
943 child_node,
944 acpi_ut_get_node_name(child_node),
945 parent_node,
946 acpi_ut_get_node_name(parent_node)));
947
948 if (parent_node->name.integer) {
949 return_VALUE((acpi_name) parent_node->name.
950 integer);
951 }
952 }
953
954 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
955 "Unable to find parent of %p (%4.4s)\n",
956 child_node,
957 acpi_ut_get_node_name(child_node)));
958 }
959
960 return_VALUE(ACPI_UNKNOWN_NAME);
961}
962#endif
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 00e79fb26029..2cd5be8fe10f 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -79,15 +79,6 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
79 return parent_node->child; 79 return parent_node->child;
80 } 80 }
81 81
82 /*
83 * Get the next node.
84 *
85 * If we are at the end of this peer list, return NULL
86 */
87 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
88 return NULL;
89 }
90
91 /* Otherwise just return the next peer */ 82 /* Otherwise just return the next peer */
92 83
93 return child_node->peer; 84 return child_node->peer;
@@ -146,9 +137,9 @@ struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
146 return (next_node); 137 return (next_node);
147 } 138 }
148 139
149 /* Otherwise, move on to the next node */ 140 /* Otherwise, move on to the next peer node */
150 141
151 next_node = acpi_ns_get_next_valid_node(next_node); 142 next_node = next_node->peer;
152 } 143 }
153 144
154 /* Not found */ 145 /* Not found */
@@ -355,7 +346,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
355 */ 346 */
356 level--; 347 level--;
357 child_node = parent_node; 348 child_node = parent_node;
358 parent_node = acpi_ns_get_parent_node(parent_node); 349 parent_node = parent_node->parent;
359 350
360 node_previously_visited = TRUE; 351 node_previously_visited = TRUE;
361 } 352 }
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index eafef24ea448..a1f04e9b8030 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -190,7 +190,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
190 190
191 /* Get the parent entry */ 191 /* Get the parent entry */
192 192
193 parent_node = acpi_ns_get_parent_node(node); 193 parent_node = node->parent;
194 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node); 194 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
195 195
196 /* Return exception if parent is null */ 196 /* Return exception if parent is null */
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 66116750a0f9..0558747579ef 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -813,10 +813,10 @@ acpi_status acpi_ut_init_globals(void)
813 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 813 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
814 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED; 814 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
815 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 815 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
816 acpi_gbl_root_node_struct.parent = NULL;
816 acpi_gbl_root_node_struct.child = NULL; 817 acpi_gbl_root_node_struct.child = NULL;
817 acpi_gbl_root_node_struct.peer = NULL; 818 acpi_gbl_root_node_struct.peer = NULL;
818 acpi_gbl_root_node_struct.object = NULL; 819 acpi_gbl_root_node_struct.object = NULL;
819 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
820 820
821#ifdef ACPI_DEBUG_OUTPUT 821#ifdef ACPI_DEBUG_OUTPUT
822 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); 822 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index db9d8ca57987..7f8cefcb2b32 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -293,12 +293,8 @@ acpi_status acpi_initialize_objects(u32 flags)
293 * Complete the GPE initialization for the GPE blocks defined in the FADT 293 * Complete the GPE initialization for the GPE blocks defined in the FADT
294 * (GPE block 0 and 1). 294 * (GPE block 0 and 1).
295 * 295 *
296 * Note1: This is where the _PRW methods are executed for the GPEs. These 296 * NOTE: Currently, there seems to be no need to run the _REG methods
297 * methods can only be executed after the SCI and Global Lock handlers are 297 * before enabling the GPEs.
298 * installed and initialized.
299 *
300 * Note2: Currently, there seems to be no need to run the _REG methods
301 * before execution of the _PRW methods and enabling of the GPEs.
302 */ 298 */
303 if (!(flags & ACPI_NO_EVENT_INIT)) { 299 if (!(flags & ACPI_NO_EVENT_INIT)) {
304 status = acpi_ev_install_fadt_gpes(); 300 status = acpi_ev_install_fadt_gpes();
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 7d857dabdde4..1575a9b51f1d 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -424,8 +424,7 @@ static int acpi_button_add(struct acpi_device *device)
424 if (device->wakeup.flags.valid) { 424 if (device->wakeup.flags.valid) {
425 /* Button's GPE is run-wake GPE */ 425 /* Button's GPE is run-wake GPE */
426 acpi_enable_gpe(device->wakeup.gpe_device, 426 acpi_enable_gpe(device->wakeup.gpe_device,
427 device->wakeup.gpe_number, 427 device->wakeup.gpe_number);
428 ACPI_GPE_TYPE_RUNTIME);
429 device->wakeup.run_wake_count++; 428 device->wakeup.run_wake_count++;
430 device->wakeup.state.enabled = 1; 429 device->wakeup.state.enabled = 1;
431 } 430 }
@@ -448,8 +447,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
448 447
449 if (device->wakeup.flags.valid) { 448 if (device->wakeup.flags.valid) {
450 acpi_disable_gpe(device->wakeup.gpe_device, 449 acpi_disable_gpe(device->wakeup.gpe_device,
451 device->wakeup.gpe_number, 450 device->wakeup.gpe_number);
452 ACPI_GPE_TYPE_RUNTIME);
453 device->wakeup.run_wake_count--; 451 device->wakeup.run_wake_count--;
454 device->wakeup.state.enabled = 0; 452 device->wakeup.state.enabled = 0;
455 } 453 }
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 1fa0aafebe2a..f31291ba94d0 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -303,11 +303,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
303 pr_debug(PREFIX "transaction start\n"); 303 pr_debug(PREFIX "transaction start\n");
304 /* disable GPE during transaction if storm is detected */ 304 /* disable GPE during transaction if storm is detected */
305 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 305 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
306 /* 306 /* It has to be disabled, so that it doesn't trigger. */
307 * It has to be disabled at the hardware level regardless of the 307 acpi_disable_gpe(NULL, ec->gpe);
308 * GPE reference counting, so that it doesn't trigger.
309 */
310 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
311 } 308 }
312 309
313 status = acpi_ec_transaction_unlocked(ec, t); 310 status = acpi_ec_transaction_unlocked(ec, t);
@@ -316,12 +313,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
316 ec_check_sci_sync(ec, acpi_ec_read_status(ec)); 313 ec_check_sci_sync(ec, acpi_ec_read_status(ec));
317 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 314 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
318 msleep(1); 315 msleep(1);
319 /* 316 /* It is safe to enable the GPE outside of the transaction. */
320 * It is safe to enable the GPE outside of the transaction. Use 317 acpi_enable_gpe(NULL, ec->gpe);
321 * acpi_set_gpe() for that, since we used it to disable the GPE
322 * above.
323 */
324 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
325 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) { 318 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
326 pr_info(PREFIX "GPE storm detected, " 319 pr_info(PREFIX "GPE storm detected, "
327 "transactions will use polling mode\n"); 320 "transactions will use polling mode\n");
@@ -746,7 +739,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
746 if (ACPI_FAILURE(status)) 739 if (ACPI_FAILURE(status))
747 return -ENODEV; 740 return -ENODEV;
748 741
749 acpi_enable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 742 acpi_enable_gpe(NULL, ec->gpe);
750 status = acpi_install_address_space_handler(ec->handle, 743 status = acpi_install_address_space_handler(ec->handle,
751 ACPI_ADR_SPACE_EC, 744 ACPI_ADR_SPACE_EC,
752 &acpi_ec_space_handler, 745 &acpi_ec_space_handler,
@@ -763,7 +756,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
763 } else { 756 } else {
764 acpi_remove_gpe_handler(NULL, ec->gpe, 757 acpi_remove_gpe_handler(NULL, ec->gpe,
765 &acpi_ec_gpe_handler); 758 &acpi_ec_gpe_handler);
766 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 759 acpi_disable_gpe(NULL, ec->gpe);
767 return -ENODEV; 760 return -ENODEV;
768 } 761 }
769 } 762 }
@@ -774,7 +767,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
774 767
775static void ec_remove_handlers(struct acpi_ec *ec) 768static void ec_remove_handlers(struct acpi_ec *ec)
776{ 769{
777 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 770 acpi_disable_gpe(NULL, ec->gpe);
778 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 771 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
779 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 772 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
780 pr_err(PREFIX "failed to remove space handler\n"); 773 pr_err(PREFIX "failed to remove space handler\n");
@@ -1018,22 +1011,6 @@ error:
1018 return -ENODEV; 1011 return -ENODEV;
1019} 1012}
1020 1013
1021static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1022{
1023 struct acpi_ec *ec = acpi_driver_data(device);
1024 /* Stop using the GPE, but keep it reference counted. */
1025 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
1026 return 0;
1027}
1028
1029static int acpi_ec_resume(struct acpi_device *device)
1030{
1031 struct acpi_ec *ec = acpi_driver_data(device);
1032 /* Enable the GPE again, but don't reference count it once more. */
1033 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
1034 return 0;
1035}
1036
1037static struct acpi_driver acpi_ec_driver = { 1014static struct acpi_driver acpi_ec_driver = {
1038 .name = "ec", 1015 .name = "ec",
1039 .class = ACPI_EC_CLASS, 1016 .class = ACPI_EC_CLASS,
@@ -1041,8 +1018,6 @@ static struct acpi_driver acpi_ec_driver = {
1041 .ops = { 1018 .ops = {
1042 .add = acpi_ec_add, 1019 .add = acpi_ec_add,
1043 .remove = acpi_ec_remove, 1020 .remove = acpi_ec_remove,
1044 .suspend = acpi_ec_suspend,
1045 .resume = acpi_ec_resume,
1046 }, 1021 },
1047}; 1022};
1048 1023
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 46cce391fa46..f14d3f251d26 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1046,26 +1046,6 @@ static int __init acpi_serialize_setup(char *str)
1046 1046
1047__setup("acpi_serialize", acpi_serialize_setup); 1047__setup("acpi_serialize", acpi_serialize_setup);
1048 1048
1049/*
1050 * Wake and Run-Time GPES are expected to be separate.
1051 * We disable wake-GPEs at run-time to prevent spurious
1052 * interrupts.
1053 *
1054 * However, if a system exists that shares Wake and
1055 * Run-time events on the same GPE this flag is available
1056 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1057 */
1058static int __init acpi_wake_gpes_always_on_setup(char *str)
1059{
1060 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1061
1062 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1063
1064 return 1;
1065}
1066
1067__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1068
1069/* Check of resource interference between native drivers and ACPI 1049/* Check of resource interference between native drivers and ACPI
1070 * OperationRegions (SystemIO and System Memory only). 1050 * OperationRegions (SystemIO and System Memory only).
1071 * IO ports and memory declared in ACPI might be used by the ACPI subsystem 1051 * IO ports and memory declared in ACPI might be used by the ACPI subsystem
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 7f2e051ed4f1..b23825ecfa37 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -740,6 +740,8 @@ acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device,
740 device->wakeup.resources.handles[i] = element->reference.handle; 740 device->wakeup.resources.handles[i] = element->reference.handle;
741 } 741 }
742 742
743 acpi_gpe_can_wake(device->wakeup.gpe_device, device->wakeup.gpe_number);
744
743 return AE_OK; 745 return AE_OK;
744} 746}
745 747
@@ -764,8 +766,9 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
764 return; 766 return;
765 } 767 }
766 768
767 status = acpi_get_gpe_status(NULL, device->wakeup.gpe_number, 769 status = acpi_get_gpe_status(device->wakeup.gpe_device,
768 &event_status); 770 device->wakeup.gpe_number,
771 &event_status);
769 if (status == AE_OK) 772 if (status == AE_OK)
770 device->wakeup.flags.run_wake = 773 device->wakeup.flags.run_wake =
771 !!(event_status & ACPI_EVENT_FLAG_HANDLE); 774 !!(event_status & ACPI_EVENT_FLAG_HANDLE);
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2862c781b372..e143203254a4 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -663,18 +663,9 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
663 return -ENODEV; 663 return -ENODEV;
664 } 664 }
665 665
666 if (enable) { 666 error = enable ?
667 error = acpi_enable_wakeup_device_power(adev, 667 acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) :
668 acpi_target_sleep_state); 668 acpi_disable_wakeup_device_power(adev);
669 if (!error)
670 acpi_enable_gpe(adev->wakeup.gpe_device,
671 adev->wakeup.gpe_number,
672 ACPI_GPE_TYPE_WAKE);
673 } else {
674 acpi_disable_gpe(adev->wakeup.gpe_device, adev->wakeup.gpe_number,
675 ACPI_GPE_TYPE_WAKE);
676 error = acpi_disable_wakeup_device_power(adev);
677 }
678 if (!error) 669 if (!error)
679 dev_info(dev, "wake-up capability %s by ACPI\n", 670 dev_info(dev, "wake-up capability %s by ACPI\n",
680 enable ? "enabled" : "disabled"); 671 enable ? "enabled" : "disabled");
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index f8db50a0941c..5981bd07e20e 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -388,12 +388,10 @@ static ssize_t counter_set(struct kobject *kobj,
388 if (index < num_gpes) { 388 if (index < num_gpes) {
389 if (!strcmp(buf, "disable\n") && 389 if (!strcmp(buf, "disable\n") &&
390 (status & ACPI_EVENT_FLAG_ENABLED)) 390 (status & ACPI_EVENT_FLAG_ENABLED))
391 result = acpi_disable_gpe(handle, index, 391 result = acpi_disable_gpe(handle, index);
392 ACPI_GPE_TYPE_RUNTIME);
393 else if (!strcmp(buf, "enable\n") && 392 else if (!strcmp(buf, "enable\n") &&
394 !(status & ACPI_EVENT_FLAG_ENABLED)) 393 !(status & ACPI_EVENT_FLAG_ENABLED))
395 result = acpi_enable_gpe(handle, index, 394 result = acpi_enable_gpe(handle, index);
396 ACPI_GPE_TYPE_RUNTIME);
397 else if (!strcmp(buf, "clear\n") && 395 else if (!strcmp(buf, "clear\n") &&
398 (status & ACPI_EVENT_FLAG_SET)) 396 (status & ACPI_EVENT_FLAG_SET))
399 result = acpi_clear_gpe(handle, index); 397 result = acpi_clear_gpe(handle, index);
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 388747a7ef4f..c80537bc3234 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -64,13 +64,14 @@ void acpi_enable_wakeup_device(u8 sleep_state)
64 struct acpi_device *dev = 64 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 65 container_of(node, struct acpi_device, wakeup_list);
66 66
67 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled 67 if (!dev->wakeup.flags.valid
68 || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
68 || sleep_state > (u32) dev->wakeup.sleep_state) 69 || sleep_state > (u32) dev->wakeup.sleep_state)
69 continue; 70 continue;
70 71
71 /* The wake-up power should have been enabled already. */ 72 /* The wake-up power should have been enabled already. */
72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 73 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
73 ACPI_GPE_TYPE_WAKE); 74 ACPI_GPE_ENABLE);
74 } 75 }
75} 76}
76 77
@@ -89,13 +90,16 @@ void acpi_disable_wakeup_device(u8 sleep_state)
89 struct acpi_device *dev = 90 struct acpi_device *dev =
90 container_of(node, struct acpi_device, wakeup_list); 91 container_of(node, struct acpi_device, wakeup_list);
91 92
92 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled 93 if (!dev->wakeup.flags.valid
94 || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
93 || (sleep_state > (u32) dev->wakeup.sleep_state)) 95 || (sleep_state > (u32) dev->wakeup.sleep_state))
94 continue; 96 continue;
95 97
96 acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 98 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
97 ACPI_GPE_TYPE_WAKE); 99 ACPI_GPE_DISABLE);
98 acpi_disable_wakeup_device_power(dev); 100
101 if (dev->wakeup.state.enabled)
102 acpi_disable_wakeup_device_power(dev);
99 } 103 }
100} 104}
101 105