Changeset 361e61b in mainline for uspace/lib/usb/src/pipes.c
- Timestamp:
- 2011-03-21T14:23:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 55e388a1
- Parents:
- c32688d (diff), 48fe0c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipes.c
rc32688d r361e61b 42 42 #include <assert.h> 43 43 44 #define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */ 45 44 46 /** Tell USB address assigned to given device. 45 47 * … … 51 53 { 52 54 sysarg_t address; 53 54 55 55 56 /* … … 96 97 } 97 98 99 /** Tell USB address assigned to given device. 100 * 101 * @param dev_handle Devman handle of the USB device in question. 102 * @return USB address or negative error code. 103 */ 104 usb_address_t usb_device_get_assigned_address(devman_handle_t dev_handle) 105 { 106 int parent_phone = devman_parent_device_connect(dev_handle, 107 IPC_FLAG_BLOCKING); 108 if (parent_phone < 0) { 109 return parent_phone; 110 } 111 112 sysarg_t address; 113 114 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 115 IPC_M_USB_GET_ADDRESS, 116 dev_handle, &address); 117 118 if (rc != EOK) { 119 return rc; 120 } 121 122 async_hangup(parent_phone); 123 124 return (usb_address_t) address; 125 } 126 98 127 /** Initialize connection to USB device. 99 128 * … … 123 152 } 124 153 125 my_address = get_my_address(parent_phone, dev); 126 if (my_address < 0) { 127 rc = my_address; 128 goto leave; 129 } 154 /* 155 * Asking for "my" address may require several attempts. 156 * That is because following scenario may happen: 157 * - parent driver (i.e. driver of parent device) announces new device 158 * and devman launches current driver 159 * - parent driver is preempted and thus does not send address-handle 160 * binding to HC driver 161 * - this driver gets here and wants the binding 162 * - the HC does not know the binding yet and thus it answers ENOENT 163 * So, we need to wait for the HC to learn the binding. 164 */ 165 do { 166 my_address = get_my_address(parent_phone, dev); 167 168 if (my_address == ENOENT) { 169 /* Be nice, let other fibrils run and try again. */ 170 async_usleep(IPC_AGAIN_DELAY); 171 } else if (my_address < 0) { 172 /* Some other problem, no sense trying again. */ 173 rc = my_address; 174 goto leave; 175 } 176 177 } while (my_address < 0); 130 178 131 179 rc = usb_device_connection_initialize(connection,
Note:
See TracChangeset
for help on using the changeset viewer.