Changeset 5823525e in mainline
- Timestamp:
- 2018-01-12T11:01:38Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 46c5dc2
- Parents:
- bb1e968
- git-author:
- Petr Manek <petr.manek@…> (2018-01-12 11:01:33)
- git-committer:
- Petr Manek <petr.manek@…> (2018-01-12 11:01:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/main.c
rbb1e968 r5823525e 77 77 78 78 /* Remove all children */ 79 list_foreach(usb_mid->interface_list, link, usbmid_interface_t, iface) { 80 usb_log_info("Removing child `%s'.\n", 81 ddf_fun_get_name(iface->fun)); 82 83 /* Tell the child to go offline. */ 84 int pret = ddf_fun_offline(iface->fun); 85 if (pret != EOK) { 86 usb_log_warning("Failed to turn off child `%s': %s\n", 87 ddf_fun_get_name(iface->fun), str_error(pret)); 88 ret = pret; 89 } 90 } 91 92 return ret; 93 } 94 95 static int destroy_interfaces(usb_mid_t *usb_mid) 96 { 97 int ret = EOK; 98 79 99 while (!list_empty(&usb_mid->interface_list)) { 80 100 link_t *item = list_first(&usb_mid->interface_list); … … 83 103 usbmid_interface_t *iface = usbmid_interface_from_link(item); 84 104 85 usb_log_info("Removing child `%s'.\n", 86 ddf_fun_get_name(iface->fun)); 87 88 /* Tell the child to go off-line. */ 89 int pret = ddf_fun_offline(iface->fun); 105 const int pret = usbmid_interface_destroy(iface); 90 106 if (pret != EOK) { 91 usb_log_warning("Failed to turn off child `%s': %s\n", 92 ddf_fun_get_name(iface->fun), str_error(pret)); 93 ret = pret; 94 } 95 96 /* Now remove the child. */ 97 pret = usbmid_interface_destroy(iface); 98 if (pret != EOK) { 99 usb_log_error("Failed to destroy child `%s': %s\n", 107 usb_log_error("Failed to remove child `%s': %s\n", 100 108 ddf_fun_get_name(iface->fun), str_error(pret)); 101 109 ret = pret; 102 110 } 103 111 } 112 104 113 return ret; 105 114 } … … 107 116 static int usbmid_device_removed(usb_device_t *dev) 108 117 { 109 // TODO: Implement me! 110 return EOK; 118 assert(dev); 119 usb_mid_t *usb_mid = usb_device_data_get(dev); 120 assert(usb_mid); 121 122 /* Children are offline. Destroy them now. */ 123 return destroy_interfaces(usb_mid); 111 124 } 112 125 … … 133 146 ddf_fun_destroy(usb_mid->ctl_fun); 134 147 135 /* Now remove all other functions */ 136 while (!list_empty(&usb_mid->interface_list)) { 137 link_t *item = list_first(&usb_mid->interface_list); 138 list_remove(item); 139 140 usbmid_interface_t *iface = usbmid_interface_from_link(item); 141 142 usb_log_info("Child `%s' is gone.\n", 143 ddf_fun_get_name(iface->fun)); 144 145 const int pret = usbmid_interface_destroy(iface); 146 if (pret != EOK) { 147 usb_log_error("Failed to remove child `%s': %s\n", 148 ddf_fun_get_name(iface->fun), str_error(pret)); 149 ret = pret; 150 } 151 } 152 return ret; 148 /* Destroy children and tell their drivers they are gone. */ 149 return destroy_interfaces(usb_mid); 153 150 } 154 151
Note:
See TracChangeset
for help on using the changeset viewer.