Changeset 07b39338 in mainline for uspace/app/lsusb/main.c


Ignore:
Timestamp:
2011-08-20T18:21:49Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ab014d
Parents:
0cf27ee (diff), f00af83 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

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

    r0cf27ee r07b39338  
    5050
    5151#define MAX_USB_ADDRESS USB11_ADDRESS_MAX
    52 #define MAX_FAILED_ATTEMPTS 10
    5352#define MAX_PATH_LENGTH 1024
    5453
    55 static void print_found_hc(size_t class_index, const char *path)
     54static void print_found_hc(service_id_t sid, const char *path)
    5655{
    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);
    5957}
    6058static void print_found_dev(usb_address_t addr, const char *path)
    6159{
    62         // printf(NAME ":     device with address %d is `%s'.\n", addr, path);
    6360        printf("  Device %02d: %s\n", addr, path);
    6461}
     
    8481                }
    8582                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);
    8784                if (rc != EOK) {
    8885                        continue;
     
    9592int main(int argc, char *argv[])
    9693{
    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;
    9999
    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++) {
    102114                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);
    104116                if (rc != EOK) {
    105                         failed_attempts++;
     117                        printf(NAME ": Error resolving handle of HC with SID %"
     118                            PRIun ", skipping.\n", svcs[i]);
    106119                        continue;
    107120                }
    108121                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);
    110123                if (rc != EOK) {
     124                        printf(NAME ": Error resolving path of HC with SID %"
     125                            PRIun ", skipping.\n", svcs[i]);
    111126                        continue;
    112127                }
    113                 print_found_hc(class_index, path);
     128                print_found_hc(svcs[i], path);
    114129                print_hc_devices(hc_handle);
    115130        }
     131
     132        free(svcs);
    116133
    117134        return 0;
Note: See TracChangeset for help on using the changeset viewer.