Changeset a83e138 in mainline for uspace/drv/usbhub/usbhub.c


Ignore:
Timestamp:
2011-03-18T14:43:09Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a7528a16
Parents:
b495a93
Message:

sollution for bug 138 (deadlock caused by incorrect asking for default address)

File:
1 edited

Legend:

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

    rb495a93 ra83e138  
    233233        result->port_count = -1;
    234234        result->device = device;
     235        result->is_default_address_used = false;
    235236
    236237        //result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     
    377378
    378379/**
     380 * release default address used by given hub
     381 *
     382 * Also unsets hub->is_default_address_used. Convenience wrapper function.
     383 * @note hub->connection MUST be open for communication
     384 * @param hub hub representation
     385 * @return error code
     386 */
     387static int usb_hub_release_default_address(usb_hub_info_t * hub){
     388        int opResult = usb_hc_release_default_address(&hub->connection);
     389        if(opResult!=EOK){
     390                usb_log_error("could not release default address, errno %d",opResult);
     391                return opResult;
     392        }
     393        hub->is_default_address_used = false;
     394        return EOK;
     395}
     396
     397/**
    379398 * Reset the port with new device and reserve the default address.
    380399 * @param hc
     
    384403static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
    385404                bool isLowSpeed) {
     405        //if this hub already uses default address, it cannot request it once more
     406        if(hub->is_default_address_used) return;
     407
    386408        usb_device_request_setup_packet_t request;
    387409        int opResult;
     
    397419                return;
    398420        }
     421        hub->is_default_address_used = true;
    399422        //reset port
    400423        usb_hub_set_reset_port_request(&request, port);
     
    407430                usb_log_error("something went wrong when reseting a port %d",opResult);
    408431                //usb_hub_release_default_address(hc);
    409                 usb_hc_release_default_address(&hub->connection);
     432                usb_hub_release_default_address(hub);
    410433        }
    411434}
     
    427450        if (opResult != EOK) {
    428451                usb_log_error("failed to clear port reset feature");
    429                 usb_hc_release_default_address(&hub->connection);
     452                usb_hub_release_default_address(hub);
    430453                return;
    431454        }
     
    453476                usb_log_error("failed to get free USB address");
    454477                opResult = new_device_address;
    455                 usb_hc_release_default_address(&hub->connection);
     478                usb_hub_release_default_address(hub);
    456479                return;
    457480        }
     
    464487        if (opResult != EOK) {
    465488                usb_log_error("could not set address for new device %d",opResult);
    466                 usb_hc_release_default_address(&hub->connection);
     489                usb_hub_release_default_address(hub);
    467490                return;
    468491        }
     
    470493
    471494        //opResult = usb_hub_release_default_address(hc);
    472         opResult = usb_hc_release_default_address(&hub->connection);
     495        opResult = usb_hub_release_default_address(hub);
    473496        if(opResult!=EOK){
    474497                return;
     
    529552                usb_log_warning("this is strange, disconnected device had no address");
    530553                //device was disconnected before it`s port was reset - return default address
    531                 //usb_drv_release_default_address(hc);
    532                 usb_hc_release_default_address(&hub->connection);
     554                usb_hub_release_default_address(hub);
    533555        }
    534556}
Note: See TracChangeset for help on using the changeset viewer.