Changeset d5ac90f in mainline
- Timestamp:
- 2011-04-09T08:27:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a546687
- Parents:
- 61727bf
- Location:
- uspace/lib/usb
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/pipes.h
r61727bf rd5ac90f 42 42 #include <ipc/devman.h> 43 43 #include <ddf/driver.h> 44 #include <fibril_synch.h> 44 45 45 46 /** Abstraction of a physical connection to the device. … … 80 81 */ 81 82 int hc_phone; 83 84 /** Guard for serialization of requests over the phone. */ 85 fibril_mutex_t hc_phone_mutex; 82 86 } usb_pipe_t; 83 87 -
uspace/lib/usb/src/pipesinit.c
r61727bf rd5ac90f 358 358 pipe->wire = connection; 359 359 pipe->hc_phone = -1; 360 fibril_mutex_initialize(&pipe->hc_phone_mutex); 360 361 pipe->endpoint_no = endpoint_no; 361 362 pipe->transfer_type = transfer_type; -
uspace/lib/usb/src/pipesio.c
r61727bf rd5ac90f 50 50 #include <usbhc_iface.h> 51 51 52 /** Ensure exclusive access to the IPC phone of given pipe. 53 * 54 * @param pipe Pipe to be exclusively accessed. 55 */ 56 static void pipe_acquire(usb_pipe_t *pipe) 57 { 58 fibril_mutex_lock(&pipe->hc_phone_mutex); 59 } 60 61 /** Terminate exclusive access to the IPC phone of given pipe. 62 * 63 * @param pipe Pipe to be released from exclusive usage. 64 */ 65 static void pipe_release(usb_pipe_t *pipe) 66 { 67 fibril_mutex_unlock(&pipe->hc_phone_mutex); 68 } 69 70 71 52 72 /** Request an in transfer, no checking of input parameters. 53 73 * … … 78 98 } 79 99 100 /* Ensure serialization over the phone. */ 101 pipe_acquire(pipe); 102 80 103 /* 81 104 * Make call identifying target USB device and type of transfer. … … 87 110 NULL); 88 111 if (opening_request == 0) { 112 pipe_release(pipe); 89 113 return ENOMEM; 90 114 } … … 96 120 aid_t data_request = async_data_read(pipe->hc_phone, buffer, size, 97 121 &data_request_call); 122 123 /* 124 * Since now on, someone else might access the backing phone 125 * without breaking the transfer IPC protocol. 126 */ 127 pipe_release(pipe); 98 128 99 129 if (data_request == 0) { … … 210 240 } 211 241 242 /* Ensure serialization over the phone. */ 243 pipe_acquire(pipe); 244 212 245 /* 213 246 * Make call identifying target USB device and type of transfer. … … 219 252 NULL); 220 253 if (opening_request == 0) { 254 pipe_release(pipe); 221 255 return ENOMEM; 222 256 } … … 226 260 */ 227 261 int rc = async_data_write_start(pipe->hc_phone, buffer, size); 262 263 /* 264 * Since now on, someone else might access the backing phone 265 * without breaking the transfer IPC protocol. 266 */ 267 pipe_release(pipe); 268 228 269 if (rc != EOK) { 229 270 async_wait_for(opening_request, NULL); … … 293 334 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) 294 335 { 336 /* Ensure serialization over the phone. */ 337 pipe_acquire(pipe); 338 295 339 /* 296 340 * Make call identifying target USB device and control transfer type. … … 311 355 setup_buffer, setup_buffer_size); 312 356 if (rc != EOK) { 357 pipe_release(pipe); 313 358 async_wait_for(opening_request, NULL); 314 359 return rc; … … 322 367 data_buffer, data_buffer_size, 323 368 &data_request_call); 369 370 /* 371 * Since now on, someone else might access the backing phone 372 * without breaking the transfer IPC protocol. 373 */ 374 pipe_release(pipe); 375 376 324 377 if (data_request == 0) { 325 378 async_wait_for(opening_request, NULL); … … 418 471 void *data_buffer, size_t data_buffer_size) 419 472 { 473 /* Ensure serialization over the phone. */ 474 pipe_acquire(pipe); 475 420 476 /* 421 477 * Make call identifying target USB device and control transfer type. … … 428 484 NULL); 429 485 if (opening_request == 0) { 486 pipe_release(pipe); 430 487 return ENOMEM; 431 488 } … … 437 494 setup_buffer, setup_buffer_size); 438 495 if (rc != EOK) { 496 pipe_release(pipe); 439 497 async_wait_for(opening_request, NULL); 440 498 return rc; … … 447 505 rc = async_data_write_start(pipe->hc_phone, 448 506 data_buffer, data_buffer_size); 507 508 /* All data sent, pipe can be released. */ 509 pipe_release(pipe); 510 449 511 if (rc != EOK) { 450 512 async_wait_for(opening_request, NULL); 451 513 return rc; 452 514 } 515 } else { 516 /* No data to send, we can release the pipe for others. */ 517 pipe_release(pipe); 453 518 } 454 519
Note:
See TracChangeset
for help on using the changeset viewer.