GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_configuration_instance_delete.c Lines: 10 10 100.0 %
Date: 2026-03-06 18:57:10 Branches: 6 6 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Host Stack                                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
#include "ux_host_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_host_stack_configuration_instance_delete        PORTABLE C      */
37
/*                                                           6.2.0        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function will delete a configuration instance. It does not     */
45
/*    delete configuration container but it deletes all the alternate     */
46
/*    current alternate settings for each interface it owns.              */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    configuration                         Pointer to configuration      */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Completion Status                                                   */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _ux_host_stack_interface_instance_delete  Delete interface instance */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    USBX Components                                                     */
63
/*                                                                        */
64
/**************************************************************************/
65
143
VOID  _ux_host_stack_configuration_instance_delete(UX_CONFIGURATION *configuration)
66
{
67
68
UX_INTERFACE    *interface_ptr;
69
ULONG           current_alternate_setting;
70
71
    /* If trace is enabled, insert this event into the trace buffer.  */
72
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CONFIGURATION_INSTANCE_DELETE, configuration, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
73
74
    /* Obtain the first interface for this configuration.  */
75
143
    interface_ptr =  configuration -> ux_configuration_first_interface;
76
77
    /* In order to keep the compiler happy, we reset the alternate setting.  */
78
143
    current_alternate_setting =  0;
79
80
    /* Each selected alternate setting for each interface must be deleted.  */
81
292
    while (interface_ptr != UX_NULL)
82
    {
83
84
        /* If this is the first alternate setting, the current alternate setting is maintained here.  */
85
149
        if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
86
        {
87
88
143
            current_alternate_setting =  interface_ptr -> ux_interface_current_alternate_setting;
89
        }
90
91
149
        if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == current_alternate_setting)
92
        {
93
94
#if UX_HOST_STACK_CONFIGURATION_INSTANCE_CREATE_CONTROL == UX_HOST_STACK_CONFIGURATION_INSTANCE_CREATE_OWNED
95
96
            /* If interface is usable, remove physical creates.  */
97
            if (interface_ptr -> ux_interface_class || configuration -> ux_configuration_device -> ux_device_class)
98
#endif
99
143
                _ux_host_stack_interface_instance_delete(interface_ptr);
100
        }
101
102
149
        interface_ptr =  interface_ptr -> ux_interface_next_interface;
103
    }
104
105
143
    return;
106
}
107