mirror of
https://github.com/torvalds/linux
synced 2024-09-20 02:57:25 +00:00
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 <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
c5eb0a6123
commit
b7fbf4cebd
|
@ -79,17 +79,17 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
|
||||||
|
|
||||||
static int find_child_checks(struct acpi_device *adev, bool check_children)
|
static int find_child_checks(struct acpi_device *adev, bool check_children)
|
||||||
{
|
{
|
||||||
bool sta_present = true;
|
|
||||||
unsigned long long sta;
|
unsigned long long sta;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
|
if (check_children && list_empty(&adev->children))
|
||||||
if (status == AE_NOT_FOUND)
|
|
||||||
sta_present = false;
|
|
||||||
else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (check_children && list_empty(&adev->children))
|
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
|
||||||
|
if (status == AE_NOT_FOUND)
|
||||||
|
return FIND_CHILD_MIN_SCORE;
|
||||||
|
|
||||||
|
if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -99,8 +99,10 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
|
||||||
* matched going forward. [This means a second spec violation in a row,
|
* matched going forward. [This means a second spec violation in a row,
|
||||||
* so whatever we do here is best effort anyway.]
|
* so whatever we do here is best effort anyway.]
|
||||||
*/
|
*/
|
||||||
return sta_present && !adev->pnp.type.platform_id ?
|
if (adev->pnp.type.platform_id)
|
||||||
FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
|
return FIND_CHILD_MIN_SCORE;
|
||||||
|
|
||||||
|
return FIND_CHILD_MAX_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
|
struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
|
||||||
|
|
Loading…
Reference in a new issue