1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/init.h>
13 #include <linux/types.h>
14 #include <linux/hardirq.h>
15 #include <linux/acpi.h>
16 #include <linux/dynamic_debug.h>
21 #define _COMPONENT ACPI_BUS_COMPONENT
22 ACPI_MODULE_NAME("utils");
24 /* --------------------------------------------------------------------------
25 Object Evaluation Helpers
26 -------------------------------------------------------------------------- */
28 acpi_util_eval_error(acpi_handle h
, acpi_string p
, acpi_status s
)
30 #ifdef ACPI_DEBUG_OUTPUT
31 char prefix
[80] = {'\0'};
32 struct acpi_buffer buffer
= {sizeof(prefix
), prefix
};
33 acpi_get_name(h
, ACPI_FULL_PATHNAME
, &buffer
);
34 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Evaluate [%s.%s]: %s\n",
35 (char *) prefix
, p
, acpi_format_exception(s
)));
42 acpi_extract_package(union acpi_object
*package
,
43 struct acpi_buffer
*format
, struct acpi_buffer
*buffer
)
45 u32 size_required
= 0;
47 char *format_string
= NULL
;
54 if (!package
|| (package
->type
!= ACPI_TYPE_PACKAGE
)
55 || (package
->package
.count
< 1)) {
56 printk(KERN_WARNING PREFIX
"Invalid package argument\n");
57 return AE_BAD_PARAMETER
;
60 if (!format
|| !format
->pointer
|| (format
->length
< 1)) {
61 printk(KERN_WARNING PREFIX
"Invalid format argument\n");
62 return AE_BAD_PARAMETER
;
66 printk(KERN_WARNING PREFIX
"Invalid buffer argument\n");
67 return AE_BAD_PARAMETER
;
70 format_count
= (format
->length
/ sizeof(char)) - 1;
71 if (format_count
> package
->package
.count
) {
72 printk(KERN_WARNING PREFIX
"Format specifies more objects [%d]"
73 " than exist in package [%d].\n",
74 format_count
, package
->package
.count
);
78 format_string
= format
->pointer
;
81 * Calculate size_required.
83 for (i
= 0; i
< format_count
; i
++) {
85 union acpi_object
*element
= &(package
->package
.elements
[i
]);
87 switch (element
->type
) {
89 case ACPI_TYPE_INTEGER
:
90 switch (format_string
[i
]) {
92 size_required
+= sizeof(u64
);
93 tail_offset
+= sizeof(u64
);
97 sizeof(char *) + sizeof(u64
) +
99 tail_offset
+= sizeof(char *);
102 printk(KERN_WARNING PREFIX
"Invalid package element"
103 " [%d]: got number, expecting"
105 i
, format_string
[i
]);
110 case ACPI_TYPE_STRING
:
111 case ACPI_TYPE_BUFFER
:
112 switch (format_string
[i
]) {
116 (element
->string
.length
* sizeof(char)) +
118 tail_offset
+= sizeof(char *);
122 sizeof(u8
*) + element
->buffer
.length
;
123 tail_offset
+= sizeof(u8
*);
126 printk(KERN_WARNING PREFIX
"Invalid package element"
127 " [%d] got string/buffer,"
129 i
, format_string
[i
]);
133 case ACPI_TYPE_LOCAL_REFERENCE
:
134 switch (format_string
[i
]) {
136 size_required
+= sizeof(void *);
137 tail_offset
+= sizeof(void *);
140 printk(KERN_WARNING PREFIX
"Invalid package element"
141 " [%d] got reference,"
143 i
, format_string
[i
]);
148 case ACPI_TYPE_PACKAGE
:
150 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
151 "Found unsupported element at index=%d\n",
153 /* TBD: handle nested packages... */
159 * Validate output buffer.
161 if (buffer
->length
== ACPI_ALLOCATE_BUFFER
) {
162 buffer
->pointer
= ACPI_ALLOCATE_ZEROED(size_required
);
163 if (!buffer
->pointer
)
165 buffer
->length
= size_required
;
167 if (buffer
->length
< size_required
) {
168 buffer
->length
= size_required
;
169 return AE_BUFFER_OVERFLOW
;
170 } else if (buffer
->length
!= size_required
||
172 return AE_BAD_PARAMETER
;
176 head
= buffer
->pointer
;
177 tail
= buffer
->pointer
+ tail_offset
;
180 * Extract package data.
182 for (i
= 0; i
< format_count
; i
++) {
185 union acpi_object
*element
= &(package
->package
.elements
[i
]);
187 switch (element
->type
) {
189 case ACPI_TYPE_INTEGER
:
190 switch (format_string
[i
]) {
193 element
->integer
.value
;
197 pointer
= (u8
**) head
;
200 element
->integer
.value
;
201 head
+= sizeof(u64
*);
203 /* NULL terminate string */
205 tail
+= sizeof(char);
208 /* Should never get here */
213 case ACPI_TYPE_STRING
:
214 case ACPI_TYPE_BUFFER
:
215 switch (format_string
[i
]) {
217 pointer
= (u8
**) head
;
219 memcpy(tail
, element
->string
.pointer
,
220 element
->string
.length
);
221 head
+= sizeof(char *);
222 tail
+= element
->string
.length
* sizeof(char);
223 /* NULL terminate string */
225 tail
+= sizeof(char);
228 pointer
= (u8
**) head
;
230 memcpy(tail
, element
->buffer
.pointer
,
231 element
->buffer
.length
);
232 head
+= sizeof(u8
*);
233 tail
+= element
->buffer
.length
;
236 /* Should never get here */
240 case ACPI_TYPE_LOCAL_REFERENCE
:
241 switch (format_string
[i
]) {
244 (void *)element
->reference
.handle
;
245 head
+= sizeof(void *);
248 /* Should never get here */
252 case ACPI_TYPE_PACKAGE
:
253 /* TBD: handle nested packages... */
255 /* Should never get here */
263 EXPORT_SYMBOL(acpi_extract_package
);
266 acpi_evaluate_integer(acpi_handle handle
,
267 acpi_string pathname
,
268 struct acpi_object_list
*arguments
, unsigned long long *data
)
270 acpi_status status
= AE_OK
;
271 union acpi_object element
;
272 struct acpi_buffer buffer
= { 0, NULL
};
275 return AE_BAD_PARAMETER
;
277 buffer
.length
= sizeof(union acpi_object
);
278 buffer
.pointer
= &element
;
279 status
= acpi_evaluate_object(handle
, pathname
, arguments
, &buffer
);
280 if (ACPI_FAILURE(status
)) {
281 acpi_util_eval_error(handle
, pathname
, status
);
285 if (element
.type
!= ACPI_TYPE_INTEGER
) {
286 acpi_util_eval_error(handle
, pathname
, AE_BAD_DATA
);
290 *data
= element
.integer
.value
;
292 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Return value [%llu]\n", *data
));
297 EXPORT_SYMBOL(acpi_evaluate_integer
);
300 acpi_evaluate_reference(acpi_handle handle
,
301 acpi_string pathname
,
302 struct acpi_object_list
*arguments
,
303 struct acpi_handle_list
*list
)
305 acpi_status status
= AE_OK
;
306 union acpi_object
*package
= NULL
;
307 union acpi_object
*element
= NULL
;
308 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
313 return AE_BAD_PARAMETER
;
316 /* Evaluate object. */
318 status
= acpi_evaluate_object(handle
, pathname
, arguments
, &buffer
);
319 if (ACPI_FAILURE(status
))
322 package
= buffer
.pointer
;
324 if ((buffer
.length
== 0) || !package
) {
325 status
= AE_BAD_DATA
;
326 acpi_util_eval_error(handle
, pathname
, status
);
329 if (package
->type
!= ACPI_TYPE_PACKAGE
) {
330 status
= AE_BAD_DATA
;
331 acpi_util_eval_error(handle
, pathname
, status
);
334 if (!package
->package
.count
) {
335 status
= AE_BAD_DATA
;
336 acpi_util_eval_error(handle
, pathname
, status
);
340 if (package
->package
.count
> ACPI_MAX_HANDLES
) {
344 list
->count
= package
->package
.count
;
346 /* Extract package data. */
348 for (i
= 0; i
< list
->count
; i
++) {
350 element
= &(package
->package
.elements
[i
]);
352 if (element
->type
!= ACPI_TYPE_LOCAL_REFERENCE
) {
353 status
= AE_BAD_DATA
;
354 acpi_util_eval_error(handle
, pathname
, status
);
358 if (!element
->reference
.handle
) {
359 status
= AE_NULL_ENTRY
;
360 acpi_util_eval_error(handle
, pathname
, status
);
363 /* Get the acpi_handle. */
365 list
->handles
[i
] = element
->reference
.handle
;
366 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found reference [%p]\n",
371 if (ACPI_FAILURE(status
)) {
373 //kfree(list->handles);
376 kfree(buffer
.pointer
);
381 EXPORT_SYMBOL(acpi_evaluate_reference
);
384 acpi_get_physical_device_location(acpi_handle handle
, struct acpi_pld_info
**pld
)
387 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
388 union acpi_object
*output
;
390 status
= acpi_evaluate_object(handle
, "_PLD", NULL
, &buffer
);
392 if (ACPI_FAILURE(status
))
395 output
= buffer
.pointer
;
397 if (!output
|| output
->type
!= ACPI_TYPE_PACKAGE
398 || !output
->package
.count
399 || output
->package
.elements
[0].type
!= ACPI_TYPE_BUFFER
400 || output
->package
.elements
[0].buffer
.length
< ACPI_PLD_REV1_BUFFER_SIZE
) {
405 status
= acpi_decode_pld_buffer(
406 output
->package
.elements
[0].buffer
.pointer
,
407 output
->package
.elements
[0].buffer
.length
,
411 kfree(buffer
.pointer
);
414 EXPORT_SYMBOL(acpi_get_physical_device_location
);
417 * acpi_evaluate_ost: Evaluate _OST for hotplug operations
418 * @handle: ACPI device handle
419 * @source_event: source event code
420 * @status_code: status code
421 * @status_buf: optional detailed information (NULL if none)
423 * Evaluate _OST for hotplug operations. All ACPI hotplug handlers
424 * must call this function when evaluating _OST for hotplug operations.
425 * When the platform does not support _OST, this function has no effect.
428 acpi_evaluate_ost(acpi_handle handle
, u32 source_event
, u32 status_code
,
429 struct acpi_buffer
*status_buf
)
431 union acpi_object params
[3] = {
432 {.type
= ACPI_TYPE_INTEGER
,},
433 {.type
= ACPI_TYPE_INTEGER
,},
434 {.type
= ACPI_TYPE_BUFFER
,}
436 struct acpi_object_list arg_list
= {3, params
};
438 params
[0].integer
.value
= source_event
;
439 params
[1].integer
.value
= status_code
;
440 if (status_buf
!= NULL
) {
441 params
[2].buffer
.pointer
= status_buf
->pointer
;
442 params
[2].buffer
.length
= status_buf
->length
;
444 params
[2].buffer
.pointer
= NULL
;
445 params
[2].buffer
.length
= 0;
448 return acpi_evaluate_object(handle
, "_OST", &arg_list
, NULL
);
450 EXPORT_SYMBOL(acpi_evaluate_ost
);
453 * acpi_handle_path: Return the object path of handle
454 * @handle: ACPI device handle
456 * Caller must free the returned buffer
458 static char *acpi_handle_path(acpi_handle handle
)
460 struct acpi_buffer buffer
= {
461 .length
= ACPI_ALLOCATE_BUFFER
,
465 if (in_interrupt() ||
466 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
) != AE_OK
)
468 return buffer
.pointer
;
472 * acpi_handle_printk: Print message with ACPI prefix and object path
474 * @handle: ACPI device handle
475 * @fmt: format string
477 * This function is called through acpi_handle_<level> macros and prints
478 * a message with ACPI prefix and object path. This function acquires
479 * the global namespace mutex to obtain an object path. In interrupt
480 * context, it shows the object path as <n/a>.
483 acpi_handle_printk(const char *level
, acpi_handle handle
, const char *fmt
, ...)
485 struct va_format vaf
;
493 path
= acpi_handle_path(handle
);
494 printk("%sACPI: %s: %pV", level
, path
? path
: "<n/a>" , &vaf
);
499 EXPORT_SYMBOL(acpi_handle_printk
);
501 #if defined(CONFIG_DYNAMIC_DEBUG)
503 * __acpi_handle_debug: pr_debug with ACPI prefix and object path
504 * @descriptor: Dynamic Debug descriptor
505 * @handle: ACPI device handle
506 * @fmt: format string
508 * This function is called through acpi_handle_debug macro and debug
509 * prints a message with ACPI prefix and object path. This function
510 * acquires the global namespace mutex to obtain an object path. In
511 * interrupt context, it shows the object path as <n/a>.
514 __acpi_handle_debug(struct _ddebug
*descriptor
, acpi_handle handle
,
515 const char *fmt
, ...)
517 struct va_format vaf
;
525 path
= acpi_handle_path(handle
);
526 __dynamic_pr_debug(descriptor
, "ACPI: %s: %pV", path
? path
: "<n/a>", &vaf
);
531 EXPORT_SYMBOL(__acpi_handle_debug
);
535 * acpi_has_method: Check whether @handle has a method named @name
536 * @handle: ACPI device handle
537 * @name: name of object or method
539 * Check whether @handle has a method named @name.
541 bool acpi_has_method(acpi_handle handle
, char *name
)
545 return ACPI_SUCCESS(acpi_get_handle(handle
, name
, &tmp
));
547 EXPORT_SYMBOL(acpi_has_method
);
549 acpi_status
acpi_execute_simple_method(acpi_handle handle
, char *method
,
552 union acpi_object obj
= { .type
= ACPI_TYPE_INTEGER
};
553 struct acpi_object_list arg_list
= { .count
= 1, .pointer
= &obj
, };
555 obj
.integer
.value
= arg
;
557 return acpi_evaluate_object(handle
, method
, &arg_list
, NULL
);
559 EXPORT_SYMBOL(acpi_execute_simple_method
);
562 * acpi_evaluate_ej0: Evaluate _EJ0 method for hotplug operations
563 * @handle: ACPI device handle
565 * Evaluate device's _EJ0 method for hotplug operations.
567 acpi_status
acpi_evaluate_ej0(acpi_handle handle
)
571 status
= acpi_execute_simple_method(handle
, "_EJ0", 1);
572 if (status
== AE_NOT_FOUND
)
573 acpi_handle_warn(handle
, "No _EJ0 support for device\n");
574 else if (ACPI_FAILURE(status
))
575 acpi_handle_warn(handle
, "Eject failed (0x%x)\n", status
);
581 * acpi_evaluate_lck: Evaluate _LCK method to lock/unlock device
582 * @handle: ACPI device handle
583 * @lock: lock device if non-zero, otherwise unlock device
585 * Evaluate device's _LCK method if present to lock/unlock device
587 acpi_status
acpi_evaluate_lck(acpi_handle handle
, int lock
)
591 status
= acpi_execute_simple_method(handle
, "_LCK", !!lock
);
592 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
594 acpi_handle_warn(handle
,
595 "Locking device failed (0x%x)\n", status
);
597 acpi_handle_warn(handle
,
598 "Unlocking device failed (0x%x)\n", status
);
605 * acpi_evaluate_reg: Evaluate _REG method to register OpRegion presence
606 * @handle: ACPI device handle
607 * @space_id: ACPI address space id to register OpRegion presence for
608 * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
609 * ACPI_REG_DISCONNECT
611 * Evaluate device's _REG method to register OpRegion presence.
613 acpi_status
acpi_evaluate_reg(acpi_handle handle
, u8 space_id
, u32 function
)
615 struct acpi_object_list arg_list
;
616 union acpi_object params
[2];
618 params
[0].type
= ACPI_TYPE_INTEGER
;
619 params
[0].integer
.value
= space_id
;
620 params
[1].type
= ACPI_TYPE_INTEGER
;
621 params
[1].integer
.value
= function
;
623 arg_list
.pointer
= params
;
625 return acpi_evaluate_object(handle
, "_REG", &arg_list
, NULL
);
627 EXPORT_SYMBOL(acpi_evaluate_reg
);
630 * acpi_evaluate_dsm - evaluate device's _DSM method
631 * @handle: ACPI device handle
632 * @guid: GUID of requested functions, should be 16 bytes
633 * @rev: revision number of requested function
634 * @func: requested function number
635 * @argv4: the function specific parameter
637 * Evaluate device's _DSM method with specified GUID, revision id and
638 * function number. Caller needs to free the returned object.
640 * Though ACPI defines the fourth parameter for _DSM should be a package,
641 * some old BIOSes do expect a buffer or an integer etc.
644 acpi_evaluate_dsm(acpi_handle handle
, const guid_t
*guid
, u64 rev
, u64 func
,
645 union acpi_object
*argv4
)
648 struct acpi_buffer buf
= {ACPI_ALLOCATE_BUFFER
, NULL
};
649 union acpi_object params
[4];
650 struct acpi_object_list input
= {
655 params
[0].type
= ACPI_TYPE_BUFFER
;
656 params
[0].buffer
.length
= 16;
657 params
[0].buffer
.pointer
= (u8
*)guid
;
658 params
[1].type
= ACPI_TYPE_INTEGER
;
659 params
[1].integer
.value
= rev
;
660 params
[2].type
= ACPI_TYPE_INTEGER
;
661 params
[2].integer
.value
= func
;
665 params
[3].type
= ACPI_TYPE_PACKAGE
;
666 params
[3].package
.count
= 0;
667 params
[3].package
.elements
= NULL
;
670 ret
= acpi_evaluate_object(handle
, "_DSM", &input
, &buf
);
671 if (ACPI_SUCCESS(ret
))
672 return (union acpi_object
*)buf
.pointer
;
674 if (ret
!= AE_NOT_FOUND
)
675 acpi_handle_warn(handle
,
676 "failed to evaluate _DSM (0x%x)\n", ret
);
680 EXPORT_SYMBOL(acpi_evaluate_dsm
);
683 * acpi_check_dsm - check if _DSM method supports requested functions.
684 * @handle: ACPI device handle
685 * @guid: GUID of requested functions, should be 16 bytes at least
686 * @rev: revision number of requested functions
687 * @funcs: bitmap of requested functions
689 * Evaluate device's _DSM method to check whether it supports requested
690 * functions. Currently only support 64 functions at maximum, should be
693 bool acpi_check_dsm(acpi_handle handle
, const guid_t
*guid
, u64 rev
, u64 funcs
)
697 union acpi_object
*obj
;
702 obj
= acpi_evaluate_dsm(handle
, guid
, rev
, 0, NULL
);
706 /* For compatibility, old BIOSes may return an integer */
707 if (obj
->type
== ACPI_TYPE_INTEGER
)
708 mask
= obj
->integer
.value
;
709 else if (obj
->type
== ACPI_TYPE_BUFFER
)
710 for (i
= 0; i
< obj
->buffer
.length
&& i
< 8; i
++)
711 mask
|= (((u64
)obj
->buffer
.pointer
[i
]) << (i
* 8));
715 * Bit 0 indicates whether there's support for any functions other than
716 * function 0 for the specified GUID and revision.
718 if ((mask
& 0x1) && (mask
& funcs
) == funcs
)
723 EXPORT_SYMBOL(acpi_check_dsm
);
726 * acpi_dev_hid_uid_match - Match device by supplied HID and UID
727 * @adev: ACPI device to match.
728 * @hid2: Hardware ID of the device.
729 * @uid2: Unique ID of the device, pass NULL to not check _UID.
731 * Matches HID and UID in @adev with given @hid2 and @uid2.
732 * Returns true if matches.
734 bool acpi_dev_hid_uid_match(struct acpi_device
*adev
,
735 const char *hid2
, const char *uid2
)
737 const char *hid1
= acpi_device_hid(adev
);
738 const char *uid1
= acpi_device_uid(adev
);
740 if (strcmp(hid1
, hid2
))
746 return uid1
&& !strcmp(uid1
, uid2
);
748 EXPORT_SYMBOL(acpi_dev_hid_uid_match
);
751 * acpi_dev_found - Detect presence of a given ACPI device in the namespace.
752 * @hid: Hardware ID of the device.
754 * Return %true if the device was present at the moment of invocation.
755 * Note that if the device is pluggable, it may since have disappeared.
757 * For this function to work, acpi_bus_scan() must have been executed
758 * which happens in the subsys_initcall() subsection. Hence, do not
759 * call from a subsys_initcall() or earlier (use acpi_get_devices()
760 * instead). Calling from module_init() is fine (which is synonymous
761 * with device_initcall()).
763 bool acpi_dev_found(const char *hid
)
765 struct acpi_device_bus_id
*acpi_device_bus_id
;
768 mutex_lock(&acpi_device_lock
);
769 list_for_each_entry(acpi_device_bus_id
, &acpi_bus_id_list
, node
)
770 if (!strcmp(acpi_device_bus_id
->bus_id
, hid
)) {
774 mutex_unlock(&acpi_device_lock
);
778 EXPORT_SYMBOL(acpi_dev_found
);
780 struct acpi_dev_match_info
{
781 struct acpi_device_id hid
[2];
786 static int acpi_dev_match_cb(struct device
*dev
, const void *data
)
788 struct acpi_device
*adev
= to_acpi_device(dev
);
789 const struct acpi_dev_match_info
*match
= data
;
790 unsigned long long hrv
;
793 if (acpi_match_device_ids(adev
, match
->hid
))
796 if (match
->uid
&& (!adev
->pnp
.unique_id
||
797 strcmp(adev
->pnp
.unique_id
, match
->uid
)))
800 if (match
->hrv
== -1)
803 status
= acpi_evaluate_integer(adev
->handle
, "_HRV", NULL
, &hrv
);
804 if (ACPI_FAILURE(status
))
807 return hrv
== match
->hrv
;
811 * acpi_dev_present - Detect that a given ACPI device is present
812 * @hid: Hardware ID of the device.
813 * @uid: Unique ID of the device, pass NULL to not check _UID
814 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
816 * Return %true if a matching device was present at the moment of invocation.
817 * Note that if the device is pluggable, it may since have disappeared.
819 * Note that unlike acpi_dev_found() this function checks the status
820 * of the device. So for devices which are present in the dsdt, but
821 * which are disabled (their _STA callback returns 0) this function
824 * For this function to work, acpi_bus_scan() must have been executed
825 * which happens in the subsys_initcall() subsection. Hence, do not
826 * call from a subsys_initcall() or earlier (use acpi_get_devices()
827 * instead). Calling from module_init() is fine (which is synonymous
828 * with device_initcall()).
830 bool acpi_dev_present(const char *hid
, const char *uid
, s64 hrv
)
832 struct acpi_dev_match_info match
= {};
835 strlcpy(match
.hid
[0].id
, hid
, sizeof(match
.hid
[0].id
));
839 dev
= bus_find_device(&acpi_bus_type
, NULL
, &match
, acpi_dev_match_cb
);
843 EXPORT_SYMBOL(acpi_dev_present
);
846 * acpi_dev_get_first_match_dev - Return the first match of ACPI device
847 * @hid: Hardware ID of the device.
848 * @uid: Unique ID of the device, pass NULL to not check _UID
849 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
851 * Return the first match of ACPI device if a matching device was present
852 * at the moment of invocation, or NULL otherwise.
854 * The caller is responsible to call put_device() on the returned device.
856 * See additional information in acpi_dev_present() as well.
859 acpi_dev_get_first_match_dev(const char *hid
, const char *uid
, s64 hrv
)
861 struct acpi_dev_match_info match
= {};
864 strlcpy(match
.hid
[0].id
, hid
, sizeof(match
.hid
[0].id
));
868 dev
= bus_find_device(&acpi_bus_type
, NULL
, &match
, acpi_dev_match_cb
);
869 return dev
? to_acpi_device(dev
) : NULL
;
871 EXPORT_SYMBOL(acpi_dev_get_first_match_dev
);
874 * acpi_backlight= handling, this is done here rather then in video_detect.c
875 * because __setup cannot be used in modules.
877 char acpi_video_backlight_string
[16];
878 EXPORT_SYMBOL(acpi_video_backlight_string
);
880 static int __init
acpi_backlight(char *str
)
882 strlcpy(acpi_video_backlight_string
, str
,
883 sizeof(acpi_video_backlight_string
));
886 __setup("acpi_backlight=", acpi_backlight
);
889 * acpi_match_platform_list - Check if the system matches with a given list
890 * @plat: pointer to acpi_platform_list table terminated by a NULL entry
892 * Return the matched index if the system is found in the platform list.
893 * Otherwise, return a negative error code.
895 int acpi_match_platform_list(const struct acpi_platform_list
*plat
)
897 struct acpi_table_header hdr
;
903 for (; plat
->oem_id
[0]; plat
++, idx
++) {
904 if (ACPI_FAILURE(acpi_get_table_header(plat
->table
, 0, &hdr
)))
907 if (strncmp(plat
->oem_id
, hdr
.oem_id
, ACPI_OEM_ID_SIZE
))
910 if (strncmp(plat
->oem_table_id
, hdr
.oem_table_id
, ACPI_OEM_TABLE_ID_SIZE
))
913 if ((plat
->pred
== all_versions
) ||
914 (plat
->pred
== less_than_or_equal
&& hdr
.oem_revision
<= plat
->oem_revision
) ||
915 (plat
->pred
== greater_than_or_equal
&& hdr
.oem_revision
>= plat
->oem_revision
) ||
916 (plat
->pred
== equal
&& hdr
.oem_revision
== plat
->oem_revision
))
922 EXPORT_SYMBOL(acpi_match_platform_list
);