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

Changeset dfa1fc8 in mainline


Ignore:
Timestamp:
2018-01-09T14:24:15Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
8eb7095
Parents:
0eadfd1e
Message:

usbdiag: use dev_removed for data cleanup

File:
1 edited

Legend:

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

    r0eadfd1e rdfa1fc8  
    9191        }
    9292
    93         usbdiag_dev_destroy(diag_dev);
    94 
    9593        return EOK;
    9694
     
    9997}
    10098
     99static int device_cleanup(usbdiag_dev_t *diag_dev)
     100{
     101        /* TODO: Join some fibrils? */
     102
     103        /* Free memory. */
     104        usbdiag_dev_destroy(diag_dev);
     105        return EOK;
     106}
     107
     108static int device_removed(usb_device_t *dev)
     109{
     110        usb_log_info("Device '%s' removed.", usb_device_get_name(dev));
     111
     112        usbdiag_dev_t *diag_dev = usb_device_to_usbdiag_dev(dev);
     113        return device_cleanup(diag_dev);
     114}
     115
    101116static int device_gone(usb_device_t *dev)
    102117{
     118        int rc;
    103119        usb_log_info("Device '%s' gone.", usb_device_get_name(dev));
    104120
     
    106122
    107123        /* TODO: Make sure nothing is going on with the device. */
    108         /* TODO: Unregister device DDF function. */
    109         /* TODO: Remove device from list */
    110 
    111         usbdiag_dev_destroy(diag_dev);
    112 
    113         return EOK;
     124
     125        if ((rc = ddf_fun_unbind(diag_dev->fun))) {
     126                usb_log_error("Failed to unbind DDF function: %s\n", str_error(rc));
     127                goto err;
     128        }
     129
     130        return device_cleanup(diag_dev);
     131
     132err:
     133        return rc;
    114134}
    115135
     
    187207        .device_add = device_add,
    188208        .device_remove = device_remove,
     209        .device_removed = device_removed,
    189210        .device_gone = device_gone,
    190211        .function_online = function_online,
Note: See TracChangeset for help on using the changeset viewer.