Changeset 7267fa1 in mainline
- Timestamp:
- 2011-12-11T17:51:21Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c0fdc0e
- Parents:
- 023a902
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/hub.c
r023a902 r7267fa1 121 121 * @return Error code. 122 122 */ 123 static int usb_request_set_address(usb_pipe_t *pipe, usb_address_t new_address, 124 usb_hc_connection_t *hc_conn) 123 static int usb_request_set_address(usb_pipe_t *pipe, usb_address_t new_address) 125 124 { 126 125 if ((new_address < 0) || (new_address >= USB11_ADDRESS_MAX)) { … … 128 127 } 129 128 assert(pipe); 130 assert(hc_conn);131 129 assert(pipe->wire != NULL); 132 130 … … 146 144 "Failed to unregister the old pipe on address change.\n"); 147 145 } 146 /* Address changed. We can release the default, thus 147 * allowing other to access the default address. */ 148 usb_hc_unregister_device(pipe->wire->hc_connection, 149 pipe->wire->address); 150 148 151 /* The address is already changed so set it in the wire */ 149 152 pipe->wire->address = new_address; … … 196 199 */ 197 200 int usb_hc_new_device_wrapper(ddf_dev_t *parent, 198 usb_hc_connection_t * connection, usb_speed_t dev_speed,201 usb_hc_connection_t *hc_conn, usb_speed_t dev_speed, 199 202 int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address, 200 203 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 201 204 { 202 if (new_fun == NULL || connection == NULL)205 if (new_fun == NULL || hc_conn == NULL) 203 206 return EINVAL; 204 205 // TODO: Why not use provided connection?206 usb_hc_connection_t hc_conn;207 usb_hc_connection_initialize(&hc_conn, connection->hc_handle);208 207 209 208 int rc; … … 215 214 } 216 215 217 rc = usb_hc_connection_open(&hc_conn); 216 /* We are gona do a lot of communication better open it in advance. */ 217 rc = usb_hc_connection_open(hc_conn); 218 218 if (rc != EOK) { 219 219 return rc; 220 220 } 221 221 222 /* 223 * Request new address. 224 */ 222 /* Request a new address. */ 225 223 usb_address_t dev_addr = 226 usb_hc_request_address( &hc_conn, 0, false, dev_speed);224 usb_hc_request_address(hc_conn, 0, false, dev_speed); 227 225 if (dev_addr < 0) { 228 226 rc = EADDRNOTAVAIL; 229 227 goto close_connection; 228 } 229 230 /* Initialize connection to device. */ 231 usb_device_connection_t dev_conn; 232 rc = usb_device_connection_initialize_on_default_address( 233 &dev_conn, hc_conn); 234 if (rc != EOK) { 235 rc = ENOTCONN; 236 goto leave_release_free_address; 230 237 } 231 238 … … 236 243 * (Someone else already wants to add a new device.) 237 244 */ 238 usb_device_connection_t dev_conn;239 rc = usb_device_connection_initialize_on_default_address(&dev_conn,240 &hc_conn);241 if (rc != EOK) {242 rc = ENOTCONN;243 goto leave_release_free_address;244 }245 246 245 usb_pipe_t ctrl_pipe; 247 246 rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_conn); … … 252 251 253 252 do { 254 rc = usb_hc_request_address( &hc_conn, USB_ADDRESS_DEFAULT,253 rc = usb_hc_request_address(hc_conn, USB_ADDRESS_DEFAULT, 255 254 true, dev_speed); 256 255 if (rc == ENOENT) { … … 306 305 } 307 306 308 rc = usb_request_set_address(&ctrl_pipe, dev_addr , &hc_conn);307 rc = usb_request_set_address(&ctrl_pipe, dev_addr); 309 308 if (rc != EOK) { 310 309 rc = ESTALL; … … 312 311 } 313 312 314 /* Address changed. We can release the default, thus315 * allowing other to access the default address. */316 usb_hc_unregister_device(&hc_conn, USB_ADDRESS_DEFAULT);317 313 318 314 /* Register the device with devman. */ … … 332 328 333 329 /* Inform the host controller about the handle. */ 334 rc = usb_hc_register_device( &hc_conn, &new_device);330 rc = usb_hc_register_device(hc_conn, &new_device); 335 331 if (rc != EOK) { 336 332 /* We know nothing about that data. */ … … 357 353 */ 358 354 leave_release_default_address: 359 usb_hc_unregister_device( &hc_conn, USB_ADDRESS_DEFAULT);355 usb_hc_unregister_device(hc_conn, USB_ADDRESS_DEFAULT); 360 356 361 357 leave_release_free_address: … … 365 361 __FUNCTION__); 366 362 367 if (usb_hc_unregister_device( &hc_conn, dev_addr) != EOK)363 if (usb_hc_unregister_device(hc_conn, dev_addr) != EOK) 368 364 usb_log_warning("%s: Failed to unregister device.\n", 369 365 __FUNCTION__); 370 366 371 367 close_connection: 372 if (usb_hc_connection_close( &hc_conn) != EOK)368 if (usb_hc_connection_close(hc_conn) != EOK) 373 369 usb_log_warning("%s: Failed to close hc connection.\n", 374 370 __FUNCTION__);
Note:
See TracChangeset
for help on using the changeset viewer.