Commit 8a8bce1d authored by Zhang Rui's avatar Zhang Rui Committed by Rafael J. Wysocki

sony-laptop: convert acpi_get_handle() to acpi_has_method()

acpi_has_method() is a new ACPI API introduced to check
the existence of an ACPI control method.

It can be used to replace acpi_get_handle() in the case that
1. the calling function doesn't need the ACPI handle of the control method.
and
2. the calling function doesn't care the reason why the method is unavailable.

Convert acpi_get_handle() to acpi_has_method()
in drivers/platform/x86/sony-laptop.c in this patch.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Mattia Dongili <malattia@linux.it>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 70122e3d
...@@ -1509,7 +1509,6 @@ static void sony_nc_function_resume(void) ...@@ -1509,7 +1509,6 @@ static void sony_nc_function_resume(void)
static int sony_nc_resume(struct device *dev) static int sony_nc_resume(struct device *dev)
{ {
struct sony_nc_value *item; struct sony_nc_value *item;
acpi_handle handle;
for (item = sony_nc_values; item->name; item++) { for (item = sony_nc_values; item->name; item++) {
int ret; int ret;
...@@ -1524,15 +1523,13 @@ static int sony_nc_resume(struct device *dev) ...@@ -1524,15 +1523,13 @@ static int sony_nc_resume(struct device *dev)
} }
} }
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
&handle))) {
int arg = 1; int arg = 1;
if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
dprintk("ECON Method failed\n"); dprintk("ECON Method failed\n");
} }
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", if (acpi_has_method(sony_nc_acpi_handle, "SN00"))
&handle)))
sony_nc_function_resume(); sony_nc_function_resume();
return 0; return 0;
...@@ -2690,7 +2687,6 @@ static void sony_nc_backlight_ng_read_limits(int handle, ...@@ -2690,7 +2687,6 @@ static void sony_nc_backlight_ng_read_limits(int handle,
static void sony_nc_backlight_setup(void) static void sony_nc_backlight_setup(void)
{ {
acpi_handle unused;
int max_brightness = 0; int max_brightness = 0;
const struct backlight_ops *ops = NULL; const struct backlight_ops *ops = NULL;
struct backlight_properties props; struct backlight_properties props;
...@@ -2725,8 +2721,7 @@ static void sony_nc_backlight_setup(void) ...@@ -2725,8 +2721,7 @@ static void sony_nc_backlight_setup(void)
sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props); sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props);
max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
} else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", } else if (acpi_has_method(sony_nc_acpi_handle, "GBRT")) {
&unused))) {
ops = &sony_backlight_ops; ops = &sony_backlight_ops;
max_brightness = SONY_MAX_BRIGHTNESS - 1; max_brightness = SONY_MAX_BRIGHTNESS - 1;
...@@ -2758,7 +2753,6 @@ static int sony_nc_add(struct acpi_device *device) ...@@ -2758,7 +2753,6 @@ static int sony_nc_add(struct acpi_device *device)
{ {
acpi_status status; acpi_status status;
int result = 0; int result = 0;
acpi_handle handle;
struct sony_nc_value *item; struct sony_nc_value *item;
pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION); pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
...@@ -2798,15 +2792,13 @@ static int sony_nc_add(struct acpi_device *device) ...@@ -2798,15 +2792,13 @@ static int sony_nc_add(struct acpi_device *device)
goto outplatform; goto outplatform;
} }
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
&handle))) {
int arg = 1; int arg = 1;
if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
dprintk("ECON Method failed\n"); dprintk("ECON Method failed\n");
} }
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", if (acpi_has_method(sony_nc_acpi_handle, "SN00")) {
&handle))) {
dprintk("Doing SNC setup\n"); dprintk("Doing SNC setup\n");
/* retrieve the available handles */ /* retrieve the available handles */
result = sony_nc_handles_setup(sony_pf_device); result = sony_nc_handles_setup(sony_pf_device);
...@@ -2829,9 +2821,8 @@ static int sony_nc_add(struct acpi_device *device) ...@@ -2829,9 +2821,8 @@ static int sony_nc_add(struct acpi_device *device)
/* find the available acpiget as described in the DSDT */ /* find the available acpiget as described in the DSDT */
for (; item->acpiget && *item->acpiget; ++item->acpiget) { for (; item->acpiget && *item->acpiget; ++item->acpiget) {
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, if (acpi_has_method(sony_nc_acpi_handle,
*item->acpiget, *item->acpiget)) {
&handle))) {
dprintk("Found %s getter: %s\n", dprintk("Found %s getter: %s\n",
item->name, *item->acpiget); item->name, *item->acpiget);
item->devattr.attr.mode |= S_IRUGO; item->devattr.attr.mode |= S_IRUGO;
...@@ -2841,9 +2832,8 @@ static int sony_nc_add(struct acpi_device *device) ...@@ -2841,9 +2832,8 @@ static int sony_nc_add(struct acpi_device *device)
/* find the available acpiset as described in the DSDT */ /* find the available acpiset as described in the DSDT */
for (; item->acpiset && *item->acpiset; ++item->acpiset) { for (; item->acpiset && *item->acpiset; ++item->acpiset) {
if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, if (acpi_has_method(sony_nc_acpi_handle,
*item->acpiset, *item->acpiset)) {
&handle))) {
dprintk("Found %s setter: %s\n", dprintk("Found %s setter: %s\n",
item->name, *item->acpiset); item->name, *item->acpiset);
item->devattr.attr.mode |= S_IWUSR; item->devattr.attr.mode |= S_IWUSR;
......
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