Changeset 85c47729 in mainline
- Timestamp:
- 2011-04-08T13:25:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 61727bf
- Parents:
- 8b74997f (diff), 4b39af4 (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
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/root_hub.c
r8b74997f r85c47729 249 249 opResult = EINVAL; 250 250 } 251 usb_transfer_batch_finish (request, opResult);251 usb_transfer_batch_finish_error(request, opResult); 252 252 return EOK; 253 253 } … … 863 863 } 864 864 865 866 867 868 865 /** 869 866 * @} -
uspace/drv/uhci-hcd/hc.c
r8b74997f r85c47729 332 332 instance->transfers[batch->speed][batch->transfer_type]; 333 333 assert(list); 334 if (batch->transfer_type == USB_TRANSFER_CONTROL) {335 usb_device_keeper_use_control(336 &instance->manager, batch->target);337 }338 334 transfer_list_add_batch(list, batch); 339 335 … … 373 369 usb_transfer_batch_t *batch = 374 370 list_get_instance(item, usb_transfer_batch_t, link); 375 switch (batch->transfer_type) 376 { 377 case USB_TRANSFER_CONTROL: 378 usb_device_keeper_release_control( 379 &instance->manager, batch->target); 380 break; 381 case USB_TRANSFER_INTERRUPT: 382 case USB_TRANSFER_ISOCHRONOUS: { 383 /* 384 int ret = bandwidth_free(&instance->bandwidth, 385 batch->target.address, 386 batch->target.endpoint, 387 batch->direction); 388 if (ret != EOK) 389 usb_log_warning("Failed(%d) to free " 390 "reserved bw: %s.\n", ret, 391 str_error(ret)); 392 */ 393 } 394 default: 395 break; 396 } 397 batch->next_step(batch); 371 usb_transfer_batch_finish(batch); 398 372 } 399 373 } -
uspace/drv/uhci-hcd/transfer_list.c
r8b74997f r85c47729 132 132 } 133 133 /*----------------------------------------------------------------------------*/ 134 /** Check list for finished batches. 135 * 136 * @param[in] instance List to use. 137 * @return Error code 138 * 139 * Creates a local list of finished batches and calls next_step on each and 140 * every one. This is safer because next_step may theoretically access 141 * this transfer list leading to the deadlock if its done inline. 134 /** Create list for finished batches. 135 * 136 * @param[in] instance List to use. 137 * @param[in] done list to fill 142 138 */ 143 139 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done) … … 161 157 } 162 158 fibril_mutex_unlock(&instance->guard); 163 164 159 } 165 160 /*----------------------------------------------------------------------------*/ … … 176 171 list_get_instance(current, usb_transfer_batch_t, link); 177 172 transfer_list_remove_batch(instance, batch); 178 usb_transfer_batch_finish (batch, EIO);173 usb_transfer_batch_finish_error(batch, EIO); 179 174 } 180 175 fibril_mutex_unlock(&instance->guard); -
uspace/lib/usb/include/usb/host/batch.h
r8b74997f r85c47729 92 92 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 93 93 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error); 94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance); 95 96 static inline void usb_transfer_batch_finish_error( 97 usb_transfer_batch_t *instance, int error) 98 { 99 assert(instance); 100 instance->error = error; 101 usb_transfer_batch_finish(instance); 102 } 95 103 96 104 #endif -
uspace/lib/usb/include/usb/host/device_keeper.h
r8b74997f r85c47729 96 96 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 97 97 usb_address_t address); 98 99 void usb_device_keeper_use_control(usb_device_keeper_t *instance,100 usb_target_t target);101 102 void usb_device_keeper_release_control(usb_device_keeper_t *instance,103 usb_target_t target);104 105 98 #endif 106 99 /** -
uspace/lib/usb/include/usb/host/endpoint.h
r8b74997f r85c47729 39 39 #include <bool.h> 40 40 #include <adt/list.h> 41 #include <fibril_synch.h> 42 41 43 #include <usb/usb.h> 42 44 … … 48 50 usb_speed_t speed; 49 51 size_t max_packet_size; 50 bool active;51 52 unsigned toggle:1; 53 fibril_mutex_t guard; 54 fibril_condvar_t avail; 55 volatile bool active; 52 56 link_t same_device_eps; 53 57 } endpoint_t; … … 58 62 59 63 void endpoint_destroy(endpoint_t *instance); 64 65 void endpoint_use(endpoint_t *instance); 66 67 void endpoint_release(endpoint_t *instance); 60 68 61 69 int endpoint_toggle_get(endpoint_t *instance); -
uspace/lib/usb/src/host/batch.c
r8b74997f r85c47729 79 79 instance->error = EOK; 80 80 instance->ep = ep; 81 endpoint_use(instance->ep); 81 82 } 82 83 /*----------------------------------------------------------------------------*/ … … 86 87 * 87 88 */ 88 void usb_transfer_batch_finish(usb_transfer_batch_t *instance , int error)89 void usb_transfer_batch_finish(usb_transfer_batch_t *instance) 89 90 { 90 91 assert(instance); 91 instance->error = error; 92 assert(instance->ep); 93 endpoint_release(instance->ep); 92 94 instance->next_step(instance); 93 95 } -
uspace/lib/usb/src/host/device_keeper.c
r8b74997f r85c47729 264 264 return instance->devices[address].speed; 265 265 } 266 /*----------------------------------------------------------------------------*/267 void usb_device_keeper_use_control(268 usb_device_keeper_t *instance, usb_target_t target)269 {270 assert(instance);271 const uint16_t ep = 1 << target.endpoint;272 fibril_mutex_lock(&instance->guard);273 while (instance->devices[target.address].control_used & ep) {274 fibril_condvar_wait(&instance->change, &instance->guard);275 }276 instance->devices[target.address].control_used |= ep;277 fibril_mutex_unlock(&instance->guard);278 }279 /*----------------------------------------------------------------------------*/280 void usb_device_keeper_release_control(281 usb_device_keeper_t *instance, usb_target_t target)282 {283 assert(instance);284 const uint16_t ep = 1 << target.endpoint;285 fibril_mutex_lock(&instance->guard);286 assert((instance->devices[target.address].control_used & ep) != 0);287 instance->devices[target.address].control_used &= ~ep;288 fibril_mutex_unlock(&instance->guard);289 fibril_condvar_signal(&instance->change);290 }291 266 /** 292 267 * @} -
uspace/lib/usb/src/host/endpoint.c
r8b74997f r85c47729 34 34 */ 35 35 36 #include <assert.h> 36 37 #include <errno.h> 37 38 #include <usb/host/endpoint.h> … … 49 50 instance->max_packet_size = max_packet_size; 50 51 instance->toggle = 0; 52 instance->active = false; 53 fibril_mutex_initialize(&instance->guard); 54 fibril_condvar_initialize(&instance->avail); 51 55 link_initialize(&instance->same_device_eps); 52 56 return EOK; … … 56 60 { 57 61 assert(instance); 62 assert(!instance->active); 58 63 list_remove(&instance->same_device_eps); 59 64 free(instance); 65 } 66 /*----------------------------------------------------------------------------*/ 67 void endpoint_use(endpoint_t *instance) 68 { 69 assert(instance); 70 fibril_mutex_lock(&instance->guard); 71 while (instance->active) 72 fibril_condvar_wait(&instance->avail, &instance->guard); 73 instance->active = true; 74 fibril_mutex_unlock(&instance->guard); 75 } 76 /*----------------------------------------------------------------------------*/ 77 void endpoint_release(endpoint_t *instance) 78 { 79 assert(instance); 80 fibril_mutex_lock(&instance->guard); 81 instance->active = false; 82 fibril_mutex_unlock(&instance->guard); 83 fibril_condvar_signal(&instance->avail); 60 84 } 61 85 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.