Changes in uspace/lib/usb/src/pipesio.c [77223f8:3954a63b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipesio.c
r77223f8 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. 86 82 */ 87 aid_t opening_request = async_send_ 3(pipe->hc_phone,83 aid_t opening_request = async_send_4(pipe->hc_phone, 88 84 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 89 85 pipe->wire->address, pipe->endpoint_no, 86 pipe->max_packet_size, 90 87 NULL); 91 88 if (opening_request == 0) { 92 pipe_end_transaction(pipe);93 89 return ENOMEM; 94 90 } … … 100 96 aid_t data_request = async_data_read(pipe->hc_phone, buffer, size, 101 97 &data_request_call); 102 103 /*104 * Since now on, someone else might access the backing phone105 * without breaking the transfer IPC protocol.106 */107 pipe_end_transaction(pipe);108 98 109 99 if (data_request == 0) { … … 156 146 157 147 if (buffer == NULL) { 158 return EINVAL;148 return EINVAL; 159 149 } 160 150 … … 163 153 } 164 154 155 if (!usb_pipe_is_session_started(pipe)) { 156 return EBADF; 157 } 158 165 159 if (pipe->direction != USB_DIRECTION_IN) { 166 160 return EBADF; … … 171 165 } 172 166 167 size_t act_size = 0; 173 168 int rc; 174 rc = pipe_add_ref(pipe);175 if (rc != EOK) {176 return rc;177 }178 179 180 size_t act_size = 0;181 169 182 170 rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size); 183 184 pipe_drop_ref(pipe);185 186 171 if (rc != EOK) { 187 172 return rc; … … 225 210 } 226 211 227 /* Ensure serialization over the phone. */228 pipe_start_transaction(pipe);229 230 212 /* 231 213 * Make call identifying target USB device and type of transfer. 232 214 */ 233 aid_t opening_request = async_send_ 3(pipe->hc_phone,215 aid_t opening_request = async_send_4(pipe->hc_phone, 234 216 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 235 217 pipe->wire->address, pipe->endpoint_no, 218 pipe->max_packet_size, 236 219 NULL); 237 220 if (opening_request == 0) { 238 pipe_end_transaction(pipe);239 221 return ENOMEM; 240 222 } … … 244 226 */ 245 227 int rc = async_data_write_start(pipe->hc_phone, buffer, size); 246 247 /*248 * Since now on, someone else might access the backing phone249 * without breaking the transfer IPC protocol.250 */251 pipe_end_transaction(pipe);252 253 228 if (rc != EOK) { 254 229 async_wait_for(opening_request, NULL); … … 285 260 } 286 261 262 if (!usb_pipe_is_session_started(pipe)) { 263 return EBADF; 264 } 265 287 266 if (pipe->direction != USB_DIRECTION_OUT) { 288 267 return EBADF; … … 293 272 } 294 273 295 int rc; 296 297 rc = pipe_add_ref(pipe); 298 if (rc != EOK) { 299 return rc; 300 } 301 302 rc = usb_pipe_write_no_check(pipe, buffer, size); 303 304 pipe_drop_ref(pipe); 274 int rc = usb_pipe_write_no_check(pipe, buffer, size); 305 275 306 276 return rc; … … 323 293 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) 324 294 { 325 /* Ensure serialization over the phone. */326 pipe_start_transaction(pipe);327 328 295 /* 329 296 * Make call identifying target USB device and control transfer type. 330 297 */ 331 aid_t opening_request = async_send_ 3(pipe->hc_phone,298 aid_t opening_request = async_send_4(pipe->hc_phone, 332 299 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ, 333 300 pipe->wire->address, pipe->endpoint_no, 301 pipe->max_packet_size, 334 302 NULL); 335 303 if (opening_request == 0) { … … 343 311 setup_buffer, setup_buffer_size); 344 312 if (rc != EOK) { 345 pipe_end_transaction(pipe);346 313 async_wait_for(opening_request, NULL); 347 314 return rc; … … 355 322 data_buffer, data_buffer_size, 356 323 &data_request_call); 357 358 /*359 * Since now on, someone else might access the backing phone360 * without breaking the transfer IPC protocol.361 */362 pipe_end_transaction(pipe);363 364 365 324 if (data_request == 0) { 366 325 async_wait_for(opening_request, NULL); … … 420 379 } 421 380 381 if (!usb_pipe_is_session_started(pipe)) { 382 return EBADF; 383 } 384 422 385 if ((pipe->direction != USB_DIRECTION_BOTH) 423 386 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 425 388 } 426 389 427 int rc;428 429 rc = pipe_add_ref(pipe);430 if (rc != EOK) {431 return rc;432 }433 434 390 size_t act_size = 0; 435 rc = usb_pipe_control_read_no_check(pipe,391 int rc = usb_pipe_control_read_no_check(pipe, 436 392 setup_buffer, setup_buffer_size, 437 393 data_buffer, data_buffer_size, &act_size); 438 439 pipe_drop_ref(pipe);440 394 441 395 if (rc != EOK) { … … 464 418 void *data_buffer, size_t data_buffer_size) 465 419 { 466 /* Ensure serialization over the phone. */467 pipe_start_transaction(pipe);468 469 420 /* 470 421 * Make call identifying target USB device and control transfer type. 471 422 */ 472 aid_t opening_request = async_send_ 4(pipe->hc_phone,423 aid_t opening_request = async_send_5(pipe->hc_phone, 473 424 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE, 474 425 pipe->wire->address, pipe->endpoint_no, 475 426 data_buffer_size, 427 pipe->max_packet_size, 476 428 NULL); 477 429 if (opening_request == 0) { 478 pipe_end_transaction(pipe);479 430 return ENOMEM; 480 431 } … … 486 437 setup_buffer, setup_buffer_size); 487 438 if (rc != EOK) { 488 pipe_end_transaction(pipe);489 439 async_wait_for(opening_request, NULL); 490 440 return rc; … … 497 447 rc = async_data_write_start(pipe->hc_phone, 498 448 data_buffer, data_buffer_size); 499 500 /* All data sent, pipe can be released. */501 pipe_end_transaction(pipe);502 503 449 if (rc != EOK) { 504 450 async_wait_for(opening_request, NULL); 505 451 return rc; 506 452 } 507 } else {508 /* No data to send, we can release the pipe for others. */509 pipe_end_transaction(pipe);510 453 } 511 454 … … 548 491 } 549 492 493 if (!usb_pipe_is_session_started(pipe)) { 494 return EBADF; 495 } 496 550 497 if ((pipe->direction != USB_DIRECTION_BOTH) 551 498 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 553 500 } 554 501 555 int rc; 556 557 rc = pipe_add_ref(pipe); 558 if (rc != EOK) { 559 return rc; 560 } 561 562 rc = usb_pipe_control_write_no_check(pipe, 502 int rc = usb_pipe_control_write_no_check(pipe, 563 503 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 564 565 pipe_drop_ref(pipe);566 504 567 505 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.