diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-03 18:42:46 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-05 11:41:16 -0500 |
commit | 7c2e17714e190b2ef857e7e842464fb47ceca146 (patch) | |
tree | 9de5bdbe9ffd639ccb645e4126bd64f1f355d50a | |
parent | d3a1ebb063cc45d5f4a5655534b87c3547fd9bbf (diff) |
ACPICA: Introduce acpi_get_data_full() and rework acpi_get_data()
Introduce a new function, acpi_get_data_full(), working in analogy
with acpi_get_data() except that it can execute a callback provided
as its 4th argument right after acpi_ns_get_attached_data() has
returned a success.
That will allow Linux to reference count the object pointed to by
*data before the namespace mutex is released so as to ensure that it
will not be freed going forward until the reference to it acquired
by acpi_get_data_full() is dropped.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r-- | drivers/acpi/acpica/nsxfeval.c | 33 | ||||
-rw-r--r-- | include/acpi/acpixf.h | 4 |
2 files changed, 34 insertions, 3 deletions
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 1f0c28ba50df..d6b33bc7bab0 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -923,19 +923,22 @@ ACPI_EXPORT_SYMBOL(acpi_detach_data) | |||
923 | 923 | ||
924 | /******************************************************************************* | 924 | /******************************************************************************* |
925 | * | 925 | * |
926 | * FUNCTION: acpi_get_data | 926 | * FUNCTION: acpi_get_data_full |
927 | * | 927 | * |
928 | * PARAMETERS: obj_handle - Namespace node | 928 | * PARAMETERS: obj_handle - Namespace node |
929 | * handler - Handler used in call to attach_data | 929 | * handler - Handler used in call to attach_data |
930 | * data - Where the data is returned | 930 | * data - Where the data is returned |
931 | * callback - function to execute before returning | ||
931 | * | 932 | * |
932 | * RETURN: Status | 933 | * RETURN: Status |
933 | * | 934 | * |
934 | * DESCRIPTION: Retrieve data that was previously attached to a namespace node. | 935 | * DESCRIPTION: Retrieve data that was previously attached to a namespace node |
936 | * and execute a callback before returning. | ||
935 | * | 937 | * |
936 | ******************************************************************************/ | 938 | ******************************************************************************/ |
937 | acpi_status | 939 | acpi_status |
938 | acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) | 940 | acpi_get_data_full(acpi_handle obj_handle, acpi_object_handler handler, |
941 | void **data, void (*callback)(void *)) | ||
939 | { | 942 | { |
940 | struct acpi_namespace_node *node; | 943 | struct acpi_namespace_node *node; |
941 | acpi_status status; | 944 | acpi_status status; |
@@ -960,10 +963,34 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) | |||
960 | } | 963 | } |
961 | 964 | ||
962 | status = acpi_ns_get_attached_data(node, handler, data); | 965 | status = acpi_ns_get_attached_data(node, handler, data); |
966 | if (ACPI_SUCCESS(status) && callback) { | ||
967 | callback(*data); | ||
968 | } | ||
963 | 969 | ||
964 | unlock_and_exit: | 970 | unlock_and_exit: |
965 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 971 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
966 | return (status); | 972 | return (status); |
967 | } | 973 | } |
968 | 974 | ||
975 | ACPI_EXPORT_SYMBOL(acpi_get_data_full) | ||
976 | |||
977 | /******************************************************************************* | ||
978 | * | ||
979 | * FUNCTION: acpi_get_data | ||
980 | * | ||
981 | * PARAMETERS: obj_handle - Namespace node | ||
982 | * handler - Handler used in call to attach_data | ||
983 | * data - Where the data is returned | ||
984 | * | ||
985 | * RETURN: Status | ||
986 | * | ||
987 | * DESCRIPTION: Retrieve data that was previously attached to a namespace node. | ||
988 | * | ||
989 | ******************************************************************************/ | ||
990 | acpi_status | ||
991 | acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) | ||
992 | { | ||
993 | return acpi_get_data_full(obj_handle, handler, data, NULL); | ||
994 | } | ||
995 | |||
969 | ACPI_EXPORT_SYMBOL(acpi_get_data) | 996 | ACPI_EXPORT_SYMBOL(acpi_get_data) |
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index fea6773f87fc..34bad459c11b 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
@@ -230,6 +230,10 @@ acpi_attach_data(acpi_handle object, acpi_object_handler handler, void *data); | |||
230 | acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler); | 230 | acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler); |
231 | 231 | ||
232 | acpi_status | 232 | acpi_status |
233 | acpi_get_data_full(acpi_handle object, acpi_object_handler handler, void **data, | ||
234 | void (*callback)(void *)); | ||
235 | |||
236 | acpi_status | ||
233 | acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data); | 237 | acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data); |
234 | 238 | ||
235 | acpi_status | 239 | acpi_status |