Changeset e280857 in mainline for uspace/app/lsusb/main.c
- Timestamp:
- 2011-08-18T12:35:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99ac5cf
- Parents:
- 12f9f0d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/lsusb/main.c
r12f9f0d0 re280857 50 50 51 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX 52 #define MAX_FAILED_ATTEMPTS 1053 52 #define MAX_PATH_LENGTH 1024 54 53 55 static void print_found_hc(s ize_t class_index, const char *path)54 static void print_found_hc(service_id_t sid, const char *path) 56 55 { 57 56 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 58 printf("Bus % 02zu: %s\n", class_index, path);57 printf("Bus %" PRIun ": %s\n", sid, path); 59 58 } 60 59 static void print_found_dev(usb_address_t addr, const char *path) … … 95 94 int main(int argc, char *argv[]) 96 95 { 97 size_t class_index = 0; 98 size_t failed_attempts = 0; 96 category_id_t usbhc_cat; 97 service_id_t *svcs; 98 size_t count; 99 size_t i; 100 int rc; 99 101 100 while (failed_attempts < MAX_FAILED_ATTEMPTS) { 101 class_index++; 102 rc = loc_category_get_id(USB_HC_DDF_CLASS_NAME, &usbhc_cat, 0); 103 if (rc != EOK) { 104 printf(NAME ": Error resolving category '%s'", 105 USB_HC_DDF_CLASS_NAME); 106 return 1; 107 } 108 109 rc = loc_category_get_svcs(usbhc_cat, &svcs, &count); 110 if (rc != EOK) { 111 printf(NAME ": Error getting list of host controllers.\n"); 112 return 1; 113 } 114 115 for (i = 0; i < count; i++) { 102 116 devman_handle_t hc_handle = 0; 103 int rc = usb_ddf_get_hc_handle_by_ class(class_index, &hc_handle);117 int rc = usb_ddf_get_hc_handle_by_sid(svcs[i], &hc_handle); 104 118 if (rc != EOK) { 105 failed_attempts++; 119 printf(NAME ": Error resolving handle of HC with SID %" 120 PRIun ", skipping.\n", svcs[i]); 106 121 continue; 107 122 } … … 109 124 rc = devman_get_device_path(hc_handle, path, MAX_PATH_LENGTH); 110 125 if (rc != EOK) { 126 printf(NAME ": Error resolving path of HC with SID %" 127 PRIun ", skipping.\n", svcs[i]); 111 128 continue; 112 129 } 113 print_found_hc( class_index, path);130 print_found_hc(svcs[i], path); 114 131 print_hc_devices(hc_handle); 115 132 } 133 134 free(svcs); 116 135 117 136 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.