GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_device_classes/src/ux_device_class_storage_uninitialize.c Lines: 8 8 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
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Device Storage Class                                                */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
#define UX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "ux_api.h"
29
#include "ux_device_class_storage.h"
30
#include "ux_device_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_device_class_storage_uninitialize               PORTABLE C      */
38
/*                                                           6.3.0        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function deinitializes the USB storage device.                 */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    command                               Pointer to storage command    */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _ux_utility_memory_free               Free memory                   */
58
/*    _ux_device_thread_delete              Delete thread                 */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    Device Storage Class                                                */
63
/*                                                                        */
64
/**************************************************************************/
65
42
UINT  _ux_device_class_storage_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
66
{
67
68
UX_SLAVE_CLASS_STORAGE                  *storage;
69
UX_SLAVE_CLASS                          *class_ptr;
70
71
    /* Get the class container.  */
72
42
    class_ptr =  command -> ux_slave_class_command_class_ptr;
73
74
    /* Get the class instance in the container.  */
75
42
    storage = (UX_SLAVE_CLASS_STORAGE *) class_ptr -> ux_slave_class_instance;
76
77
    /* Sanity check.  */
78
42
    if (storage != UX_NULL)
79
    {
80
81
        /* Remove STORAGE thread.  */
82
41
        _ux_device_thread_delete(&class_ptr -> ux_slave_class_thread);
83
84
#if !(defined(UX_DEVICE_STANDALONE) || defined(UX_STANDALONE))
85
        /* Remove the thread used by STORAGE.  */
86
41
        _ux_utility_memory_free(class_ptr -> ux_slave_class_thread_stack);
87
#endif
88
89
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
90
        _ux_utility_memory_free(storage -> ux_device_class_storage_endpoint_buffer);
91
#endif
92
93
        /* Free the resources.  */
94
41
        _ux_utility_memory_free(storage);
95
    }
96
97
    /* Return completion status.  */
98
42
    return(UX_SUCCESS);
99
}
100