summaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/usbtmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/class/usbtmc.c')
-rw-r--r--drivers/usb/class/usbtmc.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index b4bd2411c66..7c5f4e32c92 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -347,13 +347,8 @@ usbtmc_abort_bulk_out_check_status:
goto exit;
usbtmc_abort_bulk_out_clear_halt:
- rv = usb_control_msg(data->usb_dev,
- usb_sndctrlpipe(data->usb_dev, 0),
- USB_REQ_CLEAR_FEATURE,
- USB_DIR_OUT | USB_TYPE_STANDARD |
- USB_RECIP_ENDPOINT,
- USB_ENDPOINT_HALT, data->bulk_out, buffer,
- 0, USBTMC_TIMEOUT);
+ rv = usb_clear_halt(data->usb_dev,
+ usb_sndbulkpipe(data->usb_dev, data->bulk_out));
if (rv < 0) {
dev_err(dev, "usb_control_msg returned %d\n", rv);
@@ -562,10 +557,16 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
n_bytes = roundup(12 + this_part, 4);
memset(buffer + 12 + this_part, 0, n_bytes - (12 + this_part));
- retval = usb_bulk_msg(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev,
- data->bulk_out),
- buffer, n_bytes, &actual, USBTMC_TIMEOUT);
+ do {
+ retval = usb_bulk_msg(data->usb_dev,
+ usb_sndbulkpipe(data->usb_dev,
+ data->bulk_out),
+ buffer, n_bytes,
+ &actual, USBTMC_TIMEOUT);
+ if (retval != 0)
+ break;
+ n_bytes -= actual;
+ } while (n_bytes);
data->bTag_last_write = data->bTag;
data->bTag++;
@@ -702,14 +703,8 @@ usbtmc_clear_check_status:
usbtmc_clear_bulk_out_halt:
- rv = usb_control_msg(data->usb_dev,
- usb_sndctrlpipe(data->usb_dev, 0),
- USB_REQ_CLEAR_FEATURE,
- USB_DIR_OUT | USB_TYPE_STANDARD |
- USB_RECIP_ENDPOINT,
- USB_ENDPOINT_HALT,
- data->bulk_out, buffer, 0,
- USBTMC_TIMEOUT);
+ rv = usb_clear_halt(data->usb_dev,
+ usb_sndbulkpipe(data->usb_dev, data->bulk_out));
if (rv < 0) {
dev_err(dev, "usb_control_msg returned %d\n", rv);
goto exit;
@@ -730,13 +725,8 @@ static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data)
if (!buffer)
return -ENOMEM;
- rv = usb_control_msg(data->usb_dev,
- usb_sndctrlpipe(data->usb_dev, 0),
- USB_REQ_CLEAR_FEATURE,
- USB_DIR_OUT | USB_TYPE_STANDARD |
- USB_RECIP_ENDPOINT,
- USB_ENDPOINT_HALT, data->bulk_out,
- buffer, 0, USBTMC_TIMEOUT);
+ rv = usb_clear_halt(data->usb_dev,
+ usb_sndbulkpipe(data->usb_dev, data->bulk_out));
if (rv < 0) {
dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
@@ -759,12 +749,8 @@ static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data)
if (!buffer)
return -ENOMEM;
- rv = usb_control_msg(data->usb_dev, usb_sndctrlpipe(data->usb_dev, 0),
- USB_REQ_CLEAR_FEATURE,
- USB_DIR_OUT | USB_TYPE_STANDARD |
- USB_RECIP_ENDPOINT,
- USB_ENDPOINT_HALT, data->bulk_in, buffer, 0,
- USBTMC_TIMEOUT);
+ rv = usb_clear_halt(data->usb_dev,
+ usb_rcvbulkpipe(data->usb_dev, data->bulk_in));
if (rv < 0) {
dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
@@ -1109,13 +1095,13 @@ static void usbtmc_disconnect(struct usb_interface *intf)
kref_put(&data->kref, usbtmc_delete);
}
-static int usbtmc_suspend (struct usb_interface *intf, pm_message_t message)
+static int usbtmc_suspend(struct usb_interface *intf, pm_message_t message)
{
/* this driver does not have pending URBs */
return 0;
}
-static int usbtmc_resume (struct usb_interface *intf)
+static int usbtmc_resume(struct usb_interface *intf)
{
return 0;
}