Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmid/usbmid.c

    r51f0e410 ra6add7a  
    4545
    4646/** Callback for DDF USB interface. */
    47 static int usb_iface_get_address_impl(device_t *device, devman_handle_t handle,
     47static int usb_iface_get_address_impl(ddf_fun_t *fun, devman_handle_t handle,
    4848    usb_address_t *address)
    4949{
    50         assert(device);
    51         device_t *parent = device->parent;
    52 
    53         /* Default error, device does not support this operation. */
    54         int rc = ENOTSUP;
    55 
    56         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    57                 usb_iface_t *usb_iface
    58                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    59                 assert(usb_iface != NULL);
    60 
    61                 if (usb_iface->get_address) {
    62                         rc = usb_iface->get_address(parent, parent->handle,
    63                             address);
    64                 }
    65         }
    66 
    67         return rc;
     50        return usb_iface_get_address_hub_impl(fun, handle, address);
    6851}
    6952
    7053/** Callback for DDF USB interface. */
    71 static int usb_iface_get_interface_impl(device_t *device, devman_handle_t handle,
     54static int usb_iface_get_interface_impl(ddf_fun_t *fun, devman_handle_t handle,
    7255    int *iface_no)
    7356{
    74         assert(device);
    75 
    76         usbmid_interface_t *iface = device->driver_data;
     57        assert(fun);
     58
     59        usbmid_interface_t *iface = fun->driver_data;
    7760        assert(iface);
    7861
     
    8467}
    8568
     69/** DDF interface of the child - interface function. */
    8670static usb_iface_t child_usb_iface = {
    8771        .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl,
     
    9074};
    9175
    92 
    93 static device_ops_t child_device_ops = {
     76/** Operations for children - interface functions. */
     77static ddf_dev_ops_t child_device_ops = {
    9478        .interfaces[USB_DEV_IFACE] = &child_usb_iface
    9579};
    9680
    97 static device_ops_t mid_device_ops = {
     81/** Operations of the device itself. */
     82static ddf_dev_ops_t mid_device_ops = {
    9883        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
    9984};
     
    10590 * @retval NULL Error occured.
    10691 */
    107 usbmid_device_t *usbmid_device_create(device_t *dev)
     92usbmid_device_t *usbmid_device_create(ddf_dev_t *dev)
    10893{
    10994        usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));
     
    133118
    134119        mid->dev = dev;
    135         dev->ops = &mid_device_ops;
     120        (void) &mid_device_ops;
    136121
    137122        return mid;
     
    145130 * @retval NULL Error occured.
    146131 */
    147 usbmid_interface_t *usbmid_interface_create(device_t *dev, int iface_no)
     132usbmid_interface_t *usbmid_interface_create(ddf_fun_t *fun, int iface_no)
    148133{
    149134        usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
     
    154139        }
    155140
    156         iface->dev = dev;
     141        iface->fun = fun;
    157142        iface->interface_no = iface_no;
    158143
     
    172157    const usb_standard_interface_descriptor_t *interface_descriptor)
    173158{
    174         device_t *child = NULL;
     159        ddf_fun_t *child = NULL;
    175160        char *child_name = NULL;
    176161        usbmid_interface_t *child_as_interface = NULL;
    177162        int rc;
    178 
    179         /* Create the device. */
    180         child = create_device();
    181         if (child == NULL) {
    182                 rc = ENOMEM;
    183                 goto error_leave;
    184         }
    185163
    186164        /*
     
    196174        }
    197175
     176        /* Create the device. */
     177        child = ddf_fun_create(parent->dev, fun_inner, child_name);
     178        if (child == NULL) {
     179                rc = ENOMEM;
     180                goto error_leave;
     181        }
     182
     183
     184
    198185        child_as_interface = usbmid_interface_create(child,
    199186            (int) interface_descriptor->interface_number);
     
    204191
    205192        child->driver_data = child_as_interface;
    206         child->parent = parent->dev;
    207         child->name = child_name;
    208193        child->ops = &child_device_ops;
    209194
     
    215200        }
    216201
    217         rc = child_device_register(child, parent->dev);
     202        rc = ddf_fun_bind(child);
    218203        if (rc != EOK) {
    219204                goto error_leave;
     
    226211                child->name = NULL;
    227212                /* This takes care of match_id deallocation as well. */
    228                 delete_device(child);
     213                ddf_fun_destroy(child);
    229214        }
    230215        if (child_name != NULL) {
Note: See TracChangeset for help on using the changeset viewer.