Changes in uspace/lib/usbdev/src/altiface.c [ab27e01:6e3c005] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/altiface.c
rab27e01 r6e3c005 65 65 size_t alternate_count = 0; 66 66 67 const uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser,68 &dp_data, config_descr);67 const void *iface_ptr = 68 usb_dp_get_nested_descriptor(&dp_parser, &dp_data, config_descr); 69 69 while (iface_ptr != NULL) { 70 usb_standard_interface_descriptor_t *iface 71 = (usb_standard_interface_descriptor_t *) iface_ptr; 72 if (iface->descriptor_type == USB_DESCTYPE_INTERFACE) { 73 if (iface->interface_number == interface_no) { 74 alternate_count++; 75 } 70 const usb_standard_interface_descriptor_t *iface = iface_ptr; 71 if (iface->descriptor_type == USB_DESCTYPE_INTERFACE 72 && iface->interface_number == interface_no) { 73 ++alternate_count; 76 74 } 77 75 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, … … 82 80 } 83 81 84 /** Create alternate interface representation structure.82 /** Initialize alternate interface representation structure. 85 83 * 84 * @param[in] alternates Pointer to allocated structure. 86 85 * @param[in] config_descr Configuration descriptor. 87 86 * @param[in] config_descr_size Size of configuration descriptor. 88 87 * @param[in] interface_number Interface number. 89 * @param[out] alternates_ptr Where to store pointer to allocated structure.90 88 * @return Error code. 91 89 */ … … 101 99 alternates->current = 0; 102 100 101 /* No interfaces. */ 103 102 if (interface_number < 0) { 104 103 return EOK; … … 107 106 alternates->alternative_count 108 107 = usb_interface_count_alternates(config_descr, config_descr_size, 109 interface_number);108 interface_number); 110 109 111 110 if (alternates->alternative_count == 0) { … … 128 127 }; 129 128 130 usb_alternate_interface_descriptors_t * cur_alt_iface129 usb_alternate_interface_descriptors_t *iterator 131 130 = &alternates->alternatives[0]; 132 131 133 const uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser, 134 &dp_data, dp_data.data); 135 while (iface_ptr != NULL) { 136 usb_standard_interface_descriptor_t *iface 137 = (usb_standard_interface_descriptor_t *) iface_ptr; 132 const usb_alternate_interface_descriptors_t *end 133 = &alternates->alternatives[alternates->alternative_count]; 134 135 const void *iface_ptr = 136 usb_dp_get_nested_descriptor(&dp_parser, &dp_data, dp_data.data); 137 138 while (iface_ptr != NULL && iterator < end) { 139 const usb_standard_interface_descriptor_t *iface = iface_ptr; 140 138 141 if ((iface->descriptor_type != USB_DESCTYPE_INTERFACE) 139 142 || (iface->interface_number != interface_number)) { 143 /* This is not a valid alternate interface descriptor 144 * for interface with number == interface_number. */ 140 145 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, 141 146 &dp_data, dp_data.data, iface_ptr); … … 143 148 } 144 149 145 cur_alt_iface->interface = iface;146 cur_alt_iface->nested_descriptors = iface_ptr + sizeof(*iface);150 iterator->interface = iface; 151 iterator->nested_descriptors = iface_ptr + sizeof(*iface); 147 152 148 153 /* Find next interface to count size of nested descriptors. */ 149 154 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, 150 155 dp_data.data, iface_ptr); 151 if (iface_ptr == NULL) {152 const uint8_t *next = dp_data.data + dp_data.size;153 cur_alt_iface->nested_descriptors_size154 = next - cur_alt_iface->nested_descriptors;155 } else {156 cur_alt_iface->nested_descriptors_size157 = iface_ptr - cur_alt_iface->nested_descriptors;158 }159 156 160 cur_alt_iface++; 157 const uint8_t *next = (iface_ptr == NULL) ? 158 dp_data.data + dp_data.size : iface_ptr; 159 160 iterator->nested_descriptors_size 161 = next - iterator->nested_descriptors; 162 163 ++iterator; 161 164 } 162 165 … … 164 167 } 165 168 166 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate) 169 /** Clean initialized structure. 170 * @param instance structure do deinitialize. 171 */ 172 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *instance) 167 173 { 168 if (! alternate)174 if (!instance) 169 175 return; 170 free(alternate->alternatives); 176 free(instance->alternatives); 177 instance->alternatives = NULL; 171 178 } 172 179 /**
Note:
See TracChangeset
for help on using the changeset viewer.