utils.c (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) utils.c (4be44fcd3bf648b782f4460fd06dfae6c42ded4b)
1/*
2 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *

--- 16 unchanged lines hidden (view full) ---

25
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/types.h>
30#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h>
32
1/*
2 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *

--- 16 unchanged lines hidden (view full) ---

25
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/types.h>
30#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h>
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
35
37
38/* --------------------------------------------------------------------------
39 Object Evaluation Helpers
40 -------------------------------------------------------------------------- */
36/* --------------------------------------------------------------------------
37 Object Evaluation Helpers
38 -------------------------------------------------------------------------- */
41
42#ifdef ACPI_DEBUG_OUTPUT
43#define acpi_util_eval_error(h,p,s) {\
44 char prefix[80] = {'\0'};\
45 struct acpi_buffer buffer = {sizeof(prefix), prefix};\
46 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
47 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\
48 (char *) prefix, p, acpi_format_exception(s))); }
49#else
50#define acpi_util_eval_error(h,p,s)
51#endif
39#ifdef ACPI_DEBUG_OUTPUT
40#define acpi_util_eval_error(h,p,s) {\
41 char prefix[80] = {'\0'};\
42 struct acpi_buffer buffer = {sizeof(prefix), prefix};\
43 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
44 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\
45 (char *) prefix, p, acpi_format_exception(s))); }
46#else
47#define acpi_util_eval_error(h,p,s)
48#endif
52
53
54acpi_status
49acpi_status
55acpi_extract_package (
56 union acpi_object *package,
57 struct acpi_buffer *format,
58 struct acpi_buffer *buffer)
50acpi_extract_package(union acpi_object *package,
51 struct acpi_buffer *format, struct acpi_buffer *buffer)
59{
52{
60 u32 size_required = 0;
61 u32 tail_offset = 0;
62 char *format_string = NULL;
63 u32 format_count = 0;
64 u32 i = 0;
65 u8 *head = NULL;
66 u8 *tail = NULL;
53 u32 size_required = 0;
54 u32 tail_offset = 0;
55 char *format_string = NULL;
56 u32 format_count = 0;
57 u32 i = 0;
58 u8 *head = NULL;
59 u8 *tail = NULL;
67
68 ACPI_FUNCTION_TRACE("acpi_extract_package");
69
60
61 ACPI_FUNCTION_TRACE("acpi_extract_package");
62
70 if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) {
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n"));
63 if (!package || (package->type != ACPI_TYPE_PACKAGE)
64 || (package->package.count < 1)) {
65 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
66 "Invalid 'package' argument\n"));
72 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 }
74
75 if (!format || !format->pointer || (format->length < 1)) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
77 return_ACPI_STATUS(AE_BAD_PARAMETER);
78 }
79
80 if (!buffer) {
81 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
82 return_ACPI_STATUS(AE_BAD_PARAMETER);
83 }
84
67 return_ACPI_STATUS(AE_BAD_PARAMETER);
68 }
69
70 if (!format || !format->pointer || (format->length < 1)) {
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
72 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 }
74
75 if (!buffer) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
77 return_ACPI_STATUS(AE_BAD_PARAMETER);
78 }
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);
89 }
90
85 return_ACPI_STATUS(AE_BAD_DATA);
86 }
87
91 format_string = (char*)format->pointer;
88 format_string = (char *)format->pointer;
92
93 /*
94 * Calculate size_required.
95 */
89
90 /*
91 * Calculate size_required.
92 */
96 for (i=0; i<format_count; i++) {
93 for (i = 0; i < format_count; i++) {
97
98 union acpi_object *element = &(package->package.elements[i]);
99
100 if (!element) {
101 return_ACPI_STATUS(AE_BAD_DATA);
102 }
103
104 switch (element->type) {
105
106 case ACPI_TYPE_INTEGER:
107 switch (format_string[i]) {
108 case 'N':
109 size_required += sizeof(acpi_integer);
110 tail_offset += sizeof(acpi_integer);
111 break;
112 case 'S':
94
95 union acpi_object *element = &(package->package.elements[i]);
96
97 if (!element) {
98 return_ACPI_STATUS(AE_BAD_DATA);
99 }
100
101 switch (element->type) {
102
103 case ACPI_TYPE_INTEGER:
104 switch (format_string[i]) {
105 case 'N':
106 size_required += sizeof(acpi_integer);
107 tail_offset += sizeof(acpi_integer);
108 break;
109 case 'S':
113 size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char);
114 tail_offset += sizeof(char*);
110 size_required +=
111 sizeof(char *) + sizeof(acpi_integer) +
112 sizeof(char);
113 tail_offset += sizeof(char *);
115 break;
116 default:
114 break;
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 break;
120 }
121 break;
122
123 case ACPI_TYPE_STRING:
124 case ACPI_TYPE_BUFFER:
125 switch (format_string[i]) {
126 case 'S':
119 return_ACPI_STATUS(AE_BAD_DATA);
120 break;
121 }
122 break;
123
124 case ACPI_TYPE_STRING:
125 case ACPI_TYPE_BUFFER:
126 switch (format_string[i]) {
127 case 'S':
127 size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char);
128 tail_offset += sizeof(char*);
128 size_required +=
129 sizeof(char *) +
130 (element->string.length * sizeof(char)) +
131 sizeof(char);
132 tail_offset += sizeof(char *);
129 break;
130 case 'B':
133 break;
134 case 'B':
131 size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8));
132 tail_offset += sizeof(u8*);
135 size_required +=
136 sizeof(u8 *) +
137 (element->buffer.length * sizeof(u8));
138 tail_offset += sizeof(u8 *);
133 break;
134 default:
139 break;
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);
137 break;
138 }
139 break;
140
141 case ACPI_TYPE_PACKAGE:
142 default:
144 return_ACPI_STATUS(AE_BAD_DATA);
145 break;
146 }
147 break;
148
149 case ACPI_TYPE_PACKAGE:
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... */
145 return_ACPI_STATUS(AE_SUPPORT);
146 break;
147 }
148 }
149
150 /*
151 * Validate output buffer.
152 */
153 if (buffer->length < size_required) {
154 buffer->length = size_required;
155 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
154 /* TBD: handle nested packages... */
155 return_ACPI_STATUS(AE_SUPPORT);
156 break;
157 }
158 }
159
160 /*
161 * Validate output buffer.
162 */
163 if (buffer->length < size_required) {
164 buffer->length = size_required;
165 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
156 }
157 else if (buffer->length != size_required || !buffer->pointer) {
166 } else if (buffer->length != size_required || !buffer->pointer) {
158 return_ACPI_STATUS(AE_BAD_PARAMETER);
159 }
160
161 head = buffer->pointer;
162 tail = buffer->pointer + tail_offset;
163
164 /*
165 * Extract package data.
166 */
167 return_ACPI_STATUS(AE_BAD_PARAMETER);
168 }
169
170 head = buffer->pointer;
171 tail = buffer->pointer + tail_offset;
172
173 /*
174 * Extract package data.
175 */
167 for (i=0; i<format_count; i++) {
176 for (i = 0; i < format_count; i++) {
168
169 u8 **pointer = NULL;
170 union acpi_object *element = &(package->package.elements[i]);
171
172 if (!element) {
173 return_ACPI_STATUS(AE_BAD_DATA);
174 }
175
176 switch (element->type) {
177
178 case ACPI_TYPE_INTEGER:
179 switch (format_string[i]) {
180 case 'N':
177
178 u8 **pointer = NULL;
179 union acpi_object *element = &(package->package.elements[i]);
180
181 if (!element) {
182 return_ACPI_STATUS(AE_BAD_DATA);
183 }
184
185 switch (element->type) {
186
187 case ACPI_TYPE_INTEGER:
188 switch (format_string[i]) {
189 case 'N':
181 *((acpi_integer*)head) = element->integer.value;
190 *((acpi_integer *) head) =
191 element->integer.value;
182 head += sizeof(acpi_integer);
183 break;
184 case 'S':
192 head += sizeof(acpi_integer);
193 break;
194 case 'S':
185 pointer = (u8**)head;
195 pointer = (u8 **) head;
186 *pointer = tail;
196 *pointer = tail;
187 *((acpi_integer*)tail) = element->integer.value;
188 head += sizeof(acpi_integer*);
197 *((acpi_integer *) tail) =
198 element->integer.value;
199 head += sizeof(acpi_integer *);
189 tail += sizeof(acpi_integer);
190 /* NULL terminate string */
191 *tail = (char)0;
192 tail += sizeof(char);
193 break;
194 default:
195 /* Should never get here */
196 break;
197 }
198 break;
199
200 case ACPI_TYPE_STRING:
201 case ACPI_TYPE_BUFFER:
202 switch (format_string[i]) {
203 case 'S':
200 tail += sizeof(acpi_integer);
201 /* NULL terminate string */
202 *tail = (char)0;
203 tail += sizeof(char);
204 break;
205 default:
206 /* Should never get here */
207 break;
208 }
209 break;
210
211 case ACPI_TYPE_STRING:
212 case ACPI_TYPE_BUFFER:
213 switch (format_string[i]) {
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);
207 head += sizeof(char*);
217 memcpy(tail, element->string.pointer,
218 element->string.length);
219 head += sizeof(char *);
208 tail += element->string.length * sizeof(char);
209 /* NULL terminate string */
210 *tail = (char)0;
211 tail += sizeof(char);
212 break;
213 case 'B':
220 tail += element->string.length * sizeof(char);
221 /* NULL terminate string */
222 *tail = (char)0;
223 tail += sizeof(char);
224 break;
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);
217 head += sizeof(u8*);
228 memcpy(tail, element->buffer.pointer,
229 element->buffer.length);
230 head += sizeof(u8 *);
218 tail += element->buffer.length * sizeof(u8);
219 break;
220 default:
221 /* Should never get here */
222 break;
223 }
224 break;
225
226 case ACPI_TYPE_PACKAGE:
227 /* TBD: handle nested packages... */
228 default:
229 /* Should never get here */
230 break;
231 }
232 }
233
234 return_ACPI_STATUS(AE_OK);
235}
231 tail += element->buffer.length * sizeof(u8);
232 break;
233 default:
234 /* Should never get here */
235 break;
236 }
237 break;
238
239 case ACPI_TYPE_PACKAGE:
240 /* TBD: handle nested packages... */
241 default:
242 /* Should never get here */
243 break;
244 }
245 }
246
247 return_ACPI_STATUS(AE_OK);
248}
249
236EXPORT_SYMBOL(acpi_extract_package);
237
250EXPORT_SYMBOL(acpi_extract_package);
251
238
239acpi_status
252acpi_status
240acpi_evaluate_integer (
241 acpi_handle handle,
242 acpi_string pathname,
243 struct acpi_object_list *arguments,
244 unsigned long *data)
253acpi_evaluate_integer(acpi_handle handle,
254 acpi_string pathname,
255 struct acpi_object_list *arguments, unsigned long *data)
245{
256{
246 acpi_status status = AE_OK;
247 union acpi_object *element;
248 struct acpi_buffer buffer = {0,NULL};
257 acpi_status status = AE_OK;
258 union acpi_object *element;
259 struct acpi_buffer buffer = { 0, NULL };
249
250 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
251
252 if (!data)
253 return_ACPI_STATUS(AE_BAD_PARAMETER);
254
255 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
260
261 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
262
263 if (!data)
264 return_ACPI_STATUS(AE_BAD_PARAMETER);
265
266 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
256 if(!element)
267 if (!element)
257 return_ACPI_STATUS(AE_NO_MEMORY);
258
259 memset(element, 0, sizeof(union acpi_object));
260 buffer.length = sizeof(union acpi_object);
261 buffer.pointer = element;
262 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
263 if (ACPI_FAILURE(status)) {
264 acpi_util_eval_error(handle, pathname, status);

--- 7 unchanged lines hidden (view full) ---

272
273 *data = element->integer.value;
274 kfree(element);
275
276 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
277
278 return_ACPI_STATUS(AE_OK);
279}
268 return_ACPI_STATUS(AE_NO_MEMORY);
269
270 memset(element, 0, sizeof(union acpi_object));
271 buffer.length = sizeof(union acpi_object);
272 buffer.pointer = element;
273 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
274 if (ACPI_FAILURE(status)) {
275 acpi_util_eval_error(handle, pathname, status);

--- 7 unchanged lines hidden (view full) ---

283
284 *data = element->integer.value;
285 kfree(element);
286
287 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
288
289 return_ACPI_STATUS(AE_OK);
290}
291
280EXPORT_SYMBOL(acpi_evaluate_integer);
281
292EXPORT_SYMBOL(acpi_evaluate_integer);
293
282
283#if 0
284acpi_status
294#if 0
295acpi_status
285acpi_evaluate_string (
286 acpi_handle handle,
287 acpi_string pathname,
288 acpi_object_list *arguments,
289 acpi_string *data)
296acpi_evaluate_string(acpi_handle handle,
297 acpi_string pathname,
298 acpi_object_list * arguments, acpi_string * data)
290{
299{
291 acpi_status status = AE_OK;
292 acpi_object *element = NULL;
293 acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
300 acpi_status status = AE_OK;
301 acpi_object *element = NULL;
302 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
294
295 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
296
297 if (!data)
298 return_ACPI_STATUS(AE_BAD_PARAMETER);
299
300 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
301 if (ACPI_FAILURE(status)) {
302 acpi_util_eval_error(handle, pathname, status);
303 return_ACPI_STATUS(status);
304 }
305
306 element = (acpi_object *) buffer.pointer;
307
303
304 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
305
306 if (!data)
307 return_ACPI_STATUS(AE_BAD_PARAMETER);
308
309 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
310 if (ACPI_FAILURE(status)) {
311 acpi_util_eval_error(handle, pathname, status);
312 return_ACPI_STATUS(status);
313 }
314
315 element = (acpi_object *) buffer.pointer;
316
308 if ((element->type != ACPI_TYPE_STRING)
309 || (element->type != ACPI_TYPE_BUFFER)
310 || !element->string.length) {
317 if ((element->type != ACPI_TYPE_STRING)
318 || (element->type != ACPI_TYPE_BUFFER)
319 || !element->string.length) {
311 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
312 return_ACPI_STATUS(AE_BAD_DATA);
313 }
314
315 *data = kmalloc(element->string.length + 1, GFP_KERNEL);
316 if (!data) {
317 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
318 return_VALUE(-ENOMEM);

--- 5 unchanged lines hidden (view full) ---

324 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data));
325
326 acpi_os_free(buffer.pointer);
327
328 return_ACPI_STATUS(AE_OK);
329}
330#endif
331
320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
321 return_ACPI_STATUS(AE_BAD_DATA);
322 }
323
324 *data = kmalloc(element->string.length + 1, GFP_KERNEL);
325 if (!data) {
326 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
327 return_VALUE(-ENOMEM);

--- 5 unchanged lines hidden (view full) ---

333 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data));
334
335 acpi_os_free(buffer.pointer);
336
337 return_ACPI_STATUS(AE_OK);
338}
339#endif
340
332
333acpi_status
341acpi_status
334acpi_evaluate_reference (
335 acpi_handle handle,
336 acpi_string pathname,
337 struct acpi_object_list *arguments,
338 struct acpi_handle_list *list)
342acpi_evaluate_reference(acpi_handle handle,
343 acpi_string pathname,
344 struct acpi_object_list *arguments,
345 struct acpi_handle_list *list)
339{
346{
340 acpi_status status = AE_OK;
341 union acpi_object *package = NULL;
342 union acpi_object *element = NULL;
343 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
344 u32 i = 0;
347 acpi_status status = AE_OK;
348 union acpi_object *package = NULL;
349 union acpi_object *element = NULL;
350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
351 u32 i = 0;
345
346 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
347
348 if (!list) {
349 return_ACPI_STATUS(AE_BAD_PARAMETER);
350 }
351
352 /* Evaluate object. */
353
354 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
355 if (ACPI_FAILURE(status))
356 goto end;
357
352
353 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
354
355 if (!list) {
356 return_ACPI_STATUS(AE_BAD_PARAMETER);
357 }
358
359 /* Evaluate object. */
360
361 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
362 if (ACPI_FAILURE(status))
363 goto end;
364
358 package = (union acpi_object *) buffer.pointer;
365 package = (union acpi_object *)buffer.pointer;
359
360 if ((buffer.length == 0) || !package) {
366
367 if ((buffer.length == 0) || !package) {
361 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
362 "No return object (len %X ptr %p)\n",
363 (unsigned)buffer.length, package));
368 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 "No return object (len %X ptr %p)\n",
370 (unsigned)buffer.length, package));
364 status = AE_BAD_DATA;
365 acpi_util_eval_error(handle, pathname, status);
366 goto end;
367 }
368 if (package->type != ACPI_TYPE_PACKAGE) {
371 status = AE_BAD_DATA;
372 acpi_util_eval_error(handle, pathname, status);
373 goto end;
374 }
375 if (package->type != ACPI_TYPE_PACKAGE) {
369 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
370 "Expecting a [Package], found type %X\n",
371 package->type));
376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
377 "Expecting a [Package], found type %X\n",
378 package->type));
372 status = AE_BAD_DATA;
373 acpi_util_eval_error(handle, pathname, status);
374 goto end;
375 }
376 if (!package->package.count) {
379 status = AE_BAD_DATA;
380 acpi_util_eval_error(handle, pathname, status);
381 goto end;
382 }
383 if (!package->package.count) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
378 "[Package] has zero elements (%p)\n",
379 package));
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "[Package] has zero elements (%p)\n",
386 package));
380 status = AE_BAD_DATA;
381 acpi_util_eval_error(handle, pathname, status);
382 goto end;
383 }
384
385 if (package->package.count > ACPI_MAX_HANDLES) {
386 return_ACPI_STATUS(AE_NO_MEMORY);
387 }
388 list->count = package->package.count;
389
390 /* Extract package data. */
391
392 for (i = 0; i < list->count; i++) {
393
394 element = &(package->package.elements[i]);
395
396 if (element->type != ACPI_TYPE_ANY) {
397 status = AE_BAD_DATA;
387 status = AE_BAD_DATA;
388 acpi_util_eval_error(handle, pathname, status);
389 goto end;
390 }
391
392 if (package->package.count > ACPI_MAX_HANDLES) {
393 return_ACPI_STATUS(AE_NO_MEMORY);
394 }
395 list->count = package->package.count;
396
397 /* Extract package data. */
398
399 for (i = 0; i < list->count; i++) {
400
401 element = &(package->package.elements[i]);
402
403 if (element->type != ACPI_TYPE_ANY) {
404 status = AE_BAD_DATA;
398 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
399 "Expecting a [Reference] package element, found type %X\n",
400 element->type));
405 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
406 "Expecting a [Reference] package element, found type %X\n",
407 element->type));
401 acpi_util_eval_error(handle, pathname, status);
402 break;
403 }
404
405 /* Get the acpi_handle. */
406
407 list->handles[i] = element->reference.handle;
408 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
408 acpi_util_eval_error(handle, pathname, status);
409 break;
410 }
411
412 /* Get the acpi_handle. */
413
414 list->handles[i] = element->reference.handle;
415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
409 list->handles[i]));
416 list->handles[i]));
410 }
411
417 }
418
412end:
419 end:
413 if (ACPI_FAILURE(status)) {
414 list->count = 0;
415 //kfree(list->handles);
416 }
417
418 acpi_os_free(buffer.pointer);
419
420 return_ACPI_STATUS(status);
421}
420 if (ACPI_FAILURE(status)) {
421 list->count = 0;
422 //kfree(list->handles);
423 }
424
425 acpi_os_free(buffer.pointer);
426
427 return_ACPI_STATUS(status);
428}
422EXPORT_SYMBOL(acpi_evaluate_reference);
423
429
430EXPORT_SYMBOL(acpi_evaluate_reference);