Skip to content

Commit 752dd40

Browse files
committed
ACPI: utils: Return bool from acpi_evaluate_reference()
JIRA: https://issues.redhat.com/browse/RHEL-26871 commit 6909e0f Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Date: Fri Dec 8 21:06:04 2023 +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> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 6183061 commit 752dd40

File tree

6 files changed

+20
-38
lines changed

6 files changed

+20
-38
lines changed

drivers/acpi/acpi_lpss.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,13 @@ static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
573573
static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
574574
{
575575
struct acpi_handle_list dep_devices;
576-
acpi_status status;
577576
bool ret = false;
578577
int i;
579578

580579
if (!acpi_has_method(adev->handle, "_DEP"))
581580
return false;
582581

583-
status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
584-
&dep_devices);
585-
if (ACPI_FAILURE(status)) {
582+
if (!acpi_evaluate_reference(adev->handle, "_DEP", NULL, &dep_devices)) {
586583
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
587584
return false;
588585
}

drivers/acpi/scan.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,6 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
20012001
static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
20022002
{
20032003
struct acpi_handle_list dep_devices;
2004-
acpi_status status;
20052004
u32 count;
20062005
int i;
20072006

@@ -2015,8 +2014,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
20152014
!acpi_has_method(handle, "_HID"))
20162015
return 0;
20172016

2018-
status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
2019-
if (ACPI_FAILURE(status)) {
2017+
if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
20202018
acpi_handle_debug(handle, "Failed to evaluate _DEP.\n");
20212019
return 0;
20222020
}
@@ -2025,6 +2023,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
20252023
struct acpi_device_info *info;
20262024
struct acpi_dep_data *dep;
20272025
bool skip, honor_dep;
2026+
acpi_status status;
20282027

20292028
status = acpi_get_object_info(dep_devices.handles[i], &info);
20302029
if (ACPI_FAILURE(status)) {

drivers/acpi/thermal.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,14 @@ static bool update_trip_devices(struct acpi_thermal *tz,
247247
{
248248
struct acpi_handle_list devices = { 0 };
249249
char method[] = "_PSL";
250-
acpi_status status;
251250

252251
if (index != ACPI_THERMAL_TRIP_PASSIVE) {
253252
method[1] = 'A';
254253
method[2] = 'L';
255254
method[3] = '0' + index;
256255
}
257256

258-
status = acpi_evaluate_reference(tz->device->handle, method, NULL, &devices);
259-
if (ACPI_FAILURE(status)) {
257+
if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) {
260258
acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method);
261259
return false;
262260
}

drivers/acpi/utils.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,18 @@ const char *acpi_get_subsystem_id(acpi_handle handle)
329329
}
330330
EXPORT_SYMBOL_GPL(acpi_get_subsystem_id);
331331

332-
acpi_status
333-
acpi_evaluate_reference(acpi_handle handle,
334-
acpi_string pathname,
335-
struct acpi_object_list *arguments,
336-
struct acpi_handle_list *list)
332+
bool acpi_evaluate_reference(acpi_handle handle, acpi_string pathname,
333+
struct acpi_object_list *arguments,
334+
struct acpi_handle_list *list)
337335
{
338336
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
339337
union acpi_object *package;
340338
acpi_status status;
339+
bool ret = false;
341340
u32 i;
342341

343342
if (!list)
344-
return AE_BAD_PARAMETER;
343+
return false;
345344

346345
/* Evaluate object. */
347346

@@ -352,42 +351,35 @@ acpi_evaluate_reference(acpi_handle handle,
352351
package = buffer.pointer;
353352

354353
if (buffer.length == 0 || !package ||
355-
package->type != ACPI_TYPE_PACKAGE || !package->package.count) {
356-
status = AE_BAD_DATA;
354+
package->type != ACPI_TYPE_PACKAGE || !package->package.count)
357355
goto err;
358-
}
359356

360357
list->count = package->package.count;
361358
list->handles = kcalloc(list->count, sizeof(*list->handles), GFP_KERNEL);
362-
if (!list->handles) {
363-
status = AE_NO_MEMORY;
359+
if (!list->handles)
364360
goto err_clear;
365-
}
366361

367362
/* Extract package data. */
368363

369364
for (i = 0; i < list->count; i++) {
370365
union acpi_object *element = &(package->package.elements[i]);
371366

372-
if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
373-
status = AE_BAD_DATA;
367+
if (element->type != ACPI_TYPE_LOCAL_REFERENCE ||
368+
!element->reference.handle)
374369
goto err_free;
375-
}
376370

377-
if (!element->reference.handle) {
378-
status = AE_NULL_ENTRY;
379-
goto err_free;
380-
}
381371
/* Get the acpi_handle. */
382372

383373
list->handles[i] = element->reference.handle;
384374
acpi_handle_debug(list->handles[i], "Found in reference list\n");
385375
}
386376

377+
ret = true;
378+
387379
end:
388380
kfree(buffer.pointer);
389381

390-
return status;
382+
return ret;
391383

392384
err_free:
393385
kfree(list->handles);

drivers/platform/surface/surface_acpi_notify.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,15 +738,13 @@ static bool is_san_consumer(struct platform_device *pdev, acpi_handle handle)
738738
{
739739
struct acpi_handle_list dep_devices;
740740
acpi_handle supplier = ACPI_HANDLE(&pdev->dev);
741-
acpi_status status;
742741
bool ret = false;
743742
int i;
744743

745744
if (!acpi_has_method(handle, "_DEP"))
746745
return false;
747746

748-
status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
749-
if (ACPI_FAILURE(status)) {
747+
if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
750748
san_consumer_dbg(&pdev->dev, handle, "failed to evaluate _DEP\n");
751749
return false;
752750
}

include/acpi/acpi_bus.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ acpi_status
2525
acpi_evaluate_integer(acpi_handle handle,
2626
acpi_string pathname,
2727
struct acpi_object_list *arguments, unsigned long long *data);
28-
acpi_status
29-
acpi_evaluate_reference(acpi_handle handle,
30-
acpi_string pathname,
31-
struct acpi_object_list *arguments,
32-
struct acpi_handle_list *list);
28+
bool acpi_evaluate_reference(acpi_handle handle, acpi_string pathname,
29+
struct acpi_object_list *arguments,
30+
struct acpi_handle_list *list);
3331
bool acpi_handle_list_equal(struct acpi_handle_list *list1,
3432
struct acpi_handle_list *list2);
3533
void acpi_handle_list_replace(struct acpi_handle_list *dst,

0 commit comments

Comments
 (0)