Ignore:
File:
1 edited

Legend:

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

    re9ce696 r3954a63b  
    4141#include <errno.h>
    4242#include <assert.h>
    43 #include "pipepriv.h"
    4443
    4544#define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */
     
    242241 * necessary.
    243242 *
    244  * @deprecated
    245  * Obsoleted with introduction of usb_pipe_start_long_transfer
    246  *
    247243 * @param pipe Endpoint pipe to start the session on.
    248244 * @return Error code.
     
    250246int usb_pipe_start_session(usb_pipe_t *pipe)
    251247{
    252         usb_log_warning("usb_pipe_start_session() was deprecated.\n");
     248        assert(pipe);
     249
     250        if (usb_pipe_is_session_started(pipe)) {
     251                return EBUSY;
     252        }
     253
     254        int phone = devman_device_connect(pipe->wire->hc_handle, 0);
     255        if (phone < 0) {
     256                return phone;
     257        }
     258
     259        pipe->hc_phone = phone;
     260
    253261        return EOK;
    254262}
     
    257265/** Ends a session on the endpoint pipe.
    258266 *
    259  * @deprecated
    260  * Obsoleted with introduction of usb_pipe_end_long_transfer
    261  *
    262267 * @see usb_pipe_start_session
    263268 *
     
    267272int usb_pipe_end_session(usb_pipe_t *pipe)
    268273{
    269         usb_log_warning("usb_pipe_end_session() was deprecated.\n");
     274        assert(pipe);
     275
     276        if (!usb_pipe_is_session_started(pipe)) {
     277                return ENOENT;
     278        }
     279
     280        int rc = async_hangup(pipe->hc_phone);
     281        if (rc != EOK) {
     282                return rc;
     283        }
     284
     285        pipe->hc_phone = -1;
     286
    270287        return EOK;
    271288}
     
    281298bool usb_pipe_is_session_started(usb_pipe_t *pipe)
    282299{
    283         pipe_acquire(pipe);
    284         bool started = pipe->refcount > 0;
    285         pipe_release(pipe);
    286         return started;
    287 }
    288 
    289 /** Prepare pipe for a long transfer.
    290  *
    291  * By a long transfer is mean transfer consisting of several
    292  * requests to the HC.
    293  * Calling such function is optional and it has positive effect of
    294  * improved performance because IPC session is initiated only once.
    295  *
    296  * @param pipe Pipe over which the transfer will happen.
    297  * @return Error code.
    298  */
    299 int usb_pipe_start_long_transfer(usb_pipe_t *pipe)
    300 {
    301         return pipe_add_ref(pipe);
    302 }
    303 
    304 /** Terminate a long transfer on a pipe.
    305  *
    306  * @see usb_pipe_start_long_transfer
    307  *
    308  * @param pipe Pipe where to end the long transfer.
    309  */
    310 void usb_pipe_end_long_transfer(usb_pipe_t *pipe)
    311 {
    312         pipe_drop_ref(pipe);
     300        return (pipe->hc_phone >= 0);
    313301}
    314302
Note: See TracChangeset for help on using the changeset viewer.