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