Changeset 6a32665d in mainline
- Timestamp:
- 2011-04-08T11:07:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cd1cec3b
- Parents:
- 52cc968
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/host/endpoint.h
r52cc968 r6a32665d 39 39 #include <bool.h> 40 40 #include <adt/list.h> 41 #include <fibril_synch.h> 42 41 43 #include <usb/usb.h> 42 44 … … 48 50 usb_speed_t speed; 49 51 size_t max_packet_size; 52 unsigned toggle:1; 53 fibril_mutex_t guard; 54 fibril_condvar_t avail; 50 55 bool active; 51 unsigned toggle:1;52 56 link_t same_device_eps; 53 57 } endpoint_t; … … 58 62 59 63 void endpoint_destroy(endpoint_t *instance); 64 65 void endpoint_use(endpoint_t *instance); 66 67 void endpoint_release(endpoint_t *instance); 60 68 61 69 int endpoint_toggle_get(endpoint_t *instance); -
uspace/lib/usb/src/host/endpoint.c
r52cc968 r6a32665d 34 34 */ 35 35 36 #include <assert.h> 36 37 #include <errno.h> 37 38 #include <usb/host/endpoint.h> … … 49 50 instance->max_packet_size = max_packet_size; 50 51 instance->toggle = 0; 52 instance->active = false; 53 fibril_mutex_initialize(&instance->guard); 54 fibril_condvar_initialize(&instance->avail); 51 55 link_initialize(&instance->same_device_eps); 52 56 return EOK; … … 58 62 list_remove(&instance->same_device_eps); 59 63 free(instance); 64 } 65 /*----------------------------------------------------------------------------*/ 66 void endpoint_use(endpoint_t *instance) 67 { 68 assert(instance); 69 fibril_mutex_lock(&instance->guard); 70 while (instance->active) 71 fibril_condvar_wait(&instance->avail, &instance->guard); 72 instance->active = true; 73 fibril_mutex_unlock(&instance->guard); 74 } 75 /*----------------------------------------------------------------------------*/ 76 void endpoint_release(endpoint_t *instance) 77 { 78 assert(instance); 79 fibril_mutex_lock(&instance->guard); 80 instance->active = false; 81 fibril_condvar_signal(&instance->avail); 82 fibril_mutex_unlock(&instance->guard); 60 83 } 61 84 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.