Skip to content

Commit b7fbf4c

Browse files
committed
ACPI: glue: Rearrange find_child_checks()
Notice that it is not necessary to evaluate _STA in find_child_checks() if the device is expected to have children, but there are none, so move the children check to the front of the function. Also notice that FIND_CHILD_MIN_SCORE can be returned right away if _STA is missing, so make the function do so. Finally, replace the ternary operator in the return statement argument with an if () and a standalone return which is somewhat easier to follow. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c5eb0a6 commit b7fbf4c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/acpi/glue.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
7979

8080
static int find_child_checks(struct acpi_device *adev, bool check_children)
8181
{
82-
bool sta_present = true;
8382
unsigned long long sta;
8483
acpi_status status;
8584

85+
if (check_children && list_empty(&adev->children))
86+
return -ENODEV;
87+
8688
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
8789
if (status == AE_NOT_FOUND)
88-
sta_present = false;
89-
else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
90-
return -ENODEV;
90+
return FIND_CHILD_MIN_SCORE;
9191

92-
if (check_children && list_empty(&adev->children))
92+
if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
9393
return -ENODEV;
9494

9595
/*
@@ -99,8 +99,10 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
9999
* matched going forward. [This means a second spec violation in a row,
100100
* so whatever we do here is best effort anyway.]
101101
*/
102-
return sta_present && !adev->pnp.type.platform_id ?
103-
FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
102+
if (adev->pnp.type.platform_id)
103+
return FIND_CHILD_MIN_SCORE;
104+
105+
return FIND_CHILD_MAX_SCORE;
104106
}
105107

106108
struct acpi_device *acpi_find_child_device(struct acpi_device *parent,

0 commit comments

Comments
 (0)