Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  acpi_utils.c - ACPI Utility Functions ($Revision: 10 $)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/hardirq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/dynamic_debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "sleep.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define _COMPONENT		ACPI_BUS_COMPONENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) ACPI_MODULE_NAME("utils");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)                             Object Evaluation Helpers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)    -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #ifdef ACPI_DEBUG_OUTPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	char prefix[80] = {'\0'};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct acpi_buffer buffer = {sizeof(prefix), prefix};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		(char *) prefix, p, acpi_format_exception(s)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) acpi_extract_package(union acpi_object *package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		     struct acpi_buffer *format, struct acpi_buffer *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u32 size_required = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u32 tail_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	char *format_string = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 format_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u32 i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	u8 *head = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u8 *tail = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	if (!package || (package->type != ACPI_TYPE_PACKAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	    || (package->package.count < 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		printk(KERN_WARNING PREFIX "Invalid package argument\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (!format || !format->pointer || (format->length < 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		printk(KERN_WARNING PREFIX "Invalid format argument\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	format_count = (format->length / sizeof(char)) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (format_count > package->package.count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			      " than exist in package [%d].\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			      format_count, package->package.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		return AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	format_string = format->pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 * Calculate size_required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	for (i = 0; i < format_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		union acpi_object *element = &(package->package.elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		switch (element->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			case 'N':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				size_required += sizeof(u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				tail_offset += sizeof(u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			case 'S':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 				size_required +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				    sizeof(char *) + sizeof(u64) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 				    sizeof(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 				tail_offset += sizeof(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 				printk(KERN_WARNING PREFIX "Invalid package element"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 					      " [%d]: got number, expecting"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 					      " [%c]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 					      i, format_string[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				return AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			case 'S':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 				size_required +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				    sizeof(char *) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 				    (element->string.length * sizeof(char)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 				    sizeof(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 				tail_offset += sizeof(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			case 'B':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 				size_required +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 				    sizeof(u8 *) + element->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 				tail_offset += sizeof(u8 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 				printk(KERN_WARNING PREFIX "Invalid package element"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 					      " [%d] got string/buffer,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 					      " expecting [%c]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 					      i, format_string[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 				return AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			case 'R':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 				size_required += sizeof(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				tail_offset += sizeof(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 				printk(KERN_WARNING PREFIX "Invalid package element"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 					      " [%d] got reference,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 					      " expecting [%c]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 					      i, format_string[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 				return AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 					  "Found unsupported element at index=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 					  i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			/* TBD: handle nested packages... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			return AE_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * Validate output buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	if (buffer->length == ACPI_ALLOCATE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		buffer->pointer = ACPI_ALLOCATE_ZEROED(size_required);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		if (!buffer->pointer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			return AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		buffer->length = size_required;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		if (buffer->length < size_required) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			buffer->length = size_required;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			return AE_BUFFER_OVERFLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		} else if (buffer->length != size_required ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			   !buffer->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	head = buffer->pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	tail = buffer->pointer + tail_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 * Extract package data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	for (i = 0; i < format_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		u8 **pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		union acpi_object *element = &(package->package.elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		switch (element->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			case 'N':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 				*((u64 *) head) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 				    element->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				head += sizeof(u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			case 'S':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				pointer = (u8 **) head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				*pointer = tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				*((u64 *) tail) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				    element->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				head += sizeof(u64 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 				tail += sizeof(u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 				/* NULL terminate string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 				*tail = (char)0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				tail += sizeof(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				/* Should never get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			case 'S':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				pointer = (u8 **) head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				*pointer = tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 				memcpy(tail, element->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 				       element->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 				head += sizeof(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				tail += element->string.length * sizeof(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				/* NULL terminate string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				*tail = (char)0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				tail += sizeof(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			case 'B':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				pointer = (u8 **) head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				*pointer = tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				memcpy(tail, element->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				       element->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				head += sizeof(u8 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				tail += element->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				/* Should never get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			switch (format_string[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			case 'R':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				*(void **)head =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 				    (void *)element->reference.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 				head += sizeof(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				/* Should never get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			/* TBD: handle nested packages... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			/* Should never get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) EXPORT_SYMBOL(acpi_extract_package);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) acpi_evaluate_integer(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		      acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		      struct acpi_object_list *arguments, unsigned long long *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	union acpi_object element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	struct acpi_buffer buffer = { 0, NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	buffer.length = sizeof(union acpi_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	buffer.pointer = &element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (element.type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		return AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	*data = element.integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) EXPORT_SYMBOL(acpi_evaluate_integer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) acpi_evaluate_reference(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			struct acpi_object_list *arguments,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			struct acpi_handle_list *list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	union acpi_object *package = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	union acpi_object *element = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	u32 i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (!list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		return AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	/* Evaluate object. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	package = buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	if ((buffer.length == 0) || !package) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		status = AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	if (package->type != ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		status = AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (!package->package.count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		status = AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	if (package->package.count > ACPI_MAX_HANDLES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		kfree(package);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		return AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	list->count = package->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	/* Extract package data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	for (i = 0; i < list->count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		element = &(package->package.elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 			status = AE_BAD_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		if (!element->reference.handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 			status = AE_NULL_ENTRY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			acpi_util_eval_error(handle, pathname, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		/* Get the  acpi_handle. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		list->handles[i] = element->reference.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 				  list->handles[i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)       end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		list->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		//kfree(list->handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) EXPORT_SYMBOL(acpi_evaluate_reference);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	union acpi_object *output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	output = buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	if (!output || output->type != ACPI_TYPE_PACKAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	    || !output->package.count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	    || output->package.elements[0].type != ACPI_TYPE_BUFFER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	    || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	status = acpi_decode_pld_buffer(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			output->package.elements[0].buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			output->package.elements[0].buffer.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 			pld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) EXPORT_SYMBOL(acpi_get_physical_device_location);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  * acpi_evaluate_ost: Evaluate _OST for hotplug operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)  * @source_event: source event code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)  * @status_code: status code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)  * @status_buf: optional detailed information (NULL if none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)  * Evaluate _OST for hotplug operations. All ACPI hotplug handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  * must call this function when evaluating _OST for hotplug operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  * When the platform does not support _OST, this function has no effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		  struct acpi_buffer *status_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	union acpi_object params[3] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		{.type = ACPI_TYPE_INTEGER,},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		{.type = ACPI_TYPE_INTEGER,},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		{.type = ACPI_TYPE_BUFFER,}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	struct acpi_object_list arg_list = {3, params};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	params[0].integer.value = source_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	params[1].integer.value = status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	if (status_buf != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		params[2].buffer.pointer = status_buf->pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		params[2].buffer.length = status_buf->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		params[2].buffer.pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		params[2].buffer.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	return acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) EXPORT_SYMBOL(acpi_evaluate_ost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  * acpi_handle_path: Return the object path of handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  * Caller must free the returned buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static char *acpi_handle_path(acpi_handle handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	struct acpi_buffer buffer = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		.length = ACPI_ALLOCATE_BUFFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		.pointer = NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	if (in_interrupt() ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	    acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	return buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)  * acpi_handle_printk: Print message with ACPI prefix and object path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)  * @level: log level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)  * @fmt: format string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  * This function is called through acpi_handle_<level> macros and prints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  * a message with ACPI prefix and object path.  This function acquires
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)  * the global namespace mutex to obtain an object path.  In interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)  * context, it shows the object path as <n/a>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	const char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	vaf.fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	path = acpi_handle_path(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	printk("%sACPI: %s: %pV", level, path ? path : "<n/a>" , &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	kfree(path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) EXPORT_SYMBOL(acpi_handle_printk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) #if defined(CONFIG_DYNAMIC_DEBUG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)  * __acpi_handle_debug: pr_debug with ACPI prefix and object path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)  * @descriptor: Dynamic Debug descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)  * @fmt: format string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)  * This function is called through acpi_handle_debug macro and debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)  * prints a message with ACPI prefix and object path. This function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)  * acquires the global namespace mutex to obtain an object path.  In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)  * interrupt context, it shows the object path as <n/a>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		    const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	const char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	vaf.fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	path = acpi_handle_path(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	__dynamic_pr_debug(descriptor, "ACPI: %s: %pV", path ? path : "<n/a>", &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	kfree(path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) EXPORT_SYMBOL(__acpi_handle_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)  * acpi_has_method: Check whether @handle has a method named @name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)  * @name: name of object or method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  * Check whether @handle has a method named @name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) bool acpi_has_method(acpi_handle handle, char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	acpi_handle tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	return ACPI_SUCCESS(acpi_get_handle(handle, name, &tmp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) EXPORT_SYMBOL(acpi_has_method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 				       u64 arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	union acpi_object obj = { .type = ACPI_TYPE_INTEGER };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	struct acpi_object_list arg_list = { .count = 1, .pointer = &obj, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	obj.integer.value = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	return acpi_evaluate_object(handle, method, &arg_list, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) EXPORT_SYMBOL(acpi_execute_simple_method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)  * acpi_evaluate_ej0: Evaluate _EJ0 method for hotplug operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)  * Evaluate device's _EJ0 method for hotplug operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) acpi_status acpi_evaluate_ej0(acpi_handle handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	status = acpi_execute_simple_method(handle, "_EJ0", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	if (status == AE_NOT_FOUND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		acpi_handle_warn(handle, "No _EJ0 support for device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	else if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		acpi_handle_warn(handle, "Eject failed (0x%x)\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)  * acpi_evaluate_lck: Evaluate _LCK method to lock/unlock device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)  * @lock: lock device if non-zero, otherwise unlock device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)  * Evaluate device's _LCK method if present to lock/unlock device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	status = acpi_execute_simple_method(handle, "_LCK", !!lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		if (lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 			acpi_handle_warn(handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 				"Locking device failed (0x%x)\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			acpi_handle_warn(handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 				"Unlocking device failed (0x%x)\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)  * acpi_evaluate_reg: Evaluate _REG method to register OpRegion presence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)  * @space_id: ACPI address space id to register OpRegion presence for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)  * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)  *            ACPI_REG_DISCONNECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)  * Evaluate device's _REG method to register OpRegion presence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	struct acpi_object_list arg_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	union acpi_object params[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	params[0].type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	params[0].integer.value = space_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	params[1].type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	params[1].integer.value = function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	arg_list.count = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	arg_list.pointer = params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	return acpi_evaluate_object(handle, "_REG", &arg_list, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) EXPORT_SYMBOL(acpi_evaluate_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)  * acpi_evaluate_dsm - evaluate device's _DSM method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  * @guid: GUID of requested functions, should be 16 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  * @rev: revision number of requested function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)  * @func: requested function number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)  * @argv4: the function specific parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)  * Evaluate device's _DSM method with specified GUID, revision id and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)  * function number. Caller needs to free the returned object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)  * Though ACPI defines the fourth parameter for _DSM should be a package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)  * some old BIOSes do expect a buffer or an integer etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) union acpi_object *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 func,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		  union acpi_object *argv4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	acpi_status ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	union acpi_object params[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	struct acpi_object_list input = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 		.count = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 		.pointer = params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	params[0].type = ACPI_TYPE_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	params[0].buffer.length = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	params[0].buffer.pointer = (u8 *)guid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	params[1].type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	params[1].integer.value = rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	params[2].type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	params[2].integer.value = func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	if (argv4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 		params[3] = *argv4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 		params[3].type = ACPI_TYPE_PACKAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		params[3].package.count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		params[3].package.elements = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	ret = acpi_evaluate_object(handle, "_DSM", &input, &buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	if (ACPI_SUCCESS(ret))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		return (union acpi_object *)buf.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	if (ret != AE_NOT_FOUND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		acpi_handle_warn(handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 				"failed to evaluate _DSM (0x%x)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) EXPORT_SYMBOL(acpi_evaluate_dsm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)  * acpi_check_dsm - check if _DSM method supports requested functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)  * @handle: ACPI device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)  * @guid: GUID of requested functions, should be 16 bytes at least
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)  * @rev: revision number of requested functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)  * @funcs: bitmap of requested functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)  * Evaluate device's _DSM method to check whether it supports requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)  * functions. Currently only support 64 functions at maximum, should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)  * enough for now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	u64 mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	union acpi_object *obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	if (funcs == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 	obj = acpi_evaluate_dsm(handle, guid, rev, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 	if (!obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	/* For compatibility, old BIOSes may return an integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 	if (obj->type == ACPI_TYPE_INTEGER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		mask = obj->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 	else if (obj->type == ACPI_TYPE_BUFFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 		for (i = 0; i < obj->buffer.length && i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 			mask |= (((u64)obj->buffer.pointer[i]) << (i * 8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	ACPI_FREE(obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	 * Bit 0 indicates whether there's support for any functions other than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	 * function 0 for the specified GUID and revision.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	if ((mask & 0x1) && (mask & funcs) == funcs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) EXPORT_SYMBOL(acpi_check_dsm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)  * acpi_dev_hid_uid_match - Match device by supplied HID and UID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)  * @adev: ACPI device to match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)  * @hid2: Hardware ID of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)  * @uid2: Unique ID of the device, pass NULL to not check _UID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)  * Matches HID and UID in @adev with given @hid2 and @uid2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)  * Returns true if matches.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) bool acpi_dev_hid_uid_match(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 			    const char *hid2, const char *uid2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	const char *hid1 = acpi_device_hid(adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	const char *uid1 = acpi_device_uid(adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	if (strcmp(hid1, hid2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 	if (!uid2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 	return uid1 && !strcmp(uid1, uid2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) EXPORT_SYMBOL(acpi_dev_hid_uid_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)  * acpi_dev_found - Detect presence of a given ACPI device in the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)  * @hid: Hardware ID of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)  * Return %true if the device was present at the moment of invocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)  * Note that if the device is pluggable, it may since have disappeared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)  * For this function to work, acpi_bus_scan() must have been executed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)  * which happens in the subsys_initcall() subsection. Hence, do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)  * call from a subsys_initcall() or earlier (use acpi_get_devices()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)  * instead). Calling from module_init() is fine (which is synonymous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)  * with device_initcall()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) bool acpi_dev_found(const char *hid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 	struct acpi_device_bus_id *acpi_device_bus_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 	bool found = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	mutex_lock(&acpi_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 	list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 		if (!strcmp(acpi_device_bus_id->bus_id, hid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 			found = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 	mutex_unlock(&acpi_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 	return found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) EXPORT_SYMBOL(acpi_dev_found);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) struct acpi_dev_match_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 	struct acpi_device_id hid[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 	const char *uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	s64 hrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) static int acpi_dev_match_cb(struct device *dev, const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	struct acpi_device *adev = to_acpi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	const struct acpi_dev_match_info *match = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	unsigned long long hrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	if (acpi_match_device_ids(adev, match->hid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	if (match->uid && (!adev->pnp.unique_id ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	    strcmp(adev->pnp.unique_id, match->uid)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	if (match->hrv == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	status = acpi_evaluate_integer(adev->handle, "_HRV", NULL, &hrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	return hrv == match->hrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)  * acpi_dev_present - Detect that a given ACPI device is present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)  * @hid: Hardware ID of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)  * @uid: Unique ID of the device, pass NULL to not check _UID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814)  * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)  * Return %true if a matching device was present at the moment of invocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)  * Note that if the device is pluggable, it may since have disappeared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)  * Note that unlike acpi_dev_found() this function checks the status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)  * of the device. So for devices which are present in the dsdt, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)  * which are disabled (their _STA callback returns 0) this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)  * will return false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)  * For this function to work, acpi_bus_scan() must have been executed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)  * which happens in the subsys_initcall() subsection. Hence, do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)  * call from a subsys_initcall() or earlier (use acpi_get_devices()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)  * instead). Calling from module_init() is fine (which is synonymous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)  * with device_initcall()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 	struct acpi_dev_match_info match = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 	match.uid = uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 	match.hrv = hrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 	put_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 	return !!dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) EXPORT_SYMBOL(acpi_dev_present);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)  * acpi_dev_get_first_match_dev - Return the first match of ACPI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)  * @hid: Hardware ID of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)  * @uid: Unique ID of the device, pass NULL to not check _UID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849)  * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)  * Return the first match of ACPI device if a matching device was present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)  * at the moment of invocation, or NULL otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)  * The caller is responsible to call put_device() on the returned device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)  * See additional information in acpi_dev_present() as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) struct acpi_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 	struct acpi_dev_match_info match = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) 	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) 	match.uid = uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) 	match.hrv = hrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) 	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) 	return dev ? to_acpi_device(dev) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)  * acpi_backlight= handling, this is done here rather then in video_detect.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)  * because __setup cannot be used in modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) char acpi_video_backlight_string[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) EXPORT_SYMBOL(acpi_video_backlight_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) static int __init acpi_backlight(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) 	strlcpy(acpi_video_backlight_string, str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) 		sizeof(acpi_video_backlight_string));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) __setup("acpi_backlight=", acpi_backlight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)  * acpi_match_platform_list - Check if the system matches with a given list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)  * @plat: pointer to acpi_platform_list table terminated by a NULL entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)  * Return the matched index if the system is found in the platform list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893)  * Otherwise, return a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) int acpi_match_platform_list(const struct acpi_platform_list *plat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) 	struct acpi_table_header hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) 	int idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) 	if (acpi_disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) 	for (; plat->oem_id[0]; plat++, idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) 		if (ACPI_FAILURE(acpi_get_table_header(plat->table, 0, &hdr)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) 		if (strncmp(plat->oem_id, hdr.oem_id, ACPI_OEM_ID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) 		if (strncmp(plat->oem_table_id, hdr.oem_table_id, ACPI_OEM_TABLE_ID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) 		if ((plat->pred == all_versions) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) 		    (plat->pred == less_than_or_equal && hdr.oem_revision <= plat->oem_revision) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) 		    (plat->pred == greater_than_or_equal && hdr.oem_revision >= plat->oem_revision) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) 		    (plat->pred == equal && hdr.oem_revision == plat->oem_revision))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) 			return idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) 	return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) EXPORT_SYMBOL(acpi_match_platform_list);