Changeset 91173333 in mainline for uspace/drv/bus/usb/usbhub/usbhub.c
- Timestamp:
- 2018-01-13T21:36:13Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- edc51615
- Parents:
- 8a0c52a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
r8a0c52a r91173333 99 99 100 100 /* Continue polling until the device is about to be removed. */ 101 return hub->running && !hub->poll_stop;101 return hub->running; 102 102 } 103 103 … … 123 123 hub_dev->pending_ops_count = 0; 124 124 hub_dev->running = false; 125 hub_dev->poll_stop = false;126 125 fibril_mutex_initialize(&hub_dev->pending_ops_mutex); 127 fibril_mutex_initialize(&hub_dev->poll_guard);128 126 fibril_condvar_initialize(&hub_dev->pending_ops_cv); 129 fibril_condvar_initialize(&hub_dev->poll_cv);130 127 131 128 /* Set hub's first configuration. (There should be only one) */ … … 197 194 } 198 195 199 /**200 * Turn off power to all ports.201 *202 * @param usb_dev generic usb device information203 * @return error code204 */205 int usb_hub_device_remove(usb_device_t *usb_dev)206 {207 assert(usb_dev);208 usb_hub_dev_t *hub = usb_device_data_get(usb_dev);209 assert(hub);210 211 usb_log_info("(%p) USB hub will be removed.", hub);212 213 /* Instruct the hub to stop once endpoints are unregistered. */214 hub->poll_stop = true;215 return EOK;216 }217 218 196 static int usb_hub_cleanup(usb_hub_dev_t *hub) 219 197 { … … 241 219 } 242 220 243 int usb_hub_device_removed(usb_device_t *usb_dev) 221 /** 222 * Turn off power to all ports. 223 * 224 * @param usb_dev generic usb device information 225 * @return error code 226 */ 227 int usb_hub_device_remove(usb_device_t *usb_dev) 244 228 { 245 229 assert(usb_dev); … … 247 231 assert(hub); 248 232 249 usb_log_info("(%p) USB hub wasremoved, joining polling fibril.", hub);233 usb_log_info("(%p) USB hub removed, joining polling fibril.", hub); 250 234 251 235 /* Join polling fibril. */ 252 fibril_mutex_lock(&hub->poll_guard); 253 while (hub->running) 254 fibril_condvar_wait(&hub->poll_cv, &hub->poll_guard); 255 fibril_mutex_unlock(&hub->poll_guard); 256 236 usb_device_poll_join(hub->polling); 257 237 usb_log_info("(%p) USB hub polling stopped, freeing memory.", hub); 258 238 … … 272 252 assert(hub); 273 253 274 hub->poll_stop = true;275 254 usb_log_info("(%p) USB hub gone, joining polling fibril.", hub); 276 255 277 256 /* Join polling fibril. */ 278 fibril_mutex_lock(&hub->poll_guard); 279 while (hub->running) 280 fibril_condvar_wait(&hub->poll_cv, &hub->poll_guard); 281 fibril_mutex_unlock(&hub->poll_guard); 257 usb_device_poll_join(hub->polling); 258 usb_log_info("(%p) USB hub polling stopped, freeing memory.", hub); 282 259 283 260 /* Destroy hub. */ … … 592 569 fibril_mutex_unlock(&hub->pending_ops_mutex); 593 570 hub->running = false; 594 595 /* Signal polling end to joining thread. */ 596 fibril_mutex_lock(&hub->poll_guard); 597 fibril_condvar_signal(&hub->poll_cv); 598 fibril_mutex_unlock(&hub->poll_guard); 599 } 571 } 572 600 573 /** 601 574 * @}
Note:
See TracChangeset
for help on using the changeset viewer.