Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: refactor radeon_atif_call

Don't hard-code function number, this will allow to reuse the function.
v2: add support for the 2nd parameter (from Lee, Chun-Yi
<jlee@suse.com>).

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Luca Tettamanti and committed by
Alex Deucher
86504672 f3728734

+23 -15
+23 -15
drivers/gpu/drm/radeon/radeon_acpi.c
··· 37 37 #include <linux/vga_switcheroo.h> 38 38 39 39 /* Call the ATIF method 40 - * 41 - * Note: currently we discard the output 42 40 */ 43 - static int radeon_atif_call(acpi_handle handle) 41 + static union acpi_object *radeon_atif_call(acpi_handle handle, int function, 42 + struct acpi_buffer *params) 44 43 { 45 44 acpi_status status; 46 45 union acpi_object atif_arg_elements[2]; 47 46 struct acpi_object_list atif_arg; 48 - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; 47 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 49 48 50 49 atif_arg.count = 2; 51 50 atif_arg.pointer = &atif_arg_elements[0]; 52 51 53 52 atif_arg_elements[0].type = ACPI_TYPE_INTEGER; 54 - atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE; 55 - atif_arg_elements[1].type = ACPI_TYPE_INTEGER; 56 - atif_arg_elements[1].integer.value = 0; 53 + atif_arg_elements[0].integer.value = function; 54 + 55 + if (params) { 56 + atif_arg_elements[1].type = ACPI_TYPE_BUFFER; 57 + atif_arg_elements[1].buffer.length = params->length; 58 + atif_arg_elements[1].buffer.pointer = params->pointer; 59 + } else { 60 + /* We need a second fake parameter */ 61 + atif_arg_elements[1].type = ACPI_TYPE_INTEGER; 62 + atif_arg_elements[1].integer.value = 0; 63 + } 57 64 58 65 status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer); 59 66 ··· 69 62 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n", 70 63 acpi_format_exception(status)); 71 64 kfree(buffer.pointer); 72 - return 1; 65 + return NULL; 73 66 } 74 67 75 - kfree(buffer.pointer); 76 - return 0; 68 + return buffer.pointer; 77 69 } 78 70 79 71 /* Call all ACPI methods here */ 80 72 int radeon_acpi_init(struct radeon_device *rdev) 81 73 { 82 74 acpi_handle handle; 83 - int ret; 75 + union acpi_object *info; 76 + int ret = 0; 84 77 85 78 /* Get the device handle */ 86 79 handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); ··· 90 83 return 0; 91 84 92 85 /* Call the ATIF method */ 93 - ret = radeon_atif_call(handle); 94 - if (ret) 95 - return ret; 86 + info = radeon_atif_call(handle, ATIF_FUNCTION_VERIFY_INTERFACE, NULL); 87 + if (!info) 88 + ret = -EIO; 96 89 97 - return 0; 90 + kfree(info); 91 + return ret; 98 92 } 99 93