Changeset f2962621 in mainline for uspace/drv/usbhub/utils.c


Ignore:
Timestamp:
2010-12-17T10:14:01Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6e5dc07
Parents:
9223dc5c (diff), 11658b64 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

File:
1 edited

Legend:

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

    r9223dc5c rf2962621  
    506506                int hc, uint16_t port, usb_target_t target) {
    507507
    508         usb_device_request_setup_packet_t request;
    509508        int opResult;
    510509        printf("[usb_hub] finalizing add device\n");
    511         usb_address_t new_device_address =
    512                         usb_drv_request_address(hc);
    513         usb_hub_set_set_address_request
    514                         (&request, new_device_address);
    515         opResult = usb_drv_sync_control_write(
    516                         hc, target,
    517                         &request,
    518                         NULL, 0
    519                         );
     510        opResult = usb_hub_clear_port_feature(hc, target.address,
     511            port, USB_HUB_FEATURE_C_PORT_RESET);
     512        if (opResult != EOK) {
     513                goto release;
     514        }
     515
     516        /* Request address at from host controller. */
     517        usb_address_t new_device_address = usb_drv_request_address(hc);
     518        if (new_device_address < 0) {
     519                printf("[usb_hub] failed to get free USB address\n");
     520                opResult = new_device_address;
     521                goto release;
     522        }
     523        printf("[usb_hub] setting new address\n");
     524        opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
     525            new_device_address);
     526
    520527        if (opResult != EOK) {
    521528                printf("[usb_hub] could not set address for new device\n");
    522                 //will retry later...
    523                 return;
    524         }
    525 
     529                goto release;
     530        }
     531
     532release:
     533        printf("[usb_hub] releasing default address\n");
    526534        usb_drv_release_default_address(hc);
     535        if (opResult != EOK) {
     536                return;
     537        }
    527538
    528539        devman_handle_t child_handle;
    529540        opResult = usb_drv_register_child_in_devman(hc, hub->device,
    530         new_device_address, &child_handle);
     541            new_device_address, &child_handle);
    531542        if (opResult != EOK) {
    532543                printf("[usb_hub] could not start driver for new device \n");
     
    541552                return;
    542553        }
    543         printf("[usb_hub] new device address %d, handle %d\n",
     554        printf("[usb_hub] new device address %d, handle %zu\n",
    544555            new_device_address, child_handle);
    545         sleep(60);
    546556       
    547557}
     
    620630        //something connected/disconnected
    621631        if (usb_port_connect_change(&status)) {
     632                opResult = usb_hub_clear_port_feature(hc, target.address,
     633                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
     634                // TODO: check opResult
    622635                if (usb_port_dev_connected(&status)) {
    623636                        printf("[usb_hub] some connection changed\n");
     
    629642        //port reset
    630643        if (usb_port_reset_completed(&status)) {
    631                 printf("[usb_hub] finalizing add device\n");
     644                printf("[usb_hub] port reset complete\n");
    632645                if (usb_port_enabled(&status)) {
    633646                        usb_hub_finalize_add_device(hub, hc, port, target);
     
    670683                        lst_item != &usb_hub_list;
    671684                        lst_item = lst_item->next) {
    672                 printf("[usb_hub] checking hub changes\n");
    673685                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    674686                /*
     
    679691                target.address = hub_info->usb_device->address;
    680692                target.endpoint = 1;/// \TODO get from endpoint descriptor
    681                 printf("checking changes for hub at addr %d \n",target.address);
     693                printf("[usb_hub] checking changes for hub at addr %d\n",
     694                    target.address);
    682695
    683696                size_t port_count = hub_info->port_count;
Note: See TracChangeset for help on using the changeset viewer.