usb: usbtmc: Add ioctl USBTMC_IOCTL_CANCEL_IO
authorGuido Kiener <guido@kiener-muenchen.de>
Wed, 12 Sep 2018 08:50:55 +0000 (10:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Sep 2018 11:04:02 +0000 (13:04 +0200)
ioctl USBTMC_IOCTL_CANCEL_IO stops and kills all flying urbs of
last USBTMC_IOCTL_READ and USBTMC_IOCTL_WRITE function calls.
A subsequent call to USBTMC_IOCTL_READ or
USBTMC_IOCTL_WRITE_RESULT returns -ECANCELED with
information about current transferred data.

Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Reviewed-by: Steve Bayless <steve_bayless@keysight.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/usbtmc.c
include/uapi/linux/usb/tmc.h

index 45ccdd087d6f30211dfbaaea8f6239121460fb28..0d8aa4bc3fa73e3a3440ed09aee38c768db7984d 100644 (file)
@@ -2126,6 +2126,10 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case USBTMC488_IOCTL_TRIGGER:
                retval = usbtmc488_ioctl_trigger(file_data);
                break;
+
+       case USBTMC_IOCTL_CANCEL_IO:
+               retval = usbtmc_ioctl_cancel_io(file_data);
+               break;
        }
 
 skip_io_on_zombie:
index f0fd0d4334ec7d588ca2445a8f2f8dea0452d04f..42e275d1d3850f1f818c8b5e1f7ff43837d30f07 100644 (file)
@@ -97,6 +97,9 @@ struct usbtmc_message {
 #define USBTMC488_IOCTL_LOCAL_LOCKOUT  _IO(USBTMC_IOC_NR, 21)
 #define USBTMC488_IOCTL_TRIGGER                _IO(USBTMC_IOC_NR, 22)
 
+/* Cancel and cleanup asynchronous calls */
+#define USBTMC_IOCTL_CANCEL_IO         _IO(USBTMC_IOC_NR, 35)
+
 /* Driver encoded usb488 capabilities */
 #define USBTMC488_CAPABILITY_TRIGGER         1
 #define USBTMC488_CAPABILITY_SIMPLE          2