Changes in uspace/drv/bus/usb/usbmid/main.c [a821f05:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/main.c
ra821f05 rb7fd2a0 51 51 static errno_t usbmid_device_add(usb_device_t *dev) 52 52 { 53 usb_log_info("Taking care of new MID `%s'. ", usb_device_get_name(dev));53 usb_log_info("Taking care of new MID `%s'.\n", usb_device_get_name(dev)); 54 54 55 55 return usbmid_explore_device(dev); 56 }57 58 static errno_t destroy_interfaces(usb_mid_t *usb_mid)59 {60 errno_t ret = EOK;61 62 while (!list_empty(&usb_mid->interface_list)) {63 link_t *item = list_first(&usb_mid->interface_list);64 list_remove(item);65 66 usbmid_interface_t *iface = usbmid_interface_from_link(item);67 68 const errno_t pret = usbmid_interface_destroy(iface);69 if (pret != EOK) {70 usb_log_error("Failed to remove child `%s': %s",71 ddf_fun_get_name(iface->fun), str_error(pret));72 ret = pret;73 }74 }75 76 return ret;77 56 } 78 57 … … 91 70 errno_t ret = ddf_fun_unbind(usb_mid->ctl_fun); 92 71 if (ret != EOK) { 93 usb_log_error("Failed to unbind USB MID ctl function: %s. ",72 usb_log_error("Failed to unbind USB MID ctl function: %s.\n", 94 73 str_error(ret)); 95 74 return ret; … … 98 77 99 78 /* Remove all children */ 100 list_foreach(usb_mid->interface_list, link, usbmid_interface_t, iface) { 101 usb_log_info("Removing child `%s'.", 79 while (!list_empty(&usb_mid->interface_list)) { 80 link_t *item = list_first(&usb_mid->interface_list); 81 list_remove(item); 82 83 usbmid_interface_t *iface = usbmid_interface_from_link(item); 84 85 usb_log_info("Removing child `%s'.\n", 102 86 ddf_fun_get_name(iface->fun)); 103 87 104 /* Tell the child to go off line. */88 /* Tell the child to go off-line. */ 105 89 errno_t pret = ddf_fun_offline(iface->fun); 106 90 if (pret != EOK) { 107 usb_log_warning("Failed to turn off child `%s': %s ",91 usb_log_warning("Failed to turn off child `%s': %s\n", 108 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", 100 ddf_fun_get_name(iface->fun), str_error(pret)); 101 ret = pret; 109 102 } 110 103 } 111 112 return destroy_interfaces(usb_mid); 104 return ret; 113 105 } 114 106 … … 124 116 assert(usb_mid); 125 117 126 usb_log_info("USB MID gone: `%s'. ", usb_device_get_name(dev));118 usb_log_info("USB MID gone: `%s'.\n", usb_device_get_name(dev)); 127 119 128 120 /* Remove ctl function */ 129 121 errno_t ret = ddf_fun_unbind(usb_mid->ctl_fun); 130 122 if (ret != EOK) { 131 usb_log_error("Failed to unbind USB MID ctl function: %s. ",123 usb_log_error("Failed to unbind USB MID ctl function: %s.\n", 132 124 str_error(ret)); 133 125 return ret; … … 135 127 ddf_fun_destroy(usb_mid->ctl_fun); 136 128 137 /* Destroy children and tell their drivers they are gone. */ 138 return destroy_interfaces(usb_mid); 139 } 129 /* Now remove all other functions */ 130 while (!list_empty(&usb_mid->interface_list)) { 131 link_t *item = list_first(&usb_mid->interface_list); 132 list_remove(item); 140 133 141 static errno_t usbmid_function_online(ddf_fun_t *fun) 142 { 143 usb_device_t *usb_dev = ddf_dev_data_get(ddf_fun_get_dev(fun)); 144 usb_mid_t *usb_mid = usb_device_data_get(usb_dev); 145 if (fun == usb_mid->ctl_fun) 146 return ENOTSUP; 134 usbmid_interface_t *iface = usbmid_interface_from_link(item); 147 135 148 return ddf_fun_online(fun);149 } 136 usb_log_info("Child `%s' is gone.\n", 137 ddf_fun_get_name(iface->fun)); 150 138 151 static errno_t usbmid_function_offline(ddf_fun_t *fun) 152 {153 usb_device_t *usb_dev = ddf_dev_data_get(ddf_fun_get_dev(fun));154 usb_mid_t *usb_mid = usb_device_data_get(usb_dev);155 if (fun == usb_mid->ctl_fun)156 return ENOTSUP;157 158 return ddf_fun_offline(fun);139 const errno_t pret = usbmid_interface_destroy(iface); 140 if (pret != EOK) { 141 usb_log_error("Failed to remove child `%s': %s\n", 142 ddf_fun_get_name(iface->fun), str_error(pret)); 143 ret = pret; 144 } 145 } 146 return ret; 159 147 } 160 148 … … 162 150 static const usb_driver_ops_t mid_driver_ops = { 163 151 .device_add = usbmid_device_add, 164 .device_rem ove= usbmid_device_remove,152 .device_rem = usbmid_device_remove, 165 153 .device_gone = usbmid_device_gone, 166 .function_online = usbmid_function_online,167 .function_offline = usbmid_function_offline168 154 }; 169 155
Note:
See TracChangeset
for help on using the changeset viewer.