Changes in uspace/drv/usbmid/usbmid.c [ecb107b:fcafa04] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmid/usbmid.c
recb107b rfcafa04 79 79 }; 80 80 81 /** Create new interface for USB MID device. 82 * 83 * @param fun Backing generic DDF device function (representing interface). 84 * @param iface_no Interface number. 85 * @return New interface. 86 * @retval NULL Error occured. 87 */ 88 usbmid_interface_t *usbmid_interface_create(ddf_fun_t *fun, int iface_no) 89 { 90 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 91 if (iface == NULL) { 92 usb_log_error("Out of memory (wanted %zuB).\n", 93 sizeof(usbmid_interface_t)); 94 return NULL; 95 } 96 97 iface->fun = fun; 98 iface->interface_no = iface_no; 99 100 return iface; 101 } 102 81 103 82 104 /** Spawn new child device from one interface. 83 105 * 84 106 * @param parent Parent MID device. 85 * @param iface Interface information.86 107 * @param device_descriptor Device descriptor. 87 108 * @param interface_descriptor Interface descriptor. … … 89 110 */ 90 111 int usbmid_spawn_interface_child(usb_device_t *parent, 91 usbmid_interface_t *iface,92 112 const usb_standard_device_descriptor_t *device_descriptor, 93 113 const usb_standard_interface_descriptor_t *interface_descriptor) … … 95 115 ddf_fun_t *child = NULL; 96 116 char *child_name = NULL; 117 usbmid_interface_t *child_as_interface = NULL; 97 118 int rc; 98 119 … … 116 137 } 117 138 118 iface->fun = child;119 139 120 child->driver_data = iface; 140 141 child_as_interface = usbmid_interface_create(child, 142 (int) interface_descriptor->interface_number); 143 if (child_as_interface == NULL) { 144 rc = ENOMEM; 145 goto error_leave; 146 } 147 148 child->driver_data = child_as_interface; 121 149 child->ops = &child_device_ops; 122 150 … … 144 172 free(child_name); 145 173 } 174 if (child_as_interface != NULL) { 175 free(child_as_interface); 176 } 146 177 147 178 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.