Ignore:
File:
1 edited

Legend:

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

    r5153b58 r5203e256  
    4949 * @return Error code.
    5050 */
    51 static int usbmid_device_add(usb_device_t *dev)
     51static int usbmid_add_device(usb_device_t *dev)
    5252{
    5353        usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name);
     
    6565        return EOK;
    6666}
    67 /*----------------------------------------------------------------------------*/
    68 /** Callback when a MID device is about to be removed from the host.
    69  *
    70  * @param dev USB device representing the removed device.
    71  * @return Error code.
    72  */
    73 static int usbmid_device_remove(usb_device_t *dev)
    74 {
    75         assert(dev);
    76         usb_mid_t *usb_mid = dev->driver_data;
    77         assert(usb_mid);
    78 
    79         /* Remove ctl function */
    80         int ret = ddf_fun_unbind(usb_mid->ctl_fun);
    81         if (ret != EOK) {
    82                 usb_log_error("Failed to unbind USB MID ctl function: %s.\n",
    83                     str_error(ret));
    84                 return ret;
    85         }
    86         ddf_fun_destroy(usb_mid->ctl_fun);
    87 
    88         /* Remove all children */
    89         while (!list_empty(&usb_mid->interface_list)) {
    90                 link_t *item = list_first(&usb_mid->interface_list);
    91                 list_remove(item);
    92 
    93                 usbmid_interface_t *iface = usbmid_interface_from_link(item);
    94 
    95                 usb_log_info("Removing child for interface %d (%s).\n",
    96                     iface->interface_no,
    97                     usb_str_class(iface->interface->interface_class));
    98 
    99                 /* Tell the child to go off-line. */
    100                 int pret = ddf_fun_offline(iface->fun);
    101                 if (pret != EOK) {
    102                         usb_log_warning("Failed to turn off child for interface"
    103                             " %d (%s): %s\n", iface->interface_no,
    104                             usb_str_class(iface->interface->interface_class),
    105                             str_error(pret));
    106                         ret = pret;
    107                 }
    108 
    109                 /* Now remove the child. */
    110                 pret = usbmid_interface_destroy(iface);
    111                 if (pret != EOK) {
    112                         usb_log_error("Failed to destroy child for interface "
    113                             "%d (%s): %s\n", iface->interface_no,
    114                             usb_str_class(iface->interface->interface_class),
    115                             str_error(pret));
    116                         ret = pret;
    117                 }
    118         }
    119         return ret;
    120 }
    121 /*----------------------------------------------------------------------------*/
    122 /** Callback when a MID device was removed from the host.
    123  *
    124  * @param dev USB device representing the removed device.
    125  * @return Error code.
    126  */
    127 static int usbmid_device_gone(usb_device_t *dev)
    128 {
    129         assert(dev);
    130         usb_mid_t *usb_mid = dev->driver_data;
    131         assert(usb_mid);
    132 
    133         usb_log_info("USB MID gone: `%s'.\n", dev->ddf_dev->name);
    134 
    135         /* Remove ctl function */
    136         int ret = ddf_fun_unbind(usb_mid->ctl_fun);
    137         if (ret != EOK) {
    138                 usb_log_error("Failed to unbind USB MID ctl function: %s.\n",
    139                     str_error(ret));
    140                 return ret;
    141         }
    142         ddf_fun_destroy(usb_mid->ctl_fun);
    143 
    144         /* Now remove all other functions */
    145         while (!list_empty(&usb_mid->interface_list)) {
    146                 link_t *item = list_first(&usb_mid->interface_list);
    147                 list_remove(item);
    148 
    149                 usbmid_interface_t *iface = usbmid_interface_from_link(item);
    150 
    151                 usb_log_info("Child for interface %d (%s) gone.\n",
    152                     iface->interface_no,
    153                     usb_str_class(iface->interface->interface_class));
    154 
    155                 const int pret = usbmid_interface_destroy(iface);
    156                 if (pret != EOK) {
    157                         usb_log_error("Failed to remove child for interface "
    158                             "%d (%s): %s\n",
    159                             iface->interface_no,
    160                             usb_str_class(iface->interface->interface_class),
    161                             str_error(pret));
    162                         ret = pret;
    163                 }
    164         }
    165         return ret;
    166 }
    16767
    16868/** USB MID driver ops. */
    169 static const usb_driver_ops_t mid_driver_ops = {
    170         .device_add = usbmid_device_add,
    171         .device_rem = usbmid_device_remove,
    172         .device_gone = usbmid_device_gone,
     69static usb_driver_ops_t mid_driver_ops = {
     70        .add_device = usbmid_add_device,
    17371};
    17472
    17573/** USB MID driver. */
    176 static const usb_driver_t mid_driver = {
     74static usb_driver_t mid_driver = {
    17775        .name = NAME,
    17876        .ops = &mid_driver_ops,
Note: See TracChangeset for help on using the changeset viewer.