Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/lsusb/main.c

    r5dfee52 r69ac0fd  
    4444#include <devman.h>
    4545#include <devmap.h>
    46 #include <usb/hub.h>
    4746#include <usb/host.h>
    4847
    4948#define NAME "lsusb"
    5049
    51 #define MAX_FAILED_ATTEMPTS 10
     50#define MAX_FAILED_ATTEMPTS 4
    5251#define MAX_PATH_LENGTH 1024
    53 
    54 static void print_found_hc(size_t class_index, const char *path)
    55 {
    56         // printf(NAME ": host controller %zu is `%s'.\n", class_index, path);
    57         printf("Bus %02zu: %s\n", class_index, path);
    58 }
    59 static void print_found_dev(usb_address_t addr, const char *path)
    60 {
    61         // printf(NAME ":     device with address %d is `%s'.\n", addr, path);
    62         printf("  Device %02d: %s\n", addr, path);
    63 }
    64 
    65 static void print_hc_devices(devman_handle_t hc_handle)
    66 {
    67         int rc;
    68         usb_hc_connection_t conn;
    69 
    70         usb_hc_connection_initialize(&conn, hc_handle);
    71         rc = usb_hc_connection_open(&conn);
    72         if (rc != EOK) {
    73                 printf(NAME ": failed to connect to HC: %s.\n",
    74                     str_error(rc));
    75                 return;
    76         }
    77         usb_address_t addr;
    78         for (addr = 1; addr < 5; addr++) {
    79                 devman_handle_t dev_handle;
    80                 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle);
    81                 if (rc != EOK) {
    82                         continue;
    83                 }
    84                 char path[MAX_PATH_LENGTH];
    85                 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH);
    86                 if (rc != EOK) {
    87                         continue;
    88                 }
    89                 print_found_dev(addr, path);
    90         }
    91         usb_hc_connection_close(&conn);
    92 }
    9352
    9453int main(int argc, char *argv[])
     
    11069                        continue;
    11170                }
    112                 print_found_hc(class_index, path);
    113                 print_hc_devices(hc_handle);
     71                printf(NAME ": host controller %zu is `%s'.\n",
     72                    class_index, path);
    11473        }
    11574
Note: See TracChangeset for help on using the changeset viewer.