Changes in uspace/drv/bus/usb/usbmid/explore.c [87a3df7f:feeac0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/explore.c
r87a3df7f rfeeac0d 34 34 * Exploration of available interfaces in the USB device. 35 35 */ 36 #include <ddf/driver.h>37 36 #include <errno.h> 38 37 #include <str_error.h> … … 71 70 * @param config_descriptor_size Size of configuration descriptor in bytes. 72 71 * @param list List where to add the interfaces. 73 * @return EOK on success, ENOMEM if out of memory. 74 */ 75 static int create_interfaces(usb_mid_t *mid, const uint8_t *config_descriptor, 76 size_t config_descriptor_size) 72 */ 73 static void create_interfaces(const uint8_t *config_descriptor, 74 size_t config_descriptor_size, list_t *list) 77 75 { 78 76 const usb_dp_parser_data_t data = { … … 103 101 104 102 /* Skip alternate interfaces. */ 105 if (interface_in_list(&mid->interface_list, 106 interface->interface_number)) { 103 if (interface_in_list(list, interface->interface_number)) { 107 104 /* TODO: add the alternatives and create match ids 108 105 * for them. */ 109 106 continue; 110 107 } 111 112 /* Create the function */ 113 ddf_fun_t *fun = ddf_fun_create(mid->dev, fun_inner, NULL); 114 if (fun == NULL) 115 goto error; 116 117 usbmid_interface_t *iface = ddf_fun_data_alloc(fun, 118 sizeof(usbmid_interface_t)); 119 if (iface == NULL) 120 goto error; 108 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 109 if (iface == NULL) { 110 //TODO: Do something about that failure. 111 break; 112 } 121 113 122 114 link_initialize(&iface->link); 123 iface->fun = fun;115 iface->fun = NULL; 124 116 iface->interface_no = interface->interface_number; 125 117 iface->interface = interface; 126 118 127 list_append(&iface->link, &mid->interface_list); 128 } 129 130 return EOK; 131 error: 132 while (!list_empty(&mid->interface_list)) { 133 link_t *link = list_first(&mid->interface_list); 134 usbmid_interface_t *iface = list_get_instance(link, 135 usbmid_interface_t, link); 136 137 ddf_fun_destroy(iface->fun); 138 } 139 140 return ENOMEM; 119 list_append(&iface->link, list); 120 } 141 121 } 142 122 … … 185 165 } 186 166 187 usb_mid->dev = dev->ddf_dev;188 189 167 /* Create control function. */ 190 168 usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); … … 204 182 } 205 183 184 206 185 /* Create interface children. */ 207 186 list_initialize(&usb_mid->interface_list); 208 create_interfaces(usb_mid, config_descriptor_raw, config_descriptor_size); 187 create_interfaces(config_descriptor_raw, config_descriptor_size, 188 &usb_mid->interface_list); 209 189 210 190 /* Start child function for every interface. */
Note:
See TracChangeset
for help on using the changeset viewer.