Changeset d48fcc0 in mainline
- Timestamp:
- 2011-04-09T09:45:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e9ce696
- Parents:
- a546687
- Location:
- uspace/lib/usb
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/pipes.h
ra546687 rd48fcc0 60 60 * This endpoint must be bound with existing usb_device_connection_t 61 61 * (i.e. the wire to send data over). 62 * 63 * Locking order: if you want to lock both mutexes 64 * (@c guard and @c hc_phone_mutex), lock @c guard first. 65 * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex 66 * only. 62 67 */ 63 68 typedef struct { 69 /** Guard of the whole pipe. */ 70 fibril_mutex_t guard; 71 64 72 /** The connection used for sending the data. */ 65 73 usb_device_connection_t *wire; … … 79 87 /** Phone to the host controller. 80 88 * Negative when no session is active. 89 * It is an error to access this member without @c hc_phone_mutex 90 * being locked. 91 * If call over the phone is to be made, it must be preceeded by 92 * call to pipe_add_ref() [internal libusb function]. 81 93 */ 82 94 int hc_phone; -
uspace/lib/usb/src/pipepriv.c
ra546687 rd48fcc0 42 42 * @param pipe Pipe to be exclusively accessed. 43 43 */ 44 void pipe_ acquire(usb_pipe_t *pipe)44 void pipe_start_transaction(usb_pipe_t *pipe) 45 45 { 46 46 fibril_mutex_lock(&pipe->hc_phone_mutex); … … 51 51 * @param pipe Pipe to be released from exclusive usage. 52 52 */ 53 void pipe_end_transaction(usb_pipe_t *pipe) 54 { 55 fibril_mutex_unlock(&pipe->hc_phone_mutex); 56 } 57 58 /** Ensure exclusive access to the pipe as a whole. 59 * 60 * @param pipe Pipe to be exclusively accessed. 61 */ 62 void pipe_acquire(usb_pipe_t *pipe) 63 { 64 fibril_mutex_lock(&pipe->guard); 65 } 66 67 /** Terminate exclusive access to the pipe as a whole. 68 * 69 * @param pipe Pipe to be released from exclusive usage. 70 */ 53 71 void pipe_release(usb_pipe_t *pipe) 54 72 { 55 fibril_mutex_unlock(&pipe-> hc_phone_mutex);73 fibril_mutex_unlock(&pipe->guard); 56 74 } 57 75 … … 76 94 goto another_try; 77 95 } 96 /* 97 * No locking is needed, refcount is zero and whole pipe 98 * mutex is locked. 99 */ 78 100 pipe->hc_phone = phone; 79 101 } -
uspace/lib/usb/src/pipepriv.h
ra546687 rd48fcc0 41 41 void pipe_release(usb_pipe_t *); 42 42 43 void pipe_start_transaction(usb_pipe_t *); 44 void pipe_end_transaction(usb_pipe_t *); 45 43 46 int pipe_add_ref(usb_pipe_t *); 44 47 void pipe_drop_ref(usb_pipe_t *); -
uspace/lib/usb/src/pipesinit.c
ra546687 rd48fcc0 356 356 assert(connection); 357 357 358 fibril_mutex_initialize(&pipe->guard); 358 359 pipe->wire = connection; 359 360 pipe->hc_phone = -1; -
uspace/lib/usb/src/pipesio.c
ra546687 rd48fcc0 80 80 81 81 /* Ensure serialization over the phone. */ 82 pipe_ acquire(pipe);82 pipe_start_transaction(pipe); 83 83 84 84 /* … … 91 91 NULL); 92 92 if (opening_request == 0) { 93 pipe_ release(pipe);93 pipe_end_transaction(pipe); 94 94 return ENOMEM; 95 95 } … … 106 106 * without breaking the transfer IPC protocol. 107 107 */ 108 pipe_ release(pipe);108 pipe_end_transaction(pipe); 109 109 110 110 if (data_request == 0) { … … 227 227 228 228 /* Ensure serialization over the phone. */ 229 pipe_ acquire(pipe);229 pipe_start_transaction(pipe); 230 230 231 231 /* … … 238 238 NULL); 239 239 if (opening_request == 0) { 240 pipe_ release(pipe);240 pipe_end_transaction(pipe); 241 241 return ENOMEM; 242 242 } … … 251 251 * without breaking the transfer IPC protocol. 252 252 */ 253 pipe_ release(pipe);253 pipe_end_transaction(pipe); 254 254 255 255 if (rc != EOK) { … … 326 326 { 327 327 /* Ensure serialization over the phone. */ 328 pipe_ acquire(pipe);328 pipe_start_transaction(pipe); 329 329 330 330 /* … … 346 346 setup_buffer, setup_buffer_size); 347 347 if (rc != EOK) { 348 pipe_ release(pipe);348 pipe_end_transaction(pipe); 349 349 async_wait_for(opening_request, NULL); 350 350 return rc; … … 363 363 * without breaking the transfer IPC protocol. 364 364 */ 365 pipe_ release(pipe);365 pipe_end_transaction(pipe); 366 366 367 367 … … 468 468 { 469 469 /* Ensure serialization over the phone. */ 470 pipe_ acquire(pipe);470 pipe_start_transaction(pipe); 471 471 472 472 /* … … 480 480 NULL); 481 481 if (opening_request == 0) { 482 pipe_ release(pipe);482 pipe_end_transaction(pipe); 483 483 return ENOMEM; 484 484 } … … 490 490 setup_buffer, setup_buffer_size); 491 491 if (rc != EOK) { 492 pipe_ release(pipe);492 pipe_end_transaction(pipe); 493 493 async_wait_for(opening_request, NULL); 494 494 return rc; … … 503 503 504 504 /* All data sent, pipe can be released. */ 505 pipe_ release(pipe);505 pipe_end_transaction(pipe); 506 506 507 507 if (rc != EOK) { … … 511 511 } else { 512 512 /* No data to send, we can release the pipe for others. */ 513 pipe_ release(pipe);513 pipe_end_transaction(pipe); 514 514 } 515 515
Note:
See TracChangeset
for help on using the changeset viewer.