Changeset a546687 in mainline for uspace/lib/usb/src/pipesio.c


Ignore:
Timestamp:
2011-04-09T09:17:22Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d48fcc0
Parents:
d5ac90f
Message:

Sessions started automatically on pipes

It is no longer necessary to call usb_pipe_start_session prior
reading or writing on a pipe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/pipesio.c

    rd5ac90f ra546687  
    4949#include <assert.h>
    5050#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"
    7152
    7253/** Request an in transfer, no checking of input parameters.
     
    176157
    177158        if (buffer == NULL) {
    178                         return EINVAL;
     159                return EINVAL;
    179160        }
    180161
    181162        if (size == 0) {
    182163                return EINVAL;
    183         }
    184 
    185         if (!usb_pipe_is_session_started(pipe)) {
    186                 return EBADF;
    187164        }
    188165
     
    195172        }
    196173
     174        int rc;
     175        rc = pipe_add_ref(pipe);
     176        if (rc != EOK) {
     177                return rc;
     178        }
     179
     180
    197181        size_t act_size = 0;
    198         int rc;
    199182
    200183        rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
     184
     185        pipe_drop_ref(pipe);
     186
    201187        if (rc != EOK) {
    202188                return rc;
     
    301287        }
    302288
    303         if (!usb_pipe_is_session_started(pipe)) {
    304                 return EBADF;
    305         }
    306 
    307289        if (pipe->direction != USB_DIRECTION_OUT) {
    308290                return EBADF;
     
    313295        }
    314296
    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);
    316307
    317308        return rc;
     
    432423        }
    433424
    434         if (!usb_pipe_is_session_started(pipe)) {
    435                 return EBADF;
    436         }
    437 
    438425        if ((pipe->direction != USB_DIRECTION_BOTH)
    439426            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    441428        }
    442429
     430        int rc;
     431
     432        rc = pipe_add_ref(pipe);
     433        if (rc != EOK) {
     434                return rc;
     435        }
     436
    443437        size_t act_size = 0;
    444         int rc = usb_pipe_control_read_no_check(pipe,
     438        rc = usb_pipe_control_read_no_check(pipe,
    445439            setup_buffer, setup_buffer_size,
    446440            data_buffer, data_buffer_size, &act_size);
     441
     442        pipe_drop_ref(pipe);
    447443
    448444        if (rc != EOK) {
     
    556552        }
    557553
    558         if (!usb_pipe_is_session_started(pipe)) {
    559                 return EBADF;
    560         }
    561 
    562554        if ((pipe->direction != USB_DIRECTION_BOTH)
    563555            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    565557        }
    566558
    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,
    568567            setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
     568
     569        pipe_drop_ref(pipe);
    569570
    570571        return rc;
Note: See TracChangeset for help on using the changeset viewer.