Changeset cc5908e in mainline for uspace/app/lsusb/main.c
- Timestamp:
- 2011-05-07T14:28:51Z (13 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/lsusb/main.c
rbd2394b rcc5908e 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010-2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup usbvirtkbd29 /** @addtogroup lsusb 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief Keyboard configuration.34 * Listing of USB host controllers. 35 35 */ 36 37 #include <inttypes.h> 38 #include <stdio.h> 39 #include <stdlib.h> 36 40 #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> 40 47 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 53 int main(int argc, char *argv[]) 44 54 { 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; 53 57 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); 55 73 } 56 57 /* Let the framework handle all the rest. */ 58 return EFORWARD; 74 75 return 0; 59 76 } 60 61 77 62 78
Note:
See TracChangeset
for help on using the changeset viewer.