• Home
  • Raw
  • Download

Lines Matching +full:device +full:- +full:handle

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
24 /* --------------------------------------------------------------------------
26 -------------------------------------------------------------------------- */
54 if (!package || (package->type != ACPI_TYPE_PACKAGE) in acpi_extract_package()
55 || (package->package.count < 1)) { in acpi_extract_package()
60 if (!format || !format->pointer || (format->length < 1)) { in acpi_extract_package()
70 format_count = (format->length / sizeof(char)) - 1; in acpi_extract_package()
71 if (format_count > package->package.count) { in acpi_extract_package()
74 format_count, package->package.count); in acpi_extract_package()
78 format_string = format->pointer; in acpi_extract_package()
85 union acpi_object *element = &(package->package.elements[i]); in acpi_extract_package()
87 switch (element->type) { in acpi_extract_package()
116 (element->string.length * sizeof(char)) + in acpi_extract_package()
122 sizeof(u8 *) + element->buffer.length; in acpi_extract_package()
153 /* TBD: handle nested packages... */ in acpi_extract_package()
161 if (buffer->length == ACPI_ALLOCATE_BUFFER) { in acpi_extract_package()
162 buffer->pointer = ACPI_ALLOCATE_ZEROED(size_required); in acpi_extract_package()
163 if (!buffer->pointer) in acpi_extract_package()
165 buffer->length = size_required; in acpi_extract_package()
167 if (buffer->length < size_required) { in acpi_extract_package()
168 buffer->length = size_required; in acpi_extract_package()
170 } else if (buffer->length != size_required || in acpi_extract_package()
171 !buffer->pointer) { in acpi_extract_package()
176 head = buffer->pointer; in acpi_extract_package()
177 tail = buffer->pointer + tail_offset; in acpi_extract_package()
185 union acpi_object *element = &(package->package.elements[i]); in acpi_extract_package()
187 switch (element->type) { in acpi_extract_package()
193 element->integer.value; in acpi_extract_package()
200 element->integer.value; in acpi_extract_package()
219 memcpy(tail, element->string.pointer, in acpi_extract_package()
220 element->string.length); in acpi_extract_package()
222 tail += element->string.length * sizeof(char); in acpi_extract_package()
230 memcpy(tail, element->buffer.pointer, in acpi_extract_package()
231 element->buffer.length); in acpi_extract_package()
233 tail += element->buffer.length; in acpi_extract_package()
244 (void *)element->reference.handle; in acpi_extract_package()
253 /* TBD: handle nested packages... */ in acpi_extract_package()
266 acpi_evaluate_integer(acpi_handle handle, in acpi_evaluate_integer() argument
279 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); in acpi_evaluate_integer()
281 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_integer()
286 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); in acpi_evaluate_integer()
300 acpi_evaluate_reference(acpi_handle handle, in acpi_evaluate_reference() argument
318 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); in acpi_evaluate_reference()
326 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_reference()
329 if (package->type != ACPI_TYPE_PACKAGE) { in acpi_evaluate_reference()
331 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_reference()
334 if (!package->package.count) { in acpi_evaluate_reference()
336 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_reference()
340 if (package->package.count > ACPI_MAX_HANDLES) { in acpi_evaluate_reference()
344 list->count = package->package.count; in acpi_evaluate_reference()
348 for (i = 0; i < list->count; i++) { in acpi_evaluate_reference()
350 element = &(package->package.elements[i]); in acpi_evaluate_reference()
352 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { in acpi_evaluate_reference()
354 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_reference()
358 if (!element->reference.handle) { in acpi_evaluate_reference()
360 acpi_util_eval_error(handle, pathname, status); in acpi_evaluate_reference()
365 list->handles[i] = element->reference.handle; in acpi_evaluate_reference()
367 list->handles[i])); in acpi_evaluate_reference()
372 list->count = 0; in acpi_evaluate_reference()
373 //kfree(list->handles); in acpi_evaluate_reference()
384 acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld) in acpi_get_physical_device_location() argument
390 status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer); in acpi_get_physical_device_location()
397 if (!output || output->type != ACPI_TYPE_PACKAGE in acpi_get_physical_device_location()
398 || !output->package.count in acpi_get_physical_device_location()
399 || output->package.elements[0].type != ACPI_TYPE_BUFFER in acpi_get_physical_device_location()
400 || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) { in acpi_get_physical_device_location()
406 output->package.elements[0].buffer.pointer, in acpi_get_physical_device_location()
407 output->package.elements[0].buffer.length, in acpi_get_physical_device_location()
418 * @handle: ACPI device handle
428 acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code, in acpi_evaluate_ost() argument
441 params[2].buffer.pointer = status_buf->pointer; in acpi_evaluate_ost()
442 params[2].buffer.length = status_buf->length; in acpi_evaluate_ost()
448 return acpi_evaluate_object(handle, "_OST", &arg_list, NULL); in acpi_evaluate_ost()
453 * acpi_handle_path: Return the object path of handle
454 * @handle: ACPI device handle
458 static char *acpi_handle_path(acpi_handle handle) in acpi_handle_path() argument
466 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK) in acpi_handle_path()
474 * @handle: ACPI device handle
483 acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...) in acpi_handle_printk() argument
493 path = acpi_handle_path(handle); in acpi_handle_printk()
505 * @handle: ACPI device handle
514 __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, in __acpi_handle_debug() argument
525 path = acpi_handle_path(handle); in __acpi_handle_debug()
535 * acpi_has_method: Check whether @handle has a method named @name
536 * @handle: ACPI device handle
539 * Check whether @handle has a method named @name.
541 bool acpi_has_method(acpi_handle handle, char *name) in acpi_has_method() argument
545 return ACPI_SUCCESS(acpi_get_handle(handle, name, &tmp)); in acpi_has_method()
549 acpi_status acpi_execute_simple_method(acpi_handle handle, char *method, in acpi_execute_simple_method() argument
557 return acpi_evaluate_object(handle, method, &arg_list, NULL); in acpi_execute_simple_method()
563 * @handle: ACPI device handle
565 * Evaluate device's _EJ0 method for hotplug operations.
567 acpi_status acpi_evaluate_ej0(acpi_handle handle) in acpi_evaluate_ej0() argument
571 status = acpi_execute_simple_method(handle, "_EJ0", 1); in acpi_evaluate_ej0()
573 acpi_handle_warn(handle, "No _EJ0 support for device\n"); in acpi_evaluate_ej0()
575 acpi_handle_warn(handle, "Eject failed (0x%x)\n", status); in acpi_evaluate_ej0()
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) in acpi_evaluate_lck() argument
591 status = acpi_execute_simple_method(handle, "_LCK", !!lock); in acpi_evaluate_lck()
594 acpi_handle_warn(handle, in acpi_evaluate_lck()
595 "Locking device failed (0x%x)\n", status); in acpi_evaluate_lck()
597 acpi_handle_warn(handle, in acpi_evaluate_lck()
598 "Unlocking device failed (0x%x)\n", status); in acpi_evaluate_lck()
606 * @handle: ACPI device handle
611 * Evaluate device's _REG method to register OpRegion presence.
613 acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function) in acpi_evaluate_reg() argument
625 return acpi_evaluate_object(handle, "_REG", &arg_list, NULL); in acpi_evaluate_reg()
630 * acpi_evaluate_dsm - evaluate device's _DSM method
631 * @handle: ACPI device handle
637 * Evaluate device's _DSM method with specified GUID, revision id and
644 acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 func, in acpi_evaluate_dsm() argument
670 ret = acpi_evaluate_object(handle, "_DSM", &input, &buf); in acpi_evaluate_dsm()
675 acpi_handle_warn(handle, in acpi_evaluate_dsm()
683 * acpi_check_dsm - check if _DSM method supports requested functions.
684 * @handle: ACPI device handle
689 * Evaluate device's _DSM method to check whether it supports requested
693 bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs) in acpi_check_dsm() argument
702 obj = acpi_evaluate_dsm(handle, guid, rev, 0, NULL); in acpi_check_dsm()
707 if (obj->type == ACPI_TYPE_INTEGER) in acpi_check_dsm()
708 mask = obj->integer.value; in acpi_check_dsm()
709 else if (obj->type == ACPI_TYPE_BUFFER) in acpi_check_dsm()
710 for (i = 0; i < obj->buffer.length && i < 8; i++) in acpi_check_dsm()
711 mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); in 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.
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.
770 if (!strcmp(acpi_device_bus_id->bus_id, hid)) { in acpi_dev_found()
786 static int acpi_dev_match_cb(struct device *dev, const void *data) in acpi_dev_match_cb()
793 if (acpi_match_device_ids(adev, match->hid)) in acpi_dev_match_cb()
796 if (match->uid && (!adev->pnp.unique_id || in acpi_dev_match_cb()
797 strcmp(adev->pnp.unique_id, match->uid))) in acpi_dev_match_cb()
800 if (match->hrv == -1) in acpi_dev_match_cb()
803 status = acpi_evaluate_integer(adev->handle, "_HRV", NULL, &hrv); in acpi_dev_match_cb()
807 return hrv == match->hrv; in acpi_dev_match_cb()
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.
820 * of the device. So for devices which are present in the dsdt, but
833 struct device *dev; in 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
854 * The caller is responsible to call put_device() on the returned device.
862 struct device *dev; in acpi_dev_get_first_match_dev()
889 * acpi_match_platform_list - Check if the system matches with a given list
901 return -ENODEV; in acpi_match_platform_list()
903 for (; plat->oem_id[0]; plat++, idx++) { in acpi_match_platform_list()
904 if (ACPI_FAILURE(acpi_get_table_header(plat->table, 0, &hdr))) in acpi_match_platform_list()
907 if (strncmp(plat->oem_id, hdr.oem_id, ACPI_OEM_ID_SIZE)) in acpi_match_platform_list()
910 if (strncmp(plat->oem_table_id, hdr.oem_table_id, ACPI_OEM_TABLE_ID_SIZE)) in acpi_match_platform_list()
913 if ((plat->pred == all_versions) || in acpi_match_platform_list()
914 (plat->pred == less_than_or_equal && hdr.oem_revision <= plat->oem_revision) || in acpi_match_platform_list()
915 (plat->pred == greater_than_or_equal && hdr.oem_revision >= plat->oem_revision) || in acpi_match_platform_list()
916 (plat->pred == equal && hdr.oem_revision == plat->oem_revision)) in acpi_match_platform_list()
920 return -ENODEV; in acpi_match_platform_list()