Changeset 71ed4849 in mainline for uspace/lib/usb/src/usbdrv.c


Ignore:
Timestamp:
2010-12-28T14:00:36Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f8a0cd6
Parents:
de2c901
Message:

Connecting to "parent" host controller

USB drivers can now connect to host controller drivers they physically
belong to (so far, everything connected to VHC).

Each USB device must implement the USB interface of libdrv to allow
this (it is absolutely neccesary for hubs).

USB drivers can use usb_drv_hc_connect() to connect to "their" host
controller.

Child devices created with usb_drv_register_child_in_devman()are set
to handle this connection automatically.

UHCI and VHC drivers were updated.

File:
1 edited

Legend:

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

    rde2c901 r71ed4849  
    7070        }
    7171
    72         int parent_phone = devman_parent_device_connect(dev->handle, 0);
     72        int parent_phone = devman_parent_device_connect(dev->handle,
     73            IPC_FLAG_BLOCKING);
    7374        if (parent_phone < 0) {
    7475                return parent_phone;
     
    7879        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
    7980            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
     81
     82        ipc_hangup(parent_phone);
     83
    8084        if (rc != EOK) {
    8185                return rc;
     
    8589
    8690        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);
    87104}
    88105
     
    93110 * @return Phone to corresponding HC or error code.
    94111 */
    95 int usb_drv_hc_connect(device_t *dev, unsigned int flags)
    96 {
     112int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags)
     113{
     114        int rc;
     115        devman_handle_t hc_handle;
     116
    97117        /*
    98118         * Call parent hub to obtain device handle of respective HC.
    99119         */
    100 
    101         /*
    102          * FIXME: currently we connect always to virtual host controller.
    103          */
    104         int rc;
    105         devman_handle_t handle;
    106 
    107         rc = devman_device_get_handle("/virt/usbhc", &handle, flags);
     120        rc = usb_drv_find_hc(dev, &hc_handle);
    108121        if (rc != EOK) {
    109122                return rc;
    110123        }
    111124       
    112         int phone = devman_device_connect(handle, flags);
    113 
    114         return phone;
     125        return usb_drv_hc_connect(dev, hc_handle, flags);
    115126}
    116127
Note: See TracChangeset for help on using the changeset viewer.