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