Changeset 441633f in mainline


Ignore:
Timestamp:
2011-12-14T21:47:24Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
64e3dad
Parents:
6883abfa
Message:

libusbdev: Cleanup.

File:
1 edited

Legend:

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

    r6883abfa r441633f  
    107107        }
    108108
    109         usb_endpoint_mapping_t *pipes;
    110         size_t pipes_count;
    111 
    112         int rc = usb_device_create_pipes(&dev->wire, endpoints,
     109        usb_endpoint_mapping_t *pipes = NULL;
     110        size_t pipes_count = 0;
     111
     112        const int rc = usb_device_create_pipes(&dev->wire, endpoints,
    113113            dev->descriptors.configuration, dev->descriptors.configuration_size,
    114114            dev->interface_no, alternate_setting, &pipes, &pipes_count);
    115115
    116         if (rc != EOK) {
    117                 return rc;
    118         }
    119 
    120         dev->pipes = pipes;
    121         dev->pipes_count = pipes_count;
    122 
    123         return EOK;
     116        if (rc == EOK) {
     117                dev->pipes = pipes;
     118                dev->pipes_count = pipes_count;
     119        }
     120
     121        return rc;
    124122}
    125123/*----------------------------------------------------------------------------*/
     
    238236        }
    239237
    240         int rc;
    241 
    242238        /* Destroy existing pipes. */
    243239        destroy_current_pipes(dev);
    244240
    245241        /* Change the interface itself. */
    246         rc = usb_request_set_interface(&dev->ctrl_pipe, dev->interface_no,
     242        int rc = usb_request_set_interface(&dev->ctrl_pipe, dev->interface_no,
    247243            alternate_setting);
    248244        if (rc != EOK) {
     
    309305 * - registers endpoints with the host controller
    310306 *
    311  * @param[in] dev Generic DDF device backing the USB one.
    312307 * @param[in] wire Initialized backing connection to the host controller.
    313308 * @param[in] endpoints Endpoints description, NULL terminated.
     
    351346        }
    352347
    353         /* Now allocate and fully initialize. */
     348        /* Now initialize. */
    354349        for (i = 0; i < pipe_count; i++) {
    355350                pipes[i].description = endpoints[i];
     
    362357            config_descr, config_descr_size, wire);
    363358        if (rc != EOK) {
    364                 goto rollback_free_only;
    365         }
    366 
     359                free(pipes);
     360                return rc;
     361        }
     362
     363        /* Register created pipes. */
    367364        for (i = 0; i < pipe_count; i++) {
    368365                if (pipes[i].present) {
     
    395392        }
    396393
    397         /*
    398          * Jump here if something went wrong before some actual communication
    399          * with HC. Then the only thing that needs to be done is to free
    400          * allocated memory.
    401          */
    402 rollback_free_only:
    403394        free(pipes);
    404 
    405395        return rc;
    406396}
     
    408398/** Destroy pipes previously created by usb_device_create_pipes.
    409399 *
    410  * @param[in] dev Generic DDF device backing the USB one.
    411400 * @param[in] pipes Endpoint mapping to be destroyed.
    412401 * @param[in] pipes_count Number of endpoints.
Note: See TracChangeset for help on using the changeset viewer.