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 |
|
|
/** HID Class */ |
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_class_hid.h" |
30 |
|
|
#include "ux_host_stack.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _ux_host_class_hid_instance_clean PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function cleans all the components of a HID instance. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* hid Pointer to HID class */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* Completion Status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _ux_utility_memory_free Release memory block */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLED BY */ |
60 |
|
|
/* */ |
61 |
|
|
/* HID Class */ |
62 |
|
|
/* */ |
63 |
|
|
/**************************************************************************/ |
64 |
|
391 |
UINT _ux_host_class_hid_instance_clean(UX_HOST_CLASS_HID *hid) |
65 |
|
|
{ |
66 |
|
|
|
67 |
|
|
UX_HOST_CLASS_HID_PARSER *hid_parser; |
68 |
|
|
UX_HOST_CLASS_HID_REPORT *hid_report; |
69 |
|
|
UX_HOST_CLASS_HID_REPORT *hid_next_report; |
70 |
|
|
UX_HOST_CLASS_HID_FIELD *hid_field; |
71 |
|
|
UX_HOST_CLASS_HID_FIELD *hid_next_field; |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
/* Get the parser structure pointer. */ |
75 |
|
391 |
hid_parser = &hid -> ux_host_class_hid_parser; |
76 |
|
|
|
77 |
|
|
/* Each report list of the parser should be cleaned: Input report. */ |
78 |
|
391 |
hid_report = hid_parser -> ux_host_class_hid_parser_input_report; |
79 |
✓✓ |
686 |
while (hid_report != UX_NULL) |
80 |
|
|
{ |
81 |
|
|
|
82 |
|
|
/* Get the next report before we clean the current report. */ |
83 |
|
295 |
hid_next_report = hid_report -> ux_host_class_hid_report_next_report; |
84 |
|
|
|
85 |
|
|
/* Get the first field in the report. */ |
86 |
|
295 |
hid_field = hid_report -> ux_host_class_hid_report_field; |
87 |
|
|
|
88 |
|
|
/* Clean all the fields attached. */ |
89 |
✓✓ |
1075 |
while (hid_field != UX_NULL) |
90 |
|
|
{ |
91 |
|
|
|
92 |
|
|
/* Get the next field before we clean the current field. */ |
93 |
|
780 |
hid_next_field = hid_field -> ux_host_class_hid_field_next_field; |
94 |
|
|
|
95 |
|
|
/* Free the usage table. */ |
96 |
✓✓ |
780 |
if (hid_field -> ux_host_class_hid_field_usages != UX_NULL) |
97 |
|
349 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_usages); |
98 |
|
|
|
99 |
|
|
/* Free the value table. */ |
100 |
✓✗ |
780 |
if (hid_field -> ux_host_class_hid_field_values != UX_NULL) |
101 |
|
780 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_values); |
102 |
|
|
|
103 |
|
|
/* Now free the field memory. */ |
104 |
|
780 |
_ux_utility_memory_free(hid_field); |
105 |
|
|
|
106 |
|
|
/* Next field. */ |
107 |
|
780 |
hid_field = hid_next_field; |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
/* Free the report. */ |
111 |
|
295 |
_ux_utility_memory_free(hid_report); |
112 |
|
|
|
113 |
|
|
/* Next report. */ |
114 |
|
295 |
hid_report = hid_next_report; |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
/* Each report list of the parser should be cleaned: Output report. */ |
118 |
|
391 |
hid_report = hid_parser -> ux_host_class_hid_parser_output_report; |
119 |
✓✓ |
566 |
while (hid_report != UX_NULL) |
120 |
|
|
{ |
121 |
|
|
|
122 |
|
|
/* Get the next report before we clean the current report. */ |
123 |
|
175 |
hid_next_report = hid_report -> ux_host_class_hid_report_next_report; |
124 |
|
|
|
125 |
|
|
/* Get the first field in the report. */ |
126 |
|
175 |
hid_field = hid_report -> ux_host_class_hid_report_field; |
127 |
|
|
|
128 |
|
|
/* Clean all the fields attached. */ |
129 |
✓✓ |
507 |
while (hid_field != UX_NULL) |
130 |
|
|
{ |
131 |
|
|
|
132 |
|
|
/* Get the next field before we clean the current field. */ |
133 |
|
332 |
hid_next_field = hid_field -> ux_host_class_hid_field_next_field; |
134 |
|
|
|
135 |
|
|
/* Free the usage table. */ |
136 |
✓✓ |
332 |
if (hid_field -> ux_host_class_hid_field_usages != UX_NULL) |
137 |
|
169 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_usages); |
138 |
|
|
|
139 |
|
|
/* Free the value table. */ |
140 |
✓✗ |
332 |
if (hid_field -> ux_host_class_hid_field_values != UX_NULL) |
141 |
|
332 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_values); |
142 |
|
|
|
143 |
|
|
/* Now free the field memory. */ |
144 |
|
332 |
_ux_utility_memory_free(hid_field); |
145 |
|
|
|
146 |
|
|
/* Next field. */ |
147 |
|
332 |
hid_field = hid_next_field; |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
/* Free the report. */ |
151 |
|
175 |
_ux_utility_memory_free(hid_report); |
152 |
|
|
|
153 |
|
|
/* Next report. */ |
154 |
|
175 |
hid_report = hid_next_report; |
155 |
|
|
} |
156 |
|
|
|
157 |
|
|
/* Each report list of the parser should be cleaned: Feature report. */ |
158 |
|
391 |
hid_report = hid_parser -> ux_host_class_hid_parser_feature_report; |
159 |
✓✓ |
696 |
while (hid_report != UX_NULL) |
160 |
|
|
{ |
161 |
|
|
|
162 |
|
|
/* Get the next report before we clean the current report. */ |
163 |
|
305 |
hid_next_report = hid_report -> ux_host_class_hid_report_next_report; |
164 |
|
|
|
165 |
|
|
/* Get the first field in the report. */ |
166 |
|
305 |
hid_field = hid_report -> ux_host_class_hid_report_field; |
167 |
|
|
|
168 |
|
|
/* Clean all the fields attached. */ |
169 |
✓✓ |
592 |
while (hid_field != UX_NULL) |
170 |
|
|
{ |
171 |
|
|
|
172 |
|
|
/* Get the next field before we clean the current field. */ |
173 |
|
287 |
hid_next_field = hid_field -> ux_host_class_hid_field_next_field; |
174 |
|
|
|
175 |
|
|
/* Free the usage table. */ |
176 |
✓✓ |
287 |
if (hid_field -> ux_host_class_hid_field_usages != UX_NULL) |
177 |
|
285 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_usages); |
178 |
|
|
|
179 |
|
|
/* Free the value table. */ |
180 |
✓✗ |
287 |
if (hid_field -> ux_host_class_hid_field_values != UX_NULL) |
181 |
|
287 |
_ux_utility_memory_free(hid_field -> ux_host_class_hid_field_values); |
182 |
|
|
|
183 |
|
|
/* Now free the field memory. */ |
184 |
|
287 |
_ux_utility_memory_free(hid_field); |
185 |
|
|
|
186 |
|
|
/* Next field. */ |
187 |
|
287 |
hid_field = hid_next_field; |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
/* Free the report. */ |
191 |
|
305 |
_ux_utility_memory_free(hid_report); |
192 |
|
|
|
193 |
|
|
/* Next report. */ |
194 |
|
305 |
hid_report = hid_next_report; |
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
/* Return successful completion. */ |
198 |
|
391 |
return(UX_SUCCESS); |
199 |
|
|
} |
200 |
|
|
|