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


Ignore:
Timestamp:
2011-05-07T14:28:51Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
252cf2a, 68b614e
Parents:
bd2394b (diff), 7205209 (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:

Development changes merged

File:
1 moved

Legend:

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

    rbd2394b rcc5908e  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2010-2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup lsusb
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief Keyboard configuration.
     34 * Listing of USB host controllers.
    3535 */
     36
     37#include <inttypes.h>
     38#include <stdio.h>
     39#include <stdlib.h>
    3640#include <errno.h>
    37 #include <usb/descriptor.h>
    38 #include "stdreq.h"
    39 #include "kbdconfig.h"
     41#include <str_error.h>
     42#include <bool.h>
     43#include <getopt.h>
     44#include <devman.h>
     45#include <devmap.h>
     46#include <usb/host.h>
    4047
    41 int req_get_descriptor(usbvirt_device_t *device,
    42     const usb_device_request_setup_packet_t *setup_packet,
    43     uint8_t *data, size_t *act_size)
     48#define NAME "lsusb"
     49
     50#define MAX_FAILED_ATTEMPTS 4
     51#define MAX_PATH_LENGTH 1024
     52
     53int main(int argc, char *argv[])
    4454{
    45         if (setup_packet->value_high == USB_DESCTYPE_HID_REPORT) {
    46                 /*
    47                  * For simplicity, always return the same
    48                  * report descriptor.
    49                  */
    50                 usbvirt_control_reply_helper(setup_packet,
    51                     data, act_size,
    52                     report_descriptor, report_descriptor_size);
     55        size_t class_index = 0;
     56        size_t failed_attempts = 0;
    5357
    54                 return EOK;
     58        while (failed_attempts < MAX_FAILED_ATTEMPTS) {
     59                class_index++;
     60                devman_handle_t hc_handle = 0;
     61                int rc = usb_ddf_get_hc_handle_by_class(class_index, &hc_handle);
     62                if (rc != EOK) {
     63                        failed_attempts++;
     64                        continue;
     65                }
     66                char path[MAX_PATH_LENGTH];
     67                rc = devman_get_device_path(hc_handle, path, MAX_PATH_LENGTH);
     68                if (rc != EOK) {
     69                        continue;
     70                }
     71                printf(NAME ": host controller %zu is `%s'.\n",
     72                    class_index, path);
    5573        }
    56        
    57         /* Let the framework handle all the rest. */
    58         return EFORWARD;
     74
     75        return 0;
    5976}
    60 
    6177
    6278
Note: See TracChangeset for help on using the changeset viewer.