These patches implement a modification of the USBTMC
protocol to allow operation with Rigol equipment. Ioctl change allowing test
and toggling of the status of the rigol_quirk bit.


Signed-off-by: Alexandre Peixoto Ferreira <[email protected]>
---
 drivers/usb/class/usbtmc.c   | 25 +++++++++++++++++++++++++
 include/uapi/linux/usb/tmc.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 609dbc2..20c0b88 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -154,6 +154,28 @@ static int usbtmc_release(struct inode *inode, struct file 
*file)
        return 0;
 }
 
+static int usbtmc_ioctl_rigol_quirk(struct usbtmc_device_data *data,unsigned 
long arg)
+{
+       struct device *dev;
+
+       dev = &data->intf->dev;
+
+       switch(arg) {
+       case 0 : /* RESET RIGOL QUIRK MODE IF SET */
+               data->rigol_quirk = 0;
+               return 0;
+       case 1 : /* RESET RIGOL QUIRK MODE IF SET */
+               data->rigol_quirk = 1;
+               return 0;
+       case 2 : /* Check it it is set */
+               if (data->rigol_quirk) 
+                       return 0;
+               else
+                       return -EINVAL;
+       }
+       return 0;
+}
+
 static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data)
 {
        u8 *buffer;
@@ -1067,6 +1089,9 @@ static long usbtmc_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
        case USBTMC_IOCTL_ABORT_BULK_IN:
                retval = usbtmc_ioctl_abort_bulk_in(data);
                break;
+       case USBTMC_IOCTL_RIGOL_QUIRK:
+               retval = usbtmc_ioctl_rigol_quirk(data,arg);
+               break;
        }
 
 skip_io_on_zombie:
diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index c045ae1..1787460 100644
--- a/include/uapi/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
@@ -39,5 +39,6 @@
 #define USBTMC_IOCTL_ABORT_BULK_IN     _IO(USBTMC_IOC_NR, 4)
 #define USBTMC_IOCTL_CLEAR_OUT_HALT    _IO(USBTMC_IOC_NR, 6)
 #define USBTMC_IOCTL_CLEAR_IN_HALT     _IO(USBTMC_IOC_NR, 7)
+#define USBTMC_IOCTL_RIGOL_QUIRK       _IO(USBTMC_IOC_NR, 8)
 
 #endif
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to