Changeset dced52a in mainline


Ignore:
Timestamp:
2011-02-28T12:24:57Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86341e2, cc44f7e
Parents:
4abc304
Message:

Debug code refactoring, redundant code removed

Location:
uspace/drv/uhci-rhd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/main.c

    r4abc304 rdced52a  
    116116int main(int argc, char *argv[])
    117117{
    118         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     118        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    119119        return ddf_driver_main(&uhci_rh_driver);
    120120}
  • uspace/drv/uhci-rhd/port.c

    r4abc304 rdced52a  
    7171        port->checker = fibril_create(uhci_port_check, port);
    7272        if (port->checker == 0) {
    73                 usb_log_error(": failed to launch root hub fibril.");
     73                usb_log_error("Port(%p - %d): failed to launch root hub fibril.",
     74                    port->address, port->number);
    7475                return ENOMEM;
    7576        }
    7677        fibril_add_ready(port->checker);
    77         usb_log_debug(
    78           "Added fibril for port %d: %p.\n", number, port->checker);
     78        usb_log_debug("Port(%p - %d): Added fibril. %x\n",
     79            port->address, port->number, port->checker);
    7980        return EOK;
    8081}
     
    9293        uhci_port_t *port_instance = port;
    9394        assert(port_instance);
    94         port_status_write(port_instance->address, 0);
    95 
    96         uint64_t count = 0;
     95//      port_status_write(port_instance->address, 0);
     96
     97        unsigned count = 0;
    9798
    9899        while (1) {
     
    106107                static fibril_mutex_t dbg_mtx = FIBRIL_MUTEX_INITIALIZER(dbg_mtx);
    107108                fibril_mutex_lock(&dbg_mtx);
    108                 usb_log_debug("Port %d status at %p: 0x%04x. === %llu\n",
    109                   port_instance->number, port_instance->address, port_status, count++);
     109                usb_log_debug2("Port(%p - %d): Status: %#04x. === %u\n",
     110                  port_instance->address, port_instance->number, port_status, count++);
    110111//              print_port_status(port_status);
    111112                fibril_mutex_unlock(&dbg_mtx);
    112113
    113114                if ((port_status & STATUS_CONNECTED_CHANGED) != 0) {
    114                         usb_log_debug("Change detected on port %d: %x.\n",
    115                             port_instance->number, port_status);
     115                        usb_log_debug("Port(%p - %d): Connected change detected: %x.\n",
     116                            port_instance->address, port_instance->number, port_status);
    116117
    117118
     
    119120                            &port_instance->hc_connection);
    120121                        if (rc != EOK) {
    121                                 usb_log_error("Failed to connect to HC.");
     122                                usb_log_error("Port(%p - %d): Failed to connect to HC.",
     123                                    port_instance->address, port_instance->number);
    122124                                continue;
    123125                        }
     
    125127                        /* remove any old device */
    126128                        if (port_instance->attached_device) {
    127                                 usb_log_debug("Removing device on port %d.\n",
    128                                     port_instance->number);
     129                                usb_log_debug("Port(%p - %d): Removing device.\n",
     130                                    port_instance->address, port_instance->number);
    129131                                uhci_port_remove_device(port_instance);
    130132                        }
     
    136138                                /* ack changes by writing one to WC bits */
    137139                                port_status_write(port_instance->address, port_status);
    138                                 usb_log_debug("Change status ack on port %d.\n",
    139                                                 port_instance->number);
     140                                usb_log_debug("Port(%p - %d): Change status ACK.\n",
     141                                                port_instance->address, port_instance->number);
    140142                        }
    141143
     
    143145                            &port_instance->hc_connection);
    144146                        if (rc != EOK) {
    145                                 usb_log_error("Failed to disconnect from HC.");
     147                                usb_log_error("Port(%p - %d): Failed to disconnect from HC.",
     148                                    port_instance->address, port_instance->number);
    146149                        }
    147150                }
     
    160163        uhci_port_t *port = (uhci_port_t *) arg;
    161164
    162         usb_log_debug("new_device_enable_port(%d)\n", port->number);
     165        usb_log_debug2("Port(%p - %d): new_device_enable_port.\n",
     166            port->address, port->number);
    163167
    164168        /*
     
    173177         */
    174178        {
    175                 usb_log_debug("Reset Signal start on port %d.\n",
    176                     port->number);
     179                usb_log_debug("Port(%p - %d): Reset Signal start.\n",
     180                    port->address, port->number);
    177181                port_status_t port_status =
    178182                        port_status_read(port->address);
     
    184188                port_status &= ~STATUS_IN_RESET;
    185189                port_status_write(port->address, port_status);
    186                 usb_log_debug("Reset Signal stop on port %d.\n",
    187                     port->number);
     190                usb_log_debug("Port(%p - %d): Reset Signal stop.\n",
     191                    port->address, port->number);
    188192        }
    189193
     
    200204        assert(usb_hc_connection_is_opened(&port->hc_connection));
    201205
    202         usb_log_info("Detected new device on port %u.\n", port->number);
     206        usb_log_info("Port(%p-%d): Detected new device.\n",
     207            port->address, port->number);
    203208
    204209        usb_address_t dev_addr;
     
    209214
    210215        if (rc != EOK) {
    211                 usb_log_error("Failed adding new device on port %u: %s.\n",
    212                     port->number, str_error(rc));
     216                usb_log_error("Port(%p-%d): Failed(%d) adding new device: %s.\n",
     217                    port->address, port->number, rc, str_error(rc));
    213218                uhci_port_set_enabled(port, false);
    214219                return rc;
    215220        }
    216221
    217         usb_log_info("New device on port %u has address %d (handle %zu).\n",
    218             port->number, dev_addr, port->attached_device);
     222        usb_log_info("Port(%p-%d): New device has address %d (handle %zu).\n",
     223            port->address, port->number, dev_addr, port->attached_device);
    219224
    220225        return EOK;
     
    224229static int uhci_port_remove_device(uhci_port_t *port)
    225230{
    226         usb_log_error("Don't know how to remove device %#x.\n",
    227                 (unsigned int)port->attached_device);
     231        usb_log_error("Port(%p-%d): Don't know how to remove device %#x.\n",
     232                port->address, port->number, (unsigned int)port->attached_device);
    228233//      uhci_port_set_enabled(port, false);
    229234        return EOK;
     
    246251        port_status_write(port->address, port_status);
    247252
    248         usb_log_info("%s port %d.\n",
    249           enabled ? "Enabled" : "Disabled", port->number);
     253        usb_log_info("Port(%p-%d): %sabled port.\n",
     254                port->address, port->number, enabled ? "En" : "Dis");
    250255        return EOK;
    251256}
  • uspace/drv/uhci-rhd/root_hub.c

    r4abc304 rdced52a  
    4646        assert(rh);
    4747        int ret;
    48         ret = usb_hc_find(rh->handle, &instance->hc_handle);
    49         usb_log_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle);
    50         if (ret != EOK) {
    51                 return ret;
    52         }
    5348
    5449        /* allow access to root hub registers */
    5550        assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT == size);
    5651        port_status_t *regs;
    57         ret = pio_enable(
    58           addr, sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT, (void**)&regs);
     52        ret = pio_enable(addr, size, (void**)&regs);
    5953
    6054        if (ret < 0) {
     
    6761        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
    6862                /* mind pointer arithmetics */
    69                 int ret = uhci_port_init(
     63                ret = uhci_port_init(
    7064                  &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh);
    7165                if (ret != EOK) {
Note: See TracChangeset for help on using the changeset viewer.