Changeset 71ed4849 in mainline for uspace/lib/usb/src/recognise.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/recognise.c

    rde2c901 r71ed4849  
    3333 * @brief Functions for recognising kind of attached devices.
    3434 */
     35#include <usb_iface.h>
    3536#include <usb/usbdrv.h>
    3637#include <usb/classes/classes.h>
     
    3839#include <errno.h>
    3940
     41static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
     42{
     43        assert(dev);
     44        assert(dev->parent != NULL);
     45
     46        device_t *parent = dev->parent;
     47
     48        if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
     49                usb_iface_t *usb_iface
     50                    = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
     51                assert(usb_iface != NULL);
     52                if (usb_iface->get_hc_handle) {
     53                        int rc = usb_iface->get_hc_handle(parent, handle);
     54                        return rc;
     55                }
     56        }
     57
     58        return ENOTSUP;
     59}
     60
     61static usb_iface_t usb_iface = {
     62        .get_hc_handle = usb_iface_get_hc_handle
     63};
     64
     65static device_ops_t child_ops = {
     66        .interfaces[USB_DEV_IFACE] = &usb_iface
     67};
    4068
    4169#define BCD_INT(a) (((unsigned int)(a)) / 256)
     
    285313                goto failure;
    286314        }
     315        child->parent = parent;
    287316        child->name = child_name;
     317        child->ops = &child_ops;
    288318       
    289319        rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
Note: See TracChangeset for help on using the changeset viewer.