Changeset b8d453ec in mainline for uspace/lib/usb/src/host/device_keeper.c
- Timestamp:
- 2011-03-25T17:18:46Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a2923d
- Parents:
- da3dafc (diff), 095b2017 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/device_keeper.c
rda3dafc rb8d453ec 49 49 assert(instance); 50 50 fibril_mutex_initialize(&instance->guard); 51 fibril_condvar_initialize(&instance-> default_address_occupied);51 fibril_condvar_initialize(&instance->change); 52 52 instance->last_address = 0; 53 53 unsigned i = 0; 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = false; 56 57 instance->devices[i].handle = 0; 57 58 instance->devices[i].toggle_status[0] = 0; … … 71 72 fibril_mutex_lock(&instance->guard); 72 73 while (instance->devices[USB_ADDRESS_DEFAULT].occupied) { 73 fibril_condvar_wait(&instance->default_address_occupied, 74 &instance->guard); 74 fibril_condvar_wait(&instance->change, &instance->guard); 75 75 } 76 76 instance->devices[USB_ADDRESS_DEFAULT].occupied = true; … … 90 90 instance->devices[USB_ADDRESS_DEFAULT].occupied = false; 91 91 fibril_mutex_unlock(&instance->guard); 92 fibril_condvar_signal(&instance-> default_address_occupied);92 fibril_condvar_signal(&instance->change); 93 93 } 94 94 /*----------------------------------------------------------------------------*/ … … 309 309 return instance->devices[address].speed; 310 310 } 311 311 /*----------------------------------------------------------------------------*/ 312 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 313 usb_address_t address) 314 { 315 assert(instance); 316 fibril_mutex_lock(&instance->guard); 317 while (instance->devices[address].control_used) { 318 fibril_condvar_wait(&instance->change, &instance->guard); 319 } 320 instance->devices[address].control_used = true; 321 fibril_mutex_unlock(&instance->guard); 322 } 323 /*----------------------------------------------------------------------------*/ 324 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 325 usb_address_t address) 326 { 327 assert(instance); 328 fibril_mutex_lock(&instance->guard); 329 instance->devices[address].control_used = false; 330 fibril_mutex_unlock(&instance->guard); 331 fibril_condvar_signal(&instance->change); 332 } 312 333 /** 313 334 * @}
Note:
See TracChangeset
for help on using the changeset viewer.