Changeset e98e5fc in mainline
- Timestamp:
- 2015-07-01T03:51:38Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e6d7df1
- Parents:
- b303275
- Location:
- uspace/drv/bus/usb/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/main.c
rb303275 re98e5fc 68 68 printf(NAME ": HelenOS USB hub driver.\n"); 69 69 log_init(NAME); 70 logctl_set_log_level(NAME, LVL_ DEBUG);70 logctl_set_log_level(NAME, LVL_NOTE); 71 71 return usb_driver_main(&usb_hub_driver); 72 72 } -
uspace/drv/bus/usb/usbhub/port.c
rb303275 re98e5fc 55 55 static int usb_hub_port_device_gone(usb_hub_port_t *port, usb_hub_dev_t *hub); 56 56 static void usb_hub_port_reset_completed(usb_hub_port_t *port, 57 usb_ port_status_t status);57 usb_hub_dev_t *hub, usb_port_status_t status); 58 58 static int get_port_status(usb_hub_port_t *port, usb_port_status_t *status); 59 59 static int add_device_phase1_worker_fibril(void *arg); … … 243 243 /* Port reset, set on port reset complete. */ 244 244 if (status & USB_HUB_PORT_C_STATUS_RESET) { 245 usb_hub_port_reset_completed(port, status);245 usb_hub_port_reset_completed(port, hub, status); 246 246 } 247 247 … … 282 282 * @param status Port status mask 283 283 */ 284 void usb_hub_port_reset_completed(usb_hub_port_t *port, 284 void usb_hub_port_reset_completed(usb_hub_port_t *port, usb_hub_dev_t *hub, 285 285 usb_port_status_t status) 286 286 { … … 292 292 if (enabled) { 293 293 port->reset_status = RESET_OK; 294 usb_log_debug("Port %u reset complete.\n", port->port_number); 294 usb_log_debug("(%p-%u): Port reset complete.\n", hub, 295 port->port_number); 295 296 } else { 296 297 port->reset_status = RESET_FAIL; 297 usb_log_warning(" Port %u reset complete but port not enabled.",298 port->port_number);298 usb_log_warning("(%p-%u): Port reset complete but port not " 299 "enabled.", hub, port->port_number); 299 300 } 300 301 fibril_condvar_broadcast(&port->reset_cv); … … 304 305 int rc = usb_hub_port_clear_feature(port, USB_HUB_FEATURE_C_PORT_RESET); 305 306 if (rc != EOK) { 306 usb_log_error(" Failed to clear port %ureset change: %s.",307 port->port_number, str_error(rc));307 usb_log_error("(%p-%u): Failed to clear port reset change: %s.", 308 hub, port->port_number, str_error(rc)); 308 309 } 309 310 } … … 349 350 } 350 351 351 static int port_enable(usb_hub_port_t *port, bool enable)352 static int port_enable(usb_hub_port_t *port, usb_hub_dev_t *hub, bool enable) 352 353 { 353 354 if (enable) { … … 355 356 usb_hub_port_set_feature(port, USB_HUB_FEATURE_PORT_RESET); 356 357 if (rc != EOK) { 357 usb_log_error(" Port reset failed: %s.\n",358 str_error(rc));358 usb_log_error("(%p-%u): Port reset failed: %s.\n", 359 hub, port->port_number, str_error(rc)); 359 360 return rc; 360 361 } … … 417 418 port->port_number); 418 419 /* Reset port */ 419 ret = port_enable(port, true);420 ret = port_enable(port, hub, true); 420 421 if (ret != EOK) { 421 usb_log_error("Failed to reset port %u\n", port->port_number); 422 usb_log_error("(%p-%u): Failed to reset port.", hub, 423 port->port_number); 422 424 if (usb_release_default_address(exch) != EOK) 423 usb_log_warning("Failed to release default address\n"); 425 usb_log_warning("(%p-%u): Failed to release default " 426 "address.", hub, port->port_number); 424 427 ret = EIO; 425 428 goto out; … … 432 435 usb_log_error("(%p-%u): Failed to enumerate device: %s", hub, 433 436 port->port_number, str_error(ret)); 434 const int ret = port_enable(port, false);437 const int ret = port_enable(port, hub, false); 435 438 if (ret != EOK) { 436 439 usb_log_warning("(%p-%u)Failed to disable port (%s), " -
uspace/drv/bus/usb/usbhub/usbhub.c
rb303275 re98e5fc 159 159 } 160 160 hub_dev->running = true; 161 usb_log_info("Controlling hub '%s' (%zu ports).\n", 162 usb_device_get_name(hub_dev->usb_device), hub_dev->port_count); 161 usb_log_info("Controlling hub '%s' (%p: %zu ports).\n", 162 usb_device_get_name(hub_dev->usb_device), hub_dev, 163 hub_dev->port_count); 163 164 164 165 return EOK; … … 190 191 async_usleep(100000); 191 192 if (!tries--) { 192 usb_log_error("Can't remove hub, still running.\n"); 193 usb_log_error("(%p): Can't remove hub, still running.", 194 hub); 193 195 return EBUSY; 194 196 } … … 206 208 const int ret = ddf_fun_unbind(hub->hub_fun); 207 209 if (ret != EOK) { 208 usb_log_error(" Failed to unbind '%s' function: %s.\n",209 HUB_FNC_NAME, str_error(ret));210 usb_log_error("(%p) Failed to unbind '%s' function: %s.", 211 hub, HUB_FNC_NAME, str_error(ret)); 210 212 return ret; 211 213 } 212 214 ddf_fun_destroy(hub->hub_fun); 213 215 214 usb_log_info(" USB hub driver, stopped and cleaned.\n");216 usb_log_info("(%p) USB hub driver stopped and cleaned.", hub); 215 217 return EOK; 216 218 } … … 227 229 uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) 228 230 { 229 usb_log_debug("hub_port_changes_callback\n");231 // usb_log_debug("hub_port_changes_callback\n"); 230 232 usb_hub_dev_t *hub = arg; 231 233 assert(hub); … … 268 270 269 271 /* Get hub descriptor. */ 270 usb_log_debug(" Retrieving descriptor\n");272 usb_log_debug("(%p): Retrieving descriptor.", hub_dev); 271 273 usb_pipe_t *control_pipe = 272 274 usb_device_get_default_pipe(hub_dev->usb_device); … … 279 281 sizeof(usb_hub_descriptor_header_t), &received_size); 280 282 if (opResult != EOK) { 281 usb_log_error(" Failed to receive hub descriptor: %s.\n",282 str_error(opResult));283 usb_log_error("(%p): Failed to receive hub descriptor: %s.\n", 284 hub_dev, str_error(opResult)); 283 285 return opResult; 284 286 } 285 287 286 usb_log_debug("Setting port count to %d.\n", descriptor.port_count); 288 usb_log_debug("(%p): Setting port count to %d.\n", hub_dev, 289 descriptor.port_count); 287 290 hub_dev->port_count = descriptor.port_count; 288 291 … … 303 306 304 307 if (!hub_dev->power_switched) { 305 usb_log_info( 306 "Power switching not supported, ports always powered.\n");308 usb_log_info("(%p): Power switching not supported, " 309 "ports always powered.", hub_dev); 307 310 return EOK; 308 311 } 309 312 310 usb_log_info(" Hub port power switching enabled (%s).\n",313 usb_log_info("(%p): Hub port power switching enabled (%s).\n", hub_dev, 311 314 hub_dev->per_port_power ? "per port" : "ganged"); 312 315 313 316 for (size_t port = 0; port < hub_dev->port_count; ++port) { 314 usb_log_debug(" Powering port %zu.\n", port);317 usb_log_debug("(%p): Powering port %zu.", hub_dev, port); 315 318 const int ret = usb_hub_port_set_feature( 316 319 &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER); 317 320 318 321 if (ret != EOK) { 319 usb_log_error("Cannot power on port %u: %s.\n", 320 hub_dev->ports[port].port_number, str_error(ret)); 322 usb_log_error("(%p-%zu): Cannot power on port: %s.\n", 323 hub_dev, hub_dev->ports[port].port_number, 324 str_error(ret)); 321 325 } else { 322 326 if (!hub_dev->per_port_power) { 323 usb_log_debug(" Ganged power switching, "324 "one port is enough. \n");327 usb_log_debug("(%p) Ganged power switching, " 328 "one port is enough.", hub_dev); 325 329 break; 326 330 } … … 351 355 } 352 356 353 // TODO: Make sure that the cast is correct354 357 const size_t config_size = 355 358 usb_device_descriptors(usb_device)->full_config_size; … … 391 394 if (status & USB_HUB_STATUS_OVER_CURRENT) { 392 395 /* Hub should remove power from all ports if it detects OC */ 393 usb_log_warning(" Detected hub over-current condition, "394 "all ports should be powered off." );396 usb_log_warning("(%p) Detected hub over-current condition, " 397 "all ports should be powered off.", hub_dev); 395 398 return; 396 399 } … … 405 408 &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER); 406 409 if (ret != EOK) { 407 usb_log_warning(" HUB OVER-CURRENT GONE: Cannot power on"408 " po rt %u: %s\n", hub_dev->ports[port].port_number,409 str_error(ret));410 usb_log_warning("(%p-%u): HUB OVER-CURRENT GONE: Cannot" 411 " power on port: %s\n", hub_dev, 412 hub_dev->ports[port].port_number, str_error(ret)); 410 413 } else { 411 414 if (!hub_dev->per_port_power) … … 426 429 assert(hub_dev); 427 430 assert(hub_dev->usb_device); 428 usb_log_debug(" Global interrupt on a hub\n");431 usb_log_debug("(%p): Global interrupt on th hub.", hub_dev); 429 432 usb_pipe_t *control_pipe = 430 433 usb_device_get_default_pipe(hub_dev->usb_device); … … 438 441 &status, sizeof(usb_hub_status_t), &rcvd_size); 439 442 if (opResult != EOK) { 440 usb_log_error(" Could not get hub status: %s\n",443 usb_log_error("(%p): Could not get hub status: %s.", hub_dev, 441 444 str_error(opResult)); 442 445 return; 443 446 } 444 447 if (rcvd_size != sizeof(usb_hub_status_t)) { 445 usb_log_error("Received status has incorrect size\n"); 448 usb_log_error("(%p): Received status has incorrect size: " 449 "%zu != %zu", hub_dev, rcvd_size, sizeof(usb_hub_status_t)); 446 450 return; 447 451 } … … 456 460 USB_HUB_FEATURE_C_HUB_OVER_CURRENT, 0); 457 461 if (ret != EOK) { 458 usb_log_error(" Failed to clear hub over-current "459 "change flag: %s.\n", str_error(opResult));462 usb_log_error("(%p): Failed to clear hub over-current " 463 "change flag: %s.\n", hub_dev, str_error(opResult)); 460 464 } 461 465 } … … 480 484 USB_HUB_FEATURE_C_HUB_LOCAL_POWER, 0); 481 485 if (opResult != EOK) { 482 usb_log_error(" Failed to clear hub power change "483 "flag: %s.\n", str_error(ret));486 usb_log_error("(%p): Failed to clear hub power change " 487 "flag: %s.\n", hub_dev, str_error(ret)); 484 488 } 485 489 }
Note:
See TracChangeset
for help on using the changeset viewer.