Changes in uspace/drv/usbhid/hiddev.c [d70e0a3c:1c6c4092] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
rd70e0a3c r1c6c4092 149 149 usb_log_info("Processing descriptors...\n"); 150 150 151 // get the first configuration descriptor 152 usb_standard_configuration_descriptor_t config_desc; 153 151 154 int rc; 152 153 uint8_t *descriptors = NULL; 154 size_t descriptors_size; 155 rc = usb_request_get_full_configuration_descriptor_alloc( 156 &hid_dev->ctrl_pipe, 0, (void **) &descriptors, &descriptors_size); 157 if (rc != EOK) { 158 usb_log_error("Failed to retrieve config descriptor: %s.\n", 159 str_error(rc)); 160 return rc; 155 rc = usb_request_get_bare_configuration_descriptor(&hid_dev->ctrl_pipe, 156 0, &config_desc); 157 158 if (rc != EOK) { 159 usb_log_error("Failed to get bare config descriptor: %s.\n", 160 str_error(rc)); 161 return rc; 162 } 163 164 // prepare space for all underlying descriptors 165 uint8_t *descriptors = (uint8_t *)malloc(config_desc.total_length); 166 if (descriptors == NULL) { 167 usb_log_error("No memory!.\n"); 168 return ENOMEM; 169 } 170 171 size_t transferred = 0; 172 // get full configuration descriptor 173 rc = usb_request_get_full_configuration_descriptor(&hid_dev->ctrl_pipe, 174 0, descriptors, config_desc.total_length, &transferred); 175 176 if (rc != EOK) { 177 usb_log_error("Failed to get full config descriptor: %s.\n", 178 str_error(rc)); 179 free(descriptors); 180 return rc; 181 } 182 183 if (transferred != config_desc.total_length) { 184 usb_log_error("Configuration descriptor has wrong size (%u, " 185 "expected %u).\n", transferred, config_desc.total_length); 186 free(descriptors); 187 return ELIMIT; 161 188 } 162 189 … … 174 201 175 202 rc = usb_endpoint_pipe_initialize_from_configuration( 176 endpoint_mapping, 1, descriptors, descriptors_size,203 endpoint_mapping, 1, descriptors, config_desc.total_length, 177 204 &hid_dev->wire); 178 205 … … 206 233 assert(endpoint_mapping[0].interface != NULL); 207 234 208 rc = usbhid_dev_get_report_descriptor(hid_dev, 209 descriptors, descriptors_size, 235 rc = usbhid_dev_get_report_descriptor(hid_dev, descriptors, transferred, 210 236 (uint8_t *)endpoint_mapping[0].interface); 211 237
Note:
See TracChangeset
for help on using the changeset viewer.