Changes in uspace/drv/bus/usb/usbmid/usbmid.c [5203e256:5153b58] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
r5203e256 r5153b58 45 45 46 46 /** Callback for DDF USB interface. */ 47 static int usb_iface_get_address_impl(ddf_fun_t *fun, devman_handle_t handle,48 usb_address_t *address)49 {50 return usb_iface_get_address_hub_impl(fun, handle, address);51 }52 53 /** Callback for DDF USB interface. */54 47 static int usb_iface_get_interface_impl(ddf_fun_t *fun, devman_handle_t handle, 55 48 int *iface_no) … … 69 62 /** DDF interface of the child - interface function. */ 70 63 static usb_iface_t child_usb_iface = { 71 .get_hc_handle = usb_iface_get_hc_handle_ hub_child_impl,72 .get_ address = usb_iface_get_address_impl,73 .get_interface = usb_iface_get_interface_impl 64 .get_hc_handle = usb_iface_get_hc_handle_device_impl, 65 .get_my_address = usb_iface_get_my_address_forward_impl, 66 .get_interface = usb_iface_get_interface_impl, 74 67 }; 75 68 … … 79 72 }; 80 73 74 int usbmid_interface_destroy(usbmid_interface_t *mid_iface) 75 { 76 assert(mid_iface); 77 assert_link_not_used(&mid_iface->link); 78 const int ret = ddf_fun_unbind(mid_iface->fun); 79 if (ret != EOK) { 80 return ret; 81 } 82 /* NOTE: usbmid->interface points somewhere, but we did not 83 * allocate that space, so don't touch */ 84 ddf_fun_destroy(mid_iface->fun); 85 /* NOTE: mid_iface is invalid at this point, it was assigned to 86 * mid_iface->fun->driver_data and freed in ddf_fun_destroy */ 87 return EOK; 88 } 81 89 82 90 /** Spawn new child device from one interface. … … 102 110 * class name something humanly understandable. 103 111 */ 104 rc = asprintf(&child_name, "%s% d",112 rc = asprintf(&child_name, "%s%hhu", 105 113 usb_str_class(interface_descriptor->interface_class), 106 (int)interface_descriptor->interface_number);114 interface_descriptor->interface_number); 107 115 if (rc < 0) { 108 goto error_leave;116 return ENOMEM; 109 117 } 110 118 111 119 /* Create the device. */ 112 120 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 121 free(child_name); 113 122 if (child == NULL) { 114 rc = ENOMEM; 115 goto error_leave; 123 return ENOMEM; 116 124 } 117 125 118 iface->fun = child;119 120 child->driver_data = iface;121 child->ops = &child_device_ops;122 123 126 rc = usb_device_create_match_ids_from_interface(device_descriptor, 124 interface_descriptor, 125 &child->match_ids); 127 interface_descriptor, &child->match_ids); 126 128 if (rc != EOK) { 127 goto error_leave; 129 ddf_fun_destroy(child); 130 return rc; 128 131 } 129 132 130 133 rc = ddf_fun_bind(child); 131 134 if (rc != EOK) { 132 goto error_leave; 135 /* This takes care of match_id deallocation as well. */ 136 ddf_fun_destroy(child); 137 return rc; 133 138 } 134 139 140 iface->fun = child; 141 child->driver_data = iface; 142 child->ops = &child_device_ops; 143 135 144 return EOK; 136 137 error_leave:138 if (child != NULL) {139 child->name = NULL;140 /* This takes care of match_id deallocation as well. */141 ddf_fun_destroy(child);142 }143 if (child_name != NULL) {144 free(child_name);145 }146 147 return rc;148 145 } 149 146
Note:
See TracChangeset
for help on using the changeset viewer.