Changeset 0212751 in mainline for uspace/drv/bus/usb/usbhub/usbhub.c
- Timestamp:
- 2011-09-23T19:06:37Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aefa0d5
- Parents:
- 4559d89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
r4559d89 r0212751 170 170 usb_log_debug("hub_port_changes_callback\n"); 171 171 usb_hub_info_t *hub = arg; 172 173 /* FIXME: check that we received enough bytes. */ 172 assert(hub); 173 174 /* It is an error condition if we didn't receive enough data */ 174 175 if (change_bitmap_size == 0) { 175 goto leave;176 return false; 176 177 } 177 178 … … 187 188 const bool change = (change_bitmap[port / 8] >> (port % 8)) & 1; 188 189 if (change) { 189 usb_hub_port_process_interrupt( hub, port);190 usb_hub_port_process_interrupt(&hub->ports[port], hub); 190 191 } 191 192 } 192 leave:193 /* FIXME: proper interval. */194 // TODO Interval should be handled by USB HC scheduler not here195 async_usleep(1000 * 250);196 197 193 return true; 198 194 } … … 256 252 hub_info->port_count = descriptor.port_count; 257 253 258 // TODO Why +1 ?254 // TODO: +1 hack is no longer necessary 259 255 hub_info->ports = 260 256 malloc(sizeof(usb_hub_port_t) * (hub_info->port_count + 1)); … … 349 345 { 350 346 if (status & USB_HUB_STATUS_OVER_CURRENT) { 351 /* Over-current detected on one or all ports, 352 * switch them all off to prevent damage. */ 353 //TODO Consider ganged power switching here. 354 //TODO Hub should have turned the ports off already, 355 //this is redundant. 356 size_t port; 357 for (port = 1; port <= hub_info->port_count; ++port) { 358 const int opResult = usb_hub_port_clear_feature( 359 &hub_info->ports[port], USB_HUB_FEATURE_PORT_POWER); 360 if (opResult != EOK) { 361 usb_log_warning( 362 "HUB OVER-CURRENT: Cannot power off port" 363 " %d: %s\n", 364 port, str_error(opResult)); 365 } 366 } 347 /* Hub should remove power from all ports if it detects OC */ 348 usb_log_warning("Detected hub over-current condition, " 349 "all ports should be powered off."); 367 350 } else { 368 351 /* Over-current condition is gone, it is safe to turn the … … 379 362 } 380 363 } 364 } 365 const int opResult = usb_request_clear_feature( 366 &hub_info->usb_device->ctrl_pipe, USB_REQUEST_TYPE_CLASS, 367 USB_REQUEST_RECIPIENT_DEVICE, 368 USB_HUB_FEATURE_C_HUB_LOCAL_POWER, 0); 369 if (opResult != EOK) { 370 usb_log_error( 371 "Failed to clear hub over-current change flag: %s.\n", 372 str_error(opResult)); 381 373 } 382 374 }
Note:
See TracChangeset
for help on using the changeset viewer.