Changeset c7d5189 in mainline for uspace/lib/usbhost/src/ddf_helpers.c
- Timestamp:
- 2018-01-19T13:12:57Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a4e7e6e1
- Parents:
- 7138a78b
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-19 13:08:12)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-19 13:12:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
r7138a78b rc7d5189 393 393 } 394 394 395 int hcd_device_explore(device_t *device) 396 { 397 int err; 398 match_id_list_t mids; 399 usb_standard_device_descriptor_t desc = { 0 }; 400 401 init_match_ids(&mids); 402 395 int hcd_get_device_desc(device_t *device, usb_standard_device_descriptor_t *desc) 396 { 403 397 const usb_target_t control_ep = {{ 404 398 .address = device->address, … … 408 402 /* Get std device descriptor */ 409 403 const usb_device_request_setup_packet_t get_device_desc = 410 GET_DEVICE_DESC(sizeof( desc));404 GET_DEVICE_DESC(sizeof(*desc)); 411 405 412 406 usb_log_debug("Device(%d): Requesting full device descriptor.", 413 407 device->address); 414 408 ssize_t got = bus_device_send_batch_sync(device, control_ep, USB_DIRECTION_IN, 415 (char *) &desc, sizeof(desc), *(uint64_t *)&get_device_desc,409 (char *) desc, sizeof(*desc), *(uint64_t *)&get_device_desc, 416 410 "read device descriptor"); 417 if (got < 0) { 418 err = got < 0 ? got : EOVERFLOW; 419 usb_log_error("Device(%d): Failed to set get dev descriptor: %s", 420 device->address, str_error(err)); 421 goto out; 422 } 411 412 if (got < 0) 413 return got; 414 415 return got == sizeof(*desc) ? EOK : EOVERFLOW; 416 } 417 418 int hcd_setup_match_ids(device_t *device, usb_standard_device_descriptor_t *desc) 419 { 420 int err; 421 match_id_list_t mids; 422 423 init_match_ids(&mids); 423 424 424 425 /* Create match ids from the device descriptor */ 425 426 usb_log_debug("Device(%d): Creating match IDs.", device->address); 426 if ((err = create_match_ids(&mids, &desc))) { 427 usb_log_error("Device(%d): Failed to create match ids: %s", device->address, str_error(err)); 428 goto out; 427 if ((err = create_match_ids(&mids, desc))) { 428 return err; 429 429 } 430 430 … … 433 433 } 434 434 435 out: 436 clean_match_ids(&mids); 437 return err; 435 return EOK; 436 } 437 438 439 int hcd_device_explore(device_t *device) 440 { 441 int err; 442 usb_standard_device_descriptor_t desc = { 0 }; 443 444 if ((err = hcd_get_device_desc(device, &desc))) { 445 usb_log_error("Device(%d): Failed to get dev descriptor: %s", 446 device->address, str_error(err)); 447 return err; 448 } 449 450 if ((err = hcd_setup_match_ids(device, &desc))) { 451 usb_log_error("Device(%d): Failed to setup match ids: %s", device->address, str_error(err)); 452 return err; 453 } 454 455 return EOK; 438 456 } 439 457
Note:
See TracChangeset
for help on using the changeset viewer.