Changeset 651b352 in mainline for uspace/lib
- Timestamp:
- 2011-04-13T15:00:43Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8b4ce802
- Parents:
- 4deca9b (diff), d6522dd (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. - Location:
- uspace/lib/usb
- Files:
-
- 4 edited
-
include/usb/host/batch.h (modified) (3 diffs)
-
include/usb/host/endpoint.h (modified) (2 diffs)
-
src/host/batch.c (modified) (4 diffs)
-
src/host/endpoint.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/host/batch.h
r4deca9b r651b352 58 58 ddf_fun_t *fun; 59 59 void *private_data; 60 void (*private_data_dtor)(void *p_data); 60 61 }; 61 62 62 63 void usb_transfer_batch_init( 63 64 usb_transfer_batch_t *instance, 64 endpoint_t *ep,65 endpoint_t *ep, 65 66 char *buffer, 66 67 char *data_buffer, … … 72 73 void *arg, 73 74 ddf_fun_t *fun, 74 void *private_data 75 void *private_data, 76 void (*private_data_dtor)(void *p_data) 75 77 ); 76 78 77 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) 78 { 79 assert(l); 80 return list_get_instance(l, usb_transfer_batch_t, link); 81 } 82 83 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 84 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 79 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance); 80 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance); 85 81 void usb_transfer_batch_finish(usb_transfer_batch_t *instance); 82 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance); 86 83 87 84 static inline void usb_transfer_batch_finish_error( … … 93 90 } 94 91 92 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) 93 { 94 assert(l); 95 return list_get_instance(l, usb_transfer_batch_t, link); 96 } 97 95 98 #endif 96 99 /** -
uspace/lib/usb/include/usb/host/endpoint.h
r4deca9b r651b352 54 54 fibril_condvar_t avail; 55 55 volatile bool active; 56 struct { 57 void *data; 58 int (*toggle_get)(void *); 59 void (*toggle_set)(void *, int); 60 } hc_data; 56 61 } endpoint_t; 57 62 … … 61 66 62 67 void endpoint_destroy(endpoint_t *instance); 68 69 void endpoint_set_hc_data(endpoint_t *instance, 70 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)); 71 72 void endpoint_clear_hc_data(endpoint_t *instance); 63 73 64 74 void endpoint_use(endpoint_t *instance); -
uspace/lib/usb/src/host/batch.c
r4deca9b r651b352 39 39 #include <usb/host/batch.h> 40 40 41 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 42 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 43 41 44 void usb_transfer_batch_init( 42 45 usb_transfer_batch_t *instance, 43 endpoint_t *ep,46 endpoint_t *ep, 44 47 char *buffer, 45 48 char *data_buffer, … … 51 54 void *arg, 52 55 ddf_fun_t *fun, 53 void *private_data 56 void *private_data, 57 void (*private_data_dtor)(void *p_data) 54 58 ) 55 59 { … … 67 71 instance->fun = fun; 68 72 instance->private_data = private_data; 73 instance->private_data_dtor = private_data_dtor; 69 74 instance->transfered_size = 0; 70 75 instance->next_step = NULL; 71 76 instance->error = EOK; 72 77 endpoint_use(instance->ep); 78 } 79 /*----------------------------------------------------------------------------*/ 80 /** Helper function, calls callback and correctly destroys batch structure. 81 * 82 * @param[in] instance Batch structure to use. 83 */ 84 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance) 85 { 86 assert(instance); 87 usb_transfer_batch_call_in(instance); 88 usb_transfer_batch_dispose(instance); 89 } 90 /*----------------------------------------------------------------------------*/ 91 /** Helper function calls callback and correctly destroys batch structure. 92 * 93 * @param[in] instance Batch structure to use. 94 */ 95 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance) 96 { 97 assert(instance); 98 usb_transfer_batch_call_out(instance); 99 usb_transfer_batch_dispose(instance); 73 100 } 74 101 /*----------------------------------------------------------------------------*/ … … 129 156 instance->error, instance->arg); 130 157 } 158 /*----------------------------------------------------------------------------*/ 159 /** Correctly dispose all used data structures. 160 * 161 * @param[in] instance Batch structure to use. 162 */ 163 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance) 164 { 165 assert(instance); 166 usb_log_debug("Batch(%p) disposing.\n", instance); 167 if (instance->private_data) { 168 assert(instance->private_data_dtor); 169 instance->private_data_dtor(instance->private_data); 170 } 171 free(instance); 172 } 131 173 /** 132 174 * @} -
uspace/lib/usb/src/host/endpoint.c
r4deca9b r651b352 63 63 } 64 64 /*----------------------------------------------------------------------------*/ 65 void endpoint_set_hc_data(endpoint_t *instance, 66 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 67 { 68 assert(instance); 69 instance->hc_data.data = data; 70 instance->hc_data.toggle_get = toggle_get; 71 instance->hc_data.toggle_set = toggle_set; 72 } 73 /*----------------------------------------------------------------------------*/ 74 void endpoint_clear_hc_data(endpoint_t *instance) 75 { 76 assert(instance); 77 instance->hc_data.data = NULL; 78 instance->hc_data.toggle_get = NULL; 79 instance->hc_data.toggle_set = NULL; 80 } 81 /*----------------------------------------------------------------------------*/ 65 82 void endpoint_use(endpoint_t *instance) 66 83 { … … 85 102 { 86 103 assert(instance); 104 if (instance->hc_data.toggle_get) 105 instance->toggle = 106 instance->hc_data.toggle_get(instance->hc_data.data); 87 107 return (int)instance->toggle; 88 108 } … … 92 112 assert(instance); 93 113 assert(toggle == 0 || toggle == 1); 114 if (instance->hc_data.toggle_set) 115 instance->hc_data.toggle_set(instance->hc_data.data, toggle); 94 116 instance->toggle = toggle; 95 117 }
Note:
See TracChangeset
for help on using the changeset viewer.
