Changeset 26e7d6d in mainline for uspace/lib/usbhost/src/endpoint.c
- Timestamp:
- 2011-09-19T16:31:00Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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
-
uspace/lib/usbhost/src/endpoint.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/endpoint.c
r3842a955 r26e7d6d 39 39 #include <usb/host/endpoint.h> 40 40 41 int endpoint_init(endpoint_t *instance, usb_address_t address,42 usb_ endpoint_t endpoint, usb_direction_t direction,43 usb_transfer_type_t type, usb_speed_t speed,size_t max_packet_size)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) 44 44 { 45 assert(instance); 46 instance->address = address; 47 instance->endpoint = endpoint; 48 instance->direction = direction; 49 instance->transfer_type = type; 50 instance->speed = speed; 51 instance->max_packet_size = max_packet_size; 52 instance->toggle = 0; 53 instance->active = false; 54 fibril_mutex_initialize(&instance->guard); 55 fibril_condvar_initialize(&instance->avail); 56 endpoint_clear_hc_data(instance); 57 return EOK; 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; 58 64 } 59 65 /*----------------------------------------------------------------------------*/ … … 62 68 assert(instance); 63 69 assert(!instance->active); 70 if (instance->hc_data.data) { 71 assert(instance->destroy_hook); 72 instance->destroy_hook(instance); 73 } 64 74 free(instance); 65 75 } 66 76 /*----------------------------------------------------------------------------*/ 67 77 void endpoint_set_hc_data(endpoint_t *instance, 68 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 78 void *data, void (*destroy_hook)(endpoint_t *), 79 int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 69 80 { 70 81 assert(instance); 82 instance->destroy_hook = destroy_hook; 71 83 instance->hc_data.data = data; 72 84 instance->hc_data.toggle_get = toggle_get; … … 77 89 { 78 90 assert(instance); 91 instance->destroy_hook = NULL; 79 92 instance->hc_data.data = NULL; 80 93 instance->hc_data.toggle_get = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
