Changes in uspace/lib/usbhost/src/endpoint.c [563d9d0a:3e4f2e0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/endpoint.c
r563d9d0a r3e4f2e0 35 35 36 36 #include <assert.h> 37 #include <stdlib.h>38 37 #include <errno.h> 39 38 #include <usb/host/endpoint.h> 40 39 41 endpoint_t * endpoint_get(usb_address_t address, usb_endpoint_t endpoint,42 usb_ direction_t direction, usb_transfer_type_t type, usb_speed_t speed,43 size_t max_packet_size)40 int endpoint_init(endpoint_t *instance, usb_address_t address, 41 usb_endpoint_t endpoint, usb_direction_t direction, 42 usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size) 44 43 { 45 endpoint_t *instance = malloc(sizeof(endpoint_t)); 46 if (instance) { 47 instance->address = address; 48 instance->endpoint = endpoint; 49 instance->direction = direction; 50 instance->transfer_type = type; 51 instance->speed = speed; 52 instance->max_packet_size = max_packet_size; 53 instance->toggle = 0; 54 instance->active = false; 55 instance->destroy_hook = NULL; 56 instance->hc_data.data = NULL; 57 instance->hc_data.toggle_get = NULL; 58 instance->hc_data.toggle_set = NULL; 59 fibril_mutex_initialize(&instance->guard); 60 fibril_condvar_initialize(&instance->avail); 61 endpoint_clear_hc_data(instance); 62 } 63 return instance; 44 assert(instance); 45 instance->address = address; 46 instance->endpoint = endpoint; 47 instance->direction = direction; 48 instance->transfer_type = type; 49 instance->speed = speed; 50 instance->max_packet_size = max_packet_size; 51 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); 56 return EOK; 64 57 } 65 58 /*----------------------------------------------------------------------------*/ … … 68 61 assert(instance); 69 62 assert(!instance->active); 70 if (instance->hc_data.data) {71 assert(instance->destroy_hook);72 instance->destroy_hook(instance);73 }74 63 free(instance); 75 64 } 76 65 /*----------------------------------------------------------------------------*/ 77 66 void endpoint_set_hc_data(endpoint_t *instance, 78 void *data, void (*destroy_hook)(endpoint_t *), 79 int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 67 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 80 68 { 81 69 assert(instance); 82 instance->destroy_hook = destroy_hook;83 70 instance->hc_data.data = data; 84 71 instance->hc_data.toggle_get = toggle_get; … … 89 76 { 90 77 assert(instance); 91 instance->destroy_hook = NULL;92 78 instance->hc_data.data = NULL; 93 79 instance->hc_data.toggle_get = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.