Revision 5557d820

b/usb-linux.c
54 54
    void *data;
55 55
};
56 56

  
57
typedef int USBScanFunc(void *opaque, int bus_num, int addr, int devpath,
57
typedef int USBScanFunc(void *opaque, int bus_num, int addr, char *port,
58 58
                        int class_id, int vendor_id, int product_id,
59 59
                        const char *product_name, int speed);
60 60

  
......
71 71
#define USBPROCBUS_PATH "/proc/bus/usb"
72 72
#define PRODUCT_NAME_SZ 32
73 73
#define MAX_ENDPOINTS 15
74
#define MAX_PORTLEN 16
74 75
#define USBDEVBUS_PATH "/dev/bus/usb"
75 76
#define USBSYSBUS_PATH "/sys/bus/usb"
76 77

  
......
123 124
    /* Host side address */
124 125
    int bus_num;
125 126
    int addr;
126
    int devpath;
127
    char port[MAX_PORTLEN];
127 128
    struct USBAutoFilter match;
128 129

  
129 130
    QTAILQ_ENTRY(USBHostDevice) next;
......
836 837
        char device_name[32], line[1024];
837 838
        int configuration;
838 839

  
839
        sprintf(device_name, "%d-%d", s->bus_num, s->devpath);
840
        sprintf(device_name, "%d-%s", s->bus_num, s->port);
840 841

  
841 842
        if (!usb_host_read_file(line, sizeof(line), "bConfigurationValue",
842 843
                                device_name)) {
......
882 883
        char device_name[64], line[1024];
883 884
        int alt_setting;
884 885

  
885
        sprintf(device_name, "%d-%d:%d.%d", s->bus_num, s->devpath,
886
        sprintf(device_name, "%d-%s:%d.%d", s->bus_num, s->port,
886 887
                (int)configuration, (int)interface);
887 888

  
888 889
        if (!usb_host_read_file(line, sizeof(line), "bAlternateSetting",
......
1001 1002
}
1002 1003

  
1003 1004
static int usb_host_open(USBHostDevice *dev, int bus_num,
1004
                         int addr, int devpath, const char *prod_name)
1005
                         int addr, char *port, const char *prod_name)
1005 1006
{
1006 1007
    int fd = -1, ret;
1007 1008
    struct usbdevfs_connectinfo ci;
......
1027 1028

  
1028 1029
    dev->bus_num = bus_num;
1029 1030
    dev->addr = addr;
1030
    dev->devpath = devpath;
1031
    strcpy(dev->port, port);
1031 1032
    dev->fd = fd;
1032 1033

  
1033 1034
    /* read the device description */
......
1401 1402
{
1402 1403
    DIR *dir = NULL;
1403 1404
    char line[1024];
1404
    int bus_num, addr, devpath, speed, class_id, product_id, vendor_id;
1405
    int bus_num, addr, speed, class_id, product_id, vendor_id;
1405 1406
    int ret = 0;
1407
    char port[MAX_PORTLEN];
1406 1408
    char product_name[512];
1407 1409
    struct dirent *de;
1408 1410

  
......
1414 1416

  
1415 1417
    while ((de = readdir(dir))) {
1416 1418
        if (de->d_name[0] != '.' && !strchr(de->d_name, ':')) {
1417
            char *tmpstr = de->d_name;
1418
            if (!strncmp(de->d_name, "usb", 3)) {
1419
                tmpstr += 3;
1420
            }
1421
            if (sscanf(tmpstr, "%d-%d", &bus_num, &devpath) < 1) {
1422
                goto the_end;
1419
            if (sscanf(de->d_name, "%d-%7[0-9.]", &bus_num, port) < 2) {
1420
                continue;
1423 1421
            }
1424 1422

  
1425 1423
            if (!usb_host_read_file(line, sizeof(line), "devnum", de->d_name)) {
......
1471 1469
                speed = USB_SPEED_FULL;
1472 1470
            }
1473 1471

  
1474
            ret = func(opaque, bus_num, addr, devpath, class_id, vendor_id,
1472
            ret = func(opaque, bus_num, addr, port, class_id, vendor_id,
1475 1473
                       product_id, product_name, speed);
1476 1474
            if (ret) {
1477 1475
                goto the_end;
......
1562 1560

  
1563 1561
static QEMUTimer *usb_auto_timer;
1564 1562

  
1565
static int usb_host_auto_scan(void *opaque, int bus_num, int addr, int devpath,
1563
static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port,
1566 1564
                              int class_id, int vendor_id, int product_id,
1567 1565
                              const char *product_name, int speed)
1568 1566
{
......
1598 1596
        }
1599 1597
        DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
1600 1598

  
1601
        usb_host_open(s, bus_num, addr, devpath, product_name);
1599
        usb_host_open(s, bus_num, addr, port, product_name);
1602 1600
    }
1603 1601

  
1604 1602
    return 0;
......
1720 1718
    return p->class_name;
1721 1719
}
1722 1720

  
1723
static void usb_info_device(Monitor *mon, int bus_num, int addr, int class_id,
1724
                            int vendor_id, int product_id,
1721
static void usb_info_device(Monitor *mon, int bus_num, int addr, char *port,
1722
                            int class_id, int vendor_id, int product_id,
1725 1723
                            const char *product_name,
1726 1724
                            int speed)
1727 1725
{
......
1742 1740
        break;
1743 1741
    }
1744 1742

  
1745
    monitor_printf(mon, "  Device %d.%d, speed %s Mb/s\n",
1746
                bus_num, addr, speed_str);
1743
    monitor_printf(mon, "  Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
1744
                   bus_num, addr, port, speed_str);
1747 1745
    class_str = usb_class_str(class_id);
1748 1746
    if (class_str) {
1749 1747
        monitor_printf(mon, "    %s:", class_str);
......
1758 1756
}
1759 1757

  
1760 1758
static int usb_host_info_device(void *opaque, int bus_num, int addr,
1761
                                int devpath, int class_id,
1759
                                char *path, int class_id,
1762 1760
                                int vendor_id, int product_id,
1763 1761
                                const char *product_name,
1764 1762
                                int speed)
1765 1763
{
1766 1764
    Monitor *mon = opaque;
1767 1765

  
1768
    usb_info_device(mon, bus_num, addr, class_id, vendor_id, product_id,
1766
    usb_info_device(mon, bus_num, addr, path, class_id, vendor_id, product_id,
1769 1767
                    product_name, speed);
1770 1768
    return 0;
1771 1769
}

Also available in: Unified diff