Changeset 5410c04 in mainline for uspace/lib/usb/include/usb/pipes.h


Ignore:
Timestamp:
2011-04-09T16:11:41Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9d67aa, c6394aa
Parents:
8e8b84f (diff), 7b715892 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Automatic pipe sessions

It is no longer necessary to start sessions on USB pipes manually.
Actually, the original functions usb_pipe_start/end_session are now
deprecated.

For sporadic transfers, you do not need to care about sessions at all.
For longer transfers, you may hint the library about it by calling
usb_pipe_start_long_transfer.

File:
1 edited

Legend:

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

    r8e8b84f r5410c04  
    4242#include <ipc/devman.h>
    4343#include <ddf/driver.h>
     44#include <fibril_synch.h>
    4445
    4546/** Abstraction of a physical connection to the device.
     
    5960 * This endpoint must be bound with existing usb_device_connection_t
    6061 * (i.e. the wire to send data over).
     62 *
     63 * Locking order: if you want to lock both mutexes
     64 * (@c guard and @c hc_phone_mutex), lock @c guard first.
     65 * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
     66 * only.
    6167 */
    6268typedef struct {
     69        /** Guard of the whole pipe. */
     70        fibril_mutex_t guard;
     71
    6372        /** The connection used for sending the data. */
    6473        usb_device_connection_t *wire;
     
    7887        /** Phone to the host controller.
    7988         * Negative when no session is active.
     89         * It is an error to access this member without @c hc_phone_mutex
     90         * being locked.
     91         * If call over the phone is to be made, it must be preceeded by
     92         * call to pipe_add_ref() [internal libusb function].
    8093         */
    8194        int hc_phone;
     95
     96        /** Guard for serialization of requests over the phone. */
     97        fibril_mutex_t hc_phone_mutex;
     98
     99        /** Number of active transfers over the pipe. */
     100        int refcount;
    82101} usb_pipe_t;
    83102
     
    141160bool usb_pipe_is_session_started(usb_pipe_t *);
    142161
     162int usb_pipe_start_long_transfer(usb_pipe_t *);
     163void usb_pipe_end_long_transfer(usb_pipe_t *);
     164
    143165int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
    144166int usb_pipe_write(usb_pipe_t *, void *, size_t);
Note: See TracChangeset for help on using the changeset viewer.