Skip to contentSkip to conversation

usb: usbtmc: Add ioctl for generic requests on control

PATCH New Greg Kroah-Hartman 1 participant 1 message Jul 21, 2018 USB

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH v2 8/29 usb: usbtmc: Add ioctl for generic requests on control

Quoted 36 lines · Guido Kiener

Add USBTMC_IOCTL_CTRL_REQUEST to send arbitrary requests on the control pipe. Used by specific applications of IVI Foundation, Inc. to implement VISA API functions: viUsbControlIn/Out.

The maximum length of control request is set to 4k.

---
 drivers/usb/class/usbtmc.c   | 151 +++++++++++++++++++++++++++++++++++
 include/uapi/linux/usb/tmc.h |  15 ++++
 2 files changed, 166 insertions(+)
drivers/usb/class/usbtmc.c +4 -0
index d685db78b80b..846599dd0c84 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
  * Copyright (C) 2008 Novell, Inc.
  * Copyright (C) 2008 Greg Kroah-Hartman <[email protected]>
+ * Copyright (C) 2018 IVI Foundation, Inc.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -36,6 +37,9 @@
 /* Default USB timeout (in milliseconds) */
 #define USBTMC_TIMEOUT		5000
 
+/* I/O buffer size used in generic read/write functions */
+#define USBTMC_BUFSIZE		(4096)
+
 /*
  * Maximum number of read cycles to empty bulk in endpoint during CLEAR and
  * ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short

drivers/usb/class/usbtmc.c struct usbtmc_file_data { · line 138

Quoted 9 lines
drivers/usb/class/usbtmc.c +6 -0
@@ -126,6 +130,17 @@ struct usbtmc_file_data {
 	bool           term_char_enabled;
 };
 
+#ifdef CONFIG_COMPAT
+
+struct compat_usbtmc_ctrlrequest {
+	struct usbtmc_request req;
+	compat_uptr_t data;
+} __packed;

Wait, why? You are creating a new api here, why do you need a 32bit compat layer? Just create it in a way that works for both layouts. Just make your pointer a 64bit value and cast it to the pointer when using it. Other ioctls do this in lots of places, making things simpler overall. That way you don't need an ioctl compat call at all.

Please rework the code that way, don't create new apis that have to add "old" 32bit compatibility support to them. That's just extra work you don't need to do here.

thanks,

greg k-h
---
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