@@ -1754,34 +1754,80 @@ static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
return rv;
}
+/*
+ * set pipe in halt state (stalled)
+ * Needed for test purpose or workarounds.
+ */
+static int usbtmc_set_halt(struct usb_device *dev, int pipe)
+{
+ int rv;
+ int endp = usb_pipeendpoint(pipe);
+
+ if (usb_pipein(pipe))
+ endp |= USB_DIR_IN;
+
+ rv = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+ USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
+ USB_ENDPOINT_HALT, endp, NULL, 0,
+ USB_CTRL_SET_TIMEOUT);
+
+ return rv;
+}
+
+static int usbtmc_ioctl_set_out_halt(struct usbtmc_device_data *data)
+{
+ int rv;
+
+ dev_dbg(&data->intf->dev, "%s - called\n", __func__);
+
+ rv = usbtmc_set_halt(data->usb_dev,
+ usb_sndbulkpipe(data->usb_dev, data->bulk_out));
+
+ if (rv < 0)
+ dev_err(&data->usb_dev->dev, "%s returned %d\n", __func__, rv);
+ return rv;
+}
+
+static int usbtmc_ioctl_set_in_halt(struct usbtmc_device_data *data)
+{
+ int rv;
+
+ dev_dbg(&data->intf->dev, "%s - called\n", __func__);
+
+ rv = usbtmc_set_halt(data->usb_dev,
+ usb_rcvbulkpipe(data->usb_dev, data->bulk_in));
+
+ if (rv < 0)
+ dev_err(&data->usb_dev->dev, "%s returned %d\n", __func__, rv);
+ return rv;
+}
+
static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data)
{
int rv;
+ dev_dbg(&data->intf->dev, "%s - called\n", __func__);
+
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",
- rv);
- return rv;
- }
- return 0;
+ if (rv < 0)
+ dev_err(&data->usb_dev->dev, "%s returned %d\n", __func__, rv);
+ return rv;
}
static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data)
{
int rv;
+ dev_dbg(&data->intf->dev, "%s - called\n", __func__);
+
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",
- rv);
- return rv;
- }
- return 0;
+ if (rv < 0)
+ dev_err(&data->usb_dev->dev, "%s returned %d\n", __func__, rv);
+ return rv;
}
static int usbtmc_ioctl_cancel_io(struct usbtmc_file_data *file_data)
@@ -2241,6 +2287,14 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
file_data->auto_abort = !!tmp_byte;
break;
+ case USBTMC_IOCTL_SET_OUT_HALT:
+ retval = usbtmc_ioctl_set_out_halt(data);
+ break;
+
+ case USBTMC_IOCTL_SET_IN_HALT:
+ retval = usbtmc_ioctl_set_in_halt(data);
+ break;
+
case USBTMC_IOCTL_CANCEL_IO:
retval = usbtmc_ioctl_cancel_io(file_data);
break;
@@ -101,6 +101,10 @@ struct usbtmc_message {
#define USBTMC_IOCTL_MSG_IN_ATTR _IOR(USBTMC_IOC_NR, 24, __u8)
#define USBTMC_IOCTL_AUTO_ABORT _IOW(USBTMC_IOC_NR, 25, __u8)
+/* For test purpose only */
+#define USBTMC_IOCTL_SET_OUT_HALT _IO(USBTMC_IOC_NR, 30)
+#define USBTMC_IOCTL_SET_IN_HALT _IO(USBTMC_IOC_NR, 31)
+
/* Cancel and cleanup asynchronous calls */
#define USBTMC_IOCTL_CANCEL_IO _IO(USBTMC_IOC_NR, 35)
#define USBTMC_IOCTL_CLEANUP_IO _IO(USBTMC_IOC_NR, 36)