aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/events/evgpe.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/events/evgpe.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/events/evgpe.c')
-rw-r--r--drivers/acpi/events/evgpe.c428
1 files changed, 196 insertions, 232 deletions
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index ede834df4f69..b2f232df13d8 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -46,14 +46,10 @@
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpe") 49ACPI_MODULE_NAME("evgpe")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52 52static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
53static void ACPI_SYSTEM_XFACE
54acpi_ev_asynch_execute_gpe_method (
55 void *context);
56
57 53
58/******************************************************************************* 54/*******************************************************************************
59 * 55 *
@@ -69,15 +65,11 @@ acpi_ev_asynch_execute_gpe_method (
69 ******************************************************************************/ 65 ******************************************************************************/
70 66
71acpi_status 67acpi_status
72acpi_ev_set_gpe_type ( 68acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
73 struct acpi_gpe_event_info *gpe_event_info,
74 u8 type)
75{ 69{
76 acpi_status status; 70 acpi_status status;
77
78
79 ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
80 71
72 ACPI_FUNCTION_TRACE("ev_set_gpe_type");
81 73
82 /* Validate type and update register enable masks */ 74 /* Validate type and update register enable masks */
83 75
@@ -88,21 +80,20 @@ acpi_ev_set_gpe_type (
88 break; 80 break;
89 81
90 default: 82 default:
91 return_ACPI_STATUS (AE_BAD_PARAMETER); 83 return_ACPI_STATUS(AE_BAD_PARAMETER);
92 } 84 }
93 85
94 /* Disable the GPE if currently enabled */ 86 /* Disable the GPE if currently enabled */
95 87
96 status = acpi_ev_disable_gpe (gpe_event_info); 88 status = acpi_ev_disable_gpe(gpe_event_info);
97 89
98 /* Type was validated above */ 90 /* Type was validated above */
99 91
100 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ 92 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
101 gpe_event_info->flags |= type; /* Insert type */ 93 gpe_event_info->flags |= type; /* Insert type */
102 return_ACPI_STATUS (status); 94 return_ACPI_STATUS(status);
103} 95}
104 96
105
106/******************************************************************************* 97/*******************************************************************************
107 * 98 *
108 * FUNCTION: acpi_ev_update_gpe_enable_masks 99 * FUNCTION: acpi_ev_update_gpe_enable_masks
@@ -118,57 +109,55 @@ acpi_ev_set_gpe_type (
118 ******************************************************************************/ 109 ******************************************************************************/
119 110
120acpi_status 111acpi_status
121acpi_ev_update_gpe_enable_masks ( 112acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
122 struct acpi_gpe_event_info *gpe_event_info, 113 u8 type)
123 u8 type)
124{ 114{
125 struct acpi_gpe_register_info *gpe_register_info; 115 struct acpi_gpe_register_info *gpe_register_info;
126 u8 register_bit; 116 u8 register_bit;
127
128
129 ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
130 117
118 ACPI_FUNCTION_TRACE("ev_update_gpe_enable_masks");
131 119
132 gpe_register_info = gpe_event_info->register_info; 120 gpe_register_info = gpe_event_info->register_info;
133 if (!gpe_register_info) { 121 if (!gpe_register_info) {
134 return_ACPI_STATUS (AE_NOT_EXIST); 122 return_ACPI_STATUS(AE_NOT_EXIST);
135 } 123 }
136 register_bit = gpe_event_info->register_bit; 124 register_bit = gpe_event_info->register_bit;
137 125
138 /* 1) Disable case. Simply clear all enable bits */ 126 /* 1) Disable case. Simply clear all enable bits */
139 127
140 if (type == ACPI_GPE_DISABLE) { 128 if (type == ACPI_GPE_DISABLE) {
141 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 129 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
142 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 130 register_bit);
143 return_ACPI_STATUS (AE_OK); 131 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
132 return_ACPI_STATUS(AE_OK);
144 } 133 }
145 134
146 /* 2) Enable case. Set/Clear the appropriate enable bits */ 135 /* 2) Enable case. Set/Clear the appropriate enable bits */
147 136
148 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 137 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
149 case ACPI_GPE_TYPE_WAKE: 138 case ACPI_GPE_TYPE_WAKE:
150 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 139 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
151 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 140 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
152 break; 141 break;
153 142
154 case ACPI_GPE_TYPE_RUNTIME: 143 case ACPI_GPE_TYPE_RUNTIME:
155 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 144 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
156 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 145 register_bit);
146 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
157 break; 147 break;
158 148
159 case ACPI_GPE_TYPE_WAKE_RUN: 149 case ACPI_GPE_TYPE_WAKE_RUN:
160 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 150 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
161 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 151 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
162 break; 152 break;
163 153
164 default: 154 default:
165 return_ACPI_STATUS (AE_BAD_PARAMETER); 155 return_ACPI_STATUS(AE_BAD_PARAMETER);
166 } 156 }
167 157
168 return_ACPI_STATUS (AE_OK); 158 return_ACPI_STATUS(AE_OK);
169} 159}
170 160
171
172/******************************************************************************* 161/*******************************************************************************
173 * 162 *
174 * FUNCTION: acpi_ev_enable_gpe 163 * FUNCTION: acpi_ev_enable_gpe
@@ -184,21 +173,19 @@ acpi_ev_update_gpe_enable_masks (
184 ******************************************************************************/ 173 ******************************************************************************/
185 174
186acpi_status 175acpi_status
187acpi_ev_enable_gpe ( 176acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
188 struct acpi_gpe_event_info *gpe_event_info, 177 u8 write_to_hardware)
189 u8 write_to_hardware)
190{ 178{
191 acpi_status status; 179 acpi_status status;
192
193
194 ACPI_FUNCTION_TRACE ("ev_enable_gpe");
195 180
181 ACPI_FUNCTION_TRACE("ev_enable_gpe");
196 182
197 /* Make sure HW enable masks are updated */ 183 /* Make sure HW enable masks are updated */
198 184
199 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE); 185 status =
200 if (ACPI_FAILURE (status)) { 186 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE);
201 return_ACPI_STATUS (status); 187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
202 } 189 }
203 190
204 /* Mark wake-enabled or HW enable, or both */ 191 /* Mark wake-enabled or HW enable, or both */
@@ -206,41 +193,40 @@ acpi_ev_enable_gpe (
206 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 193 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
207 case ACPI_GPE_TYPE_WAKE: 194 case ACPI_GPE_TYPE_WAKE:
208 195
209 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 196 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
210 break; 197 break;
211 198
212 case ACPI_GPE_TYPE_WAKE_RUN: 199 case ACPI_GPE_TYPE_WAKE_RUN:
213 200
214 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 201 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
215 202
216 /*lint -fallthrough */ 203 /*lint -fallthrough */
217 204
218 case ACPI_GPE_TYPE_RUNTIME: 205 case ACPI_GPE_TYPE_RUNTIME:
219 206
220 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 207 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
221 208
222 if (write_to_hardware) { 209 if (write_to_hardware) {
223 /* Clear the GPE (of stale events), then enable it */ 210 /* Clear the GPE (of stale events), then enable it */
224 211
225 status = acpi_hw_clear_gpe (gpe_event_info); 212 status = acpi_hw_clear_gpe(gpe_event_info);
226 if (ACPI_FAILURE (status)) { 213 if (ACPI_FAILURE(status)) {
227 return_ACPI_STATUS (status); 214 return_ACPI_STATUS(status);
228 } 215 }
229 216
230 /* Enable the requested runtime GPE */ 217 /* Enable the requested runtime GPE */
231 218
232 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 219 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
233 } 220 }
234 break; 221 break;
235 222
236 default: 223 default:
237 return_ACPI_STATUS (AE_BAD_PARAMETER); 224 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 } 225 }
239 226
240 return_ACPI_STATUS (AE_OK); 227 return_ACPI_STATUS(AE_OK);
241} 228}
242 229
243
244/******************************************************************************* 230/*******************************************************************************
245 * 231 *
246 * FUNCTION: acpi_ev_disable_gpe 232 * FUNCTION: acpi_ev_disable_gpe
@@ -253,36 +239,33 @@ acpi_ev_enable_gpe (
253 * 239 *
254 ******************************************************************************/ 240 ******************************************************************************/
255 241
256acpi_status 242acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
257acpi_ev_disable_gpe (
258 struct acpi_gpe_event_info *gpe_event_info)
259{ 243{
260 acpi_status status; 244 acpi_status status;
261
262
263 ACPI_FUNCTION_TRACE ("ev_disable_gpe");
264 245
246 ACPI_FUNCTION_TRACE("ev_disable_gpe");
265 247
266 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) { 248 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
267 return_ACPI_STATUS (AE_OK); 249 return_ACPI_STATUS(AE_OK);
268 } 250 }
269 251
270 /* Make sure HW enable masks are updated */ 252 /* Make sure HW enable masks are updated */
271 253
272 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); 254 status =
273 if (ACPI_FAILURE (status)) { 255 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE);
274 return_ACPI_STATUS (status); 256 if (ACPI_FAILURE(status)) {
257 return_ACPI_STATUS(status);
275 } 258 }
276 259
277 /* Mark wake-disabled or HW disable, or both */ 260 /* Mark wake-disabled or HW disable, or both */
278 261
279 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 262 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
280 case ACPI_GPE_TYPE_WAKE: 263 case ACPI_GPE_TYPE_WAKE:
281 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 264 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
282 break; 265 break;
283 266
284 case ACPI_GPE_TYPE_WAKE_RUN: 267 case ACPI_GPE_TYPE_WAKE_RUN:
285 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 268 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
286 269
287 /*lint -fallthrough */ 270 /*lint -fallthrough */
288 271
@@ -290,18 +273,17 @@ acpi_ev_disable_gpe (
290 273
291 /* Disable the requested runtime GPE */ 274 /* Disable the requested runtime GPE */
292 275
293 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 276 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
294 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 277 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
295 break; 278 break;
296 279
297 default: 280 default:
298 return_ACPI_STATUS (AE_BAD_PARAMETER); 281 return_ACPI_STATUS(AE_BAD_PARAMETER);
299 } 282 }
300 283
301 return_ACPI_STATUS (AE_OK); 284 return_ACPI_STATUS(AE_OK);
302} 285}
303 286
304
305/******************************************************************************* 287/*******************************************************************************
306 * 288 *
307 * FUNCTION: acpi_ev_get_gpe_event_info 289 * FUNCTION: acpi_ev_get_gpe_event_info
@@ -319,18 +301,14 @@ acpi_ev_disable_gpe (
319 * 301 *
320 ******************************************************************************/ 302 ******************************************************************************/
321 303
322struct acpi_gpe_event_info * 304struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
323acpi_ev_get_gpe_event_info ( 305 u32 gpe_number)
324 acpi_handle gpe_device,
325 u32 gpe_number)
326{ 306{
327 union acpi_operand_object *obj_desc; 307 union acpi_operand_object *obj_desc;
328 struct acpi_gpe_block_info *gpe_block; 308 struct acpi_gpe_block_info *gpe_block;
329 acpi_native_uint i; 309 acpi_native_uint i;
330
331
332 ACPI_FUNCTION_ENTRY ();
333 310
311 ACPI_FUNCTION_ENTRY();
334 312
335 /* A NULL gpe_block means use the FADT-defined GPE block(s) */ 313 /* A NULL gpe_block means use the FADT-defined GPE block(s) */
336 314
@@ -340,11 +318,14 @@ acpi_ev_get_gpe_event_info (
340 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { 318 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
341 gpe_block = acpi_gbl_gpe_fadt_blocks[i]; 319 gpe_block = acpi_gbl_gpe_fadt_blocks[i];
342 if (gpe_block) { 320 if (gpe_block) {
343 if ((gpe_number >= gpe_block->block_base_number) && 321 if ((gpe_number >= gpe_block->block_base_number)
344 (gpe_number < gpe_block->block_base_number + 322 && (gpe_number <
345 (gpe_block->register_count * 8))) { 323 gpe_block->block_base_number +
346 return (&gpe_block->event_info[gpe_number - 324 (gpe_block->register_count * 8))) {
347 gpe_block->block_base_number]); 325 return (&gpe_block->
326 event_info[gpe_number -
327 gpe_block->
328 block_base_number]);
348 } 329 }
349 } 330 }
350 } 331 }
@@ -356,23 +337,25 @@ acpi_ev_get_gpe_event_info (
356 337
357 /* A Non-NULL gpe_device means this is a GPE Block Device */ 338 /* A Non-NULL gpe_device means this is a GPE Block Device */
358 339
359 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device); 340 obj_desc =
360 if (!obj_desc || 341 acpi_ns_get_attached_object((struct acpi_namespace_node *)
361 !obj_desc->device.gpe_block) { 342 gpe_device);
343 if (!obj_desc || !obj_desc->device.gpe_block) {
362 return (NULL); 344 return (NULL);
363 } 345 }
364 346
365 gpe_block = obj_desc->device.gpe_block; 347 gpe_block = obj_desc->device.gpe_block;
366 348
367 if ((gpe_number >= gpe_block->block_base_number) && 349 if ((gpe_number >= gpe_block->block_base_number) &&
368 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 350 (gpe_number <
369 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]); 351 gpe_block->block_base_number + (gpe_block->register_count * 8))) {
352 return (&gpe_block->
353 event_info[gpe_number - gpe_block->block_base_number]);
370 } 354 }
371 355
372 return (NULL); 356 return (NULL);
373} 357}
374 358
375
376/******************************************************************************* 359/*******************************************************************************
377 * 360 *
378 * FUNCTION: acpi_ev_gpe_detect 361 * FUNCTION: acpi_ev_gpe_detect
@@ -387,23 +370,20 @@ acpi_ev_get_gpe_event_info (
387 * 370 *
388 ******************************************************************************/ 371 ******************************************************************************/
389 372
390u32 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
391acpi_ev_gpe_detect (
392 struct acpi_gpe_xrupt_info *gpe_xrupt_list)
393{ 374{
394 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
395 u8 enabled_status_byte; 376 u8 enabled_status_byte;
396 struct acpi_gpe_register_info *gpe_register_info; 377 struct acpi_gpe_register_info *gpe_register_info;
397 u32 status_reg; 378 u32 status_reg;
398 u32 enable_reg; 379 u32 enable_reg;
399 u32 flags; 380 u32 flags;
400 acpi_status status; 381 acpi_status status;
401 struct acpi_gpe_block_info *gpe_block; 382 struct acpi_gpe_block_info *gpe_block;
402 acpi_native_uint i; 383 acpi_native_uint i;
403 acpi_native_uint j; 384 acpi_native_uint j;
404 385
405 386 ACPI_FUNCTION_NAME("ev_gpe_detect");
406 ACPI_FUNCTION_NAME ("ev_gpe_detect");
407 387
408 /* Check for the case where there are no GPEs */ 388 /* Check for the case where there are no GPEs */
409 389
@@ -413,7 +393,7 @@ acpi_ev_gpe_detect (
413 393
414 /* Examine all GPE blocks attached to this interrupt level */ 394 /* Examine all GPE blocks attached to this interrupt level */
415 395
416 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 396 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
417 gpe_block = gpe_xrupt_list->gpe_block_list_head; 397 gpe_block = gpe_xrupt_list->gpe_block_list_head;
418 while (gpe_block) { 398 while (gpe_block) {
419 /* 399 /*
@@ -428,23 +408,30 @@ acpi_ev_gpe_detect (
428 408
429 /* Read the Status Register */ 409 /* Read the Status Register */
430 410
431 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg, 411 status =
432 &gpe_register_info->status_address); 412 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
433 if (ACPI_FAILURE (status)) { 413 &status_reg,
414 &gpe_register_info->
415 status_address);
416 if (ACPI_FAILURE(status)) {
434 goto unlock_and_exit; 417 goto unlock_and_exit;
435 } 418 }
436 419
437 /* Read the Enable Register */ 420 /* Read the Enable Register */
438 421
439 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg, 422 status =
440 &gpe_register_info->enable_address); 423 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
441 if (ACPI_FAILURE (status)) { 424 &enable_reg,
425 &gpe_register_info->
426 enable_address);
427 if (ACPI_FAILURE(status)) {
442 goto unlock_and_exit; 428 goto unlock_and_exit;
443 } 429 }
444 430
445 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 431 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
446 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", 432 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
447 gpe_register_info->base_gpe_number, status_reg, enable_reg)); 433 gpe_register_info->base_gpe_number,
434 status_reg, enable_reg));
448 435
449 /* Check if there is anything active at all in this register */ 436 /* Check if there is anything active at all in this register */
450 437
@@ -460,14 +447,21 @@ acpi_ev_gpe_detect (
460 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 447 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
461 /* Examine one GPE bit */ 448 /* Examine one GPE bit */
462 449
463 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) { 450 if (enabled_status_byte &
451 acpi_gbl_decode_to8bit[j]) {
464 /* 452 /*
465 * Found an active GPE. Dispatch the event to a handler 453 * Found an active GPE. Dispatch the event to a handler
466 * or method. 454 * or method.
467 */ 455 */
468 int_status |= acpi_ev_gpe_dispatch ( 456 int_status |=
469 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], 457 acpi_ev_gpe_dispatch(&gpe_block->
470 (u32) j + gpe_register_info->base_gpe_number); 458 event_info[(i *
459 ACPI_GPE_REGISTER_WIDTH)
460 +
461 j],
462 (u32) j +
463 gpe_register_info->
464 base_gpe_number);
471 } 465 }
472 } 466 }
473 } 467 }
@@ -475,13 +469,12 @@ acpi_ev_gpe_detect (
475 gpe_block = gpe_block->next; 469 gpe_block = gpe_block->next;
476 } 470 }
477 471
478unlock_and_exit: 472 unlock_and_exit:
479 473
480 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 474 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
481 return (int_status); 475 return (int_status);
482} 476}
483 477
484
485/******************************************************************************* 478/*******************************************************************************
486 * 479 *
487 * FUNCTION: acpi_ev_asynch_execute_gpe_method 480 * FUNCTION: acpi_ev_asynch_execute_gpe_method
@@ -498,45 +491,41 @@ unlock_and_exit:
498 * 491 *
499 ******************************************************************************/ 492 ******************************************************************************/
500 493
501static void ACPI_SYSTEM_XFACE 494static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
502acpi_ev_asynch_execute_gpe_method (
503 void *context)
504{ 495{
505 struct acpi_gpe_event_info *gpe_event_info = (void *) context; 496 struct acpi_gpe_event_info *gpe_event_info = (void *)context;
506 u32 gpe_number = 0; 497 u32 gpe_number = 0;
507 acpi_status status; 498 acpi_status status;
508 struct acpi_gpe_event_info local_gpe_event_info; 499 struct acpi_gpe_event_info local_gpe_event_info;
509 struct acpi_parameter_info info; 500 struct acpi_parameter_info info;
510
511 501
512 ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method"); 502 ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method");
513 503
514 504 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
515 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 505 if (ACPI_FAILURE(status)) {
516 if (ACPI_FAILURE (status)) {
517 return_VOID; 506 return_VOID;
518 } 507 }
519 508
520 /* Must revalidate the gpe_number/gpe_block */ 509 /* Must revalidate the gpe_number/gpe_block */
521 510
522 if (!acpi_ev_valid_gpe_event (gpe_event_info)) { 511 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
523 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 512 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
524 return_VOID; 513 return_VOID;
525 } 514 }
526 515
527 /* Set the GPE flags for return to enabled state */ 516 /* Set the GPE flags for return to enabled state */
528 517
529 (void) acpi_ev_enable_gpe (gpe_event_info, FALSE); 518 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
530 519
531 /* 520 /*
532 * Take a snapshot of the GPE info for this level - we copy the 521 * Take a snapshot of the GPE info for this level - we copy the
533 * info to prevent a race condition with remove_handler/remove_block. 522 * info to prevent a race condition with remove_handler/remove_block.
534 */ 523 */
535 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, 524 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
536 sizeof (struct acpi_gpe_event_info)); 525 sizeof(struct acpi_gpe_event_info));
537 526
538 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 527 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
539 if (ACPI_FAILURE (status)) { 528 if (ACPI_FAILURE(status)) {
540 return_VOID; 529 return_VOID;
541 } 530 }
542 531
@@ -545,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method (
545 * time to avoid race with ev_gpe_install_handler 534 * time to avoid race with ev_gpe_install_handler
546 */ 535 */
547 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 536 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
548 ACPI_GPE_DISPATCH_METHOD) { 537 ACPI_GPE_DISPATCH_METHOD) {
549 /* 538 /*
550 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx 539 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
551 * control method that corresponds to this GPE 540 * control method that corresponds to this GPE
552 */ 541 */
553 info.node = local_gpe_event_info.dispatch.method_node; 542 info.node = local_gpe_event_info.dispatch.method_node;
554 info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info); 543 info.parameters =
544 ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info);
555 info.parameter_type = ACPI_PARAM_GPE; 545 info.parameter_type = ACPI_PARAM_GPE;
556 546
557 status = acpi_ns_evaluate_by_handle (&info); 547 status = acpi_ns_evaluate_by_handle(&info);
558 if (ACPI_FAILURE (status)) { 548 if (ACPI_FAILURE(status)) {
559 ACPI_REPORT_ERROR (( 549 ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number));
560 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
561 acpi_format_exception (status),
562 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
563 gpe_number));
564 } 550 }
565 } 551 }
566 552
567 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == 553 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
568 ACPI_GPE_LEVEL_TRIGGERED) { 554 ACPI_GPE_LEVEL_TRIGGERED) {
569 /* 555 /*
570 * GPE is level-triggered, we clear the GPE status bit after 556 * GPE is level-triggered, we clear the GPE status bit after
571 * handling the event. 557 * handling the event.
572 */ 558 */
573 status = acpi_hw_clear_gpe (&local_gpe_event_info); 559 status = acpi_hw_clear_gpe(&local_gpe_event_info);
574 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
575 return_VOID; 561 return_VOID;
576 } 562 }
577 } 563 }
578 564
579 /* Enable this GPE */ 565 /* Enable this GPE */
580 566
581 (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info); 567 (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info);
582 return_VOID; 568 return_VOID;
583} 569}
584 570
585
586/******************************************************************************* 571/*******************************************************************************
587 * 572 *
588 * FUNCTION: acpi_ev_gpe_dispatch 573 * FUNCTION: acpi_ev_gpe_dispatch
@@ -600,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method (
600 ******************************************************************************/ 585 ******************************************************************************/
601 586
602u32 587u32
603acpi_ev_gpe_dispatch ( 588acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
604 struct acpi_gpe_event_info *gpe_event_info,
605 u32 gpe_number)
606{ 589{
607 acpi_status status; 590 acpi_status status;
608
609
610 ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
611 591
592 ACPI_FUNCTION_TRACE("ev_gpe_dispatch");
612 593
613 /* 594 /*
614 * If edge-triggered, clear the GPE status bit now. Note that 595 * If edge-triggered, clear the GPE status bit now. Note that
615 * level-triggered events are cleared after the GPE is serviced. 596 * level-triggered events are cleared after the GPE is serviced.
616 */ 597 */
617 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 598 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
618 ACPI_GPE_EDGE_TRIGGERED) { 599 ACPI_GPE_EDGE_TRIGGERED) {
619 status = acpi_hw_clear_gpe (gpe_event_info); 600 status = acpi_hw_clear_gpe(gpe_event_info);
620 if (ACPI_FAILURE (status)) { 601 if (ACPI_FAILURE(status)) {
621 ACPI_REPORT_ERROR (( 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
622 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
623 acpi_format_exception (status), gpe_number));
624 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
625 } 604 }
626 } 605 }
627 606
628 /* Save current system state */ 607 /* Save current system state */
629 608
630 if (acpi_gbl_system_awake_and_running) { 609 if (acpi_gbl_system_awake_and_running) {
631 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); 610 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
632 } 611 } else {
633 else { 612 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
634 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
635 } 613 }
636 614
637 /* 615 /*
@@ -648,19 +626,19 @@ acpi_ev_gpe_dispatch (
648 * Invoke the installed handler (at interrupt level) 626 * Invoke the installed handler (at interrupt level)
649 * Ignore return status for now. TBD: leave GPE disabled on error? 627 * Ignore return status for now. TBD: leave GPE disabled on error?
650 */ 628 */
651 (void) gpe_event_info->dispatch.handler->address ( 629 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
652 gpe_event_info->dispatch.handler->context); 630 dispatch.
631 handler->
632 context);
653 633
654 /* It is now safe to clear level-triggered events. */ 634 /* It is now safe to clear level-triggered events. */
655 635
656 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 636 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
657 ACPI_GPE_LEVEL_TRIGGERED) { 637 ACPI_GPE_LEVEL_TRIGGERED) {
658 status = acpi_hw_clear_gpe (gpe_event_info); 638 status = acpi_hw_clear_gpe(gpe_event_info);
659 if (ACPI_FAILURE (status)) { 639 if (ACPI_FAILURE(status)) {
660 ACPI_REPORT_ERROR (( 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
661 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
662 acpi_format_exception (status), gpe_number));
663 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
664 } 642 }
665 } 643 }
666 break; 644 break;
@@ -671,24 +649,21 @@ acpi_ev_gpe_dispatch (
671 * Disable GPE, so it doesn't keep firing before the method has a 649 * Disable GPE, so it doesn't keep firing before the method has a
672 * chance to run. 650 * chance to run.
673 */ 651 */
674 status = acpi_ev_disable_gpe (gpe_event_info); 652 status = acpi_ev_disable_gpe(gpe_event_info);
675 if (ACPI_FAILURE (status)) { 653 if (ACPI_FAILURE(status)) {
676 ACPI_REPORT_ERROR (( 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
677 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
678 acpi_format_exception (status), gpe_number));
679 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
680 } 656 }
681 657
682 /* 658 /*
683 * Execute the method associated with the GPE 659 * Execute the method associated with the GPE
684 * NOTE: Level-triggered GPEs are cleared after the method completes. 660 * NOTE: Level-triggered GPEs are cleared after the method completes.
685 */ 661 */
686 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE, 662 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
687 acpi_ev_asynch_execute_gpe_method, gpe_event_info); 663 acpi_ev_asynch_execute_gpe_method,
688 if (ACPI_FAILURE (status)) { 664 gpe_event_info);
689 ACPI_REPORT_ERROR (( 665 if (ACPI_FAILURE(status)) {
690 "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", 666 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number));
691 acpi_format_exception (status), gpe_number));
692 } 667 }
693 break; 668 break;
694 669
@@ -696,28 +671,23 @@ acpi_ev_gpe_dispatch (
696 671
697 /* No handler or method to run! */ 672 /* No handler or method to run! */
698 673
699 ACPI_REPORT_ERROR (( 674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number));
700 "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
701 gpe_number));
702 675
703 /* 676 /*
704 * Disable the GPE. The GPE will remain disabled until the ACPI 677 * Disable the GPE. The GPE will remain disabled until the ACPI
705 * Core Subsystem is restarted, or a handler is installed. 678 * Core Subsystem is restarted, or a handler is installed.
706 */ 679 */
707 status = acpi_ev_disable_gpe (gpe_event_info); 680 status = acpi_ev_disable_gpe(gpe_event_info);
708 if (ACPI_FAILURE (status)) { 681 if (ACPI_FAILURE(status)) {
709 ACPI_REPORT_ERROR (( 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
710 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
711 acpi_format_exception (status), gpe_number));
712 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
713 } 684 }
714 break; 685 break;
715 } 686 }
716 687
717 return_VALUE (ACPI_INTERRUPT_HANDLED); 688 return_VALUE(ACPI_INTERRUPT_HANDLED);
718} 689}
719 690
720
721#ifdef ACPI_GPE_NOTIFY_CHECK 691#ifdef ACPI_GPE_NOTIFY_CHECK
722/******************************************************************************* 692/*******************************************************************************
723 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED 693 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
@@ -736,35 +706,29 @@ acpi_ev_gpe_dispatch (
736 ******************************************************************************/ 706 ******************************************************************************/
737 707
738acpi_status 708acpi_status
739acpi_ev_check_for_wake_only_gpe ( 709acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
740 struct acpi_gpe_event_info *gpe_event_info)
741{ 710{
742 acpi_status status; 711 acpi_status status;
743 712
713 ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe");
744 714
745 ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe"); 715 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
746 716 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */
747
748 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
749 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
750 /* This must be a wake-only GPE, disable it */ 717 /* This must be a wake-only GPE, disable it */
751 718
752 status = acpi_ev_disable_gpe (gpe_event_info); 719 status = acpi_ev_disable_gpe(gpe_event_info);
753 720
754 /* Set GPE to wake-only. Do not change wake disabled/enabled status */ 721 /* Set GPE to wake-only. Do not change wake disabled/enabled status */
755 722
756 acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 723 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
757 724
758 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", 725 ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info));
759 gpe_event_info));
760 726
761 /* This was a wake-only GPE */ 727 /* This was a wake-only GPE */
762 728
763 return_ACPI_STATUS (AE_WAKE_ONLY_GPE); 729 return_ACPI_STATUS(AE_WAKE_ONLY_GPE);
764 } 730 }
765 731
766 return_ACPI_STATUS (AE_OK); 732 return_ACPI_STATUS(AE_OK);
767} 733}
768#endif 734#endif
769
770