Changes in uspace/lib/usb/src/pipesio.c [fa0f53b:3954a63b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipesio.c
rfa0f53b r3954a63b 49 49 #include <assert.h> 50 50 #include <usbhc_iface.h> 51 #include <usb/request.h>52 #include "pipepriv.h"53 51 54 52 /** Request an in transfer, no checking of input parameters. … … 80 78 } 81 79 82 /* Ensure serialization over the phone. */83 pipe_start_transaction(pipe);84 85 80 /* 86 81 * Make call identifying target USB device and type of transfer. 87 82 */ 88 aid_t opening_request = async_send_ 3(pipe->hc_phone,83 aid_t opening_request = async_send_4(pipe->hc_phone, 89 84 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 90 85 pipe->wire->address, pipe->endpoint_no, 86 pipe->max_packet_size, 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. 233 214 */ 234 aid_t opening_request = async_send_ 3(pipe->hc_phone,215 aid_t opening_request = async_send_4(pipe->hc_phone, 235 216 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 236 217 pipe->wire->address, pipe->endpoint_no, 218 pipe->max_packet_size, 237 219 NULL); 238 220 if (opening_request == 0) { 239 pipe_end_transaction(pipe);240 221 return ENOMEM; 241 222 } … … 245 226 */ 246 227 int rc = async_data_write_start(pipe->hc_phone, buffer, size); 247 248 /*249 * Since now on, someone else might access the backing phone250 * without breaking the transfer IPC protocol.251 */252 pipe_end_transaction(pipe);253 254 228 if (rc != EOK) { 255 229 async_wait_for(opening_request, NULL); … … 286 260 } 287 261 262 if (!usb_pipe_is_session_started(pipe)) { 263 return EBADF; 264 } 265 288 266 if (pipe->direction != USB_DIRECTION_OUT) { 289 267 return EBADF; … … 294 272 } 295 273 296 int rc; 297 298 rc = pipe_add_ref(pipe); 299 if (rc != EOK) { 300 return rc; 301 } 302 303 rc = usb_pipe_write_no_check(pipe, buffer, size); 304 305 pipe_drop_ref(pipe); 274 int rc = usb_pipe_write_no_check(pipe, buffer, size); 306 275 307 276 return rc; 308 }309 310 /** Try to clear endpoint halt of default control pipe.311 *312 * @param pipe Pipe for control endpoint zero.313 */314 static void clear_self_endpoint_halt(usb_pipe_t *pipe)315 {316 assert(pipe != NULL);317 318 if (!pipe->auto_reset_halt || (pipe->endpoint_no != 0)) {319 return;320 }321 322 323 /* Prevent indefinite recursion. */324 pipe->auto_reset_halt = false;325 usb_request_clear_endpoint_halt(pipe, 0);326 pipe->auto_reset_halt = true;327 277 } 328 278 … … 343 293 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) 344 294 { 345 /* Ensure serialization over the phone. */346 pipe_start_transaction(pipe);347 348 295 /* 349 296 * Make call identifying target USB device and control transfer type. 350 297 */ 351 aid_t opening_request = async_send_ 3(pipe->hc_phone,298 aid_t opening_request = async_send_4(pipe->hc_phone, 352 299 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ, 353 300 pipe->wire->address, pipe->endpoint_no, 301 pipe->max_packet_size, 354 302 NULL); 355 303 if (opening_request == 0) { … … 363 311 setup_buffer, setup_buffer_size); 364 312 if (rc != EOK) { 365 pipe_end_transaction(pipe);366 313 async_wait_for(opening_request, NULL); 367 314 return rc; … … 375 322 data_buffer, data_buffer_size, 376 323 &data_request_call); 377 378 /*379 * Since now on, someone else might access the backing phone380 * without breaking the transfer IPC protocol.381 */382 pipe_end_transaction(pipe);383 384 385 324 if (data_request == 0) { 386 325 async_wait_for(opening_request, NULL); … … 440 379 } 441 380 381 if (!usb_pipe_is_session_started(pipe)) { 382 return EBADF; 383 } 384 442 385 if ((pipe->direction != USB_DIRECTION_BOTH) 443 386 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 445 388 } 446 389 447 int rc;448 449 rc = pipe_add_ref(pipe);450 if (rc != EOK) {451 return rc;452 }453 454 390 size_t act_size = 0; 455 rc = usb_pipe_control_read_no_check(pipe,391 int rc = usb_pipe_control_read_no_check(pipe, 456 392 setup_buffer, setup_buffer_size, 457 393 data_buffer, data_buffer_size, &act_size); 458 459 if (rc == ESTALL) {460 clear_self_endpoint_halt(pipe);461 }462 463 pipe_drop_ref(pipe);464 394 465 395 if (rc != EOK) { … … 488 418 void *data_buffer, size_t data_buffer_size) 489 419 { 490 /* Ensure serialization over the phone. */491 pipe_start_transaction(pipe);492 493 420 /* 494 421 * Make call identifying target USB device and control transfer type. 495 422 */ 496 aid_t opening_request = async_send_ 4(pipe->hc_phone,423 aid_t opening_request = async_send_5(pipe->hc_phone, 497 424 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE, 498 425 pipe->wire->address, pipe->endpoint_no, 499 426 data_buffer_size, 427 pipe->max_packet_size, 500 428 NULL); 501 429 if (opening_request == 0) { 502 pipe_end_transaction(pipe);503 430 return ENOMEM; 504 431 } … … 510 437 setup_buffer, setup_buffer_size); 511 438 if (rc != EOK) { 512 pipe_end_transaction(pipe);513 439 async_wait_for(opening_request, NULL); 514 440 return rc; … … 521 447 rc = async_data_write_start(pipe->hc_phone, 522 448 data_buffer, data_buffer_size); 523 524 /* All data sent, pipe can be released. */525 pipe_end_transaction(pipe);526 527 449 if (rc != EOK) { 528 450 async_wait_for(opening_request, NULL); 529 451 return rc; 530 452 } 531 } else {532 /* No data to send, we can release the pipe for others. */533 pipe_end_transaction(pipe);534 453 } 535 454 … … 572 491 } 573 492 493 if (!usb_pipe_is_session_started(pipe)) { 494 return EBADF; 495 } 496 574 497 if ((pipe->direction != USB_DIRECTION_BOTH) 575 498 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 577 500 } 578 501 579 int rc; 580 581 rc = pipe_add_ref(pipe); 582 if (rc != EOK) { 583 return rc; 584 } 585 586 rc = usb_pipe_control_write_no_check(pipe, 502 int rc = usb_pipe_control_write_no_check(pipe, 587 503 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 588 589 if (rc == ESTALL) {590 clear_self_endpoint_halt(pipe);591 }592 593 pipe_drop_ref(pipe);594 504 595 505 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.