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


Ignore:
Timestamp:
2013-01-27T15:39:10Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2745176
Parents:
0eb2a0f
Message:

usbmid: Use initialized parent to get address and hc handle.

Remove forwarding helpers from libusb.
Remove unused headers.

File:
1 edited

Legend:

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

    r0eb2a0f r4ca778b  
    3939#include <stdlib.h>
    4040#include <usb_iface.h>
    41 #include <usb/ddfiface.h>
    4241#include <usb/dev/pipes.h>
    4342#include <usb/classes/classes.h>
    4443#include <usb/dev/recognise.h>
    4544#include "usbmid.h"
     45/** Get host controller handle by calling the parent usb_device_t.
     46 *
     47 * @param[in] fun Device function the operation is running on.
     48 * @param[out] handle Storage for the host controller handle.
     49 * @return Error code.
     50 */
     51static int usb_iface_device_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
     52{
     53        assert(handle);
     54        assert(fun);
     55        usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));
     56        assert(usb_dev);
     57        *handle = usb_device_hc_handle(usb_dev);
     58        return EOK;
     59}
     60
     61/** Get USB device address by calling the parent usb_device_t.
     62 *
     63 * @param[in] fun Device function the operation is running on.
     64 * @param[in] handle Devman handle of USB device we want address of.
     65 * @param[out] address Storage for USB address of device with handle @p handle.
     66 * @return Error code.
     67 */
     68static int usb_iface_device_address(ddf_fun_t *fun, usb_address_t *address)
     69{
     70        assert(address);
     71        assert(fun);
     72        usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));
     73        assert(usb_dev);
     74        *address = usb_device_address(usb_dev);
     75        return EOK;
     76}
    4677
    4778/** Callback for DDF USB interface. */
    48 static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no)
     79static int usb_iface_iface(ddf_fun_t *fun, int *iface_no)
    4980{
    5081        usbmid_interface_t *iface = ddf_fun_data_get(fun);
     
    6091/** DDF interface of the child - interface function. */
    6192static usb_iface_t child_usb_iface = {
    62         .get_hc_handle = usb_iface_get_hc_handle_device_impl,
    63         .get_my_address = usb_iface_get_my_address_forward_impl,
    64         .get_my_interface = usb_iface_get_interface_impl,
     93        .get_hc_handle = usb_iface_device_hc_handle,
     94        .get_my_address = usb_iface_device_address,
     95        .get_my_interface = usb_iface_iface,
    6596};
    6697
Note: See TracChangeset for help on using the changeset viewer.