acpi: avoid using internal acpica structures
Subsystems (2)
PATCH 7/8 acpi: avoid using internal acpica structures
Avoid using internal acpica structures acpi_namespace_node and acpi_operand_object Call acpi_get_name or acpi_get_object_info to get node name and method arg count
Signed-off-by: Lin Ming <[email protected]>
--- drivers/acpi/ec.c | 13 +++++++++++-- drivers/misc/sony-laptop.c | 15 +++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)
drivers/acpi/ec.c +11 -2
@@ -754,10 +754,19 @@ static acpi_status acpi_ec_register_query_methods(acpi_handle handle, u32 level, void *context, void **return_value) { - struct acpi_namespace_node *node = handle; + char node_name[5]; +struct acpi_buffer buffer = {sizeof (node_name), node_name };struct acpi_ec *ec = context;int value =0 ; -if (sscanf (node->name.ascii,"_Q%x" , &value) ==1 ) { +acpi_status status; + + status =acpi_get_name (handle,ACPI_SINGLE_NAME , &buffer); + +if (ACPI_FAILURE (status)) { +return status; + } + +if (sscanf (node_name,"_Q%x" , &value) ==1 ) {acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); }return AE_OK ;
drivers/misc/sony-laptop.c +9 -6
@@ -935,14 +935,17 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)static acpi_status sony_walk_callback (acpi_handle handle,u32 level,void *context,void **return_value) { -struct acpi_namespace_node *node; -union acpi_operand_object *operand; +struct acpi_device_info *info; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; - node = (struct acpi_namespace_node *)handle; - operand = (union acpi_operand_object *)node->object; +if (ACPI_SUCCESS (acpi_get_object_info (handle, &buffer))) { + info = buffer.pointer; - printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii, - (u32) operand->method.param_count); + printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", + (char *)info->name, info->param_count); + +kfree (buffer.pointer); + }return AE_OK ; }
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
At least, this patch should be split in two -- for each file it touches. Second, please don't return failure status from this function, as all functions under the EC scope should be tried, and not only ones before first failure. Thanks,
Alex.
Quoted 66 lines · Lin Ming
Avoid using internal acpica structures
acpi_namespace_nodeand acpi_operand_object Callacpi_get_nameoracpi_get_object_infoto get node name and method arg countSigned-off-by: Lin Ming <[email protected]>
--- drivers/acpi/ec.c | 13 +++++++++++-- drivers/misc/sony-laptop.c | 15 +++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)drivers/acpi/ec.c +11
-2@@ -754,10 +754,19 @@ static acpi_status acpi_ec_register_query_methods(acpi_handle handle, u32 level, void *context, void **return_value) { - struct acpi_namespace_node *node = handle; + char node_name[5]; +struct acpi_buffer buffer = {sizeof (node_name), node_name };struct acpi_ec *ec = context;int value =0 ; -if (sscanf (node->name.ascii,"_Q%x" , &value) ==1 ) { +acpi_status status; + + status =acpi_get_name (handle,ACPI_SINGLE_NAME , &buffer); + +if (ACPI_FAILURE (status)) { +return status; + } + +if (sscanf (node_name,"_Q%x" , &value) ==1 ) {acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); }return AE_OK ;drivers/misc/sony-laptop.c +9
-7@@ -935,14 +935,17 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)static acpi_status sony_walk_callback (acpi_handle handle,u32 level,void *context,void **return_value) { -struct acpi_namespace_node *node; -union acpi_operand_object *operand; +struct acpi_device_info *info; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; - node = (struct acpi_namespace_node *)handle; - operand = (union acpi_operand_object *)node->object; +if (ACPI_SUCCESS (acpi_get_object_info (handle, &buffer))) { + info = buffer.pointer; - printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii, - (u32) operand->method.param_count); + printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", + (char *)info->name, info->param_count); + +kfree (buffer.pointer); + }return AE_OK ; } --
Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Alexey Starikovskiy
At least, this patch should be split in two -- for each file it touches.
OK, will split it into two.
Quoted 3 lines
Second, please don't return failure status from this function, as all functions under
the EC scope should be tried, and not only ones before first failure.
How about below patch?
--- drivers/acpi/ec.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
drivers/acpi/ec.c +11 -3
@@ -754,12 +754,20 @@ static acpi_status acpi_ec_register_query_methods(acpi_handle handle, u32 level, void *context, void **return_value) { - struct acpi_namespace_node *node = handle; + char node_name[5]; +struct acpi_buffer buffer = {sizeof (node_name), node_name };struct acpi_ec *ec = context;int value =0 ; -if (sscanf (node->name.ascii,"_Q%x" , &value) ==1 ) { -acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); +acpi_status status; + + status =acpi_get_name (handle,ACPI_SINGLE_NAME , &buffer); + +if (ACPI_SUCCESS (status)) { +if (sscanf (node_name,"_Q%x" , &value) ==1 ) { +acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); + } } +return AE_OK ; }
Thanks for review,
Lin Ming
Quoted 68 lines
Thanks,
Alex.Quoted 65 lines · Lin Ming
Avoid using internal acpica structures
acpi_namespace_nodeand acpi_operand_object Callacpi_get_nameoracpi_get_object_infoto get node name and method arg countSigned-off-by: Lin Ming <[email protected]>
--- drivers/acpi/ec.c | 13 +++++++++++-- drivers/misc/sony-laptop.c | 15 +++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)drivers/acpi/ec.c +11
-2@@ -754,10 +754,19 @@ static acpi_status acpi_ec_register_query_methods(acpi_handle handle, u32 level, void *context, void **return_value) { - struct acpi_namespace_node *node = handle; + char node_name[5]; +struct acpi_buffer buffer = {sizeof (node_name), node_name };struct acpi_ec *ec = context;int value =0 ; -if (sscanf (node->name.ascii,"_Q%x" , &value) ==1 ) { +acpi_status status; + + status =acpi_get_name (handle,ACPI_SINGLE_NAME , &buffer); + +if (ACPI_FAILURE (status)) { +return status; + } + +if (sscanf (node_name,"_Q%x" , &value) ==1 ) {acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); }return AE_OK ;drivers/misc/sony-laptop.c +9
-6@@ -935,14 +935,17 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)static acpi_status sony_walk_callback (acpi_handle handle,u32 level,void *context,void **return_value) { -struct acpi_namespace_node *node; -union acpi_operand_object *operand; +struct acpi_device_info *info; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; - node = (struct acpi_namespace_node *)handle; - operand = (union acpi_operand_object *)node->object; +if (ACPI_SUCCESS (acpi_get_object_info (handle, &buffer))) { + info = buffer.pointer; - printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii, - (u32) operand->method.param_count); + printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", + (char *)info->name, info->param_count); + +kfree (buffer.pointer); + }return AE_OK ; }
Quoted 6 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · Lin Ming
Quoted 2 lines · Alexey Starikovskiy
At least, this patch should be split in two -- for each file it touches.
OK, will split it into two.
Quoted 3 lines
Second, please don't return failure status from this function, as all functions under the EC scope should be tried, and not only ones before first failure.
How about below patch?
--- drivers/acpi/ec.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)drivers/acpi/ec.c +1
-1@@ -754,12 +754,20 @@ static acpi_status acpi_ec_register_query_methods(acpi_handle handle, u32 level, void *context, void **return_value) { - struct acpi_namespace_node *node = handle; + char node_name[5];
drivers/acpi/ec.c static acpi_status · line 765
Quoted 10 lines
drivers/acpi/ec.c +4
-2+struct acpi_buffer buffer = {sizeof (node_name), node_name };struct acpi_ec *ec = context;int value =0 ; -if (sscanf (node->name.ascii,"_Q%x" , &value) ==1 ) { -acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); +acpi_status status; + + status =acpi_get_name (handle,ACPI_SINGLE_NAME , &buffer);
Merge the above two lines?
drivers/acpi/ec.c static acpi_status · line 773
Quoted 4 lines
drivers/acpi/ec.c +3
-0+ +if (ACPI_SUCCESS (status)) { +if (sscanf (node_name,"_Q%x" , &value) ==1 ) {
single if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) ?
Quoted 11 lines
drivers/acpi/ec.c +3
-0+acpi_ec_add_query_handler (ec, value, handle,NULL ,NULL ); + } } +return
AE_OK;
}Thanks for review,
Lin Ming
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines
Merge the above two lines?
drivers/acpi/ec.c static acpi_status · line 766
Quoted 5 lines
drivers/acpi/ec.c +3
-0+ +if (ACPI_SUCCESS (status)) { +if (sscanf (node_name,"_Q%x" , &value) ==1 ) {single if (
ACPI_SUCCESS(status)&&sscanf(node_name, "_Q%x", &value)== 1) ?
OK, that makes code compact.
Thanks,
Lin Ming