Revision ed3a328d usb-linux.c

b/usb-linux.c
823 823
    return configuration;
824 824
}
825 825

  
826
static uint8_t usb_linux_get_alt_setting(USBHostDevice *s,
827
    uint8_t configuration, uint8_t interface)
828
{
829
    uint8_t alt_setting;
830
    struct usb_ctrltransfer ct;
831
    int ret;
832

  
833
    ct.bRequestType = USB_DIR_IN | USB_RECIP_INTERFACE;
834
    ct.bRequest = USB_REQ_GET_INTERFACE;
835
    ct.wValue = 0;
836
    ct.wIndex = interface;
837
    ct.wLength = 1;
838
    ct.data = &alt_setting;
839
    ct.timeout = 50;
840
    ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
841
    if (ret < 0) {
842
        /* Assume alt 0 on error */
843
        return 0;
844
    }
845

  
846
    return alt_setting;
847
}
848

  
826 849
/* returns 1 on problem encountered or 0 for success */
827 850
static int usb_linux_update_endp_table(USBHostDevice *s)
828 851
{
829 852
    uint8_t *descriptors;
830 853
    uint8_t devep, type, configuration, alt_interface;
831
    struct usb_ctrltransfer ct;
832
    int interface, ret, length, i;
854
    int interface, length, i;
833 855

  
834 856
    i = usb_linux_get_configuration(s);
835 857
    if (i < 0)
......
858 880
        }
859 881

  
860 882
        interface = descriptors[i + 2];
861

  
862
        ct.bRequestType = USB_DIR_IN | USB_RECIP_INTERFACE;
863
        ct.bRequest = USB_REQ_GET_INTERFACE;
864
        ct.wValue = 0;
865
        ct.wIndex = interface;
866
        ct.wLength = 1;
867
        ct.data = &alt_interface;
868
        ct.timeout = 50;
869

  
870
        ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
871
        if (ret < 0) {
872
            alt_interface = interface;
873
        }
883
        alt_interface = usb_linux_get_alt_setting(s, configuration, interface);
874 884

  
875 885
        /* the current interface descriptor is the active interface
876 886
         * and has endpoints */

Also available in: Unified diff