GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_device_classes/src/ux_device_class_cdc_acm_unitialize.c Lines: 12 12 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 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
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   Device CDC Class                                                    */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
#define UX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "ux_api.h"
28
#include "ux_device_class_cdc_acm.h"
29
#include "ux_device_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_device_class_cdc_acm_uninitialize               PORTABLE C      */
37
/*                                                           6.3.0        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function uninitialize the cdc-acm class.                       */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    command                               Pointer to a class command    */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    Completion Status                                                   */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _ux_device_mutex_delete               Delete Mutex                  */
57
/*    _ux_utility_memory_free               Free used local memory        */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    CDC Class                                                           */
62
/*                                                                        */
63
/**************************************************************************/
64
50
UINT  _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
65
{
66
67
UX_SLAVE_CLASS_CDC_ACM      *cdc_acm;
68
UX_SLAVE_CLASS              *class_ptr;
69
70
    /* Get the class container.  */
71
50
    class_ptr =  command -> ux_slave_class_command_class_ptr;
72
73
    /* Get the class instance in the container.  */
74
50
    cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
75
76
    /* Sanity check.  */
77
50
    if (cdc_acm != UX_NULL)
78
    {
79
80
#if !defined(UX_DEVICE_STANDALONE)
81
82
        /* Delete the IN endpoint mutex.  */
83
49
        _ux_device_mutex_delete(&cdc_acm -> ux_slave_class_cdc_acm_endpoint_in_mutex);
84
85
        /* Out Mutex. */
86
49
        _ux_device_mutex_delete(&cdc_acm -> ux_slave_class_cdc_acm_endpoint_out_mutex);
87
88
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
89
90
        /* Free resources and return error.  */
91
49
        _ux_utility_thread_delete(&cdc_acm -> ux_slave_class_cdc_acm_bulkin_thread);
92
49
        _ux_utility_thread_delete(&cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread);
93
49
        _ux_utility_event_flags_delete(&cdc_acm -> ux_slave_class_cdc_acm_event_flags_group);
94
49
        _ux_utility_memory_free(cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread_stack);
95
#endif
96
#endif
97
98
#if defined(UX_DEVICE_CLASS_CDC_ACM_OWN_ENDPOINT_BUFFER)
99
100
        /* Free the buffer for bulk endpoints.  */
101
        _ux_utility_memory_free(cdc_acm -> ux_device_class_cdc_acm_endpoint_buffer);
102
#endif
103
104
        /* Free the resources.  */
105
49
        _ux_utility_memory_free(cdc_acm);
106
107
    }
108
109
    /* Return completion status.  */
110
50
    return(UX_SUCCESS);
111
}
112