Changeset 9f583151 in mainline
- Timestamp:
- 2011-11-05T18:35:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e04182d
- Parents:
- 5153b58
- Location:
- uspace/drv/bus/usb/usbmid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/explore.c
r5153b58 r9f583151 57 57 { 58 58 list_foreach(*list, l) { 59 usbmid_interface_t *iface 60 = list_get_instance(l, usbmid_interface_t, link); 59 usbmid_interface_t *iface = usbmid_interface_from_link(l); 61 60 if (iface->interface_no == interface_no) { 62 61 return true; … … 82 81 }; 83 82 84 usb_dp_parser_t parser = {83 static const usb_dp_parser_t parser = { 85 84 .nesting = usb_dp_standard_descriptor_nesting 86 85 }; 87 86 88 87 const uint8_t *interface_ptr = 89 usb_dp_get_nested_descriptor(&parser, &data, data.data); 90 if (interface_ptr == NULL) { 91 return; 92 } 93 94 do { 95 if (interface_ptr[1] != USB_DESCTYPE_INTERFACE) { 96 goto next_descriptor; 97 } 98 99 usb_standard_interface_descriptor_t *interface 88 usb_dp_get_nested_descriptor(&parser, &data, config_descriptor); 89 90 /* Walk all descriptors nested in the current configuration decriptor; 91 * i.e. all interface descriptors. */ 92 for (;interface_ptr != NULL; 93 interface_ptr = usb_dp_get_sibling_descriptor( 94 &parser, &data, config_descriptor, interface_ptr)) 95 { 96 /* The second byte is DESCTYPE byte in all desriptors. */ 97 if (interface_ptr[1] != USB_DESCTYPE_INTERFACE) 98 continue; 99 100 const usb_standard_interface_descriptor_t *interface 100 101 = (usb_standard_interface_descriptor_t *) interface_ptr; 101 102 102 103 /* Skip alternate interfaces. */ 103 if (!interface_in_list(list, interface->interface_number)) { 104 usbmid_interface_t *iface 105 = malloc(sizeof(usbmid_interface_t)); 106 if (iface == NULL) { 107 break; 108 } 109 link_initialize(&iface->link); 110 iface->fun = NULL; 111 iface->interface_no = interface->interface_number; 112 iface->interface = interface; 113 114 list_append(&iface->link, list); 115 } 116 117 /* TODO: add the alternatives and create match ids from them 118 * as well. 119 */ 120 121 next_descriptor: 122 interface_ptr = usb_dp_get_sibling_descriptor(&parser, &data, 123 data.data, interface_ptr); 124 125 } while (interface_ptr != NULL); 126 104 if (interface_in_list(list, interface->interface_number)) { 105 /* TODO: add the alternatives and create match ids 106 * for them. */ 107 continue; 108 } 109 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 110 if (iface == NULL) { 111 //TODO: Do something about that failure. 112 break; 113 } 114 115 link_initialize(&iface->link); 116 iface->fun = NULL; 117 iface->interface_no = interface->interface_number; 118 iface->interface = interface; 119 120 list_append(&iface->link, list); 121 } 127 122 } 128 123 -
uspace/drv/bus/usb/usbmid/usbmid.h
r5153b58 r9f583151 51 51 ddf_fun_t *fun; 52 52 /** Interface descriptor. */ 53 usb_standard_interface_descriptor_t *interface;53 const usb_standard_interface_descriptor_t *interface; 54 54 /** Interface number. */ 55 55 int interface_no;
Note:
See TracChangeset
for help on using the changeset viewer.