Changes in uspace/app/lsusb/main.c [7beb220:0edf7c7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/lsusb/main.c
r7beb220 r0edf7c7 43 43 #include <getopt.h> 44 44 #include <devman.h> 45 #include < loc.h>45 #include <devmap.h> 46 46 #include <usb/dev/hub.h> 47 47 #include <usb/hc.h> … … 50 50 51 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX 52 #define MAX_FAILED_ATTEMPTS 10 52 53 #define MAX_PATH_LENGTH 1024 53 54 54 static void print_found_hc(s ervice_id_t sid, const char *path)55 static void print_found_hc(size_t class_index, const char *path) 55 56 { 56 printf("Bus %" PRIun ": %s\n", sid, path); 57 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 58 printf("Bus %02zu: %s\n", class_index, path); 57 59 } 58 60 static void print_found_dev(usb_address_t addr, const char *path) 59 61 { 62 // printf(NAME ": device with address %d is `%s'.\n", addr, path); 60 63 printf(" Device %02d: %s\n", addr, path); 61 64 } … … 81 84 } 82 85 char path[MAX_PATH_LENGTH]; 83 rc = devman_ fun_get_path(dev_handle, path, MAX_PATH_LENGTH);86 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH); 84 87 if (rc != EOK) { 85 88 continue; … … 92 95 int main(int argc, char *argv[]) 93 96 { 94 category_id_t usbhc_cat; 95 service_id_t *svcs; 96 size_t count; 97 size_t i; 98 int rc; 97 size_t class_index = 0; 98 size_t failed_attempts = 0; 99 99 100 rc = loc_category_get_id(USB_HC_CATEGORY, &usbhc_cat, 0); 101 if (rc != EOK) { 102 printf(NAME ": Error resolving category '%s'", 103 USB_HC_CATEGORY); 104 return 1; 105 } 106 107 rc = loc_category_get_svcs(usbhc_cat, &svcs, &count); 108 if (rc != EOK) { 109 printf(NAME ": Error getting list of host controllers.\n"); 110 return 1; 111 } 112 113 for (i = 0; i < count; i++) { 100 while (failed_attempts < MAX_FAILED_ATTEMPTS) { 101 class_index++; 114 102 devman_handle_t hc_handle = 0; 115 int rc = usb_ddf_get_hc_handle_by_ sid(svcs[i], &hc_handle);103 int rc = usb_ddf_get_hc_handle_by_class(class_index, &hc_handle); 116 104 if (rc != EOK) { 117 printf(NAME ": Error resolving handle of HC with SID %" 118 PRIun ", skipping.\n", svcs[i]); 105 failed_attempts++; 119 106 continue; 120 107 } 121 108 char path[MAX_PATH_LENGTH]; 122 rc = devman_ fun_get_path(hc_handle, path, MAX_PATH_LENGTH);109 rc = devman_get_device_path(hc_handle, path, MAX_PATH_LENGTH); 123 110 if (rc != EOK) { 124 printf(NAME ": Error resolving path of HC with SID %"125 PRIun ", skipping.\n", svcs[i]);126 111 continue; 127 112 } 128 print_found_hc( svcs[i], path);113 print_found_hc(class_index, path); 129 114 print_hc_devices(hc_handle); 130 115 } 131 132 free(svcs);133 116 134 117 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.