Skip to content

Commit 6909e0f

Browse files
committed
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>
1 parent 87824da commit 6909e0f

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
@@ -565,16 +565,13 @@ static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
565565
static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
566566
{
567567
struct acpi_handle_list dep_devices;
568-
acpi_status status;
569568
bool ret = false;
570569
int i;
571570

572571
if (!acpi_has_method(adev->handle, "_DEP"))
573572
return false;
574573

575-
status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
576-
&dep_devices);
577-
if (ACPI_FAILURE(status)) {
574+
if (!acpi_evaluate_reference(adev->handle, "_DEP", NULL, &dep_devices)) {
578575
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
579576
return false;
580577
}

drivers/acpi/scan.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,6 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
19841984
static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
19851985
{
19861986
struct acpi_handle_list dep_devices;
1987-
acpi_status status;
19881987
u32 count;
19891988
int i;
19901989

@@ -1998,8 +1997,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
19981997
!acpi_has_method(handle, "_HID"))
19991998
return 0;
20001999

2001-
status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
2002-
if (ACPI_FAILURE(status)) {
2000+
if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
20032001
acpi_handle_debug(handle, "Failed to evaluate _DEP.\n");
20042002
return 0;
20052003
}
@@ -2008,6 +2006,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
20082006
struct acpi_device_info *info;
20092007
struct acpi_dep_data *dep;
20102008
bool skip, honor_dep;
2009+
acpi_status status;
20112010

20122011
status = acpi_get_object_info(dep_devices.handles[i], &info);
20132012
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
@@ -740,15 +740,13 @@ static bool is_san_consumer(struct platform_device *pdev, acpi_handle handle)
740740
{
741741
struct acpi_handle_list dep_devices;
742742
acpi_handle supplier = ACPI_HANDLE(&pdev->dev);
743-
acpi_status status;
744743
bool ret = false;
745744
int i;
746745

747746
if (!acpi_has_method(handle, "_DEP"))
748747
return false;
749748

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

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)