Changes in uspace/lib/usb/src/host/endpoint.c [545764b:506d330] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/endpoint.c
r545764b r506d330 34 34 */ 35 35 36 #include <assert.h>37 36 #include <errno.h> 38 37 #include <usb/host/endpoint.h> … … 50 49 instance->max_packet_size = max_packet_size; 51 50 instance->toggle = 0; 52 instance->active = false; 53 fibril_mutex_initialize(&instance->guard); 54 fibril_condvar_initialize(&instance->avail); 55 endpoint_clear_hc_data(instance); 51 link_initialize(&instance->same_device_eps); 56 52 return EOK; 57 53 } … … 60 56 { 61 57 assert(instance); 62 assert(!instance->active);58 list_remove(&instance->same_device_eps); 63 59 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);100 60 } 101 61 /*----------------------------------------------------------------------------*/ … … 103 63 { 104 64 assert(instance); 105 if (instance->hc_data.toggle_get)106 instance->toggle =107 instance->hc_data.toggle_get(instance->hc_data.data);108 65 return (int)instance->toggle; 109 66 } … … 113 70 assert(instance); 114 71 assert(toggle == 0 || toggle == 1); 115 if (instance->hc_data.toggle_set)116 instance->hc_data.toggle_set(instance->hc_data.data, toggle);117 72 instance->toggle = toggle; 118 73 } 119 74 /*----------------------------------------------------------------------------*/ 120 void endpoint_toggle_reset _filtered(endpoint_t *instance, usb_target_t target)75 void endpoint_toggle_reset(link_t *ep) 121 76 { 77 endpoint_t *instance = 78 list_get_instance(ep, endpoint_t, same_device_eps); 122 79 assert(instance); 123 if (instance->address == target.address && 124 (instance->endpoint == target.endpoint || target.endpoint == 0)) 125 endpoint_toggle_set(instance, 0); 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; 126 90 } 127 91 /**
Note:
See TracChangeset
for help on using the changeset viewer.