Changeset 2c381250 in mainline for uspace/lib/usbvirt/stdreq.c
- Timestamp:
- 2010-10-13T06:49:48Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7da3219
- Parents:
- fd17ab5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/stdreq.c
rfd17ab5 r2c381250 34 34 */ 35 35 #include <errno.h> 36 #include <stdlib.h> 37 #include <mem.h> 36 38 #include <usb/devreq.h> 37 39 38 40 #include "private.h" 41 42 39 43 40 44 /* … … 52 56 */ 53 57 if ((type == USB_DESCTYPE_DEVICE) && (index == 0)) { 54 if (device-> standard_descriptor) {58 if (device->descriptors && device->descriptors->device) { 55 59 return device->send_data(device, 0, 56 device-> standard_descriptor,57 device-> standard_descriptor->length);60 device->descriptors->device, 61 device->descriptors->device->length); 58 62 } else { 59 63 return EFORWARD; 60 64 } 65 } 66 67 /* 68 * Configuration descriptor together with interface, endpoint and 69 * class-specific descriptors. 70 */ 71 if (type == USB_DESCTYPE_CONFIGURATION) { 72 if (!device->descriptors) { 73 return EFORWARD; 74 } 75 if (index >= device->descriptors->configuration_count) { 76 return EFORWARD; 77 } 78 /* Copy the data. */ 79 usbvirt_device_configuration_t *config = &device->descriptors 80 ->configuration[index]; 81 uint8_t *all_data = malloc(config->descriptor->total_length); 82 if (all_data == NULL) { 83 return ENOMEM; 84 } 85 86 uint8_t *ptr = all_data; 87 memcpy(ptr, config->descriptor, config->descriptor->length); 88 ptr += config->descriptor->length; 89 size_t i; 90 for (i = 0; i < config->extra_count; i++) { 91 usbvirt_device_configuration_extras_t *extra 92 = &config->extra[i]; 93 memcpy(ptr, extra->data, extra->length); 94 ptr += extra->length; 95 } 96 97 int rc = device->send_data(device, 0, all_data, 98 config->descriptor->total_length); 99 100 free(all_data); 101 102 return rc; 61 103 } 62 104
Note:
See TracChangeset
for help on using the changeset viewer.