Changeset 205f0766 in mainline
- Timestamp:
- 2011-10-12T19:41:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 90994fa
- Parents:
- 6626bba9
- Location:
- uspace/drv/bus/usb/usbhub
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
r6626bba9 r205f0766 85 85 int usb_hub_device_gone(usb_device_t *usb_dev) 86 86 { 87 return ENOTSUP; 87 assert(usb_dev); 88 usb_hub_dev_t *hub = usb_dev->driver_data; 89 assert(hub); 90 unsigned tries = 10; 91 while (hub->running) { 92 async_usleep(100000); 93 if (!tries--) { 94 usb_log_error("Can't remove hub, still running.\n"); 95 return EINPROGRESS; 96 } 97 } 98 99 assert(!hub->running); 100 const int ret = ddf_fun_unbind(hub->hub_fun); 101 if (ret != EOK) { 102 usb_log_error("Failed to unbind '%s' function: %s.\n", 103 HUB_FNC_NAME, str_error(ret)); 104 return ret; 105 } 106 ddf_fun_destroy(hub->hub_fun); 107 free(hub->ports); 108 free(hub); 109 usb_dev->driver_data = NULL; 110 usb_log_info("USB hub driver, stopped and cleaned.\n"); 111 return EOK; 88 112 } 89 113 /*----------------------------------------------------------------------------*/ … … 126 150 } 127 151 128 / /get port count and create attached_devs152 /* Get port count and create attached_devices. */ 129 153 opResult = usb_hub_process_hub_specific_info(hub_info); 130 154 if (opResult != EOK) { … … 157 181 usb_hub_polling_terminated_callback, hub_info); 158 182 if (opResult != EOK) { 183 /* Function is already bound */ 184 ddf_fun_unbind(hub_info->hub_fun); 159 185 ddf_fun_destroy(hub_info->hub_fun); 160 186 free(hub_info); … … 163 189 return opResult; 164 190 } 191 hub_info->running = true; 165 192 usb_log_info("Controlling hub '%s' (%zu ports).\n", 166 193 hub_info->usb_device->ddf_dev->name, hub_info->port_count); … … 225 252 info->port_count = -1; 226 253 info->pending_ops_count = 0; 254 info->running = false; 227 255 fibril_mutex_initialize(&info->pending_ops_mutex); 228 256 fibril_condvar_initialize(&info->pending_ops_cv); 257 usb_dev->driver_data = info; 229 258 230 259 return info; … … 489 518 } 490 519 fibril_mutex_unlock(&hub->pending_ops_mutex); 491 492 usb_device_destroy(hub->usb_device); 493 494 free(hub->ports); 495 free(hub); 520 hub->running = false; 496 521 } 497 522 /** -
uspace/drv/bus/usb/usbhub/usbhub.h
r6626bba9 r205f0766 75 75 /** Pointer to devman usbhub function. */ 76 76 ddf_fun_t *hub_fun; 77 /** Status indicator */ 78 bool running; 77 79 }; 78 80
Note:
See TracChangeset
for help on using the changeset viewer.