aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r--drivers/acpi/utils.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index a5da4efab063..1930e1a75b22 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -58,22 +58,21 @@ acpi_extract_package(union acpi_object *package,
58 u8 *head = NULL; 58 u8 *head = NULL;
59 u8 *tail = NULL; 59 u8 *tail = NULL;
60 60
61 ACPI_FUNCTION_TRACE("acpi_extract_package");
62 61
63 if (!package || (package->type != ACPI_TYPE_PACKAGE) 62 if (!package || (package->type != ACPI_TYPE_PACKAGE)
64 || (package->package.count < 1)) { 63 || (package->package.count < 1)) {
65 printk(KERN_WARNING PREFIX "Invalid package argument\n"); 64 printk(KERN_WARNING PREFIX "Invalid package argument\n");
66 return_ACPI_STATUS(AE_BAD_PARAMETER); 65 return AE_BAD_PARAMETER;
67 } 66 }
68 67
69 if (!format || !format->pointer || (format->length < 1)) { 68 if (!format || !format->pointer || (format->length < 1)) {
70 printk(KERN_WARNING PREFIX "Invalid format argument\n"); 69 printk(KERN_WARNING PREFIX "Invalid format argument\n");
71 return_ACPI_STATUS(AE_BAD_PARAMETER); 70 return AE_BAD_PARAMETER;
72 } 71 }
73 72
74 if (!buffer) { 73 if (!buffer) {
75 printk(KERN_WARNING PREFIX "Invalid buffer argument\n"); 74 printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
76 return_ACPI_STATUS(AE_BAD_PARAMETER); 75 return AE_BAD_PARAMETER;
77 } 76 }
78 77
79 format_count = (format->length / sizeof(char)) - 1; 78 format_count = (format->length / sizeof(char)) - 1;
@@ -81,7 +80,7 @@ acpi_extract_package(union acpi_object *package,
81 printk(KERN_WARNING PREFIX "Format specifies more objects [%d]" 80 printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
82 " than exist in package [%d].\n", 81 " than exist in package [%d].\n",
83 format_count, package->package.count); 82 format_count, package->package.count);
84 return_ACPI_STATUS(AE_BAD_DATA); 83 return AE_BAD_DATA;
85 } 84 }
86 85
87 format_string = (char *)format->pointer; 86 format_string = (char *)format->pointer;
@@ -94,7 +93,7 @@ acpi_extract_package(union acpi_object *package,
94 union acpi_object *element = &(package->package.elements[i]); 93 union acpi_object *element = &(package->package.elements[i]);
95 94
96 if (!element) { 95 if (!element) {
97 return_ACPI_STATUS(AE_BAD_DATA); 96 return AE_BAD_DATA;
98 } 97 }
99 98
100 switch (element->type) { 99 switch (element->type) {
@@ -116,7 +115,7 @@ acpi_extract_package(union acpi_object *package,
116 " [%d]: got number, expecing" 115 " [%d]: got number, expecing"
117 " [%c]\n", 116 " [%c]\n",
118 i, format_string[i]); 117 i, format_string[i]);
119 return_ACPI_STATUS(AE_BAD_DATA); 118 return AE_BAD_DATA;
120 break; 119 break;
121 } 120 }
122 break; 121 break;
@@ -142,7 +141,7 @@ acpi_extract_package(union acpi_object *package,
142 " [%d] got string/buffer," 141 " [%d] got string/buffer,"
143 " expecing [%c]\n", 142 " expecing [%c]\n",
144 i, format_string[i]); 143 i, format_string[i]);
145 return_ACPI_STATUS(AE_BAD_DATA); 144 return AE_BAD_DATA;
146 break; 145 break;
147 } 146 }
148 break; 147 break;
@@ -153,7 +152,7 @@ acpi_extract_package(union acpi_object *package,
153 "Found unsupported element at index=%d\n", 152 "Found unsupported element at index=%d\n",
154 i)); 153 i));
155 /* TBD: handle nested packages... */ 154 /* TBD: handle nested packages... */
156 return_ACPI_STATUS(AE_SUPPORT); 155 return AE_SUPPORT;
157 break; 156 break;
158 } 157 }
159 } 158 }
@@ -163,9 +162,9 @@ acpi_extract_package(union acpi_object *package,
163 */ 162 */
164 if (buffer->length < size_required) { 163 if (buffer->length < size_required) {
165 buffer->length = size_required; 164 buffer->length = size_required;
166 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 165 return AE_BUFFER_OVERFLOW;
167 } else if (buffer->length != size_required || !buffer->pointer) { 166 } else if (buffer->length != size_required || !buffer->pointer) {
168 return_ACPI_STATUS(AE_BAD_PARAMETER); 167 return AE_BAD_PARAMETER;
169 } 168 }
170 169
171 head = buffer->pointer; 170 head = buffer->pointer;
@@ -180,7 +179,7 @@ acpi_extract_package(union acpi_object *package,
180 union acpi_object *element = &(package->package.elements[i]); 179 union acpi_object *element = &(package->package.elements[i]);
181 180
182 if (!element) { 181 if (!element) {
183 return_ACPI_STATUS(AE_BAD_DATA); 182 return AE_BAD_DATA;
184 } 183 }
185 184
186 switch (element->type) { 185 switch (element->type) {
@@ -245,7 +244,7 @@ acpi_extract_package(union acpi_object *package,
245 } 244 }
246 } 245 }
247 246
248 return_ACPI_STATUS(AE_OK); 247 return AE_OK;
249} 248}
250 249
251EXPORT_SYMBOL(acpi_extract_package); 250EXPORT_SYMBOL(acpi_extract_package);
@@ -259,14 +258,13 @@ acpi_evaluate_integer(acpi_handle handle,
259 union acpi_object *element; 258 union acpi_object *element;
260 struct acpi_buffer buffer = { 0, NULL }; 259 struct acpi_buffer buffer = { 0, NULL };
261 260
262 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
263 261
264 if (!data) 262 if (!data)
265 return_ACPI_STATUS(AE_BAD_PARAMETER); 263 return AE_BAD_PARAMETER;
266 264
267 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 265 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
268 if (!element) 266 if (!element)
269 return_ACPI_STATUS(AE_NO_MEMORY); 267 return AE_NO_MEMORY;
270 268
271 memset(element, 0, sizeof(union acpi_object)); 269 memset(element, 0, sizeof(union acpi_object));
272 buffer.length = sizeof(union acpi_object); 270 buffer.length = sizeof(union acpi_object);
@@ -275,13 +273,13 @@ acpi_evaluate_integer(acpi_handle handle,
275 if (ACPI_FAILURE(status)) { 273 if (ACPI_FAILURE(status)) {
276 acpi_util_eval_error(handle, pathname, status); 274 acpi_util_eval_error(handle, pathname, status);
277 kfree(element); 275 kfree(element);
278 return_ACPI_STATUS(status); 276 return status;
279 } 277 }
280 278
281 if (element->type != ACPI_TYPE_INTEGER) { 279 if (element->type != ACPI_TYPE_INTEGER) {
282 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 280 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
283 kfree(element); 281 kfree(element);
284 return_ACPI_STATUS(AE_BAD_DATA); 282 return AE_BAD_DATA;
285 } 283 }
286 284
287 *data = element->integer.value; 285 *data = element->integer.value;
@@ -289,7 +287,7 @@ acpi_evaluate_integer(acpi_handle handle,
289 287
290 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); 288 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
291 289
292 return_ACPI_STATUS(AE_OK); 290 return AE_OK;
293} 291}
294 292
295EXPORT_SYMBOL(acpi_evaluate_integer); 293EXPORT_SYMBOL(acpi_evaluate_integer);
@@ -304,15 +302,14 @@ acpi_evaluate_string(acpi_handle handle,
304 acpi_object *element = NULL; 302 acpi_object *element = NULL;
305 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 303 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
306 304
307 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
308 305
309 if (!data) 306 if (!data)
310 return_ACPI_STATUS(AE_BAD_PARAMETER); 307 return AE_BAD_PARAMETER;
311 308
312 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); 309 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
313 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
314 acpi_util_eval_error(handle, pathname, status); 311 acpi_util_eval_error(handle, pathname, status);
315 return_ACPI_STATUS(status); 312 return status;
316 } 313 }
317 314
318 element = (acpi_object *) buffer.pointer; 315 element = (acpi_object *) buffer.pointer;
@@ -321,13 +318,13 @@ acpi_evaluate_string(acpi_handle handle,
321 || (element->type != ACPI_TYPE_BUFFER) 318 || (element->type != ACPI_TYPE_BUFFER)
322 || !element->string.length) { 319 || !element->string.length) {
323 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
324 return_ACPI_STATUS(AE_BAD_DATA); 321 return AE_BAD_DATA;
325 } 322 }
326 323
327 *data = kmalloc(element->string.length + 1, GFP_KERNEL); 324 *data = kmalloc(element->string.length + 1, GFP_KERNEL);
328 if (!data) { 325 if (!data) {
329 printk(KERN_ERR PREFIX "Memory allocation\n"); 326 printk(KERN_ERR PREFIX "Memory allocation\n");
330 return_VALUE(-ENOMEM); 327 return -ENOMEM;
331 } 328 }
332 memset(*data, 0, element->string.length + 1); 329 memset(*data, 0, element->string.length + 1);
333 330
@@ -337,7 +334,7 @@ acpi_evaluate_string(acpi_handle handle,
337 334
338 acpi_os_free(buffer.pointer); 335 acpi_os_free(buffer.pointer);
339 336
340 return_ACPI_STATUS(AE_OK); 337 return AE_OK;
341} 338}
342#endif 339#endif
343 340
@@ -353,10 +350,9 @@ acpi_evaluate_reference(acpi_handle handle,
353 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
354 u32 i = 0; 351 u32 i = 0;
355 352
356 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
357 353
358 if (!list) { 354 if (!list) {
359 return_ACPI_STATUS(AE_BAD_PARAMETER); 355 return AE_BAD_PARAMETER;
360 } 356 }
361 357
362 /* Evaluate object. */ 358 /* Evaluate object. */
@@ -390,7 +386,7 @@ acpi_evaluate_reference(acpi_handle handle,
390 } 386 }
391 387
392 if (package->package.count > ACPI_MAX_HANDLES) { 388 if (package->package.count > ACPI_MAX_HANDLES) {
393 return_ACPI_STATUS(AE_NO_MEMORY); 389 return AE_NO_MEMORY;
394 } 390 }
395 list->count = package->package.count; 391 list->count = package->package.count;
396 392
@@ -424,7 +420,7 @@ acpi_evaluate_reference(acpi_handle handle,
424 420
425 acpi_os_free(buffer.pointer); 421 acpi_os_free(buffer.pointer);
426 422
427 return_ACPI_STATUS(status); 423 return status;
428} 424}
429 425
430EXPORT_SYMBOL(acpi_evaluate_reference); 426EXPORT_SYMBOL(acpi_evaluate_reference);