diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/acpica/acresrc.h | 6 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsalloc.c | 18 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsutils.c | 18 | ||||
-rw-r--r-- | drivers/acpi/acpica/rscalc.c | 9 | ||||
-rw-r--r-- | drivers/acpi/acpica/rscreate.c | 36 | ||||
-rw-r--r-- | drivers/acpi/acpica/rsutils.c | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/utdebug.c | 31 | ||||
-rw-r--r-- | drivers/acpi/nvs.c | 1 | ||||
-rw-r--r-- | drivers/acpi/pci_root.c | 3 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 2 | ||||
-rw-r--r-- | drivers/acpi/sleep.c | 2 | ||||
-rw-r--r-- | drivers/acpi/sysfs.c | 54 |
12 files changed, 109 insertions, 73 deletions
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h index f691d0e4d9fa..ff97430455cb 100644 --- a/drivers/acpi/acpica/acresrc.h +++ b/drivers/acpi/acpica/acresrc.h | |||
@@ -184,7 +184,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, | |||
184 | struct acpi_buffer *output_buffer); | 184 | struct acpi_buffer *output_buffer); |
185 | 185 | ||
186 | acpi_status | 186 | acpi_status |
187 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | 187 | acpi_rs_create_aml_resources(struct acpi_buffer *resource_list, |
188 | struct acpi_buffer *output_buffer); | 188 | struct acpi_buffer *output_buffer); |
189 | 189 | ||
190 | acpi_status | 190 | acpi_status |
@@ -227,8 +227,8 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
227 | u32 aml_buffer_length, acpi_size * size_needed); | 227 | u32 aml_buffer_length, acpi_size * size_needed); |
228 | 228 | ||
229 | acpi_status | 229 | acpi_status |
230 | acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer, | 230 | acpi_rs_get_aml_length(struct acpi_resource *resource_list, |
231 | acpi_size * size_needed); | 231 | acpi_size resource_list_size, acpi_size * size_needed); |
232 | 232 | ||
233 | acpi_status | 233 | acpi_status |
234 | acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | 234 | acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, |
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c index 243737363fb8..fd1ff54cda19 100644 --- a/drivers/acpi/acpica/nsalloc.c +++ b/drivers/acpi/acpica/nsalloc.c | |||
@@ -106,6 +106,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name) | |||
106 | void acpi_ns_delete_node(struct acpi_namespace_node *node) | 106 | void acpi_ns_delete_node(struct acpi_namespace_node *node) |
107 | { | 107 | { |
108 | union acpi_operand_object *obj_desc; | 108 | union acpi_operand_object *obj_desc; |
109 | union acpi_operand_object *next_desc; | ||
109 | 110 | ||
110 | ACPI_FUNCTION_NAME(ns_delete_node); | 111 | ACPI_FUNCTION_NAME(ns_delete_node); |
111 | 112 | ||
@@ -114,12 +115,13 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node) | |||
114 | acpi_ns_detach_object(node); | 115 | acpi_ns_detach_object(node); |
115 | 116 | ||
116 | /* | 117 | /* |
117 | * Delete an attached data object if present (an object that was created | 118 | * Delete an attached data object list if present (objects that were |
118 | * and attached via acpi_attach_data). Note: After any normal object is | 119 | * attached via acpi_attach_data). Note: After any normal object is |
119 | * detached above, the only possible remaining object is a data object. | 120 | * detached above, the only possible remaining object(s) are data |
121 | * objects, in a linked list. | ||
120 | */ | 122 | */ |
121 | obj_desc = node->object; | 123 | obj_desc = node->object; |
122 | if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { | 124 | while (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { |
123 | 125 | ||
124 | /* Invoke the attached data deletion handler if present */ | 126 | /* Invoke the attached data deletion handler if present */ |
125 | 127 | ||
@@ -127,7 +129,15 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node) | |||
127 | obj_desc->data.handler(node, obj_desc->data.pointer); | 129 | obj_desc->data.handler(node, obj_desc->data.pointer); |
128 | } | 130 | } |
129 | 131 | ||
132 | next_desc = obj_desc->common.next_object; | ||
130 | acpi_ut_remove_reference(obj_desc); | 133 | acpi_ut_remove_reference(obj_desc); |
134 | obj_desc = next_desc; | ||
135 | } | ||
136 | |||
137 | /* Special case for the statically allocated root node */ | ||
138 | |||
139 | if (node == acpi_gbl_root_node) { | ||
140 | return; | ||
131 | } | 141 | } |
132 | 142 | ||
133 | /* Now we can delete the node */ | 143 | /* Now we can delete the node */ |
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index cc2fea94c5f0..4a0665b6bcc1 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c | |||
@@ -593,24 +593,26 @@ struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle) | |||
593 | 593 | ||
594 | void acpi_ns_terminate(void) | 594 | void acpi_ns_terminate(void) |
595 | { | 595 | { |
596 | union acpi_operand_object *obj_desc; | 596 | acpi_status status; |
597 | 597 | ||
598 | ACPI_FUNCTION_TRACE(ns_terminate); | 598 | ACPI_FUNCTION_TRACE(ns_terminate); |
599 | 599 | ||
600 | /* | 600 | /* |
601 | * 1) Free the entire namespace -- all nodes and objects | 601 | * Free the entire namespace -- all nodes and all objects |
602 | * | 602 | * attached to the nodes |
603 | * Delete all object descriptors attached to namepsace nodes | ||
604 | */ | 603 | */ |
605 | acpi_ns_delete_namespace_subtree(acpi_gbl_root_node); | 604 | acpi_ns_delete_namespace_subtree(acpi_gbl_root_node); |
606 | 605 | ||
607 | /* Detach any objects attached to the root */ | 606 | /* Delete any objects attached to the root node */ |
608 | 607 | ||
609 | obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node); | 608 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
610 | if (obj_desc) { | 609 | if (ACPI_FAILURE(status)) { |
611 | acpi_ns_detach_object(acpi_gbl_root_node); | 610 | return_VOID; |
612 | } | 611 | } |
613 | 612 | ||
613 | acpi_ns_delete_node(acpi_gbl_root_node); | ||
614 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
615 | |||
614 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); | 616 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); |
615 | return_VOID; | 617 | return_VOID; |
616 | } | 618 | } |
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index b62a0f4f4f9b..b60c9cf82862 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c | |||
@@ -174,6 +174,7 @@ acpi_rs_stream_option_length(u32 resource_length, | |||
174 | * FUNCTION: acpi_rs_get_aml_length | 174 | * FUNCTION: acpi_rs_get_aml_length |
175 | * | 175 | * |
176 | * PARAMETERS: resource - Pointer to the resource linked list | 176 | * PARAMETERS: resource - Pointer to the resource linked list |
177 | * resource_list_size - Size of the resource linked list | ||
177 | * size_needed - Where the required size is returned | 178 | * size_needed - Where the required size is returned |
178 | * | 179 | * |
179 | * RETURN: Status | 180 | * RETURN: Status |
@@ -185,16 +186,20 @@ acpi_rs_stream_option_length(u32 resource_length, | |||
185 | ******************************************************************************/ | 186 | ******************************************************************************/ |
186 | 187 | ||
187 | acpi_status | 188 | acpi_status |
188 | acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | 189 | acpi_rs_get_aml_length(struct acpi_resource *resource, |
190 | acpi_size resource_list_size, acpi_size * size_needed) | ||
189 | { | 191 | { |
190 | acpi_size aml_size_needed = 0; | 192 | acpi_size aml_size_needed = 0; |
193 | struct acpi_resource *resource_end; | ||
191 | acpi_rs_length total_size; | 194 | acpi_rs_length total_size; |
192 | 195 | ||
193 | ACPI_FUNCTION_TRACE(rs_get_aml_length); | 196 | ACPI_FUNCTION_TRACE(rs_get_aml_length); |
194 | 197 | ||
195 | /* Traverse entire list of internal resource descriptors */ | 198 | /* Traverse entire list of internal resource descriptors */ |
196 | 199 | ||
197 | while (resource) { | 200 | resource_end = |
201 | ACPI_ADD_PTR(struct acpi_resource, resource, resource_list_size); | ||
202 | while (resource < resource_end) { | ||
198 | 203 | ||
199 | /* Validate the descriptor type */ | 204 | /* Validate the descriptor type */ |
200 | 205 | ||
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index 65f3e1c5b598..3a2ace93e62c 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c | |||
@@ -418,22 +418,21 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
418 | * | 418 | * |
419 | * FUNCTION: acpi_rs_create_aml_resources | 419 | * FUNCTION: acpi_rs_create_aml_resources |
420 | * | 420 | * |
421 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list | 421 | * PARAMETERS: resource_list - Pointer to the resource list buffer |
422 | * output_buffer - Pointer to the user's buffer | 422 | * output_buffer - Where the AML buffer is returned |
423 | * | 423 | * |
424 | * RETURN: Status AE_OK if okay, else a valid acpi_status code. | 424 | * RETURN: Status AE_OK if okay, else a valid acpi_status code. |
425 | * If the output_buffer is too small, the error will be | 425 | * If the output_buffer is too small, the error will be |
426 | * AE_BUFFER_OVERFLOW and output_buffer->Length will point | 426 | * AE_BUFFER_OVERFLOW and output_buffer->Length will point |
427 | * to the size buffer needed. | 427 | * to the size buffer needed. |
428 | * | 428 | * |
429 | * DESCRIPTION: Takes the linked list of device resources and | 429 | * DESCRIPTION: Converts a list of device resources to an AML bytestream |
430 | * creates a bytestream to be used as input for the | 430 | * to be used as input for the _SRS control method. |
431 | * _SRS control method. | ||
432 | * | 431 | * |
433 | ******************************************************************************/ | 432 | ******************************************************************************/ |
434 | 433 | ||
435 | acpi_status | 434 | acpi_status |
436 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | 435 | acpi_rs_create_aml_resources(struct acpi_buffer *resource_list, |
437 | struct acpi_buffer *output_buffer) | 436 | struct acpi_buffer *output_buffer) |
438 | { | 437 | { |
439 | acpi_status status; | 438 | acpi_status status; |
@@ -441,16 +440,16 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
441 | 440 | ||
442 | ACPI_FUNCTION_TRACE(rs_create_aml_resources); | 441 | ACPI_FUNCTION_TRACE(rs_create_aml_resources); |
443 | 442 | ||
444 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "LinkedListBuffer = %p\n", | 443 | /* Params already validated, no need to re-validate here */ |
445 | linked_list_buffer)); | ||
446 | 444 | ||
447 | /* | 445 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ResourceList Buffer = %p\n", |
448 | * Params already validated, so we don't re-validate here | 446 | resource_list->pointer)); |
449 | * | 447 | |
450 | * Pass the linked_list_buffer into a module that calculates | 448 | /* Get the buffer size needed for the AML byte stream */ |
451 | * the buffer size needed for the byte stream. | 449 | |
452 | */ | 450 | status = acpi_rs_get_aml_length(resource_list->pointer, |
453 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); | 451 | resource_list->length, |
452 | &aml_size_needed); | ||
454 | 453 | ||
455 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", | 454 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", |
456 | (u32)aml_size_needed, acpi_format_exception(status))); | 455 | (u32)aml_size_needed, acpi_format_exception(status))); |
@@ -467,10 +466,9 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
467 | 466 | ||
468 | /* Do the conversion */ | 467 | /* Do the conversion */ |
469 | 468 | ||
470 | status = | 469 | status = acpi_rs_convert_resources_to_aml(resource_list->pointer, |
471 | acpi_rs_convert_resources_to_aml(linked_list_buffer, | 470 | aml_size_needed, |
472 | aml_size_needed, | 471 | output_buffer->pointer); |
473 | output_buffer->pointer); | ||
474 | if (ACPI_FAILURE(status)) { | 472 | if (ACPI_FAILURE(status)) { |
475 | return_ACPI_STATUS(status); | 473 | return_ACPI_STATUS(status); |
476 | } | 474 | } |
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c index aef303d56d86..14a7982c9961 100644 --- a/drivers/acpi/acpica/rsutils.c +++ b/drivers/acpi/acpica/rsutils.c | |||
@@ -753,7 +753,7 @@ acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, | |||
753 | * Convert the linked list into a byte stream | 753 | * Convert the linked list into a byte stream |
754 | */ | 754 | */ |
755 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 755 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
756 | status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); | 756 | status = acpi_rs_create_aml_resources(in_buffer, &buffer); |
757 | if (ACPI_FAILURE(status)) { | 757 | if (ACPI_FAILURE(status)) { |
758 | goto cleanup; | 758 | goto cleanup; |
759 | } | 759 | } |
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 1a67b3944b3b..03ae8affe48f 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -185,6 +185,7 @@ acpi_debug_print(u32 requested_debug_level, | |||
185 | } | 185 | } |
186 | 186 | ||
187 | acpi_gbl_prev_thread_id = thread_id; | 187 | acpi_gbl_prev_thread_id = thread_id; |
188 | acpi_gbl_nesting_level = 0; | ||
188 | } | 189 | } |
189 | 190 | ||
190 | /* | 191 | /* |
@@ -193,13 +194,21 @@ acpi_debug_print(u32 requested_debug_level, | |||
193 | */ | 194 | */ |
194 | acpi_os_printf("%9s-%04ld ", module_name, line_number); | 195 | acpi_os_printf("%9s-%04ld ", module_name, line_number); |
195 | 196 | ||
197 | #ifdef ACPI_EXEC_APP | ||
198 | /* | ||
199 | * For acpi_exec only, emit the thread ID and nesting level. | ||
200 | * Note: nesting level is really only useful during a single-thread | ||
201 | * execution. Otherwise, multiple threads will keep resetting the | ||
202 | * level. | ||
203 | */ | ||
196 | if (ACPI_LV_THREADS & acpi_dbg_level) { | 204 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
197 | acpi_os_printf("[%u] ", (u32)thread_id); | 205 | acpi_os_printf("[%u] ", (u32)thread_id); |
198 | } | 206 | } |
199 | 207 | ||
200 | acpi_os_printf("[%02ld] %-22.22s: ", | 208 | acpi_os_printf("[%02ld] ", acpi_gbl_nesting_level); |
201 | acpi_gbl_nesting_level, | 209 | #endif |
202 | acpi_ut_trim_function_name(function_name)); | 210 | |
211 | acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name)); | ||
203 | 212 | ||
204 | va_start(args, format); | 213 | va_start(args, format); |
205 | acpi_os_vprintf(format, args); | 214 | acpi_os_vprintf(format, args); |
@@ -420,7 +429,9 @@ acpi_ut_exit(u32 line_number, | |||
420 | component_id, "%s\n", acpi_gbl_fn_exit_str); | 429 | component_id, "%s\n", acpi_gbl_fn_exit_str); |
421 | } | 430 | } |
422 | 431 | ||
423 | acpi_gbl_nesting_level--; | 432 | if (acpi_gbl_nesting_level) { |
433 | acpi_gbl_nesting_level--; | ||
434 | } | ||
424 | } | 435 | } |
425 | 436 | ||
426 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) | 437 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
@@ -467,7 +478,9 @@ acpi_ut_status_exit(u32 line_number, | |||
467 | } | 478 | } |
468 | } | 479 | } |
469 | 480 | ||
470 | acpi_gbl_nesting_level--; | 481 | if (acpi_gbl_nesting_level) { |
482 | acpi_gbl_nesting_level--; | ||
483 | } | ||
471 | } | 484 | } |
472 | 485 | ||
473 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) | 486 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
@@ -504,7 +517,9 @@ acpi_ut_value_exit(u32 line_number, | |||
504 | ACPI_FORMAT_UINT64(value)); | 517 | ACPI_FORMAT_UINT64(value)); |
505 | } | 518 | } |
506 | 519 | ||
507 | acpi_gbl_nesting_level--; | 520 | if (acpi_gbl_nesting_level) { |
521 | acpi_gbl_nesting_level--; | ||
522 | } | ||
508 | } | 523 | } |
509 | 524 | ||
510 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) | 525 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
@@ -540,7 +555,9 @@ acpi_ut_ptr_exit(u32 line_number, | |||
540 | ptr); | 555 | ptr); |
541 | } | 556 | } |
542 | 557 | ||
543 | acpi_gbl_nesting_level--; | 558 | if (acpi_gbl_nesting_level) { |
559 | acpi_gbl_nesting_level--; | ||
560 | } | ||
544 | } | 561 | } |
545 | 562 | ||
546 | #endif | 563 | #endif |
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c index 266bc58ce0ce..386a9fe497b4 100644 --- a/drivers/acpi/nvs.c +++ b/drivers/acpi/nvs.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/acpi_io.h> | 15 | #include <linux/acpi_io.h> |
16 | #include <acpi/acpiosxf.h> | ||
17 | 16 | ||
18 | /* ACPI NVS regions, APEI may use it */ | 17 | /* ACPI NVS regions, APEI may use it */ |
19 | 18 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0703bff5e60e..20360e480bd8 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -65,6 +65,9 @@ static struct acpi_scan_handler pci_root_handler = { | |||
65 | .ids = root_device_ids, | 65 | .ids = root_device_ids, |
66 | .attach = acpi_pci_root_add, | 66 | .attach = acpi_pci_root_add, |
67 | .detach = acpi_pci_root_remove, | 67 | .detach = acpi_pci_root_remove, |
68 | .hotplug = { | ||
69 | .ignore = true, | ||
70 | }, | ||
68 | }; | 71 | }; |
69 | 72 | ||
70 | static DEFINE_MUTEX(osc_lock); | 73 | static DEFINE_MUTEX(osc_lock); |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 15daa21fcd05..fd39459926b1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1772,7 +1772,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) | |||
1772 | */ | 1772 | */ |
1773 | list_for_each_entry(hwid, &pnp.ids, list) { | 1773 | list_for_each_entry(hwid, &pnp.ids, list) { |
1774 | handler = acpi_scan_match_handler(hwid->id, NULL); | 1774 | handler = acpi_scan_match_handler(hwid->id, NULL); |
1775 | if (handler) { | 1775 | if (handler && !handler->hotplug.ignore) { |
1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1777 | acpi_hotplug_notify_cb, handler); | 1777 | acpi_hotplug_notify_cb, handler); |
1778 | break; | 1778 | break; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 14df30580e15..721e949e606e 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -525,7 +525,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) | |||
525 | * generate wakeup events. | 525 | * generate wakeup events. |
526 | */ | 526 | */ |
527 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { | 527 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { |
528 | acpi_event_status pwr_btn_status; | 528 | acpi_event_status pwr_btn_status = ACPI_EVENT_FLAG_DISABLED; |
529 | 529 | ||
530 | acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); | 530 | acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); |
531 | 531 | ||
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index db5293650f62..6dbc3ca45223 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -309,7 +309,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, | |||
309 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", | 309 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", |
310 | table_attr->instance); | 310 | table_attr->instance); |
311 | 311 | ||
312 | table_attr->attr.size = 0; | 312 | table_attr->attr.size = table_header->length; |
313 | table_attr->attr.read = acpi_table_show; | 313 | table_attr->attr.read = acpi_table_show; |
314 | table_attr->attr.attr.name = table_attr->name; | 314 | table_attr->attr.attr.name = table_attr->name; |
315 | table_attr->attr.attr.mode = 0400; | 315 | table_attr->attr.attr.mode = 0400; |
@@ -354,8 +354,9 @@ static int acpi_tables_sysfs_init(void) | |||
354 | { | 354 | { |
355 | struct acpi_table_attr *table_attr; | 355 | struct acpi_table_attr *table_attr; |
356 | struct acpi_table_header *table_header = NULL; | 356 | struct acpi_table_header *table_header = NULL; |
357 | int table_index = 0; | 357 | int table_index; |
358 | int result; | 358 | acpi_status status; |
359 | int ret; | ||
359 | 360 | ||
360 | tables_kobj = kobject_create_and_add("tables", acpi_kobj); | 361 | tables_kobj = kobject_create_and_add("tables", acpi_kobj); |
361 | if (!tables_kobj) | 362 | if (!tables_kobj) |
@@ -365,33 +366,34 @@ static int acpi_tables_sysfs_init(void) | |||
365 | if (!dynamic_tables_kobj) | 366 | if (!dynamic_tables_kobj) |
366 | goto err_dynamic_tables; | 367 | goto err_dynamic_tables; |
367 | 368 | ||
368 | do { | 369 | for (table_index = 0;; table_index++) { |
369 | result = acpi_get_table_by_index(table_index, &table_header); | 370 | status = acpi_get_table_by_index(table_index, &table_header); |
370 | if (!result) { | 371 | |
371 | table_index++; | 372 | if (status == AE_BAD_PARAMETER) |
372 | table_attr = NULL; | 373 | break; |
373 | table_attr = | 374 | |
374 | kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); | 375 | if (ACPI_FAILURE(status)) |
375 | if (!table_attr) | 376 | continue; |
376 | return -ENOMEM; | 377 | |
377 | 378 | table_attr = NULL; | |
378 | acpi_table_attr_init(table_attr, table_header); | 379 | table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL); |
379 | result = | 380 | if (!table_attr) |
380 | sysfs_create_bin_file(tables_kobj, | 381 | return -ENOMEM; |
381 | &table_attr->attr); | 382 | |
382 | if (result) { | 383 | acpi_table_attr_init(table_attr, table_header); |
383 | kfree(table_attr); | 384 | ret = sysfs_create_bin_file(tables_kobj, &table_attr->attr); |
384 | return result; | 385 | if (ret) { |
385 | } else | 386 | kfree(table_attr); |
386 | list_add_tail(&table_attr->node, | 387 | return ret; |
387 | &acpi_table_attr_list); | ||
388 | } | 388 | } |
389 | } while (!result); | 389 | list_add_tail(&table_attr->node, &acpi_table_attr_list); |
390 | } | ||
391 | |||
390 | kobject_uevent(tables_kobj, KOBJ_ADD); | 392 | kobject_uevent(tables_kobj, KOBJ_ADD); |
391 | kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); | 393 | kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); |
392 | result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); | 394 | status = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); |
393 | 395 | ||
394 | return result == AE_OK ? 0 : -EINVAL; | 396 | return ACPI_FAILURE(status) ? -EINVAL : 0; |
395 | err_dynamic_tables: | 397 | err_dynamic_tables: |
396 | kobject_put(tables_kobj); | 398 | kobject_put(tables_kobj); |
397 | err: | 399 | err: |