]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/acpi/utils.c
Merge tag 'pm+acpi-3.15-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafae...
[mirror_ubuntu-artful-kernel.git] / drivers / acpi / utils.c
CommitLineData
1da177e4
LT
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/kernel.h>
27#include <linux/module.h>
5a0e3ad6 28#include <linux/slab.h>
1da177e4
LT
29#include <linux/init.h>
30#include <linux/types.h>
fbfddae6
TK
31#include <linux/hardirq.h>
32#include <linux/acpi.h>
1da177e4 33
a192a958
LB
34#include "internal.h"
35
1da177e4 36#define _COMPONENT ACPI_BUS_COMPONENT
f52fd66d 37ACPI_MODULE_NAME("utils");
1da177e4
LT
38
39/* --------------------------------------------------------------------------
40 Object Evaluation Helpers
41 -------------------------------------------------------------------------- */
4fd7f518
HH
42static void
43acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s)
44{
1da177e4 45#ifdef ACPI_DEBUG_OUTPUT
4fd7f518
HH
46 char prefix[80] = {'\0'};
47 struct acpi_buffer buffer = {sizeof(prefix), prefix};
48 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);
49 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",
50 (char *) prefix, p, acpi_format_exception(s)));
1da177e4 51#else
4fd7f518 52 return;
1da177e4 53#endif
4fd7f518
HH
54}
55
1da177e4 56acpi_status
4be44fcd
LB
57acpi_extract_package(union acpi_object *package,
58 struct acpi_buffer *format, struct acpi_buffer *buffer)
1da177e4 59{
4be44fcd
LB
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;
1da177e4 67
1da177e4 68
4be44fcd
LB
69 if (!package || (package->type != ACPI_TYPE_PACKAGE)
70 || (package->package.count < 1)) {
cece9296 71 printk(KERN_WARNING PREFIX "Invalid package argument\n");
d550d98d 72 return AE_BAD_PARAMETER;
1da177e4
LT
73 }
74
75 if (!format || !format->pointer || (format->length < 1)) {
cece9296 76 printk(KERN_WARNING PREFIX "Invalid format argument\n");
d550d98d 77 return AE_BAD_PARAMETER;
1da177e4
LT
78 }
79
80 if (!buffer) {
cece9296 81 printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
d550d98d 82 return AE_BAD_PARAMETER;
1da177e4
LT
83 }
84
4be44fcd 85 format_count = (format->length / sizeof(char)) - 1;
1da177e4 86 if (format_count > package->package.count) {
cece9296
LB
87 printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
88 " than exist in package [%d].\n",
89 format_count, package->package.count);
d550d98d 90 return AE_BAD_DATA;
1da177e4
LT
91 }
92
50dd0969 93 format_string = format->pointer;
1da177e4
LT
94
95 /*
96 * Calculate size_required.
97 */
4be44fcd 98 for (i = 0; i < format_count; i++) {
1da177e4
LT
99
100 union acpi_object *element = &(package->package.elements[i]);
101
1da177e4
LT
102 switch (element->type) {
103
104 case ACPI_TYPE_INTEGER:
105 switch (format_string[i]) {
106 case 'N':
439913ff
LM
107 size_required += sizeof(u64);
108 tail_offset += sizeof(u64);
1da177e4
LT
109 break;
110 case 'S':
4be44fcd 111 size_required +=
439913ff 112 sizeof(char *) + sizeof(u64) +
4be44fcd
LB
113 sizeof(char);
114 tail_offset += sizeof(char *);
1da177e4
LT
115 break;
116 default:
cece9296 117 printk(KERN_WARNING PREFIX "Invalid package element"
e7e92ec9 118 " [%d]: got number, expecting"
cece9296
LB
119 " [%c]\n",
120 i, format_string[i]);
d550d98d 121 return AE_BAD_DATA;
1da177e4
LT
122 break;
123 }
124 break;
125
126 case ACPI_TYPE_STRING:
127 case ACPI_TYPE_BUFFER:
128 switch (format_string[i]) {
129 case 'S':
4be44fcd
LB
130 size_required +=
131 sizeof(char *) +
132 (element->string.length * sizeof(char)) +
133 sizeof(char);
134 tail_offset += sizeof(char *);
1da177e4
LT
135 break;
136 case 'B':
4be44fcd
LB
137 size_required +=
138 sizeof(u8 *) +
139 (element->buffer.length * sizeof(u8));
140 tail_offset += sizeof(u8 *);
1da177e4
LT
141 break;
142 default:
cece9296 143 printk(KERN_WARNING PREFIX "Invalid package element"
a6fc6720 144 " [%d] got string/buffer,"
e7e92ec9 145 " expecting [%c]\n",
cece9296 146 i, format_string[i]);
d550d98d 147 return AE_BAD_DATA;
1da177e4
LT
148 break;
149 }
150 break;
151
152 case ACPI_TYPE_PACKAGE:
153 default:
4be44fcd
LB
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
155 "Found unsupported element at index=%d\n",
156 i));
1da177e4 157 /* TBD: handle nested packages... */
d550d98d 158 return AE_SUPPORT;
1da177e4
LT
159 break;
160 }
161 }
162
163 /*
164 * Validate output buffer.
165 */
e83dda06
AS
166 if (buffer->length == ACPI_ALLOCATE_BUFFER) {
167 buffer->pointer = ACPI_ALLOCATE(size_required);
168 if (!buffer->pointer)
169 return AE_NO_MEMORY;
1da177e4 170 buffer->length = size_required;
e83dda06
AS
171 memset(buffer->pointer, 0, size_required);
172 } else {
173 if (buffer->length < size_required) {
174 buffer->length = size_required;
175 return AE_BUFFER_OVERFLOW;
176 } else if (buffer->length != size_required ||
177 !buffer->pointer) {
178 return AE_BAD_PARAMETER;
179 }
1da177e4
LT
180 }
181
182 head = buffer->pointer;
183 tail = buffer->pointer + tail_offset;
184
185 /*
186 * Extract package data.
187 */
4be44fcd 188 for (i = 0; i < format_count; i++) {
1da177e4
LT
189
190 u8 **pointer = NULL;
191 union acpi_object *element = &(package->package.elements[i]);
192
193 if (!element) {
d550d98d 194 return AE_BAD_DATA;
1da177e4
LT
195 }
196
197 switch (element->type) {
198
199 case ACPI_TYPE_INTEGER:
200 switch (format_string[i]) {
201 case 'N':
439913ff 202 *((u64 *) head) =
4be44fcd 203 element->integer.value;
439913ff 204 head += sizeof(u64);
1da177e4
LT
205 break;
206 case 'S':
4be44fcd 207 pointer = (u8 **) head;
1da177e4 208 *pointer = tail;
439913ff 209 *((u64 *) tail) =
4be44fcd 210 element->integer.value;
439913ff
LM
211 head += sizeof(u64 *);
212 tail += sizeof(u64);
1da177e4
LT
213 /* NULL terminate string */
214 *tail = (char)0;
215 tail += sizeof(char);
216 break;
217 default:
218 /* Should never get here */
219 break;
220 }
221 break;
222
223 case ACPI_TYPE_STRING:
224 case ACPI_TYPE_BUFFER:
225 switch (format_string[i]) {
226 case 'S':
4be44fcd 227 pointer = (u8 **) head;
1da177e4 228 *pointer = tail;
4be44fcd
LB
229 memcpy(tail, element->string.pointer,
230 element->string.length);
231 head += sizeof(char *);
1da177e4
LT
232 tail += element->string.length * sizeof(char);
233 /* NULL terminate string */
234 *tail = (char)0;
235 tail += sizeof(char);
236 break;
237 case 'B':
4be44fcd 238 pointer = (u8 **) head;
1da177e4 239 *pointer = tail;
4be44fcd
LB
240 memcpy(tail, element->buffer.pointer,
241 element->buffer.length);
242 head += sizeof(u8 *);
1da177e4
LT
243 tail += element->buffer.length * sizeof(u8);
244 break;
245 default:
246 /* Should never get here */
247 break;
248 }
249 break;
250
251 case ACPI_TYPE_PACKAGE:
252 /* TBD: handle nested packages... */
253 default:
254 /* Should never get here */
255 break;
256 }
257 }
258
d550d98d 259 return AE_OK;
1da177e4 260}
1da177e4 261
4be44fcd 262EXPORT_SYMBOL(acpi_extract_package);
1da177e4
LT
263
264acpi_status
4be44fcd
LB
265acpi_evaluate_integer(acpi_handle handle,
266 acpi_string pathname,
27663c58 267 struct acpi_object_list *arguments, unsigned long long *data)
1da177e4 268{
4be44fcd 269 acpi_status status = AE_OK;
40599072 270 union acpi_object element;
4be44fcd 271 struct acpi_buffer buffer = { 0, NULL };
1da177e4 272
1da177e4 273 if (!data)
d550d98d 274 return AE_BAD_PARAMETER;
1da177e4 275
1da177e4 276 buffer.length = sizeof(union acpi_object);
40599072 277 buffer.pointer = &element;
1da177e4
LT
278 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
279 if (ACPI_FAILURE(status)) {
280 acpi_util_eval_error(handle, pathname, status);
d550d98d 281 return status;
1da177e4
LT
282 }
283
40599072 284 if (element.type != ACPI_TYPE_INTEGER) {
1da177e4 285 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
d550d98d 286 return AE_BAD_DATA;
1da177e4
LT
287 }
288
40599072 289 *data = element.integer.value;
1da177e4 290
27663c58 291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data));
1da177e4 292
d550d98d 293 return AE_OK;
1da177e4 294}
1da177e4 295
4be44fcd 296EXPORT_SYMBOL(acpi_evaluate_integer);
1da177e4 297
1da177e4 298acpi_status
4be44fcd
LB
299acpi_evaluate_reference(acpi_handle handle,
300 acpi_string pathname,
301 struct acpi_object_list *arguments,
302 struct acpi_handle_list *list)
1da177e4 303{
4be44fcd
LB
304 acpi_status status = AE_OK;
305 union acpi_object *package = NULL;
306 union acpi_object *element = NULL;
307 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
308 u32 i = 0;
1da177e4 309
1da177e4
LT
310
311 if (!list) {
d550d98d 312 return AE_BAD_PARAMETER;
1da177e4
LT
313 }
314
315 /* Evaluate object. */
316
317 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
318 if (ACPI_FAILURE(status))
319 goto end;
320
50dd0969 321 package = buffer.pointer;
1da177e4
LT
322
323 if ((buffer.length == 0) || !package) {
6468463a
LB
324 printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n",
325 (unsigned)buffer.length, package);
1da177e4
LT
326 status = AE_BAD_DATA;
327 acpi_util_eval_error(handle, pathname, status);
328 goto end;
329 }
330 if (package->type != ACPI_TYPE_PACKAGE) {
6468463a
LB
331 printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n",
332 package->type);
1da177e4
LT
333 status = AE_BAD_DATA;
334 acpi_util_eval_error(handle, pathname, status);
335 goto end;
336 }
337 if (!package->package.count) {
6468463a
LB
338 printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n",
339 package);
1da177e4
LT
340 status = AE_BAD_DATA;
341 acpi_util_eval_error(handle, pathname, status);
342 goto end;
343 }
344
345 if (package->package.count > ACPI_MAX_HANDLES) {
d550d98d 346 return AE_NO_MEMORY;
1da177e4
LT
347 }
348 list->count = package->package.count;
349
350 /* Extract package data. */
351
352 for (i = 0; i < list->count; i++) {
353
354 element = &(package->package.elements[i]);
355
cd0b2248 356 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
1da177e4 357 status = AE_BAD_DATA;
6468463a
LB
358 printk(KERN_ERR PREFIX
359 "Expecting a [Reference] package element, found type %X\n",
360 element->type);
1da177e4
LT
361 acpi_util_eval_error(handle, pathname, status);
362 break;
363 }
364
b6a16387
TR
365 if (!element->reference.handle) {
366 printk(KERN_WARNING PREFIX "Invalid reference in"
367 " package %s\n", pathname);
368 status = AE_NULL_ENTRY;
369 break;
370 }
1da177e4
LT
371 /* Get the acpi_handle. */
372
373 list->handles[i] = element->reference.handle;
374 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
4be44fcd 375 list->handles[i]));
1da177e4
LT
376 }
377
4be44fcd 378 end:
1da177e4
LT
379 if (ACPI_FAILURE(status)) {
380 list->count = 0;
381 //kfree(list->handles);
382 }
383
02438d87 384 kfree(buffer.pointer);
1da177e4 385
d550d98d 386 return status;
1da177e4 387}
1da177e4 388
4be44fcd 389EXPORT_SYMBOL(acpi_evaluate_reference);
38ac0f1b
MG
390
391acpi_status
8ede06ab 392acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
38ac0f1b
MG
393{
394 acpi_status status;
395 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
396 union acpi_object *output;
397
398 status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
399
400 if (ACPI_FAILURE(status))
401 return status;
402
403 output = buffer.pointer;
404
405 if (!output || output->type != ACPI_TYPE_PACKAGE
406 || !output->package.count
407 || output->package.elements[0].type != ACPI_TYPE_BUFFER
8ede06ab 408 || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) {
38ac0f1b
MG
409 status = AE_TYPE;
410 goto out;
411 }
412
8ede06ab
FT
413 status = acpi_decode_pld_buffer(
414 output->package.elements[0].buffer.pointer,
415 output->package.elements[0].buffer.length,
416 pld);
417
38ac0f1b
MG
418out:
419 kfree(buffer.pointer);
420 return status;
421}
422EXPORT_SYMBOL(acpi_get_physical_device_location);
275c58d7
TK
423
424/**
700b8422 425 * acpi_evaluate_ost: Evaluate _OST for hotplug operations
275c58d7
TK
426 * @handle: ACPI device handle
427 * @source_event: source event code
428 * @status_code: status code
429 * @status_buf: optional detailed information (NULL if none)
430 *
431 * Evaluate _OST for hotplug operations. All ACPI hotplug handlers
432 * must call this function when evaluating _OST for hotplug operations.
433 * When the platform does not support _OST, this function has no effect.
434 */
435acpi_status
05730c19
JL
436acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
437 struct acpi_buffer *status_buf)
275c58d7 438{
275c58d7
TK
439 union acpi_object params[3] = {
440 {.type = ACPI_TYPE_INTEGER,},
441 {.type = ACPI_TYPE_INTEGER,},
442 {.type = ACPI_TYPE_BUFFER,}
443 };
444 struct acpi_object_list arg_list = {3, params};
275c58d7
TK
445
446 params[0].integer.value = source_event;
447 params[1].integer.value = status_code;
448 if (status_buf != NULL) {
449 params[2].buffer.pointer = status_buf->pointer;
450 params[2].buffer.length = status_buf->length;
451 } else {
452 params[2].buffer.pointer = NULL;
453 params[2].buffer.length = 0;
454 }
455
05730c19 456 return acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
275c58d7 457}
05730c19 458EXPORT_SYMBOL(acpi_evaluate_ost);
fbfddae6
TK
459
460/**
461 * acpi_handle_printk: Print message with ACPI prefix and object path
462 *
463 * This function is called through acpi_handle_<level> macros and prints
464 * a message with ACPI prefix and object path. This function acquires
465 * the global namespace mutex to obtain an object path. In interrupt
466 * context, it shows the object path as <n/a>.
467 */
468void
469acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
470{
471 struct va_format vaf;
472 va_list args;
473 struct acpi_buffer buffer = {
474 .length = ACPI_ALLOCATE_BUFFER,
475 .pointer = NULL
476 };
477 const char *path;
478
479 va_start(args, fmt);
480 vaf.fmt = fmt;
481 vaf.va = &args;
482
483 if (in_interrupt() ||
484 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK)
485 path = "<n/a>";
486 else
487 path = buffer.pointer;
488
489 printk("%sACPI: %s: %pV", level, path, &vaf);
490
491 va_end(args);
492 kfree(buffer.pointer);
493}
494EXPORT_SYMBOL(acpi_handle_printk);
952c63e9
JL
495
496/**
497 * acpi_has_method: Check whether @handle has a method named @name
498 * @handle: ACPI device handle
499 * @name: name of object or method
500 *
501 * Check whether @handle has a method named @name.
502 */
503bool acpi_has_method(acpi_handle handle, char *name)
504{
505 acpi_handle tmp;
506
507 return ACPI_SUCCESS(acpi_get_handle(handle, name, &tmp));
508}
509EXPORT_SYMBOL(acpi_has_method);
0db98202
JL
510
511acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
512 u64 arg)
513{
514 union acpi_object obj = { .type = ACPI_TYPE_INTEGER };
515 struct acpi_object_list arg_list = { .count = 1, .pointer = &obj, };
516
517 obj.integer.value = arg;
518
519 return acpi_evaluate_object(handle, method, &arg_list, NULL);
520}
521EXPORT_SYMBOL(acpi_execute_simple_method);
7d2421f8
JL
522
523/**
524 * acpi_evaluate_ej0: Evaluate _EJ0 method for hotplug operations
525 * @handle: ACPI device handle
526 *
527 * Evaluate device's _EJ0 method for hotplug operations.
528 */
529acpi_status acpi_evaluate_ej0(acpi_handle handle)
530{
531 acpi_status status;
532
533 status = acpi_execute_simple_method(handle, "_EJ0", 1);
534 if (status == AE_NOT_FOUND)
535 acpi_handle_warn(handle, "No _EJ0 support for device\n");
536 else if (ACPI_FAILURE(status))
537 acpi_handle_warn(handle, "Eject failed (0x%x)\n", status);
538
539 return status;
540}
541
542/**
543 * acpi_evaluate_lck: Evaluate _LCK method to lock/unlock device
544 * @handle: ACPI device handle
545 * @lock: lock device if non-zero, otherwise unlock device
546 *
547 * Evaluate device's _LCK method if present to lock/unlock device
548 */
549acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
550{
551 acpi_status status;
552
553 status = acpi_execute_simple_method(handle, "_LCK", !!lock);
554 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
555 if (lock)
556 acpi_handle_warn(handle,
557 "Locking device failed (0x%x)\n", status);
558 else
559 acpi_handle_warn(handle,
560 "Unlocking device failed (0x%x)\n", status);
561 }
562
563 return status;
564}
a65ac520
JL
565
566/**
567 * acpi_evaluate_dsm - evaluate device's _DSM method
568 * @handle: ACPI device handle
569 * @uuid: UUID of requested functions, should be 16 bytes
570 * @rev: revision number of requested function
571 * @func: requested function number
572 * @argv4: the function specific parameter
573 *
574 * Evaluate device's _DSM method with specified UUID, revision id and
575 * function number. Caller needs to free the returned object.
576 *
577 * Though ACPI defines the fourth parameter for _DSM should be a package,
578 * some old BIOSes do expect a buffer or an integer etc.
579 */
580union acpi_object *
581acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, int rev, int func,
582 union acpi_object *argv4)
583{
584 acpi_status ret;
585 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
586 union acpi_object params[4];
587 struct acpi_object_list input = {
588 .count = 4,
589 .pointer = params,
590 };
591
592 params[0].type = ACPI_TYPE_BUFFER;
593 params[0].buffer.length = 16;
594 params[0].buffer.pointer = (char *)uuid;
595 params[1].type = ACPI_TYPE_INTEGER;
596 params[1].integer.value = rev;
597 params[2].type = ACPI_TYPE_INTEGER;
598 params[2].integer.value = func;
599 if (argv4) {
600 params[3] = *argv4;
601 } else {
602 params[3].type = ACPI_TYPE_PACKAGE;
603 params[3].package.count = 0;
604 params[3].package.elements = NULL;
605 }
606
607 ret = acpi_evaluate_object(handle, "_DSM", &input, &buf);
608 if (ACPI_SUCCESS(ret))
609 return (union acpi_object *)buf.pointer;
610
611 if (ret != AE_NOT_FOUND)
612 acpi_handle_warn(handle,
613 "failed to evaluate _DSM (0x%x)\n", ret);
614
615 return NULL;
616}
617EXPORT_SYMBOL(acpi_evaluate_dsm);
618
619/**
620 * acpi_check_dsm - check if _DSM method supports requested functions.
621 * @handle: ACPI device handle
622 * @uuid: UUID of requested functions, should be 16 bytes at least
623 * @rev: revision number of requested functions
624 * @funcs: bitmap of requested functions
625 * @exclude: excluding special value, used to support i915 and nouveau
626 *
627 * Evaluate device's _DSM method to check whether it supports requested
628 * functions. Currently only support 64 functions at maximum, should be
629 * enough for now.
630 */
631bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs)
632{
633 int i;
634 u64 mask = 0;
635 union acpi_object *obj;
636
637 if (funcs == 0)
638 return false;
639
640 obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
641 if (!obj)
642 return false;
643
644 /* For compatibility, old BIOSes may return an integer */
645 if (obj->type == ACPI_TYPE_INTEGER)
646 mask = obj->integer.value;
647 else if (obj->type == ACPI_TYPE_BUFFER)
648 for (i = 0; i < obj->buffer.length && i < 8; i++)
649 mask |= (((u8)obj->buffer.pointer[i]) << (i * 8));
650 ACPI_FREE(obj);
651
652 /*
653 * Bit 0 indicates whether there's support for any functions other than
654 * function 0 for the specified UUID and revision.
655 */
656 if ((mask & 0x1) && (mask & funcs) == funcs)
657 return true;
658
659 return false;
660}
661EXPORT_SYMBOL(acpi_check_dsm);