Commit bb3fec14 authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

ACPICA: Remove unused ACPI_FREE_BUFFER macro. No functional change.

This macro is no longer used by ACPICA and it is not public.
Also update comments related to the use of ACPI_ALLOCATE_BUFFER and
the use of acpi_os_free (kfree is equivalent and prefered in the
kernel) to free the buffer.
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 5af2b635
...@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle, ...@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
acpi_object_type return_type) acpi_object_type return_type)
{ {
acpi_status status; acpi_status status;
u8 must_free = FALSE; u8 free_buffer_on_error = FALSE;
ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed); ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
...@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle, ...@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
} }
if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
must_free = TRUE; free_buffer_on_error = TRUE;
} }
/* Evaluate the object */ /* Evaluate the object */
status = status = acpi_evaluate_object(handle, pathname,
acpi_evaluate_object(handle, pathname, external_params, external_params, return_buffer);
return_buffer);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
...@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle, ...@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle,
pointer)->type), pointer)->type),
acpi_ut_get_type_name(return_type))); acpi_ut_get_type_name(return_type)));
if (must_free) { if (free_buffer_on_error) {
/*
/* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ * Free a buffer created via ACPI_ALLOCATE_BUFFER.
* Note: We use acpi_os_free here because acpi_os_allocate was used
ACPI_FREE_BUFFER(*return_buffer); * to allocate the buffer. This purposefully bypasses the
* (optionally enabled) allocation tracking mechanism since we
* only want to track internal allocations.
*/
acpi_os_free(return_buffer->pointer);
return_buffer->pointer = NULL; return_buffer->pointer = NULL;
} }
......
...@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer, ...@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
return (AE_BUFFER_OVERFLOW); return (AE_BUFFER_OVERFLOW);
case ACPI_ALLOCATE_BUFFER: case ACPI_ALLOCATE_BUFFER:
/*
/* Allocate a new buffer */ * Allocate a new buffer. We directectly call acpi_os_allocate here to
* purposefully bypass the (optionally enabled) internal allocation
* tracking mechanism since we only want to track internal
* allocations. Note: The caller should use acpi_os_free to free this
* buffer created via ACPI_ALLOCATE_BUFFER.
*/
buffer->pointer = acpi_os_allocate(required_length); buffer->pointer = acpi_os_allocate(required_length);
break; break;
......
...@@ -928,22 +928,14 @@ struct acpi_object_list { ...@@ -928,22 +928,14 @@ struct acpi_object_list {
* Miscellaneous common Data Structures used by the interfaces * Miscellaneous common Data Structures used by the interfaces
*/ */
#define ACPI_NO_BUFFER 0 #define ACPI_NO_BUFFER 0
#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) #define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) /* Let ACPICA allocate buffer */
#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) #define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) /* For internal use only (enables tracking) */
struct acpi_buffer { struct acpi_buffer {
acpi_size length; /* Length in bytes of the buffer */ acpi_size length; /* Length in bytes of the buffer */
void *pointer; /* pointer to buffer */ void *pointer; /* pointer to buffer */
}; };
/*
* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_BUFFER.
* Note: We use acpi_os_free here because acpi_os_allocate was used to allocate
* the buffer. This purposefully bypasses the internal allocation tracking
* mechanism (if it is enabled).
*/
#define ACPI_FREE_BUFFER(b) acpi_os_free((b).pointer)
/* /*
* name_type for acpi_get_name * name_type for acpi_get_name
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment