Changes in uspace/lib/usbdev/src/altiface.c [ab27e01:e978ada] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/altiface.c
rab27e01 re978ada 90 90 * @return Error code. 91 91 */ 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) 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) 94 95 { 95 assert(alternates != NULL);96 assert(alternates_ptr != NULL); 96 97 assert(config_descr != NULL); 97 98 assert(config_descr_size > 0); 98 99 99 alternates->alternatives = NULL; 100 alternates->alternative_count = 0; 101 alternates->current = 0; 102 100 *alternates_ptr = NULL; 103 101 if (interface_number < 0) { 104 102 return EOK; 103 } 104 105 usb_alternate_interfaces_t *alternates 106 = malloc(sizeof(usb_alternate_interfaces_t)); 107 if (alternates == NULL) { 108 return ENOMEM; 105 109 } 106 110 … … 110 114 111 115 if (alternates->alternative_count == 0) { 116 free(alternates); 112 117 return ENOENT; 113 118 } … … 116 121 sizeof(usb_alternate_interface_descriptors_t)); 117 122 if (alternates->alternatives == NULL) { 123 free(alternates); 118 124 return ENOMEM; 119 125 } 120 126 121 const usb_dp_parser_t dp_parser = { 127 alternates->current = 0; 128 129 usb_dp_parser_t dp_parser = { 122 130 .nesting = usb_dp_standard_descriptor_nesting 123 131 }; 124 constusb_dp_parser_data_t dp_data = {132 usb_dp_parser_data_t dp_data = { 125 133 .data = config_descr, 126 134 .size = config_descr_size, … … 139 147 || (iface->interface_number != interface_number)) { 140 148 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, 141 &dp_data, dp_data.data, iface_ptr); 149 &dp_data, 150 dp_data.data, iface_ptr); 142 151 continue; 143 152 } … … 161 170 } 162 171 172 *alternates_ptr = alternates; 173 163 174 return EOK; 164 175 } 165 176 166 void usb_alternate_interfaces_de init(usb_alternate_interfaces_t *alternate)177 void usb_alternate_interfaces_destroy(usb_alternate_interfaces_t *alternate) 167 178 { 168 179 if (!alternate) 169 180 return; 170 181 free(alternate->alternatives); 182 free(alternate); 171 183 } 172 184 /**
Note:
See TracChangeset
for help on using the changeset viewer.