Changeset 98064795 in mainline
- Timestamp:
- 2011-04-08T22:26:12Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b6c9e1e
- Parents:
- 1998bcd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hub.c
r1998bcd r98064795 235 235 } 236 236 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.) 258 242 */ 259 243 usb_device_connection_t dev_conn; … … 262 246 if (rc != EOK) { 263 247 rc = ENOTCONN; 264 goto leave_release_ default_address;248 goto leave_release_free_address; 265 249 } 266 250 … … 270 254 if (rc != EOK) { 271 255 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) { 272 274 goto leave_release_default_address; 273 275 } 274 276 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; 281 280 goto leave_release_default_address; 282 281 } 283 rc = usb_pipe_probe_default_control(&ctrl_pipe); 282 283 284 rc = usb_pipe_start_session(&ctrl_pipe); 284 285 if (rc != EOK) { 285 286 rc = ENOTCONN; … … 287 288 } 288 289 289 rc = usb_pipe_start_session(&ctrl_pipe);290 if (rc != EOK) {291 rc = ENOTCONN;292 goto leave_unregister_endpoint;293 }294 295 290 rc = usb_request_set_address(&ctrl_pipe, dev_addr); 296 291 if (rc != EOK) { … … 302 297 303 298 /* 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. 305 306 */ 306 307 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn); 307 308 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 } 322 311 323 312 /* … … 334 323 } 335 324 336 337 338 325 /* 339 326 * And now inform the host controller about the handle. … … 371 358 usb_pipe_end_session(&ctrl_pipe); 372 359 373 leave_ unregister_endpoint:360 leave_release_default_address: 374 361 usb_pipe_unregister(&ctrl_pipe, &hc_conn); 375 376 leave_release_default_address:377 usb_hc_release_default_address(&hc_conn);378 362 379 363 leave_release_free_address:
Note:
See TracChangeset
for help on using the changeset viewer.