Changeset 98064795 in mainline


Ignore:
Timestamp:
2011-04-08T22:26:12Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b6c9e1e
Parents:
1998bcd
Message:

New device probing does not reserve default address

File:
1 edited

Legend:

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

    r1998bcd r98064795  
    235235        }
    236236
    237 
    238         /*
    239          * Reserve the default address.
    240          */
    241         rc = usb_hc_reserve_default_address(&hc_conn, dev_speed);
    242         if (rc != EOK) {
    243                 rc = EBUSY;
    244                 goto leave_release_free_address;
    245         }
    246 
    247         /*
    248          * Enable the port (i.e. allow signaling through this port).
    249          */
    250         rc = enable_port(port_no, arg);
    251         if (rc != EOK) {
    252                 goto leave_release_default_address;
    253         }
    254 
    255         /*
    256          * Change the address from default to the free one.
    257          * We need to create a new control pipe for that.
     237        /*
     238         * We will not register control pipe on default address.
     239         * The registration might fail. That means that someone else already
     240         * registered that endpoint. We will simply wait and try again.
     241         * (Someone else already wants to add a new device.)
    258242         */
    259243        usb_device_connection_t dev_conn;
     
    262246        if (rc != EOK) {
    263247                rc = ENOTCONN;
    264                 goto leave_release_default_address;
     248                goto leave_release_free_address;
    265249        }
    266250
     
    270254        if (rc != EOK) {
    271255                rc = ENOTCONN;
     256                goto leave_release_free_address;
     257        }
     258
     259        do {
     260                rc = usb_pipe_register_with_speed(&ctrl_pipe, dev_speed, 0,
     261                    &hc_conn);
     262                if (rc != EOK) {
     263                        /* Do not overheat the CPU ;-). */
     264                        async_usleep(10);
     265                }
     266        } while (rc != EOK);
     267
     268        /*
     269         * Endpoint is registered. We can enable the port and change
     270         * device address.
     271         */
     272        rc = enable_port(port_no, arg);
     273        if (rc != EOK) {
    272274                goto leave_release_default_address;
    273275        }
    274276
    275         /* Before sending any traffic, we need to register this
    276          * endpoint.
    277          */
    278         rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
    279         if (rc != EOK) {
    280                 rc = EREFUSED;
     277        rc = usb_pipe_probe_default_control(&ctrl_pipe);
     278        if (rc != EOK) {
     279                rc = ESTALL;
    281280                goto leave_release_default_address;
    282281        }
    283         rc = usb_pipe_probe_default_control(&ctrl_pipe);
     282
     283
     284        rc = usb_pipe_start_session(&ctrl_pipe);
    284285        if (rc != EOK) {
    285286                rc = ENOTCONN;
     
    287288        }
    288289
    289         rc = usb_pipe_start_session(&ctrl_pipe);
    290         if (rc != EOK) {
    291                 rc = ENOTCONN;
    292                 goto leave_unregister_endpoint;
    293         }
    294 
    295290        rc = usb_request_set_address(&ctrl_pipe, dev_addr);
    296291        if (rc != EOK) {
     
    302297
    303298        /*
    304          * Register the control endpoint for the new device.
     299         * Address changed. We can release the original endpoint, thus
     300         * allowing other to access the default address.
     301         */
     302        unregister_control_endpoint_on_default_address(&hc_conn);
     303
     304        /*
     305         * Time to register the new endpoint.
    305306         */
    306307        rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
    307308        if (rc != EOK) {
    308                 rc = EREFUSED;
    309                 goto leave_unregister_endpoint;
    310         }
    311 
    312         /*
    313          * Release the original endpoint.
    314          */
    315         unregister_control_endpoint_on_default_address(&hc_conn);
    316 
    317         /*
    318          * Once the address is changed, we can return the default address.
    319          */
    320         usb_hc_release_default_address(&hc_conn);
    321 
     309                goto leave_release_free_address;
     310        }
    322311
    323312        /*
     
    334323        }
    335324
    336 
    337 
    338325        /*
    339326         * And now inform the host controller about the handle.
     
    371358        usb_pipe_end_session(&ctrl_pipe);
    372359
    373 leave_unregister_endpoint:
     360leave_release_default_address:
    374361        usb_pipe_unregister(&ctrl_pipe, &hc_conn);
    375 
    376 leave_release_default_address:
    377         usb_hc_release_default_address(&hc_conn);
    378362
    379363leave_release_free_address:
Note: See TracChangeset for help on using the changeset viewer.