Changeset c280d7e in mainline for uspace/drv/bus/usb/usbmid/usbmid.c


Ignore:
Timestamp:
2018-01-20T03:02:36Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60d3f35
Parents:
3cdaa7f
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-20 03:02:32)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-20 03:02:36)
Message:

libdrv: usb iface callbacks joined

In addition to handle and current interface, it is good for the device
to know its address and speed. Also, it is expected to add some other
fields (stats, info tied to devices of specific speed and so on) in the
future. Instead of adding yet another call, join those two and let HC
fill a description structure.

File:
1 edited

Legend:

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

    r3cdaa7f rc280d7e  
    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        }
    7072
    7173        return EOK;
     
    7476/** DDF interface of the child - USB functions. */
    7577static usb_iface_t child_usb_iface = {
    76         .get_my_device_handle = usb_iface_device_handle,
    77         .get_my_interface = usb_iface_iface_no,
     78        .get_my_description = usb_iface_description,
    7879};
    7980
Note: See TracChangeset for help on using the changeset viewer.