Changes in uspace/lib/usb/src/hub.c [b6c9e1e:4ede178] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hub.c
rb6c9e1e r4ede178 40 40 #include <errno.h> 41 41 #include <assert.h> 42 #include <usb/debug.h>43 42 44 43 /** Check that HC connection is alright. … … 56 55 57 56 /** Tell host controller to reserve default address. 58 * @deprecated59 57 * 60 58 * @param connection Opened connection to host controller. … … 67 65 CHECK_CONNECTION(connection); 68 66 69 usb_log_warning("usb_hc_reserve_default_address() considered obsolete");70 71 67 return async_req_2_0(connection->hc_phone, 72 68 DEV_IFACE_ID(USBHC_DEV_IFACE), … … 75 71 76 72 /** Tell host controller to release default address. 77 * @deprecated78 73 * 79 74 * @param connection Opened connection to host controller. … … 83 78 { 84 79 CHECK_CONNECTION(connection); 85 86 usb_log_warning("usb_hc_release_default_address() considered obsolete");87 80 88 81 return async_req_1_0(connection->hc_phone, … … 242 235 } 243 236 244 /* 245 * We will not register control pipe on default address. 246 * The registration might fail. That means that someone else already 247 * registered that endpoint. We will simply wait and try again. 248 * (Someone else already wants to add a new device.) 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. 249 258 */ 250 259 usb_device_connection_t dev_conn; … … 253 262 if (rc != EOK) { 254 263 rc = ENOTCONN; 255 goto leave_release_ free_address;264 goto leave_release_default_address; 256 265 } 257 266 … … 261 270 if (rc != EOK) { 262 271 rc = ENOTCONN; 263 goto leave_release_free_address; 264 } 265 266 do { 267 rc = usb_pipe_register_with_speed(&ctrl_pipe, dev_speed, 0, 268 &hc_conn); 269 if (rc != EOK) { 270 /* Do not overheat the CPU ;-). */ 271 async_usleep(10); 272 } 273 } while (rc != EOK); 274 275 /* 276 * Endpoint is registered. We can enable the port and change 277 * device address. 278 */ 279 rc = enable_port(port_no, arg); 280 if (rc != EOK) { 281 goto leave_release_default_address; 282 } 283 272 goto leave_release_default_address; 273 } 274 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; 281 goto leave_release_default_address; 282 } 284 283 rc = usb_pipe_probe_default_control(&ctrl_pipe); 285 if (rc != EOK) {286 rc = ESTALL;287 goto leave_release_default_address;288 }289 290 291 rc = usb_pipe_start_session(&ctrl_pipe);292 284 if (rc != EOK) { 293 285 rc = ENOTCONN; … … 301 293 } 302 294 303 usb_pipe_end_session(&ctrl_pipe); 304 305 /* 306 * Address changed. We can release the original endpoint, thus 307 * allowing other to access the default address. 295 /* 296 * Register the control endpoint for the new device. 297 */ 298 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn); 299 if (rc != EOK) { 300 rc = EREFUSED; 301 goto leave_unregister_endpoint; 302 } 303 304 /* 305 * Release the original endpoint. 308 306 */ 309 307 unregister_control_endpoint_on_default_address(&hc_conn); 310 308 311 309 /* 312 * Time to register the new endpoint. 313 */ 314 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn); 315 if (rc != EOK) { 316 goto leave_release_free_address; 317 } 310 * Once the address is changed, we can return the default address. 311 */ 312 usb_hc_release_default_address(&hc_conn); 313 318 314 319 315 /* … … 330 326 } 331 327 328 329 332 330 /* 333 331 * And now inform the host controller about the handle. … … 365 363 usb_pipe_end_session(&ctrl_pipe); 366 364 365 leave_unregister_endpoint: 366 usb_pipe_unregister(&ctrl_pipe, &hc_conn); 367 367 368 leave_release_default_address: 368 usb_ pipe_unregister(&ctrl_pipe,&hc_conn);369 usb_hc_release_default_address(&hc_conn); 369 370 370 371 leave_release_free_address:
Note:
See TracChangeset
for help on using the changeset viewer.