Changes in uspace/drv/usbhid/hiddev.c [2f593872:1c6c4092] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
r2f593872 r1c6c4092 135 135 } 136 136 137 hid_dev->report_desc_size = length;138 139 137 usb_log_debug("Done.\n"); 140 138 … … 151 149 usb_log_info("Processing descriptors...\n"); 152 150 151 // get the first configuration descriptor 152 usb_standard_configuration_descriptor_t config_desc; 153 153 154 int rc; 154 155 uint8_t *descriptors = NULL; 156 size_t descriptors_size; 157 rc = usb_request_get_full_configuration_descriptor_alloc( 158 &hid_dev->ctrl_pipe, 0, (void **) &descriptors, &descriptors_size); 159 if (rc != EOK) { 160 usb_log_error("Failed to retrieve config descriptor: %s.\n", 161 str_error(rc)); 162 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; 163 188 } 164 189 … … 176 201 177 202 rc = usb_endpoint_pipe_initialize_from_configuration( 178 endpoint_mapping, 1, descriptors, descriptors_size,203 endpoint_mapping, 1, descriptors, config_desc.total_length, 179 204 &hid_dev->wire); 180 205 … … 208 233 assert(endpoint_mapping[0].interface != NULL); 209 234 210 /* 211 * Save polling interval 212 */ 213 hid_dev->poll_interval = endpoint_mapping[0].descriptor->poll_interval; 214 assert(hid_dev->poll_interval > 0); 215 216 rc = usbhid_dev_get_report_descriptor(hid_dev, 217 descriptors, descriptors_size, 235 rc = usbhid_dev_get_report_descriptor(hid_dev, descriptors, transferred, 218 236 (uint8_t *)endpoint_mapping[0].interface); 219 237 … … 221 239 222 240 if (rc != EOK) { 223 usb_log_warning("Problem with getting Report descriptor: %s.\n", 224 str_error(rc)); 225 return rc; 226 } 227 228 rc = usb_hid_parse_report_descriptor(hid_dev->parser, 229 hid_dev->report_desc, hid_dev->report_desc_size); 230 if (rc != EOK) { 231 usb_log_warning("Problem parsing Report descriptor: %s.\n", 232 str_error(rc)); 233 return rc; 234 } 235 236 usb_hid_descriptor_print(hid_dev->parser); 241 usb_log_warning("Problem with parsing Report descriptor: %s.\n", 242 str_error(rc)); 243 return rc; 244 } 237 245 238 246 return EOK; … … 255 263 memset(dev, 0, sizeof(usbhid_dev_t)); 256 264 257 dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(258 usb_hid_report_parser_t)));259 if (dev->parser == NULL) {260 usb_log_fatal("No memory!\n");261 free(dev);262 return NULL;263 }264 265 265 dev->initialized = 0; 266 266 … … 339 339 return rc; 340 340 } 341 342 /*343 * Initialize the report parser.344 */345 rc = usb_hid_parser_init(hid_dev->parser);346 if (rc != EOK) {347 usb_log_error("Failed to initialize report parser.\n");348 return rc;349 }350 341 351 342 /*
Note:
See TracChangeset
for help on using the changeset viewer.