Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c54b898 in mainline


Ignore:
Timestamp:
2018-01-05T16:30:46Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
b60944b
Parents:
11d4c747
git-author:
Petr Manek <petr.manek@…> (2018-01-05 16:21:03)
git-committer:
Petr Manek <petr.manek@…> (2018-01-05 16:30:46)
Message:

usbdev: refactoring

The device_rem driver callback was renamed to device_remove. Also,
a new device_removed callback was introduced. This callback will fire
after all device pipes (endpoints, internally) are unregistered from
the HC device after a call to device_remove. It is semantically
a better opportunity for the USB device driver to free resources and
join all fibrils, since endpoint unregistration will force abort all
active transfers, waking up their issuers.

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/usbmast/main.c

    r11d4c747 rc54b898  
    390390static const usb_driver_ops_t usbmast_driver_ops = {
    391391        .device_add = usbmast_device_add,
    392         .device_rem = usbmast_device_remove,
     392        .device_remove = usbmast_device_remove,
    393393        .device_gone = usbmast_device_gone,
    394394};
  • uspace/drv/bus/usb/usbdiag/main.c

    r11d4c747 rc54b898  
    186186static const usb_driver_ops_t diag_driver_ops = {
    187187        .device_add = device_add,
    188         .device_rem = device_remove,
     188        .device_remove = device_remove,
    189189        .device_gone = device_gone,
    190190        .function_online = function_online,
  • uspace/drv/bus/usb/usbflbk/main.c

    r11d4c747 rc54b898  
    6868static const usb_driver_ops_t usbfallback_driver_ops = {
    6969        .device_add = usbfallback_device_add,
    70         .device_rem = usbfallback_device_gone,
     70        .device_remove = usbfallback_device_gone,
    7171        .device_gone = usbfallback_device_gone,
    7272};
  • uspace/drv/bus/usb/usbhub/main.c

    r11d4c747 rc54b898  
    4848static const usb_driver_ops_t usb_hub_driver_ops = {
    4949        .device_add = usb_hub_device_add,
    50 //      .device_rem = usb_hub_device_remove,
     50//      .device_remove = usb_hub_device_remove,
    5151        .device_gone = usb_hub_device_gone,
    5252};
  • uspace/drv/bus/usb/usbmid/main.c

    r11d4c747 rc54b898  
    162162static const usb_driver_ops_t mid_driver_ops = {
    163163        .device_add = usbmid_device_add,
    164         .device_rem = usbmid_device_remove,
     164        .device_remove = usbmid_device_remove,
    165165        .device_gone = usbmid_device_gone,
    166166        .function_online = usbmid_function_online,
  • uspace/drv/hid/usbhid/main.c

    r11d4c747 rc54b898  
    122122 * @return Error code.
    123123 */
    124 static int usb_hid_device_rem(usb_device_t *dev)
     124static int usb_hid_device_remove(usb_device_t *dev)
    125125{
    126126        assert(dev);
     
    164164static const usb_driver_ops_t usb_hid_driver_ops = {
    165165        .device_add = usb_hid_device_add,
    166         .device_rem = usb_hid_device_rem,
     166        .device_remove = usb_hid_device_remove,
    167167        .device_gone = usb_hid_device_gone,
    168168};
  • uspace/lib/usbdev/include/usb/dev/driver.h

    r11d4c747 rc54b898  
    4545        int (*device_add)(usb_device_t *);
    4646        /** Callback when a device is about to be removed from the system. */
    47         int (*device_rem)(usb_device_t *);
     47        int (*device_remove)(usb_device_t *);
     48        /** Callback when a device has just been removed from the system (optional). */
     49        int (*device_removed)(usb_device_t *);
    4850        /** Callback when a device was removed from the system. */
    4951        int (*device_gone)(usb_device_t *);
  • uspace/lib/usbdev/src/driver.c

    r11d4c747 rc54b898  
    8585        assert(driver);
    8686        assert(driver->ops);
    87         if (driver->ops->device_rem == NULL)
     87        if (driver->ops->device_remove == NULL)
    8888                return ENOTSUP;
     89
    8990        /* Just tell the driver to stop whatever it is doing */
    9091        usb_device_t *usb_dev = ddf_dev_data_get(gen_dev);
    91         const int ret = driver->ops->device_rem(usb_dev);
     92        int ret = driver->ops->device_remove(usb_dev);
    9293        if (ret != EOK)
    9394                return ret;
     95
     96        /* Notify the driver after endpoints were unregistered. */
     97        usb_device_destroy_pipes(usb_dev);
     98        if (driver->ops->device_removed != NULL) {
     99                ret = driver->ops->device_removed(usb_dev);
     100                if (ret != EOK)
     101                        return ret;
     102        }
     103
    94104        usb_device_destroy_ddf(gen_dev);
    95105        return EOK;
Note: See TracChangeset for help on using the changeset viewer.