Ignore:
File:
1 edited

Legend:

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

    rba5ab09 r103a3626  
    7070
    7171
    72         //printf("[usb_hub] phone to hc = %d\n", hc);
     72        dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
    7373        if (hc < 0) {
    7474                return result;
     
    7676        //get some hub info
    7777        usb_address_t addr = usb_drv_get_my_address(hc, device);
    78         dprintf(1, "address of newly created hub = %d", addr);
     78        dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);
    7979        /*if(addr<0){
    8080                //return result;
     
    8787        // get hub descriptor
    8888
    89         //printf("[usb_hub] creating serialized descriptor\n");
     89        dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton");
    9090        void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    9191        usb_hub_descriptor_t * descriptor;
    9292        size_t received_size;
    9393        int opResult;
    94         //printf("[usb_hub] starting control transaction\n");
     94        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    9595       
    9696        opResult = usb_drv_req_get_descriptor(hc, addr,
     
    100100
    101101        if (opResult != EOK) {
    102                 dprintf(1, "failed when receiving hub descriptor, badcode = %d",opResult);
     102                dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);
    103103                free(serialized_descriptor);
    104104                return result;
    105105        }
    106         //printf("[usb_hub] deserializing descriptor\n");
     106        dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");
    107107        descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
    108108        if(descriptor==NULL){
    109                 dprintf(1, "could not deserialize descriptor ");
     109                dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");
    110110                result->port_count = 1;///\TODO this code is only for debug!!!
    111111                return result;
    112112        }
    113         //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
     113        dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);
    114114        result->port_count = descriptor->ports_count;
    115115        result->attached_devs = (usb_hub_attached_device_t*)
     
    120120                result->attached_devs[i].address=0;
    121121        }
    122         //printf("[usb_hub] freeing data\n");
     122        dprintf(USB_LOG_LEVEL_DEBUG2, "freeing data");
    123123        free(serialized_descriptor);
    124124        free(descriptor->devices_removable);
     
    127127        //finish
    128128
    129         dprintf(1, "hub info created");
     129        dprintf(USB_LOG_LEVEL_INFO, "hub info created");
    130130
    131131        return result;
     
    133133
    134134int usb_add_hub_device(device_t *dev) {
    135         dprintf(1, "add_hub_device(handle=%d)", (int) dev->handle);
    136         dprintf(1, "hub device");
     135        dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle);
    137136
    138137        /*
     
    164163            &std_descriptor);
    165164        if(opResult!=EOK){
    166                 dprintf(1, "could not get device descriptor, %d",opResult);
     165                dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);
    167166                return opResult;
    168167        }
    169         dprintf(1, "hub has %d configurations",std_descriptor.configuration_count);
     168        dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count);
    170169        if(std_descriptor.configuration_count<1){
    171                 dprintf(1, "THERE ARE NO CONFIGURATIONS AVAILABLE");
     170                dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");
    172171                //shouldn`t I return?
    173172        }
     
    178177        &config_descriptor);
    179178        if(opResult!=EOK){
    180                 dprintf(1, "could not get configuration descriptor, %d",opResult);
     179                dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);
    181180                return opResult;
    182181        }
     
    186185
    187186        if (opResult != EOK) {
    188                 dprintf(1, "something went wrong when setting hub`s configuration, %d", opResult);
     187                dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult);
    189188        }
    190189
     
    193192                usb_hub_set_power_port_request(&request, port);
    194193                opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    195                 dprintf(1, "powering port %d",port);
     194                dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
    196195                if (opResult != EOK) {
    197                         dprintf(1, "something went wrong when setting hub`s %dth port", port);
     196                        dprintf(USB_LOG_LEVEL_WARNING, "something went wrong when setting hub`s %dth port", port);
    198197                }
    199198        }
     
    207206        fibril_mutex_unlock(&usb_hub_list_lock);
    208207
    209         dprintf(1, "hub info added to list");
     208        dprintf(USB_LOG_LEVEL_DEBUG, "hub info added to list");
    210209        //(void)hub_info;
    211210        usb_hub_check_hub_changes();
     
    213212       
    214213
    215         dprintf(1, "hub dev added");
    216         dprintf(1, "\taddress %d, has %d ports ",
     214        dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
     215        dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
    217216                        hub_info->usb_device->address,
    218217                        hub_info->port_count);
    219         dprintf(1, "\tused configuration %d",config_descriptor.configuration_number);
     218        dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
    220219
    221220        return EOK;
     
    238237inline static int usb_hub_release_default_address(int hc){
    239238        int opResult;
    240         dprintf(1, "releasing default address");
     239        dprintf(USB_LOG_LEVEL_INFO, "releasing default address");
    241240        opResult = usb_drv_release_default_address(hc);
    242241        if (opResult != EOK) {
    243                 dprintf(1, "failed to release default address");
     242                dprintf(USB_LOG_LEVEL_WARNING, "failed to release default address");
    244243        }
    245244        return opResult;
     
    255254        usb_device_request_setup_packet_t request;
    256255        int opResult;
    257         dprintf(1, "some connection changed");
     256        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    258257        //get default address
    259258        opResult = usb_drv_reserve_default_address(hc);
    260259        if (opResult != EOK) {
    261                 dprintf(1, "cannot assign default address, it is probably used");
     260                dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used");
    262261                return;
    263262        }
     
    270269                        );
    271270        if (opResult != EOK) {
    272                 dprintf(1, "something went wrong when reseting a port");
     271                dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port");
    273272                usb_hub_release_default_address(hc);
    274273        }
     
    285284
    286285        int opResult;
    287         dprintf(1, "finalizing add device");
     286        dprintf(USB_LOG_LEVEL_INFO, "finalizing add device");
    288287        opResult = usb_hub_clear_port_feature(hc, target.address,
    289288            port, USB_HUB_FEATURE_C_PORT_RESET);
    290289        if (opResult != EOK) {
    291                 dprintf(1, "failed to clear port reset feature");
     290                dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");
    292291                usb_hub_release_default_address(hc);
    293292                return;
     
    297296        usb_address_t new_device_address = usb_drv_request_address(hc);
    298297        if (new_device_address < 0) {
    299                 dprintf(1, "failed to get free USB address");
     298                dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address");
    300299                opResult = new_device_address;
    301300                usb_hub_release_default_address(hc);
    302301                return;
    303302        }
    304         dprintf(1, "setting new address");
     303        dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);
    305304        opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    306305            new_device_address);
    307306
    308307        if (opResult != EOK) {
    309                 dprintf(1, "could not set address for new device");
     308                dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device");
    310309                usb_hub_release_default_address(hc);
    311310                return;
     
    322321            new_device_address, &child_handle);
    323322        if (opResult != EOK) {
    324                 dprintf(1, "could not start driver for new device");
     323                dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
    325324                return;
    326325        }
     
    330329        opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
    331330        if (opResult != EOK) {
    332                 dprintf(1, "could not assign address of device in hcd");
    333                 return;
    334         }
    335         dprintf(1, "new device address %d, handle %zu",
     331                dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd");
     332                return;
     333        }
     334        dprintf(USB_LOG_LEVEL_INFO, "new device address %d, handle %zu",
    336335            new_device_address, child_handle);
    337336
     
    358357                opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
    359358                if(opResult != EOK) {
    360                         dprintf(1, "could not release address of " \
     359                        dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \
    361360                            "removed device: %d", opResult);
    362361                }
    363362                hub->attached_devs[port].address = 0;
    364363        }else{
    365                 dprintf(1, "this is strange, disconnected device had no address");
     364                dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
    366365                //device was disconnected before it`s port was reset - return default address
    367366                usb_drv_release_default_address(hc);
     
    377376static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    378377        uint16_t port, usb_address_t address) {
    379         dprintf(1, "interrupt at port %d", port);
     378        dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
    380379        //determine type of change
    381380        usb_target_t target;
     
    395394                        );
    396395        if (opResult != EOK) {
    397                 dprintf(1, "ERROR: could not get port status");
     396                dprintf(USB_LOG_LEVEL_ERROR, "ERROR: could not get port status");
    398397                return;
    399398        }
    400399        if (rcvd_size != sizeof (usb_port_status_t)) {
    401                 dprintf(1, "ERROR: received status has incorrect size");
     400                dprintf(USB_LOG_LEVEL_ERROR, "ERROR: received status has incorrect size");
    402401                return;
    403402        }
     
    408407                // TODO: check opResult
    409408                if (usb_port_dev_connected(&status)) {
    410                         dprintf(1, "some connection changed");
     409                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    411410                        usb_hub_init_add_device(hc, port, target);
    412411                } else {
     
    416415        //port reset
    417416        if (usb_port_reset_completed(&status)) {
    418                 dprintf(1, "port reset complete");
     417                dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
    419418                if (usb_port_enabled(&status)) {
    420419                        usb_hub_finalize_add_device(hub, hc, port, target);
    421420                } else {
    422                         dprintf(1, "ERROR: port reset, but port still not enabled");
     421                        dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
    423422                }
    424423        }
     
    429428        usb_port_set_dev_connected(&status, false);
    430429        if (status>>16) {
    431                 dprintf(1, "there was some unsupported change on port %d: %X",port,status);
     430                dprintf(USB_LOG_LEVEL_INFO, "there was some unsupported change on port %d: %X",port,status);
    432431
    433432        }
     
    458457                target.address = hub_info->usb_device->address;
    459458                target.endpoint = 1;/// \TODO get from endpoint descriptor
    460                 dprintf(1, "checking changes for hub at addr %d",
     459                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
    461460                    target.address);
    462461
     
    489488                if (opResult != EOK) {
    490489                        free(change_bitmap);
    491                         dprintf(1, "something went wrong while getting status of hub");
     490                        dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub");
    492491                        continue;
    493492                }
Note: See TracChangeset for help on using the changeset viewer.