diff options
author | Luca Tettamanti <kronos.it@gmail.com> | 2012-07-29 11:04:43 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2012-09-20 13:10:35 -0400 |
commit | 86504672f7d79986a8ef618fb120044220e3d1eb (patch) | |
tree | c8a8f2044749dad5adbccc4035f5bd861ec66612 /drivers/gpu/drm | |
parent | f3728734ba78310525bf4a361c7787c7c6fa5d40 (diff) |
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>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_acpi.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c index e94929c69245..f7b511dcba30 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.c +++ b/drivers/gpu/drm/radeon/radeon_acpi.c | |||
@@ -37,23 +37,30 @@ | |||
37 | #include <linux/vga_switcheroo.h> | 37 | #include <linux/vga_switcheroo.h> |
38 | 38 | ||
39 | /* Call the ATIF method | 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 | acpi_status status; | 44 | acpi_status status; |
46 | union acpi_object atif_arg_elements[2]; | 45 | union acpi_object atif_arg_elements[2]; |
47 | struct acpi_object_list atif_arg; | 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 | atif_arg.count = 2; | 49 | atif_arg.count = 2; |
51 | atif_arg.pointer = &atif_arg_elements[0]; | 50 | atif_arg.pointer = &atif_arg_elements[0]; |
52 | 51 | ||
53 | atif_arg_elements[0].type = ACPI_TYPE_INTEGER; | 52 | atif_arg_elements[0].type = ACPI_TYPE_INTEGER; |
54 | atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE; | 53 | atif_arg_elements[0].integer.value = function; |
55 | atif_arg_elements[1].type = ACPI_TYPE_INTEGER; | 54 | |
56 | atif_arg_elements[1].integer.value = 0; | 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 | status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer); | 65 | status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer); |
59 | 66 | ||
@@ -62,18 +69,18 @@ static int radeon_atif_call(acpi_handle handle) | |||
62 | DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n", | 69 | DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n", |
63 | acpi_format_exception(status)); | 70 | acpi_format_exception(status)); |
64 | kfree(buffer.pointer); | 71 | kfree(buffer.pointer); |
65 | return 1; | 72 | return NULL; |
66 | } | 73 | } |
67 | 74 | ||
68 | kfree(buffer.pointer); | 75 | return buffer.pointer; |
69 | return 0; | ||
70 | } | 76 | } |
71 | 77 | ||
72 | /* Call all ACPI methods here */ | 78 | /* Call all ACPI methods here */ |
73 | int radeon_acpi_init(struct radeon_device *rdev) | 79 | int radeon_acpi_init(struct radeon_device *rdev) |
74 | { | 80 | { |
75 | acpi_handle handle; | 81 | acpi_handle handle; |
76 | int ret; | 82 | union acpi_object *info; |
83 | int ret = 0; | ||
77 | 84 | ||
78 | /* Get the device handle */ | 85 | /* Get the device handle */ |
79 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); | 86 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); |
@@ -83,10 +90,11 @@ int radeon_acpi_init(struct radeon_device *rdev) | |||
83 | return 0; | 90 | return 0; |
84 | 91 | ||
85 | /* Call the ATIF method */ | 92 | /* Call the ATIF method */ |
86 | ret = radeon_atif_call(handle); | 93 | info = radeon_atif_call(handle, ATIF_FUNCTION_VERIFY_INTERFACE, NULL); |
87 | if (ret) | 94 | if (!info) |
88 | return ret; | 95 | ret = -EIO; |
89 | 96 | ||
90 | return 0; | 97 | kfree(info); |
98 | return ret; | ||
91 | } | 99 | } |
92 | 100 | ||