Ignore:
File:
1 edited

Legend:

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

    r58563585 r56fd7cf  
    3131 */
    3232
     33/* XXX Fix this */
     34#define _DDF_DATA_IMPLANT
     35
    3336/**
    3437 * @file
    3538 * Helper functions.
    3639 */
    37 
    3840#include <errno.h>
    3941#include <str_error.h>
    4042#include <stdlib.h>
    4143#include <usb_iface.h>
     44#include <usb/ddfiface.h>
    4245#include <usb/dev/pipes.h>
    4346#include <usb/classes/classes.h>
     
    4548#include "usbmid.h"
    4649
    47 /** Get USB device handle by calling the parent usb_device_t.
    48  *
    49  * @param[in] fun Device function the operation is running on.
    50  * @param[out] handle Device handle.
    51  * @return Error code.
    52  */
    53 static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle)
    54 {
    55         assert(fun);
    56         assert(handle);
    57         usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));
    58         *handle = usb_device_get_devman_handle(usb_dev);
    59         return EOK;
    60 }
    61 
    62 /** Callback for DDF USB get interface. */
    63 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)
    6452{
    6553        usbmid_interface_t *iface = ddf_fun_data_get(fun);
    6654        assert(iface);
    6755
    68         if (iface_no)
     56        if (iface_no != NULL) {
    6957                *iface_no = iface->interface_no;
     58        }
    7059
    7160        return EOK;
    7261}
    7362
    74 /** DDF interface of the child - USB functions. */
     63/** DDF interface of the child - interface function. */
    7564static usb_iface_t child_usb_iface = {
    76         .get_my_device_handle = usb_iface_device_handle,
    77         .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,
    7868};
    7969
     
    9181                return ret;
    9282        }
     83        /* NOTE: usbmid->interface points somewhere, but we did not
     84         * allocate that space, so don't touch */
    9385        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 */
    9488        return EOK;
    9589}
     
    10498 */
    10599int usbmid_spawn_interface_child(usb_device_t *parent,
    106     usbmid_interface_t **iface_ret,
     100    usbmid_interface_t *iface,
    107101    const usb_standard_device_descriptor_t *device_descriptor,
    108102    const usb_standard_interface_descriptor_t *interface_descriptor)
     
    125119
    126120        /* Create the device. */
    127         child = usb_device_ddf_fun_create(parent, fun_inner, child_name);
     121        child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
    128122        free(child_name);
    129123        if (child == NULL) {
     
    141135        }
    142136
    143         list_foreach(match_ids.ids, link, match_id_t, match_id) {
     137        list_foreach(match_ids.ids, link) {
     138                match_id_t *match_id = list_get_instance(link, match_id_t, link);
    144139                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
    145140                if (rc != EOK) {
     
    150145        }
    151146        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);
    159147
    160148        rc = ddf_fun_bind(child);
     
    164152                return rc;
    165153        }
    166         *iface_ret = iface;
     154
     155        iface->fun = child;
     156        ddf_fun_data_implant(child, iface);
     157        ddf_fun_set_ops(child, &child_device_ops);
    167158
    168159        return EOK;
Note: See TracChangeset for help on using the changeset viewer.