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

Changeset 2c202c5 in mainline


Ignore:
Timestamp:
2011-12-11T15:17:43Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
bd575647
Parents:
a045ab1
Message:

libusb: Add device_connection_t.

Location:
uspace/lib/usb
Files:
6 edited

Legend:

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

    ra045ab1 r2c202c5  
    3535#define LIBUSB_DEV_H_
    3636
     37#include <devman.h>
    3738#include <usb/usb.h>
    38 #include <devman.h>
     39#include <usb/hc.h>
     40
     41
     42/** Abstraction of a physical connection to the device.
     43 * This type is an abstraction of the USB wire that connects the host and
     44 * the function (device).
     45 */
     46typedef struct {
     47        /** Connection to the host controller device is connected to. */
     48        usb_hc_connection_t *hc_connection;
     49        /** Address of the device. */
     50        usb_address_t address;
     51} usb_device_connection_t;
     52
     53int usb_device_connection_initialize(usb_device_connection_t *,
     54    usb_hc_connection_t *, usb_address_t);
     55
     56/** Initialize connection to USB device on default address.
     57 *
     58 * @param dev_connection Device connection structure to be initialized.
     59 * @param hc_connection Initialized connection to host controller.
     60 * @return Error code.
     61 */
     62static inline int usb_device_connection_initialize_on_default_address(
     63    usb_device_connection_t *connection, usb_hc_connection_t *hc_conn)
     64{
     65        return usb_device_connection_initialize(connection, hc_conn, 0);
     66}
    3967
    4068usb_address_t usb_get_address_by_handle(devman_handle_t);
    4169
    42 int usb_find_hc(devman_handle_t, devman_handle_t *);
     70int usb_get_hc_by_handle(devman_handle_t, devman_handle_t *);
    4371
    4472int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *,
  • uspace/lib/usb/include/usb/hc.h

    ra045ab1 r2c202c5  
    7171        connection->ref_count = 0;
    7272        fibril_mutex_initialize(&connection->guard);
    73 
    7473}
    7574
  • uspace/lib/usb/src/ddfiface.c

    ra045ab1 r2c202c5  
    6868{
    6969        assert(fun);
    70         return usb_find_hc(fun->handle, handle);
     70        return usb_get_hc_by_handle(fun->handle, handle);
    7171}
    7272
  • uspace/lib/usb/src/dev.c

    ra045ab1 r2c202c5  
    6868 * @return Error code.
    6969 */
    70 int usb_find_hc(devman_handle_t device_handle, devman_handle_t *hc_handle)
     70int usb_get_hc_by_handle(devman_handle_t device_handle,
     71    devman_handle_t *hc_handle)
    7172{
    7273        async_sess_t *parent_sess =
     
    8889        return ret;
    8990}
     91/*----------------------------------------------------------------------------*/
     92int usb_device_connection_initialize(usb_device_connection_t *connection,
     93    usb_hc_connection_t *hc_connection, usb_address_t address)
     94{
     95        assert(connection);
     96
     97        if (hc_connection == NULL) {
     98                return EBADMEM;
     99        }
     100
     101        if ((address < 0) || (address >= USB11_ADDRESS_MAX)) {
     102                return EINVAL;
     103        }
     104
     105        connection->hc_connection = hc_connection;
     106        connection->address = address;
     107        return EOK;
     108}
  • uspace/lib/usb/src/hc.c

    ra045ab1 r2c202c5  
    114114
    115115        devman_handle_t hc_handle;
    116         const int rc = usb_find_hc(device->handle, &hc_handle);
     116        const int rc = usb_get_hc_by_handle(device->handle, &hc_handle);
    117117        if (rc == EOK) {
    118118                usb_hc_connection_initialize(connection, hc_handle);
  • uspace/lib/usb/src/resolve.c

    ra045ab1 r2c202c5  
    185185                /* Try to find its host controller. */
    186186                if (!found_hc) {
    187                         rc = usb_find_hc(tmp_handle, &hc_handle);
     187                        rc = usb_get_hc_by_handle(tmp_handle, &hc_handle);
    188188                        if (rc == EOK) {
    189189                                found_hc = true;
Note: See TracChangeset for help on using the changeset viewer.