Changeset e936e8e in mainline


Ignore:
Timestamp:
2011-02-22T14:31:09Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5d1535
Parents:
9f554e64
Message:

Add "is session started" function to the pipes API

Replaced direct querying of signess of hc_phone with this function.

Location:
uspace/lib/usb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/pipes.h

    r9f554e64 re936e8e  
    137137int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *);
    138138int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *);
     139bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *);
    139140
    140141int usb_endpoint_pipe_read(usb_endpoint_pipe_t *, void *, size_t, size_t *);
  • uspace/lib/usb/src/pipes.c

    r9f554e64 re936e8e  
    191191        assert(pipe);
    192192
    193         if (pipe->hc_phone >= 0) {
     193        if (usb_endpoint_pipe_is_session_started(pipe)) {
    194194                return EBUSY;
    195195        }
     
    217217        assert(pipe);
    218218
    219         if (pipe->hc_phone < 0) {
     219        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    220220                return ENOENT;
    221221        }
     
    229229
    230230        return EOK;
     231}
     232
     233/** Tell whether a session is started (open) on the endpoint pipe.
     234 *
     235 * The expected usage of this function is in assertions for some
     236 * nested functions.
     237 *
     238 * @param pipe Endpoint pipe in question.
     239 * @return Whether @p pipe has opened a session.
     240 */
     241bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *pipe)
     242{
     243        return (pipe->hc_phone >= 0);
    231244}
    232245
  • uspace/lib/usb/src/pipesio.c

    r9f554e64 re936e8e  
    148148        }
    149149
    150         if (pipe->hc_phone < 0) {
     150        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    151151                return EBADF;
    152152        }
     
    255255        }
    256256
    257         if (pipe->hc_phone < 0) {
     257        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    258258                return EBADF;
    259259        }
     
    369369        }
    370370
    371         if (pipe->hc_phone < 0) {
     371        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    372372                return EBADF;
    373373        }
     
    481481        }
    482482
    483         if (pipe->hc_phone < 0) {
     483        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    484484                return EBADF;
    485485        }
Note: See TracChangeset for help on using the changeset viewer.