Acpi_evaluate_integer of kernel ACPI function API,
Acpi_evaluate_integer of kernel ACPI function API
The acpi_evaluate_integer function is used to obtain the value of a string from the bios. The routine is as follows: status = acpi_evaluate_integer (ac-> device-> handle, "_ PSR", NULL, & ac-> state); if (ACPI_FAILURE (status) {ACPI_EXCEPTION (AE _INFO, status, "Error reading AC Adapter state"); ac-> state = ACPI_AC_STATUS_UNKNOWN; return-ENODEV;}. For example, this routine is used to obtain the value of _ PSR, and then save the value to acpi_statusacpi_evaluate_integer (acpi_handle handle, acpi_string path Name, struct acpi_object_list * arguments, unsigned long * data) {# default return value acpi_status status = AE _ OK; union acpi_object element; struct acpi_buffer buffer = {0, NULL }; # This data is returned as a result. if it is null, The result cannot be saved, and then exit if (! Data) return AE _BAD_PARAMETER; # assign a buffer value to the member variable of acpi_buffer according to acpi spec. length = sizeof (union acpi_object); buffer. pointer = & element; # after passing the following function, the result is saved in the element. status = acpi_evaluate_object (handle, pathname, arguments, & buffer); if (ACPI_FAILURE (status )) {acpi_util_eval_error (handle, pathname, status); return status ;}# here, the type of the value returned by Pan Dan is an integer. If it is not an integer, it indicates that it is not the result we want, errorif (element. type! = ACPI_TYPE_INTEGER) {acpi_util_eval_error (handle, pathname, AE _BAD_DATA); return AE _BAD_DATA ;}#, this sentence shows that the function is actually used to get an integer value from the bios # Here, the value obtained from the bios is saved in the unsigned long data * data = element. integer. value; # The following output ACPI_DEBUG_PRINT (ACPI_DB_INFO, "Return value [% llu] \ n", * data) can be seen through dmesg; return AE _ OK ;}