Changeset b495a93 in mainline


Ignore:
Timestamp:
2011-03-18T14:24:00Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a83e138
Parents:
73751c0
Message:

drpintf removed, usb_log_… used instead

File:
1 edited

Legend:

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

    r73751c0 rb495a93  
    7878                async_usleep(1000 * 1000 );/// \TODO proper number once
    7979        }
    80         dprintf(USB_LOG_LEVEL_ERROR,
    81                                 "something in ctrl loop went wrong, errno %d",errorCode);
     80        usb_log_error("something in ctrl loop went wrong, errno %d",errorCode);
     81
    8282        return 0;
    8383}
     
    104104                        hub->device);
    105105        if(opResult != EOK){
    106                 dprintf(USB_LOG_LEVEL_ERROR,
    107                                 "could not initialize connection to hc, errno %d",opResult);
     106                usb_log_error("could not initialize connection to hc, errno %d",opResult);
    108107                return opResult;
    109108        }
     
    112111                        hub->device);
    113112        if(opResult != EOK){
    114                 dprintf(USB_LOG_LEVEL_ERROR,
    115                                 "could not initialize connection to device, errno %d",opResult);
     113                usb_log_error("could not initialize connection to device, errno %d",
     114                                opResult);
    116115                return opResult;
    117116        }
     
    120119            &hub->device_connection);
    121120        if(opResult != EOK){
    122                 dprintf(USB_LOG_LEVEL_ERROR,
    123                                 "could not initialize connection to device endpoint, errno %d",opResult);
     121                usb_log_error("could not initialize connection to device endpoint, errno %d",
     122                                opResult);
    124123                return opResult;
    125124        }
     
    127126        opResult = usb_endpoint_pipe_probe_default_control(&hub->endpoints.control);
    128127        if (opResult != EOK) {
    129                 dprintf(USB_LOG_LEVEL_ERROR, "failed probing endpoint 0, %d", opResult);
     128                usb_log_error("failed probing endpoint 0, %d", opResult);
    130129                return opResult;
    131130        }
     
    151150            &std_descriptor);
    152151        if(opResult!=EOK){
    153                 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);
    154                 return opResult;
    155         }
    156         dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",
     152                usb_log_error("could not get device descriptor, %d",opResult);
     153                return opResult;
     154        }
     155        usb_log_info("hub has %d configurations",
    157156                        std_descriptor.configuration_count);
    158157        if(std_descriptor.configuration_count<1){
    159                 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");
     158                usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE");
    160159                //shouldn`t I return?
    161160        }
     
    184183                return opResult;
    185184        }
    186         dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",
     185        usb_log_debug("\tused configuration %d",
    187186                        config_descriptor->configuration_number);
    188187
     
    200199            &hub->device_connection);
    201200        if (opResult != EOK) {
    202                 dprintf(USB_LOG_LEVEL_ERROR,
    203                                 "Failed to initialize status change pipe: %s",
     201                usb_log_error("Failed to initialize status change pipe: %s",
    204202                    str_error(opResult));
    205203                return opResult;
    206204        }
    207205        if (!endpoint_mapping[0].present) {
    208                 dprintf(USB_LOG_LEVEL_ERROR,"Not accepting device, " \
     206                usb_log_error("Not accepting device, " \
    209207                    "cannot understand what is happenning");
    210208                return EREFUSED;
     
    240238
    241239        // get hub descriptor
    242         dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton");
     240        usb_log_debug("creating serialized descripton");
    243241        void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    244242        usb_hub_descriptor_t * descriptor;
    245         dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
     243        usb_log_debug("starting control transaction");
    246244        usb_endpoint_pipe_start_session(&result->endpoints.control);
    247245        opResult = usb_request_set_configuration(&result->endpoints.control, 1);
     
    256254
    257255        if (opResult != EOK) {
    258                 dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);
     256                usb_log_error("failed when receiving hub descriptor, badcode = %d",
     257                                opResult);
    259258                free(serialized_descriptor);
    260259                free(result);
    261260                return NULL;
    262261        }
    263         dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");
     262        usb_log_debug2("deserializing descriptor");
    264263        descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
    265264        if(descriptor==NULL){
    266                 dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");
     265                usb_log_warning("could not deserialize descriptor ");
    267266                free(result);
    268267                return NULL;
    269268        }
    270269
    271         dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);
     270        usb_log_info("setting port count to %d",descriptor->ports_count);
    272271        result->port_count = descriptor->ports_count;
    273272        result->attached_devs = (usb_hc_attached_device_t*)
     
    278277                result->attached_devs[i].address=0;
    279278        }
    280         dprintf(USB_LOG_LEVEL_DEBUG2, "freeing data");
     279        usb_log_debug2("freeing data");
    281280        free(serialized_descriptor);
    282281        free(descriptor->devices_removable);
     
    285284        //finish
    286285
    287         dprintf(USB_LOG_LEVEL_INFO, "hub info created");
     286        usb_log_info("hub info created");
    288287
    289288        return result;
     
    296295 */
    297296int usb_add_hub_device(ddf_dev_t *dev) {
    298         dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle);
     297        usb_log_info("add_hub_device(handle=%d)", (int) dev->handle);
    299298
    300299        //dev->ops = &hub_device_ops;
     
    313312        opResult = usb_hub_process_configuration_descriptors(hub_info);
    314313        if(opResult != EOK){
    315                 dprintf(USB_LOG_LEVEL_ERROR,"could not get configuration descriptors, %d",
     314                usb_log_error("could not get configuration descriptors, %d",
    316315                                opResult);
    317316                return opResult;
     
    324323                opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
    325324                                &request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
    326                 dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
     325                usb_log_info("powering port %d",port);
    327326                if (opResult != EOK) {
    328                         dprintf(USB_LOG_LEVEL_WARNING, "something went wrong when setting hub`s %dth port", port);
     327                        usb_log_warning("something went wrong when setting hub`s %dth port", port);
    329328                }
    330329        }
     
    337336        usb_lst_append(&usb_hub_list, hub_info);
    338337        fibril_mutex_unlock(&usb_hub_list_lock);
    339         dprintf(USB_LOG_LEVEL_DEBUG, "hub info added to list");
    340 
    341         dprintf(USB_LOG_LEVEL_DEBUG, "adding to ddf");
     338        usb_log_debug("hub info added to list");
     339
     340        usb_log_debug("adding to ddf");
    342341        ddf_fun_t *hub_fun = ddf_fun_create(dev, fun_exposed, "hub");
    343342        assert(hub_fun != NULL);
     
    351350        fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
    352351        if (fid == 0) {
    353                 dprintf(USB_LOG_LEVEL_ERROR,
    354                                 ": failed to start monitoring fibril for new hub");
     352                usb_log_error("failed to start monitoring fibril for new hub");
    355353                return ENOMEM;
    356354        }
    357355        fibril_add_ready(fid);
    358356
    359         dprintf(USB_LOG_LEVEL_DEBUG, "hub fibril created");
     357        usb_log_debug("hub fibril created");
    360358        //(void)hub_info;
    361359        //usb_hub_check_hub_changes();
    362360       
    363         dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
     361        usb_log_info("hub dev added");
    364362        //address is lost...
    365         dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
     363        usb_log_debug("\taddress %d, has %d ports ",
    366364                        //hub_info->endpoints.control.,
    367365                        hub_info->port_count);
     
    388386        usb_device_request_setup_packet_t request;
    389387        int opResult;
    390         dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
     388        usb_log_info("some connection changed");
    391389        assert(hub->endpoints.control.hc_phone);
    392390        //get default address
     
    395393       
    396394        if (opResult != EOK) {
    397                 dprintf(USB_LOG_LEVEL_WARNING,
    398                                 "cannot assign default address, it is probably used %d",opResult);
     395                usb_log_warning("cannot assign default address, it is probably used %d",
     396                                opResult);
    399397                return;
    400398        }
     
    407405                        );
    408406        if (opResult != EOK) {
    409                 dprintf(USB_LOG_LEVEL_ERROR,
    410                                 "something went wrong when reseting a port %d",opResult);
     407                usb_log_error("something went wrong when reseting a port %d",opResult);
    411408                //usb_hub_release_default_address(hc);
    412409                usb_hc_release_default_address(&hub->connection);
     
    424421
    425422        int opResult;
    426         dprintf(USB_LOG_LEVEL_INFO, "finalizing add device");
     423        usb_log_info("finalizing add device");
    427424        opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
    428425            port, USB_HUB_FEATURE_C_PORT_RESET);
    429426
    430427        if (opResult != EOK) {
    431                 dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");
     428                usb_log_error("failed to clear port reset feature");
    432429                usb_hc_release_default_address(&hub->connection);
    433430                return;
     
    454451                        );
    455452        if (new_device_address < 0) {
    456                 dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address");
     453                usb_log_error("failed to get free USB address");
    457454                opResult = new_device_address;
    458455                usb_hc_release_default_address(&hub->connection);
    459456                return;
    460457        }
    461         dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);
     458        usb_log_info("setting new address %d",new_device_address);
    462459        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    463460        //    new_device_address);
     
    466463        usb_endpoint_pipe_end_session(&new_device_pipe);
    467464        if (opResult != EOK) {
    468                 dprintf(USB_LOG_LEVEL_ERROR,
    469                                 "could not set address for new device %d",opResult);
     465                usb_log_error("could not set address for new device %d",opResult);
    470466                usb_hc_release_default_address(&hub->connection);
    471467                return;
     
    486482
    487483        if (opResult != EOK) {
    488                 dprintf(USB_LOG_LEVEL_ERROR,
    489                                 "could not start driver for new device %d",opResult);
     484                usb_log_error("could not start driver for new device %d",opResult);
    490485                return;
    491486        }
     
    498493                        &hub->attached_devs[port]);
    499494        if (opResult != EOK) {
    500                 dprintf(USB_LOG_LEVEL_ERROR,
    501                                 "could not assign address of device in hcd %d",opResult);
    502                 return;
    503         }
    504         dprintf(USB_LOG_LEVEL_INFO, "new device address %d, handle %zu",
     495                usb_log_error("could not assign address of device in hcd %d",opResult);
     496                return;
     497        }
     498        usb_log_info("new device address %d, handle %zu",
    505499            new_device_address, child_handle);
    506500
     
    533527                 */
    534528        }else{
    535                 dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
     529                usb_log_warning("this is strange, disconnected device had no address");
    536530                //device was disconnected before it`s port was reset - return default address
    537531                //usb_drv_release_default_address(hc);
     
    542536
    543537/**
    544  *Process over current condition on port.
     538 * Process over current condition on port.
    545539 *
    546540 * Turn off the power on the port.
     
    555549            port, USB_HUB_FEATURE_PORT_POWER);
    556550        if(opResult!=EOK){
    557                 dprintf(USB_LOG_LEVEL_ERROR, "cannot power off port %d;  %d",
     551                usb_log_error("cannot power off port %d;  %d",
    558552                                port, opResult);
    559553        }
     
    568562static void usb_hub_process_interrupt(usb_hub_info_t * hub,
    569563        uint16_t port) {
    570         dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
     564        usb_log_debug("interrupt at port %d", port);
    571565        //determine type of change
    572566        usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
     
    587581                        );
    588582        if (opResult != EOK) {
    589                 dprintf(USB_LOG_LEVEL_ERROR, "could not get port status");
     583                usb_log_error("could not get port status");
    590584                return;
    591585        }
    592586        if (rcvd_size != sizeof (usb_port_status_t)) {
    593                 dprintf(USB_LOG_LEVEL_ERROR, "received status has incorrect size");
     587                usb_log_error("received status has incorrect size");
    594588                return;
    595589        }
     
    600594                // TODO: check opResult
    601595                if (usb_port_dev_connected(&status)) {
    602                         dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
     596                        usb_log_info("some connection changed");
    603597                        usb_hub_init_add_device(hub, port, usb_port_low_speed(&status));
    604598                } else {
     
    612606                        usb_hub_over_current(hub,port);
    613607                }else{
    614                         dprintf(USB_LOG_LEVEL_INFO,
    615                                 "over current condition was auto-resolved on port %d",port);
     608                        usb_log_info("over current condition was auto-resolved on port %d",
     609                                        port);
    616610                }
    617611        }
    618612        //port reset
    619613        if (usb_port_reset_completed(&status)) {
    620                 dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
     614                usb_log_info("port reset complete");
    621615                if (usb_port_enabled(&status)) {
    622616                        usb_hub_finalize_add_device(hub, port, usb_port_low_speed(&status));
    623617                } else {
    624                         dprintf(USB_LOG_LEVEL_WARNING, "port reset, but port still not enabled");
     618                        usb_log_warning("port reset, but port still not enabled");
    625619                }
    626620        }
     
    631625        usb_port_set_dev_connected(&status, false);
    632626        if (status>>16) {
    633                 dprintf(USB_LOG_LEVEL_INFO, "there was some unsupported change on port %d: %X",port,status);
    634 
    635         }
    636         /// \TODO handle other changes
     627                usb_log_info("there was some unsupported change on port %d: %X",
     628                                port,status);
     629
     630        }
     631        /// \TODO handle other changes - is there any?
    637632}
    638633
     
    647642        opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
    648643        if(opResult != EOK){
    649                 dprintf(USB_LOG_LEVEL_ERROR,
    650                                 "could not initialize communication for hub; %d", opResult);
     644                usb_log_error("could not initialize communication for hub; %d",
     645                                opResult);
    651646                return opResult;
    652647        }
     
    669664        if (opResult != EOK) {
    670665                free(change_bitmap);
    671                 dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub");
     666                usb_log_warning("something went wrong while getting status of hub");
    672667                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    673668                return opResult;
     
    676671        opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
    677672        if(opResult!=EOK){
    678                 dprintf(USB_LOG_LEVEL_ERROR, "could not start control pipe session %d",
    679                                 opResult);
     673                usb_log_error("could not start control pipe session %d", opResult);
    680674                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    681675                return opResult;
     
    683677        opResult = usb_hc_connection_open(&hub_info->connection);
    684678        if(opResult!=EOK){
    685                 dprintf(USB_LOG_LEVEL_ERROR, "could not start host controller session %d",
     679                usb_log_error("could not start host controller session %d",
    686680                                opResult);
    687681                usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
Note: See TracChangeset for help on using the changeset viewer.