Changeset 8ba18c6 in mainline
- Timestamp:
- 2011-02-20T17:02:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5c3ace2
- Parents:
- 18cb870
- Location:
- uspace/drv/usbmid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmid/usbmid.c
r18cb870 r8ba18c6 68 68 } 69 69 70 /** Callback for DDF USB interface. */ 71 static int usb_iface_get_interface_impl(device_t *device, devman_handle_t handle, 72 int *iface_no) 73 { 74 assert(device); 75 76 usbmid_interface_t *iface = device->driver_data; 77 assert(iface); 78 79 if (iface_no != NULL) { 80 *iface_no = iface->interface_no; 81 } 82 83 return EOK; 84 } 85 70 86 static usb_iface_t child_usb_iface = { 71 87 .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl, 72 .get_address = usb_iface_get_address_impl 88 .get_address = usb_iface_get_address_impl, 89 .get_interface = usb_iface_get_interface_impl 73 90 }; 74 91 … … 121 138 } 122 139 140 /** Create new interface for USB MID device. 141 * 142 * @param dev Backing generic DDF child device (representing interface). 143 * @param iface_no Interface number. 144 * @return New interface. 145 * @retval NULL Error occured. 146 */ 147 usbmid_interface_t *usbmid_interface_create(device_t *dev, int iface_no) 148 { 149 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 150 if (iface == NULL) { 151 usb_log_error("Out of memory (wanted %zuB).\n", 152 sizeof(usbmid_interface_t)); 153 return NULL; 154 } 155 156 iface->dev = dev; 157 iface->interface_no = iface_no; 158 159 return iface; 160 } 161 123 162 124 163 /** Spawn new child device from one interface. … … 135 174 device_t *child = NULL; 136 175 char *child_name = NULL; 176 usbmid_interface_t *child_as_interface = NULL; 137 177 int rc; 138 178 … … 155 195 goto error_leave; 156 196 } 197 198 child_as_interface = usbmid_interface_create(child, 199 (int) interface_descriptor->interface_number); 200 if (child_as_interface == NULL) { 201 rc = ENOMEM; 202 goto error_leave; 203 } 204 205 child->driver_data = child_as_interface; 157 206 child->parent = parent->dev; 158 207 child->name = child_name; … … 181 230 free(child_name); 182 231 } 232 if (child_as_interface != NULL) { 233 free(child_as_interface); 234 } 183 235 184 236 return rc; -
uspace/drv/usbmid/usbmid.h
r18cb870 r8ba18c6 54 54 } usbmid_device_t; 55 55 56 typedef struct { 57 /** Device container. */ 58 device_t *dev; 59 60 /** Interface number. */ 61 int interface_no; 62 } usbmid_interface_t; 63 56 64 usbmid_device_t *usbmid_device_create(device_t *); 65 usbmid_interface_t *usbmid_interface_create(device_t *, int); 57 66 bool usbmid_explore_device(usbmid_device_t *); 58 67 int usbmid_spawn_interface_child(usbmid_device_t *,
Note:
See TracChangeset
for help on using the changeset viewer.