Changeset da77278 in mainline
- Timestamp:
- 2011-03-17T22:22:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bf58895
- Parents:
- e160da4d
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/dp.h
re160da4d rda77278 77 77 usb_dp_parser_data_t *, uint8_t *, uint8_t *); 78 78 79 void usb_dp_walk_simple(uint8_t *, size_t, usb_dp_descriptor_nesting_t *, 80 void (*)(uint8_t *, size_t, void *), void *); 81 79 82 #endif 80 83 /** -
uspace/lib/usb/src/dp.c
re160da4d rda77278 258 258 } 259 259 260 /** Browser of the descriptor tree. 261 * 262 * @see usb_dp_walk_simple 263 * 264 * @param parser Descriptor parser. 265 * @param data Data for descriptor parser. 266 * @param root Pointer to current root of the tree. 267 * @param depth Current nesting depth. 268 * @param callback Callback for each found descriptor. 269 * @param arg Custom (user) argument. 270 */ 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) 274 { 275 if (root == NULL) { 276 return; 277 } 278 callback(root, depth, arg); 279 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 280 do { 281 usb_dp_browse_simple_internal(parser, data, child, depth + 1, 282 callback, arg); 283 child = usb_dp_get_sibling_descriptor(parser, data, 284 root, child); 285 } while (child != NULL); 286 } 287 288 /** Browse flatten descriptor tree. 289 * 290 * The callback is called with following arguments: pointer to the start 291 * of the descriptor (somewhere inside @p descriptors), depth of the nesting 292 * (starting from 0 for the first descriptor) and the custom argument. 293 * Note that the size of the descriptor is not passed because it can 294 * be read from the first byte of the descriptor. 295 * 296 * @param descriptors Descriptor data. 297 * @param descriptors_size Size of descriptor data (in bytes). 298 * @param descriptor_nesting Possible descriptor nesting. 299 * @param callback Callback for each found descriptor. 300 * @param arg Custom (user) argument. 301 */ 302 void usb_dp_walk_simple(uint8_t *descriptors, size_t descriptors_size, 303 usb_dp_descriptor_nesting_t *descriptor_nesting, 304 void (*callback)(uint8_t *, size_t, void *), void *arg) 305 { 306 if ((descriptors == NULL) || (descriptors_size == 0) 307 || (descriptor_nesting == NULL) || (callback == NULL)) { 308 return; 309 } 310 311 usb_dp_parser_data_t data = { 312 .data = descriptors, 313 .size = descriptors_size, 314 .arg = NULL 315 }; 316 317 usb_dp_parser_t parser = { 318 .nesting = descriptor_nesting 319 }; 320 321 usb_dp_browse_simple_internal(&parser, &data, descriptors, 322 0, callback, arg); 323 } 260 324 261 325 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.