Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a045ab1 in mainline


Ignore:
Timestamp:
2011-12-11T13:55:20Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
2c202c5
Parents:
6df14c5
Message:

libusb: Move USB dev functions to separate header/source file

Location:
uspace/lib/usb
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/Makefile

    r6df14c5 ra045ab1  
    3737        src/class.c \
    3838        src/ddfiface.c \
     39        src/dev.c \
    3940        src/debug.c \
    4041        src/dump.c \
  • uspace/lib/usb/include/usb/hc.h

    r6df14c5 ra045ab1  
    114114}
    115115
    116 usb_address_t usb_get_address_by_handle(devman_handle_t);
    117 
    118 int usb_find_hc(devman_handle_t, devman_handle_t *);
    119 
    120 int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *,
    121     devman_handle_t *);
    122 
    123116int usb_ddf_get_hc_handle_by_sid(service_id_t, devman_handle_t *);
    124117
  • uspace/lib/usb/include/usb/usb.h

    r6df14c5 ra045ab1  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup libusb
    3029 * @{
  • uspace/lib/usb/src/ddfiface.c

    r6df14c5 ra045ab1  
    4343#include <errno.h>
    4444#include <assert.h>
     45
     46#include <usb/dev.h>
    4547
    4648/** DDF interface for USB device, implementation for typical hub. */
     
    134136        assert(fun);
    135137        assert(fun->driver_data);
    136         usb_hub_attached_device_t *device = fun->driver_data;
     138        const usb_hub_attached_device_t *device = fun->driver_data;
    137139        assert(device->fun == fun);
    138140        if (address)
  • uspace/lib/usb/src/hc.c

    r6df14c5 ra045ab1  
    3737#include <async.h>
    3838#include <dev_iface.h>
    39 #include <usb_iface.h>
    4039#include <usbhc_iface.h>
    4140#include <usb/hc.h>
    4241#include <usb/debug.h>
     42#include <usb/dev.h>
    4343#include <errno.h>
    4444#include <assert.h>
     
    288288        return ret;
    289289}
    290 /*----------------------------------------------------------------------------*/
    291 /** Tell USB address assigned to device with given handle.
    292  *
    293  * @param dev_handle Devman handle of the USB device in question.
    294  * @return USB address or negative error code.
    295  */
    296 usb_address_t usb_get_address_by_handle(devman_handle_t dev_handle)
    297 {
    298         async_sess_t *parent_sess =
    299             devman_parent_device_connect(EXCHANGE_ATOMIC, dev_handle,
    300             IPC_FLAG_BLOCKING);
    301         if (!parent_sess)
    302                 return ENOMEM;
    303 
    304         async_exch_t *exch = async_exchange_begin(parent_sess);
    305         if (!exch) {
    306                 async_hangup(parent_sess);
    307                 return ENOMEM;
    308         }
    309         usb_address_t address;
    310         const int ret = usb_get_my_address(exch, &address);
    311 
    312         async_exchange_end(exch);
    313         async_hangup(parent_sess);
    314 
    315         if (ret != EOK)
    316                 return ret;
    317 
    318         return address;
    319 }
    320 
    321 /** Find host controller handle for the device.
    322  *
    323  * @param[in] device_handle Device devman handle.
    324  * @param[out] hc_handle Where to store handle of host controller
    325  *      controlling device with @p device_handle handle.
    326  * @return Error code.
    327  */
    328 int usb_find_hc(devman_handle_t device_handle, devman_handle_t *hc_handle)
    329 {
    330         async_sess_t *parent_sess =
    331             devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle,
    332             IPC_FLAG_BLOCKING);
    333         if (!parent_sess)
    334                 return ENOMEM;
    335 
    336         async_exch_t *exch = async_exchange_begin(parent_sess);
    337         if (!exch) {
    338                 async_hangup(parent_sess);
    339                 return ENOMEM;
    340         }
    341         const int ret = usb_get_hc_handle(exch, hc_handle);
    342 
    343         async_exchange_end(exch);
    344         async_hangup(parent_sess);
    345 
    346         return ret;
    347 }
    348290
    349291/**
  • uspace/lib/usb/src/resolve.c

    r6df14c5 ra045ab1  
    3434 */
    3535#include <inttypes.h>
     36#include <usb/dev.h>
    3637#include <usb/hc.h>
    3738#include <devman.h>
     
    7778    devman_handle_t *dev_handle)
    7879{
    79         int rc;
    8080        usb_hc_connection_t conn;
    81 
    8281        usb_hc_connection_initialize(&conn, hc_handle);
    83         rc = usb_hc_connection_open(&conn);
    84         if (rc != EOK) {
    85                 return rc;
    86         }
    87 
    88         rc = usb_hc_get_handle_by_address(&conn, addr, dev_handle);
    89 
    90         usb_hc_connection_close(&conn);
     82
     83        const int rc = usb_hc_get_handle_by_address(&conn, addr, dev_handle);
    9184
    9285        return rc;
Note: See TracChangeset for help on using the changeset viewer.