Ignore:
File:
1 edited

Legend:

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

    r4e900c1 r42a3a57  
    7272int usb_hub_control_loop(void * hub_info_param){
    7373        usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param;
    74         while(true){
    75                 usb_hub_check_hub_changes(hub_info);
     74        int errorCode = EOK;
     75
     76        while(errorCode == EOK){
     77                errorCode = usb_hub_check_hub_changes(hub_info);
    7678                async_usleep(1000 * 1000 );/// \TODO proper number once
    7779        }
     80        dprintf(USB_LOG_LEVEL_ERROR,
     81                                "something in ctrl loop went wrong, errno %d",errorCode);
    7882        return 0;
    7983}
     
    118122                dprintf(USB_LOG_LEVEL_ERROR,
    119123                                "could not initialize connection to device endpoint, errno %d",opResult);
    120         }
    121         return opResult;
     124                return opResult;
     125        }
     126
     127        opResult = usb_endpoint_pipe_probe_default_control(&hub->endpoints.control);
     128        if (opResult != EOK) {
     129                dprintf(USB_LOG_LEVEL_ERROR, "failed probing endpoint 0, %d", opResult);
     130                return opResult;
     131        }
     132
     133        return EOK;
    122134}
    123135
     
    372384 * @param target
    373385 */
    374 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
     386static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
     387                bool isLowSpeed) {
    375388        usb_device_request_setup_packet_t request;
    376389        int opResult;
     
    378391        assert(hub->endpoints.control.hc_phone);
    379392        //get default address
    380         //opResult = usb_drv_reserve_default_address(hc);
    381         opResult = usb_hc_reserve_default_address(&hub->connection, USB_SPEED_LOW);
     393        usb_speed_t speed = isLowSpeed?USB_SPEED_LOW:USB_SPEED_FULL;
     394        opResult = usb_hc_reserve_default_address(&hub->connection, speed);
    382395       
    383396        if (opResult != EOK) {
     
    430443                        &new_device_pipe,
    431444                        &new_device_connection);
     445        usb_endpoint_pipe_probe_default_control(&new_device_pipe);
    432446        /// \TODO get highspeed info
    433447        usb_speed_t speed = isLowSpeed?USB_SPEED_LOW:USB_SPEED_FULL;
     
    437451        usb_address_t new_device_address = usb_hc_request_address(
    438452                        &hub->connection,
    439                         speed/// \TODO fullspeed??
     453                        speed
    440454                        );
    441455        if (new_device_address < 0) {
     
    501515static void usb_hub_removed_device(
    502516    usb_hub_info_t * hub,uint16_t port) {
    503         //usb_device_request_setup_packet_t request;
    504         int opResult;
    505        
     517               
    506518        /** \TODO remove device from device manager - not yet implemented in
    507519         * devide manager
     
    510522        //close address
    511523        if(hub->attached_devs[port].address!=0){
    512                 //opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
     524                /*uncomment this code to use it when DDF allows device removal
    513525                opResult = usb_hc_unregister_device(
    514526                                &hub->connection, hub->attached_devs[port].address);
     
    519531                hub->attached_devs[port].address = 0;
    520532                hub->attached_devs[port].handle = 0;
     533                 */
    521534        }else{
    522535                dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
     
    588601                if (usb_port_dev_connected(&status)) {
    589602                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    590                         usb_hub_init_add_device(hub, port);
     603                        usb_hub_init_add_device(hub, port, usb_port_low_speed(&status));
    591604                } else {
    592605                        usb_hub_removed_device(hub, port);
     
    626639/**
    627640 * Check changes on particular hub
    628  * @param hub_info_param
    629  */
    630 void usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
     641 * @param hub_info_param pointer to usb_hub_info_t structure
     642 * @return error code if there is problem when initializing communication with
     643 * hub, EOK otherwise
     644 */
     645int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
    631646        int opResult;
    632647        opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
     
    634649                dprintf(USB_LOG_LEVEL_ERROR,
    635650                                "could not initialize communication for hub; %d", opResult);
    636                 return;
     651                return opResult;
    637652        }
    638653
     
    656671                dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub");
    657672                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    658                 return;
     673                return opResult;
    659674        }
    660675        unsigned int port;
     
    664679                                opResult);
    665680                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    666                 return;
     681                return opResult;
    667682        }
    668683        opResult = usb_hc_connection_open(&hub_info->connection);
     
    672687                usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
    673688                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    674                 return;
     689                return opResult;
    675690        }
    676691
     
    688703        usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    689704        free(change_bitmap);
     705        return EOK;
    690706}
    691707
Note: See TracChangeset for help on using the changeset viewer.