Changes in uspace/drv/usbhub/usbhub.c [ba5ab09:f40a1e2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rba5ab09 rf40a1e2 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbhub28 /** @addtogroup usb hub driver 29 29 * @{ 30 30 */ … … 76 76 //get some hub info 77 77 usb_address_t addr = usb_drv_get_my_address(hc, device); 78 dprintf(1, "address of newly created hub = %d", addr);78 dprintf(1,"[usb_hub] address of newly created hub = %d", addr); 79 79 /*if(addr<0){ 80 80 //return result; … … 100 100 101 101 if (opResult != EOK) { 102 dprintf(1, "failed when receiving hub descriptor, badcode = %d",opResult);102 dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult); 103 103 free(serialized_descriptor); 104 104 return result; … … 107 107 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 108 108 if(descriptor==NULL){ 109 dprintf(1, "could not deserialize descriptor ");109 dprintf(1,"[usb_hub] could not deserialize descriptor "); 110 110 result->port_count = 1;///\TODO this code is only for debug!!! 111 111 return result; … … 127 127 //finish 128 128 129 dprintf(1, "hub info created");129 dprintf(1,"[usb_hub] hub info created"); 130 130 131 131 return result; … … 134 134 int usb_add_hub_device(device_t *dev) { 135 135 dprintf(1, "add_hub_device(handle=%d)", (int) dev->handle); 136 dprintf(1, "hub device");136 dprintf(1,"[usb_hub] hub device"); 137 137 138 138 /* … … 162 162 usb_standard_device_descriptor_t std_descriptor; 163 163 opResult = usb_drv_req_get_device_descriptor(hc, target.address, 164 164 &std_descriptor); 165 165 if(opResult!=EOK){ 166 dprintf(1, "could not get device descriptor, %d",opResult);166 dprintf(1,"[usb_hub] could not get device descriptor, %d",opResult); 167 167 return opResult; 168 168 } 169 dprintf(1, "hub has %d configurations",std_descriptor.configuration_count);169 dprintf(1,"[usb_hub] hub has %d configurations",std_descriptor.configuration_count); 170 170 if(std_descriptor.configuration_count<1){ 171 dprintf(1, "THERE ARE NO CONFIGURATIONS AVAILABLE");171 dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE"); 172 172 //shouldn`t I return? 173 173 } … … 178 178 &config_descriptor); 179 179 if(opResult!=EOK){ 180 dprintf(1, "could not get configuration descriptor, %d",opResult);180 dprintf(1,"[usb_hub] could not get configuration descriptor, %d",opResult); 181 181 return opResult; 182 182 } … … 186 186 187 187 if (opResult != EOK) { 188 dprintf(1, "something went wrong when setting hub`s configuration, %d", opResult);188 dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult); 189 189 } 190 190 … … 193 193 usb_hub_set_power_port_request(&request, port); 194 194 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 195 dprintf(1, "powering port %d",port);195 dprintf(1,"[usb_hub] powering port %d",port); 196 196 if (opResult != EOK) { 197 dprintf(1, "something went wrong when setting hub`s %dth port", port);197 dprintf(1,"[usb_hub]something went wrong when setting hub`s %dth port", port); 198 198 } 199 199 } … … 203 203 204 204 //add the hub to list 205 f ibril_mutex_lock(&usb_hub_list_lock);205 futex_down(&usb_hub_list_lock); 206 206 usb_lst_append(&usb_hub_list, hub_info); 207 f ibril_mutex_unlock(&usb_hub_list_lock);208 209 dprintf(1, "hub info added to list");207 futex_up(&usb_hub_list_lock); 208 209 dprintf(1,"[usb_hub] hub info added to list"); 210 210 //(void)hub_info; 211 211 usb_hub_check_hub_changes(); … … 213 213 214 214 215 dprintf(1, "hub dev added");216 dprintf(1, 215 dprintf(1,"[usb_hub] hub dev added"); 216 dprintf(1,"\taddress %d, has %d ports ", 217 217 hub_info->usb_device->address, 218 218 hub_info->port_count); 219 dprintf(1, 219 dprintf(1,"\tused configuration %d",config_descriptor.configuration_number); 220 220 221 221 return EOK; … … 238 238 inline static int usb_hub_release_default_address(int hc){ 239 239 int opResult; 240 dprintf(1, "releasing default address");240 dprintf(1,"[usb_hub] releasing default address"); 241 241 opResult = usb_drv_release_default_address(hc); 242 242 if (opResult != EOK) { 243 dprintf(1, "failed to release default address");243 dprintf(1,"[usb_hub] failed to release default address"); 244 244 } 245 245 return opResult; … … 255 255 usb_device_request_setup_packet_t request; 256 256 int opResult; 257 dprintf(1, "some connection changed");257 dprintf(1,"[usb_hub] some connection changed"); 258 258 //get default address 259 259 opResult = usb_drv_reserve_default_address(hc); 260 260 if (opResult != EOK) { 261 dprintf(1, "cannot assign default address, it is probably used");261 dprintf(1,"[usb_hub] cannot assign default address, it is probably used"); 262 262 return; 263 263 } … … 270 270 ); 271 271 if (opResult != EOK) { 272 dprintf(1, "something went wrong when reseting a port");272 dprintf(1,"[usb_hub] something went wrong when reseting a port"); 273 273 usb_hub_release_default_address(hc); 274 274 } … … 285 285 286 286 int opResult; 287 dprintf(1, "finalizing add device");287 dprintf(1,"[usb_hub] finalizing add device"); 288 288 opResult = usb_hub_clear_port_feature(hc, target.address, 289 289 port, USB_HUB_FEATURE_C_PORT_RESET); 290 290 if (opResult != EOK) { 291 dprintf(1, "failed to clear port reset feature");291 dprintf(1,"[usb_hub] failed to clear port reset feature"); 292 292 usb_hub_release_default_address(hc); 293 293 return; … … 297 297 usb_address_t new_device_address = usb_drv_request_address(hc); 298 298 if (new_device_address < 0) { 299 dprintf(1, "failed to get free USB address");299 dprintf(1,"[usb_hub] failed to get free USB address"); 300 300 opResult = new_device_address; 301 301 usb_hub_release_default_address(hc); 302 302 return; 303 303 } 304 dprintf(1, "setting new address");304 dprintf(1,"[usb_hub] setting new address"); 305 305 opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 306 306 new_device_address); 307 307 308 308 if (opResult != EOK) { 309 dprintf(1, "could not set address for new device");309 dprintf(1,"[usb_hub] could not set address for new device"); 310 310 usb_hub_release_default_address(hc); 311 311 return; … … 322 322 new_device_address, &child_handle); 323 323 if (opResult != EOK) { 324 dprintf(1, "could not start driver for new device");324 dprintf(1,"[usb_hub] could not start driver for new device"); 325 325 return; 326 326 } … … 330 330 opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 331 331 if (opResult != EOK) { 332 dprintf(1, "could not assign address of device in hcd");333 return; 334 } 335 dprintf(1, "new device address %d, handle %zu",332 dprintf(1,"[usb_hub] could not assign address of device in hcd"); 333 return; 334 } 335 dprintf(1,"[usb_hub] new device address %d, handle %zu", 336 336 new_device_address, child_handle); 337 337 … … 358 358 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 359 359 if(opResult != EOK) { 360 dprintf(1, "could not release address of " \ 361 "removed device: %d", opResult); 360 dprintf(1, 361 "[usb_hub] could not release address of removed device: %d" 362 ,opResult); 362 363 } 363 364 hub->attached_devs[port].address = 0; 364 365 }else{ 365 dprintf(1, "this is strange, disconnected device had no address"); 366 dprintf(1, 367 "[usb_hub] this is strange, disconnected device had no address"); 366 368 //device was disconnected before it`s port was reset - return default address 367 369 usb_drv_release_default_address(hc); … … 377 379 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, 378 380 uint16_t port, usb_address_t address) { 379 dprintf(1, "interrupt at port %d", port);381 dprintf(1,"[usb_hub] interrupt at port %d", port); 380 382 //determine type of change 381 383 usb_target_t target; … … 395 397 ); 396 398 if (opResult != EOK) { 397 dprintf(1, "ERROR: could not get port status");399 dprintf(1,"[usb_hub] ERROR: could not get port status"); 398 400 return; 399 401 } 400 402 if (rcvd_size != sizeof (usb_port_status_t)) { 401 dprintf(1, "ERROR: received status has incorrect size");403 dprintf(1,"[usb_hub] ERROR: received status has incorrect size"); 402 404 return; 403 405 } … … 408 410 // TODO: check opResult 409 411 if (usb_port_dev_connected(&status)) { 410 dprintf(1, "some connection changed");412 dprintf(1,"[usb_hub] some connection changed"); 411 413 usb_hub_init_add_device(hc, port, target); 412 414 } else { … … 416 418 //port reset 417 419 if (usb_port_reset_completed(&status)) { 418 dprintf(1, "port reset complete");420 dprintf(1,"[usb_hub] port reset complete"); 419 421 if (usb_port_enabled(&status)) { 420 422 usb_hub_finalize_add_device(hub, hc, port, target); 421 423 } else { 422 dprintf(1, "ERROR: port reset, but port still not enabled");424 dprintf(1,"[usb_hub] ERROR: port reset, but port still not enabled"); 423 425 } 424 426 } … … 429 431 usb_port_set_dev_connected(&status, false); 430 432 if (status>>16) { 431 dprintf(1, "there was some unsupported change on port %d: %X",port,status);433 dprintf(1,"[usb_hub]there was some unsupported change on port %d: %X",port,status); 432 434 433 435 } … … 445 447 */ 446 448 usb_general_list_t * lst_item; 447 f ibril_mutex_lock(&usb_hub_list_lock);449 futex_down(&usb_hub_list_lock); 448 450 for (lst_item = usb_hub_list.next; 449 451 lst_item != &usb_hub_list; 450 452 lst_item = lst_item->next) { 451 f ibril_mutex_unlock(&usb_hub_list_lock);453 futex_up(&usb_hub_list_lock); 452 454 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 453 455 /* … … 458 460 target.address = hub_info->usb_device->address; 459 461 target.endpoint = 1;/// \TODO get from endpoint descriptor 460 dprintf(1, "checking changes for hub at addr %d",462 dprintf(1,"[usb_hub] checking changes for hub at addr %d", 461 463 target.address); 462 464 … … 488 490 489 491 if (opResult != EOK) { 490 free(change_bitmap); 491 dprintf(1, "something went wrong while getting status of hub"); 492 dprintf(1,"[usb_hub] something went wrong while getting status of hub"); 492 493 continue; 493 494 } … … 504 505 505 506 ipc_hangup(hc); 506 f ibril_mutex_lock(&usb_hub_list_lock);507 } 508 f ibril_mutex_unlock(&usb_hub_list_lock);507 futex_down(&usb_hub_list_lock); 508 } 509 futex_up(&usb_hub_list_lock); 509 510 } 510 511
Note:
See TracChangeset
for help on using the changeset viewer.