Revision 3991c35e usb-linux.c

b/usb-linux.c
1056 1056
}
1057 1057

  
1058 1058
static int usb_host_open(USBHostDevice *dev, int bus_num,
1059
                         int addr, char *port, const char *prod_name)
1059
                        int addr, char *port, const char *prod_name, int speed)
1060 1060
{
1061 1061
    int fd = -1, ret;
1062
    struct usbdevfs_connectinfo ci;
1063 1062
    char buf[1024];
1064 1063

  
1065 1064
    if (dev->fd != -1) {
......
1114 1113
        goto fail;
1115 1114
    }
1116 1115

  
1117
    ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
1118
    if (ret < 0) {
1119
        perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
1120
        goto fail;
1121
    }
1122

  
1123
    printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
1124

  
1125 1116
    ret = usb_linux_update_endp_table(dev);
1126 1117
    if (ret) {
1127 1118
        goto fail;
1128 1119
    }
1129 1120

  
1130
    if (ci.slow) {
1131
        dev->dev.speed = USB_SPEED_LOW;
1132
    } else {
1133
        dev->dev.speed = USB_SPEED_HIGH;
1121
    if (speed == -1) {
1122
        struct usbdevfs_connectinfo ci;
1123

  
1124
        ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
1125
        if (ret < 0) {
1126
            perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
1127
            goto fail;
1128
        }
1129

  
1130
        if (ci.slow) {
1131
            speed = USB_SPEED_LOW;
1132
        } else {
1133
            speed = USB_SPEED_HIGH;
1134
        }
1134 1135
    }
1136
    dev->dev.speed = speed;
1137

  
1138
    printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
1135 1139

  
1136 1140
    if (!prod_name || prod_name[0] == '\0') {
1137 1141
        snprintf(dev->dev.product_desc, sizeof(dev->dev.product_desc),
......
1345 1349
    }
1346 1350

  
1347 1351
    device_count = 0;
1348
    bus_num = addr = speed = class_id = product_id = vendor_id = 0;
1352
    bus_num = addr = class_id = product_id = vendor_id = 0;
1353
    speed = -1; /* Can't get the speed from /[proc|dev]/bus/usb/devices */
1349 1354
    for(;;) {
1350 1355
        if (fgets(line, sizeof(line), f) == NULL) {
1351 1356
            break;
......
1655 1660
        }
1656 1661
        DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
1657 1662

  
1658
        usb_host_open(s, bus_num, addr, port, product_name);
1663
        usb_host_open(s, bus_num, addr, port, product_name, speed);
1659 1664
    }
1660 1665

  
1661 1666
    return 0;

Also available in: Unified diff