Changeset e099f26 in mainline for uspace/lib/usb/src/devdrv.c


Ignore:
Timestamp:
2011-03-21T20:22:50Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c56c5b5b
Parents:
4fb6d9ee (diff), 31b568e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Development branch changes (including OHCI)

File:
1 edited

Legend:

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

    r4fb6d9ee re099f26  
    126126
    127127        for (i = 0; i < pipe_count; i++) {
    128                 dev->pipes[i].pipe = malloc(sizeof(usb_endpoint_pipe_t));
     128                dev->pipes[i].pipe = malloc(sizeof(usb_pipe_t));
    129129                if (dev->pipes[i].pipe == NULL) {
    130130                        usb_log_oom(dev->ddf_dev);
     
    137137        }
    138138
    139         void *config_descriptor;
    140         size_t config_descriptor_size;
    141         rc = usb_request_get_full_configuration_descriptor_alloc(
    142             &dev->ctrl_pipe, 0, &config_descriptor, &config_descriptor_size);
    143         if (rc != EOK) {
    144                 usb_log_error("Failed retrieving configuration of `%s': %s.\n",
    145                     dev->ddf_dev->name, str_error(rc));
    146                 goto rollback;
    147         }
    148 
    149         rc = usb_endpoint_pipe_initialize_from_configuration(dev->pipes,
    150            pipe_count, config_descriptor, config_descriptor_size, &dev->wire);
     139        rc = usb_pipe_initialize_from_configuration(dev->pipes, pipe_count,
     140            dev->descriptors.configuration, dev->descriptors.configuration_size,
     141            &dev->wire);
    151142        if (rc != EOK) {
    152143                usb_log_error("Failed initializing USB endpoints: %s.\n",
     
    172163        for (i = 0; i < pipe_count; i++) {
    173164                if (dev->pipes[i].present) {
    174                         rc = usb_endpoint_pipe_register(dev->pipes[i].pipe,
     165                        rc = usb_pipe_register(dev->pipes[i].pipe,
    175166                            dev->pipes[i].descriptor->poll_interval,
    176167                            &hc_conn);
     
    206197 * @return Error code.
    207198 */
    208 static int initialize_pipes(usb_driver_t *drv, usb_device_t *dev)
     199static int initialize_pipes(usb_device_t *dev)
    209200{
    210201        int rc;
     
    219210        }
    220211
    221         rc = usb_endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,
     212        rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe,
    222213            &dev->wire);
    223214        if (rc != EOK) {
     
    228219        }
    229220
    230         rc = usb_endpoint_pipe_probe_default_control(&dev->ctrl_pipe);
     221        rc = usb_pipe_probe_default_control(&dev->ctrl_pipe);
    231222        if (rc != EOK) {
    232223                usb_log_error(
     
    237228
    238229        /*
    239          * Initialization of other pipes requires open session on
    240          * default control pipe.
     230         * For further actions, we need open session on default control pipe.
    241231         */
    242         rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
     232        rc = usb_pipe_start_session(&dev->ctrl_pipe);
    243233        if (rc != EOK) {
    244234                usb_log_error("Failed to start an IPC session: %s.\n",
    245235                    str_error(rc));
     236                return rc;
     237        }
     238
     239        /* Get the device descriptor. */
     240        rc = usb_request_get_device_descriptor(&dev->ctrl_pipe,
     241            &dev->descriptors.device);
     242        if (rc != EOK) {
     243                usb_log_error("Failed to retrieve device descriptor: %s.\n",
     244                    str_error(rc));
     245                return rc;
     246        }
     247
     248        /* Get the full configuration descriptor. */
     249        rc = usb_request_get_full_configuration_descriptor_alloc(
     250            &dev->ctrl_pipe, 0, (void **) &dev->descriptors.configuration,
     251            &dev->descriptors.configuration_size);
     252        if (rc != EOK) {
     253                usb_log_error("Failed retrieving configuration descriptor: %s.\n",
     254                    dev->ddf_dev->name, str_error(rc));
    246255                return rc;
    247256        }
     
    252261
    253262        /* No checking here. */
    254         usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     263        usb_pipe_end_session(&dev->ctrl_pipe);
     264
     265        /* Rollback actions. */
     266        if (rc != EOK) {
     267                if (dev->descriptors.configuration != NULL) {
     268                        free(dev->descriptors.configuration);
     269                }
     270        }
    255271
    256272        return rc;
     
    283299        dev->ddf_dev->driver_data = dev;
    284300        dev->driver_data = NULL;
    285 
    286         rc = initialize_pipes(driver, dev);
     301        dev->descriptors.configuration = NULL;
     302
     303        rc = initialize_pipes(dev);
    287304        if (rc != EOK) {
    288305                free(dev);
Note: See TracChangeset for help on using the changeset viewer.