Changeset 8b71f3e in mainline for uspace/drv/bus/usb/usbhub/usbhub.c
- Timestamp:
- 2018-01-14T21:16:03Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 17c1d9db
- Parents:
- edc51615
- git-author:
- Petr Manek <petr.manek@…> (2018-01-14 21:16:00)
- git-committer:
- Petr Manek <petr.manek@…> (2018-01-14 21:16:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
redc51615 r8b71f3e 161 161 162 162 /* Start hub operation. */ 163 const usb_device_polling_config_t config = { 164 .debug = 1, 165 .auto_clear_halt = true, 166 .delay = -1, 167 .max_failures = 3, 168 .on_data = hub_port_changes_callback, 169 .on_polling_end = usb_hub_polling_terminated_callback, 170 .on_error = usb_hub_polling_error_callback, 171 .arg = hub_dev, 172 }; 173 174 usb_endpoint_mapping_t *epm = 175 usb_device_get_mapped_ep_desc(hub_dev->usb_device, 163 usb_polling_t *polling = &hub_dev->polling; 164 opResult = usb_polling_init(polling); 165 if (opResult != EOK) { 166 ddf_fun_unbind(hub_dev->hub_fun); 167 ddf_fun_destroy(hub_dev->hub_fun); 168 usb_log_error("Failed to initialize polling fibril: %s.\n", 169 str_error(opResult)); 170 return opResult; 171 } 172 173 polling->device = hub_dev->usb_device; 174 polling->ep_mapping = usb_device_get_mapped_ep_desc(hub_dev->usb_device, 176 175 &hub_status_change_endpoint_description); 177 opResult = usb_device_poll(hub_dev->usb_device, epm, &config, 178 ((hub_dev->port_count + 1 + 7) / 8), &hub_dev->polling); 179 176 polling->request_size = ((hub_dev->port_count + 1 + 7) / 8); 177 polling->buffer = malloc(polling->request_size); 178 polling->on_data = hub_port_changes_callback; 179 polling->on_polling_end = usb_hub_polling_terminated_callback; 180 polling->on_error = usb_hub_polling_error_callback; 181 polling->arg = hub_dev; 182 183 opResult = usb_polling_start(polling); 180 184 if (opResult != EOK) { 181 185 /* Function is already bound */ 186 free(polling->buffer); 182 187 ddf_fun_unbind(hub_dev->hub_fun); 183 188 ddf_fun_destroy(hub_dev->hub_fun); … … 186 191 return opResult; 187 192 } 193 188 194 hub_dev->running = true; 189 195 usb_log_info("Controlling hub '%s' (%p: %zu ports).\n", … … 197 203 { 198 204 assert(!hub->running); 205 206 free(hub->polling.buffer); 207 usb_polling_fini(&hub->polling); 199 208 200 209 for (size_t port = 0; port < hub->port_count; ++port) { … … 233 242 usb_log_info("(%p) USB hub removed, joining polling fibril.", hub); 234 243 235 /* Join polling fibril . */236 usb_ device_poll_join(hub->polling);244 /* Join polling fibril (ignoring error code). */ 245 usb_polling_join(&hub->polling); 237 246 usb_log_info("(%p) USB hub polling stopped, freeing memory.", hub); 238 247 … … 254 263 usb_log_info("(%p) USB hub gone, joining polling fibril.", hub); 255 264 256 /* Join polling fibril . */257 usb_ device_poll_join(hub->polling);265 /* Join polling fibril (ignoring error code). */ 266 usb_polling_join(&hub->polling); 258 267 usb_log_info("(%p) USB hub polling stopped, freeing memory.", hub); 259 268
Note:
See TracChangeset
for help on using the changeset viewer.