diff options
Diffstat (limited to 'drivers/acpi/executer/exutils.c')
-rw-r--r-- | drivers/acpi/executer/exutils.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 6b0aeccbb69b..86c03880b523 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c | |||
@@ -6,7 +6,7 @@ | |||
6 | *****************************************************************************/ | 6 | *****************************************************************************/ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Copyright (C) 2000 - 2007, R. Byron Moore | 9 | * Copyright (C) 2000 - 2008, Intel Corp. |
10 | * All rights reserved. | 10 | * All rights reserved. |
11 | * | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without |
@@ -61,7 +61,6 @@ | |||
61 | #include <acpi/acpi.h> | 61 | #include <acpi/acpi.h> |
62 | #include <acpi/acinterp.h> | 62 | #include <acpi/acinterp.h> |
63 | #include <acpi/amlcode.h> | 63 | #include <acpi/amlcode.h> |
64 | #include <acpi/acevents.h> | ||
65 | 64 | ||
66 | #define _COMPONENT ACPI_EXECUTER | 65 | #define _COMPONENT ACPI_EXECUTER |
67 | ACPI_MODULE_NAME("exutils") | 66 | ACPI_MODULE_NAME("exutils") |
@@ -217,9 +216,10 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) | |||
217 | 216 | ||
218 | /* | 217 | /* |
219 | * Object must be a valid number and we must be executing | 218 | * Object must be a valid number and we must be executing |
220 | * a control method | 219 | * a control method. NS node could be there for AML_INT_NAMEPATH_OP. |
221 | */ | 220 | */ |
222 | if ((!obj_desc) || | 221 | if ((!obj_desc) || |
222 | (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || | ||
223 | (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { | 223 | (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { |
224 | return; | 224 | return; |
225 | } | 225 | } |
@@ -240,72 +240,73 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) | |||
240 | * PARAMETERS: field_flags - Flags with Lock rule: | 240 | * PARAMETERS: field_flags - Flags with Lock rule: |
241 | * always_lock or never_lock | 241 | * always_lock or never_lock |
242 | * | 242 | * |
243 | * RETURN: TRUE/FALSE indicating whether the lock was actually acquired | 243 | * RETURN: None |
244 | * | 244 | * |
245 | * DESCRIPTION: Obtain the global lock and keep track of this fact via two | 245 | * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field |
246 | * methods. A global variable keeps the state of the lock, and | 246 | * flags specifiy that it is to be obtained before field access. |
247 | * the state is returned to the caller. | ||
248 | * | 247 | * |
249 | ******************************************************************************/ | 248 | ******************************************************************************/ |
250 | 249 | ||
251 | u8 acpi_ex_acquire_global_lock(u32 field_flags) | 250 | void acpi_ex_acquire_global_lock(u32 field_flags) |
252 | { | 251 | { |
253 | u8 locked = FALSE; | ||
254 | acpi_status status; | 252 | acpi_status status; |
255 | 253 | ||
256 | ACPI_FUNCTION_TRACE(ex_acquire_global_lock); | 254 | ACPI_FUNCTION_TRACE(ex_acquire_global_lock); |
257 | 255 | ||
258 | /* Only attempt lock if the always_lock bit is set */ | 256 | /* Only use the lock if the always_lock bit is set */ |
257 | |||
258 | if (!(field_flags & AML_FIELD_LOCK_RULE_MASK)) { | ||
259 | return_VOID; | ||
260 | } | ||
259 | 261 | ||
260 | if (field_flags & AML_FIELD_LOCK_RULE_MASK) { | 262 | /* Attempt to get the global lock, wait forever */ |
261 | 263 | ||
262 | /* We should attempt to get the lock, wait forever */ | 264 | status = acpi_ex_acquire_mutex_object(ACPI_WAIT_FOREVER, |
265 | acpi_gbl_global_lock_mutex, | ||
266 | acpi_os_get_thread_id()); | ||
263 | 267 | ||
264 | status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER); | 268 | if (ACPI_FAILURE(status)) { |
265 | if (ACPI_SUCCESS(status)) { | 269 | ACPI_EXCEPTION((AE_INFO, status, |
266 | locked = TRUE; | 270 | "Could not acquire Global Lock")); |
267 | } else { | ||
268 | ACPI_EXCEPTION((AE_INFO, status, | ||
269 | "Could not acquire Global Lock")); | ||
270 | } | ||
271 | } | 271 | } |
272 | 272 | ||
273 | return_UINT8(locked); | 273 | return_VOID; |
274 | } | 274 | } |
275 | 275 | ||
276 | /******************************************************************************* | 276 | /******************************************************************************* |
277 | * | 277 | * |
278 | * FUNCTION: acpi_ex_release_global_lock | 278 | * FUNCTION: acpi_ex_release_global_lock |
279 | * | 279 | * |
280 | * PARAMETERS: locked_by_me - Return value from corresponding call to | 280 | * PARAMETERS: field_flags - Flags with Lock rule: |
281 | * acquire_global_lock. | 281 | * always_lock or never_lock |
282 | * | 282 | * |
283 | * RETURN: None | 283 | * RETURN: None |
284 | * | 284 | * |
285 | * DESCRIPTION: Release the global lock if it is locked. | 285 | * DESCRIPTION: Release the ACPI hardware Global Lock |
286 | * | 286 | * |
287 | ******************************************************************************/ | 287 | ******************************************************************************/ |
288 | 288 | ||
289 | void acpi_ex_release_global_lock(u8 locked_by_me) | 289 | void acpi_ex_release_global_lock(u32 field_flags) |
290 | { | 290 | { |
291 | acpi_status status; | 291 | acpi_status status; |
292 | 292 | ||
293 | ACPI_FUNCTION_TRACE(ex_release_global_lock); | 293 | ACPI_FUNCTION_TRACE(ex_release_global_lock); |
294 | 294 | ||
295 | /* Only attempt unlock if the caller locked it */ | 295 | /* Only use the lock if the always_lock bit is set */ |
296 | 296 | ||
297 | if (locked_by_me) { | 297 | if (!(field_flags & AML_FIELD_LOCK_RULE_MASK)) { |
298 | return_VOID; | ||
299 | } | ||
298 | 300 | ||
299 | /* OK, now release the lock */ | 301 | /* Release the global lock */ |
300 | 302 | ||
301 | status = acpi_ev_release_global_lock(); | 303 | status = acpi_ex_release_mutex_object(acpi_gbl_global_lock_mutex); |
302 | if (ACPI_FAILURE(status)) { | 304 | if (ACPI_FAILURE(status)) { |
303 | 305 | ||
304 | /* Report the error, but there isn't much else we can do */ | 306 | /* Report the error, but there isn't much else we can do */ |
305 | 307 | ||
306 | ACPI_EXCEPTION((AE_INFO, status, | 308 | ACPI_EXCEPTION((AE_INFO, status, |
307 | "Could not release ACPI Global Lock")); | 309 | "Could not release Global Lock")); |
308 | } | ||
309 | } | 310 | } |
310 | 311 | ||
311 | return_VOID; | 312 | return_VOID; |