Commit 9a816850 authored by Corentin Chary's avatar Corentin Chary Committed by Len Brown

asus-laptop: use acpi_evaluate_integer instead of read_acpi_int

Use acpi_evaluate_integer() instead of read_acpi_int()
Signed-off-by: default avatarCorentin Chary <corentincj@iksaif.net>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent be521466
...@@ -245,32 +245,19 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, ...@@ -245,32 +245,19 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
return (status == AE_OK); return (status == AE_OK);
} }
static int read_acpi_int(acpi_handle handle, const char *method, int *val,
struct acpi_object_list *params)
{
struct acpi_buffer output;
union acpi_object out_obj;
acpi_status status;
output.length = sizeof(out_obj);
output.pointer = &out_obj;
status = acpi_evaluate_object(handle, (char *)method, params, &output);
*val = out_obj.integer.value;
return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
}
static int read_wireless_status(int mask) static int read_wireless_status(int mask)
{ {
int status; ulong status;
acpi_status rv = AE_OK;
if (!wireless_status_handle) if (!wireless_status_handle)
return (hotk->status & mask) ? 1 : 0; return (hotk->status & mask) ? 1 : 0;
if (read_acpi_int(wireless_status_handle, NULL, &status, NULL)) { rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
return (status & mask) ? 1 : 0; if (ACPI_FAILURE(rv))
} else
printk(ASUS_WARNING "Error reading Wireless status\n"); printk(ASUS_WARNING "Error reading Wireless status\n");
else
return (status & mask) ? 1 : 0;
return (hotk->status & mask) ? 1 : 0; return (hotk->status & mask) ? 1 : 0;
} }
...@@ -354,9 +341,11 @@ static void lcd_blank(int blank) ...@@ -354,9 +341,11 @@ static void lcd_blank(int blank)
static int read_brightness(struct backlight_device *bd) static int read_brightness(struct backlight_device *bd)
{ {
int value; ulong value;
acpi_status rv = AE_OK;
if (!read_acpi_int(brightness_get_handle, NULL, &value, NULL)) rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value);
if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading brightness\n"); printk(ASUS_WARNING "Error reading brightness\n");
return value; return value;
...@@ -403,8 +392,10 @@ static ssize_t show_infos(struct device *dev, ...@@ -403,8 +392,10 @@ static ssize_t show_infos(struct device *dev,
struct device_attribute *attr, char *page) struct device_attribute *attr, char *page)
{ {
int len = 0; int len = 0;
int temp; ulong temp;
char buf[16]; //enough for all info char buf[16]; //enough for all info
acpi_status rv = AE_OK;
/* /*
* We use the easy way, we don't care of off and count, so we don't set eof * We use the easy way, we don't care of off and count, so we don't set eof
* to 1 * to 1
...@@ -418,9 +409,10 @@ static ssize_t show_infos(struct device *dev, ...@@ -418,9 +409,10 @@ static ssize_t show_infos(struct device *dev,
* bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
* The significance of others is yet to be found. * The significance of others is yet to be found.
*/ */
if (read_acpi_int(hotk->handle, "SFUN", &temp, NULL)) rv = acpi_evaluate_integer(hotk->handle, "SFUN", NULL, &temp);
len += if (!ACPI_FAILURE(rv))
sprintf(page + len, "SFUN value : 0x%04x\n", temp); len += sprintf(page + len, "SFUN value : 0x%04x\n",
(uint) temp);
/* /*
* Another value for userspace: the ASYM method returns 0x02 for * Another value for userspace: the ASYM method returns 0x02 for
* battery low and 0x04 for battery critical, its readings tend to be * battery low and 0x04 for battery critical, its readings tend to be
...@@ -428,9 +420,10 @@ static ssize_t show_infos(struct device *dev, ...@@ -428,9 +420,10 @@ static ssize_t show_infos(struct device *dev,
* Note: since not all the laptops provide this method, errors are * Note: since not all the laptops provide this method, errors are
* silently ignored. * silently ignored.
*/ */
if (read_acpi_int(hotk->handle, "ASYM", &temp, NULL)) rv = acpi_evaluate_integer(hotk->handle, "ASYM", NULL, &temp);
len += if (!ACPI_FAILURE(rv))
sprintf(page + len, "ASYM value : 0x%04x\n", temp); len += sprintf(page + len, "ASYM value : 0x%04x\n",
(uint) temp);
if (asus_info) { if (asus_info) {
snprintf(buf, 16, "%d", asus_info->length); snprintf(buf, 16, "%d", asus_info->length);
len += sprintf(page + len, "DSDT length : %s\n", buf); len += sprintf(page + len, "DSDT length : %s\n", buf);
...@@ -547,12 +540,15 @@ static void set_display(int value) ...@@ -547,12 +540,15 @@ static void set_display(int value)
static int read_display(void) static int read_display(void)
{ {
int value = 0; ulong value = 0;
acpi_status rv = AE_OK;
/* In most of the case, we know how to set the display, but sometime /* In most of the case, we know how to set the display, but sometime
we can't read it */ we can't read it */
if (display_get_handle) { if (display_get_handle) {
if (!read_acpi_int(display_get_handle, NULL, &value, NULL)) rv = acpi_evaluate_integer(display_get_handle, NULL,
NULL, &value);
if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading display status\n"); printk(ASUS_WARNING "Error reading display status\n");
} }
...@@ -771,7 +767,7 @@ static int asus_hotk_get_info(void) ...@@ -771,7 +767,7 @@ static int asus_hotk_get_info(void)
{ {
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *model = NULL; union acpi_object *model = NULL;
int bsts_result, hwrs_result; ulong bsts_result, hwrs_result;
char *string = NULL; char *string = NULL;
acpi_status status; acpi_status status;
...@@ -794,11 +790,13 @@ static int asus_hotk_get_info(void) ...@@ -794,11 +790,13 @@ static int asus_hotk_get_info(void)
} }
/* This needs to be called for some laptops to init properly */ /* This needs to be called for some laptops to init properly */
if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result, NULL)) status =
acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result);
if (ACPI_FAILURE(status))
printk(ASUS_WARNING "Error calling BSTS\n"); printk(ASUS_WARNING "Error calling BSTS\n");
else if (bsts_result) else if (bsts_result)
printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n", printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n",
bsts_result); (uint) bsts_result);
/* /*
* Try to match the object returned by INIT to the specific model. * Try to match the object returned by INIT to the specific model.
...@@ -840,7 +838,9 @@ static int asus_hotk_get_info(void) ...@@ -840,7 +838,9 @@ static int asus_hotk_get_info(void)
* The significance of others is yet to be found. * The significance of others is yet to be found.
* If we don't find the method, we assume the device are present. * If we don't find the method, we assume the device are present.
*/ */
if (!read_acpi_int(hotk->handle, "HRWS", &hwrs_result, NULL)) status =
acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &hwrs_result);
if (ACPI_FAILURE(status))
hwrs_result = WL_HWRS | BT_HWRS; hwrs_result = WL_HWRS | BT_HWRS;
if (hwrs_result & WL_HWRS) if (hwrs_result & WL_HWRS)
......
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