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


Ignore:
Timestamp:
2011-04-09T09:17:22Z (13 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/pipes.c

    rd5ac90f ra546687  
    4141#include <errno.h>
    4242#include <assert.h>
     43#include "pipepriv.h"
    4344
    4445#define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */
     
    246247int usb_pipe_start_session(usb_pipe_t *pipe)
    247248{
    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 
    261         return EOK;
     249        return pipe_add_ref(pipe);
    262250}
    263251
     
    272260int usb_pipe_end_session(usb_pipe_t *pipe)
    273261{
    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 
     262        pipe_drop_ref(pipe);
    287263        return EOK;
    288264}
     
    298274bool usb_pipe_is_session_started(usb_pipe_t *pipe)
    299275{
    300         return (pipe->hc_phone >= 0);
     276        pipe_acquire(pipe);
     277        bool started = pipe->refcount > 0;
     278        pipe_release(pipe);
     279        return started;
    301280}
    302281
Note: See TracChangeset for help on using the changeset viewer.