Changeset ab27e01 in mainline for uspace/lib/usbdev/src/devdrv.c
- Timestamp:
- 2011-11-05T14:58:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b77931d
- Parents:
- 7fc260ff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/devdrv.c
r7fc260ff rab27e01 81 81 * @return Number of pipes (excluding default control pipe). 82 82 */ 83 static size_t count_other_pipes(const usb_endpoint_description_t **endpoints) 84 { 85 size_t count = 0; 86 if (endpoints == NULL) { 87 return 0; 88 } 89 90 while (endpoints[count] != NULL) { 91 count++; 92 } 93 83 static inline size_t count_other_pipes( 84 const usb_endpoint_description_t **endpoints) 85 { 86 size_t count; 87 for (count = 0; endpoints && endpoints[count] != NULL; ++count); 94 88 return count; 95 89 } … … 104 98 usb_device_t *dev, int alternate_setting) 105 99 { 100 assert(dev); 101 106 102 if (endpoints == NULL) { 107 103 dev->pipes = NULL; … … 330 326 * (not NULL terminated). 331 327 * @param[out] pipes_count_ptr Where to store number of pipes 332 * (set to if you wish to ignore the count).328 * (set to NULL if you wish to ignore the count). 333 329 * @return Error code. 334 330 */ … … 351 347 const size_t pipe_count = count_other_pipes(endpoints); 352 348 if (pipe_count == 0) { 353 *pipes_count_ptr = pipe_count; 349 if (pipes_count_ptr) 350 *pipes_count_ptr = pipe_count; 354 351 *pipes_ptr = NULL; 355 352 return EOK; … … 357 354 358 355 usb_endpoint_mapping_t *pipes 359 = malloc(sizeof(usb_endpoint_mapping_t) * pipe_count);356 = calloc(pipe_count, sizeof(usb_endpoint_mapping_t)); 360 357 if (pipes == NULL) { 361 358 return ENOMEM; 362 }363 364 /* Initialize to NULL to allow smooth rollback. */365 for (i = 0; i < pipe_count; i++) {366 pipes[i].pipe = NULL;367 359 } 368 360 … … 409 401 410 402 if (usb_hc_connection_close(&hc_conn) != EOK) 411 usb_log_warning(" usb_device_create_pipes(): "412 "Failed to close connection.\n");403 usb_log_warning("%s: Failed to close connection.\n", 404 __FUNCTION__); 413 405 414 406 *pipes_ptr = pipes; … … 556 548 * it makes no sense to speak about alternate interfaces when 557 549 * controlling a device. */ 558 usb_alternate_interfaces_init(&usb_dev->alternate_interfaces,550 rc = usb_alternate_interfaces_init(&usb_dev->alternate_interfaces, 559 551 usb_dev->descriptors.configuration, 560 552 usb_dev->descriptors.configuration_size, usb_dev->interface_no); 553 const int alternate_iface = 554 (rc == EOK) ? usb_dev->alternate_interfaces.current : 0; 561 555 562 556 /* TODO Add comment here. */ 563 rc = initialize_other_pipes(endpoints, usb_dev, 0);557 rc = initialize_other_pipes(endpoints, usb_dev, alternate_iface); 564 558 if (rc != EOK) { 565 559 /* Full configuration descriptor is allocated. */
Note:
See TracChangeset
for help on using the changeset viewer.