Changeset 43c3937 in mainline for uspace/lib/usb/src/usbdrv.c


Ignore:
Timestamp:
2011-01-07T10:43:15Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5097bed4
Parents:
5f7d96e (diff), 0f191a2 (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:

merge with usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/usbdrv.c

    r5f7d96e r43c3937  
    3535#include <usb/usbdrv.h>
    3636#include <usbhc_iface.h>
     37#include <usb_iface.h>
    3738#include <errno.h>
    3839#include <str_error.h>
     
    5455} transfer_info_t;
    5556
     57/** Find handle of host controller the device is physically attached to.
     58 *
     59 * @param[in] dev Device looking for its host controller.
     60 * @param[out] handle Host controller devman handle.
     61 * @return Error code.
     62 */
     63int usb_drv_find_hc(device_t *dev, devman_handle_t *handle)
     64{
     65        if (dev == NULL) {
     66                return EBADMEM;
     67        }
     68        if (handle == NULL) {
     69                return EBADMEM;
     70        }
     71
     72        int parent_phone = devman_parent_device_connect(dev->handle,
     73            IPC_FLAG_BLOCKING);
     74        if (parent_phone < 0) {
     75                return parent_phone;
     76        }
     77
     78        devman_handle_t h;
     79        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     80            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
     81
     82        ipc_hangup(parent_phone);
     83
     84        if (rc != EOK) {
     85                return rc;
     86        }
     87
     88        *handle = h;
     89
     90        return EOK;
     91}
     92
     93/** Connect to host controller the device is physically attached to.
     94 *
     95 * @param dev Device asking for connection.
     96 * @param hc_handle Devman handle of the host controller.
     97 * @param flags Connection flags (blocking connection).
     98 * @return Phone to the HC or error code.
     99 */
     100int usb_drv_hc_connect(device_t *dev, devman_handle_t hc_handle,
     101    unsigned int flags)
     102{
     103        return devman_device_connect(hc_handle, flags);
     104}
     105
    56106/** Connect to host controller the device is physically attached to.
    57107 *
     
    60110 * @return Phone to corresponding HC or error code.
    61111 */
    62 int usb_drv_hc_connect(device_t *dev, unsigned int flags)
    63 {
     112int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags)
     113{
     114        int rc;
     115        devman_handle_t hc_handle;
     116
    64117        /*
    65118         * Call parent hub to obtain device handle of respective HC.
    66119         */
    67 
    68         /*
    69          * FIXME: currently we connect always to virtual host controller.
    70          */
    71         int rc;
    72         devman_handle_t handle;
    73 
    74         rc = devman_device_get_handle("/virt/usbhc", &handle, flags);
     120        rc = usb_drv_find_hc(dev, &hc_handle);
    75121        if (rc != EOK) {
    76122                return rc;
    77123        }
    78124       
    79         int phone = devman_device_connect(handle, flags);
    80 
    81         return phone;
     125        return usb_drv_hc_connect(dev, hc_handle, flags);
    82126}
    83127
Note: See TracChangeset for help on using the changeset viewer.