Changeset e50cd7f in mainline for uspace/lib/usb/src/host/endpoint.c
- Timestamp:
- 2011-04-17T19:17:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63517c2, cfbbe1d3
- Parents:
- ef354b6 (diff), 8595577b (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/endpoint.c
ref354b6 re50cd7f 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; 51 link_initialize(&instance->same_device_eps); 52 instance->active = false; 53 fibril_mutex_initialize(&instance->guard); 54 fibril_condvar_initialize(&instance->avail); 55 endpoint_clear_hc_data(instance); 52 56 return EOK; 53 57 } … … 56 60 { 57 61 assert(instance); 58 list_remove(&instance->same_device_eps);62 assert(!instance->active); 59 63 free(instance); 64 } 65 /*----------------------------------------------------------------------------*/ 66 void endpoint_set_hc_data(endpoint_t *instance, 67 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 68 { 69 assert(instance); 70 instance->hc_data.data = data; 71 instance->hc_data.toggle_get = toggle_get; 72 instance->hc_data.toggle_set = toggle_set; 73 } 74 /*----------------------------------------------------------------------------*/ 75 void endpoint_clear_hc_data(endpoint_t *instance) 76 { 77 assert(instance); 78 instance->hc_data.data = NULL; 79 instance->hc_data.toggle_get = NULL; 80 instance->hc_data.toggle_set = NULL; 81 } 82 /*----------------------------------------------------------------------------*/ 83 void endpoint_use(endpoint_t *instance) 84 { 85 assert(instance); 86 fibril_mutex_lock(&instance->guard); 87 while (instance->active) 88 fibril_condvar_wait(&instance->avail, &instance->guard); 89 instance->active = true; 90 fibril_mutex_unlock(&instance->guard); 91 } 92 /*----------------------------------------------------------------------------*/ 93 void endpoint_release(endpoint_t *instance) 94 { 95 assert(instance); 96 fibril_mutex_lock(&instance->guard); 97 instance->active = false; 98 fibril_mutex_unlock(&instance->guard); 99 fibril_condvar_signal(&instance->avail); 60 100 } 61 101 /*----------------------------------------------------------------------------*/ … … 63 103 { 64 104 assert(instance); 105 if (instance->hc_data.toggle_get) 106 instance->toggle = 107 instance->hc_data.toggle_get(instance->hc_data.data); 65 108 return (int)instance->toggle; 66 109 } … … 70 113 assert(instance); 71 114 assert(toggle == 0 || toggle == 1); 115 if (instance->hc_data.toggle_set) 116 instance->hc_data.toggle_set(instance->hc_data.data, toggle); 72 117 instance->toggle = toggle; 73 118 } 74 119 /*----------------------------------------------------------------------------*/ 75 void endpoint_toggle_reset (link_t *ep)120 void endpoint_toggle_reset_filtered(endpoint_t *instance, usb_target_t target) 76 121 { 77 endpoint_t *instance =78 list_get_instance(ep, endpoint_t, same_device_eps);79 122 assert(instance); 80 instance->toggle = 0; 81 } 82 /*----------------------------------------------------------------------------*/ 83 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn) 84 { 85 endpoint_t *instance = 86 list_get_instance(ep, endpoint_t, same_device_eps); 87 assert(instance); 88 if (instance->endpoint == epn) 89 instance->toggle = 0; 123 if (instance->address == target.address && 124 (instance->endpoint == target.endpoint || target.endpoint == 0)) 125 endpoint_toggle_set(instance, 0); 90 126 } 91 127 /**
Note:
See TracChangeset
for help on using the changeset viewer.