Changes in uspace/lib/usbdev/src/altiface.c [e978ada:ab27e01] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/altiface.c
re978ada rab27e01 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, … … 147 139 || (iface->interface_number != interface_number)) { 148 140 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, 149 &dp_data, 150 dp_data.data, iface_ptr); 141 &dp_data, dp_data.data, iface_ptr); 151 142 continue; 152 143 } … … 170 161 } 171 162 172 *alternates_ptr = alternates;173 174 163 return EOK; 175 164 } 176 165 177 void usb_alternate_interfaces_de stroy(usb_alternate_interfaces_t *alternate)166 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate) 178 167 { 179 168 if (!alternate) 180 169 return; 181 170 free(alternate->alternatives); 182 free(alternate);183 171 } 184 172 /**
Note:
See TracChangeset
for help on using the changeset viewer.