GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_interface_instance_create.c Lines: 8 8 100.0 %
Date: 2024-12-12 17:16:36 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   Host Stack                                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
23
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
#include "ux_host_stack.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_host_stack_interface_instance_create            PORTABLE C      */
36
/*                                                           6.1.12       */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function will create an interface instance. It creates each    */
44
/*    endpoint associated with the interface.                             */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    interface                             Pointer to interface          */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    Completion Status                                                   */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _ux_host_stack_endpoint_instance_create Create instance endpoint    */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    USBX Components                                                     */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
67
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
70
/*                                            fixed parameter/variable    */
71
/*                                            names conflict C++ keyword, */
72
/*                                            resulting in version 6.1.12 */
73
/*                                                                        */
74
/**************************************************************************/
75
1722
UINT  _ux_host_stack_interface_instance_create(UX_INTERFACE *interface_ptr)
76
{
77
78
UX_ENDPOINT     *endpoint;
79
UINT            status;
80
81
    /* If trace is enabled, insert this event into the trace buffer.  */
82
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
83
84
    /* Obtain the first endpoint for this alternate setting.  */
85
1722
    endpoint =  interface_ptr -> ux_interface_first_endpoint;
86
87
    /* Loop to create each endpoint.  */
88
3825
    while (endpoint != UX_NULL)
89
    {
90
91
        /* Create an endpoint for the instance.  */
92
2123
        status = _ux_host_stack_endpoint_instance_create(endpoint);
93
94
        /* Check status, the controller may have refused the endpoint creation.  */
95
2123
        if (status != UX_SUCCESS)
96
97
            /* An error occurred at the controller level.  */
98
20
            return(status);
99
100
        /* Move to next endpoint.  */
101
2103
        endpoint =  endpoint -> ux_endpoint_next_endpoint;
102
    }
103
104
    /* If trace is enabled, register this object.  */
105
    UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, interface_ptr, 0, 0, 0);
106
107
    /* Return completion status.  */
108
1702
    return(UX_SUCCESS);
109
}
110