ACPI AML helper conversion
Subsystems (17)
cover ACPI AML helper conversion
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=yCONFIG_ACPI_DOCK=yCONFIG_X86_PCC_CPUFREQ=yCONFIG_GPIO_ACPI=yCONFIG_DRM_I915=mCONFIG_DRM_NOUVEAU=m
ONFIG_I2C_HID=mCONFIG_HOTPLUG_PCI=yCONFIG_EEEPC_LAPTOP=yCONFIG_FUJITSU_LAPTOP=yCONFIG_INTEL_RST=mCONFIG_INTEL_SMARTCONNECT=yCONFIG_INTEL_MENLOW=yCONFIG_SONY_LAPTOP=yCONFIG_TOPSTAR_LAPTOP=yCONFIG_ACPI_TOSHIBA=yCONFIG_ACPI_WMI=yCONFIG_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(-)
PATCH 1/27 olpc_xo15_sci: convert acpi_evaluate_object() to acpi_execute_simple_method()
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
--- arch/x86/platform/olpc/olpc-xo15-sci.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
arch/x86/platform/olpc/olpc-xo15-sci.c +1 -8
@@ -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 ;
Signature · 1 line
1.8.1.2
PATCH 2/27 gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/gpio/gpiolib-acpi.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpio/gpiolib-acpi.c +1 -8
@@ -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 ; }
Signature · 1 line
1.8.1.2
Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
Quoted 9 lines · Zhang Rui
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()toacpi_execute_simple_method()indrivers/gpio/gpiolib-acpi.cSigned-off-by Zhang Rui <[email protected]>CC Mathias Nyman <[email protected]>CC Mika Westerberg <[email protected]>
Nice!
Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang RuiQuoted 25 lines · Zhang Rui
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()toacpi_execute_simple_method()indrivers/gpio/gpiolib-acpi.cSigned-off-by Zhang Rui<[email protected]>CC Mathias Nyman<[email protected]>CC Mika Westerberg<[email protected]>CC Linus Walleij<[email protected]>--- drivers/gpio/gpiolib-acpi.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)drivers/gpio/gpiolib-acpi.c +0
-2@@ -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;
drivers/gpio/gpiolib-acpi.c static irqreturn_t acpi_gpio_irq_handler(int irq, void *data) · line 80
Quoted 10 lines
drivers/gpio/gpiolib-acpi.c +1
-6- 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 ; }
Re: [PATCH 02/27] gpiolib-acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang RuiQuoted 10 lines · Zhang Rui
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()toacpi_execute_simple_method()indrivers/gpio/gpiolib-acpi.cSigned-off-by Zhang Rui <[email protected]>CC Mathias Nyman <[email protected]>CC Mika Westerberg <[email protected]>CC Linus Walleij <[email protected]>
Patch applied with Mathias and Mika's ACKs!
Yours,
Linus Walleij
PATCH 3/27 eeepc-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/eeepc-laptop.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/platform/x86/eeepc-laptop.c +1 -7
@@ -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, ¶ms,NULL );return (status ==AE_OK ?0 :-1 ); }
Signature · 1 line
1.8.1.2
PATCH 4/27 fujitsu-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/fujitsu-laptop.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/fujitsu-laptop.c +2 -9
@@ -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 ;
Signature · 1 line
1.8.1.2
Re: [PATCH 04/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
This (and the other two along similar lines) look ok to me.
Quoted 59 lines · Zhang Rui
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()toacpi_execute_simple_method()indrivers/platform/x86/fujitsu-laptop.cSigned-off-by Zhang Rui <[email protected]>CC Matthew Garrett <[email protected]>CC Jonathan Woithe <[email protected]>--- drivers/platform/x86/fujitsu-laptop.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/platform/x86/fujitsu-laptop.c +2
-9@@ -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 ;Signature · 1 line
1.8.1.2
Signature · 5 lines
Dr Jonathan Woithe Research Scientist and System administrator Atmospheric Radar Systems email: [email protected] website: http://www.physics.adelaide.edu.au/~jwoithe
PATCH 5/27 intel-rst: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/intel-rst.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
drivers/platform/x86/intel-rst.c +2 -18
@@ -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 = ¶m; - - 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 = ¶m; - - status =acpi_evaluate_object (acpi->handle,"SFTV" , &input,NULL ); + status =acpi_execute_simple_method (acpi->handle,"SFTV" , value);if (!ACPI_SUCCESS (status))return -EINVAL ;
Signature · 1 line
1.8.1.2
PATCH 6/27 intel-smartconnect: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/intel-smartconnect.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/platform/x86/intel-smartconnect.c +1 -10
@@ -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 = ¶m; -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);
Signature · 1 line
1.8.1.2
PATCH 7/27 topstar-laptop: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/topstar-laptop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/topstar-laptop.c +2 -6
@@ -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 ;
Signature · 1 line
1.8.1.2
PATCH 8/27 toshiba_acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/toshiba_acpi.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/platform/x86/toshiba_acpi.c +1 -8
@@ -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, ¶ms,NULL ); + status =acpi_execute_simple_method (NULL , (char *)methodName, val);return (status ==AE_OK ) ?0 : -EIO ; }
Signature · 1 line
1.8.1.2
PATCH 9/27 wmi: convert acpi_evaluate_object() to acpi_execute_simple_method()
In reply to Zhang Ruiacpi_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
--- drivers/platform/x86/wmi.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)
drivers/platform/x86/wmi.c +6 -19
@@ -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;
Signature · 1 line
1.8.1.2
PATCH 10/27 pcc_freq: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/cpufreq/pcc-cpufreq.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpufreq/pcc-cpufreq.c +2 -3
@@ -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);
Signature · 1 line
1.8.1.2
PATCH 11/27 i915: intel_acpi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/gpu/drm/i915/intel_acpi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_acpi.c +2 -4
@@ -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; }
Signature · 1 line
1.8.1.2
Re: [PATCH 11/27] i915: intel_acpi: convert acpi_get_handle() to acpi_has_method()
Quoted 8 lines · 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.
Quoted 5 lines
Convert
acpi_get_handle()toacpi_has_method()indrivers/gpu/drm/i915/intel_acpi.cin this patch.Signed-off-by Zhang Rui <[email protected]>CC Daniel Vetter <[email protected]>
Quoted 30 lines
--- drivers/gpu/drm/i915/intel_acpi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_acpi.c +2
-4@@ -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; }Signature · 1 line
1.8.1.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 12/27 nouveau_acpi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/gpu/drm/nouveau/nouveau_acpi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_acpi.c +2 -5
@@ -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 ;
Signature · 1 line
1.8.1.2
PATCH 13/27 acpi_pcihp: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/pci/hotplug/acpi_pcihp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/hotplug/acpi_pcihp.c +2 -5
@@ -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)
Signature · 1 line
1.8.1.2
PATCH 14/27 pci-acpi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/pci/pci-acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/pci-acpi.c +1 -2
@@ -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) {
Signature · 1 line
1.8.1.2
PATCH 15/27 fujitsu-laptop: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/fujitsu-laptop.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/platform/x86/fujitsu-laptop.c +4 -9
@@ -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
Signature · 1 line
1.8.1.2
Re: [PATCH 15/27] fujitsu-laptop: convert acpi_get_handle() to acpi_has_method()
Quoted 75 lines · 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()toacpi_has_method()indrivers/platform/x86/fujitsu-laptop.cin this patch.Signed-off-by Zhang Rui <[email protected]>CC Matthew Garrett <[email protected]>CC Jonathan Woithe <[email protected]>--- drivers/platform/x86/fujitsu-laptop.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/platform/x86/fujitsu-laptop.c +4
-9@@ -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_objectSignature · 1 line
1.8.1.2
Signature · 5 lines
Dr Jonathan Woithe Research Scientist and System administrator Atmospheric Radar Systems email: [email protected] website: http://www.physics.adelaide.edu.au/~jwoithe
PATCH 16/27 intel_menlow: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/intel_menlow.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/intel_menlow.c +2 -6
@@ -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,
Signature · 1 line
1.8.1.2
PATCH 17/27 sony-laptop: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/sony-laptop.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/platform/x86/sony-laptop.c +9 -19
@@ -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 ;
Signature · 1 line
1.8.1.2
PATCH 18/27 toshiba_acpi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/toshiba_acpi.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/platform/x86/toshiba_acpi.c +6 -15
@@ -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 ;
Signature · 1 line
1.8.1.2
PATCH 19/27 wmi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/wmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/platform/x86/wmi.c +2 -3
@@ -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 ); }
Signature · 1 line
1.8.1.2
PATCH 20/27 pnpacpi: convert acpi_get_handle() to acpi_has_method()
In reply to Zhang Ruiacpi_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.
--- drivers/pnp/pnpacpi/core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/pnp/pnpacpi/core.c +3 -8
@@ -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)))
Signature · 1 line
1.8.1.2
PATCH 21/27 acpi_processor: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/acpi/acpi_processor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/acpi_processor.c +3 -3
@@ -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 ; }
Signature · 1 line
1.8.1.2
PATCH 22/27 ACPI: dock: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/acpi/dock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/acpi/dock.c +2 -4
@@ -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)
Signature · 1 line
1.8.1.2
PATCH 23/27 i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/hid/i2c-hid/i2c-hid.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/hid/i2c-hid/i2c-hid.c +5 -13
@@ -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 ; }
Signature · 1 line
1.8.1.2
Re: [PATCH 23/27] i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
Quoted 11 lines · 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 specifiedacpi_bufferstructure required byacpi_evaluate_object();Convert
acpi_evaluate_object()toacpi_evaluate_integer()indrivers/hid/i2c-hid/i2c-hid.cin this patch.Signed-off-by Zhang Rui <[email protected]>CC Benjamin Tissoires <[email protected]>CC Jiri Kosina <[email protected]>
Quoted 50 lines
--- drivers/hid/i2c-hid/i2c-hid.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)drivers/hid/i2c-hid/i2c-hid.c +5
-13@@ -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 ; }Signature · 1 line
1.8.1.2
Signature · 2 lines
Jiri Kosina SUSE Labs
Benjamin Tissoires
Acked-byRe: [PATCH 23/27] i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
Quoted 7 lines · Jiri Kosina
Quoted 5 lines · 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 specifiedacpi_bufferstructure required byacpi_evaluate_object();
Quoted 8 lines
Quoted 6 lines
Convert
acpi_evaluate_object()toacpi_evaluate_integer()indrivers/hid/i2c-hid/i2c-hid.cin this patch.Signed-off-by Zhang Rui <[email protected]>CC Benjamin Tissoires <[email protected]>CC Jiri Kosina <[email protected]>Acked-by Jiri Kosina <[email protected]>
As long as it does not break current DSM handling (I can not test this part of the code),
Cheers,
Benjamin
PATCH 24/27 fujitsu-laptop: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/fujitsu-laptop.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/platform/x86/fujitsu-laptop.c +4 -16
@@ -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 , ¶ms[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 )
Signature · 1 line
1.8.1.2
Re: [PATCH 24/27] fujitsu-laptop: convert acpi_evaluate_object() to acpi_evaluate_integer()
Quoted 65 lines · 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 specifiedacpi_bufferstructure required byacpi_evaluate_object();Convert
acpi_evaluate_object()toacpi_evaluate_integer()indrivers/platform/x86/fujitsu-laptop.cin this patch.Signed-off-by Zhang Rui <[email protected]>CC Matthew Garrett <[email protected]>CC Jonathan Woithe <[email protected]>--- drivers/platform/x86/fujitsu-laptop.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)drivers/platform/x86/fujitsu-laptop.c +4
-16@@ -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 , ¶ms[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 )Signature · 1 line
1.8.1.2
Signature · 5 lines
Dr Jonathan Woithe Research Scientist and System administrator Atmospheric Radar Systems email: [email protected] website: http://www.physics.adelaide.edu.au/~jwoithe
PATCH 25/27 intel-rst: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/intel-rst.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/platform/x86/intel-rst.c +6 -22
@@ -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,
Signature · 1 line
1.8.1.2
PATCH 26/27 intel-smartconnect: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/intel-smartconnect.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/platform/x86/intel-smartconnect.c +3 -13
@@ -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 ; }
Signature · 1 line
1.8.1.2
PATCH 27/27 toshiba_acpi: convert acpi_evaluate_object() to acpi_evaluate_integer()
In reply to Zhang Ruiacpi_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.
--- drivers/platform/x86/toshiba_acpi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/platform/x86/toshiba_acpi.c +5 -9
@@ -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,
Signature · 1 line
1.8.1.2
Quoted 17 lines · 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:
convertsacpi_evaluate_object()toacpi_execute_simple_method()Patch 10/27 ~ Patch 20/27:
convertsacpi_get_handle()toacpi_has_method()
Patch 21/27 ~ Patch 27/27:
convertsacpi_evaluate_object()toacpi_evaluate_integer()
Quoted 4 lines
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!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.