aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.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/utils.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r--drivers/acpi/utils.c195
1 files changed, 101 insertions, 94 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 1ce2047c3804..6458c47f7ac2 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -30,15 +30,12 @@
30#include <acpi/acpi_bus.h> 30#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 31#include <acpi/acpi_drivers.h>
32 32
33
34#define _COMPONENT ACPI_BUS_COMPONENT 33#define _COMPONENT ACPI_BUS_COMPONENT
35ACPI_MODULE_NAME ("acpi_utils") 34ACPI_MODULE_NAME("acpi_utils")
36
37 35
38/* -------------------------------------------------------------------------- 36/* --------------------------------------------------------------------------
39 Object Evaluation Helpers 37 Object Evaluation Helpers
40 -------------------------------------------------------------------------- */ 38 -------------------------------------------------------------------------- */
41
42#ifdef ACPI_DEBUG_OUTPUT 39#ifdef ACPI_DEBUG_OUTPUT
43#define acpi_util_eval_error(h,p,s) {\ 40#define acpi_util_eval_error(h,p,s) {\
44 char prefix[80] = {'\0'};\ 41 char prefix[80] = {'\0'};\
@@ -49,26 +46,24 @@ ACPI_MODULE_NAME ("acpi_utils")
49#else 46#else
50#define acpi_util_eval_error(h,p,s) 47#define acpi_util_eval_error(h,p,s)
51#endif 48#endif
52
53
54acpi_status 49acpi_status
55acpi_extract_package ( 50acpi_extract_package(union acpi_object *package,
56 union acpi_object *package, 51 struct acpi_buffer *format, struct acpi_buffer *buffer)
57 struct acpi_buffer *format,
58 struct acpi_buffer *buffer)
59{ 52{
60 u32 size_required = 0; 53 u32 size_required = 0;
61 u32 tail_offset = 0; 54 u32 tail_offset = 0;
62 char *format_string = NULL; 55 char *format_string = NULL;
63 u32 format_count = 0; 56 u32 format_count = 0;
64 u32 i = 0; 57 u32 i = 0;
65 u8 *head = NULL; 58 u8 *head = NULL;
66 u8 *tail = NULL; 59 u8 *tail = NULL;
67 60
68 ACPI_FUNCTION_TRACE("acpi_extract_package"); 61 ACPI_FUNCTION_TRACE("acpi_extract_package");
69 62
70 if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { 63 if (!package || (package->type != ACPI_TYPE_PACKAGE)
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); 64 || (package->package.count < 1)) {
65 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
66 "Invalid 'package' argument\n"));
72 return_ACPI_STATUS(AE_BAD_PARAMETER); 67 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 } 68 }
74 69
@@ -82,18 +77,20 @@ acpi_extract_package (
82 return_ACPI_STATUS(AE_BAD_PARAMETER); 77 return_ACPI_STATUS(AE_BAD_PARAMETER);
83 } 78 }
84 79
85 format_count = (format->length/sizeof(char)) - 1; 80 format_count = (format->length / sizeof(char)) - 1;
86 if (format_count > package->package.count) { 81 if (format_count > package->package.count) {
87 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); 82 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
83 "Format specifies more objects [%d] than exist in package [%d].",
84 format_count, package->package.count));
88 return_ACPI_STATUS(AE_BAD_DATA); 85 return_ACPI_STATUS(AE_BAD_DATA);
89 } 86 }
90 87
91 format_string = (char*)format->pointer; 88 format_string = (char *)format->pointer;
92 89
93 /* 90 /*
94 * Calculate size_required. 91 * Calculate size_required.
95 */ 92 */
96 for (i=0; i<format_count; i++) { 93 for (i = 0; i < format_count; i++) {
97 94
98 union acpi_object *element = &(package->package.elements[i]); 95 union acpi_object *element = &(package->package.elements[i]);
99 96
@@ -110,11 +107,15 @@ acpi_extract_package (
110 tail_offset += sizeof(acpi_integer); 107 tail_offset += sizeof(acpi_integer);
111 break; 108 break;
112 case 'S': 109 case 'S':
113 size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char); 110 size_required +=
114 tail_offset += sizeof(char*); 111 sizeof(char *) + sizeof(acpi_integer) +
112 sizeof(char);
113 tail_offset += sizeof(char *);
115 break; 114 break;
116 default: 115 default:
117 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); 116 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
117 "Invalid package element [%d]: got number, expecing [%c].\n",
118 i, format_string[i]));
118 return_ACPI_STATUS(AE_BAD_DATA); 119 return_ACPI_STATUS(AE_BAD_DATA);
119 break; 120 break;
120 } 121 }
@@ -124,15 +125,22 @@ acpi_extract_package (
124 case ACPI_TYPE_BUFFER: 125 case ACPI_TYPE_BUFFER:
125 switch (format_string[i]) { 126 switch (format_string[i]) {
126 case 'S': 127 case 'S':
127 size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char); 128 size_required +=
128 tail_offset += sizeof(char*); 129 sizeof(char *) +
130 (element->string.length * sizeof(char)) +
131 sizeof(char);
132 tail_offset += sizeof(char *);
129 break; 133 break;
130 case 'B': 134 case 'B':
131 size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8)); 135 size_required +=
132 tail_offset += sizeof(u8*); 136 sizeof(u8 *) +
137 (element->buffer.length * sizeof(u8));
138 tail_offset += sizeof(u8 *);
133 break; 139 break;
134 default: 140 default:
135 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); 141 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
142 "Invalid package element [%d] got string/buffer, expecing [%c].\n",
143 i, format_string[i]));
136 return_ACPI_STATUS(AE_BAD_DATA); 144 return_ACPI_STATUS(AE_BAD_DATA);
137 break; 145 break;
138 } 146 }
@@ -140,7 +148,9 @@ acpi_extract_package (
140 148
141 case ACPI_TYPE_PACKAGE: 149 case ACPI_TYPE_PACKAGE:
142 default: 150 default:
143 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); 151 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "Found unsupported element at index=%d\n",
153 i));
144 /* TBD: handle nested packages... */ 154 /* TBD: handle nested packages... */
145 return_ACPI_STATUS(AE_SUPPORT); 155 return_ACPI_STATUS(AE_SUPPORT);
146 break; 156 break;
@@ -153,8 +163,7 @@ acpi_extract_package (
153 if (buffer->length < size_required) { 163 if (buffer->length < size_required) {
154 buffer->length = size_required; 164 buffer->length = size_required;
155 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 165 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
156 } 166 } else if (buffer->length != size_required || !buffer->pointer) {
157 else if (buffer->length != size_required || !buffer->pointer) {
158 return_ACPI_STATUS(AE_BAD_PARAMETER); 167 return_ACPI_STATUS(AE_BAD_PARAMETER);
159 } 168 }
160 169
@@ -164,7 +173,7 @@ acpi_extract_package (
164 /* 173 /*
165 * Extract package data. 174 * Extract package data.
166 */ 175 */
167 for (i=0; i<format_count; i++) { 176 for (i = 0; i < format_count; i++) {
168 177
169 u8 **pointer = NULL; 178 u8 **pointer = NULL;
170 union acpi_object *element = &(package->package.elements[i]); 179 union acpi_object *element = &(package->package.elements[i]);
@@ -178,14 +187,16 @@ acpi_extract_package (
178 case ACPI_TYPE_INTEGER: 187 case ACPI_TYPE_INTEGER:
179 switch (format_string[i]) { 188 switch (format_string[i]) {
180 case 'N': 189 case 'N':
181 *((acpi_integer*)head) = element->integer.value; 190 *((acpi_integer *) head) =
191 element->integer.value;
182 head += sizeof(acpi_integer); 192 head += sizeof(acpi_integer);
183 break; 193 break;
184 case 'S': 194 case 'S':
185 pointer = (u8**)head; 195 pointer = (u8 **) head;
186 *pointer = tail; 196 *pointer = tail;
187 *((acpi_integer*)tail) = element->integer.value; 197 *((acpi_integer *) tail) =
188 head += sizeof(acpi_integer*); 198 element->integer.value;
199 head += sizeof(acpi_integer *);
189 tail += sizeof(acpi_integer); 200 tail += sizeof(acpi_integer);
190 /* NULL terminate string */ 201 /* NULL terminate string */
191 *tail = (char)0; 202 *tail = (char)0;
@@ -201,20 +212,22 @@ acpi_extract_package (
201 case ACPI_TYPE_BUFFER: 212 case ACPI_TYPE_BUFFER:
202 switch (format_string[i]) { 213 switch (format_string[i]) {
203 case 'S': 214 case 'S':
204 pointer = (u8**)head; 215 pointer = (u8 **) head;
205 *pointer = tail; 216 *pointer = tail;
206 memcpy(tail, element->string.pointer, element->string.length); 217 memcpy(tail, element->string.pointer,
207 head += sizeof(char*); 218 element->string.length);
219 head += sizeof(char *);
208 tail += element->string.length * sizeof(char); 220 tail += element->string.length * sizeof(char);
209 /* NULL terminate string */ 221 /* NULL terminate string */
210 *tail = (char)0; 222 *tail = (char)0;
211 tail += sizeof(char); 223 tail += sizeof(char);
212 break; 224 break;
213 case 'B': 225 case 'B':
214 pointer = (u8**)head; 226 pointer = (u8 **) head;
215 *pointer = tail; 227 *pointer = tail;
216 memcpy(tail, element->buffer.pointer, element->buffer.length); 228 memcpy(tail, element->buffer.pointer,
217 head += sizeof(u8*); 229 element->buffer.length);
230 head += sizeof(u8 *);
218 tail += element->buffer.length * sizeof(u8); 231 tail += element->buffer.length * sizeof(u8);
219 break; 232 break;
220 default: 233 default:
@@ -233,19 +246,17 @@ acpi_extract_package (
233 246
234 return_ACPI_STATUS(AE_OK); 247 return_ACPI_STATUS(AE_OK);
235} 248}
236EXPORT_SYMBOL(acpi_extract_package);
237 249
250EXPORT_SYMBOL(acpi_extract_package);
238 251
239acpi_status 252acpi_status
240acpi_evaluate_integer ( 253acpi_evaluate_integer(acpi_handle handle,
241 acpi_handle handle, 254 acpi_string pathname,
242 acpi_string pathname, 255 struct acpi_object_list *arguments, unsigned long *data)
243 struct acpi_object_list *arguments,
244 unsigned long *data)
245{ 256{
246 acpi_status status = AE_OK; 257 acpi_status status = AE_OK;
247 union acpi_object *element; 258 union acpi_object *element;
248 struct acpi_buffer buffer = {0,NULL}; 259 struct acpi_buffer buffer = { 0, NULL };
249 260
250 ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); 261 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
251 262
@@ -253,7 +264,7 @@ acpi_evaluate_integer (
253 return_ACPI_STATUS(AE_BAD_PARAMETER); 264 return_ACPI_STATUS(AE_BAD_PARAMETER);
254 265
255 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 266 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
256 if(!element) 267 if (!element)
257 return_ACPI_STATUS(AE_NO_MEMORY); 268 return_ACPI_STATUS(AE_NO_MEMORY);
258 269
259 memset(element, 0, sizeof(union acpi_object)); 270 memset(element, 0, sizeof(union acpi_object));
@@ -277,20 +288,18 @@ acpi_evaluate_integer (
277 288
278 return_ACPI_STATUS(AE_OK); 289 return_ACPI_STATUS(AE_OK);
279} 290}
280EXPORT_SYMBOL(acpi_evaluate_integer);
281 291
292EXPORT_SYMBOL(acpi_evaluate_integer);
282 293
283#if 0 294#if 0
284acpi_status 295acpi_status
285acpi_evaluate_string ( 296acpi_evaluate_string(acpi_handle handle,
286 acpi_handle handle, 297 acpi_string pathname,
287 acpi_string pathname, 298 acpi_object_list * arguments, acpi_string * data)
288 acpi_object_list *arguments,
289 acpi_string *data)
290{ 299{
291 acpi_status status = AE_OK; 300 acpi_status status = AE_OK;
292 acpi_object *element = NULL; 301 acpi_object *element = NULL;
293 acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 302 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
294 303
295 ACPI_FUNCTION_TRACE("acpi_evaluate_string"); 304 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
296 305
@@ -305,9 +314,9 @@ acpi_evaluate_string (
305 314
306 element = (acpi_object *) buffer.pointer; 315 element = (acpi_object *) buffer.pointer;
307 316
308 if ((element->type != ACPI_TYPE_STRING) 317 if ((element->type != ACPI_TYPE_STRING)
309 || (element->type != ACPI_TYPE_BUFFER) 318 || (element->type != ACPI_TYPE_BUFFER)
310 || !element->string.length) { 319 || !element->string.length) {
311 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
312 return_ACPI_STATUS(AE_BAD_DATA); 321 return_ACPI_STATUS(AE_BAD_DATA);
313 } 322 }
@@ -329,19 +338,17 @@ acpi_evaluate_string (
329} 338}
330#endif 339#endif
331 340
332
333acpi_status 341acpi_status
334acpi_evaluate_reference ( 342acpi_evaluate_reference(acpi_handle handle,
335 acpi_handle handle, 343 acpi_string pathname,
336 acpi_string pathname, 344 struct acpi_object_list *arguments,
337 struct acpi_object_list *arguments, 345 struct acpi_handle_list *list)
338 struct acpi_handle_list *list)
339{ 346{
340 acpi_status status = AE_OK; 347 acpi_status status = AE_OK;
341 union acpi_object *package = NULL; 348 union acpi_object *package = NULL;
342 union acpi_object *element = NULL; 349 union acpi_object *element = NULL;
343 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
344 u32 i = 0; 351 u32 i = 0;
345 352
346 ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); 353 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
347 354
@@ -355,28 +362,28 @@ acpi_evaluate_reference (
355 if (ACPI_FAILURE(status)) 362 if (ACPI_FAILURE(status))
356 goto end; 363 goto end;
357 364
358 package = (union acpi_object *) buffer.pointer; 365 package = (union acpi_object *)buffer.pointer;
359 366
360 if ((buffer.length == 0) || !package) { 367 if ((buffer.length == 0) || !package) {
361 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 368 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
362 "No return object (len %X ptr %p)\n", 369 "No return object (len %X ptr %p)\n",
363 (unsigned)buffer.length, package)); 370 (unsigned)buffer.length, package));
364 status = AE_BAD_DATA; 371 status = AE_BAD_DATA;
365 acpi_util_eval_error(handle, pathname, status); 372 acpi_util_eval_error(handle, pathname, status);
366 goto end; 373 goto end;
367 } 374 }
368 if (package->type != ACPI_TYPE_PACKAGE) { 375 if (package->type != ACPI_TYPE_PACKAGE) {
369 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
370 "Expecting a [Package], found type %X\n", 377 "Expecting a [Package], found type %X\n",
371 package->type)); 378 package->type));
372 status = AE_BAD_DATA; 379 status = AE_BAD_DATA;
373 acpi_util_eval_error(handle, pathname, status); 380 acpi_util_eval_error(handle, pathname, status);
374 goto end; 381 goto end;
375 } 382 }
376 if (!package->package.count) { 383 if (!package->package.count) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
378 "[Package] has zero elements (%p)\n", 385 "[Package] has zero elements (%p)\n",
379 package)); 386 package));
380 status = AE_BAD_DATA; 387 status = AE_BAD_DATA;
381 acpi_util_eval_error(handle, pathname, status); 388 acpi_util_eval_error(handle, pathname, status);
382 goto end; 389 goto end;
@@ -395,9 +402,9 @@ acpi_evaluate_reference (
395 402
396 if (element->type != ACPI_TYPE_ANY) { 403 if (element->type != ACPI_TYPE_ANY) {
397 status = AE_BAD_DATA; 404 status = AE_BAD_DATA;
398 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 405 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
399 "Expecting a [Reference] package element, found type %X\n", 406 "Expecting a [Reference] package element, found type %X\n",
400 element->type)); 407 element->type));
401 acpi_util_eval_error(handle, pathname, status); 408 acpi_util_eval_error(handle, pathname, status);
402 break; 409 break;
403 } 410 }
@@ -406,10 +413,10 @@ acpi_evaluate_reference (
406 413
407 list->handles[i] = element->reference.handle; 414 list->handles[i] = element->reference.handle;
408 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", 415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
409 list->handles[i])); 416 list->handles[i]));
410 } 417 }
411 418
412end: 419 end:
413 if (ACPI_FAILURE(status)) { 420 if (ACPI_FAILURE(status)) {
414 list->count = 0; 421 list->count = 0;
415 //kfree(list->handles); 422 //kfree(list->handles);
@@ -419,5 +426,5 @@ end:
419 426
420 return_ACPI_STATUS(status); 427 return_ACPI_STATUS(status);
421} 428}
422EXPORT_SYMBOL(acpi_evaluate_reference);
423 429
430EXPORT_SYMBOL(acpi_evaluate_reference);