summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-08 21:06:04 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-15 10:46:04 +0100
commit6909e0f322b0527fee9fdc54685e6cad69008713 (patch)
tree648ec11fe2fed79a6f13c872dfbab8d93dab506c /drivers/acpi/utils.c
parent87824da27b0aee399600d313667c1d812c2749d8 (diff)
downloadlinux-stable-6909e0f322b0527fee9fdc54685e6cad69008713.tar.gz
linux-stable-6909e0f322b0527fee9fdc54685e6cad69008713.tar.bz2
linux-stable-6909e0f322b0527fee9fdc54685e6cad69008713.zip
ACPI: utils: Return bool from acpi_evaluate_reference()
There are only 4 users of acpi_evaluate_reference() and none of them actually cares about the reason why it fails. All of them are only interested in whether or not it is successful, so it can return a bool value indicating that. Modify acpi_evaluate_reference() as per the observation above and update its callers accordingly so as to get rid of useless code and local variables. The observable behavior of the kernel is not expected to change after this modification of the code. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r--drivers/acpi/utils.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 5a7766c3fbbd..958dc651d467 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -329,19 +329,18 @@ const char *acpi_get_subsystem_id(acpi_handle handle)
}
EXPORT_SYMBOL_GPL(acpi_get_subsystem_id);
-acpi_status
-acpi_evaluate_reference(acpi_handle handle,
- acpi_string pathname,
- struct acpi_object_list *arguments,
- struct acpi_handle_list *list)
+bool acpi_evaluate_reference(acpi_handle handle, acpi_string pathname,
+ struct acpi_object_list *arguments,
+ struct acpi_handle_list *list)
{
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *package;
acpi_status status;
+ bool ret = false;
u32 i;
if (!list)
- return AE_BAD_PARAMETER;
+ return false;
/* Evaluate object. */
@@ -352,42 +351,35 @@ acpi_evaluate_reference(acpi_handle handle,
package = buffer.pointer;
if (buffer.length == 0 || !package ||
- package->type != ACPI_TYPE_PACKAGE || !package->package.count) {
- status = AE_BAD_DATA;
+ package->type != ACPI_TYPE_PACKAGE || !package->package.count)
goto err;
- }
list->count = package->package.count;
list->handles = kcalloc(list->count, sizeof(*list->handles), GFP_KERNEL);
- if (!list->handles) {
- status = AE_NO_MEMORY;
+ if (!list->handles)
goto err_clear;
- }
/* Extract package data. */
for (i = 0; i < list->count; i++) {
union acpi_object *element = &(package->package.elements[i]);
- if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
- status = AE_BAD_DATA;
+ if (element->type != ACPI_TYPE_LOCAL_REFERENCE ||
+ !element->reference.handle)
goto err_free;
- }
- if (!element->reference.handle) {
- status = AE_NULL_ENTRY;
- goto err_free;
- }
/* Get the acpi_handle. */
list->handles[i] = element->reference.handle;
acpi_handle_debug(list->handles[i], "Found in reference list\n");
}
+ ret = true;
+
end:
kfree(buffer.pointer);
- return status;
+ return ret;
err_free:
kfree(list->handles);