Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3538b0e in mainline


Ignore:
Timestamp:
2011-12-12T13:28:51Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
30ec5ea
Parents:
c804484
Message:

libusbdev: Cleanup.

Location:
uspace/lib/usbdev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/usb_device_connection.h

    rc804484 r3538b0e  
    5757{
    5858        assert(connection);
    59 
    60         if (hc_connection == NULL) {
     59        if (hc_connection == NULL)
    6160                return EBADMEM;
    62         }
    63 
    64         if ((address < 0) || (address >= USB11_ADDRESS_MAX)) {
     61        if ((address < 0) || (address >= USB11_ADDRESS_MAX))
    6562                return EINVAL;
    66         }
    6763
    6864        connection->hc_connection = hc_connection;
     
    7066        return EOK;
    7167}
    72 /*----------------------------------------------------------------------------*/
    73 /** Initialize connection to USB device on default address.
    74  *
    75  * @param dev_connection Device connection structure to be initialized.
    76  * @param hc_connection Initialized connection to host controller.
    77  * @return Error code.
    78  */
    79 static inline int usb_device_connection_initialize_on_default_address(
    80     usb_device_connection_t *connection, usb_hc_connection_t *hc_conn)
    81 {
    82         return usb_device_connection_initialize(connection, hc_conn, 0);
    83 }
    84 
    8568/*----------------------------------------------------------------------------*/
    8669static inline int usb_device_register_endpoint(usb_device_connection_t *conn,
  • uspace/lib/usbdev/src/hub.c

    rc804484 r3538b0e  
    230230        /* Initialize connection to device. */
    231231        usb_device_connection_t dev_conn;
    232         rc = usb_device_connection_initialize_on_default_address(
    233             &dev_conn, hc_conn);
     232        rc = usb_device_connection_initialize(
     233            &dev_conn, hc_conn, USB_ADDRESS_DEFAULT);
    234234        if (rc != EOK) {
    235235                rc = ENOTCONN;
     
    237237        }
    238238
     239        /* Initialize control pipe on default address. Don't register yet. */
     240        usb_pipe_t ctrl_pipe;
     241        rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_conn);
     242        if (rc != EOK) {
     243                rc = ENOTCONN;
     244                goto leave_release_free_address;
     245        }
     246
    239247        /*
    240          * We will not register control pipe on default address.
    241          * The registration might fail. That means that someone else already
    242          * registered that endpoint. We will simply wait and try again.
     248         * The default address request might fail.
     249         * That means that someone else is already using that address.
     250         * We will simply wait and try again.
    243251         * (Someone else already wants to add a new device.)
    244252         */
    245         usb_pipe_t ctrl_pipe;
    246         rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_conn);
    247         if (rc != EOK) {
    248                 rc = ENOTCONN;
    249                 goto leave_release_free_address;
    250         }
    251 
    252253        do {
    253254                rc = usb_hc_request_address(hc_conn, USB_ADDRESS_DEFAULT,
     
    262263        }
    263264
    264         /* Register control pipe on default address. */
     265        /* Register control pipe on default address. 0 means no interval. */
    265266        rc = usb_pipe_register(&ctrl_pipe, 0);
    266267        if (rc != EOK) {
     
    270271
    271272        struct timeval end_time;
    272 
    273273        rc = gettimeofday(&end_time, NULL);
    274274        if (rc != EOK) {
     
    353353         */
    354354leave_release_default_address:
    355         usb_hc_unregister_device(hc_conn, USB_ADDRESS_DEFAULT);
     355        if (usb_hc_unregister_device(hc_conn, USB_ADDRESS_DEFAULT) != EOK)
     356                usb_log_warning("%s: Failed to unregister defaut device.\n",
     357                    __FUNCTION__);
    356358
    357359leave_release_free_address:
  • uspace/lib/usbdev/src/pipes.c

    rc804484 r3538b0e  
    3131 */
    3232/** @file
    33  * USB endpoint pipes miscellaneous functions.
     33 * USB endpoint pipes functions.
    3434 */
    3535#include <usb/dev/pipes.h>
  • uspace/lib/usbdev/src/pipesinit.c

    rc804484 r3538b0e  
    3131 */
    3232/** @file
    33  * Initialization of endpoint pipes.
     33 * Non trivial initialization of endpoint pipes.
    3434 *
    3535 */
Note: See TracChangeset for help on using the changeset viewer.