Commit 0e59088e authored by Guido Kiener's avatar Guido Kiener Committed by Greg Kroah-Hartman

usb: usbtmc: Fix ioctl USBTMC_IOCTL_ABORT_BULK_OUT

Add parameter 'tag' to function usbtmc_ioctl_abort_bulk_out_tag()
for future versions.

Use USBTMC_BUFSIZE (4k) instead of USBTMC_SIZE_IOBUFFER (2k).
Using USBTMC_SIZE_IOBUFFER is deprecated.

Insert a sleep of 50 ms between subsequent
CHECK_ABORT_BULK_OUT_STATUS control requests to avoid stressing
the instrument with repeated requests.

Use common macro USB_CTRL_GET_TIMEOUT instead of USBTMC_TIMEOUT.
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>
parent cbe743f1
...@@ -398,7 +398,8 @@ static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data) ...@@ -398,7 +398,8 @@ static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data)
return usbtmc_ioctl_abort_bulk_in_tag(data, data->bTag_last_read); return usbtmc_ioctl_abort_bulk_in_tag(data, data->bTag_last_read);
} }
static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) static int usbtmc_ioctl_abort_bulk_out_tag(struct usbtmc_device_data *data,
u8 tag)
{ {
struct device *dev; struct device *dev;
u8 *buffer; u8 *buffer;
...@@ -415,8 +416,8 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) ...@@ -415,8 +416,8 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
usb_rcvctrlpipe(data->usb_dev, 0), usb_rcvctrlpipe(data->usb_dev, 0),
USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT, USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
data->bTag_last_write, data->bulk_out, tag, data->bulk_out,
buffer, 2, USBTMC_TIMEOUT); buffer, 2, USB_CTRL_GET_TIMEOUT);
if (rv < 0) { if (rv < 0) {
dev_err(dev, "usb_control_msg returned %d\n", rv); dev_err(dev, "usb_control_msg returned %d\n", rv);
...@@ -435,12 +436,14 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) ...@@ -435,12 +436,14 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
n = 0; n = 0;
usbtmc_abort_bulk_out_check_status: usbtmc_abort_bulk_out_check_status:
/* do not stress device with subsequent requests */
msleep(50);
rv = usb_control_msg(data->usb_dev, rv = usb_control_msg(data->usb_dev,
usb_rcvctrlpipe(data->usb_dev, 0), usb_rcvctrlpipe(data->usb_dev, 0),
USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS, USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
0, data->bulk_out, buffer, 0x08, 0, data->bulk_out, buffer, 0x08,
USBTMC_TIMEOUT); USB_CTRL_GET_TIMEOUT);
n++; n++;
if (rv < 0) { if (rv < 0) {
dev_err(dev, "usb_control_msg returned %d\n", rv); dev_err(dev, "usb_control_msg returned %d\n", rv);
...@@ -474,6 +477,11 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) ...@@ -474,6 +477,11 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
return rv; return rv;
} }
static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
{
return usbtmc_ioctl_abort_bulk_out_tag(data, data->bTag_last_write);
}
static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data, static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
void __user *arg) void __user *arg)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment