Changeset 16b64b8 in mainline
- Timestamp:
- 2013-01-15T19:56:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 918e1e84
- Parents:
- 94fbf78
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/list.c
r94fbf78 r16b64b8 46 46 #include <usb/dev/hub.h> 47 47 #include <usb/hc.h> 48 #include <usb_iface.h> 48 49 49 50 #include "usbinfo.h" … … 90 91 } 91 92 93 static void print_usb_devices(devman_handle_t bus_handle, 94 devman_handle_t *fhs, size_t count) 95 { 96 for (size_t i = 0; i < count; ++i) { 97 if (fhs[i] == bus_handle) 98 continue; 99 char path[MAX_PATH_LENGTH]; 100 int rc = devman_fun_get_path(fhs[i], path, MAX_PATH_LENGTH); 101 if (rc != EOK) { 102 printf(NAME "Failed to get path for device %" PRIun 103 "\n", fhs[i]); 104 continue; 105 } 106 // TODO remove this. Device name contains USB address 107 // and addresses as external id are going away 108 usb_dev_session_t *sess = usb_dev_connect(fhs[i]); 109 if (!sess) { 110 printf(NAME "Failed to connect to device %" PRIun 111 "\n", fhs[i]); 112 continue; 113 } 114 async_exch_t *exch = async_exchange_begin(sess); 115 if (!exch) { 116 printf("Failed to create exchange to dev %" PRIun 117 "\n", fhs[i]); 118 usb_dev_session_close(sess); 119 continue; 120 } 121 usb_address_t address; 122 rc = usb_get_my_address(exch, &address); 123 async_exchange_end(exch); 124 usb_dev_session_close(sess); 125 if (rc != EOK) { 126 printf("Failed to get address for device %" PRIun 127 "\n", fhs[i]); 128 continue; 129 } 130 print_found_dev(address, path); 131 132 } 133 } 134 92 135 void list(void) 93 136 { … … 95 138 service_id_t *svcs; 96 139 size_t count; 97 size_t i;98 140 int rc; 99 141 … … 111 153 } 112 154 113 for ( i = 0; i < count; i++) {155 for (unsigned i = 0; i < count; ++i) { 114 156 devman_handle_t hc_handle = 0; 115 157 int rc = usb_ddf_get_hc_handle_by_sid(svcs[i], &hc_handle); … … 127 169 } 128 170 print_found_hc(svcs[i], path); 129 print_hc_devices(hc_handle); 171 (void)print_hc_devices; 172 173 // TODO replace this with something sane 174 char name[10]; 175 rc = devman_fun_get_name(hc_handle, name, 10); 176 if (rc != EOK) { 177 printf(NAME ": Error resolving name of HC with SID %" 178 PRIun ", skipping.\n", svcs[i]); 179 continue; 180 } 181 182 devman_handle_t fh; 183 path[str_size(path) - str_size(name) - 1] = '\0'; 184 rc = devman_fun_get_handle(path, &fh, IPC_FLAG_BLOCKING); 185 if (rc != EOK) { 186 printf(NAME ": Error resolving parent handle of HC with" 187 " SID %" PRIun ", skipping.\n", svcs[i]); 188 continue; 189 } 190 devman_handle_t dh; 191 rc = devman_fun_get_child(fh, &dh); 192 if (rc != EOK) { 193 printf(NAME ": Error resolving parent handle of HC with" 194 " SID %" PRIun ", skipping.\n", svcs[i]); 195 continue; 196 } 197 devman_handle_t *fhs = 0; 198 size_t count; 199 rc = devman_dev_get_functions(dh, &fhs, &count); 200 if (rc != EOK) { 201 printf(NAME ": Error siblings of HC with" 202 " SID %" PRIun ", skipping.\n", svcs[i]); 203 continue; 204 } 205 print_usb_devices(hc_handle, fhs, count); 206 free(fhs); 130 207 } 131 208
Note:
See TracChangeset
for help on using the changeset viewer.