Changeset 904dcc6 in mainline
- Timestamp:
- 2011-11-05T13:54:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7fc260ff
- Parents:
- 99a1a56
- Location:
- uspace/lib/usbdev
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/driver.h
r99a1a56 r904dcc6 87 87 int interface_no; 88 88 89 /** Alternative interfaces. 90 * Set to NULL when the driver controls whole device 91 * (i.e. more (or any) interfaces). 92 */ 93 usb_alternate_interfaces_t *alternate_interfaces; 89 /** Alternative interfaces. */ 90 usb_alternate_interfaces_t alternate_interfaces; 94 91 95 92 /** Some useful descriptors. */ … … 178 175 179 176 size_t usb_interface_count_alternates(const uint8_t *, size_t, uint8_t); 180 int usb_alternate_interfaces_ create(const uint8_t *, size_t, int,181 usb_alternate_interfaces_t **);182 void usb_alternate_interfaces_de stroy(usb_alternate_interfaces_t *);177 int usb_alternate_interfaces_init(usb_alternate_interfaces_t *, 178 const uint8_t *, size_t, int); 179 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *); 183 180 #endif 184 181 /** -
uspace/lib/usbdev/src/altiface.c
r99a1a56 r904dcc6 90 90 * @return Error code. 91 91 */ 92 int usb_alternate_interfaces_create(const uint8_t *config_descr, 93 size_t config_descr_size, int interface_number, 94 usb_alternate_interfaces_t **alternates_ptr) 92 int usb_alternate_interfaces_init(usb_alternate_interfaces_t *alternates, 93 const uint8_t *config_descr, size_t config_descr_size, int interface_number) 95 94 { 96 assert(alternates _ptr!= NULL);95 assert(alternates != NULL); 97 96 assert(config_descr != NULL); 98 97 assert(config_descr_size > 0); 99 98 100 *alternates_ptr = NULL; 99 alternates->alternatives = NULL; 100 alternates->alternative_count = 0; 101 alternates->current = 0; 102 101 103 if (interface_number < 0) { 102 104 return EOK; 103 }104 105 usb_alternate_interfaces_t *alternates106 = malloc(sizeof(usb_alternate_interfaces_t));107 if (alternates == NULL) {108 return ENOMEM;109 105 } 110 106 … … 114 110 115 111 if (alternates->alternative_count == 0) { 116 free(alternates);117 112 return ENOENT; 118 113 } … … 121 116 sizeof(usb_alternate_interface_descriptors_t)); 122 117 if (alternates->alternatives == NULL) { 123 free(alternates);124 118 return ENOMEM; 125 119 } 126 120 127 alternates->current = 0; 128 129 usb_dp_parser_t dp_parser = { 121 const usb_dp_parser_t dp_parser = { 130 122 .nesting = usb_dp_standard_descriptor_nesting 131 123 }; 132 usb_dp_parser_data_t dp_data = {124 const usb_dp_parser_data_t dp_data = { 133 125 .data = config_descr, 134 126 .size = config_descr_size, … … 170 162 } 171 163 172 *alternates_ptr = alternates;173 174 164 return EOK; 175 165 } 176 166 177 void usb_alternate_interfaces_de stroy(usb_alternate_interfaces_t *alternate)167 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate) 178 168 { 179 169 if (!alternate) 180 170 return; 181 171 free(alternate->alternatives); 182 free(alternate);183 172 } 184 173 /** -
uspace/lib/usbdev/src/devdrv.c
r99a1a56 r904dcc6 536 536 usb_dev->driver_data = NULL; 537 537 usb_dev->descriptors.configuration = NULL; 538 usb_dev->alternate_interfaces = NULL;539 538 usb_dev->pipes_count = 0; 540 539 usb_dev->pipes = NULL; … … 560 559 /* Create alternate interfaces. We will silently ignore failure. */ 561 560 //TODO Why ignore? 562 usb_alternate_interfaces_ create(usb_dev->descriptors.configuration,563 usb_dev->descriptors.configuration _size, usb_dev->interface_no,564 &usb_dev->alternate_interfaces);561 usb_alternate_interfaces_init(&usb_dev->alternate_interfaces, 562 usb_dev->descriptors.configuration, 563 usb_dev->descriptors.configuration_size, usb_dev->interface_no); 565 564 566 565 rc = initialize_other_pipes(endpoints, usb_dev, 0); … … 569 568 free(usb_dev->descriptors.configuration); 570 569 /* Alternate interfaces may be allocated */ 571 usb_alternate_interfaces_de stroy(usb_dev->alternate_interfaces);570 usb_alternate_interfaces_deinit(&usb_dev->alternate_interfaces); 572 571 *errstr_ptr = "pipes initialization"; 573 572 return rc; … … 591 590 destroy_current_pipes(dev); 592 591 593 usb_alternate_interfaces_de stroy(dev->alternate_interfaces);592 usb_alternate_interfaces_deinit(&dev->alternate_interfaces); 594 593 free(dev->descriptors.configuration); 595 594 free(dev->driver_data);
Note:
See TracChangeset
for help on using the changeset viewer.