Changeset a546687 in mainline for uspace/lib/usb/src/pipesio.c
- Timestamp:
- 2011-04-09T09:17:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d48fcc0
- Parents:
- d5ac90f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipesio.c
rd5ac90f ra546687 49 49 #include <assert.h> 50 50 #include <usbhc_iface.h> 51 52 /** Ensure exclusive access to the IPC phone of given pipe. 53 * 54 * @param pipe Pipe to be exclusively accessed. 55 */ 56 static void pipe_acquire(usb_pipe_t *pipe) 57 { 58 fibril_mutex_lock(&pipe->hc_phone_mutex); 59 } 60 61 /** Terminate exclusive access to the IPC phone of given pipe. 62 * 63 * @param pipe Pipe to be released from exclusive usage. 64 */ 65 static void pipe_release(usb_pipe_t *pipe) 66 { 67 fibril_mutex_unlock(&pipe->hc_phone_mutex); 68 } 69 70 51 #include "pipepriv.h" 71 52 72 53 /** Request an in transfer, no checking of input parameters. … … 176 157 177 158 if (buffer == NULL) { 178 159 return EINVAL; 179 160 } 180 161 181 162 if (size == 0) { 182 163 return EINVAL; 183 }184 185 if (!usb_pipe_is_session_started(pipe)) {186 return EBADF;187 164 } 188 165 … … 195 172 } 196 173 174 int rc; 175 rc = pipe_add_ref(pipe); 176 if (rc != EOK) { 177 return rc; 178 } 179 180 197 181 size_t act_size = 0; 198 int rc;199 182 200 183 rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size); 184 185 pipe_drop_ref(pipe); 186 201 187 if (rc != EOK) { 202 188 return rc; … … 301 287 } 302 288 303 if (!usb_pipe_is_session_started(pipe)) {304 return EBADF;305 }306 307 289 if (pipe->direction != USB_DIRECTION_OUT) { 308 290 return EBADF; … … 313 295 } 314 296 315 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); 316 307 317 308 return rc; … … 432 423 } 433 424 434 if (!usb_pipe_is_session_started(pipe)) {435 return EBADF;436 }437 438 425 if ((pipe->direction != USB_DIRECTION_BOTH) 439 426 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 441 428 } 442 429 430 int rc; 431 432 rc = pipe_add_ref(pipe); 433 if (rc != EOK) { 434 return rc; 435 } 436 443 437 size_t act_size = 0; 444 intrc = usb_pipe_control_read_no_check(pipe,438 rc = usb_pipe_control_read_no_check(pipe, 445 439 setup_buffer, setup_buffer_size, 446 440 data_buffer, data_buffer_size, &act_size); 441 442 pipe_drop_ref(pipe); 447 443 448 444 if (rc != EOK) { … … 556 552 } 557 553 558 if (!usb_pipe_is_session_started(pipe)) {559 return EBADF;560 }561 562 554 if ((pipe->direction != USB_DIRECTION_BOTH) 563 555 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 565 557 } 566 558 567 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, 568 567 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 568 569 pipe_drop_ref(pipe); 569 570 570 571 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.