Changeset a14d6a7 in mainline
- Timestamp:
- 2011-10-13T12:54:36Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3875af65
- Parents:
- eda7a4e0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
reda7a4e0 ra14d6a7 178 178 179 179 opResult = usb_device_auto_poll(hub_dev->usb_device, 0, 180 hub_port_changes_callback, ((hub_dev->port_count + 1 ) / 8) + 1,180 hub_port_changes_callback, ((hub_dev->port_count + 1 + 8) / 8), 181 181 usb_hub_polling_terminated_callback, hub_dev); 182 182 if (opResult != EOK) { … … 223 223 224 224 /* N + 1 bit indicates change on port N */ 225 size_t port = 1;226 for (; port < hub->port_count + 1; port++) {227 const bool change = (change_bitmap[ port / 8] >> (port % 8)) & 1;225 for (size_t port = 0; port < hub->port_count + 1; port++) { 226 const size_t bit = port + 1; 227 const bool change = (change_bitmap[bit / 8] >> (bit % 8)) & 1; 228 228 if (change) { 229 229 usb_hub_port_process_interrupt(&hub->ports[port], hub); … … 250 250 251 251 hub_dev->ports = NULL; 252 hub_dev->port_count = -1;252 hub_dev->port_count = 0; 253 253 hub_dev->pending_ops_count = 0; 254 254 hub_dev->running = false; … … 293 293 hub_dev->port_count = descriptor.port_count; 294 294 295 // TODO: +1 hack is no longer necessary 296 hub_dev->ports = 297 calloc(hub_dev->port_count + 1, sizeof(usb_hub_port_t)); 295 hub_dev->ports = calloc(hub_dev->port_count, sizeof(usb_hub_port_t)); 298 296 if (!hub_dev->ports) { 299 297 return ENOMEM; 300 298 } 301 299 302 for (size_t port = 1; port < hub_dev->port_count + 1; ++port) { 303 usb_hub_port_init(&hub_dev->ports[port], port, control_pipe); 300 for (size_t port = 0; port < hub_dev->port_count; ++port) { 301 usb_hub_port_init( 302 &hub_dev->ports[port], port + 1, control_pipe); 304 303 } 305 304 … … 311 310 & HUB_CHAR_POWER_PER_PORT_FLAG; 312 311 313 for (size_t port = 1; port <=hub_dev->port_count; ++port) {312 for (size_t port = 0; port < hub_dev->port_count; ++port) { 314 313 usb_log_debug("Powering port %zu.\n", port); 315 314 opResult = usb_hub_port_set_feature( … … 398 397 /* Over-current condition is gone, it is safe to turn the 399 398 * ports on. */ 400 size_t port; 401 for (port = 1; port <= hub_dev->port_count; ++port) { 399 for (size_t port = 0; port < hub_dev->port_count; ++port) { 402 400 const int opResult = usb_hub_port_set_feature( 403 401 &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER); 402 // TODO: consider power policy here 404 403 if (opResult != EOK) { 405 404 usb_log_warning( … … 507 506 */ 508 507 if (hub->pending_ops_count > 0) { 509 size_t port; 510 for (port = 0; port < hub->port_count; port++) { 508 for (size_t port = 0; port < hub->port_count; ++port) { 511 509 usb_hub_port_reset_fail(&hub->ports[port]); 512 510 }
Note:
See TracChangeset
for help on using the changeset viewer.