Changes in uspace/drv/usbmid/usbmid.c [fcafa04:ecb107b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmid/usbmid.c
rfcafa04 recb107b 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 103 81 104 82 /** Spawn new child device from one interface. 105 83 * 106 84 * @param parent Parent MID device. 85 * @param iface Interface information. 107 86 * @param device_descriptor Device descriptor. 108 87 * @param interface_descriptor Interface descriptor. … … 110 89 */ 111 90 int usbmid_spawn_interface_child(usb_device_t *parent, 91 usbmid_interface_t *iface, 112 92 const usb_standard_device_descriptor_t *device_descriptor, 113 93 const usb_standard_interface_descriptor_t *interface_descriptor) … … 115 95 ddf_fun_t *child = NULL; 116 96 char *child_name = NULL; 117 usbmid_interface_t *child_as_interface = NULL;118 97 int rc; 119 98 … … 137 116 } 138 117 118 iface->fun = child; 139 119 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; 120 child->driver_data = iface; 149 121 child->ops = &child_device_ops; 150 122 … … 172 144 free(child_name); 173 145 } 174 if (child_as_interface != NULL) {175 free(child_as_interface);176 }177 146 178 147 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.