aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utmutex.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/utilities/utmutex.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities/utmutex.c')
-rw-r--r--drivers/acpi/utilities/utmutex.c220
1 files changed, 97 insertions, 123 deletions
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 0699b6be62b6..90134c56ece9 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -41,22 +41,15 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46 45
47#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utmutex") 47ACPI_MODULE_NAME("utmutex")
49 48
50/* Local prototypes */ 49/* Local prototypes */
50static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
51 51
52static acpi_status 52static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
53acpi_ut_create_mutex (
54 acpi_mutex_handle mutex_id);
55
56static acpi_status
57acpi_ut_delete_mutex (
58 acpi_mutex_handle mutex_id);
59
60 53
61/******************************************************************************* 54/*******************************************************************************
62 * 55 *
@@ -70,32 +63,27 @@ acpi_ut_delete_mutex (
70 * 63 *
71 ******************************************************************************/ 64 ******************************************************************************/
72 65
73acpi_status 66acpi_status acpi_ut_mutex_initialize(void)
74acpi_ut_mutex_initialize (
75 void)
76{ 67{
77 u32 i; 68 u32 i;
78 acpi_status status; 69 acpi_status status;
79
80
81 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
82 70
71 ACPI_FUNCTION_TRACE("ut_mutex_initialize");
83 72
84 /* 73 /*
85 * Create each of the predefined mutex objects 74 * Create each of the predefined mutex objects
86 */ 75 */
87 for (i = 0; i < NUM_MUTEX; i++) { 76 for (i = 0; i < NUM_MUTEX; i++) {
88 status = acpi_ut_create_mutex (i); 77 status = acpi_ut_create_mutex(i);
89 if (ACPI_FAILURE (status)) { 78 if (ACPI_FAILURE(status)) {
90 return_ACPI_STATUS (status); 79 return_ACPI_STATUS(status);
91 } 80 }
92 } 81 }
93 82
94 status = acpi_os_create_lock (&acpi_gbl_gpe_lock); 83 status = acpi_os_create_lock(&acpi_gbl_gpe_lock);
95 return_ACPI_STATUS (status); 84 return_ACPI_STATUS(status);
96} 85}
97 86
98
99/******************************************************************************* 87/*******************************************************************************
100 * 88 *
101 * FUNCTION: acpi_ut_mutex_terminate 89 * FUNCTION: acpi_ut_mutex_terminate
@@ -108,28 +96,23 @@ acpi_ut_mutex_initialize (
108 * 96 *
109 ******************************************************************************/ 97 ******************************************************************************/
110 98
111void 99void acpi_ut_mutex_terminate(void)
112acpi_ut_mutex_terminate (
113 void)
114{ 100{
115 u32 i; 101 u32 i;
116
117
118 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
119 102
103 ACPI_FUNCTION_TRACE("ut_mutex_terminate");
120 104
121 /* 105 /*
122 * Delete each predefined mutex object 106 * Delete each predefined mutex object
123 */ 107 */
124 for (i = 0; i < NUM_MUTEX; i++) { 108 for (i = 0; i < NUM_MUTEX; i++) {
125 (void) acpi_ut_delete_mutex (i); 109 (void)acpi_ut_delete_mutex(i);
126 } 110 }
127 111
128 acpi_os_delete_lock (acpi_gbl_gpe_lock); 112 acpi_os_delete_lock(acpi_gbl_gpe_lock);
129 return_VOID; 113 return_VOID;
130} 114}
131 115
132
133/******************************************************************************* 116/*******************************************************************************
134 * 117 *
135 * FUNCTION: acpi_ut_create_mutex 118 * FUNCTION: acpi_ut_create_mutex
@@ -142,31 +125,28 @@ acpi_ut_mutex_terminate (
142 * 125 *
143 ******************************************************************************/ 126 ******************************************************************************/
144 127
145static acpi_status 128static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146acpi_ut_create_mutex (
147 acpi_mutex_handle mutex_id)
148{ 129{
149 acpi_status status = AE_OK; 130 acpi_status status = AE_OK;
150
151
152 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
153 131
132 ACPI_FUNCTION_TRACE_U32("ut_create_mutex", mutex_id);
154 133
155 if (mutex_id > MAX_MUTEX) { 134 if (mutex_id > MAX_MUTEX) {
156 return_ACPI_STATUS (AE_BAD_PARAMETER); 135 return_ACPI_STATUS(AE_BAD_PARAMETER);
157 } 136 }
158 137
159 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 138 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
160 status = acpi_os_create_semaphore (1, 1, 139 status = acpi_os_create_semaphore(1, 1,
161 &acpi_gbl_mutex_info[mutex_id].mutex); 140 &acpi_gbl_mutex_info
162 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 141 [mutex_id].mutex);
142 acpi_gbl_mutex_info[mutex_id].thread_id =
143 ACPI_MUTEX_NOT_ACQUIRED;
163 acpi_gbl_mutex_info[mutex_id].use_count = 0; 144 acpi_gbl_mutex_info[mutex_id].use_count = 0;
164 } 145 }
165 146
166 return_ACPI_STATUS (status); 147 return_ACPI_STATUS(status);
167} 148}
168 149
169
170/******************************************************************************* 150/*******************************************************************************
171 * 151 *
172 * FUNCTION: acpi_ut_delete_mutex 152 * FUNCTION: acpi_ut_delete_mutex
@@ -179,29 +159,24 @@ acpi_ut_create_mutex (
179 * 159 *
180 ******************************************************************************/ 160 ******************************************************************************/
181 161
182static acpi_status 162static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
183acpi_ut_delete_mutex (
184 acpi_mutex_handle mutex_id)
185{ 163{
186 acpi_status status; 164 acpi_status status;
187
188
189 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
190 165
166 ACPI_FUNCTION_TRACE_U32("ut_delete_mutex", mutex_id);
191 167
192 if (mutex_id > MAX_MUTEX) { 168 if (mutex_id > MAX_MUTEX) {
193 return_ACPI_STATUS (AE_BAD_PARAMETER); 169 return_ACPI_STATUS(AE_BAD_PARAMETER);
194 } 170 }
195 171
196 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); 172 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);
197 173
198 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 174 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
199 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 175 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
200 176
201 return_ACPI_STATUS (status); 177 return_ACPI_STATUS(status);
202} 178}
203 179
204
205/******************************************************************************* 180/*******************************************************************************
206 * 181 *
207 * FUNCTION: acpi_ut_acquire_mutex 182 * FUNCTION: acpi_ut_acquire_mutex
@@ -214,26 +189,22 @@ acpi_ut_delete_mutex (
214 * 189 *
215 ******************************************************************************/ 190 ******************************************************************************/
216 191
217acpi_status 192acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
218acpi_ut_acquire_mutex (
219 acpi_mutex_handle mutex_id)
220{ 193{
221 acpi_status status; 194 acpi_status status;
222 u32 this_thread_id; 195 u32 this_thread_id;
223
224
225 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
226 196
197 ACPI_FUNCTION_NAME("ut_acquire_mutex");
227 198
228 if (mutex_id > MAX_MUTEX) { 199 if (mutex_id > MAX_MUTEX) {
229 return (AE_BAD_PARAMETER); 200 return (AE_BAD_PARAMETER);
230 } 201 }
231 202
232 this_thread_id = acpi_os_get_thread_id (); 203 this_thread_id = acpi_os_get_thread_id();
233 204
234#ifdef ACPI_MUTEX_DEBUG 205#ifdef ACPI_MUTEX_DEBUG
235 { 206 {
236 u32 i; 207 u32 i;
237 /* 208 /*
238 * Mutex debug code, for internal debugging only. 209 * Mutex debug code, for internal debugging only.
239 * 210 *
@@ -245,17 +216,21 @@ acpi_ut_acquire_mutex (
245 for (i = mutex_id; i < MAX_MUTEX; i++) { 216 for (i = mutex_id; i < MAX_MUTEX; i++) {
246 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
247 if (i == mutex_id) { 218 if (i == mutex_id) {
248 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
249 "Mutex [%s] already acquired by this thread [%X]\n", 220 "Mutex [%s] already acquired by this thread [%X]\n",
250 acpi_ut_get_mutex_name (mutex_id), this_thread_id)); 221 acpi_ut_get_mutex_name
222 (mutex_id),
223 this_thread_id));
251 224
252 return (AE_ALREADY_ACQUIRED); 225 return (AE_ALREADY_ACQUIRED);
253 } 226 }
254 227
255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
256 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
257 this_thread_id, acpi_ut_get_mutex_name (i), 230 this_thread_id,
258 acpi_ut_get_mutex_name (mutex_id))); 231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name
233 (mutex_id)));
259 234
260 return (AE_ACQUIRE_DEADLOCK); 235 return (AE_ACQUIRE_DEADLOCK);
261 } 236 }
@@ -263,30 +238,31 @@ acpi_ut_acquire_mutex (
263 } 238 }
264#endif 239#endif
265 240
266 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 241 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
267 "Thread %X attempting to acquire Mutex [%s]\n", 242 "Thread %X attempting to acquire Mutex [%s]\n",
268 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 243 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
269 244
270 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 245 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,
271 1, ACPI_WAIT_FOREVER); 246 1, ACPI_WAIT_FOREVER);
272 if (ACPI_SUCCESS (status)) { 247 if (ACPI_SUCCESS(status)) {
273 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 248 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
274 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 249 "Thread %X acquired Mutex [%s]\n",
250 this_thread_id,
251 acpi_ut_get_mutex_name(mutex_id)));
275 252
276 acpi_gbl_mutex_info[mutex_id].use_count++; 253 acpi_gbl_mutex_info[mutex_id].use_count++;
277 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
278 } 255 } else {
279 else { 256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
280 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 257 "Thread %X could not acquire Mutex [%s] %s\n",
281 "Thread %X could not acquire Mutex [%s] %s\n", 258 this_thread_id,
282 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 259 acpi_ut_get_mutex_name(mutex_id),
283 acpi_format_exception (status))); 260 acpi_format_exception(status)));
284 } 261 }
285 262
286 return (status); 263 return (status);
287} 264}
288 265
289
290/******************************************************************************* 266/*******************************************************************************
291 * 267 *
292 * FUNCTION: acpi_ut_release_mutex 268 * FUNCTION: acpi_ut_release_mutex
@@ -299,21 +275,17 @@ acpi_ut_acquire_mutex (
299 * 275 *
300 ******************************************************************************/ 276 ******************************************************************************/
301 277
302acpi_status 278acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
303acpi_ut_release_mutex (
304 acpi_mutex_handle mutex_id)
305{ 279{
306 acpi_status status; 280 acpi_status status;
307 u32 this_thread_id; 281 u32 this_thread_id;
308
309 282
310 ACPI_FUNCTION_NAME ("ut_release_mutex"); 283 ACPI_FUNCTION_NAME("ut_release_mutex");
311 284
312 285 this_thread_id = acpi_os_get_thread_id();
313 this_thread_id = acpi_os_get_thread_id (); 286 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
314 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 287 "Thread %X releasing Mutex [%s]\n", this_thread_id,
315 "Thread %X releasing Mutex [%s]\n", this_thread_id, 288 acpi_ut_get_mutex_name(mutex_id)));
316 acpi_ut_get_mutex_name (mutex_id)));
317 289
318 if (mutex_id > MAX_MUTEX) { 290 if (mutex_id > MAX_MUTEX) {
319 return (AE_BAD_PARAMETER); 291 return (AE_BAD_PARAMETER);
@@ -323,16 +295,15 @@ acpi_ut_release_mutex (
323 * Mutex must be acquired in order to release it! 295 * Mutex must be acquired in order to release it!
324 */ 296 */
325 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { 297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
326 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
327 "Mutex [%s] is not acquired, cannot release\n", 299 "Mutex [%s] is not acquired, cannot release\n",
328 acpi_ut_get_mutex_name (mutex_id))); 300 acpi_ut_get_mutex_name(mutex_id)));
329 301
330 return (AE_NOT_ACQUIRED); 302 return (AE_NOT_ACQUIRED);
331 } 303 }
332
333#ifdef ACPI_MUTEX_DEBUG 304#ifdef ACPI_MUTEX_DEBUG
334 { 305 {
335 u32 i; 306 u32 i;
336 /* 307 /*
337 * Mutex debug code, for internal debugging only. 308 * Mutex debug code, for internal debugging only.
338 * 309 *
@@ -347,9 +318,11 @@ acpi_ut_release_mutex (
347 continue; 318 continue;
348 } 319 }
349 320
350 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
351 "Invalid release order: owns [%s], releasing [%s]\n", 322 "Invalid release order: owns [%s], releasing [%s]\n",
352 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); 323 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name
325 (mutex_id)));
353 326
354 return (AE_RELEASE_DEADLOCK); 327 return (AE_RELEASE_DEADLOCK);
355 } 328 }
@@ -361,20 +334,21 @@ acpi_ut_release_mutex (
361 334
362 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
363 336
364 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); 337 status =
365 338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
366 if (ACPI_FAILURE (status)) { 339
367 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 340 if (ACPI_FAILURE(status)) {
368 "Thread %X could not release Mutex [%s] %s\n", 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 342 "Thread %X could not release Mutex [%s] %s\n",
370 acpi_format_exception (status))); 343 this_thread_id,
371 } 344 acpi_ut_get_mutex_name(mutex_id),
372 else { 345 acpi_format_exception(status)));
373 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", 346 } else {
374 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 347 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
348 "Thread %X released Mutex [%s]\n",
349 this_thread_id,
350 acpi_ut_get_mutex_name(mutex_id)));
375 } 351 }
376 352
377 return (status); 353 return (status);
378} 354}
379
380