Changeset 6e3c005 in mainline for uspace/lib/usbdev/src/hub.c
- Timestamp:
- 2011-12-14T15:29:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0487a2
- Parents:
- 22ecbde
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/hub.c
r22ecbde r6e3c005 38 38 #include <usb/dev/recognise.h> 39 39 #include <usb/debug.h> 40 #include <usbhc_iface.h>41 40 #include <errno.h> 42 41 #include <assert.h> … … 45 44 #include <async.h> 46 45 47 /** How much time to wait between attempts to register endpoint 0:0.46 /** How much time to wait between attempts to get the default address. 48 47 * The value is based on typical value for port reset + some overhead. 49 48 */ 50 #define ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC (1000 * (10 + 2)) 51 52 /** Check that HC connection is alright. 53 * 54 * @param conn Connection to be checked. 55 */ 56 #define CHECK_CONNECTION(conn) \ 57 do { \ 58 assert((conn)); \ 59 if (!usb_hc_connection_is_opened((conn))) { \ 60 usb_log_error("Connection not open.\n"); \ 61 return ENOTCONN; \ 62 } \ 63 } while (false) 64 49 #define DEFAULT_ADDRESS_ATTEMPT_DELAY_USEC (1000 * (10 + 2)) 65 50 66 51 /** Inform host controller about new device. … … 70 55 * @return Error code. 71 56 */ 72 int usb_h c_register_device(usb_hc_connection_t *connection,57 int usb_hub_register_device(usb_hc_connection_t *connection, 73 58 const usb_hub_attached_device_t *attached_device) 74 59 { 75 // CHECK_CONNECTION(connection);60 assert(connection); 76 61 if (attached_device == NULL || attached_device->fun == NULL) 77 return EINVAL; 78 79 async_exch_t *exch = async_exchange_begin(connection->hc_sess); 80 if (!exch) 81 return ENOMEM; 82 const int ret = usbhc_bind_address(exch, 62 return EBADMEM; 63 return usb_hc_bind_address(connection, 83 64 attached_device->address, attached_device->fun->handle); 84 async_exchange_end(exch);85 86 return ret;87 }88 89 /** Inform host controller about device removal.90 *91 * @param connection Opened connection to host controller.92 * @param address Address of the device that is being removed.93 * @return Error code.94 */95 int usb_hc_unregister_device(usb_hc_connection_t *connection,96 usb_address_t address)97 {98 // CHECK_CONNECTION(connection);99 100 async_exch_t *exch = async_exchange_begin(connection->hc_sess);101 if (!exch)102 return ENOMEM;103 const int ret = usbhc_release_address(exch, address);104 async_exchange_end(exch);105 106 return ret;107 65 } 108 66 … … 144 102 "Failed to unregister the old pipe on address change.\n"); 145 103 } 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); 104 /* Address changed. We can release the old one, thus 105 * allowing other to us it. */ 106 usb_hc_release_address(pipe->wire->hc_connection, pipe->wire->address); 150 107 151 108 /* The address is already changed so set it in the wire */ … … 256 213 if (rc == ENOENT) { 257 214 /* Do not overheat the CPU ;-). */ 258 async_usleep( ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC);215 async_usleep(DEFAULT_ADDRESS_ATTEMPT_DELAY_USEC); 259 216 } 260 217 } while (rc == ENOENT); … … 328 285 329 286 /* Inform the host controller about the handle. */ 330 rc = usb_h c_register_device(hc_conn, &new_device);287 rc = usb_hub_register_device(hc_conn, &new_device); 331 288 if (rc != EOK) { 332 289 /* We know nothing about that data. */ … … 353 310 */ 354 311 leave_release_default_address: 355 if (usb_hc_ unregister_device(hc_conn, USB_ADDRESS_DEFAULT) != EOK)356 usb_log_warning("%s: Failed to unregister defaut device.\n",312 if (usb_hc_release_address(hc_conn, USB_ADDRESS_DEFAULT) != EOK) 313 usb_log_warning("%s: Failed to release defaut address.\n", 357 314 __FUNCTION__); 358 315 … … 363 320 __FUNCTION__); 364 321 365 if (usb_hc_ unregister_device(hc_conn, dev_addr) != EOK)366 usb_log_warning("%s: Failed to unregister device.\n",367 __FUNCTION__ );322 if (usb_hc_release_address(hc_conn, dev_addr) != EOK) 323 usb_log_warning("%s: Failed to release address: %d.\n", 324 __FUNCTION__, dev_addr); 368 325 369 326 close_connection:
Note:
See TracChangeset
for help on using the changeset viewer.