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