Changes in uspace/lib/usb/src/request.c [bc1c6fb:ad4562c2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/request.c
rbc1c6fb rad4562c2 110 110 * (must be in USB endianness). 111 111 * @param data Buffer where to store data accepted during the DATA stage. 112 * (they will come in USB endian ness).112 * (they will come in USB endianess). 113 113 * @param data_size Size of the @p data buffer 114 114 * (in native endianness). … … 161 161 * the new address. 162 162 * 163 * @see usb_drv_reserve_default_address 164 * @see usb_drv_release_default_address 165 * @see usb_drv_request_address 166 * @see usb_drv_release_address 167 * @see usb_drv_bind_address 168 * 163 169 * @param pipe Control endpoint pipe (session must be already started). 164 170 * @param new_address New USB address to be set (in native endianness). … … 195 201 * @param[in] pipe Control endpoint pipe (session must be already started). 196 202 * @param[in] request_type Request type (standard/class/vendor). 197 * @param[in] recipient Request recipient (device/interface/endpoint).198 203 * @param[in] descriptor_type Descriptor type (device/configuration/HID/...). 199 204 * @param[in] descriptor_index Descriptor index. … … 230 235 * @param[in] pipe Control endpoint pipe (session must be already started). 231 236 * @param[in] request_type Request type (standard/class/vendor). 232 * @param[in] recipient Request recipient (device/interface/endpoint).233 237 * @param[in] descriptor_type Descriptor type (device/configuration/HID/...). 234 238 * @param[in] descriptor_index Descriptor index. … … 408 412 } 409 413 410 /** Retrieve full configuration descriptor, allocate space for it.411 *412 * The function takes care that full configuration descriptor is returned413 * (i.e. the function will fail when less data then descriptor.totalLength414 * is returned).415 *416 * @param[in] pipe Control endpoint pipe (session must be already started).417 * @param[in] index Configuration index.418 * @param[out] descriptor_ptr Where to store pointer to allocated buffer.419 * @param[out] descriptor_size Where to store the size of the descriptor.420 * @return Error code.421 */422 int usb_request_get_full_configuration_descriptor_alloc(423 usb_endpoint_pipe_t *pipe, int index,424 void **descriptor_ptr, size_t *descriptor_size)425 {426 int rc;427 428 if (descriptor_ptr == NULL) {429 return EBADMEM;430 }431 432 usb_standard_configuration_descriptor_t bare_config;433 rc = usb_request_get_bare_configuration_descriptor(pipe, index,434 &bare_config);435 if (rc != EOK) {436 return rc;437 }438 439 if (bare_config.descriptor_type != USB_DESCTYPE_CONFIGURATION) {440 return ENOENT;441 }442 if (bare_config.total_length < sizeof(bare_config)) {443 return ELIMIT;444 }445 446 void *buffer = malloc(bare_config.total_length);447 if (buffer == NULL) {448 return ENOMEM;449 }450 451 size_t transferred = 0;452 rc = usb_request_get_full_configuration_descriptor(pipe, index,453 buffer, bare_config.total_length, &transferred);454 if (rc != EOK) {455 free(buffer);456 return rc;457 }458 459 if (transferred != bare_config.total_length) {460 free(buffer);461 return ELIMIT;462 }463 464 /* Everything looks okay, copy the pointers. */465 466 *descriptor_ptr = buffer;467 468 if (descriptor_size != NULL) {469 *descriptor_size = bare_config.total_length;470 }471 472 return EOK;473 }474 475 414 /** Set configuration of USB device. 476 415 * … … 524 463 return EEMPTY; 525 464 } 526 /* Sub tract first 2 bytes (length and descriptor type). */465 /* Substract first 2 bytes (length and descriptor type). */ 527 466 string_descriptor_size -= 2; 528 467 … … 544 483 size_t i; 545 484 for (i = 0; i < langs_count; i++) { 546 /* Language code from the descriptor is in USB endian ness. */485 /* Language code from the descriptor is in USB endianess. */ 547 486 /* FIXME: is this really correct? */ 548 487 uint16_t lang_code = (string_descriptor[2 + 2 * i + 1] << 8) … … 565 504 * 566 505 * @param[in] pipe Control endpoint pipe (session must be already started). 567 * @param[in] index String index (in native endianness), 568 * first index has number 1 (index from descriptors can be used directly). 569 * @param[in] lang String language (in native endianness). 506 * @param[in] index String index (in native endianess). 507 * @param[in] lang String language (in native endianess). 570 508 * @param[out] string_ptr Where to store allocated string in native encoding. 571 509 * @return Error code. … … 577 515 return EBADMEM; 578 516 } 579 /* 580 * Index is actually one byte value and zero index is used 581 * to retrieve list of supported languages. 582 */ 583 if ((index < 1) || (index > 0xFF)) { 517 /* Index is actually one byte value. */ 518 if (index > 0xFF) { 584 519 return ERANGE; 585 520 } … … 609 544 goto leave; 610 545 } 611 /* Sub tract first 2 bytes (length and descriptor type). */546 /* Substract first 2 bytes (length and descriptor type). */ 612 547 string_size -= 2; 613 548
Note:
See TracChangeset
for help on using the changeset viewer.