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

Changeset fcdab1e in mainline


Ignore:
Timestamp:
2018-01-12T11:42:00Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
0fcccd9
Parents:
b233821
Message:

usbhid: join without defuncting the DDF node

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/usbhid/main.c

    rb233821 rfcdab1e  
    137137}
    138138
    139 /**
    140  * Callback for when a device has just been from the driver.
    141  *
    142  * @param dev Structure representing the device.
    143  * @return Error code.
    144  */
    145 static int usb_hid_device_removed(usb_device_t *dev)
    146 {
    147         assert(dev);
    148         usb_hid_dev_t *hid_dev = usb_device_data_get(dev);
    149         assert(hid_dev);
    150 
    151         usb_log_info("%s endpoints unregistered, joining polling fibril.\n", usb_device_get_name(dev));
     139static int join_and_clean(usb_device_t *dev)
     140{
     141        assert(dev);
     142        usb_hid_dev_t *hid_dev = usb_device_data_get(dev);
     143        assert(hid_dev);
    152144
    153145        /* Join polling fibril. */
     
    165157
    166158/**
     159 * Callback for when a device has just been from the driver.
     160 *
     161 * @param dev Structure representing the device.
     162 * @return Error code.
     163 */
     164static int usb_hid_device_removed(usb_device_t *dev)
     165{
     166        assert(dev);
     167        usb_hid_dev_t *hid_dev = usb_device_data_get(dev);
     168        assert(hid_dev);
     169
     170        usb_log_info("%s endpoints unregistered, joining polling fibril.\n", usb_device_get_name(dev));
     171        return join_and_clean(dev);
     172}
     173
     174/**
    167175 * Callback for removing a device from the driver.
    168176 *
     
    178186        usb_log_info("Device %s gone, joining the polling fibril.\n", usb_device_get_name(dev));
    179187        usb_hid_prepare_deinit(hid_dev);
    180 
    181         unsigned tries = 100;
    182         /* Wait for fail. */
    183         while (hid_dev->running && tries--) {
    184                 async_usleep(100000);
    185         }
    186         if (hid_dev->running) {
    187                 usb_log_error("Can't remove hid, still running.\n");
    188                 return EBUSY;
    189         }
    190 
    191         usb_hid_deinit(hid_dev);
    192         usb_log_info("%s destruction complete.\n", usb_device_get_name(dev));
    193 
    194         return EOK;
     188        return join_and_clean(dev);
    195189}
    196190
Note: See TracChangeset for help on using the changeset viewer.