Lines Matching +full:integer +full:- +full:n
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
23 /* --------------------------------------------------------------------------
25 -------------------------------------------------------------------------- */
28 acpi_handle_debug(h, "Evaluate [%s]: %s\n", p, acpi_format_exception(s)); in acpi_util_eval_error()
44 if (!package || (package->type != ACPI_TYPE_PACKAGE) in acpi_extract_package()
45 || (package->package.count < 1)) { in acpi_extract_package()
46 pr_debug("Invalid package argument\n"); in acpi_extract_package()
50 if (!format || !format->pointer || (format->length < 1)) { in acpi_extract_package()
51 pr_debug("Invalid format argument\n"); in acpi_extract_package()
56 pr_debug("Invalid buffer argument\n"); in acpi_extract_package()
60 format_count = (format->length / sizeof(char)) - 1; in acpi_extract_package()
61 if (format_count > package->package.count) { in acpi_extract_package()
62 pr_debug("Format specifies more objects [%d] than present [%d]\n", in acpi_extract_package()
63 format_count, package->package.count); in acpi_extract_package()
67 format_string = format->pointer; in acpi_extract_package()
74 union acpi_object *element = &(package->package.elements[i]); in acpi_extract_package()
76 switch (element->type) { in acpi_extract_package()
80 case 'N': in acpi_extract_package()
91 pr_debug("Invalid package element [%d]: got number, expected [%c]\n", in acpi_extract_package()
103 (element->string.length * sizeof(char)) + in acpi_extract_package()
109 sizeof(u8 *) + element->buffer.length; in acpi_extract_package()
113 pr_debug("Invalid package element [%d] got string/buffer, expected [%c]\n", in acpi_extract_package()
125 pr_debug("Invalid package element [%d] got reference, expected [%c]\n", in acpi_extract_package()
133 pr_debug("Unsupported element at index=%d\n", i); in acpi_extract_package()
142 if (buffer->length == ACPI_ALLOCATE_BUFFER) { in acpi_extract_package()
143 buffer->pointer = ACPI_ALLOCATE_ZEROED(size_required); in acpi_extract_package()
144 if (!buffer->pointer) in acpi_extract_package()
146 buffer->length = size_required; in acpi_extract_package()
148 if (buffer->length < size_required) { in acpi_extract_package()
149 buffer->length = size_required; in acpi_extract_package()
151 } else if (buffer->length != size_required || in acpi_extract_package()
152 !buffer->pointer) { in acpi_extract_package()
157 head = buffer->pointer; in acpi_extract_package()
158 tail = buffer->pointer + tail_offset; in acpi_extract_package()
166 union acpi_object *element = &(package->package.elements[i]); in acpi_extract_package()
168 switch (element->type) { in acpi_extract_package()
172 case 'N': in acpi_extract_package()
174 element->integer.value; in acpi_extract_package()
181 element->integer.value; in acpi_extract_package()
200 memcpy(tail, element->string.pointer, in acpi_extract_package()
201 element->string.length); in acpi_extract_package()
203 tail += element->string.length * sizeof(char); in acpi_extract_package()
211 memcpy(tail, element->buffer.pointer, in acpi_extract_package()
212 element->buffer.length); in acpi_extract_package()
214 tail += element->buffer.length; in acpi_extract_package()
225 (void *)element->reference.handle; in acpi_extract_package()
271 *data = element.integer.value; in acpi_evaluate_integer()
273 acpi_handle_debug(handle, "Return value [%llu]\n", *data); in acpi_evaluate_integer()
287 return -ENODATA; in acpi_get_local_address()
306 acpi_handle_debug(handle, "Reading ACPI _SUB failed: %#x\n", status); in acpi_get_subsystem_id()
307 return ERR_PTR(-ENODATA); in acpi_get_subsystem_id()
311 if (obj->type == ACPI_TYPE_STRING) { in acpi_get_subsystem_id()
312 len = strlen(obj->string.pointer); in acpi_get_subsystem_id()
314 sub = kstrdup(obj->string.pointer, GFP_KERNEL); in acpi_get_subsystem_id()
316 sub = ERR_PTR(-ENOMEM); in acpi_get_subsystem_id()
318 acpi_handle_err(handle, "ACPI _SUB Length %zu is Invalid\n", len); in acpi_get_subsystem_id()
319 sub = ERR_PTR(-ENODATA); in acpi_get_subsystem_id()
322 acpi_handle_warn(handle, "Warning ACPI _SUB did not return a string\n"); in acpi_get_subsystem_id()
323 sub = ERR_PTR(-ENODATA); in acpi_get_subsystem_id()
362 if (package->type != ACPI_TYPE_PACKAGE) { in acpi_evaluate_reference()
367 if (!package->package.count) { in acpi_evaluate_reference()
373 if (package->package.count > ACPI_MAX_HANDLES) { in acpi_evaluate_reference()
377 list->count = package->package.count; in acpi_evaluate_reference()
381 for (i = 0; i < list->count; i++) { in acpi_evaluate_reference()
383 element = &(package->package.elements[i]); in acpi_evaluate_reference()
385 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { in acpi_evaluate_reference()
391 if (!element->reference.handle) { in acpi_evaluate_reference()
398 list->handles[i] = element->reference.handle; in acpi_evaluate_reference()
399 acpi_handle_debug(list->handles[i], "Found in reference list\n"); in acpi_evaluate_reference()
404 list->count = 0; in acpi_evaluate_reference()
405 //kfree(list->handles); in acpi_evaluate_reference()
429 if (!output || output->type != ACPI_TYPE_PACKAGE in acpi_get_physical_device_location()
430 || !output->package.count in acpi_get_physical_device_location()
431 || output->package.elements[0].type != ACPI_TYPE_BUFFER in acpi_get_physical_device_location()
432 || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) { in acpi_get_physical_device_location()
438 output->package.elements[0].buffer.pointer, in acpi_get_physical_device_location()
439 output->package.elements[0].buffer.length, in acpi_get_physical_device_location()
470 params[0].integer.value = source_event; in acpi_evaluate_ost()
471 params[1].integer.value = status_code; in acpi_evaluate_ost()
473 params[2].buffer.pointer = status_buf->pointer; in acpi_evaluate_ost()
474 params[2].buffer.length = status_buf->length; in acpi_evaluate_ost()
512 * context, it shows the object path as <n/a>.
526 printk("%sACPI: %s: %pV", level, path ? path : "<n/a>" , &vaf); in acpi_handle_printk()
543 * interrupt context, it shows the object path as <n/a>.
558 __dynamic_pr_debug(descriptor, "ACPI: %s: %pV", path ? path : "<n/a>", &vaf); in __acpi_handle_debug()
567 * acpi_evaluation_failure_warn - Log evaluation failure warning.
575 acpi_handle_warn(handle, "%s evaluation failed: %s\n", name, in acpi_evaluation_failure_warn()
601 obj.integer.value = arg; in acpi_execute_simple_method()
619 acpi_handle_warn(handle, "No _EJ0 support for device\n"); in acpi_evaluate_ej0()
621 acpi_handle_warn(handle, "Eject failed (0x%x)\n", status); in acpi_evaluate_ej0()
629 * @lock: lock device if non-zero, otherwise unlock device
641 "Locking device failed (0x%x)\n", status); in acpi_evaluate_lck()
644 "Unlocking device failed (0x%x)\n", status); in acpi_evaluate_lck()
665 params[0].integer.value = space_id; in acpi_evaluate_reg()
667 params[1].integer.value = function; in acpi_evaluate_reg()
676 * acpi_evaluate_dsm - evaluate device's _DSM method
687 * some old BIOSes do expect a buffer or an integer etc.
705 params[1].integer.value = rev; in acpi_evaluate_dsm()
707 params[2].integer.value = func; in acpi_evaluate_dsm()
722 "failed to evaluate _DSM %pUb (0x%x)\n", guid, ret); in acpi_evaluate_dsm()
729 * acpi_check_dsm - check if _DSM method supports requested functions.
752 /* For compatibility, old BIOSes may return an integer */ in acpi_check_dsm()
753 if (obj->type == ACPI_TYPE_INTEGER) in acpi_check_dsm()
754 mask = obj->integer.value; in acpi_check_dsm()
755 else if (obj->type == ACPI_TYPE_BUFFER) in acpi_check_dsm()
756 for (i = 0; i < obj->buffer.length && i < 8; i++) in acpi_check_dsm()
757 mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); in acpi_check_dsm()
772 * acpi_dev_hid_uid_match - Match device by supplied HID and UID
797 * acpi_dev_uid_to_integer - treat ACPI device _UID as integer
799 * @integer: output buffer for integer
801 * Considers _UID as integer and converts it to @integer.
805 int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) in acpi_dev_uid_to_integer() argument
810 return -ENODEV; in acpi_dev_uid_to_integer()
814 return -ENODATA; in acpi_dev_uid_to_integer()
816 return kstrtou64(uid, 0, integer); in acpi_dev_uid_to_integer()
821 * acpi_dev_found - Detect presence of a given ACPI device in the namespace.
840 if (!strcmp(acpi_device_bus_id->bus_id, hid)) { in acpi_dev_found()
863 if (acpi_match_device_ids(adev, match->hid)) in acpi_dev_match_cb()
866 if (match->uid && (!adev->pnp.unique_id || in acpi_dev_match_cb()
867 strcmp(adev->pnp.unique_id, match->uid))) in acpi_dev_match_cb()
870 if (match->hrv == -1) in acpi_dev_match_cb()
873 status = acpi_evaluate_integer(adev->handle, "_HRV", NULL, &hrv); in acpi_dev_match_cb()
877 return hrv == match->hrv; in acpi_dev_match_cb()
881 * acpi_dev_present - Detect that a given ACPI device is present
884 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
916 * acpi_dev_get_next_match_dev - Return the next match of ACPI device
920 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
934 struct device *start = adev ? &adev->dev : NULL; in acpi_dev_get_next_match_dev()
949 * acpi_dev_get_first_match_dev - Return the first match of ACPI device
952 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
969 * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine
971 * Return true when running on an ACPI-reduced-hw machine, false otherwise.
995 * acpi_match_platform_list - Check if the system matches with a given list
1007 return -ENODEV; in acpi_match_platform_list()
1009 for (; plat->oem_id[0]; plat++, idx++) { in acpi_match_platform_list()
1010 if (ACPI_FAILURE(acpi_get_table_header(plat->table, 0, &hdr))) in acpi_match_platform_list()
1013 if (strncmp(plat->oem_id, hdr.oem_id, ACPI_OEM_ID_SIZE)) in acpi_match_platform_list()
1016 if (strncmp(plat->oem_table_id, hdr.oem_table_id, ACPI_OEM_TABLE_ID_SIZE)) in acpi_match_platform_list()
1019 if ((plat->pred == all_versions) || in acpi_match_platform_list()
1020 (plat->pred == less_than_or_equal && hdr.oem_revision <= plat->oem_revision) || in acpi_match_platform_list()
1021 (plat->pred == greater_than_or_equal && hdr.oem_revision >= plat->oem_revision) || in acpi_match_platform_list()
1022 (plat->pred == equal && hdr.oem_revision == plat->oem_revision)) in acpi_match_platform_list()
1026 return -ENODEV; in acpi_match_platform_list()