• Guido Kiener's avatar
    usb: usbtmc: Fix ioctl USBTMC_IOCTL_CLEAR · dfee02ac
    Guido Kiener authored
    Remove calculation of max_size (=wMaxPacketSize) and wrong
    condition (actual == max_size) in while loop. A device clear
    should always flush the complete Bulk-IN FIFO.
    
    Insert a sleep of 50 ms between subsequent CHECK_CLEAR_STATUS
    control requests to avoid stressing the instrument with
    repeated requests.
    
    Some instruments need time to cleanup internal I/O buffers.
    Polling and nonbraked requests slow down the response time of
    devices.
    
    Use USBTMC_BUFSIZE (4k) instead of USBTMC_SIZE_IOBUFFER (2k).
    Using USBTMC_SIZE_IOBUFFER is deprecated.
    
    Check only bit 0 (field bmClear) of the CHECK_CLEAR_STATUS
    response, since other bits are reserved and can change in
    future versions.
    Signed-off-by: default avatarGuido Kiener <guido.kiener@rohde-schwarz.com>
    Reviewed-by: default avatarSteve Bayless <steve_bayless@keysight.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    dfee02ac
usbtmc.c 62.6 KB