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 /** USBX Component */ 15 /** */ 16 /** Device Printer Class */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 #define UX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "ux_api.h" 27 #include "ux_device_class_printer.h" 28 #include "ux_device_stack.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _ux_device_class_printer_uninitialize PORTABLE C */ 36 /* 6.3.0 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function uninitialize the printer class. */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* command Pointer to a class command */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* Completion Status */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* _ux_device_mutex_delete Delete Mutex */ 56 /* _ux_utility_memory_free Free used local memory */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* Device Printer Class */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */ 67 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */ 68 /* fixed standalone compile, */ 69 /* resulting in version 6.1.11 */ 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 /* 10-31-2022 Yajun Xia Modified comment(s), */ 75 /* added standalone support, */ 76 /* resulting in version 6.2.0 */ 77 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ 78 /* added a new mode to manage */ 79 /* endpoint buffer in classes, */ 80 /* resulting in version 6.3.0 */ 81 /* */ 82 /**************************************************************************/ _ux_device_class_printer_uninitialize(UX_SLAVE_CLASS_COMMAND * command)83UINT _ux_device_class_printer_uninitialize(UX_SLAVE_CLASS_COMMAND *command) 84 { 85 86 UX_DEVICE_CLASS_PRINTER *printer; 87 UX_SLAVE_CLASS *class_ptr; 88 89 /* Get the class container. */ 90 class_ptr = command -> ux_slave_class_command_class_ptr; 91 92 /* Get the class instance in the container. */ 93 printer = (UX_DEVICE_CLASS_PRINTER *) class_ptr -> ux_slave_class_instance; 94 95 /* Sanity check. */ 96 if (printer != UX_NULL) 97 { 98 #if !defined(UX_DEVICE_STANDALONE) 99 /* Delete the IN endpoint mutex. */ 100 _ux_device_mutex_delete(&printer -> ux_device_class_printer_endpoint_in_mutex); 101 102 /* Out Mutex. */ 103 _ux_device_mutex_delete(&printer -> ux_device_class_printer_endpoint_out_mutex); 104 #endif 105 /* Free the resources. */ 106 #if defined(UX_DEVICE_CLASS_PRINTER_OWN_ENDPOINT_BUFFER) 107 _ux_utility_memory_free(printer -> ux_device_class_printer_endpoint_buffer); 108 #endif 109 _ux_utility_memory_free(printer); 110 } 111 112 /* Return completion status. */ 113 return(UX_SUCCESS); 114 } 115