Changeset e280857 in mainline for uspace/app/lsusb/main.c


Ignore:
Timestamp:
2011-08-18T12:35:59Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99ac5cf
Parents:
12f9f0d0
Message:

Remove class infrastructure from devman.

File:
1 edited

Legend:

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

    r12f9f0d0 re280857  
    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{
    5756        // printf(NAME ": host controller %zu is `%s'.\n", class_index, path);
    58         printf("Bus %02zu: %s\n", class_index, path);
     57        printf("Bus %" PRIun ": %s\n", sid, path);
    5958}
    6059static void print_found_dev(usb_address_t addr, const char *path)
     
    9594int main(int argc, char *argv[])
    9695{
    97         size_t class_index = 0;
    98         size_t failed_attempts = 0;
     96        category_id_t usbhc_cat;
     97        service_id_t *svcs;
     98        size_t count;
     99        size_t i;
     100        int rc;
    99101
    100         while (failed_attempts < MAX_FAILED_ATTEMPTS) {
    101                 class_index++;
     102        rc = loc_category_get_id(USB_HC_DDF_CLASS_NAME, &usbhc_cat, 0);
     103        if (rc != EOK) {
     104                printf(NAME ": Error resolving category '%s'",
     105                    USB_HC_DDF_CLASS_NAME);
     106                return 1;
     107        }
     108
     109        rc = loc_category_get_svcs(usbhc_cat, &svcs, &count);
     110        if (rc != EOK) {
     111                printf(NAME ": Error getting list of host controllers.\n");
     112                return 1;
     113        }
     114
     115        for (i = 0; i < count; i++) {
    102116                devman_handle_t hc_handle = 0;
    103                 int rc = usb_ddf_get_hc_handle_by_class(class_index, &hc_handle);
     117                int rc = usb_ddf_get_hc_handle_by_sid(svcs[i], &hc_handle);
    104118                if (rc != EOK) {
    105                         failed_attempts++;
     119                        printf(NAME ": Error resolving handle of HC with SID %"
     120                            PRIun ", skipping.\n", svcs[i]);
    106121                        continue;
    107122                }
     
    109124                rc = devman_get_device_path(hc_handle, path, MAX_PATH_LENGTH);
    110125                if (rc != EOK) {
     126                        printf(NAME ": Error resolving path of HC with SID %"
     127                            PRIun ", skipping.\n", svcs[i]);
    111128                        continue;
    112129                }
    113                 print_found_hc(class_index, path);
     130                print_found_hc(svcs[i], path);
    114131                print_hc_devices(hc_handle);
    115132        }
     133
     134        free(svcs);
    116135
    117136        return 0;
Note: See TracChangeset for help on using the changeset viewer.