Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/request.c

    r9d58539 r1cf26ab  
    3939
    4040#define MAX_DATA_LENGTH ((size_t)(0xFFFF))
     41
     42static_assert(sizeof(usb_device_request_setup_packet_t) == 8);
    4143
    4244/** Generic wrapper for SET requests using standard control request format.
     
    114116  *     (in native endianness).
    115117  * @param actual_data_size Actual size of transfered data
    116   *     (in native endianness).
     118  *        (in native endianness).
    117119  * @return Error code.
    118120  * @retval EBADMEM @p pipe is NULL.
     
    147149                    | (request_type << 5) | recipient,
    148150                .request = request,
    149                 .value = value,
    150                 .index = index,
    151                 .length = (uint16_t) data_size,
     151                .value = uint16_host2usb(value),
     152                .index = uint16_host2usb(index),
     153                .length = uint16_host2usb(data_size),
    152154        };
    153155
     
    375377        usb_standard_device_descriptor_t descriptor_tmp;
    376378        int rc = usb_request_get_descriptor(pipe,
    377             USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 
     379            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    378380            USB_DESCTYPE_DEVICE, 0, 0,
    379381            &descriptor_tmp, sizeof(descriptor_tmp),
     
    435437        /* Everything is okay, copy the descriptor. */
    436438        memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp));
    437 
    438439        return EOK;
    439440}
     
    495496                return ENOENT;
    496497        }
    497         if (bare_config.total_length < sizeof(bare_config)) {
     498
     499        const size_t total_length = uint16_usb2host(bare_config.total_length);
     500        if (total_length < sizeof(bare_config)) {
    498501                return ELIMIT;
    499502        }
    500503
    501         void *buffer = malloc(bare_config.total_length);
     504        void *buffer = malloc(total_length);
    502505        if (buffer == NULL) {
    503506                return ENOMEM;
     
    506509        size_t transferred = 0;
    507510        rc = usb_request_get_full_configuration_descriptor(pipe, index,
    508             buffer, bare_config.total_length, &transferred);
     511            buffer, total_length, &transferred);
    509512        if (rc != EOK) {
    510513                free(buffer);
     
    512515        }
    513516
    514         if (transferred != bare_config.total_length) {
     517        if (transferred != total_length) {
    515518                free(buffer);
    516519                return ELIMIT;
     
    522525
    523526        if (descriptor_size != NULL) {
    524                 *descriptor_size = bare_config.total_length;
     527                *descriptor_size = total_length;
    525528        }
    526529
Note: See TracChangeset for help on using the changeset viewer.