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