Changeset a14d6a7 in mainline


Ignore:
Timestamp:
2011-10-13T12:54:36Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3875af65
Parents:
eda7a4e0
Message:

usbhub: Remove +1 port_count hack

File:
1 edited

Legend:

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

    reda7a4e0 ra14d6a7  
    178178
    179179        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),
    181181            usb_hub_polling_terminated_callback, hub_dev);
    182182        if (opResult != EOK) {
     
    223223
    224224        /* 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;
    228228                if (change) {
    229229                        usb_hub_port_process_interrupt(&hub->ports[port], hub);
     
    250250
    251251        hub_dev->ports = NULL;
    252         hub_dev->port_count = -1;
     252        hub_dev->port_count = 0;
    253253        hub_dev->pending_ops_count = 0;
    254254        hub_dev->running = false;
     
    293293        hub_dev->port_count = descriptor.port_count;
    294294
    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));
    298296        if (!hub_dev->ports) {
    299297                return ENOMEM;
    300298        }
    301299
    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);
    304303        }
    305304
     
    311310                    & HUB_CHAR_POWER_PER_PORT_FLAG;
    312311
    313                 for (size_t port = 1; port <= hub_dev->port_count; ++port) {
     312                for (size_t port = 0; port < hub_dev->port_count; ++port) {
    314313                        usb_log_debug("Powering port %zu.\n", port);
    315314                        opResult = usb_hub_port_set_feature(
     
    398397                /* Over-current condition is gone, it is safe to turn the
    399398                 * 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) {
    402400                        const int opResult = usb_hub_port_set_feature(
    403401                            &hub_dev->ports[port], USB_HUB_FEATURE_PORT_POWER);
     402                        // TODO: consider power policy here
    404403                        if (opResult != EOK) {
    405404                                usb_log_warning(
     
    507506         */
    508507        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) {
    511509                        usb_hub_port_reset_fail(&hub->ports[port]);
    512510                }
Note: See TracChangeset for help on using the changeset viewer.