Changeset a81a1d09 in mainline for uspace/app/usbinfo


Ignore:
Timestamp:
2011-05-11T16:49:28Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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 development/ changes

Location:
uspace/app/usbinfo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/Makefile

    re1dbcbc ra81a1d09  
    3030BINARY = usbinfo
    3131
    32 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBDRV_PREFIX)/libdrv.a
    33 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include
     32LIBS = \
     33        $(LIBUSBDEV_PREFIX)/libusbdev.a \
     34        $(LIBUSB_PREFIX)/libusb.a \
     35        $(LIBDRV_PREFIX)/libdrv.a
     36EXTRA_CFLAGS = \
     37        -I$(LIBUSB_PREFIX)/include \
     38        -I$(LIBUSBDEV_PREFIX)/include \
     39        -I$(LIBDRV_PREFIX)/include
    3440
    3541SOURCES = \
  • uspace/app/usbinfo/dev.c

    re1dbcbc ra81a1d09  
    4040#include "usbinfo.h"
    4141
    42 usbinfo_device_t *prepare_device(devman_handle_t hc_handle,
    43     usb_address_t dev_addr)
     42usbinfo_device_t *prepare_device(const char *name,
     43    devman_handle_t hc_handle, usb_address_t dev_addr)
    4444{
    4545        usbinfo_device_t *dev = malloc(sizeof(usbinfo_device_t));
     
    5555        if (rc != EOK) {
    5656                fprintf(stderr,
    57                     NAME ": failed to create connection to the device: %s.\n",
    58                     str_error(rc));
     57                    NAME ": failed to create connection to device %s: %s.\n",
     58                    name, str_error(rc));
    5959                goto leave;
    6060        }
     
    6464        if (rc != EOK) {
    6565                fprintf(stderr,
    66                     NAME ": failed to create default control pipe: %s.\n",
    67                     str_error(rc));
     66                    NAME ": failed to create default control pipe to %s: %s.\n",
     67                    name, str_error(rc));
    6868                goto leave;
    6969        }
     
    7171        rc = usb_pipe_probe_default_control(&dev->ctrl_pipe);
    7272        if (rc != EOK) {
    73                 fprintf(stderr,
    74                     NAME ": probing default control pipe failed: %s.\n",
    75                     str_error(rc));
     73                if (rc == ENOENT) {
     74                        fprintf(stderr, NAME ": " \
     75                            "device %s not present or malfunctioning.\n",
     76                            name);
     77                } else {
     78                        fprintf(stderr, NAME ": " \
     79                            "probing default control pipe of %s failed: %s.\n",
     80                            name, str_error(rc));
     81                }
    7682                goto leave;
    7783        }
     
    8490        if (rc != EOK) {
    8591                fprintf(stderr,
    86                     NAME ": failed to retrieve device descriptor: %s.\n",
    87                     str_error(rc));
     92                    NAME ": failed to retrieve device descriptor of %s: %s.\n",
     93                    name, str_error(rc));
    8894                goto leave;
    8995        }
     
    9399            &dev->full_configuration_descriptor_size);
    94100        if (rc != EOK) {
    95                 fprintf(stderr,
    96                     NAME ": failed to retrieve configuration descriptor: %s.\n",
    97                     str_error(rc));
     101                fprintf(stderr, NAME ": " \
     102                    "failed to retrieve configuration descriptor of %s: %s.\n",
     103                    name, str_error(rc));
    98104                goto leave;
    99105        }
  • uspace/app/usbinfo/info.c

    re1dbcbc ra81a1d09  
    4141#include <usb/request.h>
    4242#include <usb/classes/classes.h>
    43 #include <usb/classes/hid.h>
    4443#include <usb/classes/hub.h>
    4544#include "usbinfo.h"
  • uspace/app/usbinfo/main.c

    re1dbcbc ra81a1d09  
    4545#include <usb/usbdevice.h>
    4646#include <usb/pipes.h>
     47#include <usb/host.h>
     48#include <usb/driver.h>
    4749#include "usbinfo.h"
     50
     51static bool try_parse_class_and_address(const char *path,
     52    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
     53{
     54        size_t class_index;
     55        size_t address;
     56        int rc;
     57        char *ptr;
     58
     59        rc = str_size_t(path, &ptr, 10, false, &class_index);
     60        if (rc != EOK) {
     61                return false;
     62        }
     63        if ((*ptr == ':') || (*ptr == '.')) {
     64                ptr++;
     65        } else {
     66                return false;
     67        }
     68        rc = str_size_t(ptr, NULL, 10, true, &address);
     69        if (rc != EOK) {
     70                return false;
     71        }
     72        rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
     73        if (rc != EOK) {
     74                return false;
     75        }
     76        if (out_device_address != NULL) {
     77                *out_device_address = (usb_address_t) address;
     78        }
     79        return true;
     80}
    4881
    4982static bool resolve_hc_handle_and_dev_addr(const char *devpath,
     
    6093        if (str_cmp(devpath, "virt") == 0) {
    6194                devpath = "/virt/usbhc/usb00_a1/usb00_a2";
     95        }
     96
     97        if (try_parse_class_and_address(devpath,
     98            out_hc_handle, out_device_address)) {
     99                return true;
    62100        }
    63101
     
    271309                }
    272310
    273                 usbinfo_device_t *dev = prepare_device(hc_handle, dev_addr);
     311                usbinfo_device_t *dev = prepare_device(devpath,
     312                    hc_handle, dev_addr);
    274313                if (dev == NULL) {
    275314                        continue;
  • uspace/app/usbinfo/usbinfo.h

    re1dbcbc ra81a1d09  
    7171}
    7272
    73 usbinfo_device_t *prepare_device(devman_handle_t, usb_address_t);
     73usbinfo_device_t *prepare_device(const char *, devman_handle_t, usb_address_t);
    7474void destroy_device(usbinfo_device_t *);
    7575
Note: See TracChangeset for help on using the changeset viewer.