Changes in uspace/lib/usb/src/pipesio.c [d48fcc0:3954a63b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipesio.c
rd48fcc0 r3954a63b 49 49 #include <assert.h> 50 50 #include <usbhc_iface.h> 51 #include "pipepriv.h"52 51 53 52 /** Request an in transfer, no checking of input parameters. … … 79 78 } 80 79 81 /* Ensure serialization over the phone. */82 pipe_start_transaction(pipe);83 84 80 /* 85 81 * Make call identifying target USB device and type of transfer. … … 91 87 NULL); 92 88 if (opening_request == 0) { 93 pipe_end_transaction(pipe);94 89 return ENOMEM; 95 90 } … … 101 96 aid_t data_request = async_data_read(pipe->hc_phone, buffer, size, 102 97 &data_request_call); 103 104 /*105 * Since now on, someone else might access the backing phone106 * without breaking the transfer IPC protocol.107 */108 pipe_end_transaction(pipe);109 98 110 99 if (data_request == 0) { … … 157 146 158 147 if (buffer == NULL) { 159 return EINVAL;148 return EINVAL; 160 149 } 161 150 … … 164 153 } 165 154 155 if (!usb_pipe_is_session_started(pipe)) { 156 return EBADF; 157 } 158 166 159 if (pipe->direction != USB_DIRECTION_IN) { 167 160 return EBADF; … … 172 165 } 173 166 167 size_t act_size = 0; 174 168 int rc; 175 rc = pipe_add_ref(pipe);176 if (rc != EOK) {177 return rc;178 }179 180 181 size_t act_size = 0;182 169 183 170 rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size); 184 185 pipe_drop_ref(pipe);186 187 171 if (rc != EOK) { 188 172 return rc; … … 226 210 } 227 211 228 /* Ensure serialization over the phone. */229 pipe_start_transaction(pipe);230 231 212 /* 232 213 * Make call identifying target USB device and type of transfer. … … 238 219 NULL); 239 220 if (opening_request == 0) { 240 pipe_end_transaction(pipe);241 221 return ENOMEM; 242 222 } … … 246 226 */ 247 227 int rc = async_data_write_start(pipe->hc_phone, buffer, size); 248 249 /*250 * Since now on, someone else might access the backing phone251 * without breaking the transfer IPC protocol.252 */253 pipe_end_transaction(pipe);254 255 228 if (rc != EOK) { 256 229 async_wait_for(opening_request, NULL); … … 287 260 } 288 261 262 if (!usb_pipe_is_session_started(pipe)) { 263 return EBADF; 264 } 265 289 266 if (pipe->direction != USB_DIRECTION_OUT) { 290 267 return EBADF; … … 295 272 } 296 273 297 int rc; 298 299 rc = pipe_add_ref(pipe); 300 if (rc != EOK) { 301 return rc; 302 } 303 304 rc = usb_pipe_write_no_check(pipe, buffer, size); 305 306 pipe_drop_ref(pipe); 274 int rc = usb_pipe_write_no_check(pipe, buffer, size); 307 275 308 276 return rc; … … 325 293 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) 326 294 { 327 /* Ensure serialization over the phone. */328 pipe_start_transaction(pipe);329 330 295 /* 331 296 * Make call identifying target USB device and control transfer type. … … 346 311 setup_buffer, setup_buffer_size); 347 312 if (rc != EOK) { 348 pipe_end_transaction(pipe);349 313 async_wait_for(opening_request, NULL); 350 314 return rc; … … 358 322 data_buffer, data_buffer_size, 359 323 &data_request_call); 360 361 /*362 * Since now on, someone else might access the backing phone363 * without breaking the transfer IPC protocol.364 */365 pipe_end_transaction(pipe);366 367 368 324 if (data_request == 0) { 369 325 async_wait_for(opening_request, NULL); … … 423 379 } 424 380 381 if (!usb_pipe_is_session_started(pipe)) { 382 return EBADF; 383 } 384 425 385 if ((pipe->direction != USB_DIRECTION_BOTH) 426 386 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 428 388 } 429 389 430 int rc;431 432 rc = pipe_add_ref(pipe);433 if (rc != EOK) {434 return rc;435 }436 437 390 size_t act_size = 0; 438 rc = usb_pipe_control_read_no_check(pipe,391 int rc = usb_pipe_control_read_no_check(pipe, 439 392 setup_buffer, setup_buffer_size, 440 393 data_buffer, data_buffer_size, &act_size); 441 442 pipe_drop_ref(pipe);443 394 444 395 if (rc != EOK) { … … 467 418 void *data_buffer, size_t data_buffer_size) 468 419 { 469 /* Ensure serialization over the phone. */470 pipe_start_transaction(pipe);471 472 420 /* 473 421 * Make call identifying target USB device and control transfer type. … … 480 428 NULL); 481 429 if (opening_request == 0) { 482 pipe_end_transaction(pipe);483 430 return ENOMEM; 484 431 } … … 490 437 setup_buffer, setup_buffer_size); 491 438 if (rc != EOK) { 492 pipe_end_transaction(pipe);493 439 async_wait_for(opening_request, NULL); 494 440 return rc; … … 501 447 rc = async_data_write_start(pipe->hc_phone, 502 448 data_buffer, data_buffer_size); 503 504 /* All data sent, pipe can be released. */505 pipe_end_transaction(pipe);506 507 449 if (rc != EOK) { 508 450 async_wait_for(opening_request, NULL); 509 451 return rc; 510 452 } 511 } else {512 /* No data to send, we can release the pipe for others. */513 pipe_end_transaction(pipe);514 453 } 515 454 … … 552 491 } 553 492 493 if (!usb_pipe_is_session_started(pipe)) { 494 return EBADF; 495 } 496 554 497 if ((pipe->direction != USB_DIRECTION_BOTH) 555 498 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 557 500 } 558 501 559 int rc; 560 561 rc = pipe_add_ref(pipe); 562 if (rc != EOK) { 563 return rc; 564 } 565 566 rc = usb_pipe_control_write_no_check(pipe, 502 int rc = usb_pipe_control_write_no_check(pipe, 567 503 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 568 569 pipe_drop_ref(pipe);570 504 571 505 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.