Changes in uspace/lib/usbdev/src/dp.c [8a121b1:160b75e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/dp.c
r8a121b1 r160b75e 75 75 * @return Whether @p ptr points inside <code>data->data</code> field. 76 76 */ 77 static bool is_valid_descriptor_pointer( constusb_dp_parser_data_t *data,78 constuint8_t *ptr)77 static bool is_valid_descriptor_pointer(usb_dp_parser_data_t *data, 78 uint8_t *ptr) 79 79 { 80 80 if (ptr == NULL) { … … 100 100 * @retval NULL Invalid input or no next descriptor. 101 101 */ 102 static const uint8_t *get_next_descriptor(constusb_dp_parser_data_t *data,103 constuint8_t *current)102 static uint8_t *get_next_descriptor(usb_dp_parser_data_t *data, 103 uint8_t *current) 104 104 { 105 105 assert(is_valid_descriptor_pointer(data, current)); 106 106 107 constuint8_t current_length = *current;108 constuint8_t *next = current + current_length;107 uint8_t current_length = *current; 108 uint8_t *next = current + current_length; 109 109 110 110 if (!is_valid_descriptor_pointer(data, next)) { … … 124 124 * @retval -1 Invalid input. 125 125 */ 126 static int get_descriptor_type( const usb_dp_parser_data_t *data, constuint8_t *start)126 static int get_descriptor_type(usb_dp_parser_data_t *data, uint8_t *start) 127 127 { 128 128 if (start == NULL) { … … 145 145 * @return Whether @p child could be child of @p parent. 146 146 */ 147 static bool is_nested_descriptor_type( constusb_dp_parser_t *parser,147 static bool is_nested_descriptor_type(usb_dp_parser_t *parser, 148 148 int child, int parent) 149 149 { 150 constusb_dp_descriptor_nesting_t *nesting = parser->nesting;150 usb_dp_descriptor_nesting_t *nesting = parser->nesting; 151 151 while ((nesting->child > 0) && (nesting->parent > 0)) { 152 152 if ((nesting->child == child) && (nesting->parent == parent)) { … … 166 166 * @return Whether @p child could be child of @p parent. 167 167 */ 168 static bool is_nested_descriptor( constusb_dp_parser_t *parser,169 const usb_dp_parser_data_t *data, const uint8_t *child, constuint8_t *parent)168 static bool is_nested_descriptor(usb_dp_parser_t *parser, 169 usb_dp_parser_data_t *data, uint8_t *child, uint8_t *parent) 170 170 { 171 171 return is_nested_descriptor_type(parser, … … 183 183 * @retval NULL Invalid input. 184 184 */ 185 const uint8_t *usb_dp_get_nested_descriptor(constusb_dp_parser_t *parser,186 const usb_dp_parser_data_t *data, constuint8_t *parent)185 uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *parser, 186 usb_dp_parser_data_t *data, uint8_t *parent) 187 187 { 188 188 if (!is_valid_descriptor_pointer(data, parent)) { … … 190 190 } 191 191 192 constuint8_t *next = get_next_descriptor(data, parent);192 uint8_t *next = get_next_descriptor(data, parent); 193 193 if (next == NULL) { 194 194 return NULL; … … 211 211 * @retval NULL Invalid input. 212 212 */ 213 static const uint8_t *skip_nested_descriptors(const usb_dp_parser_t *parser, 214 const usb_dp_parser_data_t *data, const uint8_t *parent) 215 { 216 const uint8_t *child = 217 usb_dp_get_nested_descriptor(parser, data, parent); 213 static uint8_t *skip_nested_descriptors(usb_dp_parser_t *parser, 214 usb_dp_parser_data_t *data, uint8_t *parent) 215 { 216 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, parent); 218 217 if (child == NULL) { 219 218 return get_next_descriptor(data, parent); 220 219 } 221 const uint8_t *next_child = 222 skip_nested_descriptors(parser, data, child); 220 uint8_t *next_child = skip_nested_descriptors(parser, data, child); 223 221 while (is_nested_descriptor(parser, data, next_child, parent)) { 224 222 next_child = skip_nested_descriptors(parser, data, next_child); … … 238 236 * @retval NULL Invalid input. 239 237 */ 240 const uint8_t *usb_dp_get_sibling_descriptor( 241 const usb_dp_parser_t *parser, const usb_dp_parser_data_t *data, 242 const uint8_t *parent, const uint8_t *sibling) 238 uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *parser, 239 usb_dp_parser_data_t *data, uint8_t *parent, uint8_t *sibling) 243 240 { 244 241 if (!is_valid_descriptor_pointer(data, parent) … … 247 244 } 248 245 249 const uint8_t *possible_sibling = 250 skip_nested_descriptors(parser, data, sibling); 246 uint8_t *possible_sibling = skip_nested_descriptors(parser, data, sibling); 251 247 if (possible_sibling == NULL) { 252 248 return NULL; … … 273 269 * @param arg Custom (user) argument. 274 270 */ 275 static void usb_dp_browse_simple_internal( constusb_dp_parser_t *parser,276 const usb_dp_parser_data_t *data, constuint8_t *root, size_t depth,277 void (*callback)( constuint8_t *, size_t, void *), void *arg)271 static void usb_dp_browse_simple_internal(usb_dp_parser_t *parser, 272 usb_dp_parser_data_t *data, uint8_t *root, size_t depth, 273 void (*callback)(uint8_t *, size_t, void *), void *arg) 278 274 { 279 275 if (root == NULL) { … … 281 277 } 282 278 callback(root, depth, arg); 283 constuint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);279 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 284 280 do { 285 281 usb_dp_browse_simple_internal(parser, data, child, depth + 1, … … 305 301 */ 306 302 void usb_dp_walk_simple(uint8_t *descriptors, size_t descriptors_size, 307 constusb_dp_descriptor_nesting_t *descriptor_nesting,308 walk_callback_t callback, void *arg)303 usb_dp_descriptor_nesting_t *descriptor_nesting, 304 void (*callback)(uint8_t *, size_t, void *), void *arg) 309 305 { 310 306 if ((descriptors == NULL) || (descriptors_size == 0) … … 313 309 } 314 310 315 constusb_dp_parser_data_t data = {311 usb_dp_parser_data_t data = { 316 312 .data = descriptors, 317 313 .size = descriptors_size, … … 319 315 }; 320 316 321 constusb_dp_parser_t parser = {317 usb_dp_parser_t parser = { 322 318 .nesting = descriptor_nesting 323 319 };
Note:
See TracChangeset
for help on using the changeset viewer.