Changeset d46ceb2b in mainline


Ignore:
Timestamp:
2017-10-28T14:54:29Z (6 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d37514e
Parents:
40a3bfa
Message:

Modified libusbdev to forward fun_online and _offline calls to USB drivers. Added poor man's implementation of HID device removal hook.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/main.c

    r40a3bfa rd46ceb2b  
    124124static int usb_hid_device_rem(usb_device_t *dev)
    125125{
    126         // TODO: Stop device polling
    127         // TODO: Call deinit (stops autorepeat too)
    128         return ENOTSUP;
     126        assert(dev);
     127        usb_hid_dev_t *hid_dev = usb_device_data_get(dev);
     128        assert(hid_dev);
     129
     130        /* TODO: Stop device polling prior to deinit. Now it fails on endpoint error. */
     131
     132        usb_hid_deinit(hid_dev);
     133        usb_log_debug2("%s destruction complete.\n", usb_device_get_name(dev));
     134        return EOK;
    129135}
    130136
  • uspace/drv/bus/usb/usbmid/main.c

    r40a3bfa rd46ceb2b  
    147147}
    148148
     149static int usbmid_function_online(ddf_fun_t *fun)
     150{
     151        /* TODO: What if this is the control function? */
     152        return ddf_fun_online(fun);
     153}
     154
     155static int usbmid_function_offline(ddf_fun_t *fun)
     156{
     157        /* TODO: What if this is the control function? */
     158        return ddf_fun_offline(fun);
     159}
     160
    149161/** USB MID driver ops. */
    150162static const usb_driver_ops_t mid_driver_ops = {
     
    152164        .device_rem = usbmid_device_remove,
    153165        .device_gone = usbmid_device_gone,
     166        .function_online = usbmid_function_online,
     167        .function_offline = usbmid_function_offline
    154168};
    155169
  • uspace/lib/usbdev/include/usb/dev/driver.h

    r40a3bfa rd46ceb2b  
    4848        /** Callback when a device was removed from the system. */
    4949        int (*device_gone)(usb_device_t *);
     50        /** Callback asking the driver to online a specific function. */
     51        int (*function_online)(ddf_fun_t *);
     52        /** Callback asking the driver to offline a specific function. */
     53        int (*function_offline)(ddf_fun_t *);
    5054} usb_driver_ops_t;
    5155
  • uspace/lib/usbdev/src/driver.c

    r40a3bfa rd46ceb2b  
    117117}
    118118
     119/** Callback when the driver is asked to online a specific function.
     120 *
     121 * This callback is a wrapper for USB specific version of @c fun_online.
     122 *
     123 * @param gen_dev Device function structure as prepared by DDF.
     124 * @return Error code.
     125 */
     126static int generic_function_online(ddf_fun_t *fun)
     127{
     128        assert(driver);
     129        assert(driver->ops);
     130        if (driver->ops->function_online == NULL)
     131                return ENOTSUP;
     132        return driver->ops->function_online(fun);
     133}
     134
     135/** Callback when the driver is asked to offline a specific function.
     136 *
     137 * This callback is a wrapper for USB specific version of @c fun_offline.
     138 *
     139 * @param gen_dev Device function structure as prepared by DDF.
     140 * @return Error code.
     141 */
     142static int generic_function_offline(ddf_fun_t *fun)
     143{
     144        assert(driver);
     145        assert(driver->ops);
     146        if (driver->ops->function_offline == NULL)
     147                return ENOTSUP;
     148        return driver->ops->function_offline(fun);
     149}
     150
    119151static driver_ops_t generic_driver_ops = {
    120152        .dev_add = generic_device_add,
    121153        .dev_remove = generic_device_remove,
    122154        .dev_gone = generic_device_gone,
     155        .fun_online = generic_function_online,
     156        .fun_offline = generic_function_offline,
    123157};
    124158static driver_t generic_driver = {
Note: See TracChangeset for help on using the changeset viewer.