Ignore:
File:
1 edited

Legend:

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

    rd5c1051 r4c3fef4  
    4545#include "usbmid.h"
    4646
    47 /** Get USB device handle by calling the parent usb_device_t.
     47/**
     48 * Get USB device description by calling HC and altering the interface field.
    4849 *
    4950 * @param[in] fun Device function the operation is running on.
    50  * @param[out] handle Device handle.
     51 * @param[out] desc Device descriptor.
    5152 * @return Error code.
    5253 */
    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)
     54static int usb_iface_description(ddf_fun_t *fun, usb_device_desc_t *desc)
    6455{
    6556        usbmid_interface_t *iface = ddf_fun_data_get(fun);
    6657        assert(iface);
     58        usb_device_t *usb_dev = ddf_dev_data_get(ddf_fun_get_dev(fun));
     59        assert(usb_dev);
    6760
    68         if (iface_no)
    69                 *iface_no = iface->interface_no;
     61        async_exch_t *exch = usb_device_bus_exchange_begin(usb_dev);
     62        if (!exch)
     63                return EPARTY;
     64
     65        usb_device_desc_t tmp_desc;
     66        const int ret = usb_get_my_description(exch, &tmp_desc);
     67
     68        if (ret == EOK && desc) {
     69                *desc = tmp_desc;
     70                desc->iface = iface->interface_no;
     71        }
     72
     73        usb_device_bus_exchange_end(exch);
    7074
    7175        return EOK;
     
    7478/** DDF interface of the child - USB functions. */
    7579static usb_iface_t child_usb_iface = {
    76         .get_my_device_handle = usb_iface_device_handle,
    77         .get_my_interface = usb_iface_iface_no,
     80        .get_my_description = usb_iface_description,
    7881};
    7982
     
    117120         * class name something humanly understandable.
    118121         */
    119         int ret = asprintf(&child_name, "%s%hhu",
     122        rc = asprintf(&child_name, "%s%hhu",
    120123            usb_str_class(interface_descriptor->interface_class),
    121124            interface_descriptor->interface_number);
    122         if (ret < 0) {
     125        if (rc < 0) {
    123126                return ENOMEM;
    124127        }
Note: See TracChangeset for help on using the changeset viewer.