Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/hub.c

    r0edf7c7 r160b75e  
    4141#include <assert.h>
    4242#include <usb/debug.h>
    43 #include <time.h>
    4443
    4544/** How much time to wait between attempts to register endpoint 0:0.
     
    120119}
    121120
     121/** Get handle of USB device with given address.
     122 *
     123 * @param[in] connection Opened connection to host controller.
     124 * @param[in] address Address of device in question.
     125 * @param[out] handle Where to write the device handle.
     126 * @return Error code.
     127 */
     128int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
     129    usb_address_t address, devman_handle_t *handle)
     130{
     131        CHECK_CONNECTION(connection);
     132
     133        sysarg_t tmp;
     134        int rc = async_req_2_1(connection->hc_phone,
     135            DEV_IFACE_ID(USBHC_DEV_IFACE),
     136            IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
     137            address, &tmp);
     138        if ((rc == EOK) && (handle != NULL)) {
     139                *handle = tmp;
     140        }
     141
     142        return rc;
     143}
    122144
    123145static void unregister_control_endpoint_on_default_address(
     
    196218
    197219        int rc;
    198         struct timeval start_time;
    199 
    200         rc = gettimeofday(&start_time, NULL);
    201         if (rc != EOK) {
    202                 return rc;
    203         }
    204220
    205221        rc = usb_hc_connection_open(&hc_conn);
     
    248264                }
    249265        } while (rc != EOK);
    250         struct timeval end_time;
    251 
    252         rc = gettimeofday(&end_time, NULL);
    253         if (rc != EOK) {
    254                 goto leave_release_default_address;
    255         }
    256 
    257         /* According to the USB spec part 9.1.2 host allows 100ms time for
    258          * the insertion process to complete. According to 7.1.7.1 this is the
    259          * time between attach detected and port reset. However, the setup done
    260          * above might use much of this time so we should only wait to fill
    261          * up the 100ms quota*/
    262         suseconds_t elapsed = tv_sub(&end_time, &start_time);
    263         if (elapsed < 100000) {
    264                 async_usleep(100000 - elapsed);
    265         }
    266266
    267267        /*
     
    273273                goto leave_release_default_address;
    274274        }
    275         /* USB spec 7.1.7.1: The USB System Software guarantees a minimum of
    276          * 10ms for reset recovery. Device response to any bus transactions
    277          * addressed to the default device address during the reset recovery
    278          * time is undefined.
    279          */
    280         async_usleep(10000);
    281275
    282276        rc = usb_pipe_probe_default_control(&ctrl_pipe);
Note: See TracChangeset for help on using the changeset viewer.