Changes in uspace/drv/usbhub/utils.c [4317827:9ca0013] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/utils.c
r4317827 r9ca0013 109 109 //********************************************* 110 110 111 static void set_hub_address(device_t *dev, usb_address_t address);112 113 111 usb_hcd_hub_info_t * usb_create_hub_info(device_t * device) { 114 112 usb_hcd_hub_info_t* result = (usb_hcd_hub_info_t*) malloc(sizeof (usb_hcd_hub_info_t)); … … 124 122 int usb_add_hub_device(device_t *dev) { 125 123 printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle); 126 set_hub_address(dev, 5);127 124 128 125 check_hub_changes(); … … 142 139 } 143 140 144 /** Sample usage of usb_hc_async functions.145 * This function sets hub address using standard SET_ADDRESS request.146 *147 * @warning This function shall be removed once you are familiar with148 * the usb_hc_ API.149 *150 * @param hc Host controller the hub belongs to.151 * @param address New hub address.152 */153 static void set_hub_address(device_t *dev, usb_address_t address) {154 printf(NAME ": setting hub address to %d\n", address);155 usb_target_t target = {0, 0};156 usb_handle_t handle;157 int rc;158 159 usb_device_request_setup_packet_t setup_packet = {160 .request_type = 0,161 .request = USB_DEVREQ_SET_ADDRESS,162 .index = 0,163 .length = 0,164 };165 setup_packet.value = address;166 167 int hc = usb_drv_hc_connect(dev, 0);168 169 rc = usb_drv_async_control_write_setup(hc, target,170 &setup_packet, sizeof (setup_packet), &handle);171 if (rc != EOK) {172 return;173 }174 175 rc = usb_drv_async_wait_for(handle);176 if (rc != EOK) {177 return;178 }179 180 rc = usb_drv_async_control_write_status(hc, target, &handle);181 if (rc != EOK) {182 return;183 }184 185 rc = usb_drv_async_wait_for(handle);186 if (rc != EOK) {187 return;188 }189 190 printf(NAME ": hub address changed\n");191 }192 141 193 142 /** Check changes on all known hubs. … … 237 186 */ 238 187 188 /* 189 * WARNING: sample code, will not work out of the box. 190 * And does not contain code for checking for errors. 191 */ 192 #if 0 193 /* 194 * Before opening the port, we must acquire the default 195 * address. 196 */ 197 usb_drv_reserve_default_address(hc); 198 199 usb_address_t new_device_address = usb_drv_request_address(hc); 200 201 // TODO: open the port 202 203 // TODO: send request for setting address to new_device_address 204 205 /* 206 * Once new address is set, we can release the default 207 * address. 208 */ 209 usb_drv_release_default_address(hc); 210 211 /* 212 * Obtain descriptors and create match ids for devman. 213 */ 214 215 // TODO: get device descriptors 216 217 // TODO: create match ids 218 219 // TODO: add child device 220 221 // child_device_register sets the device handle 222 // TODO: store it here 223 devman_handle_t new_device_handle = 0; 224 225 /* 226 * Inform the HC that the new device has devman handle 227 * assigned. 228 */ 229 usb_drv_bind_address(hc, new_device_address, new_device_handle); 230 231 /* 232 * That's all. 233 */ 234 #endif 235 239 236 240 237 /*
Note:
See TracChangeset
for help on using the changeset viewer.