1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 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.1.12 */ 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 /* RELEASE HISTORY */ 65 /* */ 66 /* DATE NAME DESCRIPTION */ 67 /* */ 68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 70 /* resulting in version 6.1 */ 71 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 72 /* added standalone support, */ 73 /* resulting in version 6.1.10 */ 74 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 75 /* fixed parameter/variable */ 76 /* names conflict C++ keyword, */ 77 /* resulting in version 6.1.12 */ 78 /* */ 79 /**************************************************************************/ _ux_device_class_storage_uninitialize(UX_SLAVE_CLASS_COMMAND * command)80UINT _ux_device_class_storage_uninitialize(UX_SLAVE_CLASS_COMMAND *command) 81 { 82 83 UX_SLAVE_CLASS_STORAGE *storage; 84 UX_SLAVE_CLASS *class_ptr; 85 86 /* Get the class container. */ 87 class_ptr = command -> ux_slave_class_command_class_ptr; 88 89 /* Get the class instance in the container. */ 90 storage = (UX_SLAVE_CLASS_STORAGE *) class_ptr -> ux_slave_class_instance; 91 92 /* Sanity check. */ 93 if (storage != UX_NULL) 94 { 95 96 /* Remove STORAGE thread. */ 97 _ux_device_thread_delete(&class_ptr -> ux_slave_class_thread); 98 99 #if !(defined(UX_DEVICE_STANDALONE) || defined(UX_STANDALONE)) 100 /* Remove the thread used by STORAGE. */ 101 _ux_utility_memory_free(class_ptr -> ux_slave_class_thread_stack); 102 #endif 103 104 /* Free the resources. */ 105 _ux_utility_memory_free(storage); 106 } 107 108 /* Return completion status. */ 109 return(UX_SUCCESS); 110 } 111 112