Changeset 39db23f in mainline


Ignore:
Timestamp:
2011-04-09T11:00:22Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
112d159, 8e8b84f
Parents:
0c311d5 (diff), 61727bf (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

File:
1 edited

Legend:

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

    r0c311d5 r39db23f  
    178178 * error codes than those listed as return codes by this function itself).
    179179 *
     180 * The @p connection representing connection with host controller does not
     181 * need to be started.
     182 * This function duplicates the connection to allow simultaneous calls of
     183 * this function (i.e. from different fibrils).
     184 *
    180185 * @param[in] parent Parent device (i.e. the hub device).
    181  * @param[in] connection Opened connection to host controller.
     186 * @param[in] connection Connection to host controller.
    182187 * @param[in] dev_speed New device speed.
    183188 * @param[in] enable_port Function for enabling signaling through the port the
     
    206211    ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
    207212{
    208         CHECK_CONNECTION(connection);
     213        assert(connection != NULL);
     214        // FIXME: this is awful, we are accessing directly the structure.
     215        usb_hc_connection_t hc_conn = {
     216                .hc_handle = connection->hc_handle,
     217                .hc_phone = -1
     218        };
     219
     220        int rc;
     221
     222        rc = usb_hc_connection_open(&hc_conn);
     223        if (rc != EOK) {
     224                return rc;
     225        }
     226
    209227
    210228        /*
    211229         * Request new address.
    212230         */
    213         usb_address_t dev_addr = usb_hc_request_address(connection, dev_speed);
     231        usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed);
    214232        if (dev_addr < 0) {
     233                usb_hc_connection_close(&hc_conn);
    215234                return EADDRNOTAVAIL;
    216235        }
    217236
    218         int rc;
    219237
    220238        /*
    221239         * Reserve the default address.
    222240         */
    223         rc = usb_hc_reserve_default_address(connection, dev_speed);
     241        rc = usb_hc_reserve_default_address(&hc_conn, dev_speed);
    224242        if (rc != EOK) {
    225243                rc = EBUSY;
     
    241259        usb_device_connection_t dev_conn;
    242260        rc = usb_device_connection_initialize_on_default_address(&dev_conn,
    243             connection);
     261            &hc_conn);
    244262        if (rc != EOK) {
    245263                rc = ENOTCONN;
     
    258276         * endpoint.
    259277         */
    260         rc = usb_pipe_register(&ctrl_pipe, 0, connection);
     278        rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
    261279        if (rc != EOK) {
    262280                rc = EREFUSED;
     
    286304         * Register the control endpoint for the new device.
    287305         */
    288         rc = usb_pipe_register(&ctrl_pipe, 0, connection);
     306        rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
    289307        if (rc != EOK) {
    290308                rc = EREFUSED;
     
    295313         * Release the original endpoint.
    296314         */
    297         unregister_control_endpoint_on_default_address(connection);
     315        unregister_control_endpoint_on_default_address(&hc_conn);
    298316
    299317        /*
    300318         * Once the address is changed, we can return the default address.
    301319         */
    302         usb_hc_release_default_address(connection);
     320        usb_hc_release_default_address(&hc_conn);
    303321
    304322
     
    325343                .handle = child_handle
    326344        };
    327         rc = usb_hc_register_device(connection, &new_device);
     345        rc = usb_hc_register_device(&hc_conn, &new_device);
    328346        if (rc != EOK) {
    329347                rc = EDESTADDRREQ;
     
    354372
    355373leave_unregister_endpoint:
    356         usb_pipe_unregister(&ctrl_pipe, connection);
     374        usb_pipe_unregister(&ctrl_pipe, &hc_conn);
    357375
    358376leave_release_default_address:
    359         usb_hc_release_default_address(connection);
     377        usb_hc_release_default_address(&hc_conn);
    360378
    361379leave_release_free_address:
    362         usb_hc_unregister_device(connection, dev_addr);
     380        usb_hc_unregister_device(&hc_conn, dev_addr);
     381
     382        usb_hc_connection_close(&hc_conn);
    363383
    364384        return rc;
Note: See TracChangeset for help on using the changeset viewer.