zircon/third_party/lib/acpica/source/components/namespace/nsxfeval.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiGetDevices
 *
 * PARAMETERS:  HID                 - HID to search for. Can be NULL.
 *              UserFunction        - Called when a matching object is found
 *              Context             - Passed to user function
 *              ReturnValue         - Location where return value of
 *                                    UserFunction is put if terminated early
 *
 * RETURNS      Return value from the UserFunction if terminated early.
 *              Otherwise, returns NULL.
 *
 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
 *              starting (and ending) at the object specified by StartHandle.
 *              The UserFunction is called whenever an object of type
 *              Device is found. If the user function returns
 *              a non-zero value, the search is terminated immediately and this
 *              value is returned to the caller.
 *
 *              This is a wrapper for WalkNamespace, but the callback performs
 *              additional filtering. Please see AcpiNsGetDeviceCallback.
 *
 ******************************************************************************/
AcpiGetDevices
PARAMETERS:  HID                 - HID to search for. Can be NULL.
UserFunction        - Called when a matching object is found
Context             - Passed to user function
ReturnValue         - Location where return value of
UserFunction is put if terminated early

RETURNS      Return value from the UserFunction if terminated early.
Otherwise, returns NULL.

Performs a modified depth-first walk of the namespace tree,
starting (and ending) at the object specified by StartHandle.
The UserFunction is called whenever an object of type
Device is found. If the user function returns
a non-zero value, the search is terminated immediately and this
value is returned to the caller.

This is a wrapper for WalkNamespace, but the callback performs
additional filtering.
AcpiGetDevices PARAMETERS : HID - HID to search for . Can be NULL . UserFunction - Called when a matching object is found Context - Passed to user function ReturnValue - Location where return value of UserFunction is put if terminated early RETURNS Return value from the UserFunction if terminated early . Otherwise returns NULL . Performs a modified depth - first walk of the namespace tree starting ( and ending ) at the object specified by StartHandle . The UserFunction is called whenever an object of type Device is found . If the user function returns a non - zero value the search is terminated immediately and this value is returned to the caller . This is a wrapper for WalkNamespace but the callback performs additional filtering .
ACPI_STATUS
AcpiGetDevices (
    char                    *HID,
    ACPI_WALK_CALLBACK      UserFunction,
    void                    *Context,
    void                    **ReturnValue)
{
    ACPI_STATUS             Status;
    ACPI_GET_DEVICES_INFO   Info;
    ACPI_FUNCTION_TRACE (AcpiGetDevices);
    if (!UserFunction)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
    Info.Hid = HID;
    Info.Context = Context;
    Info.UserFunction = UserFunction;
    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
        ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
        AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    return_ACPI_STATUS (Status);
}
ACPI_STATUS AcpiGetDevices ( char * HID , ACPI_WALK_CALLBACK UserFunction , void * Context , void * * ReturnValue ) { ACPI_STATUS Status ; ACPI_GET_DEVICES_INFO Info ; ACPI_FUNCTION_TRACE ( AcpiGetDevices ) ; if ( ! UserFunction ) { return_ACPI_STATUS ( AE_BAD_PARAMETER ) ; } Info . Hid = HID ; Info . Context = Context ; Info . UserFunction = UserFunction ; Status = AcpiUtAcquireMutex ( ACPI_MTX_NAMESPACE ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } Status = AcpiNsWalkNamespace ( ACPI_TYPE_DEVICE , ACPI_ROOT_OBJECT , ACPI_UINT32_MAX , ACPI_NS_WALK_UNLOCK , AcpiNsGetDeviceCallback , NULL , & Info , ReturnValue ) ; ( void ) AcpiUtReleaseMutex ( ACPI_MTX_NAMESPACE ) ; return_ACPI_STATUS ( Status ) ; }
FUNCTION:    AcpiGetDevices
 PARAMETERS:  HID                 - HID to search for.
FUNCTION : AcpiGetDevices PARAMETERS : HID - HID to search for .
/* Parameter validation */ /*
     * We're going to call their callback from OUR callback, so we need
     * to know what it is, and their context parameter.
     */ /*
     * Lock the namespace around the walk.
     * The namespace will be unlocked/locked around each call
     * to the user function - since this function
     * must be allowed to make Acpi calls itself.
     */