Changeset 6e3c005 in mainline for uspace/lib/usbdev/src
- Timestamp:
- 2011-12-14T15:29:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0487a2
- Parents:
- 22ecbde
- Location:
- uspace/lib/usbdev/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/altiface.c
r22ecbde r6e3c005 167 167 } 168 168 169 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate) 169 /** Clean initialized structure. 170 * @param instance structure do deinitialize. 171 */ 172 void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *instance) 170 173 { 171 if (! alternate)174 if (!instance) 172 175 return; 173 free(alternate->alternatives); 176 free(instance->alternatives); 177 instance->alternatives = NULL; 174 178 } 175 179 /** -
uspace/lib/usbdev/src/devdrv.c
r22ecbde r6e3c005 516 516 } 517 517 518 /* Open hc connection for pipe registration. */ 518 519 rc = usb_hc_connection_open(&usb_dev->hc_conn); 519 520 if (rc != EOK) { … … 575 576 } 576 577 578 /** Allocate driver specific data. 579 * @param usb_dev usb_device structure. 580 * @param size requested data size. 581 * @return Pointer to the newly allocated space, NULL on failure. 582 */ 577 583 void * usb_device_data_alloc(usb_device_t *usb_dev, size_t size) 578 584 { -
uspace/lib/usbdev/src/devpoll.c
r22ecbde r6e3c005 46 46 /** Data needed for polling. */ 47 47 typedef struct { 48 /** Parameters for automated polling. */ 48 49 usb_device_auto_polling_t auto_polling; 49 50 51 /** USB device to poll. */ 50 52 usb_device_t *dev; 53 /** Device pipe to use for polling. */ 51 54 size_t pipe_index; 55 /** Size of the recieved data. */ 52 56 size_t request_size; 57 /** Data buffer. */ 53 58 uint8_t *buffer; 59 /** Argument to pass to callbacks. */ 54 60 void *custom_arg; 55 61 } polling_data_t; -
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: -
uspace/lib/usbdev/src/recognise.c
r22ecbde r6e3c005 324 324 } 325 325 326 327 326 /** Index to append after device name for uniqueness. */ 328 327 static atomic_t device_name_index = {0};
Note:
See TracChangeset
for help on using the changeset viewer.