Commit 86d86980 authored by Taku Izumi's avatar Taku Izumi Committed by Jesse Barnes

pci-acpi: Cleanup _OSC evaluation code

Cleanup _OSC evaluation code.  Some whitespace changes and a few other
minor cleanups.
Reviewed-by: default avatarAndrew Patterson <andrew.patterson@hp.com>
Tested-by: default avatarAndrew Patterson <andrew.patterson@hp.com>
Signed-off-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarTaku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent e0fa3b43
...@@ -24,15 +24,14 @@ struct acpi_osc_data { ...@@ -24,15 +24,14 @@ struct acpi_osc_data {
acpi_handle handle; acpi_handle handle;
u32 support_set; u32 support_set;
u32 control_set; u32 control_set;
u32 control_query;
int is_queried; int is_queried;
u32 query_result;
struct list_head sibiling; struct list_head sibiling;
}; };
static LIST_HEAD(acpi_osc_data_list); static LIST_HEAD(acpi_osc_data_list);
struct acpi_osc_args { struct acpi_osc_args {
u32 capbuf[3]; u32 capbuf[3];
u32 query_result;
}; };
static DEFINE_MUTEX(pci_acpi_lock); static DEFINE_MUTEX(pci_acpi_lock);
...@@ -58,7 +57,7 @@ static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, ...@@ -58,7 +57,7 @@ static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40,
0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
static acpi_status acpi_run_osc(acpi_handle handle, static acpi_status acpi_run_osc(acpi_handle handle,
struct acpi_osc_args *osc_args) struct acpi_osc_args *osc_args, u32 *retval)
{ {
acpi_status status; acpi_status status;
struct acpi_object_list input; struct acpi_object_list input;
...@@ -114,9 +113,7 @@ static acpi_status acpi_run_osc(acpi_handle handle, ...@@ -114,9 +113,7 @@ static acpi_status acpi_run_osc(acpi_handle handle,
goto out_kfree; goto out_kfree;
} }
out_success: out_success:
if (flags & OSC_QUERY_ENABLE) *retval = *((u32 *)(out_obj->buffer.pointer + 8));
osc_args->query_result =
*((u32 *)(out_obj->buffer.pointer + 8));
status = AE_OK; status = AE_OK;
out_kfree: out_kfree:
...@@ -127,7 +124,7 @@ out_kfree: ...@@ -127,7 +124,7 @@ out_kfree:
static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data) static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data)
{ {
acpi_status status; acpi_status status;
u32 support_set; u32 support_set, result;
struct acpi_osc_args osc_args; struct acpi_osc_args osc_args;
/* do _OSC query for all possible controls */ /* do _OSC query for all possible controls */
...@@ -136,10 +133,10 @@ static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data) ...@@ -136,10 +133,10 @@ static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data)
osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set;
osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
status = acpi_run_osc(osc_data->handle, &osc_args); status = acpi_run_osc(osc_data->handle, &osc_args, &result);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
osc_data->support_set = support_set; osc_data->support_set = support_set;
osc_data->query_result = osc_args.query_result; osc_data->control_query = result;
osc_data->is_queried = 1; osc_data->is_queried = 1;
} }
...@@ -187,7 +184,7 @@ out: ...@@ -187,7 +184,7 @@ out:
acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
{ {
acpi_status status; acpi_status status;
u32 ctrlset, control_set; u32 control_req, control_set, result;
acpi_handle tmp; acpi_handle tmp;
struct acpi_osc_data *osc_data; struct acpi_osc_data *osc_data;
struct acpi_osc_args osc_args; struct acpi_osc_args osc_args;
...@@ -204,14 +201,14 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) ...@@ -204,14 +201,14 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
goto out; goto out;
} }
ctrlset = (flags & OSC_CONTROL_MASKS); control_req = (flags & OSC_CONTROL_MASKS);
if (!ctrlset) { if (!control_req) {
status = AE_TYPE; status = AE_TYPE;
goto out; goto out;
} }
/* No need to evaluate _OSC if the control was already granted. */ /* No need to evaluate _OSC if the control was already granted. */
if ((osc_data->control_set & ctrlset) == ctrlset) if ((osc_data->control_set & control_req) == control_req)
goto out; goto out;
if (!osc_data->is_queried) { if (!osc_data->is_queried) {
...@@ -220,18 +217,18 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) ...@@ -220,18 +217,18 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
goto out; goto out;
} }
if ((osc_data->query_result & ctrlset) != ctrlset) { if ((osc_data->control_query & control_req) != control_req) {
status = AE_SUPPORT; status = AE_SUPPORT;
goto out; goto out;
} }
control_set = osc_data->control_set | ctrlset; control_set = osc_data->control_set | control_req;
osc_args.capbuf[OSC_QUERY_TYPE] = 0; osc_args.capbuf[OSC_QUERY_TYPE] = 0;
osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set; osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set;
osc_args.capbuf[OSC_CONTROL_TYPE] = control_set; osc_args.capbuf[OSC_CONTROL_TYPE] = control_set;
status = acpi_run_osc(handle, &osc_args); status = acpi_run_osc(handle, &osc_args, &result);
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
osc_data->control_set = control_set; osc_data->control_set = result;
out: out:
mutex_unlock(&pci_acpi_lock); mutex_unlock(&pci_acpi_lock);
return status; return status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment