Ignore:
File:
1 edited

Legend:

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

    r0c0f823b rc0fdc0e  
    170170                return ENOTSUP;
    171171        /* Just tell the driver to stop whatever it is doing, keep structures */
    172         return driver->ops->device_rem(gen_dev->driver_data);
     172        const int ret = driver->ops->device_rem(gen_dev->driver_data);
     173        if (ret != EOK)
     174                return ret;
     175        return ENOTSUP;
    173176}
    174177/*----------------------------------------------------------------------------*/
     
    373376        }
    374377
    375         /* Register the endpoints with HC. */
    376         usb_hc_connection_t hc_conn;
    377         rc = usb_hc_connection_initialize_from_device(&hc_conn, dev);
    378         if (rc != EOK) {
    379                 goto rollback_free_only;
    380         }
    381 
    382         rc = usb_hc_connection_open(&hc_conn);
    383         if (rc != EOK) {
    384                 goto rollback_free_only;
    385         }
    386 
    387378        for (i = 0; i < pipe_count; i++) {
    388379                if (pipes[i].present) {
    389380                        rc = usb_pipe_register(&pipes[i].pipe,
    390                             pipes[i].descriptor->poll_interval, &hc_conn);
     381                            pipes[i].descriptor->poll_interval);
    391382                        if (rc != EOK) {
    392383                                goto rollback_unregister_endpoints;
     
    394385                }
    395386        }
    396 
    397         if (usb_hc_connection_close(&hc_conn) != EOK)
    398                 usb_log_warning("%s: Failed to close connection.\n",
    399                     __FUNCTION__);
    400387
    401388        *pipes_ptr = pipes;
     
    415402        for (i = 0; i < pipe_count; i++) {
    416403                if (pipes[i].present) {
    417                         usb_pipe_unregister(&pipes[i].pipe, &hc_conn);
     404                        usb_pipe_unregister(&pipes[i].pipe);
    418405                }
    419406        }
    420 
    421         if (usb_hc_connection_close(&hc_conn) != EOK)
    422                 usb_log_warning("usb_device_create_pipes(): "
    423                     "Failed to close connection.\n");
    424407
    425408        /*
     
    470453                    i, pipes[i].present ? "" : "not ");
    471454                if (pipes[i].present)
    472                         usb_pipe_unregister(&pipes[i].pipe, &hc_conn);
    473         }
    474 
    475         if (usb_hc_connection_close(&hc_conn) != EOK)
    476                 usb_log_warning("usb_device_destroy_pipes(): "
    477                     "Failed to close connection.\n");
     455                        usb_pipe_unregister(&pipes[i].pipe);
     456        }
    478457
    479458        free(pipes);
     
    505484        usb_dev->pipes = NULL;
    506485
     486        /* Initialize hc connection. */
     487        usb_hc_connection_initialize_from_device(&usb_dev->hc_conn, ddf_dev);
     488        const usb_address_t address =
     489            usb_get_address_by_handle(ddf_dev->handle);
     490
    507491        /* Initialize backing wire and control pipe. */
    508         int rc = usb_device_connection_initialize_from_device(
    509             &usb_dev->wire, ddf_dev);
     492        int rc = usb_device_connection_initialize(
     493            &usb_dev->wire, &usb_dev->hc_conn, address);
    510494        if (rc != EOK) {
    511495                *errstr_ptr = "device connection initialization";
     
    515499        /* This pipe was registered by the hub driver,
    516500         * during device initialization. */
    517         rc = usb_pipe_initialize_default_control(&usb_dev->ctrl_pipe,
    518             &usb_dev->wire);
     501        rc = usb_pipe_initialize_default_control(
     502            &usb_dev->ctrl_pipe, &usb_dev->wire);
    519503        if (rc != EOK) {
    520504                *errstr_ptr = "default control pipe initialization";
     505                return rc;
     506        }
     507
     508        rc = usb_hc_connection_open(&usb_dev->hc_conn);
     509        if (rc != EOK) {
     510                *errstr_ptr = "hc connection open";
    521511                return rc;
    522512        }
     
    524514        /* Get our interface. */
    525515        usb_dev->interface_no = usb_device_get_assigned_interface(ddf_dev);
    526 
    527516        /* Retrieve standard descriptors. */
    528         rc = usb_device_retrieve_descriptors(&usb_dev->ctrl_pipe,
    529             &usb_dev->descriptors);
     517        rc = usb_device_retrieve_descriptors(
     518            &usb_dev->ctrl_pipe, &usb_dev->descriptors);
    530519        if (rc != EOK) {
    531520                *errstr_ptr = "descriptor retrieval";
     521                usb_hc_connection_close(&usb_dev->hc_conn);
    532522                return rc;
    533523        }
     
    546536        rc = initialize_other_pipes(endpoints, usb_dev, alternate_iface);
    547537        if (rc != EOK) {
     538                usb_hc_connection_close(&usb_dev->hc_conn);
    548539                /* Full configuration descriptor is allocated. */
    549540                usb_device_release_descriptors(&usb_dev->descriptors);
     
    554545        }
    555546
     547        usb_hc_connection_close(&usb_dev->hc_conn);
    556548        return EOK;
    557549}
Note: See TracChangeset for help on using the changeset viewer.