Changeset f527f58 in mainline for uspace/lib/usbhost/src/endpoint.c
- Timestamp:
- 2016-08-03T11:12:24Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 96ef672
- Parents:
- e657635
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/endpoint.c
re657635 rf527f58 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup libusbhost 29 30 * @{ … … 37 38 #include <assert.h> 38 39 #include <stdlib.h> 40 #include <atomic.h> 39 41 40 42 /** Allocate ad initialize endpoint_t structure. … … 55 57 endpoint_t *instance = malloc(sizeof(endpoint_t)); 56 58 if (instance) { 59 atomic_set(&instance->refcnt, 0); 57 60 instance->address = address; 58 61 instance->endpoint = endpoint; … … 83 86 { 84 87 assert(instance); 85 //TODO: Do something about waiting fibrils.86 88 assert(!instance->active); 87 89 assert(instance->hc_data.data == NULL); 88 90 free(instance); 91 } 92 93 void endpoint_add_ref(endpoint_t *instance) 94 { 95 atomic_inc(&instance->refcnt); 96 } 97 98 void endpoint_del_ref(endpoint_t *instance) 99 { 100 if (atomic_predec(&instance->refcnt) == 0) 101 endpoint_destroy(instance); 89 102 } 90 103 … … 122 135 { 123 136 assert(instance); 137 /* Add reference for active endpoint. */ 138 endpoint_add_ref(instance); 124 139 fibril_mutex_lock(&instance->guard); 125 140 while (instance->active) … … 139 154 fibril_mutex_unlock(&instance->guard); 140 155 fibril_condvar_signal(&instance->avail); 156 /* Drop reference for active endpoint. */ 157 endpoint_del_ref(instance); 141 158 } 142 159 … … 171 188 fibril_mutex_unlock(&instance->guard); 172 189 } 190 173 191 /** 174 192 * @}
Note:
See TracChangeset
for help on using the changeset viewer.