ACPI: utils: Return bool from acpi_evaluate_reference()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 Dec 2023 20:06:04 +0000 (21:06 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 15 Dec 2023 09:46:04 +0000 (10:46 +0100)
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>
drivers/acpi/acpi_lpss.c
drivers/acpi/scan.c
drivers/acpi/thermal.c
drivers/acpi/utils.c
drivers/platform/surface/surface_acpi_notify.c
include/acpi/acpi_bus.h

index 79f4fc7d6871177e5f382e2ac64d57c52a00f61b..1623af8d62bc417bacfd12f93211a16d02101ad1 100644 (file)
@@ -565,16 +565,13 @@ static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
 static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
 {
        struct acpi_handle_list dep_devices;
-       acpi_status status;
        bool ret = false;
        int i;
 
        if (!acpi_has_method(adev->handle, "_DEP"))
                return false;
 
-       status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
-                                        &dep_devices);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_evaluate_reference(adev->handle, "_DEP", NULL, &dep_devices)) {
                dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
                return false;
        }
index 02bb2cce423f47d6bc1a1c4e6563a6de6369514d..7b731958af5e93036d9e675c3bff7726082485e4 100644 (file)
@@ -1984,7 +1984,6 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
 static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
 {
        struct acpi_handle_list dep_devices;
-       acpi_status status;
        u32 count;
        int i;
 
@@ -1998,8 +1997,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
            !acpi_has_method(handle, "_HID"))
                return 0;
 
-       status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
                acpi_handle_debug(handle, "Failed to evaluate _DEP.\n");
                return 0;
        }
@@ -2008,6 +2006,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
                struct acpi_device_info *info;
                struct acpi_dep_data *dep;
                bool skip, honor_dep;
+               acpi_status status;
 
                status = acpi_get_object_info(dep_devices.handles[i], &info);
                if (ACPI_FAILURE(status)) {
index f74d81abdbfc073aa68273e786a11cabfa826f2e..15f09c71a5ecd69c42e1dd23b4dde220ea6f7cca 100644 (file)
@@ -247,7 +247,6 @@ static bool update_trip_devices(struct acpi_thermal *tz,
 {
        struct acpi_handle_list devices = { 0 };
        char method[] = "_PSL";
-       acpi_status status;
 
        if (index != ACPI_THERMAL_TRIP_PASSIVE) {
                method[1] = 'A';
@@ -255,8 +254,7 @@ static bool update_trip_devices(struct acpi_thermal *tz,
                method[3] = '0' + index;
        }
 
-       status = acpi_evaluate_reference(tz->device->handle, method, NULL, &devices);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) {
                acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method);
                return false;
        }
index 5a7766c3fbbd1fe5fa8e418ad47da03b49b20cca..958dc651d4672feccfa3019baacae416e3e844c5 100644 (file)
@@ -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);
index e4dee920da185094a59a0f4a7177b2a319945423..96ec052d0940bde4146b4175b4fef533f7fb8324 100644 (file)
@@ -740,15 +740,13 @@ static bool is_san_consumer(struct platform_device *pdev, acpi_handle handle)
 {
        struct acpi_handle_list dep_devices;
        acpi_handle supplier = ACPI_HANDLE(&pdev->dev);
-       acpi_status status;
        bool ret = false;
        int i;
 
        if (!acpi_has_method(handle, "_DEP"))
                return false;
 
-       status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
                san_consumer_dbg(&pdev->dev, handle, "failed to evaluate _DEP\n");
                return false;
        }
index aae31552c5740368b1d9cee75f87797287781176..fbe60af56b349ce99bd9366a08f94611a98e9373 100644 (file)
@@ -25,11 +25,9 @@ acpi_status
 acpi_evaluate_integer(acpi_handle handle,
                      acpi_string pathname,
                      struct acpi_object_list *arguments, unsigned long long *data);
-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);
 bool acpi_handle_list_equal(struct acpi_handle_list *list1,
                            struct acpi_handle_list *list2);
 void acpi_handle_list_replace(struct acpi_handle_list *dst,