Changes in uspace/lib/usbdev/src/pipes.c [79ae36dd:e8f826b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipes.c
r79ae36dd re8f826b 48 48 /** Tell USB address assigned to given device. 49 49 * 50 * @param sess Sessionto parent device.50 * @param phone Phone to parent device. 51 51 * @param dev Device in question. 52 52 * @return USB address or error code. 53 53 */ 54 static usb_address_t get_my_address( async_sess_t *sess, ddf_dev_t *dev)55 { 56 async_exch_t *exch = async_exchange_begin(sess);57 54 static usb_address_t get_my_address(int phone, ddf_dev_t *dev) 55 { 56 sysarg_t address; 57 58 58 /* 59 59 * We are sending special value as a handle - zero - to get … … 61 61 * when registering our device @p dev. 62 62 */ 63 sysarg_t address; 64 int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 65 IPC_M_USB_GET_ADDRESS, 0, &address); 66 67 async_exchange_end(exch); 68 69 if (rc != EOK) 63 int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE), 64 IPC_M_USB_GET_ADDRESS, 65 0, &address); 66 67 if (rc != EOK) { 70 68 return rc; 71 69 } 70 72 71 return (usb_address_t) address; 73 72 } … … 80 79 int usb_device_get_assigned_interface(ddf_dev_t *device) 81 80 { 82 async_sess_t *parent_sess = 83 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 81 int parent_phone = devman_parent_device_connect(device->handle, 84 82 IPC_FLAG_BLOCKING); 85 if ( !parent_sess)83 if (parent_phone < 0) { 86 84 return -1; 87 88 async_exch_t *exch = async_exchange_begin(parent_sess); 89 85 } 86 90 87 sysarg_t iface_no; 91 int rc = async_req_2_1( exch, DEV_IFACE_ID(USB_DEV_IFACE),92 IPC_M_USB_GET_INTERFACE, device->handle, &iface_no);93 94 async_exchange_end(exch); 95 async_hangup(parent_ sess);96 97 if (rc != EOK) 88 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 89 IPC_M_USB_GET_INTERFACE, 90 device->handle, &iface_no); 91 92 async_hangup(parent_phone); 93 94 if (rc != EOK) { 98 95 return -1; 99 96 } 97 100 98 return (int) iface_no; 101 99 } … … 112 110 assert(connection); 113 111 assert(dev); 114 112 115 113 int rc; 116 114 devman_handle_t hc_handle; 117 115 usb_address_t my_address; 118 116 119 117 rc = usb_hc_find(dev->handle, &hc_handle); 120 if (rc != EOK) 118 if (rc != EOK) { 121 119 return rc; 122 123 async_sess_t *parent_sess = 124 devman_parent_device_connect(EXCHANGE_SERIALIZE,dev->handle,120 } 121 122 int parent_phone = devman_parent_device_connect(dev->handle, 125 123 IPC_FLAG_BLOCKING); 126 if (!parent_sess) 127 return ENOMEM; 128 124 if (parent_phone < 0) { 125 return parent_phone; 126 } 127 129 128 /* 130 129 * Asking for "my" address may require several attempts. … … 138 137 * So, we need to wait for the HC to learn the binding. 139 138 */ 140 141 139 do { 142 my_address = get_my_address(parent_ sess, dev);143 140 my_address = get_my_address(parent_phone, dev); 141 144 142 if (my_address == ENOENT) { 145 143 /* Be nice, let other fibrils run and try again. */ … … 150 148 goto leave; 151 149 } 152 150 153 151 } while (my_address < 0); 154 152 155 153 rc = usb_device_connection_initialize(connection, 156 154 hc_handle, my_address); 157 155 158 156 leave: 159 async_hangup(parent_ sess);157 async_hangup(parent_phone); 160 158 return rc; 161 159 }
Note:
See TracChangeset
for help on using the changeset viewer.