linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: rjw@sisk.pl
Cc: linux-pm@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	Mattia Dongili <malattia@linux.it>,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH 17/27] sony-laptop: convert acpi_get_handle() to acpi_has_method()
Date: Tue,  3 Sep 2013 08:32:05 +0800	[thread overview]
Message-ID: <1378168335-22556-18-git-send-email-rui.zhang@intel.com> (raw)
In-Reply-To: <1378168335-22556-1-git-send-email-rui.zhang@intel.com>

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: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Mattia Dongili <malattia@linux.it>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/sony-laptop.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 069821b..ccacd13 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1509,7 +1509,6 @@ static void sony_nc_function_resume(void)
 static int sony_nc_resume(struct device *dev)
 {
 	struct sony_nc_value *item;
-	acpi_handle handle;
 
 	for (item = sony_nc_values; item->name; item++) {
 		int ret;
@@ -1524,15 +1523,13 @@ static int sony_nc_resume(struct device *dev)
 		}
 	}
 
-	if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON",
-					 &handle))) {
+	if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
 		int arg = 1;
 		if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
 			dprintk("ECON Method failed\n");
 	}
 
-	if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00",
-					 &handle)))
+	if (acpi_has_method(sony_nc_acpi_handle, "SN00"))
 		sony_nc_function_resume();
 
 	return 0;
@@ -2687,7 +2684,6 @@ static void sony_nc_backlight_ng_read_limits(int handle,
 
 static void sony_nc_backlight_setup(void)
 {
-	acpi_handle unused;
 	int max_brightness = 0;
 	const struct backlight_ops *ops = NULL;
 	struct backlight_properties props;
@@ -2722,8 +2718,7 @@ static void sony_nc_backlight_setup(void)
 		sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props);
 		max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
 
-	} else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
-						&unused))) {
+	} else if (acpi_has_method(sony_nc_acpi_handle, "GBRT")) {
 		ops = &sony_backlight_ops;
 		max_brightness = SONY_MAX_BRIGHTNESS - 1;
 
@@ -2755,7 +2750,6 @@ static int sony_nc_add(struct acpi_device *device)
 {
 	acpi_status status;
 	int result = 0;
-	acpi_handle handle;
 	struct sony_nc_value *item;
 
 	pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
@@ -2795,15 +2789,13 @@ static int sony_nc_add(struct acpi_device *device)
 		goto outplatform;
 	}
 
-	if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON",
-					 &handle))) {
+	if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
 		int arg = 1;
 		if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
 			dprintk("ECON Method failed\n");
 	}
 
-	if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00",
-					 &handle))) {
+	if (acpi_has_method(sony_nc_acpi_handle, "SN00")) {
 		dprintk("Doing SNC setup\n");
 		/* retrieve the available handles */
 		result = sony_nc_handles_setup(sony_pf_device);
@@ -2826,9 +2818,8 @@ static int sony_nc_add(struct acpi_device *device)
 
 		/* find the available acpiget as described in the DSDT */
 		for (; item->acpiget && *item->acpiget; ++item->acpiget) {
-			if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle,
-							 *item->acpiget,
-							 &handle))) {
+			if (acpi_has_method(sony_nc_acpi_handle,
+							*item->acpiget)) {
 				dprintk("Found %s getter: %s\n",
 						item->name, *item->acpiget);
 				item->devattr.attr.mode |= S_IRUGO;
@@ -2838,9 +2829,8 @@ static int sony_nc_add(struct acpi_device *device)
 
 		/* find the available acpiset as described in the DSDT */
 		for (; item->acpiset && *item->acpiset; ++item->acpiset) {
-			if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle,
-							 *item->acpiset,
-							 &handle))) {
+			if (acpi_has_method(sony_nc_acpi_handle,
+							*item->acpiset)) {
 				dprintk("Found %s setter: %s\n",
 						item->name, *item->acpiset);
 				item->devattr.attr.mode |= S_IWUSR;
-- 
1.8.1.2

  parent reply	other threads:[~2013-09-03  0:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
2013-09-03  0:31 ` [PATCH 01/27] olpc_xo15_sci: convert acpi_evaluate_object() to acpi_execute_simple_method() Zhang Rui
2013-09-03  0:31 ` [PATCH 02/27] gpiolib-acpi: " Zhang Rui
2013-09-03  7:17   ` Mika Westerberg
2013-09-03  7:42   ` Mathias Nyman
2013-09-17 12:55   ` Linus Walleij
2013-09-03  0:31 ` [PATCH 03/27] eeepc-laptop: " Zhang Rui
2013-09-03  0:31 ` [PATCH 04/27] fujitsu-laptop: " Zhang Rui
2013-09-03 13:11   ` Jonathan Woithe
2013-09-03  0:31 ` [PATCH 05/27] intel-rst: " Zhang Rui
2013-09-03  0:31 ` [PATCH 06/27] intel-smartconnect: " Zhang Rui
2013-09-03  0:31 ` [PATCH 07/27] topstar-laptop: " Zhang Rui
2013-09-03  0:31 ` [PATCH 08/27] toshiba_acpi: " Zhang Rui
2013-09-03  0:31 ` [PATCH 09/27] wmi: " Zhang Rui
2013-09-03  0:31 ` [PATCH 10/27] pcc_freq: convert acpi_get_handle() to acpi_has_method() Zhang Rui
2013-09-03  0:31 ` [PATCH 11/27] i915: intel_acpi: " Zhang Rui
2013-09-09  8:57   ` Daniel Vetter
2013-09-03  0:32 ` [PATCH 12/27] nouveau_acpi: " Zhang Rui
2013-09-03  0:32 ` [PATCH 13/27] acpi_pcihp: " Zhang Rui
2013-09-03  0:32 ` [PATCH 14/27] pci-acpi: " Zhang Rui
2013-09-03  0:32 ` [PATCH 15/27] fujitsu-laptop: " Zhang Rui
2013-09-03 13:11   ` Jonathan Woithe
2013-09-03  0:32 ` [PATCH 16/27] intel_menlow: " Zhang Rui
2013-09-03  0:32 ` Zhang Rui [this message]
2013-09-03  0:32 ` [PATCH 18/27] toshiba_acpi: " Zhang Rui
2013-09-03  0:32 ` [PATCH 19/27] wmi: " Zhang Rui
2013-09-03  0:32 ` [PATCH 20/27] pnpacpi: " Zhang Rui
2013-09-03  0:32 ` [PATCH 21/27] acpi_processor: convert acpi_evaluate_object() to acpi_evaluate_integer() Zhang Rui
2013-09-03  0:32 ` [PATCH 22/27] ACPI: dock: " Zhang Rui
2013-09-03  0:32 ` [PATCH 23/27] i2c-hid: " Zhang Rui
2013-09-04 10:14   ` Jiri Kosina
2013-09-06  8:17     ` Benjamin Tissoires
2013-09-03  0:32 ` [PATCH 24/27] fujitsu-laptop: " Zhang Rui
2013-09-03 13:12   ` Jonathan Woithe
2013-09-03  0:32 ` [PATCH 25/27] intel-rst: " Zhang Rui
2013-09-03  0:32 ` [PATCH 26/27] intel-smartconnect: " Zhang Rui
2013-09-03  0:32 ` [PATCH 27/27] toshiba_acpi: " Zhang Rui
2013-09-03 11:24 ` [PATCH 00/27] ACPI AML helper conversion Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378168335-22556-18-git-send-email-rui.zhang@intel.com \
    --to=rui.zhang@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=malattia@linux.it \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).