Changes in / [39db23f:0c311d5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hub.c
r39db23f r0c311d5 178 178 * error codes than those listed as return codes by this function itself). 179 179 * 180 * The @p connection representing connection with host controller does not181 * need to be started.182 * This function duplicates the connection to allow simultaneous calls of183 * this function (i.e. from different fibrils).184 *185 180 * @param[in] parent Parent device (i.e. the hub device). 186 * @param[in] connection Connection to host controller.181 * @param[in] connection Opened connection to host controller. 187 182 * @param[in] dev_speed New device speed. 188 183 * @param[in] enable_port Function for enabling signaling through the port the … … 211 206 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 212 207 { 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 }; 208 CHECK_CONNECTION(connection); 209 210 /* 211 * Request new address. 212 */ 213 usb_address_t dev_addr = usb_hc_request_address(connection, dev_speed); 214 if (dev_addr < 0) { 215 return EADDRNOTAVAIL; 216 } 219 217 220 218 int rc; 221 219 222 rc = usb_hc_connection_open(&hc_conn);223 if (rc != EOK) {224 return rc;225 }226 227 228 /*229 * Request new address.230 */231 usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed);232 if (dev_addr < 0) {233 usb_hc_connection_close(&hc_conn);234 return EADDRNOTAVAIL;235 }236 237 238 220 /* 239 221 * Reserve the default address. 240 222 */ 241 rc = usb_hc_reserve_default_address( &hc_conn, dev_speed);223 rc = usb_hc_reserve_default_address(connection, dev_speed); 242 224 if (rc != EOK) { 243 225 rc = EBUSY; … … 259 241 usb_device_connection_t dev_conn; 260 242 rc = usb_device_connection_initialize_on_default_address(&dev_conn, 261 &hc_conn);243 connection); 262 244 if (rc != EOK) { 263 245 rc = ENOTCONN; … … 276 258 * endpoint. 277 259 */ 278 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);260 rc = usb_pipe_register(&ctrl_pipe, 0, connection); 279 261 if (rc != EOK) { 280 262 rc = EREFUSED; … … 304 286 * Register the control endpoint for the new device. 305 287 */ 306 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);288 rc = usb_pipe_register(&ctrl_pipe, 0, connection); 307 289 if (rc != EOK) { 308 290 rc = EREFUSED; … … 313 295 * Release the original endpoint. 314 296 */ 315 unregister_control_endpoint_on_default_address( &hc_conn);297 unregister_control_endpoint_on_default_address(connection); 316 298 317 299 /* 318 300 * Once the address is changed, we can return the default address. 319 301 */ 320 usb_hc_release_default_address( &hc_conn);302 usb_hc_release_default_address(connection); 321 303 322 304 … … 343 325 .handle = child_handle 344 326 }; 345 rc = usb_hc_register_device( &hc_conn, &new_device);327 rc = usb_hc_register_device(connection, &new_device); 346 328 if (rc != EOK) { 347 329 rc = EDESTADDRREQ; … … 372 354 373 355 leave_unregister_endpoint: 374 usb_pipe_unregister(&ctrl_pipe, &hc_conn);356 usb_pipe_unregister(&ctrl_pipe, connection); 375 357 376 358 leave_release_default_address: 377 usb_hc_release_default_address( &hc_conn);359 usb_hc_release_default_address(connection); 378 360 379 361 leave_release_free_address: 380 usb_hc_unregister_device(&hc_conn, dev_addr); 381 382 usb_hc_connection_close(&hc_conn); 362 usb_hc_unregister_device(connection, dev_addr); 383 363 384 364 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.