Changeset 7fc260ff in mainline
- Timestamp:
- 2011-11-05T14:33:07Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab27e01
- Parents:
- 904dcc6
- Location:
- uspace/lib/usbdev
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/driver.h
r904dcc6 r7fc260ff 72 72 /** USB device structure. */ 73 73 typedef struct { 74 /** Connection backing the pipes. 75 * Typically, you will not need to use this attribute at all. 76 */ 77 usb_device_connection_t wire; 74 78 /** The default control pipe. */ 75 79 usb_pipe_t ctrl_pipe; … … 93 97 usb_device_descriptors_t descriptors; 94 98 95 /** Generic DDF device backing this one. RO: DO NOT TOUCH!*/99 /** Generic DDF device backing this one. DO NOT TOUCH! */ 96 100 ddf_dev_t *ddf_dev; 97 101 /** Custom driver data. … … 100 104 */ 101 105 void *driver_data; 102 103 /** Connection backing the pipes.104 * Typically, you will not need to use this attribute at all.105 */106 usb_device_connection_t wire;107 106 } usb_device_t; 108 107 … … 160 159 int usb_driver_main(const usb_driver_t *); 161 160 161 int usb_device_init(usb_device_t *, ddf_dev_t *, 162 const usb_endpoint_description_t **, const char **); 163 void usb_device_deinit(usb_device_t *); 164 162 165 int usb_device_select_interface(usb_device_t *, uint8_t, 163 166 const usb_endpoint_description_t **); 164 167 165 168 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *); 169 void usb_device_release_descriptors(usb_device_descriptors_t *); 170 166 171 int usb_device_create_pipes(const ddf_dev_t *, usb_device_connection_t *, 167 172 const usb_endpoint_description_t **, const uint8_t *, size_t, int, int, 168 173 usb_endpoint_mapping_t **, size_t *); 169 174 int usb_device_destroy_pipes(const ddf_dev_t *, usb_endpoint_mapping_t *, size_t); 170 int usb_device_init(usb_device_t *, ddf_dev_t *,171 const usb_endpoint_description_t **, const char **);172 void usb_device_deinit(usb_device_t *);173 175 174 176 void * usb_device_data_alloc(usb_device_t *, size_t); -
uspace/lib/usbdev/src/devdrv.c
r904dcc6 r7fc260ff 300 300 301 301 return rc; 302 } 303 304 /** Cleanup structure initialized via usb_device_retrieve_descriptors. 305 * 306 * @param[in] descriptors Where to store the descriptors. 307 */ 308 void usb_device_release_descriptors(usb_device_descriptors_t *descriptors) 309 { 310 assert(descriptors); 311 free(descriptors->configuration); 312 descriptors->configuration = NULL; 302 313 } 303 314 … … 490 501 } 491 502 492 /** Initialize control pipe in a device.493 *494 * @param dev USB device in question.495 * @param errmsg Where to store error context.496 * @return497 */498 static int init_wire_and_ctrl_pipe(usb_device_t *dev, const char **errmsg)499 {500 int rc;501 502 rc = usb_device_connection_initialize_from_device(&dev->wire,503 dev->ddf_dev);504 if (rc != EOK) {505 *errmsg = "device connection initialization";506 return rc;507 }508 509 rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe,510 &dev->wire);511 if (rc != EOK) {512 *errmsg = "default control pipe initialization";513 return rc;514 }515 516 return EOK;517 }518 519 520 503 /** Initialize new instance of USB device. 521 504 * … … 533 516 assert(ddf_dev != NULL); 534 517 518 *errstr_ptr = NULL; 519 535 520 usb_dev->ddf_dev = ddf_dev; 536 521 usb_dev->driver_data = NULL; … … 540 525 541 526 /* Initialize backing wire and control pipe. */ 542 int rc = init_wire_and_ctrl_pipe(usb_dev, errstr_ptr); 543 if (rc != EOK) { 527 int rc = usb_device_connection_initialize_from_device( 528 &usb_dev->wire, ddf_dev); 529 if (rc != EOK) { 530 *errstr_ptr = "device connection initialization"; 531 return rc; 532 } 533 534 /* This pipe was registered by the hub driver, 535 * during device initialization. */ 536 rc = usb_pipe_initialize_default_control(&usb_dev->ctrl_pipe, 537 &usb_dev->wire); 538 if (rc != EOK) { 539 *errstr_ptr = "default control pipe initialization"; 544 540 return rc; 545 541 } … … 552 548 &usb_dev->descriptors); 553 549 if (rc != EOK) { 554 /* Nothing allocated, nothing to free. */555 550 *errstr_ptr = "descriptor retrieval"; 556 551 return rc; 557 552 } 558 553 559 /* Create alternate interfaces. We will silently ignore failure. */ 560 //TODO Why ignore? 554 /* Create alternate interfaces. We will silently ignore failure. 555 * We might either control one interface or an entire device, 556 * it makes no sense to speak about alternate interfaces when 557 * controlling a device. */ 561 558 usb_alternate_interfaces_init(&usb_dev->alternate_interfaces, 562 559 usb_dev->descriptors.configuration, 563 560 usb_dev->descriptors.configuration_size, usb_dev->interface_no); 564 561 562 /* TODO Add comment here. */ 565 563 rc = initialize_other_pipes(endpoints, usb_dev, 0); 566 564 if (rc != EOK) { 567 565 /* Full configuration descriptor is allocated. */ 568 free(usb_dev->descriptors.configuration);566 usb_device_release_descriptors(&usb_dev->descriptors); 569 567 /* Alternate interfaces may be allocated */ 570 568 usb_alternate_interfaces_deinit(&usb_dev->alternate_interfaces); … … 573 571 } 574 572 575 *errstr_ptr = NULL;576 577 573 return EOK; 578 574 } … … 591 587 592 588 usb_alternate_interfaces_deinit(&dev->alternate_interfaces); 593 free(dev->descriptors.configuration);589 usb_device_release_descriptors(&dev->descriptors); 594 590 free(dev->driver_data); 595 591 } -
uspace/lib/usbdev/src/pipes.c
r904dcc6 r7fc260ff 75 75 int usb_device_get_assigned_interface(const ddf_dev_t *device) 76 76 { 77 assert(device); 77 78 async_sess_t *parent_sess = 78 79 devman_parent_device_connect(EXCHANGE_ATOMIC, device->handle,
Note:
See TracChangeset
for help on using the changeset viewer.