aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exmutex.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/executer/exmutex.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/executer/exmutex.c')
-rw-r--r--drivers/acpi/executer/exmutex.c160
1 files changed, 63 insertions, 97 deletions
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index c3cb714d2cba..ab47f6d8b5c0 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -42,20 +42,16 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
50 ACPI_MODULE_NAME ("exmutex") 49ACPI_MODULE_NAME("exmutex")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54static void 52static void
55acpi_ex_link_mutex ( 53acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
56 union acpi_operand_object *obj_desc, 54 struct acpi_thread_state *thread);
57 struct acpi_thread_state *thread);
58
59 55
60/******************************************************************************* 56/*******************************************************************************
61 * 57 *
@@ -69,12 +65,9 @@ acpi_ex_link_mutex (
69 * 65 *
70 ******************************************************************************/ 66 ******************************************************************************/
71 67
72void 68void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
73acpi_ex_unlink_mutex (
74 union acpi_operand_object *obj_desc)
75{ 69{
76 struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; 70 struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
77
78 71
79 if (!thread) { 72 if (!thread) {
80 return; 73 return;
@@ -88,13 +81,11 @@ acpi_ex_unlink_mutex (
88 81
89 if (obj_desc->mutex.prev) { 82 if (obj_desc->mutex.prev) {
90 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; 83 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
91 } 84 } else {
92 else {
93 thread->acquired_mutex_list = obj_desc->mutex.next; 85 thread->acquired_mutex_list = obj_desc->mutex.next;
94 } 86 }
95} 87}
96 88
97
98/******************************************************************************* 89/*******************************************************************************
99 * 90 *
100 * FUNCTION: acpi_ex_link_mutex 91 * FUNCTION: acpi_ex_link_mutex
@@ -109,12 +100,10 @@ acpi_ex_unlink_mutex (
109 ******************************************************************************/ 100 ******************************************************************************/
110 101
111static void 102static void
112acpi_ex_link_mutex ( 103acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
113 union acpi_operand_object *obj_desc, 104 struct acpi_thread_state *thread)
114 struct acpi_thread_state *thread)
115{ 105{
116 union acpi_operand_object *list_head; 106 union acpi_operand_object *list_head;
117
118 107
119 list_head = thread->acquired_mutex_list; 108 list_head = thread->acquired_mutex_list;
120 109
@@ -134,7 +123,6 @@ acpi_ex_link_mutex (
134 thread->acquired_mutex_list = obj_desc; 123 thread->acquired_mutex_list = obj_desc;
135} 124}
136 125
137
138/******************************************************************************* 126/*******************************************************************************
139 * 127 *
140 * FUNCTION: acpi_ex_acquire_mutex 128 * FUNCTION: acpi_ex_acquire_mutex
@@ -150,27 +138,23 @@ acpi_ex_link_mutex (
150 ******************************************************************************/ 138 ******************************************************************************/
151 139
152acpi_status 140acpi_status
153acpi_ex_acquire_mutex ( 141acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
154 union acpi_operand_object *time_desc, 142 union acpi_operand_object *obj_desc,
155 union acpi_operand_object *obj_desc, 143 struct acpi_walk_state *walk_state)
156 struct acpi_walk_state *walk_state)
157{ 144{
158 acpi_status status; 145 acpi_status status;
159
160
161 ACPI_FUNCTION_TRACE_PTR ("ex_acquire_mutex", obj_desc);
162 146
147 ACPI_FUNCTION_TRACE_PTR("ex_acquire_mutex", obj_desc);
163 148
164 if (!obj_desc) { 149 if (!obj_desc) {
165 return_ACPI_STATUS (AE_BAD_PARAMETER); 150 return_ACPI_STATUS(AE_BAD_PARAMETER);
166 } 151 }
167 152
168 /* Sanity check -- we must have a valid thread ID */ 153 /* Sanity check -- we must have a valid thread ID */
169 154
170 if (!walk_state->thread) { 155 if (!walk_state->thread) {
171 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", 156 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
172 acpi_ut_get_node_name (obj_desc->mutex.node))); 157 return_ACPI_STATUS(AE_AML_INTERNAL);
173 return_ACPI_STATUS (AE_AML_INTERNAL);
174 } 158 }
175 159
176 /* 160 /*
@@ -178,10 +162,8 @@ acpi_ex_acquire_mutex (
178 * mutex. This mechanism provides some deadlock prevention 162 * mutex. This mechanism provides some deadlock prevention
179 */ 163 */
180 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 164 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
181 ACPI_REPORT_ERROR (( 165 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
182 "Cannot acquire Mutex [%4.4s], incorrect sync_level\n", 166 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
183 acpi_ut_get_node_name (obj_desc->mutex.node)));
184 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
185 } 167 }
186 168
187 /* Support for multiple acquires by the owning thread */ 169 /* Support for multiple acquires by the owning thread */
@@ -190,43 +172,43 @@ acpi_ex_acquire_mutex (
190 /* Special case for Global Lock, allow all threads */ 172 /* Special case for Global Lock, allow all threads */
191 173
192 if ((obj_desc->mutex.owner_thread->thread_id == 174 if ((obj_desc->mutex.owner_thread->thread_id ==
193 walk_state->thread->thread_id) || 175 walk_state->thread->thread_id) ||
194 (obj_desc->mutex.semaphore == 176 (obj_desc->mutex.semaphore ==
195 acpi_gbl_global_lock_semaphore)) { 177 acpi_gbl_global_lock_semaphore)) {
196 /* 178 /*
197 * The mutex is already owned by this thread, 179 * The mutex is already owned by this thread,
198 * just increment the acquisition depth 180 * just increment the acquisition depth
199 */ 181 */
200 obj_desc->mutex.acquisition_depth++; 182 obj_desc->mutex.acquisition_depth++;
201 return_ACPI_STATUS (AE_OK); 183 return_ACPI_STATUS(AE_OK);
202 } 184 }
203 } 185 }
204 186
205 /* Acquire the mutex, wait if necessary */ 187 /* Acquire the mutex, wait if necessary */
206 188
207 status = acpi_ex_system_acquire_mutex (time_desc, obj_desc); 189 status = acpi_ex_system_acquire_mutex(time_desc, obj_desc);
208 if (ACPI_FAILURE (status)) { 190 if (ACPI_FAILURE(status)) {
209 /* Includes failure from a timeout on time_desc */ 191 /* Includes failure from a timeout on time_desc */
210 192
211 return_ACPI_STATUS (status); 193 return_ACPI_STATUS(status);
212 } 194 }
213 195
214 /* Have the mutex: update mutex and walk info and save the sync_level */ 196 /* Have the mutex: update mutex and walk info and save the sync_level */
215 197
216 obj_desc->mutex.owner_thread = walk_state->thread; 198 obj_desc->mutex.owner_thread = walk_state->thread;
217 obj_desc->mutex.acquisition_depth = 1; 199 obj_desc->mutex.acquisition_depth = 1;
218 obj_desc->mutex.original_sync_level = walk_state->thread->current_sync_level; 200 obj_desc->mutex.original_sync_level =
201 walk_state->thread->current_sync_level;
219 202
220 walk_state->thread->current_sync_level = obj_desc->mutex.sync_level; 203 walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
221 204
222 /* Link the mutex to the current thread for force-unlock at method exit */ 205 /* Link the mutex to the current thread for force-unlock at method exit */
223 206
224 acpi_ex_link_mutex (obj_desc, walk_state->thread); 207 acpi_ex_link_mutex(obj_desc, walk_state->thread);
225 208
226 return_ACPI_STATUS (AE_OK); 209 return_ACPI_STATUS(AE_OK);
227} 210}
228 211
229
230/******************************************************************************* 212/*******************************************************************************
231 * 213 *
232 * FUNCTION: acpi_ex_release_mutex 214 * FUNCTION: acpi_ex_release_mutex
@@ -241,48 +223,40 @@ acpi_ex_acquire_mutex (
241 ******************************************************************************/ 223 ******************************************************************************/
242 224
243acpi_status 225acpi_status
244acpi_ex_release_mutex ( 226acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
245 union acpi_operand_object *obj_desc, 227 struct acpi_walk_state *walk_state)
246 struct acpi_walk_state *walk_state)
247{ 228{
248 acpi_status status; 229 acpi_status status;
249
250
251 ACPI_FUNCTION_TRACE ("ex_release_mutex");
252 230
231 ACPI_FUNCTION_TRACE("ex_release_mutex");
253 232
254 if (!obj_desc) { 233 if (!obj_desc) {
255 return_ACPI_STATUS (AE_BAD_PARAMETER); 234 return_ACPI_STATUS(AE_BAD_PARAMETER);
256 } 235 }
257 236
258 /* The mutex must have been previously acquired in order to release it */ 237 /* The mutex must have been previously acquired in order to release it */
259 238
260 if (!obj_desc->mutex.owner_thread) { 239 if (!obj_desc->mutex.owner_thread) {
261 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n", 240 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
262 acpi_ut_get_node_name (obj_desc->mutex.node))); 241 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
263 return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
264 } 242 }
265 243
266 /* Sanity check -- we must have a valid thread ID */ 244 /* Sanity check -- we must have a valid thread ID */
267 245
268 if (!walk_state->thread) { 246 if (!walk_state->thread) {
269 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", 247 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
270 acpi_ut_get_node_name (obj_desc->mutex.node))); 248 return_ACPI_STATUS(AE_AML_INTERNAL);
271 return_ACPI_STATUS (AE_AML_INTERNAL);
272 } 249 }
273 250
274 /* 251 /*
275 * The Mutex is owned, but this thread must be the owner. 252 * The Mutex is owned, but this thread must be the owner.
276 * Special case for Global Lock, any thread can release 253 * Special case for Global Lock, any thread can release
277 */ 254 */
278 if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) && 255 if ((obj_desc->mutex.owner_thread->thread_id !=
279 (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 256 walk_state->thread->thread_id)
280 ACPI_REPORT_ERROR (( 257 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
281 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", 258 ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id));
282 walk_state->thread->thread_id, 259 return_ACPI_STATUS(AE_AML_NOT_OWNER);
283 acpi_ut_get_node_name (obj_desc->mutex.node),
284 obj_desc->mutex.owner_thread->thread_id));
285 return_ACPI_STATUS (AE_AML_NOT_OWNER);
286 } 260 }
287 261
288 /* 262 /*
@@ -290,10 +264,8 @@ acpi_ex_release_mutex (
290 * equal to the current sync level 264 * equal to the current sync level
291 */ 265 */
292 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { 266 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
293 ACPI_REPORT_ERROR (( 267 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
294 "Cannot release Mutex [%4.4s], incorrect sync_level\n", 268 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
295 acpi_ut_get_node_name (obj_desc->mutex.node)));
296 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
297 } 269 }
298 270
299 /* Match multiple Acquires with multiple Releases */ 271 /* Match multiple Acquires with multiple Releases */
@@ -302,26 +274,26 @@ acpi_ex_release_mutex (
302 if (obj_desc->mutex.acquisition_depth != 0) { 274 if (obj_desc->mutex.acquisition_depth != 0) {
303 /* Just decrement the depth and return */ 275 /* Just decrement the depth and return */
304 276
305 return_ACPI_STATUS (AE_OK); 277 return_ACPI_STATUS(AE_OK);
306 } 278 }
307 279
308 /* Unlink the mutex from the owner's list */ 280 /* Unlink the mutex from the owner's list */
309 281
310 acpi_ex_unlink_mutex (obj_desc); 282 acpi_ex_unlink_mutex(obj_desc);
311 283
312 /* Release the mutex */ 284 /* Release the mutex */
313 285
314 status = acpi_ex_system_release_mutex (obj_desc); 286 status = acpi_ex_system_release_mutex(obj_desc);
315 287
316 /* Update the mutex and walk state, restore sync_level before acquire */ 288 /* Update the mutex and walk state, restore sync_level before acquire */
317 289
318 obj_desc->mutex.owner_thread = NULL; 290 obj_desc->mutex.owner_thread = NULL;
319 walk_state->thread->current_sync_level = obj_desc->mutex.original_sync_level; 291 walk_state->thread->current_sync_level =
292 obj_desc->mutex.original_sync_level;
320 293
321 return_ACPI_STATUS (status); 294 return_ACPI_STATUS(status);
322} 295}
323 296
324
325/******************************************************************************* 297/*******************************************************************************
326 * 298 *
327 * FUNCTION: acpi_ex_release_all_mutexes 299 * FUNCTION: acpi_ex_release_all_mutexes
@@ -334,17 +306,13 @@ acpi_ex_release_mutex (
334 * 306 *
335 ******************************************************************************/ 307 ******************************************************************************/
336 308
337void 309void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
338acpi_ex_release_all_mutexes (
339 struct acpi_thread_state *thread)
340{ 310{
341 union acpi_operand_object *next = thread->acquired_mutex_list; 311 union acpi_operand_object *next = thread->acquired_mutex_list;
342 union acpi_operand_object *this; 312 union acpi_operand_object *this;
343 acpi_status status; 313 acpi_status status;
344
345
346 ACPI_FUNCTION_ENTRY ();
347 314
315 ACPI_FUNCTION_ENTRY();
348 316
349 /* Traverse the list of owned mutexes, releasing each one */ 317 /* Traverse the list of owned mutexes, releasing each one */
350 318
@@ -353,13 +321,13 @@ acpi_ex_release_all_mutexes (
353 next = this->mutex.next; 321 next = this->mutex.next;
354 322
355 this->mutex.acquisition_depth = 1; 323 this->mutex.acquisition_depth = 1;
356 this->mutex.prev = NULL; 324 this->mutex.prev = NULL;
357 this->mutex.next = NULL; 325 this->mutex.next = NULL;
358 326
359 /* Release the mutex */ 327 /* Release the mutex */
360 328
361 status = acpi_ex_system_release_mutex (this); 329 status = acpi_ex_system_release_mutex(this);
362 if (ACPI_FAILURE (status)) { 330 if (ACPI_FAILURE(status)) {
363 continue; 331 continue;
364 } 332 }
365 333
@@ -372,5 +340,3 @@ acpi_ex_release_all_mutexes (
372 thread->current_sync_level = this->mutex.original_sync_level; 340 thread->current_sync_level = this->mutex.original_sync_level;
373 } 341 }
374} 342}
375
376