All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/27] ACPI AML helper conversion
@ 2013-09-03  0:31 Zhang Rui
  2013-09-03  0:31 ` [PATCH 01/27] olpc_xo15_sci: convert acpi_evaluate_object() to acpi_execute_simple_method() Zhang Rui
                   ` (27 more replies)
  0 siblings, 28 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui

Hi, all,

ACPI has some fine grained helpers for evaluating AML,
which can be used to simplify the code a lot.
And there are a couple of new helpers introduced recently,
say, acpi_has_method/acpi_execute_simple_method, etc.

This patch set does some cleanup and converts the code to use
the AML helpers when possible.

Patch 01/27 ~ Patch 09/27:
converts acpi_evaluate_object() to acpi_execute_simple_method()
Patch 10/27 ~ Patch 20/27:
converts acpi_get_handle() to acpi_has_method()
Patch 21/27 ~ Patch 27/27:
converts acpi_evaluate_object() to acpi_evaluate_integer()

Given that there is no functional change in this patch set, and most of the
patches are not able for me to test as they are platform driver changes,
I just did build test and reboot with acpi_processor, i915 driver loaded
on an Lenovo Ultrabook, and everything works well.

Drivers that I've compiled in my build test,
CONFIG_ACPI_PROCESSOR=y
CONFIG_ACPI_DOCK=y
CONFIG_X86_PCC_CPUFREQ=y
CONFIG_GPIO_ACPI=y
CONFIG_DRM_I915=m
CONFIG_DRM_NOUVEAU=m
ONFIG_I2C_HID=m
CONFIG_HOTPLUG_PCI=y
CONFIG_EEEPC_LAPTOP=y
CONFIG_FUJITSU_LAPTOP=y
CONFIG_INTEL_RST=m
CONFIG_INTEL_SMARTCONNECT=y
CONFIG_INTEL_MENLOW=y
CONFIG_SONY_LAPTOP=y
CONFIG_TOPSTAR_LAPTOP=y
CONFIG_ACPI_TOSHIBA=y
CONFIG_ACPI_WMI=y
CONFIG_PNPACPI=y

Any comments are welcome. :)

thanks,
rui

------------------------------------------------------------------------
 arch/x86/platform/olpc/olpc-xo15-sci.c    |  9 +--------
 drivers/acpi/acpi_processor.c             |  6 +++---
 drivers/acpi/dock.c                       |  6 ++----
 drivers/cpufreq/pcc-cpufreq.c             |  5 ++---
 drivers/gpio/gpiolib-acpi.c               | 11 ++---------
 drivers/gpu/drm/i915/intel_acpi.c         |  5 ++---
 drivers/gpu/drm/nouveau/nouveau_acpi.c    |  6 ++----
 drivers/hid/i2c-hid/i2c-hid.c             | 16 ++++------------
 drivers/pci/hotplug/acpi_pcihp.c          |  7 ++-----
 drivers/pci/pci-acpi.c                    |  3 +--
 drivers/platform/x86/eeepc-laptop.c       |  8 +-------
 drivers/platform/x86/fujitsu-laptop.c     | 42 +++++++++---------------------------------
 drivers/platform/x86/intel-rst.c          | 48 ++++++++----------------------------------------
 drivers/platform/x86/intel-smartconnect.c | 27 ++++-----------------------
 drivers/platform/x86/intel_menlow.c       |  7 ++-----
 drivers/platform/x86/sony-laptop.c        | 28 +++++++++-------------------
 drivers/platform/x86/topstar-laptop.c     |  8 ++------
 drivers/platform/x86/toshiba_acpi.c       | 44 ++++++++++++--------------------------------
 drivers/platform/x86/wmi.c                | 30 ++++++++----------------------
 drivers/pnp/pnpacpi/core.c                | 10 +++-------
 20 files changed, 79 insertions(+), 247 deletions(-)


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 01/27] olpc_xo15_sci: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 02/27] gpiolib-acpi: " Zhang Rui
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Daniel Drake, H. Peter Anvin

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in arch/x86/platform/olpc/olpc-xo15-sci.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Daniel Drake <dsd@laptop.org>
CC: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/platform/olpc/olpc-xo15-sci.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index fef7d0b..649a12b 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -40,16 +40,9 @@ static bool				lid_wake_on_close;
  */
 static int set_lid_wake_behavior(bool wake_on_close)
 {
-	struct acpi_object_list arg_list;
-	union acpi_object arg;
 	acpi_status status;
 
-	arg_list.count		= 1;
-	arg_list.pointer	= &arg;
-	arg.type		= ACPI_TYPE_INTEGER;
-	arg.integer.value	= wake_on_close;
-
-	status = acpi_evaluate_object(NULL, "\\_SB.PCI0.LID.LIDW", &arg_list, NULL);
+	status = acpi_execute_simple_method(NULL, "\\_SB.PCI0.LID.LIDW", wake_on_close);
 	if (ACPI_FAILURE(status)) {
 		pr_warning(PFX "failed to set lid behavior\n");
 		return 1;
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  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 ` Zhang Rui
  2013-09-03  7:17   ` Mika Westerberg
                     ` (2 more replies)
  2013-09-03  0:31 ` [PATCH 03/27] eeepc-laptop: " Zhang Rui
                   ` (25 subsequent siblings)
  27 siblings, 3 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Mathias Nyman, Mika Westerberg, Linus Walleij

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/gpio/gpiolib-acpi.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Mathias Nyman <mathias.nyman@linux.intel.com>
CC: Mika Westerberg <mika.westerberg@linux.intel.com>
CC: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpiolib-acpi.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 5c1ef2b..f2beb72 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -73,15 +73,8 @@ static irqreturn_t acpi_gpio_irq_handler(int irq, void *data)
 static irqreturn_t acpi_gpio_irq_handler_evt(int irq, void *data)
 {
 	struct acpi_gpio_evt_pin *evt_pin = data;
-	struct acpi_object_list args;
-	union acpi_object arg;
 
-	arg.type = ACPI_TYPE_INTEGER;
-	arg.integer.value = evt_pin->pin;
-	args.count = 1;
-	args.pointer = &arg;
-
-	acpi_evaluate_object(evt_pin->evt_handle, NULL, &args, NULL);
+	acpi_execute_simple_method(evt_pin->evt_handle, NULL, evt_pin->pin);
 
 	return IRQ_HANDLED;
 }
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 03/27] eeepc-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
  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  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 04/27] fujitsu-laptop: " Zhang Rui
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Matthew Garrett, Corentin Chary,
	platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/eeepc-laptop.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Corentin Chary <corentincj@iksaif.net>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/eeepc-laptop.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index a6afd41..aefcc32 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -190,16 +190,10 @@ struct eeepc_laptop {
  */
 static int write_acpi_int(acpi_handle handle, const char *method, int val)
 {
-	struct acpi_object_list params;
-	union acpi_object in_obj;
 	acpi_status status;
 
-	params.count = 1;
-	params.pointer = &in_obj;
-	in_obj.type = ACPI_TYPE_INTEGER;
-	in_obj.integer.value = val;
+	status = acpi_execute_simple_method(handle, (char *)method, val);
 
-	status = acpi_evaluate_object(handle, (char *)method, &params, NULL);
 	return (status == AE_OK ? 0 : -1);
 }
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 04/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (2 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 03/27] eeepc-laptop: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03 13:11   ` Jonathan Woithe
  2013-09-03  0:31 ` [PATCH 05/27] intel-rst: " Zhang Rui
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Matthew Garrett, Jonathan Woithe,
	platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/fujitsu-laptop.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/fujitsu-laptop.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 52b8a97..29738cb 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -317,8 +317,6 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev)
 static int set_lcd_level(int level)
 {
 	acpi_status status = AE_OK;
-	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
-	struct acpi_object_list arg_list = { 1, &arg0 };
 	acpi_handle handle = NULL;
 
 	vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
@@ -333,9 +331,8 @@ static int set_lcd_level(int level)
 		return -ENODEV;
 	}
 
-	arg0.integer.value = level;
 
-	status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
+	status = acpi_execute_simple_method(handle, NULL, level);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
@@ -345,8 +342,6 @@ static int set_lcd_level(int level)
 static int set_lcd_level_alt(int level)
 {
 	acpi_status status = AE_OK;
-	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
-	struct acpi_object_list arg_list = { 1, &arg0 };
 	acpi_handle handle = NULL;
 
 	vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
@@ -361,9 +356,7 @@ static int set_lcd_level_alt(int level)
 		return -ENODEV;
 	}
 
-	arg0.integer.value = level;
-
-	status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
+	status = acpi_execute_simple_method(handle, NULL, level);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 05/27] intel-rst: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (3 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 04/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 06/27] intel-smartconnect: " Zhang Rui
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/intel-rst.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/intel-rst.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
index 9385afd..fdf8ca0 100644
--- a/drivers/platform/x86/intel-rst.c
+++ b/drivers/platform/x86/intel-rst.c
@@ -54,8 +54,6 @@ static ssize_t irst_store_wakeup_events(struct device *dev,
 					const char *buf, size_t count)
 {
 	struct acpi_device *acpi;
-	struct acpi_object_list input;
-	union acpi_object param;
 	acpi_status status;
 	unsigned long value;
 	int error;
@@ -67,13 +65,7 @@ static ssize_t irst_store_wakeup_events(struct device *dev,
 	if (error)
 		return error;
 
-	param.type = ACPI_TYPE_INTEGER;
-	param.integer.value = value;
-
-	input.count = 1;
-	input.pointer = &param;
-
-	status = acpi_evaluate_object(acpi->handle, "SFFS", &input, NULL);
+	status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
 
 	if (!ACPI_SUCCESS(status))
 		return -EINVAL;
@@ -116,8 +108,6 @@ static ssize_t irst_store_wakeup_time(struct device *dev,
 				      const char *buf, size_t count)
 {
 	struct acpi_device *acpi;
-	struct acpi_object_list input;
-	union acpi_object param;
 	acpi_status status;
 	unsigned long value;
 	int error;
@@ -129,13 +119,7 @@ static ssize_t irst_store_wakeup_time(struct device *dev,
 	if (error)
 		return error;
 
-	param.type = ACPI_TYPE_INTEGER;
-	param.integer.value = value;
-
-	input.count = 1;
-	input.pointer = &param;
-
-	status = acpi_evaluate_object(acpi->handle, "SFTV", &input, NULL);
+	status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
 
 	if (!ACPI_SUCCESS(status))
 		return -EINVAL;
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 06/27] intel-smartconnect: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (4 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 05/27] intel-rst: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 07/27] topstar-laptop: " Zhang Rui
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/intel-smartconnect.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/intel-smartconnect.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/platform/x86/intel-smartconnect.c b/drivers/platform/x86/intel-smartconnect.c
index f74e93d..9758b00 100644
--- a/drivers/platform/x86/intel-smartconnect.c
+++ b/drivers/platform/x86/intel-smartconnect.c
@@ -25,10 +25,8 @@ MODULE_LICENSE("GPL");
 
 static int smartconnect_acpi_init(struct acpi_device *acpi)
 {
-	struct acpi_object_list input;
 	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *result;
-	union acpi_object param;
 	acpi_status status;
 
 	status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output);
@@ -43,15 +41,8 @@ static int smartconnect_acpi_init(struct acpi_device *acpi)
 	}
 
 	if (result->integer.value & 0x1) {
-		param.type = ACPI_TYPE_INTEGER;
-		param.integer.value = 0;
-
-		input.count = 1;
-		input.pointer = &param;
-
 		dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
-		status = acpi_evaluate_object(acpi->handle, "SAOS", &input,
-					      NULL);
+		status = acpi_execute_simple_method(acpi->handle, "SAOS", 0);
 	}
 
 	kfree(result);
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 07/27] topstar-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (5 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 06/27] intel-smartconnect: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 08/27] toshiba_acpi: " Zhang Rui
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Herton Ronaldo Krzesinski, Matthew Garrett,
	platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/topstar-laptop.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/topstar-laptop.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 4ab618c..67897c8 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -80,13 +80,9 @@ static void acpi_topstar_notify(struct acpi_device *device, u32 event)
 static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state)
 {
 	acpi_status status;
-	union acpi_object fncx_params[1] = {
-		{ .type = ACPI_TYPE_INTEGER }
-	};
-	struct acpi_object_list fncx_arg_list = { 1, &fncx_params[0] };
 
-	fncx_params[0].integer.value = state ? 0x86 : 0x87;
-	status = acpi_evaluate_object(device->handle, "FNCX", &fncx_arg_list, NULL);
+	status = acpi_execute_simple_method(device->handle, "FNCX",
+						state ? 0x86 : 0x87);
 	if (ACPI_FAILURE(status)) {
 		pr_err("Unable to switch FNCX notifications\n");
 		return -ENODEV;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 08/27] toshiba_acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (6 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 07/27] topstar-laptop: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 09/27] wmi: " Zhang Rui
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/toshiba_acpi.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/toshiba_acpi.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index eb3467e..4c0e657 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -191,16 +191,9 @@ static __inline__ void _set_bit(u32 * word, u32 mask, int value)
 
 static int write_acpi_int(const char *methodName, int val)
 {
-	struct acpi_object_list params;
-	union acpi_object in_objs[1];
 	acpi_status status;
 
-	params.count = ARRAY_SIZE(in_objs);
-	params.pointer = in_objs;
-	in_objs[0].type = ACPI_TYPE_INTEGER;
-	in_objs[0].integer.value = val;
-
-	status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
+	status = acpi_execute_simple_method(NULL, (char *)methodName, val);
 	return (status == AE_OK) ? 0 : -EIO;
 }
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 09/27] wmi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (7 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 08/27] toshiba_acpi: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 10/27] pcc_freq: convert acpi_get_handle() to acpi_has_method() Zhang Rui
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/wmi.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/wmi.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b13344c..cb4fe80 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -252,8 +252,6 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
 {
 	struct guid_block *block = NULL;
 	char method[5];
-	struct acpi_object_list input;
-	union acpi_object params[1];
 	acpi_status status;
 	acpi_handle handle;
 
@@ -263,13 +261,9 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
 	if (!block)
 		return AE_NOT_EXIST;
 
-	input.count = 1;
-	input.pointer = params;
-	params[0].type = ACPI_TYPE_INTEGER;
-	params[0].integer.value = enable;
 
 	snprintf(method, 5, "WE%02X", block->notify_id);
-	status = acpi_evaluate_object(handle, method, &input, NULL);
+	status = acpi_execute_simple_method(handle, method, enable);
 
 	if (status != AE_OK && status != AE_NOT_FOUND)
 		return status;
@@ -355,8 +349,8 @@ struct acpi_buffer *out)
 	struct wmi_block *wblock = NULL;
 	acpi_handle handle, wc_handle;
 	acpi_status status, wc_status = AE_ERROR;
-	struct acpi_object_list input, wc_input;
-	union acpi_object wc_params[1], wq_params[1];
+	struct acpi_object_list input;
+	union acpi_object wq_params[1];
 	char method[5];
 	char wc_method[5] = "WC";
 
@@ -386,11 +380,6 @@ struct acpi_buffer *out)
 	 * enable collection.
 	 */
 	if (block->flags & ACPI_WMI_EXPENSIVE) {
-		wc_input.count = 1;
-		wc_input.pointer = wc_params;
-		wc_params[0].type = ACPI_TYPE_INTEGER;
-		wc_params[0].integer.value = 1;
-
 		strncat(wc_method, block->object_id, 2);
 
 		/*
@@ -400,8 +389,8 @@ struct acpi_buffer *out)
 		 */
 		wc_status = acpi_get_handle(handle, wc_method, &wc_handle);
 		if (ACPI_SUCCESS(wc_status))
-			wc_status = acpi_evaluate_object(handle, wc_method,
-				&wc_input, NULL);
+			wc_status = acpi_execute_simple_method(handle,
+								wc_method, 1);
 	}
 
 	strcpy(method, "WQ");
@@ -414,9 +403,7 @@ struct acpi_buffer *out)
 	 * the WQxx method failed - we should disable collection anyway.
 	 */
 	if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
-		wc_params[0].integer.value = 0;
-		status = acpi_evaluate_object(handle,
-		wc_method, &wc_input, NULL);
+		status = acpi_execute_simple_method(handle, wc_method, 0);
 	}
 
 	return status;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 10/27] pcc_freq: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (8 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 09/27] wmi: " Zhang Rui
@ 2013-09-03  0:31 ` Zhang Rui
  2013-09-03  0:31 ` [PATCH 11/27] i915: intel_acpi: " Zhang Rui
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui

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/cpufreq/pcc_freq.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: linux-pm@vger.kernel.org
---
 drivers/cpufreq/pcc-cpufreq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index d81c4e5..70438de 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -396,15 +396,14 @@ static int __init pcc_cpufreq_probe(void)
 	struct pcc_memory_resource *mem_resource;
 	struct pcc_register_resource *reg_resource;
 	union acpi_object *out_obj, *member;
-	acpi_handle handle, osc_handle, pcch_handle;
+	acpi_handle handle, osc_handle;
 	int ret = 0;
 
 	status = acpi_get_handle(NULL, "\\_SB", &handle);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	status = acpi_get_handle(handle, "PCCH", &pcch_handle);
-	if (ACPI_FAILURE(status))
+	if (!acpi_has_method(handle, "PCCH"))
 		return -ENODEV;
 
 	status = acpi_get_handle(handle, "_OSC", &osc_handle);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 11/27] i915: intel_acpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (9 preceding siblings ...)
  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 ` Zhang Rui
  2013-09-09  8:57   ` Daniel Vetter
  2013-09-03  0:32 ` [PATCH 12/27] nouveau_acpi: " Zhang Rui
                   ` (16 subsequent siblings)
  27 siblings, 1 reply; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:31 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Daniel Vetter

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/gpu/drm/i915/intel_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_acpi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c
index 57fe1ae..43959ed 100644
--- a/drivers/gpu/drm/i915/intel_acpi.c
+++ b/drivers/gpu/drm/i915/intel_acpi.c
@@ -193,16 +193,14 @@ static void intel_dsm_platform_mux_info(void)
 
 static bool intel_dsm_pci_probe(struct pci_dev *pdev)
 {
-	acpi_handle dhandle, intel_handle;
-	acpi_status status;
+	acpi_handle dhandle;
 	int ret;
 
 	dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
 	if (!dhandle)
 		return false;
 
-	status = acpi_get_handle(dhandle, "_DSM", &intel_handle);
-	if (ACPI_FAILURE(status)) {
+	if (!acpi_has_method(dhandle, "_DSM")) {
 		DRM_DEBUG_KMS("no _DSM method for intel device\n");
 		return false;
 	}
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 12/27] nouveau_acpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (10 preceding siblings ...)
  2013-09-03  0:31 ` [PATCH 11/27] i915: intel_acpi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 13/27] acpi_pcihp: " Zhang Rui
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Ben Skeggs, Dave Airlie

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/gpu/drm/nouveau/nouveau_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Ben Skeggs <bskeggs@redhat.com>
CC: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_acpi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 4d70fb7..3cfb551 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -235,18 +235,15 @@ static struct vga_switcheroo_handler nouveau_dsm_handler = {
 
 static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
 {
-	acpi_handle dhandle, nvidia_handle;
-	acpi_status status;
+	acpi_handle dhandle;
 	int retval = 0;
 
 	dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
 	if (!dhandle)
 		return false;
 
-	status = acpi_get_handle(dhandle, "_DSM", &nvidia_handle);
-	if (ACPI_FAILURE(status)) {
+	if (!acpi_has_method(dhandle, "_DSM"))
 		return false;
-	}
 
 	if (nouveau_test_dsm(dhandle, nouveau_dsm, NOUVEAU_DSM_POWER))
 		retval |= NOUVEAU_DSM_HAS_MUX;
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 13/27] acpi_pcihp: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (11 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 12/27] nouveau_acpi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 14/27] pci-acpi: " Zhang Rui
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Bjorn Helgaas

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/pci/hotplug/acpi_pcihp.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/hotplug/acpi_pcihp.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 2a47e82..5440131 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -411,13 +411,10 @@ EXPORT_SYMBOL(acpi_get_hp_hw_control_from_firmware);
 static int pcihp_is_ejectable(acpi_handle handle)
 {
 	acpi_status status;
-	acpi_handle tmp;
 	unsigned long long removable;
-	status = acpi_get_handle(handle, "_ADR", &tmp);
-	if (ACPI_FAILURE(status))
+	if (!acpi_has_method(handle, "_ADR"))
 		return 0;
-	status = acpi_get_handle(handle, "_EJ0", &tmp);
-	if (ACPI_SUCCESS(status))
+	if (acpi_has_method(handle, "_EJ0"))
 		return 1;
 	status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable);
 	if (ACPI_SUCCESS(status) && removable)
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 14/27] pci-acpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (12 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 13/27] acpi_pcihp: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 15/27] fujitsu-laptop: " Zhang Rui
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Bjorn Helgaas

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/pci/pci-acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci-acpi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 7c29ee4..513404f 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -181,7 +181,6 @@ static bool acpi_pci_power_manageable(struct pci_dev *dev)
 static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 {
 	acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
-	acpi_handle tmp;
 	static const u8 state_conv[] = {
 		[PCI_D0] = ACPI_STATE_D0,
 		[PCI_D1] = ACPI_STATE_D1,
@@ -192,7 +191,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 	int error = -EINVAL;
 
 	/* If the ACPI device has _EJ0, ignore the device */
-	if (!handle || ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp)))
+	if (!handle || acpi_has_method(handle, "_EJ0"))
 		return -ENODEV;
 
 	switch (state) {
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 15/27] fujitsu-laptop: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (13 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 14/27] pci-acpi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03 13:11   ` Jonathan Woithe
  2013-09-03  0:32 ` [PATCH 16/27] intel_menlow: " Zhang Rui
                   ` (12 subsequent siblings)
  27 siblings, 1 reply; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Matthew Garrett, Jonathan Woithe,
	platform-driver-x86

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/fujitsu-laptop.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/fujitsu-laptop.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 29738cb..765d8c1 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -579,11 +579,10 @@ static struct platform_driver fujitsupf_driver = {
 
 static void dmi_check_cb_common(const struct dmi_system_id *id)
 {
-	acpi_handle handle;
 	pr_info("Identified laptop model '%s'\n", id->ident);
 	if (use_alt_lcd_levels == -1) {
-		if (ACPI_SUCCESS(acpi_get_handle(NULL,
-				"\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
+		if (acpi_has_method(NULL,
+				"\\_SB.PCI0.LPCB.FJEX.SBL2"))
 			use_alt_lcd_levels = 1;
 		else
 			use_alt_lcd_levels = 0;
@@ -646,7 +645,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = {
 
 static int acpi_fujitsu_add(struct acpi_device *device)
 {
-	acpi_handle handle;
 	int result = 0;
 	int state = 0;
 	struct input_dev *input;
@@ -695,8 +693,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
 
 	fujitsu->dev = device;
 
-	if (ACPI_SUCCESS
-	    (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
+	if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
 		vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
 		if (ACPI_FAILURE
 		    (acpi_evaluate_object
@@ -796,7 +793,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
 
 static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
 {
-	acpi_handle handle;
 	int result = 0;
 	int state = 0;
 	struct input_dev *input;
@@ -859,8 +855,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
 
 	fujitsu_hotkey->dev = device;
 
-	if (ACPI_SUCCESS
-	    (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
+	if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
 		vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
 		if (ACPI_FAILURE
 		    (acpi_evaluate_object
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 16/27] intel_menlow: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (14 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 15/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 17/27] sony-laptop: " Zhang Rui
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

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/intel_menlow.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/intel_menlow.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index d6cfc15..11244f8 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -156,19 +156,15 @@ static struct thermal_cooling_device_ops memory_cooling_ops = {
 static int intel_menlow_memory_add(struct acpi_device *device)
 {
 	int result = -ENODEV;
-	acpi_status status = AE_OK;
-	acpi_handle dummy;
 	struct thermal_cooling_device *cdev;
 
 	if (!device)
 		return -EINVAL;
 
-	status = acpi_get_handle(device->handle, MEMORY_GET_BANDWIDTH, &dummy);
-	if (ACPI_FAILURE(status))
+	if (!acpi_has_method(device->handle, MEMORY_GET_BANDWIDTH))
 		goto end;
 
-	status = acpi_get_handle(device->handle, MEMORY_SET_BANDWIDTH, &dummy);
-	if (ACPI_FAILURE(status))
+	if (!acpi_has_method(device->handle, MEMORY_SET_BANDWIDTH))
 		goto end;
 
 	cdev = thermal_cooling_device_register("Memory controller", device,
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 17/27] sony-laptop: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (15 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 16/27] intel_menlow: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 18/27] toshiba_acpi: " Zhang Rui
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Matthew Garrett, Mattia Dongili,
	platform-driver-x86

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

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 18/27] toshiba_acpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (16 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 17/27] sony-laptop: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 19/27] wmi: " Zhang Rui
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

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/toshiba_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/toshiba_acpi.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 4c0e657..235185b 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -974,7 +974,7 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
 static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 {
 	acpi_status status;
-	acpi_handle ec_handle, handle;
+	acpi_handle ec_handle;
 	int error;
 	u32 hci_result;
 
@@ -1001,10 +1001,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	 */
 	status = AE_ERROR;
 	ec_handle = ec_get_handle();
-	if (ec_handle)
-		status = acpi_get_handle(ec_handle, "NTFY", &handle);
-
-	if (ACPI_SUCCESS(status)) {
+	if (ec_handle && acpi_has_method(ec_handle, "NTFY")) {
 		INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work);
 
 		error = i8042_install_filter(toshiba_acpi_i8042_filter);
@@ -1020,10 +1017,9 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	 * Determine hotkey query interface. Prefer using the INFO
 	 * method when it is available.
 	 */
-	status = acpi_get_handle(dev->acpi_dev->handle, "INFO", &handle);
-	if (ACPI_SUCCESS(status)) {
+	if (acpi_has_method(dev->acpi_dev->handle, "INFO"))
 		dev->info_supported = 1;
-	} else {
+	else {
 		hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result);
 		if (hci_result == HCI_SUCCESS)
 			dev->system_event_supported = 1;
@@ -1148,15 +1144,10 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 
 static const char *find_hci_method(acpi_handle handle)
 {
-	acpi_status status;
-	acpi_handle hci_handle;
-
-	status = acpi_get_handle(handle, "GHCI", &hci_handle);
-	if (ACPI_SUCCESS(status))
+	if (acpi_has_method(handle, "GHCI"))
 		return "GHCI";
 
-	status = acpi_get_handle(handle, "SPFC", &hci_handle);
-	if (ACPI_SUCCESS(status))
+	if (acpi_has_method(handle, "SPFC"))
 		return "SPFC";
 
 	return NULL;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 19/27] wmi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (17 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 18/27] toshiba_acpi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 20/27] pnpacpi: " Zhang Rui
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

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/wmi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/wmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index cb4fe80..806ad7a 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -347,7 +347,7 @@ struct acpi_buffer *out)
 {
 	struct guid_block *block = NULL;
 	struct wmi_block *wblock = NULL;
-	acpi_handle handle, wc_handle;
+	acpi_handle handle;
 	acpi_status status, wc_status = AE_ERROR;
 	struct acpi_object_list input;
 	union acpi_object wq_params[1];
@@ -387,8 +387,7 @@ struct acpi_buffer *out)
 		 * expensive, but have no corresponding WCxx method. So we
 		 * should not fail if this happens.
 		 */
-		wc_status = acpi_get_handle(handle, wc_method, &wc_handle);
-		if (ACPI_SUCCESS(wc_status))
+		if (acpi_has_method(handle, wc_method))
 			wc_status = acpi_execute_simple_method(handle,
 								wc_method, 1);
 	}
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 20/27] pnpacpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (18 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 19/27] wmi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 21/27] acpi_processor: convert acpi_evaluate_object() to acpi_evaluate_integer() Zhang Rui
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Bjorn Helgaas

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/pnp/pnpacpi/core.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pnp/pnpacpi/core.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 34049b0..747826d 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -239,8 +239,6 @@ static char *__init pnpacpi_get_id(struct acpi_device *device)
 
 static int __init pnpacpi_add_device(struct acpi_device *device)
 {
-	acpi_handle temp = NULL;
-	acpi_status status;
 	struct pnp_dev *dev;
 	char *pnpid;
 	struct acpi_hardware_id *id;
@@ -253,8 +251,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
 	 * If a PnPacpi device is not present , the device
 	 * driver should not be loaded.
 	 */
-	status = acpi_get_handle(device->handle, "_CRS", &temp);
-	if (ACPI_FAILURE(status))
+	if (!acpi_has_method(device->handle, "_CRS"))
 		return 0;
 
 	pnpid = pnpacpi_get_id(device);
@@ -271,16 +268,14 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
 	dev->data = device;
 	/* .enabled means the device can decode the resources */
 	dev->active = device->status.enabled;
-	status = acpi_get_handle(device->handle, "_SRS", &temp);
-	if (ACPI_SUCCESS(status))
+	if (acpi_has_method(device->handle, "_SRS"))
 		dev->capabilities |= PNP_CONFIGURABLE;
 	dev->capabilities |= PNP_READ;
 	if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
 		dev->capabilities |= PNP_WRITE;
 	if (device->flags.removable)
 		dev->capabilities |= PNP_REMOVABLE;
-	status = acpi_get_handle(device->handle, "_DIS", &temp);
-	if (ACPI_SUCCESS(status))
+	if (acpi_has_method(device->handle, "_DIS"))
 		dev->capabilities |= PNP_DISABLE;
 
 	if (strlen(acpi_device_name(device)))
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 21/27] acpi_processor: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (19 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 20/27] pnpacpi: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 22/27] ACPI: dock: " Zhang Rui
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/acpi/acpi_processor.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_processor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f29e06e..357abdc 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -219,6 +219,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
 	int cpu_index, device_declaration = 0;
 	acpi_status status = AE_OK;
 	static int cpu0_initialized;
+	unsigned long long value;
 
 	if (num_online_cpus() > 1)
 		errata.smp = TRUE;
@@ -258,7 +259,6 @@ static int acpi_processor_get_info(struct acpi_device *device)
 		 * Declared with "Device" statement; match _UID.
 		 * Note that we don't handle string _UIDs yet.
 		 */
-		unsigned long long value;
 		status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
 						NULL, &value);
 		if (ACPI_FAILURE(status)) {
@@ -332,9 +332,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
 	 * ensure we get the right value in the "physical id" field
 	 * of /proc/cpuinfo
 	 */
-	status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
+	status = acpi_evaluate_integer(pr->handle, "_SUN", NULL, &value);
 	if (ACPI_SUCCESS(status))
-		arch_fix_phys_package_id(pr->id, object.integer.value);
+		arch_fix_phys_package_id(pr->id, value);
 
 	return 0;
 }
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 22/27] ACPI: dock: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (20 preceding siblings ...)
  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 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 23/27] i2c-hid: " Zhang Rui
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/acpi/dock.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/dock.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 05ea4be..ca86c1c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -441,7 +441,7 @@ static void handle_dock(struct dock_station *ds, int dock)
 	acpi_status status;
 	struct acpi_object_list arg_list;
 	union acpi_object arg;
-	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+	unsigned long long value;
 
 	acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
 
@@ -450,12 +450,10 @@ static void handle_dock(struct dock_station *ds, int dock)
 	arg_list.pointer = &arg;
 	arg.type = ACPI_TYPE_INTEGER;
 	arg.integer.value = dock;
-	status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
+	status = acpi_evaluate_integer(ds->handle, "_DCK", &arg_list, &value);
 	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
 		acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
 				status);
-
-	kfree(buffer.pointer);
 }
 
 static inline void dock(struct dock_station *ds)
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 23/27] i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (21 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 22/27] ACPI: dock: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-04 10:14   ` Jiri Kosina
  2013-09-03  0:32 ` [PATCH 24/27] fujitsu-laptop: " Zhang Rui
                   ` (4 subsequent siblings)
  27 siblings, 1 reply; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Benjamin Tissoires, Jiri Kosina

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/hid/i2c-hid/i2c-hid.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Benjamin Tissoires <benjamin.tissoires@redhat.com>
CC: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/i2c-hid/i2c-hid.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 05d4f96..dbca084 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -854,10 +854,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
 		0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
 		0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
 	};
-	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object params[4], *obj;
+	union acpi_object params[4];
 	struct acpi_object_list input;
 	struct acpi_device *adev;
+	unsigned long long value;
 	acpi_handle handle;
 
 	handle = ACPI_HANDLE(&client->dev);
@@ -877,22 +877,14 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
 	params[3].type = ACPI_TYPE_INTEGER;
 	params[3].integer.value = 0;
 
-	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf))) {
+	if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_DSM", &input,
+								&value))) {
 		dev_err(&client->dev, "device _DSM execution failed\n");
 		return -ENODEV;
 	}
 
-	obj = (union acpi_object *)buf.pointer;
-	if (obj->type != ACPI_TYPE_INTEGER) {
-		dev_err(&client->dev, "device _DSM returned invalid type: %d\n",
-			obj->type);
-		kfree(buf.pointer);
-		return -EINVAL;
-	}
-
-	pdata->hid_descriptor_address = obj->integer.value;
+	pdata->hid_descriptor_address = value;
 
-	kfree(buf.pointer);
 	return 0;
 }
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 24/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (22 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 23/27] i2c-hid: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03 13:12   ` Jonathan Woithe
  2013-09-03  0:32 ` [PATCH 25/27] intel-rst: " Zhang Rui
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw
  Cc: linux-pm, Zhang Rui, Matthew Garrett, Jonathan Woithe,
	platform-driver-x86

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/platform/x86/fujitsu-laptop.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/fujitsu-laptop.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 765d8c1..9d30d69 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -219,8 +219,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
 	{ .type = ACPI_TYPE_INTEGER }
 	};
 	struct acpi_object_list arg_list = { 4, &params[0] };
-	struct acpi_buffer output;
-	union acpi_object out_obj;
+	unsigned long long value;
 	acpi_handle handle = NULL;
 
 	status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
@@ -235,10 +234,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
 	params[2].integer.value = arg1;
 	params[3].integer.value = arg2;
 
-	output.length = sizeof(out_obj);
-	output.pointer = &out_obj;
-
-	status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
+	status = acpi_evaluate_integer(handle, NULL, &arg_list, &value);
 	if (ACPI_FAILURE(status)) {
 		vdbg_printk(FUJLAPTOP_DBG_WARN,
 			"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
@@ -246,18 +242,10 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
 		return -ENODEV;
 	}
 
-	if (out_obj.type != ACPI_TYPE_INTEGER) {
-		vdbg_printk(FUJLAPTOP_DBG_WARN,
-			"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
-			"return an integer\n",
-			cmd, arg0, arg1, arg2);
-		return -ENODEV;
-	}
-
 	vdbg_printk(FUJLAPTOP_DBG_TRACE,
 		"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
-			cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
-	return out_obj.integer.value;
+			cmd, arg0, arg1, arg2, (int)value);
+	return value;
 }
 
 #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 25/27] intel-rst: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (23 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 24/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03  0:32 ` [PATCH 26/27] intel-smartconnect: " Zhang Rui
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/platform/x86/intel-rst.c in this patch.
Plus, this should also fix a memory leak that
the acpi_buffer is not freed in some cases.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/intel-rst.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
index fdf8ca0..6bdfe46 100644
--- a/drivers/platform/x86/intel-rst.c
+++ b/drivers/platform/x86/intel-rst.c
@@ -29,24 +29,16 @@ static ssize_t irst_show_wakeup_events(struct device *dev,
 				       char *buf)
 {
 	struct acpi_device *acpi;
-	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *result;
+	unsigned long long value;
 	acpi_status status;
 
 	acpi = to_acpi_device(dev);
 
-	status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output);
+	status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
 	if (!ACPI_SUCCESS(status))
 		return -EINVAL;
 
-	result = output.pointer;
-
-	if (result->type != ACPI_TYPE_INTEGER) {
-		kfree(result);
-		return -EINVAL;
-	}
-
-	return sprintf(buf, "%lld\n", result->integer.value);
+	return sprintf(buf, "%lld\n", value);
 }
 
 static ssize_t irst_store_wakeup_events(struct device *dev,
@@ -83,24 +75,16 @@ static ssize_t irst_show_wakeup_time(struct device *dev,
 				     struct device_attribute *attr, char *buf)
 {
 	struct acpi_device *acpi;
-	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *result;
+	unsigned long long value;
 	acpi_status status;
 
 	acpi = to_acpi_device(dev);
 
-	status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output);
+	status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
 	if (!ACPI_SUCCESS(status))
 		return -EINVAL;
 
-	result = output.pointer;
-
-	if (result->type != ACPI_TYPE_INTEGER) {
-		kfree(result);
-		return -EINVAL;
-	}
-
-	return sprintf(buf, "%lld\n", result->integer.value);
+	return sprintf(buf, "%lld\n", value);
 }
 
 static ssize_t irst_store_wakeup_time(struct device *dev,
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 26/27] intel-smartconnect: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (24 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 25/27] intel-rst: " Zhang Rui
@ 2013-09-03  0:32 ` 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
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/platform/x86/intel-smartconnect.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/intel-smartconnect.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/platform/x86/intel-smartconnect.c b/drivers/platform/x86/intel-smartconnect.c
index 9758b00..88a30e3 100644
--- a/drivers/platform/x86/intel-smartconnect.c
+++ b/drivers/platform/x86/intel-smartconnect.c
@@ -25,28 +25,18 @@ MODULE_LICENSE("GPL");
 
 static int smartconnect_acpi_init(struct acpi_device *acpi)
 {
-	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *result;
+	unsigned long long value;
 	acpi_status status;
 
-	status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output);
+	status = acpi_evaluate_integer(acpi->handle, "GAOS", NULL, &value);
 	if (!ACPI_SUCCESS(status))
 		return -EINVAL;
 
-	result = output.pointer;
-
-	if (result->type != ACPI_TYPE_INTEGER) {
-		kfree(result);
-		return -EINVAL;
-	}
-
-	if (result->integer.value & 0x1) {
+	if (value & 0x1) {
 		dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
 		status = acpi_execute_simple_method(acpi->handle, "SAOS", 0);
 	}
 
-	kfree(result);
-
 	return 0;
 }
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 27/27] toshiba_acpi: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (25 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 26/27] intel-smartconnect: " Zhang Rui
@ 2013-09-03  0:32 ` Zhang Rui
  2013-09-03 11:24 ` [PATCH 00/27] ACPI AML helper conversion Rafael J. Wysocki
  27 siblings, 0 replies; 38+ messages in thread
From: Zhang Rui @ 2013-09-03  0:32 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui, Matthew Garrett, platform-driver-x86

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/platform/x86/toshiba_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/toshiba_acpi.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 235185b..0cfadb6 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -940,21 +940,17 @@ static void toshiba_acpi_hotkey_work(struct work_struct *work)
  */
 static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev *dev)
 {
-	struct acpi_buffer buf;
-	union acpi_object out_obj;
+	unsigned long long value;
 	acpi_status status;
 
-	buf.pointer = &out_obj;
-	buf.length = sizeof(out_obj);
-
-	status = acpi_evaluate_object(dev->acpi_dev->handle, "INFO",
-				      NULL, &buf);
-	if (ACPI_FAILURE(status) || out_obj.type != ACPI_TYPE_INTEGER) {
+	status = acpi_evaluate_integer(dev->acpi_dev->handle, "INFO",
+				      NULL, &value);
+	if (ACPI_FAILURE(status)) {
 		pr_err("ACPI INFO method execution failed\n");
 		return -EIO;
 	}
 
-	return out_obj.integer.value;
+	return value;
 }
 
 static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  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
  2 siblings, 0 replies; 38+ messages in thread
From: Mika Westerberg @ 2013-09-03  7:17 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Mathias Nyman, Linus Walleij

On Tue, Sep 03, 2013 at 08:31:50AM +0800, Zhang Rui wrote:
> acpi_execute_simple_method() is a new ACPI API introduced to invoke
> an ACPI control method that has single integer parameter and no return value.
> 
> Convert acpi_evaluate_object() to acpi_execute_simple_method()
> in drivers/gpio/gpiolib-acpi.c
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Mathias Nyman <mathias.nyman@linux.intel.com>
> CC: Mika Westerberg <mika.westerberg@linux.intel.com>

Nice!

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  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
  2 siblings, 0 replies; 38+ messages in thread
From: Mathias Nyman @ 2013-09-03  7:42 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Mika Westerberg, Linus Walleij

On 09/03/2013 03:31 AM, Zhang Rui wrote:
> acpi_execute_simple_method() is a new ACPI API introduced to invoke
> an ACPI control method that has single integer parameter and no return value.
>
> Convert acpi_evaluate_object() to acpi_execute_simple_method()
> in drivers/gpio/gpiolib-acpi.c
>
> Signed-off-by: Zhang Rui<rui.zhang@intel.com>
> CC: Mathias Nyman<mathias.nyman@linux.intel.com>
> CC: Mika Westerberg<mika.westerberg@linux.intel.com>
> CC: Linus Walleij<linus.walleij@linaro.org>
> ---
>   drivers/gpio/gpiolib-acpi.c | 9 +--------
>   1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 5c1ef2b..f2beb72 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -73,15 +73,8 @@ static irqreturn_t acpi_gpio_irq_handler(int irq, void *data)
>   static irqreturn_t acpi_gpio_irq_handler_evt(int irq, void *data)
>   {
>   	struct acpi_gpio_evt_pin *evt_pin = data;
> -	struct acpi_object_list args;
> -	union acpi_object arg;
>
> -	arg.type = ACPI_TYPE_INTEGER;
> -	arg.integer.value = evt_pin->pin;
> -	args.count = 1;
> -	args.pointer =&arg;
> -
> -	acpi_evaluate_object(evt_pin->evt_handle, NULL,&args, NULL);
> +	acpi_execute_simple_method(evt_pin->evt_handle, NULL, evt_pin->pin);
>
>   	return IRQ_HANDLED;
>   }


Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/27] ACPI AML helper conversion
  2013-09-03  0:31 [PATCH 00/27] ACPI AML helper conversion Zhang Rui
                   ` (26 preceding siblings ...)
  2013-09-03  0:32 ` [PATCH 27/27] toshiba_acpi: " Zhang Rui
@ 2013-09-03 11:24 ` Rafael J. Wysocki
  27 siblings, 0 replies; 38+ messages in thread
From: Rafael J. Wysocki @ 2013-09-03 11:24 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, ACPI Devel Maling List

On Tuesday, September 03, 2013 08:31:48 AM Zhang Rui wrote:
> Hi, all,
> 
> ACPI has some fine grained helpers for evaluating AML,
> which can be used to simplify the code a lot.
> And there are a couple of new helpers introduced recently,
> say, acpi_has_method/acpi_execute_simple_method, etc.
> 
> This patch set does some cleanup and converts the code to use
> the AML helpers when possible.
> 
> Patch 01/27 ~ Patch 09/27:
> converts acpi_evaluate_object() to acpi_execute_simple_method()
> Patch 10/27 ~ Patch 20/27:
> converts acpi_get_handle() to acpi_has_method()
> Patch 21/27 ~ Patch 27/27:
> converts acpi_evaluate_object() to acpi_evaluate_integer()
> 
> Given that there is no functional change in this patch set, and most of the
> patches are not able for me to test as they are platform driver changes,
> I just did build test and reboot with acpi_processor, i915 driver loaded
> on an Lenovo Ultrabook, and everything works well.

Nice series, I'm going to queue it up for 3.13.

Thanks!


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
  2013-09-03  0:31 ` [PATCH 04/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03 13:11   ` Jonathan Woithe
  0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Woithe @ 2013-09-03 13:11 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Matthew Garrett, platform-driver-x86, jwoithe

This (and the other two along similar lines) look ok to me.

Acked-by: Jonathan Woithe <jwoithe@just42.net>

On Tue, Sep 03, 2013 at 08:31:52AM +0800, Zhang Rui wrote:
> acpi_execute_simple_method() is a new ACPI API introduced to invoke
> an ACPI control method that has single integer parameter and no return value.
> 
> Convert acpi_evaluate_object() to acpi_execute_simple_method()
> in drivers/platform/x86/fujitsu-laptop.c
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Matthew Garrett <matthew.garrett@nebula.com>
> CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
> CC: platform-driver-x86@vger.kernel.org
> ---
>  drivers/platform/x86/fujitsu-laptop.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 52b8a97..29738cb 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -317,8 +317,6 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev)
>  static int set_lcd_level(int level)
>  {
>  	acpi_status status = AE_OK;
> -	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
> -	struct acpi_object_list arg_list = { 1, &arg0 };
>  	acpi_handle handle = NULL;
>  
>  	vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
> @@ -333,9 +331,8 @@ static int set_lcd_level(int level)
>  		return -ENODEV;
>  	}
>  
> -	arg0.integer.value = level;
>  
> -	status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
> +	status = acpi_execute_simple_method(handle, NULL, level);
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> @@ -345,8 +342,6 @@ static int set_lcd_level(int level)
>  static int set_lcd_level_alt(int level)
>  {
>  	acpi_status status = AE_OK;
> -	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
> -	struct acpi_object_list arg_list = { 1, &arg0 };
>  	acpi_handle handle = NULL;
>  
>  	vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
> @@ -361,9 +356,7 @@ static int set_lcd_level_alt(int level)
>  		return -ENODEV;
>  	}
>  
> -	arg0.integer.value = level;
> -
> -	status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
> +	status = acpi_execute_simple_method(handle, NULL, level);
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> -- 
> 1.8.1.2

-- 
Dr Jonathan Woithe
  Research Scientist and System administrator
  Atmospheric Radar Systems
  email:   jwoithe@atrad.com.au
  website: http://www.physics.adelaide.edu.au/~jwoithe

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 15/27] fujitsu-laptop: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:32 ` [PATCH 15/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03 13:11   ` Jonathan Woithe
  0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Woithe @ 2013-09-03 13:11 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Matthew Garrett, platform-driver-x86, jwoithe

Acked-by: Jonathan Woithe <jwoithe@just42.net>

On Tue, Sep 03, 2013 at 08:32:03AM +0800, Zhang Rui wrote:
> 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/fujitsu-laptop.c in this patch.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Matthew Garrett <matthew.garrett@nebula.com>
> CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
> CC: platform-driver-x86@vger.kernel.org
> ---
>  drivers/platform/x86/fujitsu-laptop.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 29738cb..765d8c1 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -579,11 +579,10 @@ static struct platform_driver fujitsupf_driver = {
>  
>  static void dmi_check_cb_common(const struct dmi_system_id *id)
>  {
> -	acpi_handle handle;
>  	pr_info("Identified laptop model '%s'\n", id->ident);
>  	if (use_alt_lcd_levels == -1) {
> -		if (ACPI_SUCCESS(acpi_get_handle(NULL,
> -				"\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
> +		if (acpi_has_method(NULL,
> +				"\\_SB.PCI0.LPCB.FJEX.SBL2"))
>  			use_alt_lcd_levels = 1;
>  		else
>  			use_alt_lcd_levels = 0;
> @@ -646,7 +645,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = {
>  
>  static int acpi_fujitsu_add(struct acpi_device *device)
>  {
> -	acpi_handle handle;
>  	int result = 0;
>  	int state = 0;
>  	struct input_dev *input;
> @@ -695,8 +693,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
>  
>  	fujitsu->dev = device;
>  
> -	if (ACPI_SUCCESS
> -	    (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
> +	if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
>  		vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
>  		if (ACPI_FAILURE
>  		    (acpi_evaluate_object
> @@ -796,7 +793,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
>  
>  static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
>  {
> -	acpi_handle handle;
>  	int result = 0;
>  	int state = 0;
>  	struct input_dev *input;
> @@ -859,8 +855,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
>  
>  	fujitsu_hotkey->dev = device;
>  
> -	if (ACPI_SUCCESS
> -	    (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
> +	if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
>  		vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
>  		if (ACPI_FAILURE
>  		    (acpi_evaluate_object
> -- 
> 1.8.1.2

-- 
Dr Jonathan Woithe
  Research Scientist and System administrator
  Atmospheric Radar Systems
  email:   jwoithe@atrad.com.au
  website: http://www.physics.adelaide.edu.au/~jwoithe

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 24/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-03  0:32 ` [PATCH 24/27] fujitsu-laptop: " Zhang Rui
@ 2013-09-03 13:12   ` Jonathan Woithe
  0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Woithe @ 2013-09-03 13:12 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Matthew Garrett, platform-driver-x86, jwoithe

Acked-by: Jonathan Woithe <jwoithe@just42.net>

On Tue, Sep 03, 2013 at 08:32:12AM +0800, Zhang Rui wrote:
> acpi_evaluate_integer() is an ACPI API introduced to evaluate an
> ACPI control method that is known to have an integer return value.
> This API can simplify the code because the calling function does not need to
> use the specified acpi_buffer structure required by acpi_evaluate_object();
> 
> Convert acpi_evaluate_object() to acpi_evaluate_integer()
> in drivers/platform/x86/fujitsu-laptop.c in this patch.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Matthew Garrett <matthew.garrett@nebula.com>
> CC: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
> CC: platform-driver-x86@vger.kernel.org
> ---
>  drivers/platform/x86/fujitsu-laptop.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 765d8c1..9d30d69 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -219,8 +219,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
>  	{ .type = ACPI_TYPE_INTEGER }
>  	};
>  	struct acpi_object_list arg_list = { 4, &params[0] };
> -	struct acpi_buffer output;
> -	union acpi_object out_obj;
> +	unsigned long long value;
>  	acpi_handle handle = NULL;
>  
>  	status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
> @@ -235,10 +234,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
>  	params[2].integer.value = arg1;
>  	params[3].integer.value = arg2;
>  
> -	output.length = sizeof(out_obj);
> -	output.pointer = &out_obj;
> -
> -	status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
> +	status = acpi_evaluate_integer(handle, NULL, &arg_list, &value);
>  	if (ACPI_FAILURE(status)) {
>  		vdbg_printk(FUJLAPTOP_DBG_WARN,
>  			"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
> @@ -246,18 +242,10 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
>  		return -ENODEV;
>  	}
>  
> -	if (out_obj.type != ACPI_TYPE_INTEGER) {
> -		vdbg_printk(FUJLAPTOP_DBG_WARN,
> -			"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
> -			"return an integer\n",
> -			cmd, arg0, arg1, arg2);
> -		return -ENODEV;
> -	}
> -
>  	vdbg_printk(FUJLAPTOP_DBG_TRACE,
>  		"FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
> -			cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
> -	return out_obj.integer.value;
> +			cmd, arg0, arg1, arg2, (int)value);
> +	return value;
>  }
>  
>  #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
> -- 
> 1.8.1.2

-- 
Dr Jonathan Woithe
  Research Scientist and System administrator
  Atmospheric Radar Systems
  email:   jwoithe@atrad.com.au
  website: http://www.physics.adelaide.edu.au/~jwoithe

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 23/27] i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
  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
  0 siblings, 1 reply; 38+ messages in thread
From: Jiri Kosina @ 2013-09-04 10:14 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Benjamin Tissoires

On Tue, 3 Sep 2013, Zhang Rui wrote:

> acpi_evaluate_integer() is an ACPI API introduced to evaluate an
> ACPI control method that is known to have an integer return value.
> This API can simplify the code because the calling function does not need to
> use the specified acpi_buffer structure required by acpi_evaluate_object();
> 
> Convert acpi_evaluate_object() to acpi_evaluate_integer()
> in drivers/hid/i2c-hid/i2c-hid.c in this patch.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> CC: Jiri Kosina <jkosina@suse.cz>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  drivers/hid/i2c-hid/i2c-hid.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> index 05d4f96..dbca084 100644
> --- a/drivers/hid/i2c-hid/i2c-hid.c
> +++ b/drivers/hid/i2c-hid/i2c-hid.c
> @@ -854,10 +854,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
>  		0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
>  		0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
>  	};
> -	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
> -	union acpi_object params[4], *obj;
> +	union acpi_object params[4];
>  	struct acpi_object_list input;
>  	struct acpi_device *adev;
> +	unsigned long long value;
>  	acpi_handle handle;
>  
>  	handle = ACPI_HANDLE(&client->dev);
> @@ -877,22 +877,14 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
>  	params[3].type = ACPI_TYPE_INTEGER;
>  	params[3].integer.value = 0;
>  
> -	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf))) {
> +	if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_DSM", &input,
> +								&value))) {
>  		dev_err(&client->dev, "device _DSM execution failed\n");
>  		return -ENODEV;
>  	}
>  
> -	obj = (union acpi_object *)buf.pointer;
> -	if (obj->type != ACPI_TYPE_INTEGER) {
> -		dev_err(&client->dev, "device _DSM returned invalid type: %d\n",
> -			obj->type);
> -		kfree(buf.pointer);
> -		return -EINVAL;
> -	}
> -
> -	pdata->hid_descriptor_address = obj->integer.value;
> +	pdata->hid_descriptor_address = value;
>  
> -	kfree(buf.pointer);
>  	return 0;
>  }
>  
> -- 
> 1.8.1.2
> 

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 23/27] i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
  2013-09-04 10:14   ` Jiri Kosina
@ 2013-09-06  8:17     ` Benjamin Tissoires
  0 siblings, 0 replies; 38+ messages in thread
From: Benjamin Tissoires @ 2013-09-06  8:17 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Zhang Rui, rjw, linux-pm

On 04/09/13 12:14, Jiri Kosina wrote:
> On Tue, 3 Sep 2013, Zhang Rui wrote:
> 
>> acpi_evaluate_integer() is an ACPI API introduced to evaluate an
>> ACPI control method that is known to have an integer return value.
>> This API can simplify the code because the calling function does not need to
>> use the specified acpi_buffer structure required by acpi_evaluate_object();
>>
>> Convert acpi_evaluate_object() to acpi_evaluate_integer()
>> in drivers/hid/i2c-hid/i2c-hid.c in this patch.
>>
>> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
>> CC: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> CC: Jiri Kosina <jkosina@suse.cz>
> 
> Acked-by: Jiri Kosina <jkosina@suse.cz>

As long as it does not break current DSM handling (I can not test this
part of the code),

Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 11/27] i915: intel_acpi: convert acpi_get_handle() to acpi_has_method()
  2013-09-03  0:31 ` [PATCH 11/27] i915: intel_acpi: " Zhang Rui
@ 2013-09-09  8:57   ` Daniel Vetter
  0 siblings, 0 replies; 38+ messages in thread
From: Daniel Vetter @ 2013-09-09  8:57 UTC (permalink / raw)
  To: Zhang Rui; +Cc: rjw, linux-pm, Daniel Vetter, Intel Graphics Development

On Tue, Sep 03, 2013 at 08:31:59AM +0800, Zhang Rui wrote:
> 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/gpu/drm/i915/intel_acpi.c in this patch.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Daniel Vetter <daniel.vetter@ffwll.ch>

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/intel_acpi.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c
> index 57fe1ae..43959ed 100644
> --- a/drivers/gpu/drm/i915/intel_acpi.c
> +++ b/drivers/gpu/drm/i915/intel_acpi.c
> @@ -193,16 +193,14 @@ static void intel_dsm_platform_mux_info(void)
>  
>  static bool intel_dsm_pci_probe(struct pci_dev *pdev)
>  {
> -	acpi_handle dhandle, intel_handle;
> -	acpi_status status;
> +	acpi_handle dhandle;
>  	int ret;
>  
>  	dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
>  	if (!dhandle)
>  		return false;
>  
> -	status = acpi_get_handle(dhandle, "_DSM", &intel_handle);
> -	if (ACPI_FAILURE(status)) {
> +	if (!acpi_has_method(dhandle, "_DSM")) {
>  		DRM_DEBUG_KMS("no _DSM method for intel device\n");
>  		return false;
>  	}
> -- 
> 1.8.1.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
  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
  2 siblings, 0 replies; 38+ messages in thread
From: Linus Walleij @ 2013-09-17 12:55 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Rafael J. Wysocki, linux-pm, Mathias Nyman, Mika Westerberg

On Tue, Sep 3, 2013 at 2:31 AM, Zhang Rui <rui.zhang@intel.com> wrote:

> acpi_execute_simple_method() is a new ACPI API introduced to invoke
> an ACPI control method that has single integer parameter and no return value.
>
> Convert acpi_evaluate_object() to acpi_execute_simple_method()
> in drivers/gpio/gpiolib-acpi.c
>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> CC: Mathias Nyman <mathias.nyman@linux.intel.com>
> CC: Mika Westerberg <mika.westerberg@linux.intel.com>
> CC: Linus Walleij <linus.walleij@linaro.org>

Patch applied with Mathias and Mika's ACKs!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2013-09-17 12:55 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 17/27] sony-laptop: " Zhang Rui
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.