Ignore:
File:
1 edited

Legend:

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

    r3121b5f rfeeac0d  
    3131 */
    3232
     33/* XXX Fix this */
     34#define _DDF_DATA_IMPLANT
     35
    3336/**
    3437 * @file
     
    3942#include <stdlib.h>
    4043#include <usb_iface.h>
     44#include <usb/ddfiface.h>
    4145#include <usb/dev/pipes.h>
    4246#include <usb/classes/classes.h>
     
    4448#include "usbmid.h"
    4549
    46 /** Get USB device handle by calling the parent usb_device_t.
    47  *
    48  * @param[in] fun Device function the operation is running on.
    49  * @param[out] handle Device handle.
    50  * @return Error code.
    51  */
    52 static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle)
    53 {
    54         assert(fun);
    55         assert(handle);
    56         usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));
    57         *handle = usb_device_get_devman_handle(usb_dev);
    58         return EOK;
    59 }
    60 
    61 /** Callback for DDF USB get interface. */
    62 static int usb_iface_iface_no(ddf_fun_t *fun, int *iface_no)
     50/** Callback for DDF USB interface. */
     51static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no)
    6352{
    6453        usbmid_interface_t *iface = ddf_fun_data_get(fun);
    6554        assert(iface);
    6655
    67         if (iface_no)
     56        if (iface_no != NULL) {
    6857                *iface_no = iface->interface_no;
     58        }
    6959
    7060        return EOK;
    7161}
    7262
    73 /** DDF interface of the child - USB functions. */
     63/** DDF interface of the child - interface function. */
    7464static usb_iface_t child_usb_iface = {
    75         .get_my_device_handle = usb_iface_device_handle,
    76         .get_my_interface = usb_iface_iface_no,
     65        .get_hc_handle = usb_iface_get_hc_handle_device_impl,
     66        .get_my_address = usb_iface_get_my_address_forward_impl,
     67        .get_my_interface = usb_iface_get_interface_impl,
    7768};
    7869
     
    9081                return ret;
    9182        }
     83        /* NOTE: usbmid->interface points somewhere, but we did not
     84         * allocate that space, so don't touch */
    9285        ddf_fun_destroy(mid_iface->fun);
     86        /* NOTE: mid_iface is invalid at this point, it was assigned to
     87         * mid_iface->fun->driver_data and freed in ddf_fun_destroy */
    9388        return EOK;
    9489}
     
    10398 */
    10499int usbmid_spawn_interface_child(usb_device_t *parent,
    105     usbmid_interface_t **iface_ret,
     100    usbmid_interface_t *iface,
    106101    const usb_standard_device_descriptor_t *device_descriptor,
    107102    const usb_standard_interface_descriptor_t *interface_descriptor)
     
    124119
    125120        /* Create the device. */
    126         child = usb_device_ddf_fun_create(parent, fun_inner, child_name);
     121        child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
    127122        free(child_name);
    128123        if (child == NULL) {
     
    140135        }
    141136
    142         list_foreach(match_ids.ids, link) {
    143                 match_id_t *match_id = list_get_instance(link, match_id_t, link);
     137        list_foreach(match_ids.ids, link, match_id_t, match_id) {
    144138                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
    145139                if (rc != EOK) {
     
    150144        }
    151145        clean_match_ids(&match_ids);
    152         ddf_fun_set_ops(child, &child_device_ops);
    153 
    154         usbmid_interface_t *iface = ddf_fun_data_alloc(child, sizeof(*iface));
    155 
    156         iface->fun = child;
    157         iface->interface_no = interface_descriptor->interface_number;
    158         link_initialize(&iface->link);
    159146
    160147        rc = ddf_fun_bind(child);
     
    164151                return rc;
    165152        }
    166         *iface_ret = iface;
     153
     154        iface->fun = child;
     155        ddf_fun_data_implant(child, iface);
     156        ddf_fun_set_ops(child, &child_device_ops);
    167157
    168158        return EOK;
Note: See TracChangeset for help on using the changeset viewer.