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_delete            PORTABLE C      */
36 /*                                                           6.1.12       */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Chaoqiong Xiao, Microsoft Corporation                               */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function will delete an interface instance. It does not delete */
44 /*    the interface container, but it removes all the endpoints           */
45 /*    associated with alternate setting.                                  */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    interface                             Pointer to interface          */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _ux_host_stack_endpoint_instance_delete  Delete endpoint            */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    USBX Components                                                     */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
71 /*                                            fixed parameter/variable    */
72 /*                                            names conflict C++ keyword, */
73 /*                                            resulting in version 6.1.12 */
74 /*                                                                        */
75 /**************************************************************************/
_ux_host_stack_interface_instance_delete(UX_INTERFACE * interface_ptr)76 VOID  _ux_host_stack_interface_instance_delete(UX_INTERFACE *interface_ptr)
77 {
78 
79 UX_ENDPOINT     *endpoint;
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_DELETE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
83 
84     /* If trace is enabled, register this object.  */
85     UX_TRACE_OBJECT_UNREGISTER(interface_ptr);
86 
87     /* Obtain the first endpoint for this alternate setting.  */
88     endpoint =  interface_ptr -> ux_interface_first_endpoint;
89 
90     /* Loop to delete each endpoint.  */
91     while (endpoint != UX_NULL)
92     {
93 
94         /* Delete endpoint.  */
95         _ux_host_stack_endpoint_instance_delete(endpoint);
96 
97         /* Move to next endpoint. */
98         endpoint =  endpoint -> ux_endpoint_next_endpoint;
99     }
100 
101     /* Return to caller.  */
102     return;
103 }
104 
105