Changeset d70e0a3c in mainline for uspace/drv/usbhid/hiddev.c
- Timestamp:
- 2011-03-02T18:17:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a6567ed
- Parents:
- 4723444
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
r4723444 rd70e0a3c 149 149 usb_log_info("Processing descriptors...\n"); 150 150 151 // get the first configuration descriptor152 usb_standard_configuration_descriptor_t config_desc;153 154 151 int 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", 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", 160 159 str_error(rc)); 161 160 return rc; 162 }163 164 // prepare space for all underlying descriptors165 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 descriptor173 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;188 161 } 189 162 … … 201 174 202 175 rc = usb_endpoint_pipe_initialize_from_configuration( 203 endpoint_mapping, 1, descriptors, config_desc.total_length,176 endpoint_mapping, 1, descriptors, descriptors_size, 204 177 &hid_dev->wire); 205 178 … … 233 206 assert(endpoint_mapping[0].interface != NULL); 234 207 235 rc = usbhid_dev_get_report_descriptor(hid_dev, descriptors, transferred, 208 rc = usbhid_dev_get_report_descriptor(hid_dev, 209 descriptors, descriptors_size, 236 210 (uint8_t *)endpoint_mapping[0].interface); 237 211
Note:
See TracChangeset
for help on using the changeset viewer.