Changeset 8be7819 in mainline
- Timestamp:
- 2011-10-30T19:59:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cae002c
- Parents:
- e462909
- Location:
- uspace/drv/bus/usb/usbmid
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/explore.c
re462909 r8be7819 139 139 int rc; 140 140 141 intdev_class = dev->descriptors.device.device_class;141 unsigned dev_class = dev->descriptors.device.device_class; 142 142 if (dev_class != USB_CLASS_USE_INTERFACE) { 143 143 usb_log_warning( 144 "Device class: %d (%s), but expected class 0.\n", 145 dev_class, usb_str_class(dev_class)); 144 "Device class: %u (%s), but expected class %u.\n", 145 dev_class, usb_str_class(dev_class), 146 USB_CLASS_USE_INTERFACE); 146 147 usb_log_error("Not multi interface device, refusing.\n"); 147 148 return false; 148 149 } 149 150 150 /* Short 151 /* Shortcuts to save on typing ;-). */ 151 152 const void *config_descriptor_raw = dev->descriptors.configuration; 152 153 size_t config_descriptor_size = dev->descriptors.configuration_size; … … 163 164 } 164 165 166 /* Create driver soft-state. */ 165 167 usb_mid_t *usb_mid = usb_device_data_alloc(dev, sizeof(usb_mid_t)); 166 168 if (!usb_mid) { … … 169 171 } 170 172 171 /* Create control function */173 /* Create control function. */ 172 174 usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); 173 175 if (usb_mid->ctl_fun == NULL) { … … 175 177 return false; 176 178 } 177 178 179 usb_mid->ctl_fun->ops = &mid_device_ops; 179 180 181 /* Bind control function. */ 180 182 rc = ddf_fun_bind(usb_mid->ctl_fun); 181 183 if (rc != EOK) { … … 192 194 &usb_mid->interface_list); 193 195 196 /* Start child function for every interface. */ 194 197 list_foreach(usb_mid->interface_list, link) { 195 usbmid_interface_t *iface = list_get_instance(link, 196 usbmid_interface_t, link); 198 usbmid_interface_t *iface = usbmid_interface_from_link(link); 197 199 198 200 usb_log_info("Creating child for interface %d (%s).\n", 199 (int)iface->interface_no,201 iface->interface_no, 200 202 usb_str_class(iface->interface->interface_class)); 201 203 -
uspace/drv/bus/usb/usbmid/main.c
re462909 r8be7819 74 74 { 75 75 assert(dev); 76 int ret = ENOTSUP; 76 77 /* Remove ctl function */ 77 78 usb_mid_t *usb_mid = dev->driver_data; 78 assert(usb_mid); 79 int ret = ddf_fun_unbind(usb_mid->ctl_fun); 80 if (ret != EOK) { 81 usb_log_error("Failed to unbind USB MID ctl function: %s.\n", 82 str_error(ret)); 83 return ret; 84 } 85 ddf_fun_destroy(usb_mid->ctl_fun); 79 86 80 /* Signal all interface functions */ 81 list_foreach(usb_mid->interface_list, item) { 87 /* Remove all children */ 88 while (!list_empty(&usb_mid->interface_list)) { 89 link_t *item = list_first(&usb_mid->interface_list); 90 list_remove(item); 91 82 92 usbmid_interface_t *iface = usbmid_interface_from_link(item); 83 93 84 usb_log_info(" Signaling remove to child for interface "85 "%d (%s).\n",iface->interface_no,94 usb_log_info("Removing child for interface %d (%s).\n", 95 iface->interface_no, 86 96 usb_str_class(iface->interface->interface_class)); 87 // TODO cascade the call. 97 98 /* Tell the child to go off-line. */ 99 int pret = ddf_fun_offline(iface->fun); 100 if (pret != EOK) { 101 usb_log_warning("Failed to turn off child for interface" 102 " %d (%s): %s\n", iface->interface_no, 103 usb_str_class(iface->interface->interface_class), 104 str_error(pret)); 105 ret = pret; 106 } 107 108 /* Now remove the child. */ 109 pret = usbmid_interface_destroy(iface); 110 if (pret != EOK) { 111 usb_log_error("Failed to remove child for interface " 112 "%d (%s): %s\n", iface->interface_no, 113 usb_str_class(iface->interface->interface_class), 114 str_error(pret)); 115 ret = pret; 116 } 88 117 } 89 118 return ret; … … 117 146 usbmid_interface_t *iface = usbmid_interface_from_link(item); 118 147 119 usb_log_info(" Removing child for interface %d (%s).\n",148 usb_log_info("Child for interface %d (%s) gone.\n", 120 149 iface->interface_no, 121 150 usb_str_class(iface->interface->interface_class)); -
uspace/drv/bus/usb/usbmid/usbmid.c
re462909 r8be7819 110 110 * class name something humanly understandable. 111 111 */ 112 rc = asprintf(&child_name, "%s% d",112 rc = asprintf(&child_name, "%s%hhu", 113 113 usb_str_class(interface_descriptor->interface_class), 114 (int)interface_descriptor->interface_number);114 interface_descriptor->interface_number); 115 115 if (rc < 0) { 116 116 return ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.