Changeset e98e5fc in mainline for uspace/drv/bus/usb/usbhub/usbhub.c


Ignore:
Timestamp:
2015-07-01T03:51:38Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6d7df1
Parents:
b303275
Message:

usbhub: Add identifier to debug messages

Add explicit debug settings (makes it easier to switch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/usbhub.c

    rb303275 re98e5fc  
    159159        }
    160160        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);
    163164
    164165        return EOK;
     
    190191                async_usleep(100000);
    191192                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);
    193195                        return EBUSY;
    194196                }
     
    206208        const int ret = ddf_fun_unbind(hub->hub_fun);
    207209        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));
    210212                return ret;
    211213        }
    212214        ddf_fun_destroy(hub->hub_fun);
    213215
    214         usb_log_info("USB hub driver, stopped and cleaned.\n");
     216        usb_log_info("(%p) USB hub driver stopped and cleaned.", hub);
    215217        return EOK;
    216218}
     
    227229    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg)
    228230{
    229         usb_log_debug("hub_port_changes_callback\n");
     231//      usb_log_debug("hub_port_changes_callback\n");
    230232        usb_hub_dev_t *hub = arg;
    231233        assert(hub);
     
    268270
    269271        /* Get hub descriptor. */
    270         usb_log_debug("Retrieving descriptor\n");
     272        usb_log_debug("(%p): Retrieving descriptor.", hub_dev);
    271273        usb_pipe_t *control_pipe =
    272274            usb_device_get_default_pipe(hub_dev->usb_device);
     
    279281            sizeof(usb_hub_descriptor_header_t), &received_size);
    280282        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));
    283285                return opResult;
    284286        }
    285287
    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);
    287290        hub_dev->port_count = descriptor.port_count;
    288291
     
    303306
    304307        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);
    307310                return EOK;
    308311        }
    309312
    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,
    311314            hub_dev->per_port_power ? "per port" : "ganged");
    312315
    313316        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);
    315318                const int ret = usb_hub_port_set_feature(
    316319                    &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER);
    317320
    318321                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));
    321325                } else {
    322326                        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);
    325329                                break;
    326330                        }
     
    351355        }
    352356
    353         // TODO: Make sure that the cast is correct
    354357        const size_t config_size =
    355358            usb_device_descriptors(usb_device)->full_config_size;
     
    391394        if (status & USB_HUB_STATUS_OVER_CURRENT) {
    392395                /* 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);
    395398                return;
    396399        }
     
    405408                    &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER);
    406409                if (ret != EOK) {
    407                         usb_log_warning("HUB OVER-CURRENT GONE: Cannot power on"
    408                             " port %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));
    410413                } else {
    411414                        if (!hub_dev->per_port_power)
     
    426429        assert(hub_dev);
    427430        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);
    429432        usb_pipe_t *control_pipe =
    430433            usb_device_get_default_pipe(hub_dev->usb_device);
     
    438441            &status, sizeof(usb_hub_status_t), &rcvd_size);
    439442        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,
    441444                    str_error(opResult));
    442445                return;
    443446        }
    444447        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));
    446450                return;
    447451        }
     
    456460                    USB_HUB_FEATURE_C_HUB_OVER_CURRENT, 0);
    457461                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));
    460464                }
    461465        }
     
    480484                    USB_HUB_FEATURE_C_HUB_LOCAL_POWER, 0);
    481485                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));
    484488                }
    485489        }
Note: See TracChangeset for help on using the changeset viewer.